@mendable/search
Version:
A React component for integrating Mendable Search into your application.
1 lines • 770 kB
JavaScript
"use strict";var e=require("react"),t=require("react-dom");function n(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var r=n(e),o=function(){return o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},o.apply(this,arguments)};function i(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function a(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{l(r.next(e))}catch(e){i(e)}}function s(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((r=r.apply(e,t||[])).next())}))}function s(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function l(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}var c=Object.defineProperty,u=(e,t,n)=>(((e,t,n)=>{t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!=typeof t?t+"":t,n),n);let p=new class{constructor(){u(this,"current",this.detect()),u(this,"handoffState","pending"),u(this,"currentId",0)}set(e){this.current!==e&&(this.handoffState="pending",this.currentId=0,this.current=e)}reset(){this.set(this.detect())}nextId(){return++this.currentId}get isServer(){return"server"===this.current}get isClient(){return"client"===this.current}detect(){return"undefined"==typeof window||"undefined"==typeof document?"server":"client"}handoff(){"pending"===this.handoffState&&(this.handoffState="complete")}get isHandoffComplete(){return"complete"===this.handoffState}},d=(t,n)=>{p.isServer?e.useEffect(t,n):e.useLayoutEffect(t,n)};function f(t){let n=e.useRef(t);return d((()=>{n.current=t}),[t]),n}function m(e){"function"==typeof queueMicrotask?queueMicrotask(e):Promise.resolve().then(e).catch((e=>setTimeout((()=>{throw e}))))}function h(){let e=[],t=[],n={enqueue(e){t.push(e)},addEventListener:(e,t,r,o)=>(e.addEventListener(t,r,o),n.add((()=>e.removeEventListener(t,r,o)))),requestAnimationFrame(...e){let t=requestAnimationFrame(...e);return n.add((()=>cancelAnimationFrame(t)))},nextFrame:(...e)=>n.requestAnimationFrame((()=>n.requestAnimationFrame(...e))),setTimeout(...e){let t=setTimeout(...e);return n.add((()=>clearTimeout(t)))},microTask(...e){let t={current:!0};return m((()=>{t.current&&e[0]()})),n.add((()=>{t.current=!1}))},add:t=>(e.push(t),()=>{let n=e.indexOf(t);if(n>=0){let[t]=e.splice(n,1);t()}}),dispose(){for(let t of e.splice(0))t()},async workQueue(){for(let e of t.splice(0))await e()},style(e,t,n){let r=e.style.getPropertyValue(t);return Object.assign(e.style,{[t]:n}),this.add((()=>{Object.assign(e.style,{[t]:r})}))}};return n}function g(){let[t]=e.useState(h);return e.useEffect((()=>()=>t.dispose()),[t]),t}let y=function(t){let n=f(t);return e.useCallback(((...e)=>n.current(...e)),[n])};function v(){let[t,n]=e.useState(p.isHandoffComplete);return t&&!1===p.isHandoffComplete&&n(!1),e.useEffect((()=>{!0!==t&&n(!0)}),[t]),e.useEffect((()=>p.handoff()),[]),t}var b;let w=null!=(b=e.useId)?b:function(){let t=v(),[n,r]=e.useState(t?()=>p.nextId():null);return d((()=>{null===n&&r(p.nextId())}),[n]),null!=n?""+n:void 0};function k(e,t,...n){if(e in t){let r=t[e];return"function"==typeof r?r(...n):r}let r=new Error(`Tried to handle "${e}" but there is no handler defined. Only defined handlers are: ${Object.keys(t).map((e=>`"${e}"`)).join(", ")}.`);throw Error.captureStackTrace&&Error.captureStackTrace(r,k),r}function x(e){return p.isServer?null:e instanceof Node?e.ownerDocument:null!=e&&e.hasOwnProperty("current")&&e.current instanceof Node?e.current.ownerDocument:document}let _=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].map((e=>`${e}:not([tabindex='-1'])`)).join(",");var S=(e=>(e[e.First=1]="First",e[e.Previous=2]="Previous",e[e.Next=4]="Next",e[e.Last=8]="Last",e[e.WrapAround=16]="WrapAround",e[e.NoScroll=32]="NoScroll",e))(S||{}),E=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))(E||{}),C=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(C||{});var O=(e=>(e[e.Strict=0]="Strict",e[e.Loose=1]="Loose",e))(O||{});function A(e){null==e||e.focus({preventScroll:!0})}let T=["textarea","input"].join(",");function P(e,t,{sorted:n=!0,relativeTo:r=null,skipElements:o=[]}={}){let i=Array.isArray(e)?e.length>0?e[0].ownerDocument:document:e.ownerDocument,a=Array.isArray(e)?n?function(e,t=(e=>e)){return e.slice().sort(((e,n)=>{let r=t(e),o=t(n);if(null===r||null===o)return 0;let i=r.compareDocumentPosition(o);return i&Node.DOCUMENT_POSITION_FOLLOWING?-1:i&Node.DOCUMENT_POSITION_PRECEDING?1:0}))}(e):e:function(e=document.body){return null==e?[]:Array.from(e.querySelectorAll(_)).sort(((e,t)=>Math.sign((e.tabIndex||Number.MAX_SAFE_INTEGER)-(t.tabIndex||Number.MAX_SAFE_INTEGER))))}(e);o.length>0&&a.length>1&&(a=a.filter((e=>!o.includes(e)))),r=null!=r?r:i.activeElement;let s,l=(()=>{if(5&t)return 1;if(10&t)return-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),c=(()=>{if(1&t)return 0;if(2&t)return Math.max(0,a.indexOf(r))-1;if(4&t)return Math.max(0,a.indexOf(r))+1;if(8&t)return a.length-1;throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last")})(),u=32&t?{preventScroll:!0}:{},p=0,d=a.length;do{if(p>=d||p+d<=0)return 0;let e=c+p;if(16&t)e=(e+d)%d;else{if(e<0)return 3;if(e>=d)return 1}s=a[e],null==s||s.focus(u),p+=l}while(s!==i.activeElement);return 6&t&&function(e){var t,n;return null!=(n=null==(t=null==e?void 0:e.matches)?void 0:t.call(e,T))&&n}(s)&&s.select(),s.hasAttribute("tabindex")||s.setAttribute("tabindex","0"),2}function N(t,n,r){let o=f(n);e.useEffect((()=>{function e(e){o.current(e)}return document.addEventListener(t,e,r),()=>document.removeEventListener(t,e,r)}),[t,r])}function F(t,n,r=!0){let o=e.useRef(!1);function i(e,r){if(!o.current||e.defaultPrevented)return;let i=function e(t){return"function"==typeof t?e(t()):Array.isArray(t)||t instanceof Set?t:[t]}(t),a=r(e);if(null!==a&&a.getRootNode().contains(a)){for(let t of i){if(null===t)continue;let n=t instanceof HTMLElement?t:t.current;if(null!=n&&n.contains(a)||e.composed&&e.composedPath().includes(n))return}return!function(e,t=0){var n;return e!==(null==(n=x(e))?void 0:n.body)&&k(t,{0:()=>e.matches(_),1(){let t=e;for(;null!==t;){if(t.matches(_))return!0;t=t.parentElement}return!1}})}(a,O.Loose)&&-1!==a.tabIndex&&e.preventDefault(),n(e,a)}}e.useEffect((()=>{requestAnimationFrame((()=>{o.current=r}))}),[r]);let a=e.useRef(null);N("mousedown",(e=>{var t,n;o.current&&(a.current=(null==(n=null==(t=e.composedPath)?void 0:t.call(e))?void 0:n[0])||e.target)}),!0),N("click",(e=>{!a.current||(i(e,(()=>a.current)),a.current=null)}),!0),N("blur",(e=>i(e,(()=>window.document.activeElement instanceof HTMLIFrameElement?window.document.activeElement:null))),!0)}let I=Symbol();function R(...t){let n=e.useRef(t);e.useEffect((()=>{n.current=t}),[t]);let r=y((e=>{for(let t of n.current)null!=t&&("function"==typeof t?t(e):t.current=e)}));return t.every((e=>null==e||(null==e?void 0:e[I])))?void 0:r}function L(...e){return e.filter(Boolean).join(" ")}var D=(e=>(e[e.None=0]="None",e[e.RenderStrategy=1]="RenderStrategy",e[e.Static=2]="Static",e))(D||{}),M=(e=>(e[e.Unmount=0]="Unmount",e[e.Hidden=1]="Hidden",e))(M||{});function j({ourProps:e,theirProps:t,slot:n,defaultTag:r,features:o,visible:i=!0,name:a}){let s=z(t,e);if(i)return B(s,n,r,a);let l=null!=o?o:0;if(2&l){let{static:e=!1,...t}=s;if(e)return B(t,n,r,a)}if(1&l){let{unmount:e=!0,...t}=s;return k(e?0:1,{0:()=>null,1:()=>B({...t,hidden:!0,style:{display:"none"}},n,r,a)})}return B(s,n,r,a)}function B(t,n={},r,o){var i;let{as:a=r,children:s,refName:l="ref",...c}=H(t,["unmount","static"]),u=void 0!==t.ref?{[l]:t.ref}:{},p="function"==typeof s?s(n):s;c.className&&"function"==typeof c.className&&(c.className=c.className(n));let d={};if(n){let e=!1,t=[];for(let[r,o]of Object.entries(n))"boolean"==typeof o&&(e=!0),!0===o&&t.push(r);e&&(d["data-headlessui-state"]=t.join(" "))}if(a===e.Fragment&&Object.keys($(c)).length>0){if(!e.isValidElement(p)||Array.isArray(p)&&p.length>1)throw new Error(['Passing props on "Fragment"!',"",`The current component <${o} /> is rendering a "Fragment".`,"However we need to passthrough the following props:",Object.keys(c).map((e=>` - ${e}`)).join("\n"),"","You can apply a few solutions:",['Add an `as="..."` prop, to ensure that we render an actual element instead of a "Fragment".',"Render a single element as the child so that we can forward the props onto that element."].map((e=>` - ${e}`)).join("\n")].join("\n"));let t=L(null==(i=p.props)?void 0:i.className,c.className),n=t?{className:t}:{};return e.cloneElement(p,Object.assign({},z(p.props,$(H(c,["ref"]))),d,u,function(...e){return{ref:e.every((e=>null==e))?void 0:t=>{for(let n of e)null!=n&&("function"==typeof n?n(t):n.current=t)}}}(p.ref,u.ref),n))}return e.createElement(a,Object.assign({},H(c,["ref"]),a!==e.Fragment&&u,a!==e.Fragment&&d),p)}function z(...e){if(0===e.length)return{};if(1===e.length)return e[0];let t={},n={};for(let r of e)for(let e in r)e.startsWith("on")&&"function"==typeof r[e]?(null!=n[e]||(n[e]=[]),n[e].push(r[e])):t[e]=r[e];if(t.disabled||t["aria-disabled"])return Object.assign(t,Object.fromEntries(Object.keys(n).map((e=>[e,void 0]))));for(let e in n)Object.assign(t,{[e](t,...r){let o=n[e];for(let e of o){if((t instanceof Event||(null==t?void 0:t.nativeEvent)instanceof Event)&&t.defaultPrevented)return;e(t,...r)}}});return t}function q(t){var n;return Object.assign(e.forwardRef(t),{displayName:null!=(n=t.displayName)?n:t.name})}function $(e){let t=Object.assign({},e);for(let e in t)void 0===t[e]&&delete t[e];return t}function H(e,t=[]){let n=Object.assign({},e);for(let e of t)e in n&&delete n[e];return n}function U(e){let t=e.parentElement,n=null;for(;t&&!(t instanceof HTMLFieldSetElement);)t instanceof HTMLLegendElement&&(n=t),t=t.parentElement;let r=""===(null==t?void 0:t.getAttribute("disabled"));return(!r||!function(e){if(!e)return!1;let t=e.previousElementSibling;for(;null!==t;){if(t instanceof HTMLLegendElement)return!1;t=t.previousElementSibling}return!0}(n))&&r}var V=(e=>(e[e.None=1]="None",e[e.Focusable=2]="Focusable",e[e.Hidden=4]="Hidden",e))(V||{});let G=q((function(e,t){let{features:n=1,...r}=e;return j({ourProps:{ref:t,"aria-hidden":2==(2&n)||void 0,style:{position:"fixed",top:1,left:1,width:1,height:0,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0",...4==(4&n)&&2!=(2&n)&&{display:"none"}}},theirProps:r,slot:{},defaultTag:"div",name:"Hidden"})})),W=e.createContext(null);W.displayName="OpenClosedContext";var K=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(K||{});function Y(){return e.useContext(W)}function X({value:t,children:n}){return e.createElement(W.Provider,{value:t},n)}var Z=(e=>(e.Space=" ",e.Enter="Enter",e.Escape="Escape",e.Backspace="Backspace",e.Delete="Delete",e.ArrowLeft="ArrowLeft",e.ArrowUp="ArrowUp",e.ArrowRight="ArrowRight",e.ArrowDown="ArrowDown",e.Home="Home",e.End="End",e.PageUp="PageUp",e.PageDown="PageDown",e.Tab="Tab",e))(Z||{});function Q(t,n){let r=e.useRef([]),o=y(t);e.useEffect((()=>{let e=[...r.current];for(let[t,i]of n.entries())if(r.current[t]!==i){let t=o(n,e);return r.current=n,t}}),[o,...n])}var J=(e=>(e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards",e))(J||{});function ee(){let t=e.useRef(0);return function(t,n,r){let o=f(n);e.useEffect((()=>{function e(e){o.current(e)}return window.addEventListener(t,e,r),()=>window.removeEventListener(t,e,r)}),[t,r])}("keydown",(e=>{"Tab"===e.key&&(t.current=e.shiftKey?1:0)}),!0),t}function te(){let t=e.useRef(!1);return d((()=>(t.current=!0,()=>{t.current=!1})),[]),t}function ne(...t){return e.useMemo((()=>x(...t)),[...t])}function re(t,n,r,o){let i=f(r);e.useEffect((()=>{function e(e){i.current(e)}return(t=null!=t?t:window).addEventListener(n,e,o),()=>t.removeEventListener(n,e,o)}),[t,n,o])}var oe=(e=>(e[e.None=1]="None",e[e.InitialFocus=2]="InitialFocus",e[e.TabLock=4]="TabLock",e[e.FocusLock=8]="FocusLock",e[e.RestoreFocus=16]="RestoreFocus",e[e.All=30]="All",e))(oe||{});let ie=Object.assign(q((function(t,n){let r=e.useRef(null),o=R(r,n),{initialFocus:i,containers:a,features:s=30,...l}=t;v()||(s=1);let c=ne(r);!function({ownerDocument:t},n){let r=e.useRef(null);re(null==t?void 0:t.defaultView,"focusout",(e=>{!n||r.current||(r.current=e.target)}),!0),Q((()=>{n||((null==t?void 0:t.activeElement)===(null==t?void 0:t.body)&&A(r.current),r.current=null)}),[n]);let o=e.useRef(!1);e.useEffect((()=>(o.current=!1,()=>{o.current=!0,m((()=>{!o.current||(A(r.current),r.current=null)}))})),[])}({ownerDocument:c},Boolean(16&s));let u=function({ownerDocument:t,container:n,initialFocus:r},o){let i=e.useRef(null),a=te();return Q((()=>{if(!o)return;let e=n.current;!e||m((()=>{if(!a.current)return;let n=null==t?void 0:t.activeElement;if(null!=r&&r.current){if((null==r?void 0:r.current)===n)return void(i.current=n)}else if(e.contains(n))return void(i.current=n);null!=r&&r.current?A(r.current):P(e,S.First)===E.Error&&console.warn("There are no focusable elements inside the <FocusTrap />"),i.current=null==t?void 0:t.activeElement}))}),[o]),i}({ownerDocument:c,container:r,initialFocus:i},Boolean(2&s));!function({ownerDocument:e,container:t,containers:n,previousActiveElement:r},o){let i=te();re(null==e?void 0:e.defaultView,"focus",(e=>{if(!o||!i.current)return;let a=new Set(null==n?void 0:n.current);a.add(t);let s=r.current;if(!s)return;let l=e.target;l&&l instanceof HTMLElement?ae(a,l)?(r.current=l,A(l)):(e.preventDefault(),e.stopPropagation(),A(s)):A(r.current)}),!0)}({ownerDocument:c,container:r,containers:a,previousActiveElement:u},Boolean(8&s));let p=ee(),d=y((e=>{let t=r.current;t&&k(p.current,{[J.Forwards]:()=>{P(t,S.First,{skipElements:[e.relatedTarget]})},[J.Backwards]:()=>{P(t,S.Last,{skipElements:[e.relatedTarget]})}})})),f=g(),h=e.useRef(!1),b={ref:o,onKeyDown(e){"Tab"==e.key&&(h.current=!0,f.requestAnimationFrame((()=>{h.current=!1})))},onBlur(e){let t=new Set(null==a?void 0:a.current);t.add(r);let n=e.relatedTarget;n instanceof HTMLElement&&"true"!==n.dataset.headlessuiFocusGuard&&(ae(t,n)||(h.current?P(r.current,k(p.current,{[J.Forwards]:()=>S.Next,[J.Backwards]:()=>S.Previous})|S.WrapAround,{relativeTo:e.target}):e.target instanceof HTMLElement&&A(e.target)))}};return e.createElement(e.Fragment,null,Boolean(4&s)&&e.createElement(G,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:d,features:V.Focusable}),j({ourProps:b,theirProps:l,defaultTag:"div",name:"FocusTrap"}),Boolean(4&s)&&e.createElement(G,{as:"button",type:"button","data-headlessui-focus-guard":!0,onFocus:d,features:V.Focusable}))})),{features:oe});function ae(e,t){var n;for(let r of e)if(null!=(n=r.current)&&n.contains(t))return!0;return!1}let se=new Set,le=new Map;function ce(e){e.setAttribute("aria-hidden","true"),e.inert=!0}function ue(e){let t=le.get(e);!t||(null===t["aria-hidden"]?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",t["aria-hidden"]),e.inert=t.inert)}let pe=e.createContext(!1);function de(){return e.useContext(pe)}function fe(t){return e.createElement(pe.Provider,{value:t.force},t.children)}let me=e.Fragment,he=q((function(n,r){let o=n,i=e.useRef(null),a=R(function(e,t=!0){return Object.assign(e,{[I]:t})}((e=>{i.current=e})),r),s=ne(i),l=function(t){let n=de(),r=e.useContext(ye),o=ne(t),[i,a]=e.useState((()=>{if(!n&&null!==r||p.isServer)return null;let e=null==o?void 0:o.getElementById("headlessui-portal-root");if(e)return e;if(null===o)return null;let t=o.createElement("div");return t.setAttribute("id","headlessui-portal-root"),o.body.appendChild(t)}));return e.useEffect((()=>{null!==i&&(null!=o&&o.body.contains(i)||null==o||o.body.appendChild(i))}),[i,o]),e.useEffect((()=>{n||null!==r&&a(r.current)}),[r,a,n]),i}(i),[c]=e.useState((()=>{var e;return p.isServer?null:null!=(e=null==s?void 0:s.createElement("div"))?e:null})),u=v(),f=e.useRef(!1);return d((()=>{if(f.current=!1,l&&c)return l.contains(c)||(c.setAttribute("data-headlessui-portal",""),l.appendChild(c)),()=>{f.current=!0,m((()=>{var e;!f.current||!l||!c||(c instanceof Node&&l.contains(c)&&l.removeChild(c),l.childNodes.length<=0&&(null==(e=l.parentElement)||e.removeChild(l)))}))}}),[l,c]),u&&l&&c?t.createPortal(j({ourProps:{ref:a},theirProps:o,defaultTag:me,name:"Portal"}),c):null})),ge=e.Fragment,ye=e.createContext(null),ve=q((function(t,n){let{target:r,...o}=t,i={ref:R(n)};return e.createElement(ye.Provider,{value:r},j({ourProps:i,theirProps:o,defaultTag:ge,name:"Popover.Group"}))})),be=Object.assign(he,{Group:ve}),we=e.createContext(null);function ke(){let t=e.useContext(we);if(null===t){let e=new Error("You used a <Description /> component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(e,ke),e}return t}let xe=q((function(e,t){let n=w(),{id:r=`headlessui-description-${n}`,...o}=e,i=ke(),a=R(t);return d((()=>i.register(r)),[r,i.register]),j({ourProps:{ref:a,...i.props,id:r},theirProps:o,slot:i.slot||{},defaultTag:"p",name:i.name||"Description"})})),_e=e.createContext((()=>{}));_e.displayName="StackContext";var Se=(e=>(e[e.Add=0]="Add",e[e.Remove=1]="Remove",e))(Se||{});function Ee({children:t,onUpdate:n,type:r,element:o,enabled:i}){let a=e.useContext(_e),s=y(((...e)=>{null==n||n(...e),a(...e)}));return d((()=>{let e=void 0===i||!0===i;return e&&s(0,r,o),()=>{e&&s(1,r,o)}}),[s,r,o,i]),e.createElement(_e.Provider,{value:s},t)}const Ce="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},{useState:Oe,useEffect:Ae,useLayoutEffect:Te,useDebugValue:Pe}=r;function Ne(e){const t=e.getSnapshot,n=e.value;try{const e=t();return!Ce(n,e)}catch{return!0}}const Fe=!("undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement)?function(e,t,n){return t()}:function(e,t,n){const r=t(),[{inst:o},i]=Oe({inst:{value:r,getSnapshot:t}});return Te((()=>{o.value=r,o.getSnapshot=t,Ne(o)&&i({inst:o})}),[e,r,t]),Ae((()=>(Ne(o)&&i({inst:o}),e((()=>{Ne(o)&&i({inst:o})})))),[e]),Pe(r),r},Ie="useSyncExternalStore"in r?r.useSyncExternalStore:Fe;function Re(){let e;return{before({doc:t}){var n;let r=t.documentElement;e=(null!=(n=t.defaultView)?n:window).innerWidth-r.clientWidth},after({doc:t,d:n}){let r=t.documentElement,o=r.clientWidth-r.offsetWidth,i=e-o;n.style(r,"paddingRight",`${i}px`)}}}function Le(){if(!(/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0))return{};let e;return{before(){e=window.pageYOffset},after({doc:t,d:n,meta:r}){function o(e){return r.containers.flatMap((e=>e())).some((t=>t.contains(e)))}n.style(t.body,"marginTop",`-${e}px`),window.scrollTo(0,0);let i=null;n.addEventListener(t,"click",(e=>{if(e.target instanceof HTMLElement)try{let n=e.target.closest("a");if(!n)return;let{hash:r}=new URL(n.href),a=t.querySelector(r);a&&!o(a)&&(i=a)}catch{}}),!0),n.addEventListener(t,"touchmove",(e=>{e.target instanceof HTMLElement&&!o(e.target)&&e.preventDefault()}),{passive:!1}),n.add((()=>{window.scrollTo(0,window.pageYOffset+e),i&&i.isConnected&&(i.scrollIntoView({block:"nearest"}),i=null)}))}}}function De(e){let t={};for(let n of e)Object.assign(t,n(t));return t}let Me=function(e,t){let n=e(),r=new Set;return{getSnapshot:()=>n,subscribe:e=>(r.add(e),()=>r.delete(e)),dispatch(e,...o){let i=t[e].call(n,...o);i&&(n=i,r.forEach((e=>e())))}}}((()=>new Map),{PUSH(e,t){var n;let r=null!=(n=this.get(e))?n:{doc:e,count:0,d:h(),meta:new Set};return r.count++,r.meta.add(t),this.set(e,r),this},POP(e,t){let n=this.get(e);return n&&(n.count--,n.meta.delete(t)),this},SCROLL_PREVENT({doc:e,d:t,meta:n}){let r={doc:e,d:t,meta:De(n)},o=[Le(),Re(),{before({doc:e,d:t}){t.style(e.documentElement,"overflow","hidden")}}];o.forEach((({before:e})=>null==e?void 0:e(r))),o.forEach((({after:e})=>null==e?void 0:e(r)))},SCROLL_ALLOW({d:e}){e.dispose()},TEARDOWN({doc:e}){this.delete(e)}});function je(e,t,n){let r=function(e){return Ie(e.subscribe,e.getSnapshot,e.getSnapshot)}(Me),o=e?r.get(e):void 0,i=!!o&&o.count>0;return d((()=>{if(e&&t)return Me.dispatch("PUSH",e,n),()=>Me.dispatch("POP",e,n)}),[t,e]),i}Me.subscribe((()=>{let e=Me.getSnapshot(),t=new Map;for(let[n]of e)t.set(n,n.documentElement.style.overflow);for(let n of e.values()){let e="hidden"===t.get(n.doc),r=0!==n.count;(r&&!e||!r&&e)&&Me.dispatch(n.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",n),0===n.count&&Me.dispatch("TEARDOWN",n)}}));var Be=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(Be||{}),ze=(e=>(e[e.SetTitleId=0]="SetTitleId",e))(ze||{});let qe={0:(e,t)=>e.titleId===t.id?e:{...e,titleId:t.id}},$e=e.createContext(null);function He(t){let n=e.useContext($e);if(null===n){let e=new Error(`<${t} /> is missing a parent <Dialog /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(e,He),e}return n}function Ue(e,t){return k(t.type,qe,e,t)}$e.displayName="DialogContext";let Ve=D.RenderStrategy|D.Static,Ge=q((function(t,n){let r=w(),{id:o=`headlessui-dialog-${r}`,open:i,onClose:a,initialFocus:s,__demoMode:l=!1,...c}=t,[u,p]=e.useState(0),f=Y();void 0===i&&null!==f&&(i=(f&K.Open)===K.Open);let m=e.useRef(new Set),h=e.useRef(null),g=R(h,n),b=e.useRef(null),_=ne(h),S=t.hasOwnProperty("open")||null!==f,E=t.hasOwnProperty("onClose");if(!S&&!E)throw new Error("You have to provide an `open` and an `onClose` prop to the `Dialog` component.");if(!S)throw new Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");if(!E)throw new Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");if("boolean"!=typeof i)throw new Error(`You provided an \`open\` prop to the \`Dialog\`, but the value is not a boolean. Received: ${i}`);if("function"!=typeof a)throw new Error(`You provided an \`onClose\` prop to the \`Dialog\`, but the value is not a function. Received: ${a}`);let C=i?0:1,[O,A]=e.useReducer(Ue,{titleId:null,descriptionId:null,panelRef:e.createRef()}),T=y((()=>a(!1))),P=y((e=>A({type:0,id:e}))),N=!!v()&&(!l&&0===C),I=u>1,L=null!==e.useContext($e),D=I?"parent":"leaf",M=null!==f&&(f&K.Closing)===K.Closing;!function(e,t=!0){d((()=>{if(!t||!e.current)return;let n=e.current,r=x(n);if(r){se.add(n);for(let e of le.keys())e.contains(n)&&(ue(e),le.delete(e));return r.querySelectorAll("body > *").forEach((e=>{if(e instanceof HTMLElement){for(let t of se)if(e.contains(t))return;1===se.size&&(le.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),ce(e))}})),()=>{if(se.delete(n),se.size>0)r.querySelectorAll("body > *").forEach((e=>{if(e instanceof HTMLElement&&!le.has(e)){for(let t of se)if(e.contains(t))return;le.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),ce(e)}}));else for(let e of le.keys())ue(e),le.delete(e)}}}),[t])}(h,!(!I||M)&&N);let B=y((()=>{var e,t;return[...Array.from(null!=(e=null==_?void 0:_.querySelectorAll("html > *, body > *, [data-headlessui-portal]"))?e:[]).filter((e=>!(e===document.body||e===document.head||!(e instanceof HTMLElement)||e.contains(b.current)||O.panelRef.current&&e.contains(O.panelRef.current)))),null!=(t=O.panelRef.current)?t:h.current]}));F((()=>B()),T,!(!N||I));let z=!(I||0!==C);re(null==_?void 0:_.defaultView,"keydown",(e=>{!z||e.defaultPrevented||e.key===Z.Escape&&(e.preventDefault(),e.stopPropagation(),T())})),function(e,t,n=(()=>[document.body])){je(e,t,(e=>{var t;return{containers:[...null!=(t=e.containers)?t:[],n]}}))}(_,!(M||0!==C||L),B),e.useEffect((()=>{if(0!==C||!h.current)return;let e=new IntersectionObserver((e=>{for(let t of e)0===t.boundingClientRect.x&&0===t.boundingClientRect.y&&0===t.boundingClientRect.width&&0===t.boundingClientRect.height&&T()}));return e.observe(h.current),()=>e.disconnect()}),[C,h,T]);let[q,$]=function(){let[t,n]=e.useState([]);return[t.length>0?t.join(" "):void 0,e.useMemo((()=>function(t){let r=y((e=>(n((t=>[...t,e])),()=>n((t=>{let n=t.slice(),r=n.indexOf(e);return-1!==r&&n.splice(r,1),n}))))),o=e.useMemo((()=>({register:r,slot:t.slot,name:t.name,props:t.props})),[r,t.slot,t.name,t.props]);return e.createElement(we.Provider,{value:o},t.children)}),[n])]}(),H=e.useMemo((()=>[{dialogState:C,close:T,setTitleId:P},O]),[C,O,T,P]),U=e.useMemo((()=>({open:0===C})),[C]),W={ref:g,id:o,role:"dialog","aria-modal":0===C||void 0,"aria-labelledby":O.titleId,"aria-describedby":q};return e.createElement(Ee,{type:"Dialog",enabled:0===C,element:h,onUpdate:y(((e,t,n)=>{"Dialog"===t&&k(e,{[Se.Add](){m.current.add(n),p((e=>e+1))},[Se.Remove](){m.current.add(n),p((e=>e-1))}})}))},e.createElement(fe,{force:!0},e.createElement(be,null,e.createElement($e.Provider,{value:H},e.createElement(be.Group,{target:h},e.createElement(fe,{force:!1},e.createElement($,{slot:U,name:"Dialog.Description"},e.createElement(ie,{initialFocus:s,containers:m,features:N?k(D,{parent:ie.features.RestoreFocus,leaf:ie.features.All&~ie.features.FocusLock}):ie.features.None},j({ourProps:W,theirProps:c,slot:U,defaultTag:"div",features:Ve,visible:0===C,name:"Dialog"})))))))),e.createElement(G,{features:V.Hidden,ref:b}))})),We=q((function(t,n){let r=w(),{id:o=`headlessui-dialog-overlay-${r}`,...i}=t,[{dialogState:a,close:s}]=He("Dialog.Overlay"),l=R(n),c=y((e=>{if(e.target===e.currentTarget){if(U(e.currentTarget))return e.preventDefault();e.preventDefault(),e.stopPropagation(),s()}}));return j({ourProps:{ref:l,id:o,"aria-hidden":!0,onClick:c},theirProps:i,slot:e.useMemo((()=>({open:0===a})),[a]),defaultTag:"div",name:"Dialog.Overlay"})})),Ke=q((function(t,n){let r=w(),{id:o=`headlessui-dialog-backdrop-${r}`,...i}=t,[{dialogState:a},s]=He("Dialog.Backdrop"),l=R(n);e.useEffect((()=>{if(null===s.panelRef.current)throw new Error("A <Dialog.Backdrop /> component is being used, but a <Dialog.Panel /> component is missing.")}),[s.panelRef]);let c=e.useMemo((()=>({open:0===a})),[a]);return e.createElement(fe,{force:!0},e.createElement(be,null,j({ourProps:{ref:l,id:o,"aria-hidden":!0},theirProps:i,slot:c,defaultTag:"div",name:"Dialog.Backdrop"})))})),Ye=q((function(t,n){let r=w(),{id:o=`headlessui-dialog-panel-${r}`,...i}=t,[{dialogState:a},s]=He("Dialog.Panel"),l=R(n,s.panelRef),c=e.useMemo((()=>({open:0===a})),[a]),u=y((e=>{e.stopPropagation()}));return j({ourProps:{ref:l,id:o,onClick:u},theirProps:i,slot:c,defaultTag:"div",name:"Dialog.Panel"})})),Xe=q((function(t,n){let r=w(),{id:o=`headlessui-dialog-title-${r}`,...i}=t,[{dialogState:a,setTitleId:s}]=He("Dialog.Title"),l=R(n);e.useEffect((()=>(s(o),()=>s(null))),[o,s]);let c=e.useMemo((()=>({open:0===a})),[a]);return j({ourProps:{ref:l,id:o},theirProps:i,slot:c,defaultTag:"h2",name:"Dialog.Title"})})),Ze=Object.assign(Ge,{Backdrop:Ke,Panel:Ye,Overlay:We,Title:Xe,Description:xe});function Qe(e,...t){e&&t.length>0&&e.classList.add(...t)}function Je(e,...t){e&&t.length>0&&e.classList.remove(...t)}function et(e,t,n,r){let o=n?"enter":"leave",i=h(),a=void 0!==r?function(e){let t={called:!1};return(...n)=>{if(!t.called)return t.called=!0,e(...n)}}(r):()=>{};"enter"===o&&(e.removeAttribute("hidden"),e.style.display="");let s=k(o,{enter:()=>t.enter,leave:()=>t.leave}),l=k(o,{enter:()=>t.enterTo,leave:()=>t.leaveTo}),c=k(o,{enter:()=>t.enterFrom,leave:()=>t.leaveFrom});return Je(e,...t.enter,...t.enterTo,...t.enterFrom,...t.leave,...t.leaveFrom,...t.leaveTo,...t.entered),Qe(e,...s,...c),i.nextFrame((()=>{Je(e,...c),Qe(e,...l),function(e,t){let n=h();if(!e)return n.dispose;let{transitionDuration:r,transitionDelay:o}=getComputedStyle(e),[i,a]=[r,o].map((e=>{let[t=0]=e.split(",").filter(Boolean).map((e=>e.includes("ms")?parseFloat(e):1e3*parseFloat(e))).sort(((e,t)=>t-e));return t}));if(i+a!==0){let r=n.addEventListener(e,"transitionend",(e=>{e.target===e.currentTarget&&(t(),r())}))}else t();n.add((()=>t())),n.dispose}(e,(()=>(Je(e,...s),Qe(e,...t.entered),a())))})),i.dispose}function tt(e=""){return e.split(" ").filter((e=>e.trim().length>1))}let nt=e.createContext(null);nt.displayName="TransitionContext";var rt=(e=>(e.Visible="visible",e.Hidden="hidden",e))(rt||{});let ot=e.createContext(null);function it(e){return"children"in e?it(e.children):e.current.filter((({el:e})=>null!==e.current)).filter((({state:e})=>"visible"===e)).length>0}function at(t,n){let r=f(t),o=e.useRef([]),i=te(),a=g(),s=y(((e,t=M.Hidden)=>{let n=o.current.findIndex((({el:t})=>t===e));-1!==n&&(k(t,{[M.Unmount](){o.current.splice(n,1)},[M.Hidden](){o.current[n].state="hidden"}}),a.microTask((()=>{var e;!it(o)&&i.current&&(null==(e=r.current)||e.call(r))})))})),l=y((e=>{let t=o.current.find((({el:t})=>t===e));return t?"visible"!==t.state&&(t.state="visible"):o.current.push({el:e,state:"visible"}),()=>s(e,M.Unmount)})),c=e.useRef([]),u=e.useRef(Promise.resolve()),p=e.useRef({enter:[],leave:[],idle:[]}),d=y(((e,t,r)=>{c.current.splice(0),n&&(n.chains.current[t]=n.chains.current[t].filter((([t])=>t!==e))),null==n||n.chains.current[t].push([e,new Promise((e=>{c.current.push(e)}))]),null==n||n.chains.current[t].push([e,new Promise((e=>{Promise.all(p.current[t].map((([e,t])=>t))).then((()=>e()))}))]),"enter"===t?u.current=u.current.then((()=>null==n?void 0:n.wait.current)).then((()=>r(t))):r(t)})),m=y(((e,t,n)=>{Promise.all(p.current[t].splice(0).map((([e,t])=>t))).then((()=>{var e;null==(e=c.current.shift())||e()})).then((()=>n(t)))}));return e.useMemo((()=>({children:o,register:l,unregister:s,onStart:d,onStop:m,wait:u,chains:p})),[l,s,o,d,m,p,u])}function st(){}ot.displayName="NestingContext";let lt=["beforeEnter","afterEnter","beforeLeave","afterLeave"];function ct(e){var t;let n={};for(let r of lt)n[r]=null!=(t=e[r])?t:st;return n}let ut=D.RenderStrategy,pt=q((function(t,n){let{beforeEnter:r,afterEnter:o,beforeLeave:i,afterLeave:a,enter:s,enterFrom:l,enterTo:c,entered:u,leave:m,leaveFrom:b,leaveTo:w,...x}=t,_=e.useRef(null),S=R(_,n),E=x.unmount?M.Unmount:M.Hidden,{show:C,appear:O,initial:A}=function(){let t=e.useContext(nt);if(null===t)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return t}(),[T,P]=e.useState(C?"visible":"hidden"),N=function(){let t=e.useContext(ot);if(null===t)throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");return t}(),{register:F,unregister:I}=N,D=e.useRef(null);e.useEffect((()=>F(_)),[F,_]),e.useEffect((()=>{if(E===M.Hidden&&_.current)return C&&"visible"!==T?void P("visible"):k(T,{hidden:()=>I(_),visible:()=>F(_)})}),[T,_,F,I,C,E]);let B=f({enter:tt(s),enterFrom:tt(l),enterTo:tt(c),entered:tt(u),leave:tt(m),leaveFrom:tt(b),leaveTo:tt(w)}),z=function(t){let n=e.useRef(ct(t));return e.useEffect((()=>{n.current=ct(t)}),[t]),n}({beforeEnter:r,afterEnter:o,beforeLeave:i,afterLeave:a}),q=v();e.useEffect((()=>{if(q&&"visible"===T&&null===_.current)throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?")}),[_,T,q]);let $=A&&!O,H=!q||$||D.current===C?"idle":C?"enter":"leave",U=function(t=0){let[n,r]=e.useState(t),o=e.useCallback((e=>r((t=>t|e))),[n]),i=e.useCallback((e=>Boolean(n&e)),[n]),a=e.useCallback((e=>r((t=>t&~e))),[r]),s=e.useCallback((e=>r((t=>t^e))),[r]);return{flags:n,addFlag:o,hasFlag:i,removeFlag:a,toggleFlag:s}}(0),V=y((e=>k(e,{enter:()=>{U.addFlag(K.Opening),z.current.beforeEnter()},leave:()=>{U.addFlag(K.Closing),z.current.beforeLeave()},idle:()=>{}}))),G=y((e=>k(e,{enter:()=>{U.removeFlag(K.Opening),z.current.afterEnter()},leave:()=>{U.removeFlag(K.Closing),z.current.afterLeave()},idle:()=>{}}))),W=at((()=>{P("hidden"),I(_)}),N);(function({container:e,direction:t,classes:n,onStart:r,onStop:o}){let i=te(),a=g(),s=f(t);d((()=>{let t=h();a.add(t.dispose);let l=e.current;if(l&&"idle"!==s.current&&i.current)return t.dispose(),r.current(s.current),t.add(et(l,n.current,"enter"===s.current,(()=>{t.dispose(),o.current(s.current)}))),t.dispose}),[t])})({container:_,classes:B,direction:H,onStart:f((e=>{W.onStart(_,e,V)})),onStop:f((e=>{W.onStop(_,e,G),"leave"===e&&!it(W)&&(P("hidden"),I(_))}))}),e.useEffect((()=>{!$||(E===M.Hidden?D.current=null:D.current=C)}),[C,$,T]);let Y=x,Z={ref:S};return O&&C&&p.isServer&&(Y={...Y,className:L(x.className,...B.current.enter,...B.current.enterFrom)}),e.createElement(ot.Provider,{value:W},e.createElement(X,{value:k(T,{visible:K.Open,hidden:K.Closed})|U.flags},j({ourProps:Z,theirProps:Y,defaultTag:"div",features:ut,visible:"visible"===T,name:"Transition.Child"})))})),dt=q((function(t,n){let{show:r,appear:o=!1,unmount:i,...a}=t,s=e.useRef(null),l=R(s,n);v();let c=Y();if(void 0===r&&null!==c&&(r=(c&K.Open)===K.Open),![!0,!1].includes(r))throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");let[u,p]=e.useState(r?"visible":"hidden"),f=at((()=>{p("hidden")})),[m,h]=e.useState(!0),g=e.useRef([r]);d((()=>{!1!==m&&g.current[g.current.length-1]!==r&&(g.current.push(r),h(!1))}),[g,r]);let y=e.useMemo((()=>({show:r,appear:o,initial:m})),[r,o,m]);e.useEffect((()=>{if(r)p("visible");else if(it(f)){let e=s.current;if(!e)return;let t=e.getBoundingClientRect();0===t.x&&0===t.y&&0===t.width&&0===t.height&&p("hidden")}else p("hidden")}),[r,f]);let b={unmount:i};return e.createElement(ot.Provider,{value:f},e.createElement(nt.Provider,{value:y},j({ourProps:{...b,as:e.Fragment,children:e.createElement(pt,{ref:l,...b,...a})},theirProps:{},defaultTag:e.Fragment,features:ut,visible:"visible"===u,name:"Transition"})))})),ft=q((function(t,n){let r=null!==e.useContext(nt),o=null!==Y();return e.createElement(e.Fragment,null,!r&&o?e.createElement(dt,{ref:n,...t}):e.createElement(pt,{ref:n,...t}))})),mt=Object.assign(dt,{Child:ft,Root:dt});var ht,gt={darkMode:!0,accentColor:"#8559F4"},yt={backgroundColor:"#1a1a1a",borderColor:"#6B728033",color:"#e1e3e7",shadow:!1,showShortcut:!0},vt={backgroundColor:"#fff",borderColor:"#6B728033",color:"#9ca3af",shadow:!1,showShortcut:!0},bt={color:"#ffffff",backgroundColor:"#8559F4"},wt={openSourcesInNewTab:!1,prettySources:!1,persistMessagesBetweenSessions:!1,scrollToView:!0,sourcesFirst:!1,sourcesDisplay:"short"},kt={showStopGeneratingButton:!0};!function(e){e.NoDocs="noDocs",e.FullDocs="fullDocs",e.None="none",e.Error="error"}(ht||(ht={}));var xt="https://api.mendable.ai/v1",_t="0.0.206",St="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Et(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Ct(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];return n.push.apply(n,arguments),new(Function.bind.apply(t,n))}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var Ot={},At={get exports(){return Ot},set exports(e){Ot=e}};var Tt,Pt={},Nt={get exports(){return Pt},set exports(e){Pt=e}},Ft=Ct(Object.freeze({__proto__:null,default:{}}));function It(){return Tt||(Tt=1,Nt.exports=function(){var e=e||function(e,t){var n;if("undefined"!=typeof window&&window.crypto&&(n=window.crypto),"undefined"!=typeof self&&self.crypto&&(n=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(n=globalThis.crypto),!n&&"undefined"!=typeof window&&window.msCrypto&&(n=window.msCrypto),!n&&void 0!==St&&St.crypto&&(n=St.crypto),!n)try{n=Ft}catch(e){}var r=function(){if(n){if("function"==typeof n.getRandomValues)try{return n.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof n.randomBytes)try{return n.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),i={},a=i.lib={},s=a.Base={extend:function(e){var t=o(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},l=a.WordArray=s.extend({init:function(e,n){e=this.words=e||[],this.sigBytes=n!=t?n:4*e.length},toString:function(e){return(e||u).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes,o=e.sigBytes;if(this.clamp(),r%4)for(var i=0;i<o;i++){var a=n[i>>>2]>>>24-i%4*8&255;t[r+i>>>2]|=a<<24-(r+i)%4*8}else for(var s=0;s<o;s+=4)t[r+s>>>2]=n[s>>>2];return this.sigBytes+=o,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=s.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n<e;n+=4)t.push(r());return new l.init(t,e)}}),c=i.enc={},u=c.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],o=0;o<n;o++){var i=t[o>>>2]>>>24-o%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new l.init(n,t/2)}},p=c.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],o=0;o<n;o++){var i=t[o>>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(i))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new l.init(n,t)}},d=c.Utf8={stringify:function(e){try{return decodeURIComponent(escape(p.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return p.parse(unescape(encodeURIComponent(e)))}},f=a.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new l.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=d.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n,r=this._data,o=r.words,i=r.sigBytes,a=this.blockSize,s=i/(4*a),c=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*a,u=e.min(4*c,i);if(c){for(var p=0;p<c;p+=a)this._doProcessBlock(o,p);n=o.splice(0,c),r.sigBytes-=u}return new l.init(n,u)},clone:function(){var e=s.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});a.Hasher=f.extend({cfg:s.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){f.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new m.HMAC.init(e,n).finalize(t)}}});var m=i.algo={};return i}(Math);return e}()),Pt}var Rt,Lt={},Dt={get exports(){return Lt},set exports(e){Lt=e}};function Mt(){return Rt||(Rt=1,Dt.exports=function(e){return function(t){var n=e,r=n.lib,o=r.Base,i=r.WordArray,a=n.x64={};a.Word=o.extend({init:function(e,t){this.high=e,this.low=t}}),a.WordArray=o.extend({init:function(e,n){e=this.words=e||[],this.sigBytes=n!=t?n:8*e.length},toX32:function(){for(var e=this.words,t=e.length,n=[],r=0;r<t;r++){var o=e[r];n.push(o.high),n.push(o.low)}return i.create(n,this.sigBytes)},clone:function(){for(var e=o.clone.call(this),t=e.words=this.words.slice(0),n=t.length,r=0;r<n;r++)t[r]=t[r].clone();return e}})}(),e}(It())),Lt}var jt,Bt={},zt={get exports(){return Bt},set exports(e){Bt=e}};function qt(){return jt||(jt=1,zt.exports=function(e){return function(){if("function"==typeof ArrayBuffer){var t=e.lib.WordArray,n=t.init,r=t.init=function(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),(e instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)&&(e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),e instanceof Uint8Array){for(var t=e.byteLength,r=[],o=0;o<t;o++)r[o>>>2]|=e[o]<<24-o%4*8;n.call(this,r,t)}else n.apply(this,arguments)};r.prototype=t}}(),e.lib.WordArray}(It())),Bt}var $t,Ht={},Ut={get exports(){return Ht},set exports(e){Ht=e}};function Vt(){return $t||($t=1,Ut.exports=function(e){return function(){var t=e,n=t.lib.WordArray,r=t.enc;function o(e){return e<<8&4278255360|e>>>8&16711935}r.Utf16=r.Utf16BE={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],o=0;o<n;o+=2){var i=t[o>>>2]>>>16-o%4*8&65535;r.push(String.fromCharCode(i))}return r.join("")},parse:function(e){for(var t=e.length,r=[],o=0;o<t;o++)r[o>>>1]|=e.charCodeAt(o)<<16-o%2*16;return n.create(r,2*t)}},r.Utf16LE={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i+=2){var a=o(t[i>>>2]>>>16-i%4*8&65535);r.push(String.fromCharCode(a))}return r.join("")},parse:function(e){for(var t=e.length,r=[],i=0;i<t;i++)r[i>>>1]|=o(e.charCodeAt(i)<<16-i%2*16);return n.create(r,2*t)}}}(),e.enc.Utf16}(It())),Ht}var Gt,Wt={},Kt={get exports(){return Wt},set exports(e){Wt=e}};function Yt(){return Gt||(Gt=1,Kt.exports=function(e){return function(){var t=e,n=t.lib.WordArray;function r(e,t,r){for(var o=[],i=0,a=0;a<t;a++)if(a%4){var s=r[e.charCodeAt(a-1)]<<a%4*2|r[e.charCodeAt(a)]>>>6-a%4*2;o[i>>>2]|=s<<24-i%4*8,i++}return n.create(o,i)}t.enc.Base64={stringify:function(e){var t=e.words,n=e.sigBytes,r=this._map;e.clamp();for(var o=[],i=0;i<n;i+=3)for(var a=(t[i>>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,s=0;s<4&&i+.75*s<n;s++)o.push(r.charAt(a>>>6*(3-s)&63));var l=r.charAt(64);if(l)for(;o.length%4;)o.push(l);return o.join("")},parse:function(e){var t=e.length,n=this._map,o=this._reverseMap;if(!o){o=this._reverseMap=[];for(var i=0;i<n.length;i++)o[n.charCodeAt(i)]=i}var a=n.charAt(64);if(a){var s=e.indexOf(a);-1!==s&&(t=s)}return r(e,t,o)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),e.enc.Base64}(It())),Wt}var Xt,Zt={},Qt={get exports(){return Zt},set exports(e){Zt=e}};function Jt(){return Xt||(Xt=1,Qt.exports=function(e){return function(){var t=e,n=t.lib.WordArray;function r(e,t,r){for(var o=[],i=0,a=0;a<t;a++)if(a%4){var s=r[e.charCodeAt(a-1)]<<a%4*2|r[e.charCodeAt(a)]>>>6-a%4*2;o[i>>>2]|=s<<24-i%4*8,i++}return n.create(o,i)}t.enc.Base64url={stringify:function(e,t){void 0===t&&(t=!0);var n=e.words,r=e.sigBytes,o=t?this._safe_map:this._map;e.clamp();for(var i=[],a=0;a<r;a+=3)for(var s=(n[a>>>2]>>>24-a%4*8&255)<<16|(n[a+1>>>2]>>>24-(a+1)%4*8&255)<<8|n[a+2>>>2]>>>24-(a+2)%4*8&255,l=0;l<4&&a+.75*l<r;l++)i.push(o.charAt(s>>>6*(3-l)&63));var c=o.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(e,t){void 0===t&&(t=!0);var n=e.length,o=t?this._safe_map:this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var a=0;a<o.length;a++)i[o.charCodeAt(a)]=a}var s=o.charAt(64);if(s){var l=e.indexOf(s);-1!==l&&(n=l)}return r(e,n,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"}}(),e.enc.Base64url}(It())),Zt}var en,tn={},nn={get exports(){return tn},set exports(e){tn=e}};function rn(){return en||(en=1,nn.exports=function(e){return function(t){var n=e,r=n.lib,o=r.WordArray,i=r.Hasher,a=n.algo,s=[];!function(){for(var e=0;e<64;e++)s[e]=4294967296*t.abs(t.sin(e+1))|0}();var l=a.MD5=i.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var n=0;n<16;n++){var r=t+n,o=e[r];e[r]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8)}var i=this._hash.words,a=e[t+0],l=e[t+1],f=e[t+2],m=e[t+3],h=e[t+4],g=e[t+5],y=e[t+6],v=e[t+7],b=e[t+8],w=e[t+9],k=e[t+10],x=e[t+11],_=e[t+12],S=e[t+13],E=e[t+14],C=e[t+15],O=i[0],A=i[1],T=i[2],P=i[3];O=c(O,A,T,P,a,7,s[0]),P=c(P,O,A,T,l,12,s[1]),T=c(T,P,O,A,f,17,s[2]),A=c(A,T,P,O,m,22,s[3]),O=c(O,A,T,P,h,7,s[4]),P=c(P,O,A,T,g,12,s[5]),T=c(T,P,O,A,y,17,s[6]),A=c(A,T,P,O,v,22,s[7]),O=c(O,A,T,P,b,7,s[8]),P=c(P,O,A,T,w,12,s[9]),T=c(T,P,O,A,k,17,s[10]),A=c(A,T,P,O,x,22,s[11]),O=c(O,A,T,P,_,7,s[12]),P=c(P,O,A,T,S,12,s[13]),T=c(T,P,O,A,E,17,s[14]),O=u(O,A=c(A,T,P,O,C,22,s[15]),T,P,l,5,s[16]),P=u(P,O,A,T,y,9,s[17]),T=u(T,P,O,A,x,14,s[18]),A=u(A,T,P,O,a,20,s[19]),O=u(O,A,T,P,g,5,s[20]),P=u(P,O,A,T,k,9,s[21]),T=u(T,P,O,A,C,14,s[22]),A=u(A,T,P,O,h,20,s[23]),O=u(O,A,T,P,w,5,s[24]),P=u(P,O,A,T,E,9,s[25]),T=u(T,P,O,A,m,14,s[26]),A=u(A,T,P,O,b,20,s[27]),O=u(O,A,T,P,S,5,s[28]),P=u(P,O,A,T,f,9,s[29]),T=u(T,P,O,A,v,14,s[30]),O=p(O,A=u(A,T,P,O,_,20,s[31]),T,P,g,4,s[32]),P=p(P,O,A,T,b,11,s[33]),T=p(T,P,O,A,x,16,s[34]),A=p(A,T,P,O,E,23,s[35]),O=p(O,A,T,P,l,4,s[36]),P=p(P,O,A,T,h,11,s[37]),T=p(T,P,O,A,v,16,s[38]),A=p(A,T,P,O,k,23,s[39]),O=p(O,A,T,P,S,4,s[40]),P=p(P,O,A,T,a,11,s[41]),T=p(T,P,O,A,m,16,s[42]),A=p(A,T,P,O,y,23,s[43]),O=p(O,A,T,P,w,4,s[44]),P=p(P,O,A,T,_,11,s[45]),T=p(T,P,O,A,C,16,s[46]),O=d(O,A=p(A,T,P,O,f,23,s[47]),T,P,a,6,s[48]),P=d(P,O,A,T,v,10,s[49]),T=d(T,P,O,A,E,15,s[50]),A=d(A,T,P,O,g,21,s[51]),O=d(O,A,T,P,_,6,s[52]),P=d(P,O,A,T,m,10,s[53]),T=d(T,P,O,A,k,15,s[54]),A=d(A,T,P,O,l,21,s[55]),O=d(O,A,T,P,b,6,s[56]),P=d(P,O,A,T,C,10,s[57]),T=d(T,P,O,A,y,15,s[58]),A=d(A,T,P,O,S,21,s[59]),O=d(O,A,T,P,h,6,s[60]),P=d(P,O,A,T,x,10,s[61]),T=d(T,P,O,A,f,15,s[62]),A=d(A,T,P,O,w,21,s[63]),i[0]=i[0]+O|0,i[1]=i[1]+A|0,i[2]=i[2]+T|0,i[3]=i[3]+P|0},_doFinalize:function(){var e=this._data,n=e.words,r=8*this._nDataBytes,o=8*e.sigBytes;n[o>>>5]|=128<<24-o%32;var i=t.floor(r/4294967296),a=r;n[15+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),n[14+(o+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),e.sigBytes=4*(n.length+1),this._process();for(var s=this._hash,l=s.words,c=0;c<4;c++){var u=l[c];l[c]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8)}return s},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});function c(e,t,n,r,o,i,a){var s=e+(t&n|~t&r)+o+a;return(s<<i|s>>>32-i)+t}function u(e,t,n,r,o,i,a){var s=e+(t&r|n&~r)+o+a;return(s<<i|s>>>32-i)+t}function p(e,t,n,r,o,i,a){var s=e+(t^n^r)+o+a;return(s<<i|s>>>32-i)+t}function d(e,t,n,r,o,i,a){var s=e+(n^(t|~r))+o+a;return(s<<i|s>>>32-i)+t}n.MD5=i._createHelper(l),n.HmacMD5=i._createHmacHelper(l)}(Math),e.MD5}(It())),tn}var on,an={},sn={get exports(){return an},set exports(e){an=e}};function ln(){return on||(on=1,sn.exports=function(e){return function(){var t=e,n=t.lib,r=n.WordArray,o=n.Hasher,i=t.algo,a=[],s=i.SHA1=o.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],s=n[3],l=n[4],c=0;c<80;c++){if(c<16)a[c]=0|e[t+c];else{var u=a[c-3]^a[c-8]^a[c-14]^a[c-16];a[c]=u<<1|u>>>31}var p=(r<<5|r>>>27)+l+a[c];p+=c<20?1518500249+(o&i|~o&s):c<40?1859775393+(o^i^s):c<60?(o&i|o&s|i&s)-1894007588:(o^i^s)-899497514,l=s,s=i,i=o<<30|o>>>2,o=r,r=p}n[0]=n[0]+r|0,n[1]=n[1]+o|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+l|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(r+64>>>9<<4)]=Math.floor(n/4294967296),t[15+(r+64>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA1=o._createHelper(s),t.HmacSHA1=o._createHmacHelper(s)}(),e.SHA1}(It())),an}var cn,un={},pn={get exports(){return un},set exports(e){un=e}};function dn(){return cn||(cn=1,pn.exports=function(e){return function(t){var n=e,r=n.lib,o=r.WordArray,i=r.Hasher,a=n.algo,s=[],l=[];!function(){function e(e){for(var n=t.sqrt(e),r=2;r<=n;r++)if(!(e%r))return!1;return!0}function n(e){return 4294967296*(e-(0|e))|0}for(var r=2,o=0;o<64;)e(r)&&(o<8&&(s[o]=n(t.pow(r,.5))),l[o]=n(t.pow(r,1/3)),o++),r++}();var c=[],u=a.SHA256=i.extend({_doReset:function(){this._hash=new o.init(s.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],o=n[1],i=n[2],a=n[3],s=n[