@rimori/playwright-testing 0.3.33-next.0 → 0.3.34-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/harness/dist2.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import{a as e,r as t,t as n}from"./rolldown-runtime.js";import{a as r,i,n as a,o,r as s,s as c,t as l}from"./__mfe_internal__rimori_mf_2_scenario_mf_2_host__loadShare___mf_0_rimori_mf_1_client__loadShare__.mjs.js";import{Fn as u,Gn as d,Hn as f,In as p,Jn as m,Pn as h,Rn as g,Sn as _,Tn as v,Wn as y,Yn as b,ar as x,cr as S,dn as C,fn as w,pn as T}from"./__mfe_internal__rimori_mf_2_scenario_mf_2_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs.js";import{h as E,v as ee}from"./__mfe_internal__rimori_mf_2_scenario_mf_2_host__loadShare__react_mf_2_dom__loadShare__.mjs.js";S();var D=typeof window<`u`?window:void 0,O=typeof globalThis<`u`?globalThis:D;typeof self>`u`&&(O.self=O),typeof File>`u`&&(O.File=function(){});var k=O?.navigator,A=O?.document,j=O?.location,te=O?.fetch,ne=O!=null&&O.XMLHttpRequest&&`withCredentials`in new O.XMLHttpRequest?O.XMLHttpRequest:void 0,re=O?.AbortController,ie=O?.CompressionStream,ae=k?.userAgent,M=D??{},oe=`1.375.0`,se={DEBUG:!1,LIB_VERSION:oe,LIB_NAME:`web`,JS_SDK_VERSION:oe};function ce(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function le(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){ce(a,r,i,o,s,`next`,e)}function s(e){ce(a,r,i,o,s,`throw`,e)}o(void 0)}))}}function N(){return N=Object.assign?Object.assign.bind():function(e){for(var t=1;arguments.length>t;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},N.apply(null,arguments)}function ue(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var de,fe=function(e){return e.GZipJS=`gzip-js`,e.Base64=`base64`,e}({}),pe=[`$snapshot`,`$pageview`,`$pageleave`,`$set`,`survey dismissed`,`survey sent`,`survey shown`,`$identify`,`$groupidentify`,`$create_alias`,`$$client_ingestion_warning`,`$web_experiment_applied`,`$feature_enrollment_update`,`$feature_flag_called`],me=`NativeGzipValidationError`,he=e=>e.length>=2&&e[0]===31&&e[1]===139,ge=e=>!(!e||typeof e!=`object`)&&(`name`in e?String(e.name):``)===`NotReadableError`,_e=e=>{var t=Error(`Native gzip produced invalid output: `+e);throw t.name=me,t},ve=function(){var e=le((function*(e,t){18>e.size&&_e(`too-short`);var n=new Uint8Array(yield e.slice(0,10).arrayBuffer());he(n)&&n[2]===8||_e(`invalid-header`);var r=new DataView(yield e.slice(e.size-8).arrayBuffer());r.getUint32(0,!0)!==(e=>{for(var t=(()=>{if(de)return de;de=[];for(var e=0;256>e;e++){for(var t=e,n=0;8>n;n++)t=1&t?3988292384^t>>>1:t>>>1;de[e]=t>>>0}return de})(),n=4294967295,r=0;e.length>r;r++)n=t[255&(n^e[r])]^n>>>8;return(4294967295^n)>>>0})(t)&&_e(`invalid-crc`);var i=t.length>>>0;r.getUint32(4,!0)!==i&&_e(`invalid-size`)}));return function(t,n){return e.apply(this,arguments)}}();function ye(){return ye=le((function*(e,t,n){t===void 0&&(t=!0);try{var r=new TextEncoder().encode(e),i=new CompressionStream(`gzip`),a=i.writable.getWriter(),o=a.write(r).then((()=>a.close())).catch(function(){var e=le((function*(e){try{yield a.abort(e)}catch{}throw e}));return function(t){return e.apply(this,arguments)}}()),s=new Response(i.readable).blob(),[c]=yield Promise.all([s,o]);return yield ve(c,r),c}catch(e){if(n!=null&&n.rethrow)throw e;return t&&console.error(`Failed to gzip compress data`,e),null}})),ye.apply(this,arguments)}var be=`amazonbot,amazonproductbot,app.hypefactors.com,applebot,archive.org_bot,awariobot,backlinksextendedbot,baiduspider,bingbot,bingpreview,chrome-lighthouse,dataforseobot,deepscan,duckduckbot,facebookexternal,facebookcatalog,http://yandex.com/bots,hubspot,ia_archiver,leikibot,linkedinbot,meta-externalagent,mj12bot,msnbot,nessus,petalbot,pinterest,prerender,rogerbot,screaming frog,sebot-wa,sitebulb,slackbot,slurp,trendictionbot,turnitin,twitterbot,vercel-screenshot,vercelbot,yahoo! slurp,yandexbot,zoombot,bot.htm,bot.php,(bot;,bot/,crawler,ahrefsbot,ahrefssiteaudit,semrushbot,siteauditbot,splitsignalbot,gptbot,oai-searchbot,chatgpt-user,perplexitybot,better uptime bot,sentryuptimebot,uptimerobot,headlesschrome,cypress,google-hoteladsverifier,adsbot-google,apis-google,duplexweb-google,feedfetcher-google,google favicon,google web preview,google-read-aloud,googlebot,googleother,google-cloudvertexbot,googleweblight,mediapartners-google,storebot-google,google-inspectiontool,bytespider`.split(`,`),xe=function(e,t){if(t===void 0&&(t=[]),!e)return!1;var n=e.toLowerCase();return be.concat(t).some((e=>{var t=e.toLowerCase();return n.indexOf(t)!==-1}))};function P(e,t){return e.indexOf(t)!==-1}var Se=function(e){return e.trim()},Ce=function(e){return e.replace(/^\$/,``)},we=Object.prototype,Te=we.hasOwnProperty,Ee=we.toString,F=Array.isArray||function(e){return Ee.call(e)===`[object Array]`},De=e=>typeof e==`function`,Oe=e=>e===Object(e)&&!F(e),ke=e=>{if(Oe(e)){for(var t in e)if(Te.call(e,t))return!1;return!0}return!1},I=e=>e===void 0,Ae=e=>Ee.call(e)==`[object String]`,je=e=>Ae(e)&&e.trim().length===0,Me=e=>e===null,L=e=>I(e)||Me(e),Ne=e=>Ee.call(e)==`[object Number]`&&e==e,Pe=e=>Ne(e)&&e>0,Fe=e=>Ee.call(e)===`[object Boolean]`,Ie=e=>e instanceof FormData,Le=e=>P(pe,e);function Re(e){return typeof e!=`object`||!e}function ze(e,t){return{}.toString.call(e)===`[object `+t+`]`}function Be(e){return typeof Event<`u`&&function(e,t){try{return e instanceof t}catch{return!1}}(e,Event)}var Ve=[!0,`true`,1,`1`,`yes`],He=e=>P(Ve,e),Ue=[!1,`false`,0,`0`,`no`];function We(e,t,n,r,i){return t>n&&(r.warn(`min cannot be greater than max.`),t=n),Ne(e)?e>n?(r.warn(` cannot be greater than max: `+n+`. Using max value instead.`),n):t>e?(r.warn(` cannot be less than min: `+t+`. Using min value instead.`),t):e:(r.warn(` must be a number. using max or fallback. max: `+n+`, fallback: `+i),We(i||n,t,n,r))}var Ge=class{constructor(e){this.$t={},this.zt=e.zt,this.Zt=We(e.bucketSize,0,100,e.Gt),this.Qt=We(e.refillRate,0,this.Zt,e.Gt),this.Jt=We(e.refillInterval,0,864e5,e.Gt)}Kt(e,t){var n=Math.floor((t-e.lastAccess)/this.Jt);n>0&&(e.tokens=Math.min(e.tokens+n*this.Qt,this.Zt),e.lastAccess+=n*this.Jt)}consumeRateLimit(e){var t,n=Date.now(),r=String(e),i=this.$t[r];return i?this.Kt(i,n):this.$t[r]=i={tokens:this.Zt,lastAccess:n},i.tokens===0||(i.tokens--,i.tokens===0&&((t=this.zt)==null||t.call(this,e)),i.tokens===0)}stop(){this.$t={}}},Ke,qe,Je,Ye=`Mobile`,Xe=`iOS`,Ze=`Android`,Qe=`Tablet`,$e=Ze+` `+Qe,et=`iPad`,tt=`Apple`,nt=tt+` Watch`,rt=`Safari`,it=`BlackBerry`,at=`Samsung`,ot=at+`Browser`,st=at+` Internet`,ct=`Chrome`,lt=ct+` OS`,ut=ct+` `+Xe,dt=`Internet Explorer`,ft=dt+` `+Ye,pt=`Opera`,mt=pt+` Mini`,ht=`Edge`,gt=`Microsoft `+ht,_t=`Firefox`,vt=_t+` `+Xe,yt=`Nintendo`,bt=`PlayStation`,xt=`Xbox`,St=Ze+` `+Ye,Ct=Ye+` `+rt,wt=`Windows`,Tt=wt+` Phone`,Et=`Nokia`,Dt=`Ouya`,Ot=`Generic`,kt=Ot+` `+Ye.toLowerCase(),At=Ot+` `+Qe.toLowerCase(),jt=`Konqueror`,Mt=`Oculus Browser`,Nt=`(\\d+(\\.\\d+)?)`,Pt=RegExp(`Version/`+Nt),Ft=new RegExp(xt,`i`),It=RegExp(bt+` \\w+`,`i`),Lt=RegExp(yt+` \\w+`,`i`),Rt=RegExp(it+`|PlayBook|BB10`,`i`),zt={"NT3.51":`NT 3.11`,"NT4.0":`NT 4.0`,"5.0":`2000`,5.1:`XP`,5.2:`XP`,"6.0":`Vista`,6.1:`7`,6.2:`8`,6.3:`8.1`,6.4:`10`,"10.0":`10`},Bt=function(e,t){return t||=``,P(e,` OPR/`)&&P(e,`Mini`)?mt:P(e,` OPR/`)?pt:Rt.test(e)?it:P(e,`IE`+Ye)||P(e,`WPDesktop`)?ft:P(e,`OculusBrowser`)?Mt:P(e,ot)?st:P(e,ht)||P(e,`Edg/`)?gt:P(e,`FBIOS`)?`Facebook `+Ye:P(e,`UCWEB`)||P(e,`UCBrowser`)?`UC Browser`:P(e,`CriOS`)?ut:P(e,`CrMo`)||P(e,ct)?ct:P(e,Ze)&&P(e,rt)?St:P(e,`FxiOS`)?vt:P(e.toLowerCase(),jt.toLowerCase())?jt:((e,t)=>t&&P(t,tt)||function(e){return P(e,rt)&&!P(e,ct)&&!P(e,Ze)}(e))(e,t)?P(e,Ye)?Ct:rt:P(e,_t)?_t:P(e,`MSIE`)||P(e,`Trident/`)?dt:P(e,`Gecko`)?_t:``},Vt={[ft]:[RegExp(`rv:`+Nt)],[gt]:[RegExp(ht+`?\\/`+Nt)],[ct]:[RegExp(`(`+ct+`|CrMo)\\/`+Nt)],[ut]:[RegExp(`CriOS\\/`+Nt)],"UC Browser":[RegExp(`(UCBrowser|UCWEB)\\/`+Nt)],[rt]:[Pt],[Ct]:[Pt],[pt]:[RegExp(`(Opera|OPR)\\/`+Nt)],[_t]:[RegExp(_t+`\\/`+Nt)],[vt]:[RegExp(`FxiOS\\/`+Nt)],[jt]:[RegExp(`Konqueror[:/]?`+Nt,`i`)],[it]:[RegExp(it+` `+Nt),Pt],[St]:[RegExp(`android\\s`+Nt,`i`)],[st]:[RegExp(ot+`\\/`+Nt)],[Mt]:[RegExp(`OculusBrowser\\/`+Nt)],[dt]:[RegExp(`(rv:|MSIE )`+Nt)],Mozilla:[RegExp(`rv:`+Nt)]},Ht=function(e,t){var n=Vt[Bt(e,t)];if(I(n))return null;for(var r=0;n.length>r;r++){var i=e.match(n[r]);if(i)return parseFloat(i[i.length-2])}return null},Ut=[[RegExp(xt+`; `+xt+` (.*?)[);]`,`i`),e=>[xt,e&&e[1]||``]],[new RegExp(yt,`i`),[yt,``]],[new RegExp(bt,`i`),[bt,``]],[Rt,[it,``]],[new RegExp(wt,`i`),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Tt,``];if(new RegExp(Ye).test(t)&&!/IEMobile\b/.test(t))return[wt+` `+Ye,``];var n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){var r=zt[n[1]]||``;return/arm/i.test(t)&&(r=`RT`),[wt,r]}return[wt,``]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?[Xe,[e[3],e[4],e[5]||`0`].join(`.`)]:[Xe,``]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t=``;return e&&e.length>=3&&(t=I(e[2])?e[3]:e[2]),[`watchOS`,t]}],[RegExp(`(`+Ze+` (\\d+)\\.(\\d+)\\.?(\\d+)?|`+Ze+`)`,`i`),e=>e&&e[2]?[Ze,[e[2],e[3],e[4]||`0`].join(`.`)]:[Ze,``]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=[`Mac OS X`,``];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||`0`].join(`.`)),t}],[/Mac/i,[`Mac OS X`,``]],[/CrOS/,[lt,``]],[/Linux|debian/i,[`Linux`,``]]],Wt=function(e){return Lt.test(e)?yt:It.test(e)?bt:Ft.test(e)?xt:new RegExp(Dt,`i`).test(e)?Dt:RegExp(`(`+Tt+`|WPDesktop)`,`i`).test(e)?Tt:/iPad/.test(e)?et:/iPod/.test(e)?`iPod Touch`:/iPhone/.test(e)?`iPhone`:/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?nt:Rt.test(e)?it:/(kobo)\s(ereader|touch)/i.test(e)?`Kobo`:new RegExp(Et,`i`).test(e)?Et:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?`Kindle Fire`:/(Android|ZTE)/i.test(e)?new RegExp(Ye).test(e)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)||/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?Ze:$e:RegExp(`(pda|`+Ye+`)`,`i`).test(e)?kt:new RegExp(Qe,`i`).test(e)&&!RegExp(Qe+` pc`,`i`).test(e)?At:``},Gt=e=>e instanceof Error,Kt={trace:{text:`TRACE`,number:1},debug:{text:`DEBUG`,number:5},info:{text:`INFO`,number:9},warn:{text:`WARN`,number:13},error:{text:`ERROR`,number:17},fatal:{text:`FATAL`,number:21}},qt=Kt.info;function Jt(e){if(Fe(e))return{boolValue:e};if(typeof e==`number`)return Number.isFinite(e)?Number.isInteger(e)?{intValue:e}:{doubleValue:e}:{stringValue:String(e)};if(typeof e==`string`)return{stringValue:e};if(F(e))return{arrayValue:{values:e.map((e=>Jt(e)))}};try{return{stringValue:JSON.stringify(e)}}catch{return{stringValue:String(e)}}}function Yt(e){var t=[];for(var n in e){var r=e[n];Me(r)||I(r)||t.push({key:n,value:Jt(r)})}return t}function Xt(e){var t=globalThis._posthogChunkIds;if(t){var n=Object.keys(t);return Je&&n.length===qe||(qe=n.length,Je=n.reduce(((n,r)=>{Ke||={};var i=Ke[r];if(i)n[i[0]]=i[1];else for(var a=e(r),o=a.length-1;o>=0;o--){var s=a[o]?.filename,c=t[r];if(s&&c){n[s]=c,Ke[r]=[s,c];break}}return n}),{})),Je}}var Zt=class{constructor(e,t,n){n===void 0&&(n=[]),this.coercers=e,this.stackParser=t,this.modifiers=n}buildFromUnknown(e,t){t===void 0&&(t={});var n=t&&t.mechanism||{handled:!0,type:`generic`},r=this.buildCoercingContext(n,t,0).apply(e),i=this.buildParsingContext(t),a=this.parseStacktrace(r,i);return{$exception_list:this.convertToExceptionList(a,n),$exception_level:`error`}}modifyFrames(e){var t=this;return le((function*(){for(var n of e)n.stacktrace&&n.stacktrace.frames&&F(n.stacktrace.frames)&&(n.stacktrace.frames=yield t.applyModifiers(n.stacktrace.frames));return e}))()}coerceFallback(e){return{type:`Error`,value:`Unknown error`,stack:e.syntheticException?.stack,synthetic:!0}}parseStacktrace(e,t){var n,r;return e.cause!=null&&(n=this.parseStacktrace(e.cause,t)),e.stack!=``&&e.stack!=null&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),N({},e,{cause:n,stack:r})}applyChunkIds(e,t){return e.map((e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e)))}applyCoercers(e,t){for(var n of this.coercers)if(n.match(e))return n.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return le((function*(){var n=e;for(var r of t.modifiers)n=yield r(n);return n}))()}convertToExceptionList(e,t){var n,r,i={type:e.type,value:e.value,mechanism:{type:t.type??`generic`,handled:(n=t.handled)==null||n,synthetic:(r=e.synthetic)!=null&&r}};e.stack&&(i.stacktrace={type:`raw`,frames:e.stack});var a=[i];return e.cause!=null&&a.push(...this.convertToExceptionList(e.cause,N({},t,{handled:!0}))),a}buildParsingContext(e){return{chunkIdMap:Xt(this.stackParser),skipFirstLines:e.skipFirstLines??1}}buildCoercingContext(e,t,n){n===void 0&&(n=0);var r=(n,r)=>{if(4>=r){var i=this.buildCoercingContext(e,t,r);return this.applyCoercers(n,i)}};return N({},t,{syntheticException:n==0?t.syntheticException:void 0,mechanism:e,apply:e=>r(e,n),next:e=>r(e,n+1)})}},Qt=`?`;function $t(e,t,n,r,i){var a={platform:e,filename:t,function:n===`<anonymous>`?Qt:n,in_app:!0};return I(r)||(a.lineno=r),I(i)||(a.colno=i),a}var en=(e,t)=>{var n=e.indexOf(`safari-extension`)!==-1,r=e.indexOf(`safari-web-extension`)!==-1;return n||r?[e.indexOf(`@`)===-1?Qt:e.split(`@`)[0],n?`safari-extension:`+t:`safari-web-extension:`+t]:[e,t]},tn=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,nn=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,rn=/\((\S*)(?::(\d+))(?::(\d+))\)/,an=(e,t)=>{var n=tn.exec(e);if(n){var[,r,i,a]=n;return $t(t,r,Qt,+i,+a)}var o=nn.exec(e);if(o){if(o[2]&&o[2].indexOf(`eval`)===0){var s=rn.exec(o[2]);s&&(o[2]=s[1],o[3]=s[2],o[4]=s[3])}var[c,l]=en(o[1]||Qt,o[2]);return $t(t,l,c,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},on=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,sn=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,cn=(e,t)=>{var n=on.exec(e);if(n){if(n[3]&&n[3].indexOf(` > eval`)>-1){var r=sn.exec(n[3]);r&&(n[1]=n[1]||`eval`,n[3]=r[1],n[4]=r[2],n[5]=``)}var i=n[3],a=n[1]||Qt;return[a,i]=en(a,i),$t(t,i,a,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},ln=/\(error: (.*)\)/,un=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var n=Ae(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:n?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?`DOMError`:`DOMException`}getValue(e){var t=e.name||(this.isDOMError(e)?`DOMError`:`DOMException`);return e.message?t+`: `+e.message:t}isDOMException(e){return ze(e,`DOMException`)}isDOMError(e){return ze(e,`DOMError`)}},dn=class{match(e){return(e=>e instanceof Error)(e)}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var n=e.message;return String(n.error&&typeof n.error.message==`string`?n.error.message:n)}getStack(e){return e.stacktrace||e.stack||void 0}},fn=class{constructor(){}match(e){return ze(e,`ErrorEvent`)&&e.error!=null}coerce(e,t){return t.apply(e.error)||{type:`ErrorEvent`,value:e.message,stack:t.syntheticException?.stack,synthetic:!0}}},pn=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,mn=class{match(e){return typeof e==`string`}coerce(e,t){var[n,r]=this.getInfos(e);return{type:n??`Error`,value:r??e,stack:t.syntheticException?.stack,synthetic:!0}}getInfos(e){var t=`Error`,n=e,r=e.match(pn);return r&&(t=r[1],n=r[2]),[t,n]}},hn=[`fatal`,`error`,`warning`,`log`,`info`,`debug`];function gn(e,t){t===void 0&&(t=40);var n=Object.keys(e);if(n.sort(),!n.length)return`[object has no keys]`;for(var r=n.length;r>0;r--){var i=n.slice(0,r).join(`, `);if(t>=i.length)return r===n.length?i:i.length>t?i.slice(0,t)+`...`:i}return``}var _n=class{match(e){return typeof e==`object`&&!!e}coerce(e,t){var n=this.getErrorPropertyFromObject(e);return n?t.apply(n):{type:this.getType(e),value:this.getValue(e),stack:t.syntheticException?.stack,level:this.isSeverityLevel(e.level)?e.level:`error`,synthetic:!0}}getType(e){return Be(e)?e.constructor.name:`Error`}getValue(e){if(`name`in e&&typeof e.name==`string`){var t=`'`+e.name+`' captured as exception`;return`message`in e&&typeof e.message==`string`&&(t+=` with message: '`+e.message+`'`),t}if(`message`in e&&typeof e.message==`string`)return e.message;var n=this.getObjectClassName(e);return(n&&n!==`Object`?`'`+n+`'`:`Object`)+` captured as exception with keys: `+gn(e)}isSeverityLevel(e){return Ae(e)&&!je(e)&&hn.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var n=e[t];if(Gt(n))return n}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},vn=class{match(e){return Be(e)}coerce(e,t){var n=e.constructor.name;return{type:n,value:n+` captured as exception with keys: `+gn(e),stack:t.syntheticException?.stack,synthetic:!0}}},yn=class{match(e){return Re(e)}coerce(e,t){return{type:`Error`,value:`Primitive value captured as exception: `+String(e),stack:t.syntheticException?.stack,synthetic:!0}}},bn=class{match(e){return ze(e,`PromiseRejectionEvent`)||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!Be(e))return!1;try{var t=e.detail;return typeof t==`object`&&!!t&&`reason`in t}catch{return!1}}coerce(e,t){var n=this.getUnhandledRejectionReason(e);return Re(n)?{type:`UnhandledRejection`,value:`Non-Error promise rejection captured with value: `+String(n),stack:t.syntheticException?.stack,synthetic:!0}:t.apply(n)}getUnhandledRejectionReason(e){try{if(`reason`in e)return e.reason;if(`detail`in e&&e.detail!=null&&typeof e.detail==`object`&&`reason`in e.detail)return e.detail.reason}catch{}return e}},xn=`$message`,Sn=`$timestamp`,Cn=new Set([xn,Sn]),wn={enabled:!0,max_bytes:32768};function Tn(e){return e?{enabled:e.enabled??wn.enabled,max_bytes:Dn(e.max_bytes,wn.max_bytes)}:N({},wn)}var En=class{constructor(e){this.Yt=[],this.Xt=0,this.qt=Tn(e)}setConfig(e){this.qt=Tn(e),this.er()}add(e){var t=function(e){var t=function(e){var t=new WeakSet;try{return JSON.stringify(e,((e,n)=>{if(typeof n==`bigint`)return n.toString();if(typeof n!=`function`&&typeof n!=`symbol`){if(n instanceof Date)return n.toISOString();if(n instanceof Error)return{name:n.name,message:n.message,stack:n.stack};if(n&&typeof n==`object`){if(t.has(n))return`[Circular]`;t.add(n)}return n}}))}catch{return}}(e);if(t)try{var n=JSON.parse(t);if(!Oe(n))return;var r=n,i=r[xn],a=r[Sn];return!Ae(i)||i.trim().length===0||!Ae(a)&&!Ne(a)?void 0:{step:r,json:t}}catch{return}}(e);if(t){var n=function(e){if(typeof TextEncoder<`u`)return new TextEncoder().encode(e).length;for(var t=encodeURIComponent(e),n=0,r=0;t.length>r;r++)t[r]===`%`?(n+=1,r+=2):n+=1;return n}(t.json);n>this.qt.max_bytes||(this.Yt.push({step:t.step,bytes:n}),this.Xt+=n,this.er())}}getAttachable(){return this.Yt.map((e=>e.step))}clear(){this.Yt=[],this.Xt=0}size(){return this.Yt.length}er(){for(;this.Xt>this.qt.max_bytes&&this.Yt.length>0;){var e=this.Yt.shift();e&&(this.Xt-=e.bytes)}}};function Dn(e,t){if(!Ne(e)||e===1/0||e===-1/0)return t;var n=Math.floor(e);return 0>n?t:n}var On=function(e,t){var{debugEnabled:n}=t===void 0?{}:t,r={k(t){if(D&&(se.DEBUG||M.POSTHOG_DEBUG||n)&&!I(D.console)&&D.console){for(var r=(`__rrweb_original__`in D.console[t])?D.console[t].__rrweb_original__:D.console[t],i=arguments.length,a=Array(i>1?i-1:0),o=1;i>o;o++)a[o-1]=arguments[o];r(e,...a)}},debug(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];r.k(`debug`,...t)},info(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];r.k(`log`,...t)},warn(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];r.k(`warn`,...t)},error(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];r.k(`error`,...t)},critical(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];console.error(e,...n)},uninitializedWarning(e){r.error(`You must initialize PostHog before calling `+e)},createLogger:(t,n)=>On(e+` `+t,n)};return r},R=On(`[PostHog.js]`),kn=R.createLogger,An=kn(`[ExternalScriptsLoader]`),jn=(e,t,n)=>{if(e.config.disable_external_dependency_loading)return An.warn(t+` was requested but loading of external scripts is disabled.`),n(`Loading of external scripts is disabled`);var r=A?.querySelectorAll(`script`);if(r){for(var i,a=function(){if(r[o].src===t){var e=r[o];return e.__posthog_loading_callback_fired?{v:n()}:(e.addEventListener(`load`,(t=>{e.__posthog_loading_callback_fired=!0,n(void 0,t)})),e.onerror=e=>n(e),{v:void 0})}},o=0;r.length>o;o++)if(i=a())return i.v}var s=()=>{if(!A)return n(`document not found`);var r=A.createElement(`script`);if(r.type=`text/javascript`,r.crossOrigin=`anonymous`,r.src=t,r.onload=e=>{r.__posthog_loading_callback_fired=!0,n(void 0,e)},r.onerror=e=>n(e),e.config.prepare_external_dependency_script&&(r=e.config.prepare_external_dependency_script(r)),!r)return n(`prepare_external_dependency_script returned null`);if(e.config.external_scripts_inject_target===`head`)A.head.appendChild(r);else{var i,a=A.querySelectorAll(`body > script`);a.length>0?(i=a[0].parentNode)==null||i.insertBefore(r,a[0]):A.body.appendChild(r)}};A!=null&&A.body?s():A?.addEventListener(`DOMContentLoaded`,s)};M.__PosthogExtensions__=M.__PosthogExtensions__||{},M.__PosthogExtensions__.loadExternalDependency=(e,t,n)=>{if(t!==`remote-config`){var r;if(e.config.__preview_external_dependency_versioned_paths)r=e.requestRouter.endpointFor(`assets`,`/static/`+e.version+`/`+t+`.js`);else{var i=`/static/`+t+`.js?v=`+e.version;if(t===`toolbar`){var a=3e5;i=i+`&t=`+Math.floor(Date.now()/a)*a}r=e.requestRouter.endpointFor(`assets`,i)}jn(e,r,n)}else jn(e,e.requestRouter.endpointFor(`assets`,`/array/`+e.config.token+`/config.js`),n)},M.__PosthogExtensions__.loadSiteApp=(e,t,n)=>{jn(e,e.requestRouter.endpointFor(`api`,t),n)};var Mn=`$people_distinct_id`,Nn=`$device_id`,Pn=`__alias`,Fn=`__timers`,In=`$autocapture_disabled_server_side`,Ln=`$heatmaps_enabled_server_side`,Rn=`$exception_capture_enabled_server_side`,zn=`$error_tracking_suppression_rules`,Bn=`$error_tracking_capture_extension_exceptions`,Vn=`$web_vitals_enabled_server_side`,Hn=`$dead_clicks_enabled_server_side`,Un=`$product_tours_enabled_server_side`,Wn=`$web_vitals_allowed_metrics`,Gn=`$session_recording_remote_config`,Kn=`$replay_override_sampling`,qn=`$replay_override_linked_flag`,Jn=`$replay_override_url_trigger`,Yn=`$replay_override_event_trigger`,Xn=`$sesid`,Zn=`$session_is_sampled`,Qn=`$enabled_feature_flags`,$n=`$active_feature_flags`,er=`$early_access_features`,tr=`$feature_flag_details`,nr=`$feature_flag_payloads`,rr=`$feature_flag_request_id`,ir=`$override_feature_flags`,ar=`$override_feature_flag_payloads`,or=`$stored_person_properties`,sr=`$stored_group_properties`,cr=`$surveys`,lr=`$surveys_activated`,ur=`ph_product_tours`,dr=`$flag_call_reported`,fr=`$flag_call_reported_session_id`,pr=`$feature_flag_errors`,mr=`$feature_flag_evaluated_at`,hr=`$user_state`,gr=`$client_session_props`,_r=`$capture_rate_limit`,vr=`$initial_campaign_params`,yr=`$initial_referrer_info`,br=`$initial_person_info`,xr=`$epp`,Sr=`__POSTHOG_TOOLBAR__`,Cr=`$posthog_cookieless`,wr=`$sdk_debug_extensions_init_method`,Tr=`$sdk_debug_extensions_init_time_ms`,Er=`$sdk_debug_recording_script_not_loaded`,Dr=`PostHog loadExternalDependency extension not found.`,Or=`on_reject`,kr=`always`,Ar=`anonymous`,jr=`identified`,Mr=`identified_only`,Nr=`visibilitychange`,Pr=`beforeunload`,Fr=`$pageview`,Ir=`$pageleave`,Lr=`$identify`,Rr=`$groupidentify`;function zr(e,t){F(e)&&e.forEach(t)}function Br(e,t){if(!L(e))if(F(e))e.forEach(t);else if(Ie(e))e.forEach(((e,n)=>t(e,n)));else for(var n in e)Te.call(e,n)&&t(e[n],n)}var Vr=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];for(var i of n)for(var a in i)i[a]!==void 0&&(e[a]=i[a]);return e};function Hr(e){for(var t=Object.keys(e),n=t.length,r=Array(n);n--;)r[n]=[t[n],e[t[n]]];return r}var Ur=function(e){try{return e()}catch{return}},Wr=function(e){return function(){try{for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return e.apply(this,n)}catch(e){R.critical(`Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A.`),R.critical(e)}}},Gr=function(e){var t={};return Br(e,(function(e,n){(Ae(e)&&e.length>0||Ne(e))&&(t[n]=e)})),t},Kr=[`herokuapp.com`,`vercel.app`,`netlify.app`];function qr(e){var t=e?.hostname;if(!Ae(t))return!1;var n=t.split(`.`).slice(-2).join(`.`);for(var r of Kr)if(n===r)return!1;return!0}function Jr(e,t,n,r){var{capture:i=!1,passive:a=!0}=r??{};e?.addEventListener(t,n,{capture:i,passive:a})}function Yr(e){return e.name===`ph_toolbar_internal`}Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return Ne(e)&&isFinite(e)&&Math.floor(e)===e});var Xr=class e{constructor(e){if(this.bytes=e,e.length!==16)throw TypeError(`not 128-bit length`)}static fromFieldsV7(t,n,r,i){if(!Number.isInteger(t)||!Number.isInteger(n)||!Number.isInteger(r)||!Number.isInteger(i)||0>t||0>n||0>r||0>i||t>0xffffffffffff||n>4095||r>1073741823||i>4294967295)throw RangeError(`invalid field value`);var a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/2**8,a[5]=t,a[6]=112|n>>>8,a[7]=n,a[8]=128|r>>>24,a[9]=r>>>16,a[10]=r>>>8,a[11]=r,a[12]=i>>>24,a[13]=i>>>16,a[14]=i>>>8,a[15]=i,new e(a)}toString(){for(var e=``,t=0;this.bytes.length>t;t++)e=e+(this.bytes[t]>>>4).toString(16)+(15&this.bytes[t]).toString(16),t!==3&&t!==5&&t!==7&&t!==9||(e+=`-`);if(e.length!==36)throw Error(`Invalid UUIDv7 was generated`);return e}clone(){return new e(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var t=0;16>t;t++){var n=this.bytes[t]-e.bytes[t];if(n!==0)return Math.sign(n)}return 0}},Zr=class{constructor(){this.S=0,this.C=0,this.I=new ei}generate(){var e=this.generateOrAbort();if(I(e)){this.S=0;var t=this.generateOrAbort();if(I(t))throw Error(`Could not generate UUID after timestamp reset`);return t}return e}generateOrAbort(){var e=Date.now();if(e>this.S)this.S=e,this.T();else{if(this.S>=e+1e4)return;this.C++,this.C>4398046511103&&(this.S++,this.T())}return Xr.fromFieldsV7(this.S,Math.trunc(this.C/2**30),this.C&2**30-1,this.I.nextUint32())}T(){this.C=1024*this.I.nextUint32()+(1023&this.I.nextUint32())}},Qr,$r=e=>{if(typeof UUIDV7_DENY_WEAK_RNG<`u`&&UUIDV7_DENY_WEAK_RNG)throw Error(`no cryptographically strong RNG available`);for(var t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};D&&!I(D.crypto)&&crypto.getRandomValues&&($r=e=>crypto.getRandomValues(e));var ei=class{constructor(){this.M=new Uint32Array(8),this.O=1/0}nextUint32(){return this.M.length>this.O||($r(this.M),this.O=0),this.M[this.O++]}},ti=()=>ni().toString(),ni=()=>(Qr||=new Zr).generate(),ri=``,ii=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,ai={R:()=>!!A,D(e){R.error(`cookieStore error: `+e)},A(e){if(A){try{for(var t=e+`=`,n=A.cookie.split(`;`).filter((e=>e.length)),r=0;n.length>r;r++){for(var i=n[r];i.charAt(0)==` `;)i=i.substring(1,i.length);if(i.indexOf(t)===0)return decodeURIComponent(i.substring(t.length,i.length))}}catch{}return null}},F(e){var t;try{t=JSON.parse(ai.A(e))||{}}catch{}return t},N(e,t,n,r,i){if(A)try{var a=``,o=``,s=function(e,t){if(t){var n=function(e,t){if(t===void 0&&(t=A),ri)return ri;if(!t||[`localhost`,`127.0.0.1`].includes(e))return``;for(var n=e.split(`.`),r=Math.min(n.length,8),i=`dmn_chk_`+ti();!ri&&r--;){var a=n.slice(r).join(`.`),o=i+`=1;domain=.`+a+`;path=/`;t.cookie=o+`;max-age=3`,t.cookie.includes(i)&&(t.cookie=o+`;max-age=0`,ri=a)}return ri}(e);if(!n){var r=(e=>{var t=e.match(ii);return t?t[0]:``})(e);r!==n&&R.info(`Warning: cookie subdomain discovery mismatch`,r,n),n=r}return n?`; domain=.`+n:``}return``}(A.location.hostname,r);if(n){var c=new Date;c.setTime(c.getTime()+864e5*n),a=`; expires=`+c.toUTCString()}i&&(o=`; secure`);var l=e+`=`+encodeURIComponent(JSON.stringify(t))+a+`; SameSite=Lax; path=/`+s+o;return l.length>3686.4&&R.warn(`cookieStore warning: large cookie, len=`+l.length),A.cookie=l,l}catch{return}},q(e,t){if(A!=null&&A.cookie)try{ai.N(e,``,-1,t)}catch{return}}},oi=null,si={R(){if(!Me(oi))return oi;var e=!0;if(I(D))e=!1;else try{var t=`__mplssupport__`;si.N(t,`xyz`),si.A(t)!==`"xyz"`&&(e=!1),si.q(t)}catch{e=!1}return e||R.error(`localStorage unsupported; falling back to cookie store`),oi=e,e},D(e){R.error(`localStorage error: `+e)},A(e){try{return D?.localStorage.getItem(e)}catch(e){si.D(e)}return null},F(e){try{return JSON.parse(si.A(e))||{}}catch{}return null},N(e,t){try{D?.localStorage.setItem(e,JSON.stringify(t))}catch(e){si.D(e)}},q(e){try{D?.localStorage.removeItem(e)}catch(e){si.D(e)}}},ci=[Nn,`distinct_id`,Xn,Zn,xr,br,hr],li={},ui={R:()=>!0,D(e){R.error(`memoryStorage error: `+e)},A:e=>li[e]||null,F:e=>li[e]||null,N(e,t){li[e]=t},q(e){delete li[e]}},di=null,fi={R(){if(!Me(di))return di;if(di=!0,I(D))di=!1;else try{var e=`__support__`;fi.N(e,`xyz`),fi.A(e)!==`"xyz"`&&(di=!1),fi.q(e)}catch{di=!1}return di},D(e){R.error(`sessionStorage error: `,e)},A(e){try{return D?.sessionStorage.getItem(e)}catch(e){fi.D(e)}return null},F(e){try{return JSON.parse(fi.A(e))||null}catch{}return null},N(e,t){try{D?.sessionStorage.setItem(e,JSON.stringify(t))}catch(e){fi.D(e)}},q(e){try{D?.sessionStorage.removeItem(e)}catch(e){fi.D(e)}}},pi=class{constructor(e){this._instance=e}get qt(){return this._instance.config}get consent(){return this.rr()?0:this.ir}isOptedOut(){return this.qt.cookieless_mode===kr||this.isRejected()||this.consent===-1&&this.qt.cookieless_mode===Or}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.qt.opt_out_capturing_by_default}optInOut(e){this.nr.N(this.sr,+!!e,this.qt.cookie_expiration,this.qt.cross_subdomain_cookie,this.qt.secure_cookie)}reset(){this.nr.q(this.sr,this.qt.cross_subdomain_cookie)}get sr(){var{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:n}=this._instance.config;return n||(t?t+e:`__ph_opt_in_out_`+e)}get ir(){var e=this.nr.A(this.sr);return He(e)?1:P(Ue,e)?0:-1}get nr(){var e=this.qt.opt_out_capturing_persistence_type,t=e===`localStorage`?si:ai;if(!this.ar||this.ar!==t){this.ar=t;var n=e===`localStorage`?ai:si;n.A(this.sr)&&(this.ar.A(this.sr)||this.optInOut(He(n.A(this.sr))),n.q(this.sr,this.qt.cross_subdomain_cookie))}return this.ar}rr(){return!!this.qt.respect_dnt&&[k?.doNotTrack,k?.msDoNotTrack,M.doNotTrack].some((e=>He(e)))}},mi=kn(`[Dead Clicks]`),hi=()=>!0,gi=e=>{var t,n=!((t=e.instance.persistence)==null||!t.get_property(Hn)),r=e.instance.config.capture_dead_clicks;return Fe(r)?r:!!Oe(r)||n},_i=class{get lazyLoadedDeadClicksAutocapture(){return this.ur}constructor(e,t,n){this.instance=e,this.isEnabled=t,this.onCapture=n,this.startIfEnabledOrStop()}onRemoteConfig(e){`captureDeadClicks`in e&&(this.instance.persistence&&this.instance.persistence.register({[Hn]:e.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.lr((()=>{this.hr()})):this.stop()}lr(e){var t,n;(t=M.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture&&e(),(n=M.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this.instance,`dead-clicks-autocapture`,(t=>{t?mi.error(`failed to load script`,t):e()}))}hr(){var e;if(A){if(!this.ur&&(e=M.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var t=Oe(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this.ur=M.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.ur.start(A),mi.info(`starting...`)}}else mi.error("`document` not found. Cannot start.")}stop(){this.ur&&(this.ur.stop(),this.ur=void 0,mi.info(`stopping...`))}},vi=kn(`[SegmentIntegration]`),yi=`posthog-js`;function bi(e,t){var{organization:n,projectId:r,prefix:i,severityAllowList:a=[`error`],sendExceptionsToPostHog:o=!0}=t===void 0?{}:t;return t=>{if(a!==`*`&&!a.includes(t.level)||!e.__loaded)return t;t.tags||={};var s=e.requestRouter.endpointFor(`ui`,`/project/`+e.config.token+`/person/`+e.get_distinct_id());t.tags[`PostHog Person URL`]=s,e.sessionRecordingStarted()&&(t.tags[`PostHog Recording URL`]=e.get_session_replay_url({withTimestamp:!0}));var c,l=t.exception?.values||[],u=l.map((e=>N({},e,{stacktrace:e.stacktrace?N({},e.stacktrace,{type:`raw`,frames:(e.stacktrace.frames||[]).map((e=>N({},e,{platform:`web:javascript`})))}):void 0}))),d={$exception_message:l[0]?.value||t.message,$exception_type:l[0]?.type,$exception_level:t.level,$exception_list:u,$sentry_event_id:t.event_id,$sentry_exception:t.exception,$sentry_exception_message:l[0]?.value||t.message,$sentry_exception_type:l[0]?.type,$sentry_tags:t.tags};return n&&r&&(d.$sentry_url=(i||`https://sentry.io/organizations/`)+n+`/issues/?project=`+r+`&query=`+t.event_id),o&&((c=e.exceptions)==null||c.sendExceptionEvent(d)),t}}var xi=class{constructor(e,t,n,r,i,a){this.name=yi,this.setupOnce=function(o){o(bi(e,{organization:t,projectId:n,prefix:r,severityAllowList:i,sendExceptionsToPostHog:a==null||a}))}}},Si=class{constructor(e){this.cr=(e,t,n)=>{n&&(n.noSessionId||n.activityTimeout||n.sessionPastMaximumLength)&&(R.info(`[PageViewManager] Session rotated, clearing pageview state`,{sessionId:e,changeReason:n}),this.dr=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.vr()}vr(){this.pr=this._instance.sessionManager?.onSessionId(this.cr)}destroy(){var e;(e=this.pr)==null||e.call(this),this.pr=void 0}doPageView(e,t){var n=this.gr(e,t);return this.dr={pathname:D?.location.pathname??``,pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),n}doPageLeave(e){return this.gr(e,this.dr?.pageViewId)}doEvent(){return{$pageview_id:this.dr?.pageViewId}}gr(e,t){var n=this.dr;if(!n)return{$pageview_id:t};var r={$pageview_id:t,$prev_pageview_id:n.pageViewId},i=this._instance.scrollManager.getContext();if(i&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:a,lastScrollY:o,maxScrollY:s,maxContentHeight:c,lastContentY:l,maxContentY:u}=i;if(!(I(a)||I(o)||I(s)||I(c)||I(l)||I(u))){a=Math.ceil(a),o=Math.ceil(o),s=Math.ceil(s),c=Math.ceil(c),l=Math.ceil(l),u=Math.ceil(u);var d=a>1?We(o/a,0,1,R):1,f=a>1?We(s/a,0,1,R):1,p=c>1?We(l/c,0,1,R):1,m=c>1?We(u/c,0,1,R):1;r=Vr(r,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:s,$prev_pageview_max_scroll_percentage:f,$prev_pageview_last_content:l,$prev_pageview_last_content_percentage:p,$prev_pageview_max_content:u,$prev_pageview_max_content_percentage:m})}}return n.pathname&&(r.$prev_pageview_pathname=n.pathname),n.timestamp&&(r.$prev_pageview_duration=(e.getTime()-n.timestamp.getTime())/1e3),r}},Ci={[Mn]:{exposure:`hidden`},[Pn]:{exposure:`hidden`},__cmpns:{exposure:`hidden`},[Fn]:{exposure:`hidden`},[In]:{exposure:`event`},[Ln]:{exposure:`hidden`},[Rn]:{exposure:`event`},[zn]:{exposure:`hidden`},[Bn]:{exposure:`event`},[Vn]:{exposure:`event`},[Hn]:{exposure:`event`},[Un]:{exposure:`hidden`},[Wn]:{exposure:`event`},[Gn]:{exposure:`hidden`},$session_recording_enabled_server_side:{exposure:`hidden`},[Xn]:{exposure:`hidden`},[Zn]:{exposure:`event`},$session_past_minimum_duration:{exposure:`event`},$session_recording_url_trigger_activated_session:{exposure:`event`},$session_recording_event_trigger_activated_session:{exposure:`event`},$debug_first_full_snapshot_timestamp:{exposure:`event`},[Qn]:{exposure:`derived`,shouldSkipFromEventProperties:(e,t)=>t(),transformToEventProperties(e){if(!Oe(e))return{};for(var t={},n=Object.keys(e),r=0;n.length>r;r++)t[`$feature/`+n[r]]=e[n[r]];return t}},[$n]:{exposure:`event`},[er]:{exposure:`hidden`},[tr]:{exposure:`hidden`},[nr]:{exposure:`event`},[rr]:{exposure:`event`},[ir]:{exposure:`event`},[ar]:{exposure:`hidden`},[or]:{exposure:`hidden`},[sr]:{exposure:`hidden`},[cr]:{exposure:`hidden`},[lr]:{exposure:`event`},[ur]:{exposure:`hidden`},$product_tours_activated:{exposure:`hidden`},$conversations_widget_session_id:{exposure:`event`},$conversations_ticket_id:{exposure:`event`},$conversations_widget_state:{exposure:`event`},$conversations_user_traits:{exposure:`event`},[dr]:{exposure:`hidden`},[fr]:{exposure:`hidden`},[pr]:{exposure:`hidden`},[mr]:{exposure:`hidden`},[hr]:{exposure:`hidden`},[gr]:{exposure:`hidden`},[_r]:{exposure:`hidden`},[vr]:{exposure:`hidden`},[yr]:{exposure:`hidden`},[br]:{exposure:`hidden`},[xr]:{exposure:`hidden`},[Kn]:{exposure:`event`},[qn]:{exposure:`event`},[Jn]:{exposure:`event`},[Yn]:{exposure:`event`},[wr]:{exposure:`event`},[Tr]:{exposure:`event`},[Er]:{exposure:`event`},$sdk_debug_replay_event_trigger_status:{exposure:`event`},$sdk_debug_replay_linked_flag_trigger_status:{exposure:`event`},$sdk_debug_replay_matched_recording_trigger_groups:{exposure:`event`},$sdk_debug_replay_remote_trigger_matching_config:{exposure:`event`},$sdk_debug_replay_trigger_groups_count:{exposure:`event`},$sdk_debug_replay_url_trigger_status:{exposure:`event`},$session_recording_start_reason:{exposure:`event`}},wi=[[`$posthog_sr_group_event_trigger_`,{exposure:`hidden`}],[`$posthog_sr_group_url_trigger_`,{exposure:`hidden`}],[`$posthog_sr_group_sampling_`,{exposure:`hidden`}]],Ti=e=>{var t=A?.createElement(`a`);return I(t)?null:(t.href=e,t)},Ei=function(e,t){for(var n,r=((e.split(`#`)[0]||``).split(/\?(.*)/)[1]||``).replace(/^\?+/g,``).split(`&`),i=0;r.length>i;i++){var a=r[i].split(`=`);if(a[0]===t){n=a;break}}if(!F(n)||2>n.length)return``;var o=n[1];try{o=decodeURIComponent(o)}catch{R.error(`Skipping decoding for malformed query param: `+o)}return o.replace(/\+/g,` `)},Di=function(e,t,n){if(!e||!t||!t.length)return e;for(var r=e.split(`#`),i=r[1],a=(r[0]||``).split(`?`),o=a[1],s=a[0],c=(o||``).split(`&`),l=[],u=0;c.length>u;u++){var d=c[u].split(`=`);F(d)&&(t.includes(d[0])?l.push(d[0]+`=`+n):l.push(c[u]))}var f=s;return o!=null&&(f+=`?`+l.join(`&`)),i!=null&&(f+=`#`+i),f},Oi=function(e,t){var n=e.match(RegExp(t+`=([^&]*)`));return n?n[1]:null},ki=`https?://(.*)`,Ai=[`gclid`,`gclsrc`,`dclid`,`gbraid`,`wbraid`,`fbclid`,`msclkid`,`twclid`,`li_fat_id`,`igshid`,`ttclid`,`rdt_cid`,`epik`,`qclid`,`sccid`,`irclid`,`_kx`],ji=[`utm_source`,`utm_medium`,`utm_campaign`,`utm_content`,`utm_term`,`gad_source`,`mc_cid`,...Ai],Mi=`<masked>`,Ni=[`li_fat_id`];function Pi(e,t,n){if(!A)return{};var r,i=t?[...Ai,...n||[]]:[],a=Fi(Di(A.URL,i,Mi),e);return Vr((r={},Br(Ni,(function(e){var t=ai.A(e);r[e]=t||null})),r),a)}function Fi(e,t){var n=ji.concat(t||[]),r={};return Br(n,(function(t){r[t]=Ei(e,t)||null})),r}function Ii(e){var t=function(e){return e?e.search(ki+`google.([^/?]*)`)===0?`google`:e.search(ki+`bing.com`)===0?`bing`:e.search(ki+`yahoo.com`)===0?`yahoo`:e.search(ki+`duckduckgo.com`)===0?`duckduckgo`:null:null}(e),n=t==`yahoo`?`p`:`q`,r={};if(!Me(t)){r.$search_engine=t;var i=A?Ei(A.referrer,n):``;i.length&&(r.ph_keyword=i)}return r}function Li(){return navigator.language||navigator.userLanguage}var Ri=`$direct`;function zi(){return A?.referrer||Ri}function Bi(e,t){var n=e?[...Ai,...t||[]]:[],r=j?.href.substring(0,1e3);return{r:zi().substring(0,1e3),u:r?Di(r,n,Mi):void 0}}function Vi(e){var{r:t,u:n}=e,r={$referrer:t,$referring_domain:t==null?void 0:t==Ri?Ri:Ti(t)?.host};if(n){r.$current_url=n;var i=Ti(n);r.$host=i?.host,r.$pathname=i?.pathname,Vr(r,Fi(n))}return t&&Vr(r,Ii(t)),r}function Hi(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Ui(){try{return new Date().getTimezoneOffset()}catch{return}}var Wi=[`cookie`,`localstorage`,`localstorage+cookie`,`sessionstorage`,`memory`],Gi=class{constructor(e,t){this.qt=e,this.props={},this.mr=!1,this.yr=(e=>{var t=``;return e.token&&(t=e.token.replace(/\+/g,`PL`).replace(/\//g,`SL`).replace(/=/g,`EQ`)),e.persistence_name?`ph_`+e.persistence_name:`ph_`+t+`_posthog`})(e),this.nr=this.br(e),this.load(),e.debug&&R.info(`Persistence loaded`,e.persistence,N({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this._r}br(e){Wi.indexOf(e.persistence.toLowerCase())===-1&&(R.critical(`Unknown persistence type `+e.persistence+`; falling back to localStorage+cookie`),e.persistence=`localStorage+cookie`);var t=function(e){e===void 0&&(e=[]);var t=[...ci,...e];return N({},si,{F(e){try{var t={};try{t=ai.F(e)||{}}catch{}var n=Vr(t,JSON.parse(si.A(e)||`{}`));return si.N(e,n),n}catch{}return null},N(e,n,r,i,a,o){try{si.N(e,n,void 0,void 0,o);var s={};t.forEach((e=>{n[e]&&(s[e]=n[e])})),Object.keys(s).length&&ai.N(e,s,r,i,a,o)}catch(e){si.D(e)}},q(e,t){try{D?.localStorage.removeItem(e),ai.q(e,t)}catch(e){si.D(e)}}})}(e.cookie_persisted_properties||[]),n=e.persistence.toLowerCase();return n===`localstorage`&&si.R()?si:n===`localstorage+cookie`&&t.R()?t:n===`sessionstorage`&&fi.R()?fi:n===`memory`?ui:n===`cookie`?ai:t.R()?t:ai}wr(e){var t=e??this.qt.feature_flag_cache_ttl_ms;if(!t||0>=t)return!1;var n=this.props[mr];return!n||typeof n!=`number`||Date.now()-n>t}properties(){var e={};return Br(this.props,((t,n)=>{var r=(e=>{var t=Ci[e];if(t)return t;for(var[n,r]of wi)if(e.indexOf(n)===0)return r})(n);if(r?.exposure===`derived`){if(r.shouldSkipFromEventProperties!=null&&r.shouldSkipFromEventProperties(t,n===Qn?()=>this.wr():()=>!1))return;r.transformToEventProperties&&Vr(e,r.transformToEventProperties(t))}else r&&r.exposure!==`event`||(e[n]=t)})),e}load(){if(!this._r){var e=this.nr.F(this.yr);e&&(this.props=Vr({},e))}}save(){this._r||this.nr.N(this.yr,this.props,this.Sr,this.kr,this.Cr,this.qt.debug)}remove(){this.nr.q(this.yr,!1),this.nr.q(this.yr,!0)}clear(){this.remove(),this.props={}}register_once(e,t,n){if(Oe(e)){I(t)&&(t=`None`),this.Sr=I(n)?this.Ir:n;var r=!1;if(Br(e,((e,n)=>{this.props.hasOwnProperty(n)&&this.props[n]!==t||(this.Tr(n,e),r=!0)})),r)return this.save(),!0}return!1}register(e,t){if(Oe(e)){this.Sr=I(t)?this.Ir:t;var n=!1;if(Br(e,((t,r)=>{e.hasOwnProperty(r)&&this.props[r]!==t&&(this.Tr(r,t),n=!0)})),n)return this.save(),!0}return!1}unregister(e){e in this.props&&(this.Er(e),this.save())}update_campaign_params(){if(!this.mr){var e=Pi(this.qt.custom_campaign_params,this.qt.mask_personal_data_properties,this.qt.custom_personal_data_properties);ke(Gr(e))||this.register(e),this.mr=!0}}update_search_keyword(){var e;this.register((e=A?.referrer)?Ii(e):{})}update_referrer_info(){this.register_once({$referrer:zi(),$referring_domain:A!=null&&A.referrer&&Ti(A.referrer)?.host||Ri},void 0)}set_initial_person_info(){this.props[vr]||this.props[yr]||this.register_once({[br]:Bi(this.qt.mask_personal_data_properties,this.qt.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};Br([yr,vr],(t=>{var n=this.props[t];n&&Br(n,(function(t,n){e[`$initial_`+Ce(n)]=t}))}));var t,n,r=this.props[br];return r&&Vr(e,(t=Vi(r),n={},Br(t,(function(e,t){n[`$initial_`+Ce(t)]=e})),n)),e}safe_merge(e){return Br(this.props,(function(t,n){n in e||(e[n]=t)})),e}update_config(e,t,n){if(this.Ir=this.Sr=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!n),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence||!((e,t)=>{if(e.length!==t.length)return!1;var n=[...e].sort(),r=[...t].sort();return n.every(((e,t)=>e===r[t]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[])){var r=this.br(e),i=this.props;this.clear(),this.nr=r,this.props=i,this.save()}}set_disabled(e){this._r=e,this._r?this.remove():this.save()}set_cross_subdomain(e){e!==this.kr&&(this.kr=e,this.remove(),this.save())}set_secure(e){e!==this.Cr&&(this.Cr=e,this.remove(),this.save())}set_event_timer(e,t){var n=this.props[Fn]||{};n[e]=t,this.Tr(Fn,n),this.save()}remove_event_timer(e){var t=this.props[Fn]||{},n=t[e];return I(n)||(delete t[e],this.Tr(Fn,t),this.save()),n}get_property(e){return this.props[e]}set_property(e,t){this.Tr(e,t),this.save()}Tr(e,t){this.props[e]=t}Er(e){delete this.props[e]}},Ki={Activation:`events`,Cancellation:`cancelEvents`},qi={Popover:`popover`,API:`api`,Widget:`widget`,ExternalSurvey:`external_survey`},Ji={SHOWN:`survey shown`,DISMISSED:`survey dismissed`,SENT:`survey sent`,ABANDONED:`survey abandoned`},Yi={SURVEY_ID:`$survey_id`,SURVEY_NAME:`$survey_name`,SURVEY_RESPONSE:`$survey_response`,SURVEY_ITERATION:`$survey_iteration`,SURVEY_ITERATION_START_DATE:`$survey_iteration_start_date`,SURVEY_PARTIALLY_COMPLETED:`$survey_partially_completed`,SURVEY_SUBMISSION_ID:`$survey_submission_id`,SURVEY_QUESTIONS:`$survey_questions`,SURVEY_COMPLETED:`$survey_completed`,PRODUCT_TOUR_ID:`$product_tour_id`,SURVEY_LAST_SEEN_DATE:`$survey_last_seen_date`,SURVEY_LANGUAGE:`$survey_language`},Xi={Popover:`popover`,Inline:`inline`},Zi={SHOWN:`product tour shown`,DISMISSED:`product tour dismissed`,COMPLETED:`product tour completed`,STEP_SHOWN:`product tour step shown`,STEP_COMPLETED:`product tour step completed`,BUTTON_CLICKED:`product tour button clicked`,STEP_SELECTOR_FAILED:`product tour step selector failed`,BANNER_CONTAINER_SELECTOR_FAILED:`product tour banner container selector failed`,BANNER_ACTION_CLICKED:`product tour banner action clicked`},Qi={TOUR_ID:`$product_tour_id`,TOUR_NAME:`$product_tour_name`,TOUR_ITERATION:`$product_tour_iteration`,TOUR_RENDER_REASON:`$product_tour_render_reason`,TOUR_STEP_ID:`$product_tour_step_id`,TOUR_STEP_ORDER:`$product_tour_step_order`,TOUR_STEP_TYPE:`$product_tour_step_type`,TOUR_DISMISS_REASON:`$product_tour_dismiss_reason`,TOUR_BUTTON_TEXT:`$product_tour_button_text`,TOUR_BUTTON_ACTION:`$product_tour_button_action`,TOUR_BUTTON_LINK:`$product_tour_button_link`,TOUR_BUTTON_TOUR_ID:`$product_tour_button_tour_id`,TOUR_STEPS_COUNT:`$product_tour_steps_count`,TOUR_STEP_SELECTOR:`$product_tour_step_selector`,TOUR_STEP_SELECTOR_FOUND:`$product_tour_step_selector_found`,TOUR_STEP_ELEMENT_TAG:`$product_tour_step_element_tag`,TOUR_STEP_ELEMENT_ID:`$product_tour_step_element_id`,TOUR_STEP_ELEMENT_CLASSES:`$product_tour_step_element_classes`,TOUR_STEP_ELEMENT_TEXT:`$product_tour_step_element_text`,TOUR_ERROR:`$product_tour_error`,TOUR_MATCHES_COUNT:`$product_tour_matches_count`,TOUR_FAILURE_PHASE:`$product_tour_failure_phase`,TOUR_WAITED_FOR_ELEMENT:`$product_tour_waited_for_element`,TOUR_WAIT_DURATION_MS:`$product_tour_wait_duration_ms`,TOUR_BANNER_SELECTOR:`$product_tour_banner_selector`,TOUR_LINKED_SURVEY_ID:`$product_tour_linked_survey_id`,USE_MANUAL_SELECTOR:`$use_manual_selector`,INFERENCE_DATA_PRESENT:`$inference_data_present`,TOUR_LAST_SEEN_DATE:`$product_tour_last_seen_date`,TOUR_TYPE:`$product_tour_type`},$i=kn(`[RateLimiter]`),ea=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach((e=>{$i.info((e||`events`)+` is quota limited.`),this.serverLimits[e]=new Date().getTime()+6e4}))}catch(e){$i.warn(`could not rate limit - continuing. Error: "`+e?.message+`"`,{text:t});return}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){return this.instance.config.rate_limiting?.events_per_second||10}get captureEventsBurstLimit(){return Math.max(this.instance.config.rate_limiting?.events_burst_limit||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t;e===void 0&&(e=!1);var{captureEventsBurstLimit:n,captureEventsPerSecond:r}=this,i=new Date().getTime(),a=this.instance.persistence?.get_property(_r)??{tokens:n,last:i};a.tokens+=(i-a.last)/1e3*r,a.last=i,a.tokens>n&&(a.tokens=n);var o=1>a.tokens;return o||e||(a.tokens=Math.max(0,a.tokens-1)),!o||this.lastEventRateLimited||e||this.instance.capture(`$$client_ingestion_warning`,{$$client_ingestion_warning_message:`posthog-js client rate limited. Config is set to `+r+` events per second and `+n+` events burst limit.`},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=o,(t=this.instance.persistence)==null||t.set_property(_r,a),{isRateLimited:o,remainingTokens:a.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||`events`]||!1;return!1!==t&&new Date().getTime()<t}},ta=kn(`[RemoteConfig]`),na=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=M._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}Mr(e){var t,n;(t=M.__PosthogExtensions__)!=null&&t.loadExternalDependency?(n=M.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`remote-config`,(()=>e(this.remoteConfig))):e()}Pr(e){this._instance._send_request({method:`GET`,url:this._instance.requestRouter.endpointFor(`assets`,`/array/`+this._instance.config.token+`/config`),callback(t){e(t.json)}})}load(){try{if(this.remoteConfig)return ta.info(`Using preloaded remote config`,this.remoteConfig),this.Rr(this.remoteConfig),void this.Or();if(this._instance.Lr())return void ta.warn(`Remote config is disabled. Falling back to local config.`);this.Mr((e=>{if(!e)return ta.info(`No config found after loading remote JS config. Falling back to JSON.`),void this.Pr((e=>{this.Rr(e),this.Or()}));this.Rr(e),this.Or()}))}catch(e){ta.error(`Error loading remote config`,e)}}stop(){this.Fr&&=(clearInterval(this.Fr),void 0)}refresh(){!this._instance.Lr()&&A&&A.visibilityState!==`hidden`&&this._instance.reloadFeatureFlags()}Or(){if(!this.Fr){var e=this._instance.config.remote_config_refresh_interval_ms??3e5;e!==0&&(this.Fr=setInterval((()=>{this.refresh()}),e))}}Rr(e){var t;e||ta.error(`Failed to fetch remote config from PostHog.`),this._instance.Rr(e??{}),!1!==e?.hasFeatureFlags&&(this._instance.config.advanced_disable_feature_flags_on_first_load||(t=this._instance.featureFlags)==null||t.ensureFlagsLoaded())}},ra={GZipJS:`gzip-js`,Base64:`base64`},ia=Uint8Array,aa=Uint16Array,oa=Uint32Array,sa=new ia([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ca=new ia([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),la=new ia([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ua=function(e,t){for(var n=new aa(31),r=0;31>r;++r)n[r]=t+=1<<e[r-1];var i=new oa(n[30]);for(r=1;30>r;++r)for(var a=n[r];n[r+1]>a;++a)i[a]=a-n[r]<<5|r;return[n,i]},da=ua(sa,2),fa=da[1];da[0][28]=258,fa[258]=28;for(var pa=ua(ca,0)[1],ma=new aa(32768),ha=0;32768>ha;++ha){var ga=(43690&ha)>>>1|(21845&ha)<<1;ma[ha]=((65280&(ga=(61680&(ga=(52428&ga)>>>2|(13107&ga)<<2))>>>4|(3855&ga)<<4))>>>8|(255&ga)<<8)>>>1}var _a=function(e,t,n){for(var r=e.length,i=0,a=new aa(t);r>i;++i)++a[e[i]-1];var o,s=new aa(t);for(i=0;t>i;++i)s[i]=s[i-1]+a[i-1]<<1;if(n){o=new aa(1<<t);var c=15-t;for(i=0;r>i;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=s[e[i]-1]++<<u,f=d|(1<<u)-1;f>=d;++d)o[ma[d]>>>c]=l}else for(o=new aa(r),i=0;r>i;++i)o[i]=ma[s[e[i]-1]++]>>>15-e[i];return o},va=new ia(288);for(ha=0;144>ha;++ha)va[ha]=8;for(ha=144;256>ha;++ha)va[ha]=9;for(ha=256;280>ha;++ha)va[ha]=7;for(ha=280;288>ha;++ha)va[ha]=8;var ya=new ia(32);for(ha=0;32>ha;++ha)ya[ha]=5;var ba=_a(va,9,0),xa=_a(ya,5,0),Sa=function(e){return(e/8>>0)+(7&e&&1)},Ca=function(e,t,n){(n==null||n>e.length)&&(n=e.length);var r=new(e instanceof aa?aa:e instanceof oa?oa:ia)(n-t);return r.set(e.subarray(t,n)),r},wa=function(e,t,n){var r=t/8>>0;e[r]|=n<<=7&t,e[r+1]|=n>>>8},Ta=function(e,t,n){var r=t/8>>0;e[r]|=n<<=7&t,e[r+1]|=n>>>8,e[r+2]|=n>>>16},Ea=function(e,t){for(var n=[],r=0;e.length>r;++r)e[r]&&n.push({s:r,f:e[r]});var i=n.length,a=n.slice();if(!i)return[new ia(0),0];if(i==1){var o=new ia(n[0].s+1);return o[n[0].s]=1,[o,1]}n.sort((function(e,t){return e.f-t.f})),n.push({s:-1,f:25001});var s=n[0],c=n[1],l=0,u=1,d=2;for(n[0]={s:-1,f:s.f+c.f,l:s,r:c};u!=i-1;)s=n[n[d].f>n[l].f?l++:d++],c=n[l!=u&&n[d].f>n[l].f?l++:d++],n[u++]={s:-1,f:s.f+c.f,l:s,r:c};var f=a[0].s;for(r=1;i>r;++r)a[r].s>f&&(f=a[r].s);var p=new aa(f+1),m=Da(n[u-1],p,0);if(m>t){r=0;var h=0,g=m-t,_=1<<g;for(a.sort((function(e,t){return p[t.s]-p[e.s]||e.f-t.f}));i>r;++r){var v=a[r].s;if(t>=p[v])break;h+=_-(1<<m-p[v]),p[v]=t}for(h>>>=g;h>0;){var y=a[r].s;t>p[y]?h-=1<<t-p[y]++-1:++r}for(;r>=0&&h;--r){var b=a[r].s;p[b]==t&&(--p[b],++h)}m=t}return[new ia(p),m]},Da=function(e,t,n){return e.s==-1?Math.max(Da(e.l,t,n+1),Da(e.r,t,n+1)):t[e.s]=n},Oa=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new aa(++t),r=0,i=e[0],a=1,o=function(e){n[r++]=e},s=1;t>=s;++s)if(e[s]==i&&s!=t)++a;else{if(!i&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(i),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(i);a=1,i=e[s]}return[n.subarray(0,r),t]},ka=function(e,t){for(var n=0,r=0;t.length>r;++r)n+=e[r]*t[r];return n},Aa=function(e,t,n){var r=n.length,i=Sa(t+2);e[i]=255&r,e[i+1]=r>>>8,e[i+2]=255^e[i],e[i+3]=255^e[i+1];for(var a=0;r>a;++a)e[i+a+4]=n[a];return 8*(i+4+r)},ja=function(e,t,n,r,i,a,o,s,c,l,u){wa(t,u++,n),++i[256];for(var d=Ea(i,15),f=d[0],p=d[1],m=Ea(a,15),h=m[0],g=m[1],_=Oa(f),v=_[0],y=_[1],b=Oa(h),x=b[0],S=b[1],C=new aa(19),w=0;v.length>w;++w)C[31&v[w]]++;for(w=0;x.length>w;++w)C[31&x[w]]++;for(var T=Ea(C,7),E=T[0],ee=T[1],D=19;D>4&&!E[la[D-1]];--D);var O,k,A,j,te=l+5<<3,ne=ka(i,va)+ka(a,ya)+o,re=ka(i,f)+ka(a,h)+o+14+3*D+ka(C,E)+(2*C[16]+3*C[17]+7*C[18]);if(ne>=te&&re>=te)return Aa(t,u,e.subarray(c,c+l));if(wa(t,u,1+(ne>re)),u+=2,ne>re){O=_a(f,p,0),k=f,A=_a(h,g,0),j=h;var ie=_a(E,ee,0);for(wa(t,u,y-257),wa(t,u+5,S-1),wa(t,u+10,D-4),u+=14,w=0;D>w;++w)wa(t,u+3*w,E[la[w]]);u+=3*D;for(var ae=[v,x],M=0;2>M;++M){var oe=ae[M];for(w=0;oe.length>w;++w)wa(t,u,ie[se=31&oe[w]]),u+=E[se],se>15&&(wa(t,u,oe[w]>>>5&127),u+=oe[w]>>>12)}}else O=ba,k=va,A=xa,j=ya;for(w=0;s>w;++w)if(r[w]>255){var se;Ta(t,u,O[257+(se=r[w]>>>18&31)]),u+=k[se+257],se>7&&(wa(t,u,r[w]>>>23&31),u+=sa[se]);var ce=31&r[w];Ta(t,u,A[ce]),u+=j[ce],ce>3&&(Ta(t,u,r[w]>>>5&8191),u+=ca[ce])}else Ta(t,u,O[r[w]]),u+=k[r[w]];return Ta(t,u,O[256]),u+k[256]},Ma=new oa([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Na=function(){for(var e=new oa(256),t=0;256>t;++t){for(var n=t,r=9;--r;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),Pa=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function Fa(e,t){t===void 0&&(t={});var n=function(){var e=4294967295;return{p(t){for(var n=e,r=0;t.length>r;++r)n=Na[255&n^t[r]]^n>>>8;e=n},d(){return 4294967295^e}}}(),r=e.length;n.p(e);var i,a,o,s,c,l=(s=10+((i=t).filename&&i.filename.length+1||0),c=8,function(e,t,n,r,i,a){var o=e.length,s=new ia(r+o+5*(1+Math.floor(o/7e3))+i),c=s.subarray(r,s.length-i),l=0;if(!t||8>o)for(var u=0;o>=u;u+=65535){var d=u+65535;o>d?l=Aa(c,l,e.subarray(u,d)):(c[u]=!0,l=Aa(c,l,e.subarray(u,o)))}else{for(var f=Ma[t-1],p=f>>>13,m=8191&f,h=(1<<n)-1,g=new aa(32768),_=new aa(h+1),v=Math.ceil(n/3),y=2*v,b=function(t){return(e[t]^e[t+1]<<v^e[t+2]<<y)&h},x=new oa(25e3),S=new aa(288),C=new aa(32),w=0,T=0,E=(u=0,0),ee=0,D=0;o>u;++u){var O=b(u),k=32767&u,A=_[O];if(g[k]=A,_[O]=k,u>=ee){var j=o-u;if((w>7e3||E>24576)&&j>423){l=ja(e,c,0,x,S,C,T,E,D,u-D,l),E=w=T=0,D=u;for(var te=0;286>te;++te)S[te]=0;for(te=0;30>te;++te)C[te]=0}var ne=2,re=0,ie=m,ae=k-A&32767;if(j>2&&O==b(u-ae))for(var M=Math.min(p,j)-1,oe=Math.min(32767,u),se=Math.min(258,j);oe>=ae&&--ie&&k!=A;){if(e[u+ne]==e[u+ne-ae]){for(var ce=0;se>ce&&e[u+ce]==e[u+ce-ae];++ce);if(ce>ne){if(ne=ce,re=ae,ce>M)break;var le=Math.min(ae,ce-2),N=0;for(te=0;le>te;++te){var ue=u-ae+te+32768&32767,de=ue-g[ue]+32768&32767;de>N&&(N=de,A=ue)}}}ae+=(k=A)-(A=g[k])+32768&32767}if(re){x[E++]=268435456|fa[ne]<<18|pa[re];var fe=31&fa[ne],pe=31&pa[re];T+=sa[fe]+ca[pe],++S[257+fe],++C[pe],ee=u+ne,++w}else x[E++]=e[u],++S[e[u]]}}l=ja(e,c,!0,x,S,C,T,E,D,u-D,l)}return Ca(s,0,r+Sa(l)+i)}(a=e,(o=t).level==null?6:o.level,o.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(a.length)))):12+o.mem,s,c)),u=l.length;return function(e,t){var n=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=2>t.level?4:t.level==9?2:0,e[9]=3,t.mtime!=0&&Pa(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),n){e[3]=8;for(var r=0;n.length>=r;++r)e[r+10]=n.charCodeAt(r)}}(l,t),Pa(l,u-8,n.d()),Pa(l,u-4,r),l}var Ia=!!ne||!!te,La=`text/plain`,Ra=!1,za=(e,t)=>{var[n,r]=e.split(`#`),[i,a]=n.split(`?`);if(!a)return e;var o=a.split(`&`).filter((e=>e.split(`=`)[0]!==t)).join(`&`);return i+(o?`?`+o:``)+(r?`#`+r:``)},Ba=function(e,t,n){n===void 0&&(n=!0);var[r,i]=e.split(`?`),a=N({},t),o=i?.split(`&`).map((e=>{var t,[r,i]=e.split(`=`),o=n&&(t=a[r])!=null?t:i;return delete a[r],r+`=`+o}))??[],s=function(e,t){var n,r;t===void 0&&(t=`&`);var i=[];return Br(e,(function(e,t){I(e)||I(t)||t===`undefined`||(n=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),r=encodeURIComponent(t),i[i.length]=r+`=`+n)})),i.join(t)}(a);return s&&o.push(s),r+`?`+o.join(`&`)},Va=(e,t)=>JSON.stringify(e,((e,t)=>typeof t==`bigint`?t.toString():t),t),Ha=e=>{if(e.tr)return e.tr;var{data:t,compression:n}=e;if(t){if(n===ra.GZipJS){var r=Fa(function(e,t){var n=e.length;if(typeof TextEncoder<`u`)return new TextEncoder().encode(e);for(var r=new ia(e.length+(e.length>>>1)),i=0,a=function(e){r[i++]=e},o=0;n>o;++o){if(i+5>r.length){var s=new ia(i+8+(n-o<<1));s.set(r),r=s}var c=e.charCodeAt(o);128>c?a(c):2048>c?(a(192|c>>>6),a(128|63&c)):c>55295&&57344>c?(a(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++o))>>>18),a(128|c>>>12&63),a(128|c>>>6&63),a(128|63&c)):(a(224|c>>>12),a(128|c>>>6&63),a(128|63&c))}return Ca(r,0,i)}(Va(t)),{mtime:0});return{contentType:La,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(n===ra.Base64){var i=(e=>`data=`+encodeURIComponent(typeof e==`string`?e:Va(e)))(function(e){return e&&btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(parseInt(t,16)))))}(Va(t)));return{contentType:`application/x-www-form-urlencoded`,body:i,estimatedSize:new Blob([i]).size}}var a=Va(t);return{contentType:`application/json`,body:a,estimatedSize:new Blob([a]).size}}},Ua=e=>{var t,n,r,i=Ha(e);return!i||(n=e.compression,r=Ei(e.url,`compression`),n!==fe.GZipJS&&r!==fe.GZipJS&&r!==`gzip`)||((t=i.body)instanceof ArrayBuffer?he(new Uint8Array(t)):ArrayBuffer.isView(t)&&he(new Uint8Array(t.buffer,t.byteOffset,t.byteLength)))?{url:e.url,encodedBody:i}:(Ra=!0,{url:za(e.url,`compression`),encodedBody:Ha(N({},e,{compression:void 0,tr:void 0}))})},Wa=function(){var e=le((function*(e){var t=yield function(e,t,n){return ye.apply(this,arguments)}(Va(e.data),se.DEBUG,{rethrow:!0});if(!t)return e;var n=yield t.arrayBuffer();return N({},e,{tr:{contentType:La,body:n,estimatedSize:n.byteLength}})}));return function(t){return e.apply(this,arguments)}}(),Ga=(e,t)=>Ba(e,{_:new Date().getTime().toString(),ver:se.JS_SDK_VERSION,compression:t}),Ka=[];te&&Ka.push({transport:`fetch`,method(e){var{url:t,encodedBody:n}=Ua(e),{contentType:r,body:i,estimatedSize:a}=n??{},o=new Headers;Br(e.headers,(function(e,t){o.append(t,e)})),r&&o.append(`Content-Type`,r);var s=null;if(re){var c=new re;s={signal:c.signal,timeout:setTimeout((()=>c.abort()),e.timeout)}}te(t,N({method:e?.method||`GET`,headers:o,keepalive:e.method===`POST`&&52428.8>(a||0),body:i,signal:s?.signal},e.fetchOptions)).then((t=>t.text().then((n=>{var r={statusCode:t.status,text:n};if(t.status===200)try{r.json=JSON.parse(n)}catch(e){R.error(e)}e.callback==null||e.callback(r)})))).catch((t=>{R.error(t),e.callback==null||e.callback({statusCode:0,error:t})})).finally((()=>s?clearTimeout(s.timeout):null))}}),ne&&Ka.push({transport:`XHR`,method(e){var t=new ne,{url:n,encodedBody:r}=Ua(e);t.open(e.method||`GET`,n,!0);var{contentType:i,body:a}=r??{};Br(e.headers,(function(e,n){t.setRequestHeader(n,e)})),i&&t.setRequestHeader(`Content-Type`,i),e.timeout&&(t.timeout=e.timeout),e.disableXHRCredentials||(t.withCredentials=!0),t.onreadystatechange=()=>{if(t.readyState===4){var n={statusCode:t.status,text:t.responseText};if(t.status===200)try{n.json=JSON.parse(t.responseText)}catch{}e.callback==null||e.callback(n)}},t.send(a)}}),k!=null&&k.sendBeacon&&Ka.push({transport:`sendBeacon`,method(e){try{var{url:t,encodedBody:n}=Ua(e),r=Ba(t,{beacon:`1`}),{contentType:i,body:a}=n??{};if(!a)return;var o=a instanceof Blob?a:new Blob([a],{type:i});k.sendBeacon(r,o)}catch{}}});var qa=3e3,Ja=class{constructor(e,t){this.Ar=!0,this.Nr=[],this.$r=We(t?.flush_interval_ms||qa,250,5e3,R.createLogger(`flush interval`),qa),this.Dr=e}enqueue(e){this.Nr.push(e),this.qr||this.jr()}unload(){this.Hr();var e=this.Nr.length>0?this.Ur():{},t=Object.values(e);[...t.filter((e=>e.url.indexOf(`/e`)===0)),...t.filter((e=>e.url.indexOf(`/e`)!==0))].map((e=>{this.Dr(N({},e,{transport:`sendBeacon`}))}))}enable(){this.Ar=!1,this.jr()}jr(){var e=this;this.Ar||(this.qr=setTimeout((()=>{if(this.Hr(),this.Nr.length>0){var t=this.Ur(),n=function(){var n=t[r],i=new Date().getTime();n.data&&F(n.data)&&Br(n.data,(e=>{e.offset=Math.abs(e.timestamp-i),delete e.timestamp})),e.Dr(n)};for(var r in t)n()}}),this.$r))}Hr(){clearTimeout(this.qr),this.qr=void 0}Ur(){var e={};return Br(this.Nr,(t=>{var n,r=t,i=(r?r.batchKey:null)||r.url;I(e[i])&&(e[i]=N({},r,{data:[]})),(n=e[i].data)==null||n.push(r.data)})),this.Nr=[],e}},Ya=[`retriesPerformedSoFar`],Xa=class{constructor(e){this.Br=!1,this.zr=3e3,this.Nr=[],this._instance=e,this.Nr=[],this.Vr=!0,!I(D)&&`onLine`in D.navigator&&(this.Vr=D.navigator.onLine,this.Wr=()=>{this.Vr=!0,this.Zr()},this.Gr=()=>{this.Vr=!1},Jr(D,`online`,this.Wr),Jr(D,`offline`,this.Gr))}get length(){return this.Nr.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,n=ue(e,Ya);Pe(t)&&(n.url=Ba(n.url,{retry_count:t})),this._instance._send_request(N({},n,{callback:e=>{e.statusCode===200||e.statusCode>=400&&500>e.statusCode||(t??0)>=10?n.callback==null||n.callback(e):this.Qr(N({retriesPerformedSoFar:t},n))}}))}Qr(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var n=function(e){var t=3e3*2**e,n=t/2,r=Math.min(18e5,t),i=Math.random()-.5;return Math.ceil(r+i*(r-n))}(t),r=Date.now()+n;this.Nr.push({retryAt:r,requestOptions:e});var i=`Enqueued failed request for retry in `+n;navigator.onLine||(i+=` (Browser is offline)`),R.warn(i),this.Br||(this.Br=!0,this.Jr())}Jr(){if(this.Kr&&clearTimeout(this.Kr),this.Nr.length===0)return this.Br=!1,void(this.Kr=void 0);this.Kr=setTimeout((()=>{this.Vr&&this.Nr.length>0&&this.Zr(),this.Jr()}),this.zr)}Zr(){var e=Date.now(),t=[],n=this.Nr.filter((n=>e>n.retryAt||(t.push(n),!1)));if(this.Nr=t,n.length>0)for(var{requestOptions:r}of n)this.retriableRequest(r)}unload(){for(var{requestOptions:e}of(this.Kr&&=(clearTimeout(this.Kr),void 0),this.Br=!1,I(D)||(this.Wr&&=(D.removeEventListener(`online`,this.Wr),void 0),this.Gr&&=(D.removeEventListener(`offline`,this.Gr),void 0)),this.Nr))try{this._instance._send_request(N({},e,{transport:`sendBeacon`}))}catch(e){R.error(e)}this.Nr=[]}},Za=class{constructor(e){this.Yr=()=>{this.Xr||={};var e=this.scrollElement(),t=this.scrollY(),n=e?Math.max(0,e.scrollHeight-e.clientHeight):0,r=t+(e?.clientHeight||0),i=e?.scrollHeight||0;this.Xr.lastScrollY=Math.ceil(t),this.Xr.maxScrollY=Math.max(t,this.Xr.maxScrollY??0),this.Xr.maxScrollHeight=Math.max(n,this.Xr.maxScrollHeight??0),this.Xr.lastContentY=r,this.Xr.maxContentY=Math.max(r,this.Xr.maxContentY??0),this.Xr.maxContentHeight=Math.max(i,this.Xr.maxContentHeight??0)},this._instance=e}get ei(){return this._instance.config.scroll_root_selector}getContext(){return this.Xr}resetContext(){var e=this.Xr;return setTimeout(this.Yr,0),e}startMeasuringScrollPosition(){Jr(D,`scroll`,this.Yr,{capture:!0}),Jr(D,`scrollend`,this.Yr,{capture:!0}),Jr(D,`resize`,this.Yr)}scrollElement(){if(!this.ei)return D?.document.documentElement;for(var e of F(this.ei)?this.ei:[this.ei]){var t=D?.document.querySelector(e);if(t)return t}}scrollY(){if(this.ei){var e=this.scrollElement();return e&&e.scrollTop||0}return D&&(D.scrollY||D.pageYOffset||D.document.documentElement.scrollTop)||0}scrollX(){if(this.ei){var e=this.scrollElement();return e&&e.scrollLeft||0}return D&&(D.scrollX||D.pageXOffset||D.document.documentElement.scrollLeft)||0}},Qa=e=>Bi(e?.config.mask_personal_data_properties,e?.config.custom_personal_data_properties),$a=class{constructor(e,t,n,r){this.ti=e=>{var t=this.ri();if(!t||t.sessionId!==e){var n={sessionId:e,props:this.ii(this._instance)};this.ni.register({[gr]:n})}},this._instance=e,this.si=t,this.ni=n,this.ii=r||Qa,this.si.onSessionId(this.ti)}ri(){return this.ni.props[gr]}getSetOnceProps(){var e=this.ri()?.props;return e?`r`in e?Vi(e):{$referring_domain:e.referringDomain,$pathname:e.initialPathName,utm_source:e.utm_source,utm_campaign:e.utm_campaign,utm_medium:e.utm_medium,utm_content:e.utm_content,utm_term:e.utm_term}:{}}getSessionProps(){var e={};return Br(Gr(this.getSetOnceProps()),((t,n)=>{n===`$current_url`&&(n=`url`),e[`$session_entry_`+Ce(n)]=t})),e}},eo=class{constructor(){this.oi={}}on(e,t){return this.oi[e]||(this.oi[e]=[]),this.oi[e].push(t),()=>{this.oi[e]=this.oi[e].filter((e=>e!==t))}}emit(e,t){for(var n of this.oi[e]||[])n(t);for(var r of this.oi[`*`]||[])r(e,t)}},to=kn(`[SessionId]`),no=class{on(e,t){return this.ai.on(e,t)}constructor(e,t,n){var r;if(this.ui=[],this.li=void 0,this.ai=new eo,this.hi=(e,t)=>!(!Pe(e)||!Pe(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw Error(`SessionIdManager requires a PostHogPersistence instance`);if(e.config.cookieless_mode===kr)throw Error(`SessionIdManager cannot be used with cookieless_mode="always"`);this.qt=e.config,this.ni=e.persistence,this.ci=void 0,this.di=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.vi=t||ti,this.fi=n||ti;var i=this.qt.persistence_name||this.qt.token;if(this._sessionTimeoutMs=1e3*We(this.qt.session_idle_timeout_seconds||1800,60,36e3,to.createLogger(`session_idle_timeout_seconds`),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.pi(),this.gi=`ph_`+i+`_window_id`,this.mi=`ph_`+i+`_primary_window_exists`,this.yi()){var a=fi.F(this.gi),o=fi.F(this.mi);a&&!o?this.ci=a:fi.q(this.gi),fi.N(this.mi,!0)}if((r=this.qt.bootstrap)!=null&&r.sessionID)try{var s=(e=>{var t=this.qt.bootstrap.sessionID.replace(/-/g,``);if(t.length!==32)throw Error(`Not a valid UUID`);if(t[12]!==`7`)throw Error(`Not a UUIDv7`);return parseInt(t.substring(0,12),16)})();this.bi(this.qt.bootstrap.sessionID,new Date().getTime(),s)}catch(e){to.error(`Invalid sessionID in bootstrap`,e)}this.wi()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return I(this.ui)&&(this.ui=[]),this.ui.push(e),this.di&&e(this.di,this.ci),()=>{this.ui=this.ui.filter((t=>t!==e))}}yi(){return this.qt.persistence!==`memory`&&!this.ni._r&&fi.R()}xi(e){e!==this.ci&&(this.ci=e,this.yi()&&fi.N(this.gi,e))}Si(){return this.ci?this.ci:this.yi()?fi.F(this.gi):null}bi(e,t,n){e===this.di&&t===this._sessionActivityTimestamp&&n===this._sessionStartTimestamp||(this._sessionStartTimestamp=n,this._sessionActivityTimestamp=t,this.di=e,this.ni.register({[Xn]:[t,e,n]}))}ki(){var e=this.ni.props[Xn];return F(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.bi(null,null,null)}destroy(){clearTimeout(this.Ci),this.Ci=void 0,this.li&&D&&(D.removeEventListener(Pr,this.li,{capture:!1}),this.li=void 0),this.ui=[]}wi(){this.li=()=>{this.yi()&&fi.q(this.mi)},Jr(D,Pr,this.li,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(e===void 0&&(e=!1),t===void 0&&(t=null),this.qt.cookieless_mode===kr)throw Error(`checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"`);var n=t||new Date().getTime(),[r,i,a]=this.ki(),o=this.Si(),s=Pe(a)&&Math.abs(n-a)>864e5,c=!1,l=!i,u=!l&&!e&&this.hi(n,r);l||u||s?(i=this.vi(),o=this.fi(),to.info(`new session ID generated`,{sessionId:i,windowId:o,changeReason:{noSessionId:l,activityTimeout:u,sessionPastMaximumLength:s}}),a=n,c=!0):o||(o=this.fi(),c=!0);var d=Pe(r)&&e&&!s?r:n,f=Pe(a)?a:new Date().getTime();return this.xi(o),this.bi(i,d,f),e||this.pi(),c&&this.ui.forEach((e=>e(i,o,c?{noSessionId:l,activityTimeout:u,sessionPastMaximumLength:s}:void 0))),{sessionId:i,windowId:o,sessionStartTimestamp:f,changeReason:c?{noSessionId:l,activityTimeout:u,sessionPastMaximumLength:s}:void 0,lastActivityTimestamp:r}}pi(){clearTimeout(this.Ci),this.Ci=setTimeout((()=>{var[e]=this.ki();if(this.hi(new Date().getTime(),e)){var t=this.di;this.resetSessionId(),this.ai.emit(`forcedIdleReset`,{idleSessionId:t})}}),1.1*this.sessionTimeoutMs)}},ro=function(e,t){if(!e)return!1;var n=e.userAgent;if(n&&xe(n,t))return!0;try{var r=e?.userAgentData;if(r!=null&&r.brands&&r.brands.some((e=>xe(e?.brand,t))))return!0}catch{}return!!e.webdriver},io=function(e,t){if(!function(e){try{new RegExp(e)}catch{return!1}return!0}(t))return!1;try{return new RegExp(t).test(e)}catch{return!1}};function ao(e,t,n){return Va({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:n})}var oo={exact:(e,t)=>t.some((t=>e.some((e=>t===e)))),is_not:(e,t)=>t.every((t=>e.every((e=>t!==e)))),regex:(e,t)=>t.some((t=>e.some((e=>io(t,e))))),not_regex:(e,t)=>t.every((t=>e.every((e=>!io(t,e))))),icontains:(e,t)=>t.map(so).some((t=>e.map(so).some((e=>t.includes(e))))),not_icontains:(e,t)=>t.map(so).every((t=>e.map(so).every((e=>!t.includes(e))))),gt:(e,t)=>t.some((t=>{var n=parseFloat(t);return!isNaN(n)&&e.some((e=>n>parseFloat(e)))})),lt:(e,t)=>t.some((t=>{var n=parseFloat(t);return!isNaN(n)&&e.some((e=>n<parseFloat(e)))}))},so=e=>e.toLowerCase();function co(e,t){return!e||Object.entries(e).every((e=>{var[n,r]=e,i=t?.[n];if(I(i)||Me(i))return!1;var a=[String(i)],o=oo[r.operator];return!!o&&o(r.values,a)}))}var lo=`custom`,uo=`i.posthog.com`,fo=/^\/static\//,po=class{constructor(e){this.Ii={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,``);return e===`https://app.posthog.com`?`https://us.i.posthog.com`:e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,``):this.apiHost}get uiHost(){var e=this.instance.config.ui_host?.replace(/\/$/,``);return e||=this.apiHost.replace(`.`+uo,`.posthog.com`),e===`https://app.posthog.com`?`https://us.posthog.com`:e}get region(){return this.Ii[this.apiHost]||(this.Ii[this.apiHost]=/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?`us`:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?`eu`:lo),this.Ii[this.apiHost]}Ti(e){var t=this.instance.config.__preview_external_dependency_versioned_paths;if(typeof t==`string`&&fo.test(e))return t.trim().replace(/\/$/,``)||void 0}endpointFor(e,t){if(t===void 0&&(t=``),t&&=t[0]===`/`?t:`/`+t,e===`ui`)return this.uiHost+t;if(e===`flags`)return this.flagsApiHost+t;if(e===`assets`){var n=this.Ti(t);if(n)return``+n+t}if(this.region===lo)return this.apiHost+t;var r=uo+t;switch(e){case`assets`:return`https://`+this.region+`-assets.`+r;case`api`:return`https://`+this.region+`.`+r}}},z=kn(`[Surveys]`),mo=`seenSurvey_`,ho=[qi.Popover,qi.Widget,qi.API],go={ignoreConditions:!1,ignoreDelay:!1,displayType:Xi.Popover},_o=kn(`[PostHog ExternalIntegrations]`),vo={intercom:`intercom-integration`,crispChat:`crisp-chat-integration`},yo=class{constructor(e){this._instance=e}lr(e,t){var n;(n=M.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,e,(e=>{if(e)return _o.error(`failed to load script`,e);t()}))}startIfEnabledOrStop(){var e=this,t=function(t){var n,i,a;!r||(n=M.__PosthogExtensions__)!=null&&(n=n.integrations)!=null&&n[t]||e.lr(vo[t],(()=>{var n;(n=M.__PosthogExtensions__)==null||(n=n.integrations)==null||(n=n[t])==null||n.start(e._instance)})),!r&&(i=M.__PosthogExtensions__)!=null&&(i=i.integrations)!=null&&i[t]&&((a=M.__PosthogExtensions__)==null||(a=a.integrations)==null||(a=a[t])==null||a.stop())};for(var[n,r]of Object.entries((i=this._instance.config.integrations)??{})){var i;t(n)}}},bo,xo={},So=0,Co=()=>{},wo=`Consent opt in/out is not valid with cookieless_mode="always" and will be ignored`,To=`Surveys module not available`,Eo=`sanitize_properties is deprecated. Use before_send instead`,Do=`Invalid value for property_denylist config: `,Oo=`posthog`,ko=!Ia&&ae?.indexOf(`MSIE`)===-1&&ae?.indexOf(`Mozilla`)===-1,Ao=e=>{var t;return N({api_host:`https://us.i.posthog.com`,flags_api_host:null,ui_host:null,token:``,autocapture:!0,cross_subdomain_cookie:qr(A?.location),persistence:`localStorage+cookie`,persistence_name:``,cookie_persisted_properties:[],loaded:Co,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:`if_capture_pageview`,defaults:e??`unset`,__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,debug:j&&Ae(j?.search)&&j.search.indexOf(`__posthog_debug=true`)!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(D==null||(t=D.location)==null?void 0:t.protocol)===`https:`,ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:`localStorage`,consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(e){R.error(`Bad HTTP status: `+e.statusCode+` `+e.text)},get_device_id:e=>e,capture_performance:void 0,name:`posthog`,bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Mr,before_send:void 0,request_queue_config:{flush_interval_ms:qa},error_tracking:{},_onCapture:Co,__preview_eager_load_replay:!1},(e=>({rageclick:!e||`2025-11-30`>e||{content_ignorelist:!0},capture_pageview:!e||`2025-05-24`>e||`history_change`,session_recording:e&&e>=`2025-11-30`?{strictMinimumDuration:!0}:{},external_scripts_inject_target:e&&e>=`2026-01-30`?`head`:`body`,internal_or_test_user_hostname:e&&e>=`2026-01-30`?/^(localhost|127\.0\.0\.1)$/:void 0}))(e))},jo=[[`process_person`,`person_profiles`],[`xhr_headers`,`request_headers`],[`cookie_name`,`persistence_name`],[`disable_cookie`,`disable_persistence`],[`store_google`,`save_campaign_params`],[`verbose`,`debug`]],Mo=e=>{var t={};for(var[n,r]of jo)I(e[n])||(t[r]=e[n]);var i=Vr({},t,e);return F(e.property_blacklist)&&(I(e.property_denylist)?i.property_denylist=e.property_blacklist:F(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:R.error(Do+e.property_denylist)),i},No=class{constructor(){this.__forceAllowLocalhost=!1}get Ei(){return this.__forceAllowLocalhost}set Ei(e){R.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},Po=class e{Mi(e,t){if(e){var n=this.Pi.indexOf(e);n!==-1&&this.Pi.splice(n,1)}return this.Pi.push(t),t.initialize==null||t.initialize(),t}Ri(){return this.config.cookieless_mode===kr||this.config.cookieless_mode===Or&&this.consent.isRejected()}get decideEndpointWasHit(){var e;return(e=this.featureFlags?.hasLoadedFlags)!=null&&e}get flagsEndpointWasHit(){var e;return(e=this.featureFlags?.hasLoadedFlags)!=null&&e}constructor(){this.webPerformance=new No,this.Oi=!1,this.version=se.LIB_VERSION,this.Li=new eo,this.Pi=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Ao(),this.SentryIntegration=xi,this.sentryIntegration=e=>function(e,t){var n=bi(e,t);return{name:yi,processEvent:e=>n(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint=`/e/`,this.Fi=!1,this.Ai=null,this.Ni=null,this.$i=null,this.scrollManager=new Za(this),this.pageViewManager=new Si(this),this.rateLimiter=new ea(this),this.requestRouter=new po(this),this.consent=new pi(this),this.externalIntegrations=new yo(this);var t=e.__defaultExtensionClasses??{};this.featureFlags=t.featureFlags&&new t.featureFlags(this),this.toolbar=t.toolbar&&new t.toolbar(this),this.surveys=t.surveys&&new t.surveys(this),this.conversations=t.conversations&&new t.conversations(this),this.logs=t.logs&&new t.logs(this),this.experiments=t.experiments&&new t.experiments(this),this.exceptions=t.exceptions&&new t.exceptions(this),this.people={set:(e,t,n)=>{var r=Ae(e)?{[e]:t}:e;this.setPersonProperties(r),n?.({})},set_once:(e,t,n)=>{var r=Ae(e)?{[e]:t}:e;this.setPersonProperties(void 0,r),n?.({})}},this.on(`eventCaptured`,(e=>R.info(`send "`+e?.event+`"`,e)))}init(t,n,r){if(r&&r!==Oo){var i=xo[r]??new e;return i._init(t,n,r),xo[r]=i,xo[Oo][r]=i,i}return this._init(t,n,r)}_init(e,t,n){var r;if(t===void 0&&(t={}),I(e)||je(e))return R.critical(`PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()`),this;if(this.__loaded)return console.warn(`[PostHog.js]`,`You have already initialized PostHog! Re-initializing is a no-op`),this;this.__loaded=!0,this.config={},t.debug=this.Di(t.debug),this.qi=t,this.ji=[],t.person_profiles?this.Ni=t.person_profiles:t.process_person&&(this.Ni=t.process_person),this.set_config(Vr({},Ao(t.defaults),Mo(t),{name:n,token:e})),this.config.on_xhr_error&&R.error(`on_xhr_error is deprecated. Use on_request_error instead`),this.compression=t.disable_compression?void 0:ra.GZipJS;var i=this.Hi();this.persistence=new Gi(this.config,i),this.sessionPersistence=this.config.persistence===`sessionStorage`||this.config.persistence===`memory`?this.persistence:new Gi(N({},this.config,{persistence:`sessionStorage`}),i);var a=N({},this.persistence.props),o=N({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Ui=new Ja((e=>this.Bi(e)),this.config.request_queue_config),this.zi=new Xa(this),this.__request_queue=[];var s=this.Ri();if(s||(this.sessionManager=new no(this),this.sessionPropsManager=new $a(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(R.info(`Deferring extension initialization to improve startup performance`),setTimeout((()=>{this.Vi(s)}),0)):(R.info(`Initializing extensions synchronously`),this.Vi(s)),se.DEBUG=se.DEBUG||this.config.debug,se.DEBUG&&R.info(`Starting in debug mode`,{this:this,config:t,thisC:N({},this.config),p:a,s:o}),!this.config.identity_distinct_id||(r=t.bootstrap)!=null&&r.distinctID||(t.bootstrap=N({},t.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),t.bootstrap?.distinctID!==void 0){var c=t.bootstrap.distinctID,l=this.get_distinct_id(),u=this.persistence.get_property(hr);if(t.bootstrap.isIdentifiedID&&l!=null&&l!==c&&u===Ar)this.identify(c);else if(t.bootstrap.isIdentifiedID&&l!=null&&l!==c&&u===jr)R.warn(`Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.`);else{var d=this.config.get_device_id(ti()),f=t.bootstrap.isIdentifiedID?d:c;this.persistence.set_property(hr,t.bootstrap.isIdentifiedID?jr:Ar),this.register({distinct_id:c,$device_id:f})}}if(s)this.register_once({distinct_id:Cr,$device_id:null},``);else if(!this.get_distinct_id()){var p=this.config.get_device_id(ti());this.register_once({distinct_id:p,$device_id:p},``),this.persistence.set_property(hr,Ar)}return Jr(D,`onpagehide`in self?`pagehide`:`unload`,this._handle_unload.bind(this),{passive:!1}),t.segment?function(e,t){var n=e.config.segment;if(!n)return t();(function(e,t){var n=e.config.segment;if(!n)return t();var r=n=>{var r=()=>n.anonymousId()||ti();e.config.get_device_id=r,n.id()&&(e.register({distinct_id:n.id(),$device_id:r()}),e.persistence.set_property(hr,jr)),t()},i=n.user();`then`in i&&De(i.then)?i.then(r):r(i)})(e,(()=>{n.register((e=>{Promise&&Promise.resolve||vi.warn(`This browser does not have Promise support, and can not use the segment integration`);var t=(t,n)=>{if(!n)return t;t.event.userId||t.event.anonymousId===e.get_distinct_id()||(vi.info(`No userId set, resetting PostHog`),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(vi.info(`UserId set, identifying with PostHog`),e.identify(t.event.userId));var r=e.calculateEventProperties(n,t.event.properties);return t.event.properties=Object.assign({},r,t.event.properties),t};return{name:`PostHog JS`,type:`enrichment`,version:`1.0.0`,isLoaded:()=>!0,load:()=>Promise.resolve(),track:e=>t(e,e.event.event),page:e=>t(e,Fr),identify:e=>t(e,Lr),screen:e=>t(e,`$screen`)}})(e)).then((()=>{t()}))}))}(this,(()=>this.Wi())):this.Wi(),De(this.config._onCapture)&&this.config._onCapture!==Co&&(R.warn("onCapture is deprecated. Please use `before_send` instead"),this.on(`eventCaptured`,(e=>this.config._onCapture(e.event,e)))),this.config.ip&&R.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this}Vi(t){var n=performance.now(),r=N({},e.__defaultExtensionClasses,this.config.__extensionClasses),i=[];r.featureFlags&&this.Pi.push(this.featureFlags=this.featureFlags??new r.featureFlags(this)),r.exceptions&&this.Pi.push(this.exceptions=this.exceptions??new r.exceptions(this)),r.historyAutocapture&&this.Pi.push(this.historyAutocapture=new r.historyAutocapture(this)),r.tracingHeaders&&this.Pi.push(new r.tracingHeaders(this)),r.siteApps&&this.Pi.push(this.siteApps=new r.siteApps(this)),r.sessionRecording&&!t&&this.Pi.push(this.sessionRecording=new r.sessionRecording(this)),this.config.disable_scroll_properties||i.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),r.autocapture&&this.Pi.push(this.autocapture=new r.autocapture(this)),r.surveys&&this.Pi.push(this.surveys=this.surveys??new r.surveys(this)),r.logs&&this.Pi.push(this.logs=this.logs??new r.logs(this)),r.conversations&&this.Pi.push(this.conversations=this.conversations??new r.conversations(this)),r.productTours&&this.Pi.push(this.productTours=new r.productTours(this)),r.heatmaps&&this.Pi.push(this.heatmaps=new r.heatmaps(this)),r.webVitalsAutocapture&&this.Pi.push(this.webVitalsAutocapture=new r.webVitalsAutocapture(this)),r.exceptionObserver&&this.Pi.push(this.exceptionObserver=new r.exceptionObserver(this)),r.deadClicksAutocapture&&this.Pi.push(this.deadClicksAutocapture=new r.deadClicksAutocapture(this,gi)),r.toolbar&&this.Pi.push(this.toolbar=this.toolbar??new r.toolbar(this)),r.experiments&&this.Pi.push(this.experiments=this.experiments??new r.experiments(this)),this.Pi.forEach((e=>{e.initialize&&i.push((()=>{e.initialize==null||e.initialize()}))})),i.push((()=>{if(this.Zi){var e=this.Zi;this.Zi=void 0,this.Rr(e)}})),this.Gi(i,n)}Gi(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this.Gi(e,t)}),0);var n=e.shift();if(n)try{n()}catch(e){R.error(`Error initializing extension:`,e)}}var r=Math.round(performance.now()-t);this.register_for_session({[wr]:this.config.__preview_deferred_init_extensions?`deferred`:`synchronous`,[Tr]:r}),this.config.__preview_deferred_init_extensions&&R.info(`PostHog extensions initialized (`+r+`ms)`)}Rr(e){var t;if(!A||!A.body)return R.info(`document not ready yet, trying again in 500 milliseconds...`),void setTimeout((()=>{this.Rr(e)}),500);this.config.__preview_deferred_init_extensions&&(this.Zi=e),this.Qi=e,this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=P(e.supportedCompression,ra.GZipJS)?ra.GZipJS:P(e.supportedCompression,ra.Base64)?ra.Base64:void 0),(t=e.analytics)!=null&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Ni?this.Ni:Mr}),this.Pi.forEach((t=>t.onRemoteConfig==null?void 0:t.onRemoteConfig(e)))}Wi(){try{this.config.loaded(this)}catch(e){R.critical("`loaded` function failed",e)}if(this.Ji(),this.config.internal_or_test_user_hostname&&j!=null&&j.hostname){var e=j.hostname,t=this.config.internal_or_test_user_hostname;(typeof t==`string`?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.Ri())&&this.Ki()}),1),this.Yi=new na(this),this.Yi.load()}Ji(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Ui)==null||e.enable())}_dom_loaded(){this.is_capturing()&&zr(this.__request_queue,(e=>this.Bi(e))),this.__request_queue=[],this.Ji()}_handle_unload(){var e,t,n,r;(e=this.surveys)==null||e.handlePageUnload(),this.config.request_batching?(this.Xi()&&this.capture(Ir),(t=this.logs)==null||t.flushLogs(`sendBeacon`),(n=this.Ui)==null||n.unload(),(r=this.zi)==null||r.unload()):this.Xi()&&this.capture(Ir,null,{transport:`sendBeacon`})}_send_request(e){this.__loaded&&(ko?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Ba(e.url,{ip:+!!this.config.ip}),e.headers=N({},this.config.request_headers,e.headers),e.compression=e.compression===`best-available`?this.compression:e.compression,e.disableXHRCredentials=this.config.__preview_disable_xhr_credentials,this.config.__preview_disable_beacon&&(e.disableTransport=[`sendBeacon`]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(e=>{var t=N({},e);t.timeout=t.timeout||6e4,t.url=Ga(t.url,t.compression);var n=t.transport??`fetch`,r=Ka.filter((e=>!t.disableTransport||!e.transport||!t.disableTransport.includes(e.transport))),i=function(e,t){for(var r=0;e.length>r;r++)if(e[r].transport===n)return e[r]}(r)?.method??r[0].method;if(!i)throw Error(`No available transport method`);n!==`sendBeacon`&&t.data&&t.compression===ra.GZipJS&&ie&&!Ra?Wa(t).then((e=>{i(e)})).catch((n=>{if(ge(n))return Ra=!0,void i(N({},t,{compression:void 0,url:Ga(e.url,void 0)}));(e=>{if(!e||typeof e!=`object`)return!1;var t=`name`in e?String(e.name):``;return ge(e)||t===me})(n)&&(Ra=!0),i(t)})):i(t)})(N({},e,{callback:t=>{var n,r;this.rateLimiter.checkForLimiting(t),400>t.statusCode||(n=(r=this.config).on_request_error)==null||n.call(r,t),e.callback==null||e.callback(t)}}))))}Bi(e){this.zi?this.zi.retriableRequest(e):this._send_request(e)}_execute_array(e){So++;try{var t,n=[],r=[],i=[];zr(e,(e=>{if(e)if(F(t=e[0]))i.push(e);else if(De(e))try{e.call(this)}catch(t){R.error(`Error executing queued PostHog call`,e,t)}else F(e)&&t===`alias`?n.push(e):F(e)&&t.indexOf(`capture`)!==-1&&De(this[t])?i.push(e):r.push(e)}));var a=function(e,t){zr(e,(function(e){try{if(F(e[0])){var n=t;Br(e,(function(e){n=n[e[0]].apply(n,e.slice(1))}))}else t[e[0]].apply(t,e.slice(1))}catch(t){R.error(`Error executing queued PostHog call`,e,t)}}))};a(n,this),a(r,this),a(i,this)}finally{So--}}push(t){if(So>0&&F(t)&&Ae(t[0])){var n=e.prototype[t[0]];De(n)&&n.apply(this,t.slice(1))}else this._execute_array([t])}capture(e,t,n){var r,i,a,o;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Ui){if(this.is_capturing())if(!I(e)&&Ae(e)){var s=!this.config.opt_out_useragent_filter&&this._is_bot();if(!s||this.config.__preview_capture_bot_pageviews){var c=n!=null&&n.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(c==null||!c.isRateLimited){t!=null&&t.$current_url&&!Ae(t?.$current_url)&&(R.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),t==null||delete t.$current_url),e!==`$exception`||n!=null&&n.en||R.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var l=new Date,u=n?.timestamp||l,d=n?.uuid||ti(),f={uuid:d,event:e,properties:this.calculateEventProperties(e,t||{},u,d)};e===Fr&&this.config.__preview_capture_bot_pageviews&&s&&(f.event=`$bot_pageview`,f.properties.$browser_type=`bot`),c&&(f.properties.$lib_rate_limit_remaining_tokens=c.remainingTokens),n!=null&&n.$set&&(f.$set=n?.$set);var p,m,h,g=this.tn(n?.$set_once,e!==Rr,e===Lr);if(g&&(f.$set_once=g),n!=null&&n._noTruncate||(r=this.config.properties_string_max_length,i=f,a=e=>Ae(e)?e.slice(0,r):e,o=new Set,f=function e(t,n){return t===Object(t)?o.has(t)?void 0:(o.add(t),F(t)?(r=[],zr(t,(t=>{r.push(e(t))}))):(r={},Br(t,((t,n)=>{o.has(t)||(r[n]=e(t,n))}))),r):a?a(t):t;var r}(i)),f.timestamp=u,I(n?.timestamp)||(f.properties.$event_time_override_provided=!0,f.properties.$event_time_override_system_time=l),e===Ji.DISMISSED||e===Ji.SENT){var _=t?.[Yi.SURVEY_ID],v=t?.[Yi.SURVEY_ITERATION];(e=>{try{var t=(e=>((e,t)=>{var n=``+mo+t.id;return t.current_iteration&&t.current_iteration>0&&(n=``+mo+t.id+`_`+t.current_iteration),n})(0,e))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,`true`)}catch(e){z.error(`Failed to persist survey seen state`,e)}})({id:_,current_iteration:v}),f.$set=N({},f.$set,{[(p={id:_,current_iteration:v},m=e===Ji.SENT?`responded`:`dismissed`,h=`$survey_`+m+`/`+p.id,p.current_iteration&&p.current_iteration>0&&(h=`$survey_`+m+`/`+p.id+`/`+p.current_iteration),h)]:!0})}else e===Ji.SHOWN&&(f.$set=N({},f.$set,{[Yi.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(e===Zi.SHOWN){var y=t?.[Qi.TOUR_TYPE];y&&(f.$set=N({},f.$set,{[Qi.TOUR_LAST_SEEN_DATE+`/`+y]:new Date().toISOString()}))}var b=N({},f.properties.$set,f.$set);if(ke(b)||this.setPersonPropertiesForFlags(b),!L(this.config.before_send)){var x=this.rn(f);if(!x)return;f=x}this.Li.emit(`eventCaptured`,f);var S={method:`POST`,url:n?._url??this.requestRouter.endpointFor(`api`,this.analyticsDefaultEndpoint),data:f,compression:`best-available`,batchKey:n?._batchKey,transport:n?.transport};return!this.config.request_batching||n&&(n==null||!n._batchKey)||n!=null&&n.send_instantly?this.Bi(S):this.Ui.enqueue(S),f}R.critical(`This capture call is ignored due to client rate limiting.`)}}else R.error(`No event name provided to posthog.capture`)}else R.uninitializedWarning(`posthog.capture`)}_addCaptureHook(e){return this.on(`eventCaptured`,(t=>e(t.event,t)))}calculateEventProperties(e,t,n,r,i){if(n||=new Date,!this.persistence||!this.sessionPersistence)return t;var a=i?void 0:this.persistence.remove_event_timer(e),o=N({},t);if(o.token=this.config.token,o.$config_defaults=this.config.defaults,this.Ri()&&(o.$cookieless_mode=!0),e===`$snapshot`){var s=N({},this.persistence.properties(),this.sessionPersistence.properties());return o.distinct_id=s.distinct_id,(!Ae(o.distinct_id)&&!Ne(o.distinct_id)||je(o.distinct_id))&&R.error(`Invalid distinct_id for replay event. This indicates a bug in your implementation`),o}var c,l=function(e,t){var n,r,i;if(!ae)return{};var a,o,s,c,l=e?[...Ai,...t||[]]:[],[u,d]=function(e){for(var t=0;Ut.length>t;t++){var[n,r]=Ut[t],i=n.exec(e),a=i&&(De(r)?r(i,e):r);if(a)return a}return[``,``]}(ae);return Vr(Gr({$os:u,$os_version:d,$browser:Bt(ae,navigator.vendor),$device:Wt(ae),$device_type:(o=ae,s={userAgentDataPlatform:(n=navigator)==null||(n=n.userAgentData)==null?void 0:n.platform,maxTouchPoints:navigator?.maxTouchPoints,screenWidth:D==null||(r=D.screen)==null?void 0:r.width,screenHeight:D==null||(i=D.screen)==null?void 0:i.height,devicePixelRatio:D?.devicePixelRatio},c=Wt(o),c===et||c===$e||c===`Kobo`||c===`Kindle Fire`||c===At?Qe:c===yt||c===xt||c===bt||c===Dt?`Console`:c===nt?`Wearable`:c?Ye:s?.userAgentDataPlatform===`Android`&&(s?.maxTouchPoints??0)>0?600>Math.min(s?.screenWidth??0,s?.screenHeight??0)/(s?.devicePixelRatio??1)?Ye:Qe:`Desktop`),$timezone:Hi(),$timezone_offset:Ui()}),{$current_url:Di(j?.href,l,Mi),$host:j?.host,$pathname:j?.pathname,$raw_user_agent:ae.length>1e3?ae.substring(0,997)+`...`:ae,$browser_version:Ht(ae,navigator.vendor),$browser_language:Li(),$browser_language_prefix:(a=Li(),typeof a==`string`?a.split(`-`)[0]:void 0),$screen_height:D?.screen.height,$screen_width:D?.screen.width,$viewport_height:D?.innerHeight,$viewport_width:D?.innerWidth,$lib:se.LIB_NAME,$lib_version:se.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:u,windowId:d}=this.sessionManager.checkAndGetSessionAndWindowId(i,n.getTime());o.$session_id=u,o.$window_id=d}this.sessionPropsManager&&Vr(o,this.sessionPropsManager.getSessionProps());try{this.sessionRecording&&Vr(o,this.sessionRecording.sdkDebugProperties),o.$sdk_debug_retry_queue_size=this.zi?.length}catch(e){o.$sdk_debug_error_capturing_properties=String(e)}if(this.requestRouter.region===lo&&(o.$lib_custom_api_host=this.config.api_host),c=e!==Fr||i?e!==Ir||i?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(n):this.pageViewManager.doPageView(n,r),o=Vr(o,c),e===Fr&&A&&(o.title=A.title),!I(a)){var f=n.getTime()-a;o.$duration=parseFloat((f/1e3).toFixed(3))}ae&&this.config.opt_out_useragent_filter&&(o.$browser_type=this._is_bot()?`bot`:`browser`),(o=Vr({},l,this.persistence.properties(),this.sessionPersistence.properties(),o)).$is_identified=this._isIdentified(),F(this.config.property_denylist)?Br(this.config.property_denylist,(function(e){delete o[e]})):R.error(Do+this.config.property_denylist+` or property_blacklist config: `+this.config.property_blacklist);var p=this.config.sanitize_properties;p&&(R.error(Eo),o=p(o,e));var m=this.nn();return o.$process_person_profile=m,m&&!i&&this.sn(`_calculate_event_properties`),o}tn(e,t,n){if(t===void 0&&(t=!0),n===void 0&&(n=!1),!this.persistence||!this.nn()||this.Oi&&!n)return e;var r=Vr({},this.persistence.get_initial_props(),this.sessionPropsManager?.getSetOnceProps()||{},e||{}),i=this.config.sanitize_properties;return i&&(R.error(Eo),r=i(r,`$set_once`)),t&&(this.Oi=!0),ke(r)?void 0:r}register(e,t){var n;(n=this.persistence)==null||n.register(e,t)}register_once(e,t,n){var r;(r=this.persistence)==null||r.register_once(e,t,n)}register_for_session(e){var t;(t=this.sessionPersistence)==null||t.register(e)}unregister(e){var t;(t=this.persistence)==null||t.unregister(e)}unregister_for_session(e){var t;(t=this.sessionPersistence)==null||t.unregister(e)}an(e,t){this.register({[e]:t})}getFeatureFlag(e,t){return this.featureFlags?.getFeatureFlag(e,t)}getFeatureFlagPayload(e){return this.featureFlags?.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){return this.featureFlags?.getFeatureFlagResult(e,t)}isFeatureEnabled(e,t){return this.featureFlags?.isFeatureEnabled(e,t)}reloadFeatureFlags(){var e;(e=this.featureFlags)==null||e.reloadFeatureFlags()}updateFlags(e,t,n){var r;(r=this.featureFlags)==null||r.updateFlags(e,t,n)}updateEarlyAccessFeatureEnrollment(e,t,n){var r;(r=this.featureFlags)==null||r.updateEarlyAccessFeatureEnrollment(e,t,n)}getEarlyAccessFeatures(e,t,n){return t===void 0&&(t=!1),this.featureFlags?.getEarlyAccessFeatures(e,t,n)}on(e,t){return this.Li.on(e,t)}onFeatureFlags(e){return this.featureFlags?this.featureFlags.onFeatureFlags(e):(e([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:To}),()=>{})}onSessionId(e){return this.sessionManager?.onSessionId(e)??(()=>{})}getSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:To})}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:To})}renderSurvey(e,t){var n;(n=this.surveys)==null||n.renderSurvey(e,t)}displaySurvey(e,t){var n;t===void 0&&(t=go),(n=this.surveys)==null||n.displaySurvey(e,t)}cancelPendingSurvey(e){var t;(t=this.surveys)==null||t.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys?.canRenderSurvey(e)??{visible:!1,disabledReason:To}}canRenderSurveyAsync(e,t){return t===void 0&&(t=!1),this.surveys?.canRenderSurveyAsync(e,t)??Promise.resolve({visible:!1,disabledReason:To})}un(e){return!e||je(e)?(R.critical(`Unique user id has not been set in posthog.identify`),!1):e===Cr?(R.critical(`The string "`+e+`" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.`),!1):![`distinct_id`,`distinctid`].includes(e.toLowerCase())&&![`undefined`,`null`].includes(e.toLowerCase())||(R.critical(`The string "`+e+`" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.`),!1)}identify(e,t,n){if(!this.__loaded||!this.persistence)return R.uninitializedWarning(`posthog.identify`);if(Ne(e)&&(e=e.toString(),R.warn(`The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.`)),this.un(e)&&this.sn(`posthog.identify`)){var r=this.get_distinct_id();this.register({$user_id:e}),this.get_property(Nn)||this.register_once({$had_persisted_distinct_id:!0,$device_id:r},``),e!==r&&e!==this.get_property(Pn)&&(this.unregister(Pn),this.register({distinct_id:e}));var i,a=(this.persistence.get_property(hr)||Ar)===Ar;e!==r&&a?(this.persistence.set_property(hr,jr),this.setPersonPropertiesForFlags({$set:t||{},$set_once:n||{}},!1),this.capture(Lr,{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:n||{}}),this.$i=ao(e,t,n),(i=this.featureFlags)==null||i.setAnonymousDistinctId(r)):(t||n)&&this.setPersonProperties(t,n),e!==r&&(this.reloadFeatureFlags(),this.unregister(dr))}}setPersonProperties(e,t){if((e||t)&&this.sn(`posthog.setPersonProperties`)){var n=ao(this.get_distinct_id(),e,t);this.$i===n?R.info(`A duplicate setPersonProperties call was made with the same properties. It has been ignored.`):(this.setPersonPropertiesForFlags({$set:e||{},$set_once:t||{}},!0),this.capture(`$set`,{$set:e||{},$set_once:t||{}}),this.$i=n)}}group(e,t,n){if(e&&t){var r=this.getGroups(),i=r[e]!==t;if(i&&this.resetGroupPropertiesForFlags(e),this.register({$groups:N({},r,{[e]:t})}),i||n){var a={$group_type:e,$group_key:t};n&&(a.$group_set=n),this.capture(Rr,a)}n&&this.setGroupPropertiesForFlags({[e]:n}),i&&!n&&this.reloadFeatureFlags()}else R.error(`posthog.group requires a group type and group key`)}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){var n;t===void 0&&(t=!0),(n=this.featureFlags)==null||n.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){var e;(e=this.featureFlags)==null||e.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){var n;t===void 0&&(t=!0),this.sn(`posthog.setGroupPropertiesForFlags`)&&((n=this.featureFlags)==null||n.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;(t=this.featureFlags)==null||t.resetGroupPropertiesForFlags(e)}reset(e){var t,n,r,i,a,o,s,c;if(R.info(`reset`),!this.__loaded)return R.uninitializedWarning(`posthog.reset`);var l,u=this.get_property(Nn),d=this.get_property(Gn);if(this.consent.reset(),(t=this.persistence)==null||t.clear(),(n=this.sessionPersistence)==null||n.clear(),I(d)||(l=this.persistence)==null||l.register({[Gn]:d}),(r=this.surveys)==null||r.reset(),(i=this.Yi)==null||i.stop(),(a=this.featureFlags)==null||a.reset(),(o=this.conversations)==null||o.reset(),(s=this.persistence)==null||s.set_property(hr,Ar),(c=this.sessionManager)==null||c.resetSessionId(),this.$i=null,this.config.cookieless_mode===kr)this.register_once({distinct_id:Cr,$device_id:null},``);else{var f=this.config.get_device_id(ti());this.register_once({distinct_id:f,$device_id:e?f:u},``)}this.register({$last_posthog_reset:new Date().toISOString()},1),delete this.config.identity_distinct_id,delete this.config.identity_hash,this.reloadFeatureFlags()}setIdentity(e,t){var n;this.config.identity_distinct_id=e,this.config.identity_hash=t,this.alias(e),(n=this.conversations)==null||n.ln()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,(e=this.conversations)==null||e.hn()}get_distinct_id(){return this.get_property(`distinct_id`)}getGroups(){return this.get_property(`$groups`)||{}}get_session_id(){return this.sessionManager?.checkAndGetSessionAndWindowId(!0).sessionId??``}get_session_replay_url(e){if(!this.sessionManager)return``;var{sessionId:t,sessionStartTimestamp:n}=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=this.requestRouter.endpointFor(`ui`,`/project/`+this.config.token+`/replay/`+t);if(e!=null&&e.withTimestamp&&n){var i=e.timestampLookBack??10;if(!n)return r;r+=`?t=`+Math.max(Math.floor((new Date().getTime()-n)/1e3)-i,0)}return r}alias(e,t){return e===this.get_property(Mn)?(R.critical(`Attempting to create alias for existing People user - aborting.`),-2):this.sn(`posthog.alias`)?(I(t)&&(t=this.get_distinct_id()),e===t?(R.warn(`alias matches current distinct_id - skipping api call.`),this.identify(e),-1):(this.an(Pn,e),this.capture(`$create_alias`,{alias:e,distinct_id:t}))):void 0}set_config(e){var t=N({},this.config);if(Oe(e)){var n,r,i,a,o,s,c,l,u,d;Vr(this.config,Mo(e));var f=this.Hi();(n=this.persistence)==null||n.update_config(this.config,t,f),this.sessionPersistence=this.config.persistence===`sessionStorage`||this.config.persistence===`memory`?this.persistence:new Gi(N({},this.config,{persistence:`sessionStorage`}),f);var p=this.Di(this.config.debug);Fe(p)&&(this.config.debug=p),Fe(this.config.debug)&&(this.config.debug?(se.DEBUG=!0,si.R()&&si.N(`ph_debug`,!0),R.info(`set_config`,{config:e,oldConfig:t,newConfig:N({},this.config)})):(se.DEBUG=!1,si.R()&&si.q(`ph_debug`))),(r=this.exceptionObserver)==null||r.onConfigChange(),(i=this.exceptions)==null||i.onConfigChange(),(a=this.sessionRecording)==null||a.startIfEnabledOrStop(),(o=this.autocapture)==null||o.startIfEnabled(),(s=this.heatmaps)==null||s.startIfEnabled(),(c=this.exceptionObserver)==null||c.startIfEnabledOrStop(),(l=this.deadClicksAutocapture)==null||l.startIfEnabledOrStop(),(u=this.surveys)==null||u.loadIfEnabled(),this.cn(),(d=this.externalIntegrations)==null||d.startIfEnabledOrStop()}}_overrideSDKInfo(e,t){se.LIB_NAME=e,se.LIB_VERSION=t}startSessionRecording(e){var t,n,r,i,a,o=!0===e,s={sampling:o||!(e==null||!e.sampling),linked_flag:o||!(e==null||!e.linked_flag),url_trigger:o||!(e==null||!e.url_trigger),event_trigger:o||!(e==null||!e.event_trigger)};Object.values(s).some(Boolean)&&((t=this.sessionManager)==null||t.checkAndGetSessionAndWindowId(),s.sampling&&((n=this.sessionRecording)==null||n.overrideSampling()),s.linked_flag&&((r=this.sessionRecording)==null||r.overrideLinkedFlag()),s.url_trigger&&((i=this.sessionRecording)==null||i.overrideTrigger(`url`)),s.event_trigger&&((a=this.sessionRecording)==null||a.overrideTrigger(`event`))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,t){if(this.exceptions){var n=Error(`PostHog syntheticException`),r=this.exceptions.buildProperties(e,{handled:!0,syntheticException:n});return this.exceptions.sendExceptionEvent(N({},r,t))}}addExceptionStep(e,t){var n;(n=this.exceptions)==null||n.addExceptionStep(e,t)}captureLog(e){var t;(t=this.logs)==null||t.captureLog(e)}get logger(){return this.logs?.logger??e.dn}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t;return(t=this.toolbar?.loadToolbar(e))!=null&&t}get_property(e){return this.persistence?.props[e]}getSessionProperty(e){return this.sessionPersistence?.props[e]}toString(){var e=this.config.name??Oo;return e!==Oo&&(e=Oo+`.`+e),e}_isIdentified(){return this.persistence?.get_property(hr)===jr||this.sessionPersistence?.get_property(hr)===jr}nn(){var e,t;return!(this.config.person_profiles===`never`||this.config.person_profiles===Mr&&!this._isIdentified()&&ke(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[Pn])&&((t=this.persistence)==null||(t=t.props)==null||!t[xr]))}Xi(){return!0===this.config.capture_pageleave||this.config.capture_pageleave===`if_capture_pageview`&&(!0===this.config.capture_pageview||this.config.capture_pageview===`history_change`)}createPersonProfile(){this.nn()||this.sn(`posthog.createPersonProfile`)&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.sn(`posthog.setInternalOrTestUser`)&&this.setPersonProperties({$internal_or_test_user:!0})}sn(e){return this.config.person_profiles===`never`?(R.error(e+` was called, but process_person is set to "never". This call will be ignored.`),!1):(this.an(xr,!0),!0)}Hi(){if(this.config.cookieless_mode===`always`)return!0;var e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==Or)}cn(){var e,t,n=this.Hi();return this.persistence?._r!==n&&((e=this.persistence)==null||e.set_disabled(n)),this.sessionPersistence?._r!==n&&((t=this.sessionPersistence)==null||t.set_disabled(n)),n}opt_in_capturing(t){var n;if(this.config.cookieless_mode!==kr){if(this.Ri()){var r,i;this.reset(!0),(r=this.sessionManager)==null||r.destroy(),(i=this.pageViewManager)==null||i.destroy(),this.sessionManager=new no(this),this.pageViewManager=new Si(this),this.persistence&&(this.sessionPropsManager=new $a(this,this.sessionManager,this.persistence));var a,o=this.config.__extensionClasses?.sessionRecording??e.__defaultExtensionClasses?.sessionRecording;o&&(this.sessionRecording=this.Mi(this.sessionRecording,new o(this)),this.Qi&&((a=this.sessionRecording)==null||a.onRemoteConfig==null||a.onRemoteConfig(this.Qi)))}var s;this.consent.optInOut(!0),this.cn(),this.Ji(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),this.config.cookieless_mode==Or&&((s=this.surveys)==null||s.loadIfEnabled()),(I(t?.captureEventName)||t!=null&&t.captureEventName)&&this.capture(t?.captureEventName??`$opt_in`,t?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Ki()}else R.warn(wo)}opt_out_capturing(){var e,t,n;this.config.cookieless_mode===kr?R.warn(wo):(this.config.cookieless_mode===Or&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.cn(),this.config.cookieless_mode===Or&&(this.register({distinct_id:Cr,$device_id:null}),(e=this.sessionRecording)==null||e.stopRecording(),this.sessionRecording=void 0,(t=this.sessionManager)==null||t.destroy(),(n=this.pageViewManager)==null||n.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.Ki()))}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return e===1?`granted`:e===0?`denied`:`pending`}is_capturing(){return this.config.cookieless_mode===kr||(this.config.cookieless_mode===Or?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.cn()}_is_bot(){return k?ro(k,this.config.custom_blocked_useragents):void 0}Ki(){A&&(A.visibilityState===`visible`?this.Fi||(this.Fi=!0,this.capture(Fr,{title:A.title},{send_instantly:!0}),this.Ai&&=(A.removeEventListener(Nr,this.Ai),null)):this.Ai||(this.Ai=this.Ki.bind(this),Jr(A,Nr,this.Ai)))}debug(e){!1===e?(D?.console.log(`You've disabled debug mode.`),this.set_config({debug:!1})):(D?.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}Lr(){var e,t,n,r,i,a,o=this.qi||{};return`advanced_disable_flags`in o?!!o.advanced_disable_flags:!1===this.config.advanced_disable_flags?!0===this.config.advanced_disable_decide?(R.warn(`Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version.`),!0):(n=`advanced_disable_decide`,r=R,i=(t=`advanced_disable_flags`)in(e=o)&&!L(e[t]),a=n in e&&!L(e[n]),i?e[t]:!!a&&(r&&r.warn(`Config field '`+n+`' is deprecated. Please use '`+t+`' instead. The old field will be removed in a future major version.`),e[n])):!!this.config.advanced_disable_flags}rn(e){if(L(this.config.before_send))return e;var t=F(this.config.before_send)?this.config.before_send:[this.config.before_send],n=e;for(var r of t){if(n=r(n),L(n)){var i=`Event '`+e.event+`' was rejected in beforeSend function`;return Le(e.event)?R.warn(i+`. This can cause unexpected behavior.`):R.info(i),null}n.properties&&!ke(n.properties)||R.warn(`Event '`+e.event+`' has no properties after beforeSend function, this is likely an error.`)}return n}getPageViewId(){return this.pageViewManager.dr?.pageViewId}captureTraceFeedback(e,t){this.capture(`$ai_feedback`,{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,n){this.capture(`$ai_metric`,{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(n)})}Di(e){var t=Fe(e)&&!e,n=si.R()&&si.A(`ph_debug`)===`true`;return!t&&(!!n||e)}};Po.__defaultExtensionClasses={},Po.dn={trace:bo=()=>{},debug:bo,info:bo,warn:bo,error:bo,fatal:bo},function(e,t){for(var n=0;t.length>n;n++)e.prototype[t[n]]=Wr(e.prototype[t[n]])}(Po,[`identify`]);var Fo=1,Io=3,Lo=11;function Ro(e){return e instanceof Element&&(e.id===Sr||!(e.closest==null||!e.closest(`.toolbar-global-fade-container`)))}function zo(e){return!!e&&e.nodeType===Fo}function Bo(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Vo(e){return!!e&&e.nodeType===Io}function Ho(e){return!!e&&e.nodeType===Lo&&zo(e.host)}function Uo(e){return e?Se(e).split(/\s+/):[]}function Wo(e){var t=D?.location.href;return!!(t&&e&&e.some((e=>t.match(e))))}function Go(e){var t=``;switch(typeof e.className){case`string`:t=e.className;break;case`object`:t=(e.className&&`baseVal`in e.className?e.className.baseVal:null)||e.getAttribute(`class`)||``;break;default:t=``}return Uo(t)}function Ko(e){return L(e)?null:Se(e).split(/(\s+)/).filter((e=>ds(e))).join(``).replace(/[\r\n]/g,` `).replace(/[ ]+/g,` `).substring(0,255)}function qo(e){var t=``;return ns(e)&&!rs(e)&&e.childNodes&&e.childNodes.length&&Br(e.childNodes,(function(e){Vo(e)&&e.textContent&&(t+=Ko(e.textContent)??``)})),Se(t)}function Jo(e){return I(e.target)?e.srcElement||null:(t=e.target)!=null&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var Yo=[`a`,`button`,`form`,`input`,`select`,`textarea`,`label`];function Xo(e,t){if(I(t))return!0;var n,r=function(e){if(t.some((t=>e.matches(t))))return{v:!0}};for(var i of e)if(n=r(i))return n.v;return!1}function Zo(e){var t=e.parentNode;return!(!t||!zo(t))&&t}var Qo=[`next`,`previous`,`prev`,`>`,`<`],$o=[`.ph-no-rageclick`,`.ph-no-capture`],es=e=>!e||Bo(e,`html`)||!zo(e),ts=(e,t)=>{if(!D||es(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var n=!1,r=[e],i=e;i.parentNode&&!Bo(i,`body`);)if(Ho(i.parentNode))r.push(i.parentNode.host),i=i.parentNode.host;else{var a=Zo(i);if(!a)break;if(t||Yo.indexOf(a.tagName.toLowerCase())>-1)n=!0;else{var o=D.getComputedStyle(a);o&&o.getPropertyValue(`cursor`)===`pointer`&&(n=!0)}r.push(a),i=a}return{parentIsUsefulElement:n,targetElementList:r}};function ns(e){for(var t=e;t.parentNode&&!Bo(t,`body`);t=t.parentNode){var n=Go(t);if(P(n,`ph-sensitive`)||P(n,`ph-no-capture`))return!1}if(P(Go(e),`ph-include`))return!0;var r=e.type||``;if(Ae(r))switch(r.toLowerCase()){case`hidden`:case`password`:return!1}var i=e.name||e.id||``;return!Ae(i)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(i.replace(/[^a-zA-Z0-9]/g,``))}function rs(e){return!!(Bo(e,`input`)&&![`button`,`checkbox`,`submit`,`reset`].includes(e.type)||Bo(e,`select`)||Bo(e,`textarea`)||e.getAttribute(`contenteditable`)===`true`)}var is=`(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11})`,as=RegExp(`^(?:`+is+`)$`),ss=new RegExp(is),cs=`\\d{3}-?\\d{2}-?\\d{4}`,ls=RegExp(`^(`+cs+`)$`),us=RegExp(`(`+cs+`)`);function ds(e,t){return t===void 0&&(t=!0),!(L(e)||Ae(e)&&(e=Se(e),(t?as:ss).test((e||``).replace(/[- ]/g,``))||(t?ls:us).test(e)))}function fs(e){var t=qo(e);return ds(t=(t+` `+ps(e)).trim())?t:``}function ps(e){var t=``;return e&&e.childNodes&&e.childNodes.length&&Br(e.childNodes,(function(e){if(e&&e.tagName?.toLowerCase()===`span`)try{var n=qo(e);t=(t+` `+n).trim(),e.childNodes&&e.childNodes.length&&(t=(t+` `+ps(e)).trim())}catch(e){R.error(`[AutoCapture]`,e)}})),t}function ms(e){return e.replace(/"|\\"/g,`\\"`)}function hs(e){var t=e.attr__class;return t?F(t)?t:Uo(t):void 0}var gs=class{constructor(e){this.disabled=!1===e;var t=Oe(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,n){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<this.thresholdPx&&this.timeoutMs>n-r.timestamp){if(this.clicks.push({x:e,y:t,timestamp:n}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:n}];return!1}},_s=`$copy_autocapture`,vs=kn(`[AutoCapture]`);function ys(e,t){return t.length>e?t.slice(0,e)+`...`:t}function bs(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do t=t.previousSibling;while(t&&!zo(t));return t}function xs(e,t){var n,{e:r,maskAllElementAttributes:i,maskAllText:a,elementAttributeIgnoreList:o,elementsChainAsString:s}=t;if(!zo(e))return{props:{}};for(var c=[e],l=e;l.parentNode&&!Bo(l,`body`);)if(Ho(l.parentNode))c.push(l.parentNode.host),l=l.parentNode.host;else{if(!zo(l.parentNode))break;c.push(l.parentNode),l=l.parentNode}var u,d,f=[],p={},m=!1,h=!1;if(Br(c,(e=>{var t=ns(e);if(Bo(e,`a`)){var n=e.getAttribute(`href`);m=t&&!!n&&ds(n)&&n}P(Go(e),`ph-no-capture`)&&(h=!0),f.push(function(e,t,n,r){var i=e.tagName.toLowerCase(),a={tag_name:i};Yo.indexOf(i)>-1&&!n&&(a.$el_text=i.toLowerCase()===`a`||i.toLowerCase()===`button`?ys(1024,fs(e)):ys(1024,qo(e)));var o=Go(e);o.length>0&&(a.classes=o.filter((function(e){return e!==``}))),Br(e.attributes,(function(n){var i;if((!rs(e)||[`name`,`id`,`class`,`aria-label`].indexOf(n.name)!==-1)&&(r==null||!r.includes(n.name))&&!t&&ds(n.value)&&(!Ae(i=n.name)||i.substring(0,10)!==`_ngcontent`&&i.substring(0,7)!==`_nghost`)){var o=n.value;n.name===`class`&&(o=Uo(o).join(` `)),a[`attr__`+n.name]=ys(1024,o)}}));for(var s=1,c=1,l=e;l=bs(l);)s++,l.tagName===e.tagName&&c++;return a.nth_child=s,a.nth_of_type=c,a}(e,i,a,o)),Vr(p,function(e){if(!ns(e))return{};var t={};return Br(e.attributes,(function(e){if(e.name&&e.name.indexOf(`data-ph-capture-attribute`)===0){var n=e.name.replace(`data-ph-capture-attribute-`,``),r=e.value;n&&r&&ds(r)&&(t[n]=r)}})),t}(e))})),h)return{props:{},explicitNoCapture:h};if(a||(f[0].$el_text=Bo(e,`a`)||Bo(e,`button`)?fs(e):qo(e)),m){var g;f[0].attr__href=m;var _=Ti(m)?.host,v=D==null||(g=D.location)==null?void 0:g.host;_&&v&&_!==v&&(u=m)}return{props:Vr({$event_type:r.type,$ce_version:1},s?{}:{$elements:f},{$elements_chain:(d=f,function(e){return e.map((e=>{var t=``;if(e.tag_name&&(t+=e.tag_name),e.attr_class)for(var n of(e.attr_class.sort(),e.attr_class))t+=`.`+n.replace(/"/g,``);var r=N({},e.text?{text:e.text}:{},{"nth-child":e.nth_child??0,"nth-of-type":e.nth_of_type??0},e.href?{href:e.href}:{},e.attr_id?{attr_id:e.attr_id}:{},e.attributes),i={};return Hr(r).sort(((e,t)=>{var[n]=e,[r]=t;return n.localeCompare(r)})).forEach((e=>{var[t,n]=e;return i[ms(t.toString())]=ms(n.toString())})),(t+=`:`)+Hr(i).map((e=>{var[t,n]=e;return t+`="`+n+`"`})).join(``)})).join(`;`)}(function(e){return e.map((e=>{var t={text:e.$el_text?.slice(0,400),tag_name:e.tag_name,href:e.attr__href?.slice(0,2048),attr_class:hs(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Hr(e).filter((e=>{var[t]=e;return t.indexOf(`attr__`)===0})).forEach((e=>{var[n,r]=e;return t.attributes[n]=r})),t}))}(d)))},(n=f[0])!=null&&n.$el_text?{$el_text:f[0]?.$el_text}:{},u&&r.type===`click`?{$external_click_url:u}:{},p)}}var Ss=kn(`[ExceptionAutocapture]`);function Cs(e,t,n){try{if(!(t in e))return()=>{};var r=e[t],i=n(r);return De(i)&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__posthog_wrapped__:{enumerable:!1,value:!0}})),e[t]=i,()=>{e[t]=r}}catch{return()=>{}}}var ws=kn(`[TracingHeaders]`),Ts=kn(`[Web Vitals]`),Es=9e5,Ds=`disabled`,Os=`lazy_loading`,ks=`awaiting_config`,As=`missing_config`;kn(`[SessionRecording]`),kn(`[SessionRecording]`);var js=`[SessionRecording]`,Ms=kn(js),Ns=kn(`[Heatmaps]`);function Ps(e){return Oe(e)&&`clientX`in e&&`clientY`in e&&Ne(e.clientX)&&Ne(e.clientY)}var Fs=kn(`[Product Tours]`),Is=[`$set_once`,`$set`],Ls=kn(`[SiteApps]`),Rs=`Error while initializing PostHog app with config id `;function zs(e,t,n){if(L(e))return!1;switch(n){case`exact`:return e===t;case`contains`:var r=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`).replace(/_/g,`.`).replace(/%/g,`.*`);return new RegExp(r,`i`).test(e);case`regex`:try{return new RegExp(t).test(e)}catch{return!1}default:return!1}}var Bs=class{constructor(e){this.vn=new eo,this.fn=(e,t)=>this.pn(e,t)&&this.gn(e,t)&&this.mn(e,t)&&this.yn(e,t),this.pn=(e,t)=>t==null||!t.event||e?.event===t?.event,this._instance=e,this.bn=new Set,this._n=new Set}init(){var e;I(this._instance?._addCaptureHook)||(e=this._instance)==null||e._addCaptureHook(((e,t)=>{this.on(e,t)}))}register(e){var t;if(!I(this._instance?._addCaptureHook)&&(e.forEach((e=>{var t,n;(t=this._n)==null||t.add(e),(n=e.steps)==null||n.forEach((e=>{var t;(t=this.bn)==null||t.add(e?.event||``)}))})),(t=this._instance)!=null&&t.autocapture)){var n,r=new Set;e.forEach((e=>{var t;(t=e.steps)==null||t.forEach((e=>{e!=null&&e.selector&&r.add(e?.selector)}))})),(n=this._instance)==null||n.autocapture.setElementSelectors(r)}}on(e,t){t!=null&&e.length!=0&&(this.bn.has(e)||this.bn.has(t?.event))&&this._n&&this._n?.size>0&&this._n.forEach((e=>{this.wn(t,e)&&this.vn.emit(`actionCaptured`,e.name)}))}xn(e){this.onAction(`actionCaptured`,(t=>e(t)))}wn(e,t){if(t?.steps==null)return!1;for(var n of t.steps)if(this.fn(e,n))return!0;return!1}onAction(e,t){return this.vn.on(e,t)}gn(e,t){if(t!=null&&t.url){var n,r=e==null||(n=e.properties)==null?void 0:n.$current_url;if(!r||typeof r!=`string`||!zs(r,t.url,t.url_matching||`contains`))return!1}return!0}mn(e,t){return!!this.Sn(e,t)&&!!this.kn(e,t)&&!!this.Cn(e,t)}Sn(e,t){var n;if(t==null||!t.href)return!0;var r=this.In(e);if(r.length>0)return r.some((e=>zs(e.href,t.href,t.href_matching||`exact`)));var i,a=(e==null||(n=e.properties)==null?void 0:n.$elements_chain)||``;return!!a&&zs((i=a.match(/(?::|")href="(.*?)"/))?i[1]:``,t.href,t.href_matching||`exact`)}kn(e,t){var n;if(t==null||!t.text)return!0;var r=this.In(e);if(r.length>0)return r.some((e=>zs(e.text,t.text,t.text_matching||`exact`)||zs(e.$el_text,t.text,t.text_matching||`exact`)));var i,a,o,s=(e==null||(n=e.properties)==null?void 0:n.$elements_chain)||``;return!!s&&(i=function(e){for(var t,n=[],r=/(?::|")text="(.*?)"/g;!L(t=r.exec(e));)n.includes(t[1])||n.push(t[1]);return n}(s),a=t.text,o=t.text_matching||`exact`,i.some((e=>zs(e,a,o))))}Cn(e,t){var n,r;if(t==null||!t.selector)return!0;var i=e==null||(n=e.properties)==null?void 0:n.$element_selectors;if(i!=null&&i.includes(t.selector))return!0;var a=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||``;if(t.selector_regex&&a)try{return new RegExp(t.selector_regex).test(a)}catch{return!1}return!1}In(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}yn(e,t){return t==null||!t.properties||t.properties.length===0||co(t.properties.reduce(((e,t)=>{var n=F(t.value)?t.value.map(String):t.value==null?[]:[String(t.value)];return e[t.key]={values:n,operator:t.operator||`exact`},e}),{}),e?.properties)}},Vs=class{constructor(e){this._instance=e,this.Tn=new Map,this.En=new Map,this.Mn=new Map}Pn(e,t){return!!e&&co(e.propertyFilters,t?.properties)}Rn(e,t){var n=new Map;return e.forEach((e=>{var r;(r=e.conditions)==null||(r=r[t])==null||(r=r.values)==null||r.forEach((t=>{if(t!=null&&t.name){var r=n.get(t.name)||[];r.push(e.id),n.set(t.name,r)}}))})),n}On(e,t,n){var r=(n===Ki.Activation?this.Tn:this.En).get(e),i=[];return this.Ln((e=>{i=e.filter((e=>r?.includes(e.id)))})),i.filter((r=>{var i,a=(i=r.conditions)==null||(i=i[n])==null||(i=i.values)==null?void 0:i.find((t=>t.name===e));return this.Pn(a,t)}))}register(e){I(this._instance?._addCaptureHook)||(this.Fn(e),this.An(e))}An(e){var t=e.filter((e=>{var t;return e.conditions?.actions&&((t=e.conditions)==null||(t=t.actions)==null||(t=t.values)==null?void 0:t.length)>0}));t.length!==0&&(this.Nn??(this.Nn=new Bs(this._instance),this.Nn.init(),this.Nn.xn((e=>{this.onAction(e)}))),t.forEach((e=>{var t,n,r,i,a;e.conditions&&(t=e.conditions)!=null&&t.actions&&(n=e.conditions)!=null&&(n=n.actions)!=null&&n.values&&((r=e.conditions)==null||(r=r.actions)==null||(r=r.values)==null?void 0:r.length)>0&&((i=this.Nn)==null||i.register(e.conditions.actions.values),(a=e.conditions)==null||(a=a.actions)==null||(a=a.values)==null||a.forEach((t=>{if(t&&t.name){var n=this.Mn.get(t.name);n&&n.push(e.id),this.Mn.set(t.name,n||[e.id])}})))})))}Fn(e){var t,n=e.filter((e=>{var t;return e.conditions?.events&&((t=e.conditions)==null||(t=t.events)==null||(t=t.values)==null?void 0:t.length)>0})),r=e.filter((e=>{var t;return e.conditions?.cancelEvents&&((t=e.conditions)==null||(t=t.cancelEvents)==null||(t=t.values)==null?void 0:t.length)>0}));n.length===0&&r.length===0||((t=this._instance)==null||t._addCaptureHook(((e,t)=>{this.onEvent(e,t)})),this.Tn=this.Rn(e,Ki.Activation),this.En=this.Rn(e,Ki.Cancellation))}onEvent(e,t){var n,r=this.le(),i=this.$n(),a=this.Dn(),o=((n=this._instance)==null||(n=n.persistence)==null?void 0:n.props[i])||[];if(a===e&&t&&o.length>0){var s,c;r.info(`event matched, removing item from activated items`,{event:e,eventPayload:t,existingActivatedItems:o});var l=(t==null||(s=t.properties)==null?void 0:s.$survey_id)||(t==null||(c=t.properties)==null?void 0:c.$product_tour_id);if(l){var u=o.indexOf(l);0>u||(o.splice(u,1),this.qn(o))}}else{if(this.En.has(e)){var d=this.On(e,t,Ki.Cancellation);d.length>0&&(r.info(`cancel event matched, cancelling items`,{event:e,itemsToCancel:d.map((e=>e.id))}),d.forEach((e=>{var t=o.indexOf(e.id);0>t||o.splice(t,1),this.jn(e.id)})),this.qn(o))}if(this.Tn.has(e)){r.info(`event name matched`,{event:e,eventPayload:t,items:this.Tn.get(e)});var f=this.On(e,t,Ki.Activation);this.qn(o.concat(f.map((e=>e.id))||[]))}}}onAction(e){var t,n=this.$n(),r=((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[n])||[];this.Mn.has(e)&&this.qn(r.concat(this.Mn.get(e)||[]))}qn(e){var t=this.le(),n=[...new Set(e)].filter((e=>!this.Hn(e)));t.info(`updating activated items`,{activatedItems:n}),this.Un(n)}getActivatedIds(){var e,t=this.$n();return((e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t])||[]}getEventToItemsMap(){return this.Tn}Bn(){return this.Nn}},Hs=class extends Vs{constructor(e){super(e)}$n(){return lr}Dn(){return Ji.SHOWN}Ln(e){var t;(t=this._instance)==null||t.getSurveys(e)}jn(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}le(){return z}Un(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({[lr]:e})}Hn(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},Us=`SDK is not enabled or survey functionality is not yet loaded`,Ws=`Disabled. Not loading surveys.`,Gs=D!=null&&D.location?Oi(D.location.hash,`__posthog`)||Oi(location.hash,`state`):null,Ks=`_postHogToolbarParams`,qs=kn(`[Toolbar]`),Js=kn(`[FeatureFlags]`),Ys=kn(`[FeatureFlags]`,{debugEnabled:!0}),Xs=`" failed. Feature flags didn't load in time.`,Zs=e=>{for(var t={},n=0;e.length>n;n++)t[e[n]]=!0;return t},Qs=e=>{var t={};for(var[n,r]of Hr(e||{}))r&&(t[n]=r);return t},$s=kn(`[Error tracking]`),ec=`Refusing to render web experiment since the viewer is a likely bot`,tc={icontains:(e,t)=>!!D&&t.href.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>!!D&&t.href.toLowerCase().indexOf(e.toLowerCase())===-1,regex:(e,t)=>!!D&&io(t.href,e),not_regex:(e,t)=>!!D&&!io(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e},nc=class e{get qt(){return this._instance.config}constructor(t){var n=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(t){t===void 0&&(t=!1),n.getWebExperiments((t=>{e.zn(`retrieved web experiments from the server`),n.Vn=new Map,t.forEach((t=>{if(t.feature_flag_key){var r;n.Vn&&(e.zn(`setting flag key `,t.feature_flag_key,` to web experiment `,t),(r=n.Vn)==null||r.set(t.feature_flag_key,t));var i=n._instance.getFeatureFlag(t.feature_flag_key);Ae(i)&&t.variants[i]&&n.Wn(t.name,i,t.variants[i].transforms)}else if(t.variants)for(var a in t.variants){var o=t.variants[a];e.Zn(o)&&n.Wn(t.name,a,o.transforms)}}))}),t)},this._instance=t,this._instance.onFeatureFlags((e=>{this.onFeatureFlags(e)}))}initialize(){}onFeatureFlags(t){if(this._is_bot())e.zn(ec);else if(!this.qt.disable_web_experiments){if(L(this.Vn))return this.Vn=new Map,this.loadIfEnabled(),void this.previewWebExperiment();e.zn(`applying feature flags`,t),t.forEach((e=>{var t;if(this.Vn&&(t=this.Vn)!=null&&t.has(e)){var n=this._instance.getFeatureFlag(e),r=this.Vn?.get(e);n&&r!=null&&r.variants[n]&&this.Wn(r.name,n,r.variants[n].transforms)}}))}}previewWebExperiment(){var t=e.getWindowLocation();if(t!=null&&t.search){var n=Ei(t?.search,`__experiment_id`),r=Ei(t?.search,`__experiment_variant`);n&&r&&(e.zn(`previewing web experiments `+n+` && `+r),this.getWebExperiments((e=>{this.Gn(parseInt(n),r,e)}),!1,!0))}}loadIfEnabled(){this.qt.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,n){if(this.qt.disable_web_experiments&&!n)return e([]);var r=this._instance.get_property(`$web_experiments`);if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/web_experiments/?token=`+this.qt.token),method:`GET`,callback:t=>e(t.statusCode===200&&t.json&&t.json.experiments||[])})}Gn(t,n,r){var i=r.filter((e=>e.id===t));i&&i.length>0&&(e.zn(`Previewing web experiment [`+i[0].name+`] with variant [`+n+`]`),this.Wn(i[0].name,n,i[0].variants[n].transforms))}static Zn(t){return!L(t.conditions)&&e.Qn(t)&&e.Jn(t)}static Qn(t){if(L(t.conditions)||L(t.conditions?.url))return!0;var n,r=e.getWindowLocation();return!!r&&((n=t.conditions)==null||!n.url||tc[t.conditions?.urlMatchType??`icontains`](t.conditions.url,r))}static getWindowLocation(){return D?.location}static Jn(e){if(L(e.conditions)||L(e.conditions?.utm))return!0;var t=Pi();if(t.utm_source){var n,r,i,a,o,s,c,l,u=(n=e.conditions)==null||(n=n.utm)==null||!n.utm_campaign||((r=e.conditions)==null||(r=r.utm)==null?void 0:r.utm_campaign)==t.utm_campaign,d=(i=e.conditions)==null||(i=i.utm)==null||!i.utm_source||((a=e.conditions)==null||(a=a.utm)==null?void 0:a.utm_source)==t.utm_source,f=(o=e.conditions)==null||(o=o.utm)==null||!o.utm_medium||((s=e.conditions)==null||(s=s.utm)==null?void 0:s.utm_medium)==t.utm_medium,p=(c=e.conditions)==null||(c=c.utm)==null||!c.utm_term||((l=e.conditions)==null||(l=l.utm)==null?void 0:l.utm_term)==t.utm_term;return u&&f&&p&&d}return!1}static zn(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];R.info(`[WebExperiments] `+e,n)}Wn(t,n,r){this._is_bot()?e.zn(ec):n===`control`?e.zn(`Control variants leave the page unmodified.`):r.forEach((r=>{r.selector&&(e.zn(`applying transform of variant `+n+` for experiment `+t+` `,r),(document?.querySelectorAll(r.selector))?.forEach((e=>{var t=e;r.html&&(t.innerHTML=r.html),r.css&&t.setAttribute(`style`,r.css)})))}))}_is_bot(){return k&&this._instance?ro(k,this.qt.custom_blocked_useragents):void 0}},rc=kn(`[Conversations]`),ic=`Conversations not available yet.`,ac={featureFlags:class{constructor(e){this.Kn=!1,this.Yn=!1,this.Xn=!1,this.es=!1,this.ts=!1,this.rs=!1,this.ns=!1,this.ss=!1,this._instance=e,this.featureFlagEventHandlers=[]}get qt(){return this._instance.config}get ni(){return this._instance.persistence}os(e){return this._instance.get_property(e)}us(){var e;return(e=this.ni?.wr(this.qt.feature_flag_cache_ttl_ms))!=null&&e}ls(){return!!this.us()&&(this.ss||this.Xn||(this.ss=!0,Js.warn(`Feature flag cache is stale, triggering refresh...`),this.reloadFeatureFlags()),!0)}hs(){var e=this.qt.evaluation_contexts??this.qt.evaluation_environments;return!this.qt.evaluation_environments||this.qt.evaluation_contexts||this.ns||(Js.warn(`evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version.`),this.ns=!0),e!=null&&e.length?e.filter((e=>{var t=e&&typeof e==`string`&&e.trim().length>0;return t||Js.error(`Invalid evaluation context found:`,e,`Expected non-empty string`),t})):[]}cs(){return this.hs().length>0}ds(){var e=this.qt.flag_keys;if(!I(e)){if(F(e))return e.filter((e=>{var t=e&&typeof e==`string`&&e.trim().length>0;return t||Js.error(`Invalid flag key found:`,e,`Expected non-empty string`),t}));Js.error(`Invalid flag_keys found:`,e,`Expected array of non-empty strings`)}}initialize(){var{config:e}=this._instance,t=e.bootstrap?.featureFlags??{};if(Object.keys(t).length){var n=e.bootstrap?.featureFlagPayloads??{},r=Object.keys(t).filter((e=>!!t[e])).reduce(((e,n)=>(e[n]=t[n]||!1,e)),{}),i=Object.keys(n).filter((e=>r[e])).reduce(((e,t)=>(n[t]&&(e[t]=n[t]),e)),{});this.receivedFeatureFlags({featureFlags:r,featureFlagPayloads:i})}}updateFlags(e,t,n){var r=n!=null&&n.merge?this.getFlagVariants():{},i=n!=null&&n.merge?this.getFlagPayloads():{},a=N({},r,e),o=N({},i,t),s={};for(var[c,l]of Object.entries(a)){var u=typeof l==`string`;s[c]={key:c,enabled:!!u||!!l,variant:u?l:void 0,reason:void 0,metadata:I(o?.[c])?void 0:{id:0,version:void 0,description:void 0,payload:o[c]}}}this.receivedFeatureFlags({flags:s})}get hasLoadedFlags(){return this.Yn}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this.os(tr),t=this.os(ir),n=this.os(ar);if(!n&&!t)return e||{};var r=Vr({},e||{});for(var i of[...new Set([...Object.keys(n||{}),...Object.keys(t||{})])]){var a,o,s=r[i],c=t?.[i],l=I(c)?(a=s?.enabled)!=null&&a:!!c,u=I(c)?s.variant:typeof c==`string`?c:void 0,d=n?.[i],f=N({},s,{enabled:l,variant:l?u??s?.variant:void 0});l!==s?.enabled&&(f.original_enabled=s?.enabled),u!==s?.variant&&(f.original_variant=s?.variant),d&&(f.metadata=N({},s?.metadata,{payload:d,original_payload:s==null||(o=s.metadata)==null?void 0:o.payload})),r[i]=f}return this.Kn||=(Js.warn(` Overriding feature flag details!`,{flagDetails:e,overriddenPayloads:n,finalDetails:r}),!0),r}getFlagVariants(){var e=this.os(Qn),t=this.os(ir);if(!t)return e||{};for(var n=Vr({},e),r=Object.keys(t),i=0;r.length>i;i++)n[r[i]]=t[r[i]];return this.Kn||=(Js.warn(` Overriding feature flags!`,{enabledFlags:e,overriddenFlags:t,finalFlags:n}),!0),n}getFlagPayloads(){var e=this.os(nr),t=this.os(ar);if(!t)return e||{};for(var n=Vr({},e||{}),r=Object.keys(t),i=0;r.length>i;i++)n[r[i]]=t[r[i]];return this.Kn||=(Js.warn(` Overriding feature flag payloads!`,{flagPayloads:e,overriddenPayloads:t,finalPayloads:n}),!0),n}reloadFeatureFlags(){this.es||this.qt.advanced_disable_feature_flags||this.vs||(this._instance.Li.emit(`featureFlagsReloading`,!0),this.vs=setTimeout((()=>{this.fs()}),5))}ps(){clearTimeout(this.vs),this.vs=void 0}ensureFlagsLoaded(){this.Yn||this.Xn||this.vs||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.es=e}fs(e){if(this.ps(),!this._instance.Lr())if(this.Xn)this.ts=!0;else{var t=this.qt.token,n=this.os(Nn),r={token:t,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:N({},this.ni?.get_initial_props()||{},this.os(or)||{}),group_properties:this.os(sr),timezone:Hi()};Me(n)||I(n)||(r.$device_id=n),(e!=null&&e.disableFlags||this.qt.advanced_disable_feature_flags)&&(r.disable_flags=!0),this.cs()&&(r.evaluation_contexts=this.hs());var i=this.ds();I(i)||(r.flag_keys=i);var a=!!this.qt.advanced_only_evaluate_survey_feature_flags,o=this._instance.requestRouter.endpointFor(`flags`,`/flags/?v=2`+(this.qt.advanced_only_evaluate_survey_feature_flags?`&only_evaluate_survey_feature_flags=true`:``));this.Xn=!0,this._instance._send_request({method:`POST`,url:o,data:r,compression:this.qt.disable_compression?void 0:ra.Base64,timeout:this.qt.feature_flag_request_timeout_ms,callback:e=>{var t,n,i,o=!0;if(e.statusCode===200&&(this.ts||(this.$anon_distinct_id=void 0),o=!1),this.Xn=!1,!r.disable_flags||this.ts){this.rs=!o;var s=[];e.error?e.error instanceof Error?s.push(e.error.name===`AbortError`?`timeout`:`connection_error`):s.push(`unknown_error`):e.statusCode!==200&&s.push(`api_error_`+e.statusCode),(t=e.json)!=null&&t.errorsWhileComputingFlags&&s.push(`errors_while_computing_flags`);var c=!((n=e.json)==null||(n=n.quotaLimited)==null||!n.includes(`feature_flags`));c&&s.push(`quota_limited`),(i=this.ni)==null||i.register({[pr]:s}),c?Js.warn(`You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more.`):(r.disable_flags||this.receivedFeatureFlags(e.json??{},o,{partialResponse:a}),this.ts&&(this.ts=!1,this.fs()))}}})}}getFeatureFlag(e,t){if(t===void 0&&(t={}),!t.fresh||this.rs)if(this.Yn||this.getFlags()&&this.getFlags().length>0){if(!this.ls()){var n=this.getFeatureFlagResult(e,t);return n?.variant??n?.enabled}}else Js.warn(`getFeatureFlag for key "`+e+Xs)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){return this.getFeatureFlagResult(e,{send_event:!1})?.payload}getFeatureFlagResult(e,t){if(t===void 0&&(t={}),!t.fresh||this.rs)if(this.Yn||this.getFlags()&&this.getFlags().length>0){if(!this.ls()){var n=this.getFlagVariants(),r=e in n,i=n[e],a=this.getFlagPayloads()[e],o=String(i),s=this.os(rr)||void 0,c=this.os(mr)||void 0,l=this.os(dr)||{};if(this.qt.advanced_feature_flags_dedup_per_session){var u,d=this._instance.get_session_id(),f=this.os(fr);d&&d!==f&&(l={},(u=this.ni)==null||u.register({[dr]:l,[fr]:d}))}if((t.send_event||!(`send_event`in t))&&(!(e in l)||!l[e].includes(o))){var p,m,h,g,_,v,y,b;F(l[e])?l[e].push(o):l[e]=[o],(p=this.ni)==null||p.register({[dr]:l});var x=this.getFeatureFlagDetails(e),S=[...this.os(pr)??[]];I(i)&&S.push(`flag_missing`);var C={$feature_flag:e,$feature_flag_response:i,$feature_flag_payload:a||null,$feature_flag_request_id:s,$feature_flag_evaluated_at:c,$feature_flag_bootstrapped_response:((m=this.qt.bootstrap)==null||(m=m.featureFlags)==null?void 0:m[e])||null,$feature_flag_bootstrapped_payload:((h=this.qt.bootstrap)==null||(h=h.featureFlagPayloads)==null?void 0:h[e])||null,$used_bootstrap_value:!this.rs};I(x==null||(g=x.metadata)==null?void 0:g.version)||(C.$feature_flag_version=x.metadata.version);var w,T=(x==null||(_=x.reason)==null?void 0:_.description)??(x==null||(v=x.reason)==null?void 0:v.code);T&&(C.$feature_flag_reason=T),x!=null&&(y=x.metadata)!=null&&y.id&&(C.$feature_flag_id=x.metadata.id),I(x?.original_variant)&&I(x?.original_enabled)||(C.$feature_flag_original_response=I(x.original_variant)?x.original_enabled:x.original_variant),x!=null&&(b=x.metadata)!=null&&b.original_payload&&(C.$feature_flag_original_payload=x==null||(w=x.metadata)==null?void 0:w.original_payload),S.length&&(C.$feature_flag_error=S.join(`,`)),this._instance.capture(`$feature_flag_called`,C)}if(r){var E=a;if(!I(a))try{E=JSON.parse(a)}catch{}return{key:e,enabled:!!i,variant:typeof i==`string`?i:void 0,payload:E}}}}else Js.warn(`getFeatureFlagResult for key "`+e+Xs)}getRemoteConfigPayload(e,t){var n=this.qt.token,r={distinct_id:this._instance.get_distinct_id(),token:n};this.cs()&&(r.evaluation_contexts=this.hs());var i=this.ds();I(i)||(r.flag_keys=i),this._instance._send_request({method:`POST`,url:this._instance.requestRouter.endpointFor(`flags`,`/flags/?v=2`),data:r,compression:this.qt.disable_compression?void 0:ra.Base64,timeout:this.qt.feature_flag_request_timeout_ms,callback(n){var r=n.json?.featureFlagPayloads;t(r?.[e]||void 0)}})}isFeatureEnabled(e,t){if(t===void 0&&(t={}),!t.fresh||this.rs){if(this.Yn||this.getFlags()&&this.getFlags().length>0){var n=this.getFeatureFlag(e,t);return I(n)?void 0:!!n}Js.warn(`isFeatureEnabled for key "`+e+Xs)}}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t,n){if(this.ni){this.Yn=!0;var r=this.getFlagVariants(),i=this.getFlagPayloads(),a=this.getFlagsWithDetails();(function(e,t,n,r,i,a){n===void 0&&(n={}),r===void 0&&(r={}),i===void 0&&(i={});var o=(e=>{var t=e.flags;return t?(e.featureFlags=Object.fromEntries(Object.keys(t).map((e=>[e,t[e].variant??t[e].enabled]))),e.featureFlagPayloads=Object.fromEntries(Object.keys(t).filter((e=>t[e].enabled)).filter((e=>t[e].metadata?.payload)).map((e=>[e,t[e].metadata?.payload])))):Js.warn(`Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version`),e})(e),s=o.flags,c=o.featureFlags,l=o.featureFlagPayloads;if(c){var u=e.requestId,d=e.evaluatedAt;if(F(c)){Js.warn(`v1 of the feature flags endpoint is deprecated. Please use the latest version.`);var f={};if(c)for(var p=0;c.length>p;p++)f[c[p]]=!0;t&&t.register({[$n]:c,[Qn]:f})}else{var m=c,h=l,g=s;if(a!=null&&a.partialResponse)m=N({},n,m),h=N({},r,h),g=N({},i,g);else if(e.errorsWhileComputingFlags)if(s){var _=new Set(Object.keys(s).filter((e=>{var t;return!((t=s[e])!=null&&t.failed)})));m=N({},n,Object.fromEntries(Object.entries(m).filter((e=>{var[t]=e;return _.has(t)})))),h=N({},r,Object.fromEntries(Object.entries(h||{}).filter((e=>{var[t]=e;return _.has(t)})))),g=N({},i,Object.fromEntries(Object.entries(g||{}).filter((e=>{var[t]=e;return _.has(t)}))))}else m=N({},n,m),h=N({},r,h),g=N({},i,g);t&&t.register(N({[$n]:Object.keys(Qs(m)),[Qn]:m||{},[nr]:h||{},[tr]:g||{}},u?{[rr]:u}:{},d?{[mr]:d}:{}))}}})(e,this.ni,r,i,a,n),t||(this.ss=!1),this.gs(t)}}override(e,t){t===void 0&&(t=!1),Js.warn(`override is deprecated. Please use overrideFeatureFlags instead.`),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this.ni)return Js.uninitializedWarning(`posthog.featureFlags.overrideFeatureFlags`);if(!1===e)return this.ni.unregister(ir),this.ni.unregister(ar),this.gs(),Ys.info(`All overrides cleared`);if(F(e)){var t=Zs(e);return this.ni.register({[ir]:t}),this.gs(),Ys.info(`Flag overrides set`,{flags:e})}if(e&&typeof e==`object`&&(`flags`in e||`payloads`in e)){var n,r=e;if(this.Kn=!!((n=r.suppressWarning)!=null&&n),`flags`in r){if(!1===r.flags)this.ni.unregister(ir),Ys.info(`Flag overrides cleared`);else if(r.flags){if(F(r.flags)){var i=Zs(r.flags);this.ni.register({[ir]:i})}else this.ni.register({[ir]:r.flags});Ys.info(`Flag overrides set`,{flags:r.flags})}}`payloads`in r&&(!1===r.payloads?(this.ni.unregister(ar),Ys.info(`Payload overrides cleared`)):r.payloads&&(this.ni.register({[ar]:r.payloads}),Ys.info(`Payload overrides set`,{payloads:r.payloads}))),this.gs();return}if(e&&typeof e==`object`)return this.ni.register({[ir]:e}),this.gs(),Ys.info(`Flag overrides set`,{flags:e});Js.warn(`Invalid overrideOptions provided to overrideFeatureFlags`,{overrideOptions:e})}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.Yn){var{flags:t,flagVariants:n}=this.ys();e(t,n)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,n){var r,i=(this.os(er)||[]).find((t=>t.flagKey===e)),a={[`$feature_enrollment/`+e]:t},o={$feature_flag:e,$feature_enrollment:t,$set:a};i&&(o.$early_access_feature_name=i.name),n&&(o.$feature_enrollment_stage=n),this._instance.capture(`$feature_enrollment_update`,o),this.setPersonPropertiesForFlags(a,!1);var s=N({},this.getFlagVariants(),{[e]:t});(r=this.ni)==null||r.register({[$n]:Object.keys(Qs(s)),[Qn]:s}),this.gs()}getEarlyAccessFeatures(e,t,n){t===void 0&&(t=!1);var r=this.os(er),i=n?`&`+n.map((e=>`stage=`+e)).join(`&`):``;if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/early_access_features/?token=`+this.qt.token+i),method:`GET`,callback:t=>{var n,r;if(t.json){var i=t.json.earlyAccessFeatures;return(n=this.ni)==null||n.unregister(er),(r=this.ni)==null||r.register({[er]:i}),e(i)}}})}ys(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((e=>t[e])),flagVariants:Object.keys(t).filter((e=>t[e])).reduce(((e,n)=>(e[n]=t[n],e)),{})}}gs(e){var{flags:t,flagVariants:n}=this.ys();this.featureFlagEventHandlers.forEach((r=>r(t,n,{errorsLoading:e})))}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=this.os(or)||{},r=e?.$set||(e!=null&&e.$set_once?{}:e),i=e?.$set_once,a={};if(i)for(var o in i)({}).hasOwnProperty.call(i,o)&&(o in n||(a[o]=i[o]));this._instance.register({[or]:N({},n,a,r)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(or)}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=this.os(sr)||{};Object.keys(n).length!==0&&Object.keys(n).forEach((t=>{n[t]=N({},n[t],e[t]),delete e[t]})),this._instance.register({[sr]:N({},n,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this.os(sr)||{};this._instance.register({[sr]:N({},t,{[e]:{}})})}else this._instance.unregister(sr)}reset(){this.Yn=!1,this.Xn=!1,this.es=!1,this.ts=!1,this.rs=!1,this.$anon_distinct_id=void 0,this.ps(),this.Kn=!1}}},oc={sessionRecording:class{get qt(){return this._instance.config}get ni(){return this._instance.persistence}get started(){var e;return!((e=this.bs)==null||!e.isStarted)}get status(){return this._s===ks||this._s===As?this._s:this.bs?.status??this._s}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this._s=Ds,this.ws=void 0,this._instance=e,!this._instance.sessionManager)throw Ms.error(`started without valid sessionManager`),Error(js+` started without valid sessionManager. This is a bug.`);if(this.qt.cookieless_mode===kr)throw Error(js+` cannot be used with cookieless_mode="always"`)}initialize(){this.startIfEnabledOrStop()}get xs(){var e,t=!((e=this._instance.get_property(Gn))==null||!e.enabled),n=!this.qt.disable_session_recording,r=this.qt.disable_session_recording||this._instance.consent.isOptedOut();return D&&t&&n&&!r}startIfEnabledOrStop(e){var t;if(!this.xs||(t=this.bs)==null||!t.isStarted){var n=!I(Object.assign)&&!I(Array.from);this.xs&&n?(this.Ss(e),Ms.info(`starting`)):(this._s=Ds,this.stopRecording())}}Ss(e){var t,n,r;this.xs&&(this._s!==ks&&this._s!==As&&(this._s=Os),M!=null&&(t=M.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&(n=M.__PosthogExtensions__)!=null&&n.initSessionRecording?this.ks(e):(r=M.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,this.Cs,(t=>{if(t)return Ms.error(`could not load recorder`,t);this.ks(e)})))}stopRecording(){var e,t;(e=this.ws)==null||e.call(this),this.ws=void 0,(t=this.bs)==null||t.stop()}Is(){var e,t;(e=this.ws)==null||e.call(this),this.ws=void 0,(t=this.bs)==null||t.discard()}Ts(){var e;(e=this.ni)==null||e.unregister(Zn)}Es(e,t){if(L(e))return null;var n,r=Ne(e)?e:parseFloat(e);return typeof(n=r)!=`number`||!Number.isFinite(n)||0>n||n>1?(Ms.warn(t+` must be between 0 and 1. Ignoring invalid value:`,e),null):r}Ms(e){if(this.ni){var t,n=this.ni,r=()=>{var t=!1===e.sessionRecording?void 0:e.sessionRecording,r=this.Es(this.qt.session_recording?.sampleRate,`session_recording.sampleRate`),i=this.Es(t?.sampleRate,`remote config sampleRate`),a=r??i;L(a)&&this.Ts();var o=t?.minimumDurationMilliseconds;n.register({[Gn]:N({cache_timestamp:Date.now(),enabled:!!t},t,{networkPayloadCapture:N({capturePerformance:e.capturePerformance},t?.networkPayloadCapture),canvasRecording:{enabled:t?.recordCanvas,fps:t?.canvasFps,quality:t?.canvasQuality},sampleRate:a,minimumDurationMilliseconds:I(o)?null:o,endpoint:t?.endpoint,triggerMatchType:t?.triggerMatchType,masking:t?.masking,urlTriggers:t?.urlTriggers,version:t?.version,triggerGroups:t?.triggerGroups})})};r(),(t=this.ws)==null||t.call(this),this.ws=this._instance.sessionManager?.onSessionId(r)}}onRemoteConfig(e){`sessionRecording`in e?!1===e.sessionRecording?(this.Ms(e),this.Is()):(this.Ms(e),this.startIfEnabledOrStop()):(this._s===ks&&(this._s=As,Ms.warn(`config refresh failed, recording will not start until page reload`)),this.startIfEnabledOrStop())}log(e,t){var n;t===void 0&&(t=`log`),(n=this.bs)!=null&&n.log?this.bs.log(e,t):Ms.warn(`log called before recorder was ready`)}get Cs(){var e,t,n=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(Gn);return(n==null||(t=n.scriptConfig)==null?void 0:t.script)||`lazy-recorder`}Ps(){var e,t=this._instance.get_property(Gn);if(!t)return!1;try{e=typeof t==`object`?t:JSON.parse(t)}catch(e){return Ms.warn(`persisted remote config for session recording is invalid and will be ignored`,e),!1}var n=e.cache_timestamp??Date.now();return 36e5>=Date.now()-n}ks(e){var t;if((t=M.__PosthogExtensions__)==null||!t.initSessionRecording)return Ms.warn(`Called on script loaded before session recording is available. This can be caused by adblockers.`),void this._instance.register_for_session({[Er]:!0});if(this.bs||(this.bs=M.__PosthogExtensions__?.initSessionRecording(this._instance),this.bs._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Ps()){if(this._s===As||this._s===ks)return;this._s=ks,Ms.info(`persisted remote config is stale, requesting fresh config before starting`),new na(this._instance).load();return}this._s=Os,this.bs.start(e)}onRRwebEmit(e){var t;(t=this.bs)==null||t.onRRwebEmit==null||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this.bs||(t=this.ni)==null||t.register({[qn]:!0}),(e=this.bs)==null||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.bs||(t=this.ni)==null||t.register({[Kn]:!0}),(e=this.bs)==null||e.overrideSampling()}overrideTrigger(e){var t,n;this.bs||(n=this.ni)==null||n.register({[e===`url`?Jn:Yn]:!0}),(t=this.bs)==null||t.overrideTrigger(e)}get sdkDebugProperties(){return this.bs?.sdkDebugProperties||{$recording_status:this.status}}tryAddCustomEvent(e,t){var n;return!((n=this.bs)==null||!n.tryAddCustomEvent(e,t))}}},sc={autocapture:class{constructor(e){this.Rs=!1,this.Os=null,this.Ls=!1,this.instance=e,this.rageclicks=new gs(e.config.rageclick),this.Fs=null}initialize(){this.startIfEnabled()}get qt(){var e=Oe(this.instance.config.autocapture)?this.instance.config.autocapture:{};return e.url_allowlist=e.url_allowlist?.map((e=>new RegExp(e))),e.url_ignorelist=e.url_ignorelist?.map((e=>new RegExp(e))),e}As(){if(this.isBrowserSupported()){if(D&&A){var e=e=>{e||=D?.event;try{this.Ns(e)}catch(e){vs.error(`Failed to capture event`,e)}};if(Jr(A,`submit`,e,{capture:!0}),Jr(A,`change`,e,{capture:!0}),Jr(A,`click`,e,{capture:!0}),this.qt.capture_copied_text){var t=e=>{e||=D?.event;try{this.Ns(e,_s)}catch(e){vs.error(`Failed to capture copy/cut event`,e)}};Jr(A,`copy`,t,{capture:!0}),Jr(A,`cut`,t,{capture:!0})}}}else vs.info(`Disabling Automatic Event Collection because this browser is not supported`)}startIfEnabled(){this.isEnabled&&!this.Rs&&(this.As(),this.Rs=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this.Ls=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[In]:!!e.autocapture_opt_out}),this.Os=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this.Fs=e}getElementSelectors(e){var t,n=[];return(t=this.Fs)==null||t.forEach((t=>{(A?.querySelectorAll(t))?.forEach((r=>{e===r&&n.push(t)}))})),n}get isEnabled(){var e=this.instance.persistence?.props[In];if(Me(this.Os)&&!Fe(e)&&!this.instance.Lr())return!1;var t=this.Os??!!e;return!!this.instance.config.autocapture&&!t}Ns(e,t){if(t===void 0&&(t=`$autocapture`),this.isEnabled){var n,r=Jo(e);Vo(r)&&(r=r.parentNode||null),t===`$autocapture`&&e.type===`click`&&e instanceof MouseEvent&&this.instance.config.rageclick&&(n=this.rageclicks)!=null&&n.isRageClick(e.clientX,e.clientY,e.timeStamp||new Date().getTime())&&function(e,t){if(!D||es(e))return!1;var n,r;if(Fe(t)?(n=!!t&&$o,r=void 0):(n=t?.css_selector_ignorelist??$o,r=t?.content_ignorelist),!1===n)return!1;var{targetElementList:i}=ts(e,!1);return!function(e,t){if(!1===e||I(e))return!1;var n;if(!0===e)n=Qo;else{if(!F(e))return!1;if(e.length>10)return R.error(`[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching.`),!1;n=e.map((e=>e.toLowerCase()))}return t.some((e=>{var{safeText:t,ariaLabel:r}=e;return n.some((e=>t.includes(e)||r.includes(e)))}))}(r,i.map((e=>({safeText:qo(e).toLowerCase(),ariaLabel:e.getAttribute(`aria-label`)?.toLowerCase().trim()||``}))))&&!Xo(i,n)}(r,this.instance.config.rageclick)&&this.Ns(e,`$rageclick`);var i=t===_s;if(r&&function(e,t,n,r,i){var a,o,s;if(n===void 0&&(n=void 0),!D||es(e)||(a=n)!=null&&a.url_allowlist&&!Wo(n.url_allowlist)||(o=n)!=null&&o.url_ignorelist&&Wo(n.url_ignorelist))return!1;if((s=n)!=null&&s.dom_event_allowlist){var c=n.dom_event_allowlist;if(c&&!c.some((e=>t.type===e)))return!1}var{parentIsUsefulElement:l,targetElementList:u}=ts(e,r);if(!function(e,t){var n=t?.element_allowlist;if(I(n))return!0;var r,i=function(e){if(n.some((t=>e.tagName.toLowerCase()===t)))return{v:!0}};for(var a of e)if(r=i(a))return r.v;return!1}(u,n)||!Xo(u,n?.css_selector_allowlist))return!1;var d=D.getComputedStyle(e);if(d&&d.getPropertyValue(`cursor`)===`pointer`&&t.type===`click`)return!0;var f=e.tagName.toLowerCase();switch(f){case`html`:return!1;case`form`:return(i||[`submit`]).indexOf(t.type)>=0;case`input`:case`select`:case`textarea`:return(i||[`change`,`click`]).indexOf(t.type)>=0;default:return l?(i||[`click`]).indexOf(t.type)>=0:(i||[`click`]).indexOf(t.type)>=0&&(Yo.indexOf(f)>-1||e.getAttribute(`contenteditable`)===`true`)}}(r,e,this.qt,i,i?[`copy`,`cut`]:void 0)){var{props:a,explicitNoCapture:o}=xs(r,{e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.qt.element_attribute_ignorelist,elementsChainAsString:this.Ls});if(o)return!1;var s=this.getElementSelectors(r);if(s&&s.length>0&&(a.$element_selectors=s),t===_s){var c,l=Ko(D==null||(c=D.getSelection())==null?void 0:c.toString()),u=e.type||`clipboard`;if(!l)return!1;a.$selected_content=l,a.$copy_type=u}return this.instance.capture(t,a),!0}}}isBrowserSupported(){return De(A?.querySelectorAll)}},historyAutocapture:class{constructor(e){var t;this._instance=e,this.$s=(D==null||(t=D.location)==null?void 0:t.pathname)||``}initialize(){this.startIfEnabled()}get isEnabled(){return this._instance.config.capture_pageview===`history_change`}startIfEnabled(){this.isEnabled&&(R.info(`History API monitoring enabled, starting...`),this.monitorHistoryChanges())}stop(){this.Ds&&this.Ds(),this.Ds=void 0,R.info(`History API monitoring stopped`)}monitorHistoryChanges(){var e,t;if(D&&D.history){var n=this;(e=D.history.pushState)!=null&&e.__posthog_wrapped__||Cs(D.history,`pushState`,(e=>function(t,r,i){e.call(this,t,r,i),n.qs(`pushState`)})),(t=D.history.replaceState)!=null&&t.__posthog_wrapped__||Cs(D.history,`replaceState`,(e=>function(t,r,i){e.call(this,t,r,i),n.qs(`replaceState`)})),this.js()}}qs(e){try{var t,n=D==null||(t=D.location)==null?void 0:t.pathname;if(!n)return;n!==this.$s&&this.isEnabled&&this._instance.capture(Fr,{navigation_type:e}),this.$s=n}catch(t){R.error(`Error capturing `+e+` pageview`,t)}}js(){if(!this.Ds){var e=()=>{this.qs(`popstate`)};Jr(D,`popstate`,e),this.Ds=()=>{D&&D.removeEventListener(`popstate`,e)}}}},heatmaps:class{get qt(){return this.instance.config}constructor(e){var t;this.Hs=!1,this.Rs=!1,this.Us=null,this.instance=e,this.Hs=!((t=this.instance.persistence)==null||!t.props[Ln]),this.rageclicks=new gs(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var e=5e3;return Oe(this.qt.capture_heatmaps)&&this.qt.capture_heatmaps.flush_interval_milliseconds&&(e=this.qt.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return L(this.qt.capture_heatmaps)?L(this.qt.enable_heatmaps)?this.Hs:this.qt.enable_heatmaps:!1!==this.qt.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.Rs)return;Ns.info(`starting...`),this.Bs(),this.At()}else clearInterval(this.Us??void 0),this.zs(),this.getAndClearBuffer()}onRemoteConfig(e){if(`heatmaps`in e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Ln]:t}),this.Hs=t,this.startIfEnabled()}}getAndClearBuffer(){var e=this.M;return this.M=void 0,e}Vs(e){this.Mt(e.originalEvent,`deadclick`)}At(){this.Us&&clearInterval(this.Us),this.Us=A?.visibilityState===`visible`?setInterval(this.Zr.bind(this),this.flushIntervalMilliseconds):null}Bs(){D&&A&&(this.Ws=this.Zr.bind(this),Jr(D,Pr,this.Ws),this.Zs=e=>this.Mt(e||D?.event),Jr(A,`click`,this.Zs,{capture:!0}),this.Gs=e=>this.Qs(e||D?.event),Jr(A,`mousemove`,this.Gs,{capture:!0}),this.Js=new _i(this.instance,hi,this.Vs.bind(this)),this.Js.startIfEnabledOrStop(),this.Ks=this.At.bind(this),Jr(A,Nr,this.Ks),this.Rs=!0)}zs(){var e;D&&A&&(this.Ws&&D.removeEventListener(Pr,this.Ws),this.Zs&&A.removeEventListener(`click`,this.Zs,{capture:!0}),this.Gs&&A.removeEventListener(`mousemove`,this.Gs,{capture:!0}),this.Ks&&A.removeEventListener(Nr,this.Ks),clearTimeout(this.Ys),(e=this.Js)==null||e.stop(),this.Rs=!1)}Xs(e,t){var n=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),i=this.instance.scrollManager.scrollElement(),a=function(e,t,n){for(var r=e;r&&zo(r)&&!Bo(r,`body`);){if(r===n)return!1;if(P(t,D?.getComputedStyle(r).position))return!0;r=Zo(r)}return!1}(Jo(e),[`fixed`,`sticky`],i);return{x:e.clientX+(a?0:r),y:e.clientY+(a?0:n),target_fixed:a,type:t}}Mt(e,t){var n;if(t===void 0&&(t=`click`),!Ro(e.target)&&Ps(e)){var r=this.Xs(e,t);(n=this.rageclicks)!=null&&n.isRageClick(e.clientX,e.clientY,new Date().getTime())&&this.eo(N({},r,{type:`rageclick`})),this.eo(r)}}Qs(e){!Ro(e.target)&&Ps(e)&&(clearTimeout(this.Ys),this.Ys=setTimeout((()=>{this.eo(this.Xs(e,`mousemove`))}),500))}eo(e){if(D){var t=D.location.href,n=this.qt.custom_personal_data_properties,r=Di(t,this.qt.mask_personal_data_properties?[...Ai,...n||[]]:[],Mi);this.M=this.M||{},this.M[r]||(this.M[r]=[]),this.M[r].push(e)}}Zr(){this.M&&!ke(this.M)&&this.instance.capture(`$$heatmap`,{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:_i,webVitalsAutocapture:class{constructor(e){var t;this.Hs=!1,this.Rs=!1,this.M={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.ro=()=>{clearTimeout(this.io),this.M.metrics.length!==0&&(this._instance.capture(`$web_vitals`,this.M.metrics.reduce(((e,t)=>N({},e,{[`$web_vitals_`+t.name+`_event`]:N({},t),[`$web_vitals_`+t.name+`_value`]:t.value})),{})),this.M={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.ht=e=>{this.M=this.M||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var t=this.no();if(!I(t))if(L(e?.name)||L(e?.value))Ts.error(`Invalid metric received`,e);else if(!this.so||this.so>e.value){this.M.url!==t&&(this.ro(),this.io=setTimeout(this.ro,this.flushToCaptureTimeoutMs)),I(this.M.url)&&(this.M.url=t),this.M.firstMetricTimestamp=I(this.M.firstMetricTimestamp)?Date.now():this.M.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0);var n=this._instance.sessionManager?.checkAndGetSessionAndWindowId(!0),r=N({},e,{$current_url:t,timestamp:Date.now()});I(n)||(r.$session_id=n.sessionId,r.$window_id=n.windowId),this.M.metrics.push(r),this.M.metrics.length===this.allowedMetrics.length&&this.ro()}else Ts.error(`Ignoring metric with value >= `+this.so,e)},this.oo=()=>{if(!this.Rs){var e,t,n,r,i=M.__PosthogExtensions__;I(i)||I(i.postHogWebVitalsCallbacks)||({onLCP:e,onCLS:t,onFCP:n,onINP:r}=i.postHogWebVitalsCallbacks),e&&t&&n&&r?(this.allowedMetrics.indexOf(`LCP`)>-1&&e(this.ht.bind(this)),this.allowedMetrics.indexOf(`CLS`)>-1&&t(this.ht.bind(this)),this.allowedMetrics.indexOf(`FCP`)>-1&&n(this.ht.bind(this)),this.allowedMetrics.indexOf(`INP`)>-1&&r(this.ht.bind(this)),this.Rs=!0):Ts.error(`web vitals callbacks not loaded - not starting`)}},this._instance=e,this.Hs=!((t=this._instance.persistence)==null||!t.props[Vn]),this.startIfEnabled()}get ao(){return this._instance.config.capture_performance}get allowedMetrics(){var e=Oe(this.ao)?this.ao?.web_vitals_allowed_metrics:void 0;return L(e)?this._instance.persistence?.props[Wn]||[`CLS`,`FCP`,`INP`,`LCP`]:e}get flushToCaptureTimeoutMs(){return(Oe(this.ao)?this.ao.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=Oe(this.ao)?this.ao.web_vitals_attribution:void 0;return e!=null&&e}get so(){var e=Oe(this.ao)&&Ne(this.ao.__web_vitals_max_value)?this.ao.__web_vitals_max_value:Es;return e>0&&6e4>=e?Es:e}get isEnabled(){var e=j?.protocol;if(e!==`http:`&&e!==`https:`)return Ts.info(`Web Vitals are disabled on non-http/https protocols`),!1;var t=Oe(this.ao)?this.ao.web_vitals:Fe(this.ao)?this.ao:void 0;return Fe(t)?t:this.Hs}startIfEnabled(){this.isEnabled&&!this.Rs&&(Ts.info(`enabled, starting...`),this.lr(this.oo))}onRemoteConfig(e){if(`capturePerformance`in e){var t=Oe(e.capturePerformance)&&!!e.capturePerformance.web_vitals,n=Oe(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Vn]:t}),this._instance.persistence.register({[Wn]:n})),this.Hs=t,this.startIfEnabled()}}lr(e){var t,n;(t=M.__PosthogExtensions__)!=null&&t.postHogWebVitalsCallbacks?e():(n=M.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,this.useAttribution?`web-vitals-with-attribution`:`web-vitals`,(t=>{t?Ts.error(`failed to load script`,t):e()}))}no(){var e=D?D.location.href:void 0;if(e){var t=this._instance.config.custom_personal_data_properties;return Di(e,this._instance.config.mask_personal_data_properties?[...Ai,...t||[]]:[],Mi)}Ts.error(`Could not determine current URL`)}}},cc={exceptionObserver:class{constructor(e){var t;this.oo=()=>{var e;if(D&&this.isEnabled&&(e=M.__PosthogExtensions__)!=null&&e.errorWrappingFunctions){var t=M.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,n=M.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=M.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.uo&&this.qt.capture_unhandled_errors&&(this.uo=t(this.captureException.bind(this))),!this.lo&&this.qt.capture_unhandled_rejections&&(this.lo=n(this.captureException.bind(this))),!this.ho&&this.qt.capture_console_errors&&(this.ho=r(this.captureException.bind(this)))}catch(e){Ss.error(`failed to start`,e),this.co()}}},this._instance=e,this.do=!((t=this._instance.persistence)==null||!t.props[Rn]),this.vo=new Ge({refillRate:this._instance.config.error_tracking.__exceptionRateLimiterRefillRate??1,bucketSize:this._instance.config.error_tracking.__exceptionRateLimiterBucketSize??10,refillInterval:1e4,Gt:Ss}),this.qt=this.fo(),this.startIfEnabledOrStop()}fo(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return Oe(e)?t=N({},t,e):(I(e)?this.do:e)&&(t=N({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.qt.capture_console_errors||this.qt.capture_unhandled_errors||this.qt.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Ss.info(`enabled`),this.co(),this.lr(this.oo)):this.co()}lr(e){var t,n;(t=M.__PosthogExtensions__)!=null&&t.errorWrappingFunctions&&e(),(n=M.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`exception-autocapture`,(t=>{if(t)return Ss.error(`failed to load script`,t);e()}))}co(){var e,t,n;(e=this.uo)==null||e.call(this),this.uo=void 0,(t=this.lo)==null||t.call(this),this.lo=void 0,(n=this.ho)==null||n.call(this),this.ho=void 0}onRemoteConfig(e){`autocaptureExceptions`in e&&(this.do=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Rn]:this.do}),this.qt=this.fo(),this.startIfEnabledOrStop())}onConfigChange(){this.qt=this.fo()}captureException(e){var t,n,r=(e==null||(t=e.$exception_list)==null||(t=t[0])==null?void 0:t.type)??`Exception`;this.vo.consumeRateLimit(r)?Ss.info(`Skipping exception capture because of client rate limiting.`,{exception:r}):(n=this._instance.exceptions)==null||n.sendExceptionEvent(e)}},exceptions:class{constructor(e){this.po=[],this.mo=new Zt([new un,new bn,new fn,new dn,new vn,new _n,new mn,new yn],function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];return function(t,r){r===void 0&&(r=0);for(var i=[],a=t.split(`
|
|
2
|
-
`),o=r;a.length>o;o++){var s=a[o];if(1024>=s.length){var c=ln.test(s)?s.replace(ln,`$1`):s;if(!c.match(/\S*Error: /)){for(var l of n){var u=l(c,e);if(u){i.push(u);break}}if(i.length>=50)break}}}return function(e){if(!e.length)return[];var t=Array.from(e);return t.reverse(),t.slice(0,50).map((e=>{return N({},e,{filename:e.filename||(n=t,n[n.length-1]||{}).filename,function:e.function||Qt});var n}))}(i)}}(`web:javascript`,an,cn)),this._instance=e,this.po=this._instance.persistence?.get_property(zn)??[],this.yo=Tn(this.bo()),this._o=new En(this.yo)}onConfigChange(){this.yo=Tn(this.bo()),this._o.setConfig(this.yo)}onRemoteConfig(e){if(`errorTracking`in e){var t=e.errorTracking?.suppressionRules??[],n=e.errorTracking?.captureExtensionExceptions;this.po=t,this._instance.persistence&&this._instance.persistence.register({[zn]:this.po,[Bn]:n})}}get wo(){var e,t=!!this._instance.get_property(Bn);return(e=this._instance.config.error_tracking.captureExtensionExceptions??t)!=null&&e}buildProperties(e,t){return this.mo.buildFromUnknown(e,{syntheticException:t?.syntheticException,mechanism:{handled:t?.handled}})}addExceptionStep(e,t){if(this.yo.enabled)try{if(!Ae(e)||e.trim().length===0)return void $s.warn(`Ignoring exception step because message must be a non-empty string`);var{sanitizedProperties:n,droppedKeys:r}=function(e){if(!e)return{sanitizedProperties:{},droppedKeys:[]};var t=[];return{sanitizedProperties:Object.keys(e).reduce(((n,r)=>Cn.has(r)?(t.push(r),n):(n[r]=e[r],n)),{}),droppedKeys:t}}(this.xo(t));r.length>0&&$s.warn(`Ignoring reserved exception step fields`,{droppedKeys:r}),this._o.add(N({[xn]:e,[Sn]:new Date().toISOString()},n))}catch(e){$s.error(`Failed to add exception step. Ignoring breadcrumb.`,e)}}sendExceptionEvent(e){try{var t=e.$exception_list;if(this.So(t)){if(this.ko(t))return this.Co(`Exception dropped: matched a suppression rule`),void $s.info(`Skipping exception capture because a suppression rule matched`);if(!this.wo&&this.Io(t))return this.Co(`Exception dropped: thrown by a browser extension`),void $s.info(`Skipping exception capture because it was thrown by an extension`);if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.To(t))return this.Co(`Exception dropped: thrown by the PostHog SDK`),void $s.info(`Skipping exception capture because it was thrown by the PostHog SDK`)}var n=this.yo.enabled&&L(e.$exception_steps)?this.Eo(e):e;try{var r=this._instance.capture(`$exception`,n,{_noTruncate:!0,_batchKey:`exceptionEvent`,en:!0});return r&&this._o.clear(),r}catch(e){$s.error(`Failed to capture exception event. Dropping this exception.`,e),this._o.clear();return}}catch(e){$s.error(`Failed to process exception event. Ignoring this exception.`,e);return}}Eo(e){try{var t=this._o.getAttachable();return t.length===0?e:N({},e,{$exception_steps:t})}catch(t){return $s.error(`Failed to read buffered exception steps. Capturing exception without steps.`,t),e}}Co(e){this.yo.enabled&&this._o.add({[xn]:e,[Sn]:new Date().toISOString()})}xo(e){return Oe(e)?N({},e):{}}bo(){return this._instance.config.error_tracking?.exception_steps??{}}ko(e){if(e.length===0)return!1;var t=e.reduce(((e,t)=>{var{type:n,value:r}=t;return Ae(n)&&n.length>0&&e.$exception_types.push(n),Ae(r)&&r.length>0&&e.$exception_values.push(r),e}),{$exception_types:[],$exception_values:[]});return this.po.some((e=>{var n=e.values.map((e=>{var n=oo[e.operator],r=F(e.value)?e.value:[e.value],i=t[e.key]??[];return r.length>0&&n(r,i)}));return e.type===`OR`?n.some(Boolean):n.every(Boolean)}))}Io(e){return e.flatMap((e=>e.stacktrace?.frames??[])).some((e=>e.filename&&e.filename.startsWith(`chrome-extension://`)))}To(e){if(e.length>0){var t,n,r=e[0].stacktrace?.frames??[],i=r[r.length-1];return(t=i==null||(n=i.filename)==null?void 0:n.includes(`posthog.com/static`))!=null&&t}return!1}So(e){return!L(e)&&F(e)}}},lc=N({productTours:class{get ni(){return this._instance.persistence}constructor(e){this.Mo=null,this.Po=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){`productTours`in e&&(this.ni&&this.ni.register({[Un]:!!e.productTours}),this.loadIfEnabled())}loadIfEnabled(){var e,t;this.Mo||(e=this._instance).config.disable_product_tours||(t=e.persistence)==null||!t.get_property(Un)||this.lr((()=>this.Ro()))}lr(e){var t,n;(t=M.__PosthogExtensions__)!=null&&t.generateProductTours?e():(n=M.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`product-tours`,(t=>{t?Fs.error(`Could not load product tours script`,t):e()}))}Ro(){var e;!this.Mo&&(e=M.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.Mo=M.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(t===void 0&&(t=!1),!F(this.Po)||t){var n=this.ni;if(n){var r=n.props[ur];if(F(r)&&!t)return this.Po=r,void e(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/product_tours/?token=`+this._instance.config.token),method:`GET`,callback:t=>{var r=t.statusCode;if(r!==200||!t.json){var i=`Product Tours API could not be loaded, status: `+r;Fs.error(i),e([],{isLoaded:!1,error:i});return}var a=F(t.json.product_tours)?t.json.product_tours:[];this.Po=a,n&&n.register({[ur]:a}),e(a,{isLoaded:!0})}})}else e(this.Po,{isLoaded:!0})}getActiveProductTours(e){L(this.Mo)?e([],{isLoaded:!1,error:`Product tours not loaded`}):this.Mo.getActiveProductTours(e)}showProductTour(e){var t;(t=this.Mo)==null||t.showTourById(e)}previewTour(e){this.Mo?this.Mo.previewTour(e):this.lr((()=>{var t;this.Ro(),(t=this.Mo)==null||t.previewTour(e)}))}dismissProductTour(){var e;(e=this.Mo)==null||e.dismissTour(`user_clicked_skip`)}nextStep(){var e;(e=this.Mo)==null||e.nextStep()}previousStep(){var e;(e=this.Mo)==null||e.previousStep()}clearCache(){var e;this.Po=null,(e=this.ni)==null||e.unregister(ur)}resetTour(e){var t;(t=this.Mo)==null||t.resetTour(e)}resetAllTours(){var e;(e=this.Mo)==null||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.Mo)==null||t.cancelPendingTour(e)}}},ac),uc={siteApps:class{constructor(e){this._instance=e,this.Oo=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Lo(e,t){if(t){var n=this.globalsForEvent(t);this.Oo.push(n),this.Oo.length>1e3&&(this.Oo=this.Oo.slice(10))}}get siteAppLoaders(){var e;return(e=M._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}initialize(){if(this.isEnabled){var e=this._instance._addCaptureHook(this.Lo.bind(this));this.Fo=()=>{e(),this.Oo=[],this.Fo=void 0}}}globalsForEvent(e){if(!e)throw Error(`Event payload is required`);var t={},n=this._instance.get_property(`$groups`)||[],r=this._instance.get_property(`$stored_group_properties`)||{};for(var[i,a]of Object.entries(r))t[i]={id:n[i],type:i,properties:a};var{$set_once:o,$set:s}=e;return{event:N({},ue(e,Is),{properties:N({},e.properties,s?{$set:N({},e.properties?.$set??{},s)}:{},o?{$set_once:N({},e.properties?.$set_once??{},o)}:{}),elements_chain:e.properties?.$elements_chain??``,distinct_id:e.properties?.distinct_id}),person:{properties:this._instance.get_property(`$stored_person_properties`)},groups:t}}setupSiteApp(e){var t=this.apps[e.id],n=()=>{var n;!t.errored&&this.Oo.length&&(Ls.info(`Processing `+this.Oo.length+` events for site app with id `+e.id),this.Oo.forEach((e=>t.processEvent==null?void 0:t.processEvent(e))),t.processedBuffer=!0),Object.values(this.apps).every((e=>e.processedBuffer||e.errored))&&((n=this.Fo)==null||n.call(this))},r=!1,i=i=>{t.errored=!i,t.loaded=!0,Ls.info(`Site app with id `+e.id+` `+(i?`loaded`:`errored`)),r&&n()};try{var{processEvent:a}=e.init({posthog:this._instance,callback(e){i(e)}});a&&(t.processEvent=a),r=!0}catch(t){Ls.error(Rs+e.id,t),i(!1)}if(r&&t.loaded)try{n()}catch(n){Ls.error(`Error while processing buffered events PostHog app with config id `+e.id,n),t.errored=!0}}Ao(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var n of e)this.setupSiteApp(n)}No(e){if(Object.keys(this.apps).length!==0){var t=this.globalsForEvent(e);for(var n of Object.values(this.apps))try{n.processEvent==null||n.processEvent(t)}catch(t){Ls.error(`Error while processing event `+e.event+` for site app `+n.id,t)}}}onRemoteConfig(e){var t,n,r,i=this;if((t=this.siteAppLoaders)!=null&&t.length)return this.isEnabled?(this.Ao(),void this._instance.on(`eventCaptured`,(e=>this.No(e)))):void Ls.error(`PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.`);if((n=this.Fo)==null||n.call(this),(r=e.siteApps)!=null&&r.length)if(this.isEnabled){var a=function(e){var t;M[`__$$ph_site_app_`+e]=i._instance,(t=M.__PosthogExtensions__)==null||t.loadSiteApp==null||t.loadSiteApp(i._instance,s,(t=>{if(t)return Ls.error(Rs+e,t)}))};for(var{id:o,url:s}of e.siteApps)a(o)}else Ls.error(`PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.`)}}},dc={tracingHeaders:class{constructor(e){this.$o=void 0,this.Do=void 0,this.oo=()=>{var e,t,n=this.qo()||[];I(this.$o)&&((e=M.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null||e._patchXHR(n,this._instance.get_distinct_id(),this._instance.sessionManager)),I(this.Do)&&((t=M.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null||t._patchFetch(n,this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=e}initialize(){this.startIfEnabledOrStop()}lr(e){var t,n;(t=M.__PosthogExtensions__)!=null&&t.tracingHeadersPatchFns&&e(),(n=M.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`tracing-headers`,(t=>{if(t)return ws.error(`failed to load script`,t);e()}))}qo(){return this._instance.config.addTracingHeaders??this._instance.config.__add_tracing_headers}startIfEnabledOrStop(){var e,t;this.qo()?this.lr(this.oo):((e=this.$o)==null||e.call(this),(t=this.Do)==null||t.call(this),this.$o=void 0,this.Do=void 0)}}},fc=N({surveys:class{get qt(){return this._instance.config}constructor(e){this.jo=void 0,this._surveyManager=null,this.Ho=!1,this.Uo=[],this.Bo=null,this._instance=e,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this.qt.disable_surveys){var t=e.surveys;if(L(t))return z.warn(`Flags not loaded yet. Not loading surveys.`);var n=F(t);this.jo=n?t.length>0:t,z.info(`flags response received, isSurveysEnabled: `+this.jo),this.loadIfEnabled()}}reset(){localStorage.removeItem(`lastSeenSurveyDate`);for(var e=[],t=0;t<localStorage.length;t++){var n=localStorage.key(t);(n!=null&&n.startsWith(mo)||n!=null&&n.startsWith(`inProgressSurvey_`))&&e.push(n)}e.forEach((e=>localStorage.removeItem(e)))}loadIfEnabled(){if(!this._surveyManager)if(this.Ho)z.info(`Already initializing surveys, skipping...`);else if(this.qt.disable_surveys)z.info(Ws);else if(this.qt.cookieless_mode&&this._instance.consent.isOptedOut())z.info(`Not loading surveys in cookieless mode without consent.`);else{var e=M?.__PosthogExtensions__;if(e){if(!I(this.jo)||this.qt.advanced_enable_surveys){var t=this.jo||this.qt.advanced_enable_surveys;this.Ho=!0;try{var n=e.generateSurveys;if(n)return void this.zo(n,t);var r=e.loadExternalDependency;if(!r)return void this.Vo(Dr);r(this._instance,`surveys`,(n=>{n||!e.generateSurveys?this.Vo(`Could not load surveys script`,n):this.zo(e.generateSurveys,t)}))}catch(e){throw this.Vo(`Error initializing surveys`,e),e}finally{this.Ho=!1}}}else z.error(`PostHog Extensions not found.`)}}zo(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new Hs(this._instance),z.info(`Surveys loaded successfully`),this.Wo({isLoaded:!0})}Vo(e,t){z.error(e,t),this.Wo({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.Uo.push(e),this._surveyManager&&this.Wo({isLoaded:!0}),()=>{this.Uo=this.Uo.filter((t=>t!==e))}}getSurveys(e,t){if(t===void 0&&(t=!1),this.qt.disable_surveys)return z.info(Ws),e([]);var n,r=this._instance.get_property(cr);if(r&&!t)return e(r,{isLoaded:!0});typeof Promise<`u`&&this.Bo?this.Bo.then((t=>{var{surveys:n,context:r}=t;return e(n,r)})):(typeof Promise<`u`&&(this.Bo=new Promise((e=>{n=e}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/surveys/?token=`+this.qt.token),method:`GET`,timeout:this.qt.surveys_request_timeout_ms,callback:t=>{var r;this.Bo=null;var i=t.statusCode;if(i!==200||!t.json){var a=`Surveys API could not be loaded, status: `+i;z.error(a);var o={isLoaded:!1,error:a};e([],o),n?.({surveys:[],context:o});return}var s,c=t.json.surveys||[],l=c.filter((e=>function(e){return!(!e.start_date||e.end_date)}(e)&&(function(e){var t;return!((t=e.conditions)==null||(t=t.events)==null||(t=t.values)==null||!t.length)}(e)||function(e){var t;return!((t=e.conditions)==null||(t=t.actions)==null||(t=t.values)==null||!t.length)}(e))));l.length>0&&((s=this._surveyEventReceiver)==null||s.register(l)),(r=this._instance.persistence)==null||r.register({[cr]:c});var u={isLoaded:!0};e(c,u),n?.({surveys:c,context:u})}}))}Wo(e){for(var t of this.Uo)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){z.error(`Error in survey callback`,e)}}getActiveMatchingSurveys(e,t){if(t===void 0&&(t=!1),!L(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);z.warn(`init was not called`)}Zo(e){var t=null;return this.getSurveys((n=>{t=n.find((t=>t.id===e))??null})),t}Go(e){if(L(this._surveyManager))return{eligible:!1,reason:Us};var t=typeof e==`string`?this.Zo(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:`Survey not found`}}canRenderSurvey(e){if(L(this._surveyManager))return z.warn(`init was not called`),{visible:!1,disabledReason:Us};var t=this.Go(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return L(this._surveyManager)?(z.warn(`init was not called`),Promise.resolve({visible:!1,disabledReason:Us})):new Promise((n=>{this.getSurveys((t=>{var r=t.find((t=>t.id===e))??null;if(r){var i=this.Go(r);n({visible:i.eligible,disabledReason:i.reason})}else n({visible:!1,disabledReason:`Survey not found`})}),t)}))}renderSurvey(e,t,n){var r;if(L(this._surveyManager))z.warn(`init was not called`);else{var i=typeof e==`string`?this.Zo(e):e;if(i!=null&&i.id)if(ho.includes(i.type)){var a=A?.querySelector(t);if(a)return(r=i.appearance)!=null&&r.surveyPopupDelaySeconds?(z.info(`Rendering survey `+i.id+` with delay of `+i.appearance.surveyPopupDelaySeconds+` seconds`),void setTimeout((()=>{var e;z.info(`Rendering survey `+i.id+` with delay of `+i.appearance?.surveyPopupDelaySeconds+` seconds`),(e=this._surveyManager)==null||e.renderSurvey(i,a,n),z.info(`Survey `+i.id+` rendered`)}),1e3*i.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(i,a,n);z.warn(`Survey element not found`)}else z.warn(`Surveys of type `+i.type+` cannot be rendered in the app`);else z.warn(`Survey not found`)}}displaySurvey(e,t){var n;if(L(this._surveyManager))z.warn(`init was not called`);else{var r=this.Zo(e);if(r){var i=r;if((n=r.appearance)!=null&&n.surveyPopupDelaySeconds&&t.ignoreDelay&&(i=N({},r,{appearance:N({},r.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==Xi.Popover&&t.initialResponses&&z.warn(`initialResponses is only supported for popover surveys. prefill will not be applied.`),!1===t.ignoreConditions){var a=this.canRenderSurvey(r);if(!a.visible)return void z.warn(`Survey is not eligible to be displayed: `,a.disabledReason)}t.displayType===Xi.Inline?this.renderSurvey(i,t.selector,t.properties):this._surveyManager.handlePopoverSurvey(i,t)}else z.warn(`Survey not found`)}}cancelPendingSurvey(e){L(this._surveyManager)?z.warn(`init was not called`):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;(e=this._surveyManager)==null||e.handlePageUnload()}}},ac),pc={toolbar:class{constructor(e){this.instance=e}Qo(e){M.ph_toolbar_state=e}Jo(){return M.ph_toolbar_state??0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e,t,n){if(e===void 0&&(e=void 0),t===void 0&&(t=void 0),n===void 0&&(n=void 0),Yr(this.instance.config)||!D||!A)return!1;e??=D.location,n??=D.history;try{if(!t){try{D.localStorage.setItem(`test`,`test`),D.localStorage.removeItem(`test`)}catch{return!1}t=D?.localStorage}var r,i=Gs||Oi(e.hash,`__posthog`)||Oi(e.hash,`state`),a=i?Ur((()=>JSON.parse(atob(decodeURIComponent(i)))))||Ur((()=>JSON.parse(decodeURIComponent(i)))):null;return a&&a.action===`ph_authorize`?((r=a).source=`url`,r&&Object.keys(r).length>0&&(a.desiredHash?e.hash=a.desiredHash:n?n.replaceState(n.state,``,e.pathname+e.search):e.hash=``)):((r=JSON.parse(t.getItem(Ks)||`{}`)).source=`localstorage`,delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch{return!1}}Ko(e){var t=M.ph_load_toolbar||M.ph_load_editor;!L(t)&&De(t)?t(e,this.instance):qs.warn(`No toolbar load function found`)}loadToolbar(e){var t=!(A==null||!A.getElementById(Sr));if(!D||t)return!1;var n=this.instance.requestRouter.region===`custom`&&this.instance.config.advanced_disable_toolbar_metrics,r=N({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor(`ui`)},n?{instrument:!1}:{});if(D.localStorage.setItem(Ks,JSON.stringify(N({},r,{source:void 0}))),this.Jo()===2)this.Ko(r);else if(this.Jo()===0){var i;this.Qo(1),(i=M.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this.instance,`toolbar`,(e=>{if(e)return qs.error(`[Toolbar] Failed to load`,e),void this.Qo(0);this.Qo(2),this.Ko(r)})),Jr(D,`turbolinks:load`,(()=>{this.Qo(0),this.loadToolbar(r)}))}return!0}Yo(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,n){return e===void 0&&(e=void 0),t===void 0&&(t=void 0),n===void 0&&(n=void 0),this.maybeLoadToolbar(e,t,n)}}},mc=N({experiments:nc},ac),hc=N({},ac,oc,sc,cc,lc,uc,fc,dc,pc,mc,{conversations:class{constructor(e){this.Xo=void 0,this._conversationsManager=null,this.ea=!1,this.ta=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this._instance.config.disable_conversations){var t=e.conversations;L(t)||(Fe(t)?this.Xo=t:(this.Xo=t.enabled,this.ta=t),this.loadIfEnabled())}}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.Xo=void 0,this.ta=null}loadIfEnabled(){if(!(this._conversationsManager||this.ea||this._instance.config.disable_conversations||Yr(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=M?.__PosthogExtensions__;if(e&&!I(this.Xo)&&this.Xo)if(this.ta&&this.ta.token){this.ea=!0;try{var t=e.initConversations;if(t)return this.ra(t),void(this.ea=!1);var n=e.loadExternalDependency;if(!n)return void this.ia(Dr);n(this._instance,`conversations`,(t=>{t||!e.initConversations?this.ia(`Could not load conversations script`,t):this.ra(e.initConversations),this.ea=!1}))}catch(e){this.ia(`Error initializing conversations`,e),this.ea=!1}}else rc.error(`Conversations enabled but missing token in remote config.`)}}ra(e){if(this.ta)try{this._conversationsManager=e(this.ta,this._instance),rc.info(`Conversations loaded successfully`)}catch(e){this.ia(`Error completing conversations initialization`,e)}else rc.error(`Cannot complete initialization: remote config is null`)}ia(e,t){rc.error(e,t),this._conversationsManager=null,this.ea=!1}show(){this._conversationsManager?this._conversationsManager.show():rc.warn(`Conversations not loaded yet.`)}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.Xo&&!Me(this._conversationsManager)}isVisible(){var e;return(e=this._conversationsManager?.isVisible())!=null&&e}sendMessage(e,t,n){var r=this;return le((function*(){return r._conversationsManager?r._conversationsManager.sendMessage(e,t,n):(rc.warn(ic),null)}))()}getMessages(e,t){var n=this;return le((function*(){return n._conversationsManager?n._conversationsManager.getMessages(e,t):(rc.warn(ic),null)}))()}markAsRead(e){var t=this;return le((function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(rc.warn(ic),null)}))()}getTickets(e){var t=this;return le((function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(rc.warn(ic),null)}))()}requestRestoreLink(e){var t=this;return le((function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(rc.warn(ic),null)}))()}restoreFromToken(e){var t=this;return le((function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(rc.warn(ic),null)}))()}restoreFromUrlToken(){var e=this;return le((function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(rc.warn(ic),null)}))()}getCurrentTicketId(){return this._conversationsManager?.getCurrentTicketId()??null}getWidgetSessionId(){return this._conversationsManager?.getWidgetSessionId()??null}ln(){var e;(e=this._conversationsManager)==null||e.setIdentity()}hn(){var e;(e=this._conversationsManager)==null||e.clearIdentity()}}},{logs:class{constructor(e){var t;this.na=!1,this.sa=!1,this.Gt=kn(`[logs]`),this.oa=[],this.aa=0,this.ua=0,this.la=!1,this._instance=e,this._instance&&(t=this._instance.config.logs)!=null&&t.captureConsoleLogs&&(this.na=!0)}initialize(){this.loadIfEnabled()}onRemoteConfig(e){var t=e.logs?.captureConsoleLogs;!L(t)&&t&&(this.na=!0,this.loadIfEnabled())}reset(){this.oa=[],this.qr&&=(clearTimeout(this.qr),void 0),this.aa=0,this.ua=0,this.la=!1}loadIfEnabled(){if(this.na&&!this.sa){var e=M?.__PosthogExtensions__;if(e){var t=e.loadExternalDependency;t?t(this._instance,`logs`,(t=>{var n;t||(n=e.logs)==null||!n.initializeLogs?this.Gt.error(`Could not load logs script`,t):(e.logs.initializeLogs(this._instance),this.sa=!0)})):this.Gt.error(Dr)}else this.Gt.error(`PostHog Extensions not found.`)}}captureLog(e){if(this._instance.is_capturing())if(e&&e.body){var t=this._instance.config.logs?.flushIntervalMs??3e3,n=this._instance.config.logs?.maxLogsPerInterval??1e3,r=Date.now();if(t>r-this.ua||(this.ua=r,this.aa=0,this.la=!1),n>this.aa){this.aa++;var i=function(e,t){var{text:n,number:r}=Kt[e.level||`info`]||qt,i=String(Date.now())+`000000`,a={};t.distinctId&&(a.posthogDistinctId=t.distinctId),t.sessionId&&(a.sessionId=t.sessionId),t.currentUrl&&(a[`url.full`]=t.currentUrl),t.screenName&&(a[`screen.name`]=t.screenName),t.appState&&(a[`app.state`]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(a.feature_flags=t.activeFeatureFlags);var o=N({},a,e.attributes||{}),s={timeUnixNano:i,observedTimeUnixNano:i,severityNumber:r,severityText:n,body:{stringValue:e.body},attributes:Yt(o)};return e.trace_id&&(s.traceId=e.trace_id),e.span_id&&(s.spanId=e.span_id),I(e.trace_flags)||(s.flags=e.trace_flags),s}(e,this.ha());this.oa.push({record:i}),(this._instance.config.logs?.maxBufferSize??100)>this.oa.length?this.ca():this.flushLogs()}else this.la||=(this.Gt.warn(`captureLog dropping logs: exceeded `+n+` logs per `+t+`ms`),!0)}else this.Gt.warn(`captureLog requires a body`)}get logger(){return this.da||={trace:(e,t)=>this.captureLog({body:e,level:`trace`,attributes:t}),debug:(e,t)=>this.captureLog({body:e,level:`debug`,attributes:t}),info:(e,t)=>this.captureLog({body:e,level:`info`,attributes:t}),warn:(e,t)=>this.captureLog({body:e,level:`warn`,attributes:t}),error:(e,t)=>this.captureLog({body:e,level:`error`,attributes:t}),fatal:(e,t)=>this.captureLog({body:e,level:`fatal`,attributes:t})},this.da}flushLogs(e){if(this.qr&&=(clearTimeout(this.qr),void 0),this.oa.length!==0){var t=this.oa;this.oa=[];var n=this._instance.config.logs,r=N({"service.name":n?.serviceName||`unknown_service`},n?.environment&&{"deployment.environment":n.environment},n?.serviceVersion&&{"service.version":n.serviceVersion},n?.resourceAttributes),i=function(e,t,n,r){return{resourceLogs:[{resource:{attributes:Yt(t)},scopeLogs:[{scope:{name:n,version:r},logRecords:e}]}]}}(t.map((e=>e.record)),r,se.LIB_NAME,se.LIB_VERSION),a=this._instance.requestRouter.endpointFor(`api`,`/i/v1/logs`)+`?token=`+encodeURIComponent(this._instance.config.token);this._instance.Bi({method:`POST`,url:a,data:i,compression:`best-available`,batchKey:`logs`,transport:e})}}ca(){this.qr||=setTimeout((()=>{this.qr=void 0,this.flushLogs()}),this._instance.config.logs?.flushIntervalMs??3e3)}ha(){var e,t={};if(t.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var{sessionId:n}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);t.sessionId=n}if(M!=null&&(e=M.location)!=null&&e.href&&(t.currentUrl=M.location.href),this._instance.featureFlags){var r=this._instance.featureFlags.getFlags();r&&r.length>0&&(t.activeFeatureFlags=r)}return t}}});Po.__defaultExtensionClasses=N({},hc);var gc,_c=(gc=xo[Oo]=new Po,function(){function e(){e.done||(e.done=!0,ko=!1,Br(xo,(function(e){e._dom_loaded()})))}A!=null&&A.addEventListener?A.readyState===`complete`?e():Jr(A,`DOMContentLoaded`,e,{capture:!1}):D&&R.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),gc),vc=({client:e})=>{let[t,n]=b(!1),[r,i]=b({x:0,y:0}),[a,o]=b(0),s=m(null),c=window.innerWidth<768,l=e.plugin.getUserInfo().context_menu_on_select,u=e.plugin.getPluginInfo().installedPlugins.flatMap(e=>e.context_menu_actions).filter(Boolean),d=(e,t=0)=>{let n=window.getSelection();if(!n||!e)return{x:0,y:0,text:e};let r=n.getRangeAt(0).getBoundingClientRect();return{x:r.left+r.width/2-t/2,y:r.bottom+12,text:e}};return g(()=>{e.event.on(`global.contextMenu.createActions`,({data:e})=>{u.push(...e.actions)})},[]),g(()=>{t&&s.current&&o(s.current.offsetWidth)},[t]),g(()=>{let e=e=>{let n=window.getSelection()?.toString().trim();t&&n===r.text||i(c&&n?d(n,a):{x:e.clientX,y:e.clientY,text:n})},o=e=>{var r;let o=window.getSelection()?.toString().trim();if(s.current&&s.current.contains(e.target))return;let u=e.target;if(u&&(u.tagName===`TEXTAREA`||u.tagName===`INPUT`&&u.type===`text`)){n(!1);return}e.button===0&&t?(n(!1),(r=window.getSelection())==null||r.removeAllRanges()):o&&(l||e.button===2)?(e.button===2&&e.preventDefault(),i(c?d(o,a):{x:e.clientX,y:e.clientY,text:o}),n(!0)):n(!1)},u=()=>{let e=window.getSelection()?.toString().trim();!e&&t?n(!1):e&&t&&c&&i(d(e,a))};return document.addEventListener(`mouseup`,o),window.addEventListener(`mousemove`,e),document.addEventListener(`contextmenu`,o),document.addEventListener(`selectionchange`,u),()=>{document.removeEventListener(`mouseup`,o),window.removeEventListener(`mousemove`,e),document.removeEventListener(`contextmenu`,o),document.removeEventListener(`selectionchange`,u)}},[l,t,r.text]),t?w(`div`,{ref:s,className:`fixed bg-gray-400 dark:bg-gray-700 shadow-lg border border-gray-400 rounded-md overflow-hidden dark:text-white z-50`,style:{top:r.y,left:r.x},children:u.map((t,i)=>w(yc,{iconUrl:t.iconUrl,text:t.text,onClick:()=>{var i;n(!1),(i=window.getSelection())==null||i.removeAllRanges(),e.event.emitSidebarAction(t.plugin_id,t.action_key,r.text)}},i))}):null};function yc(e){return T(`button`,{onClick:e.onClick,className:`px-2 md:px-4 py-2 text-left hover:bg-gray-500 dark:hover:bg-gray-600 w-full flex flex-row`,children:[e.iconUrl&&w(`span`,{className:`flex-grow`,children:w(`img`,{src:e.iconUrl,alt:e.text,className:`w-4 h-4 mr-2`})}),w(`span`,{className:`flex-grow`,children:e.text})]})}function bc(e=`system`,t=!1){let n=e===`system`?xc():e===`dark`;if(t)return{isDark:n,theme:e,isDisabled:t};let r=document.documentElement;return r.dataset.theme=n?`dark`:`light`,r.style.colorScheme=n?`dark`:`light`,r.classList[n?`add`:`remove`](`dark`),document.querySelector(`#root`).classList.add(`dark:bg-gradient-to-br`,`dark:from-gray-900`,`dark:to-gray-800`,`dark:text-white`,`min-h-screen`,`bg-fixed`),{isDark:n,theme:e,isDisabled:t}}function xc(){return window.matchMedia(`(prefers-color-scheme: dark)`).matches}S();var Sc=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},Cc=_(null),wc=({children:e,pluginId:t,client:n,userInfo:r,settings:i})=>{let o=!!n,[s,l]=b(n??null),[u,d]=b(!1),[f,p]=b(null),[m,h]=b(void 0),[_,v]=b(r??null);g(()=>{o&&(n&&l(n),r&&v(r))},[n,r,o]),bc(m,o),g(()=>{_c.__loaded||_c.init(`phc_l4vPVZxtjlcQUDivoh5TaUL6oDe8K2lig89405cGnsv`,{cookieless_mode:`always`,api_host:`https://c.rimori.se`,defaults:`2026-01-30`,loaded:e=>{e.register({application:`frontend`,pluginId:t})}})},[]);let y=f===`sidebar`,x=f===`settings`;return g(()=>{if(o)return;Dc(t);let e=window===window.parent;e&&!u&&a.getInstance().then(e=>{e.needsLogin().then(t=>d(t?e:!0))}),(!e&&!s||e&&u===!0)&&c.getInstance(t).then(t=>{l(t),v(t.plugin.getUserInfo()),e||(h(t.plugin.theme),p(t.plugin.applicationMode),t.event.emit(`self.rimori.triggerInitFinished`))})},[t,u,s,o]),g(()=>{_?.user_id&&_c.identify(_.user_id)},[_?.user_id]),g(()=>{if(!s)return;let e=s.plugin.onRimoriInfoUpdate(e=>{v(e.profile)});return()=>e()},[s]),g(()=>{if(!s||y||o)return;let e=history.pushState;history.pushState=(...t)=>{let n=e.apply(history,t);return s.event.emit(`session.triggerUrlChange`,{url:location.hash}),n}},[s,y,o]),g(()=>{if(!s||o)return;let e=()=>{let e=document.documentElement.scrollHeight>window.innerHeight;s.event.emit(`session.triggerScrollbarChange`,{hasScrollbar:e})};e(),window.addEventListener(`resize`,e);let t=new ResizeObserver(()=>e());return t.observe(document.body),()=>{window.removeEventListener(`resize`,e),t.disconnect()}},[s,o]),u instanceof a?w(Oc,{onLogin:(e,t)=>Sc(void 0,void 0,void 0,function*(){(yield u.login(e,t))&&d(!0)})}):!s||!_?``:T(Cc.Provider,{value:{client:s,userInfo:_},children:[!i?.disableContextMenu&&!y&&!x&&w(vc,{client:s}),e]})},Tc=()=>{let e=u(Cc);if(e===null)throw Error(`useRimori must be used within an PluginProvider`);return Object.assign(e.client,{userInfo:e.userInfo})};function Ec(e){let t=window.location.hash.split(`?`);if(t.length>1){let n=new URLSearchParams(t[1]).get(e);if(n)return n}return new URL(window.location.href).searchParams.get(e)}function Dc(e){let t=Ec(`applicationMode`)===`sidebar`;r.getInstance(`Plugin EventBus `+e+` `+(t?`sidebar`:`main`))}function Oc({onLogin:e}){let[t,n]=b(``),[r,i]=b(``);return w(`div`,{style:{position:`fixed`,inset:0,display:`flex`,alignItems:`center`,justifyContent:`center`,backgroundColor:`rgba(0, 0, 0, 0.5)`},children:T(`div`,{style:{backgroundColor:`#343534`,padding:`1rem`,borderRadius:`0.5rem`,width:`500px`,flexDirection:`column`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:[w(`p`,{style:{fontSize:`2rem`,fontWeight:`bold`,marginBottom:`1rem`,textAlign:`center`},children:`Rimori Login Required`}),w(`p`,{style:{marginBottom:`1rem`,textAlign:`center`},children:`Please login with your Rimori developer account for this plugin to be able to access the Rimori platform the same way it would when being deployed.`}),w(`input`,{style:{marginBottom:`1rem`,width:`100%`,padding:`0.5rem`,borderRadius:`0.5rem`,border:`none`,backgroundColor:`#444444`},type:`email`,placeholder:`Email`,onChange:e=>n(e.target.value)}),w(`input`,{style:{marginBottom:`1rem`,width:`100%`,padding:`0.5rem`,borderRadius:`0.5rem`,border:`none`,backgroundColor:`#444444`},type:`password`,placeholder:`Password`,onChange:e=>i(e.target.value)}),w(`button`,{style:{marginBottom:`1rem`,width:`100%`,padding:`0.5rem`,borderRadius:`0.5rem`,border:`none`,backgroundColor:`#928358`},onClick:()=>{e(t,r)},children:`Login`})]})})}S();function kc(e,t){let[n,r]=x.useState([]),[i,a]=x.useState(!1),{ai:o}=Tc(),s=x.useRef({prompt:t?.prompt,promptVariables:t?.promptVariables});return{messages:n,append:i=>{let c=[...n,...i];r(c),a(!0);let l=s.current.promptVariables??t?.promptVariables,u=s.current.prompt??t?.prompt;o.getStreamedText({messages:c,onMessage:(e,t,n,i)=>{a(!n),r(n=>{let r=n[n.length-1];return r?.id===e?[...n.slice(0,-1),Object.assign(Object.assign({},r),{content:t,toolCalls:i})]:[...n,{id:e,role:`assistant`,content:t,toolCalls:i}]})},tools:e,prompt:u,variables:l})},init:x.useCallback(e=>{s.current=Object.assign(Object.assign({},s.current),e)},[]),isLoading:i,setMessages:r,lastMessage:n[n.length-1]}}S();var Ac=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function jc(e){let t=Tc(),[n,r]=b(e),[i,a]=b(!0);return g(()=>{let n=!1;return t.plugin.getSettings(e).then(e=>{n||(r(e),a(!1))}),()=>{n=!0}},[]),{settings:n,isLoading:i,setSettings:h(e=>Ac(this,void 0,void 0,function*(){let i=Object.assign(Object.assign({},n),e);r(i),yield t.plugin.setSettings(i)}),[n,t])}}S();var Mc=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function Nc(e){let{actionKey:t,skillCategory:n,initialData:r,onAction:i}=e,{event:a,exercise:o}=Tc(),[s,c]=b(!1),[l,u]=b(null),d=m(r??{}),f=m(null),p=m(!1),_=m(i);return y(()=>{_.current=i}),g(()=>{r&&(d.current=Object.assign({},r))},[]),g(()=>{let e=a.onMainPanelAction(e=>Mc(this,void 0,void 0,function*(){console.log(`[useExerciseTracker:${t}] Dashboard action received:`,e),p.current=!0,f.current=Date.now(),c(!0),u(e),d.current=r??{},_.current&&(yield _.current(e)),console.log(`[useExerciseTracker:${t}] onAction complete, exercise active`)}),t);return()=>e.off()},[t]),{isActive:s,actionParams:l,start:h(e=>Mc(this,void 0,void 0,function*(){console.log(`[useExerciseTracker:${t}] start() called (self-initiated)`,e),p.current=!1,yield o.start({actionKey:t,knowledgeId:e?.knowledgeId}),f.current=Date.now(),d.current=r??{},c(!0),console.log(`[useExerciseTracker:${t}] start() complete, session token acquired`)}),[t,o,r]),ready:h(()=>{f.current=Date.now()},[]),micro:h(e=>{let t={type:`micro`,skillCategory:n,accomplishmentKeyword:e.accomplishmentKeyword,description:e.description,meta:e.meta};a.emitAccomplishment(t)},[a,n]),track:h(e=>{d.current=Object.assign(Object.assign({},d.current),e)},[]),end:h(e=>{let r=f.current?Date.now()-f.current:0,i=Math.max(1,Math.round(r/6e4));console.log(`[useExerciseTracker:${t}] end() — keyword=${e.accomplishmentKeyword}, errorRatio=${e.errorRatio}, duration=${i}min, trackedData=`,d.current);let o=[...Object.entries(d.current).map(([e,t])=>({key:e,value:t,description:e})),...e.meta??[]],s={type:`macro`,skillCategory:n,accomplishmentKeyword:e.accomplishmentKeyword,description:e.description,errorRatio:e.errorRatio,durationMinutes:i,meta:o.length>0?o:void 0};a.emitAccomplishment(s),console.log(`[useExerciseTracker:${t}] Macro accomplishment emitted`),c(!1),u(null),f.current=null},[t,a,n])}}S();function Pc(e){let t=Tc(),n=t.userInfo.subscription_tier;return{hasAccess:i.indexOf(n)>=i.indexOf(e),requestUpgrade:h(()=>t.plugin.requestUpgrade(e),[t,e])}}S();var Fc={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Ic=x.createContext&&x.createContext(Fc);S();var Lc=[`attr`,`size`,`title`];function Rc(e,t){if(e==null)return{};var n=zc(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function zc(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function Bc(){return Bc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Bc.apply(this,arguments)}function Vc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Hc(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Vc(Object(n),!0).forEach(function(t){Uc(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Vc(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Uc(e,t,n){return t=Wc(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Wc(e){var t=Gc(e,`string`);return typeof t==`symbol`?t:t+``}function Gc(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Kc(e){return e&&e.map((e,t)=>x.createElement(e.tag,Hc({key:t},e.attr),Kc(e.child)))}function B(e){return t=>x.createElement(qc,Bc({attr:Hc({},e.attr)},t),Kc(e.child))}function qc(e){var t=t=>{var{attr:n,size:r,title:i}=e,a=Rc(e,Lc),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),x.createElement(`svg`,Bc({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:Hc(Hc({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&x.createElement(`title`,null,i),e.children)};return Ic===void 0?t(Fc):x.createElement(Ic.Consumer,null,e=>t(e))}function Jc(e){return B({tag:`svg`,attr:{viewBox:`0 0 384 512`},child:[{tag:`path`,attr:{d:`M333.49 238a122 122 0 0 0 27-65.21C367.87 96.49 308 32 233.42 32H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h31.87v288H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h209.32c70.8 0 134.14-51.75 141-122.4 4.74-48.45-16.39-92.06-50.83-119.6zM145.66 112h87.76a48 48 0 0 1 0 96h-87.76zm87.76 288h-87.76V288h87.76a56 56 0 0 1 0 112z`},child:[]}]})(e)}function Yc(e){return B({tag:`svg`,attr:{viewBox:`0 0 640 512`},child:[{tag:`path`,attr:{d:`M278.9 511.5l-61-17.7c-6.4-1.8-10-8.5-8.2-14.9L346.2 8.7c1.8-6.4 8.5-10 14.9-8.2l61 17.7c6.4 1.8 10 8.5 8.2 14.9L293.8 503.3c-1.9 6.4-8.5 10.1-14.9 8.2zm-114-112.2l43.5-46.4c4.6-4.9 4.3-12.7-.8-17.2L117 256l90.6-79.7c5.1-4.5 5.5-12.3.8-17.2l-43.5-46.4c-4.5-4.8-12.1-5.1-17-.5L3.8 247.2c-5.1 4.7-5.1 12.8 0 17.5l144.1 135.1c4.9 4.6 12.5 4.4 17-.5zm327.2.6l144.1-135.1c5.1-4.7 5.1-12.8 0-17.5L492.1 112.1c-4.8-4.5-12.4-4.3-17 .5L431.6 159c-4.6 4.9-4.3 12.7.8 17.2L523 256l-90.6 79.7c-5.1 4.5-5.5 12.3-.8 17.2l43.5 46.4c4.5 4.9 12.1 5.1 17 .6z`},child:[]}]})(e)}function Xc(e){return B({tag:`svg`,attr:{viewBox:`0 0 320 512`},child:[{tag:`path`,attr:{d:`M320 48v32a16 16 0 0 1-16 16h-62.76l-80 320H208a16 16 0 0 1 16 16v32a16 16 0 0 1-16 16H16a16 16 0 0 1-16-16v-32a16 16 0 0 1 16-16h62.76l80-320H112a16 16 0 0 1-16-16V48a16 16 0 0 1 16-16h192a16 16 0 0 1 16 16z`},child:[]}]})(e)}function Zc(e){return B({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M448 48v32a16 16 0 0 1-16 16h-48v368a16 16 0 0 1-16 16h-32a16 16 0 0 1-16-16V96h-32v368a16 16 0 0 1-16 16h-32a16 16 0 0 1-16-16V352h-32a160 160 0 0 1 0-320h240a16 16 0 0 1 16 16z`},child:[]}]})(e)}function Qc(e){return B({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm115.7 272l-176 101c-15.8 8.8-35.7-2.5-35.7-21V152c0-18.4 19.8-29.8 35.7-21l176 107c16.4 9.2 16.4 32.9 0 42z`},child:[]}]})(e)}function $c(e){return B({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm96 328c0 8.8-7.2 16-16 16H176c-8.8 0-16-7.2-16-16V176c0-8.8 7.2-16 16-16h160c8.8 0 16 7.2 16 16v160z`},child:[]}]})(e)}function el(e){return B({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M496 224H293.9l-87.17-26.83A43.55 43.55 0 0 1 219.55 112h66.79A49.89 49.89 0 0 1 331 139.58a16 16 0 0 0 21.46 7.15l42.94-21.47a16 16 0 0 0 7.16-21.46l-.53-1A128 128 0 0 0 287.51 32h-68a123.68 123.68 0 0 0-123 135.64c2 20.89 10.1 39.83 21.78 56.36H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h480a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm-180.24 96A43 43 0 0 1 336 356.45 43.59 43.59 0 0 1 292.45 400h-66.79A49.89 49.89 0 0 1 181 372.42a16 16 0 0 0-21.46-7.15l-42.94 21.47a16 16 0 0 0-7.16 21.46l.53 1A128 128 0 0 0 224.49 480h68a123.68 123.68 0 0 0 123-135.64 114.25 114.25 0 0 0-5.34-24.36z`},child:[]}]})(e)}S();var tl=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},nl=[.8,.9,1,1.1,1.2,1.5],rl=!1,il=({text:e,voice:t,language:n,hide:r,playListenerEvent:i,initialSpeed:a=1,playOnMount:s=!1,enableSpeedAdjustment:c=!1,cache:l=!0,size:u=`25px`,ttsInstructions:d,disableDialect:f=!1})=>{let[p,h]=b(null),[_,v]=b(a),[x,S]=b(!1),[C,E]=b(!1),{ai:ee,userInfo:D}=Tc(),O=m(null),k=m(null);g(()=>(p&&h(null),()=>{p&&URL.revokeObjectURL(p)}),[e]);let A=()=>tl(void 0,void 0,void 0,function*(){E(!0);let r=d??(!f&&D?.dialect?`Speak with a ${D.dialect} accent and pronunciation.`:void 0),i=yield ee.getVoice(e,t||(n?`aws_default`:`openai_alloy`),1,n,l,r);h(URL.createObjectURL(i)),E(!1)});g(()=>{if(!p||!x){O.current&&=(O.current.pause(),O.current.currentTime=0,null);return}O.current&&(O.current.pause(),O.current.currentTime=0);let e=new Audio(p);return O.current=e,e.playbackRate=_,e.play().then(()=>{e.onended=()=>{S(!1),rl=!1,O.current=null}}).catch(e=>{console.warn(`Error playing audio:`,e),S(!1),O.current=null}),()=>{O.current&&=(O.current.pause(),O.current.currentTime=0,null)}},[p,x,_]),g(()=>()=>{O.current&&=(O.current.pause(),O.current.currentTime=0,null),S(!1)},[]),g(()=>()=>{p&&URL.revokeObjectURL(p)},[p]);let j=()=>{!x&&!p?A().then(()=>S(!0)):S(e=>!e)},te=m(j);return y(()=>{te.current=j}),g(()=>i?(k.current=o.on(i,()=>te.current()),()=>{k.current&&=(k.current.off(),null)}):void 0,[i]),g(()=>{!s||rl||(rl=!0,j())},[s]),w(`div`,{className:`group relative`,children:T(`div`,{className:`flex flex-row items-end`,children:[!r&&w(`button`,{className:`text-gray-400`,onClick:j,disabled:C,children:w(C?al:x?$c:Qc,{size:u})}),c&&T(`div`,{className:`ml-1 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex flex-row text-sm text-gray-500`,children:[w(`span`,{className:`pr-1`,children:`Speed: `}),w(`select`,{value:_,className:`appearance-none cursor-pointer pr-0 p-0 rounded shadow leading-tight focus:outline-none focus:bg-gray-800 focus:ring bg-transparent border-0`,onChange:e=>v(parseFloat(e.target.value)),disabled:C,children:nl.map(e=>w(`option`,{value:e,children:e},e))})]})]})})},al=({text:e,className:t,size:n=`30px`})=>T(`div`,{className:`flex items-center space-x-2 pl-1 `+t,children:[T(`svg`,{style:{width:n,height:n},className:`animate-spin -ml-1 h-5 w-5 text-white`,xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,children:[w(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),w(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`})]}),e&&w(`span`,{className:``,children:e})]});function ol(e){return B({tag:`svg`,attr:{viewBox:`0 0 384 512`},child:[{tag:`path`,attr:{d:`M192 0C139 0 96 43 96 96l0 160c0 53 43 96 96 96s96-43 96-96l0-160c0-53-43-96-96-96zM64 216c0-13.3-10.7-24-24-24s-24 10.7-24 24l0 40c0 89.1 66.2 162.7 152 174.4l0 33.6-48 0c-13.3 0-24 10.7-24 24s10.7 24 24 24l72 0 72 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-48 0 0-33.6c85.8-11.7 152-85.3 152-174.4l0-40c0-13.3-10.7-24-24-24s-24 10.7-24 24l0 40c0 70.7-57.3 128-128 128s-128-57.3-128-128l0-40z`},child:[]}]})(e)}function sl(e){return B({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M304 48a48 48 0 1 0 -96 0 48 48 0 1 0 96 0zm0 416a48 48 0 1 0 -96 0 48 48 0 1 0 96 0zM48 304a48 48 0 1 0 0-96 48 48 0 1 0 0 96zm464-48a48 48 0 1 0 -96 0 48 48 0 1 0 96 0zM142.9 437A48 48 0 1 0 75 369.1 48 48 0 1 0 142.9 437zm0-294.2A48 48 0 1 0 75 75a48 48 0 1 0 67.9 67.9zM369.1 437A48 48 0 1 0 437 369.1 48 48 0 1 0 369.1 437z`},child:[]}]})(e)}S();var cl=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},ll=v(({onVoiceRecorded:e,iconSize:t,className:n,disabled:r,loading:i,onRecordingStatusChange:a,enablePushToTalk:o=!1},s)=>{let[c,u]=b(!1),[d,p]=b(!1),h=m(null),{ai:_,plugin:v}=Tc(),y=m(e);g(()=>{y.current=e},[e]);let x=()=>cl(void 0,void 0,void 0,function*(){try{h.current||=new l(v.pluginId),yield h.current.startRecording(),u(!0),a(!0)}catch(e){console.error(`Failed to start recording:`,e)}}),S=()=>cl(void 0,void 0,void 0,function*(){try{if(h.current&&c){let e=yield h.current.stopRecording();p(!0);let t=yield _.getTextFromVoice(e.recording);p(!1),y.current(t)}}catch(e){console.error(`Failed to stop recording:`,e)}finally{u(!1),a(!1)}});f(s,()=>({startRecording:x,stopRecording:S}));let C=m(!1);return g(()=>{if(!o)return;let e=e=>cl(void 0,void 0,void 0,function*(){e.code===`Space`&&!C.current&&(C.current=!0,yield x())}),t=e=>{e.code===`Space`&&C.current&&(C.current=!1,S())};return window.addEventListener(`keydown`,e),window.addEventListener(`keyup`,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`keyup`,t)}},[o]),w(`button`,{className:`flex flex-row justify-center items-center rounded-full mx-auto disabled:opacity-50 `+n,onClick:c?S:x,disabled:r||i||d,children:i||d?w(sl,{className:`animate-spin`}):w(ol,{size:t,className:c?`text-red-600`:``})})});S();function ul({imageUrl:e,className:t,isDarkTheme:n=!1,width:r=`150px`,loudnessRef:i}){let a=m(null),o=m(0),s=m(null),c=(e,t,r,i)=>{if(t&&e){e.clearRect(0,0,t.width,t.height);let a=Math.min(t.width,t.height)/3,o=t.width/2,s=t.height/2,c=a+i/2.5;e.beginPath(),e.arc(o,s,c,0,Math.PI*2,!0),e.strokeStyle=n?`rgba(255, 255, 255, 0.5)`:`rgba(0, 0, 0, 0.5)`,e.lineWidth=5,e.stroke(),e.save(),e.beginPath(),e.arc(o,s,a,0,Math.PI*2,!0),e.closePath(),e.clip(),e.drawImage(r,o-a,s-a,a*2,a*2),e.restore(),e.beginPath(),e.arc(o,s,a,0,Math.PI*2,!0),e.strokeStyle=n?`rgba(255, 255, 255, 0.9)`:`rgba(0, 0, 0, 0.9)`,e.lineWidth=5,e.stroke()}};return g(()=>{let t=a.current;if(t){let n=t.getContext(`2d`);if(n){let r=new Image;r.src=e;let a=!0;return r.onload=()=>{if(!a)return;c(n,t,r,0);let e=()=>{let a=i?.current??0;o.current>a?o.current=Math.max(a,o.current-.06*o.current):o.current=a,c(n,t,r,o.current),s.current=requestAnimationFrame(e)};s.current=requestAnimationFrame(e)},()=>{a=!1,s.current&&cancelAnimationFrame(s.current)}}}},[e]),w(`canvas`,{ref:a,className:t,width:500,height:500,style:{width:r}})}function dl(e){let t=[];return e.userMessage&&t.push({id:`1`,role:`user`,content:e.userMessage}),e.assistantMessage&&t.push({id:`2`,role:`assistant`,content:e.assistantMessage}),t}S();function fl({avatarImageUrl:e,voiceId:t,agentTools:n,autoStartConversation:r,children:i,circleSize:a=`300px`,className:o,cache:c=!1,prompt:l,promptVariables:u,onMessage:f,hideCircleAvatar:p=!1}){let{ai:h,plugin:_,userInfo:v}=Tc(),{isDark:y}=bc(_.theme,!0),[x,S]=b(!1),[C,E]=b(!1),ee=m(0),D=v?.dialect?`Speak with a ${v.dialect} accent and pronunciation.`:void 0,O=d(()=>new s((...e)=>h.getVoice(...e),t,c),[t,h,c]);g(()=>{O.setInstructions(D)},[O,D]);let{messages:k,append:A,isLoading:j,lastMessage:te,setMessages:ne}=kc(n,{prompt:l,promptVariables:u});return g(()=>{console.log(`messages`,k),f?.(k)},[k,f]),g(()=>{j||E(!1)},[j]),g(()=>{t&&(O.setOnLoudnessChange(e=>{ee.current=e}),O.setOnEndOfSpeech(()=>S(!1)),r&&(ne(dl(r)),r.assistantMessage?O.handleNewText(r.assistantMessage,j):r.userMessage&&A([{role:`user`,content:r.userMessage,id:k.length.toString()}])))},[r,t]),g(()=>()=>{O.cleanup()},[O]),g(()=>{te?.role===`assistant`&&(O.handleNewText(te.content,j),te.toolCalls&&(S(!1),E(!1)))},[te,j]),T(`div`,{className:`md:pb-8 ${o||``}`,children:[!p&&w(ul,{width:a,className:`mx-auto`,imageUrl:e,isDarkTheme:y,loudnessRef:ee}),i,w(ll,{iconSize:`30`,className:`w-16 h-16 shadow-lg rounded-full bg-gray-400 dark:bg-gray-800`,disabled:x,loading:C,enablePushToTalk:!0,onVoiceRecorded:e=>{S(!0),A([{role:`user`,content:`Message(`+Math.floor((k.length+1)/2)+`): `+e,id:k.length.toString()}])},onRecordingStatusChange:e=>!e&&E(!0)})]})}S();function pl(){let{plugin:e}=Tc(),[t,n]=b(null),[r,i]=b(0);return g(()=>{e.getTranslator().then(e=>{n(e),e.onLanguageChanged(()=>{i(e=>e+1)})})},[e]),{t:h((e,n)=>t&&t.t(e,n)||``,[t,r]),ready:t!==null}}function ml(e){return B({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{d:`M5.536 21.886a1.004 1.004 0 0 0 1.033-.064l13-9a1 1 0 0 0 0-1.644l-13-9A1 1 0 0 0 5 3v18a1 1 0 0 0 .536.886z`},child:[]}]})(e)}S();var hl=0,gl=()=>`ba-${++hl}`;function _l({prompt:e,promptVariables:t,autoStartConversation:n,circleSize:r=`160px`,chatPlaceholder:i,bottomAction:a,className:o,voiceSpeed:c=1,tools:l,showName:u=!1}){let{ai:f,plugin:p,userInfo:h}=Tc(),_=p.ttsEnabled,{isDark:v}=bc(p.theme,!0),y=h.study_buddy,x=h?.dialect,S=x?`Speak with a ${x} accent and pronunciation.`:void 0,[C,E]=b(``),[ee,D]=b([]),[O,k]=b(!1),[A,j]=b(!1),te=m(0),ne=m(_);g(()=>{ne.current=_,!_&&A&&(re.stop(),j(!1))},[_]);let re=d(()=>new s((...e)=>f.getVoice(...e),y?.voiceId??``),[y?.voiceId,f]);g(()=>{re.setInstructions(S)},[re,S]),g(()=>(re.setVoiceSpeed(c),re.setOnLoudnessChange(e=>{te.current=e}),re.setOnEndOfSpeech(()=>j(!1)),()=>re.cleanup()),[re]);let ie=e=>e.map(e=>({role:e.role,content:e.content})),ae=n=>{k(!0),f.getStreamedText({messages:ie(n),onMessage:(e,t,n)=>{k(!n);let r=`ai-${e}`;D(e=>{let n=e[e.length-1];return n?.id===r?[...e.slice(0,-1),Object.assign(Object.assign({},n),{content:t})]:[...e,{id:r,role:`assistant`,content:t}]}),ne.current&&(re.handleNewText(t,!n),t&&j(!0))},tools:l,prompt:e,variables:t})},M=m(!1);if(g(()=>{if(!M.current){if(M.current=!0,n?.assistantMessage)D([{id:`init`,role:`assistant`,content:n.assistantMessage}]),ne.current&&(re.handleNewText(n.assistantMessage,!1),j(!0));else if(n?.userMessage){let e={id:`auto-start`,role:`user`,content:n.userMessage};D([e]),ae([e])}}},[]),!y)return w(`div`,{});let oe=e=>{if(!e.trim()||O)return;let t={id:gl(),role:`user`,content:e},n=[...ee,t];D(n),ae(n)},se=[...ee].filter(e=>e.role===`assistant`).pop();return T(`div`,{className:`flex flex-col items-center ${o||``}`,children:[w(ul,{width:r,imageUrl:y.avatarUrl,isDarkTheme:v,loudnessRef:te,className:`mx-auto`}),u&&w(`div`,{className:`flex items-center gap-2`,children:w(`span`,{className:`text-3xl font-semibold`,children:y.name})}),!p.ttsEnabled&&ee.length>1?w(`div`,{className:`w-full rounded-xl bg-gray-200/70 dark:bg-gray-800/70 px-4 py-3 text-sm text-gray-800 dark:text-gray-200 leading-relaxed border border-gray-300/40 dark:border-gray-700/40 mt-4`,children:!se?.content&&O?T(`span`,{className:`inline-flex gap-1 py-0.5`,children:[w(`span`,{className:`w-1.5 h-1.5 rounded-full bg-gray-400 animate-bounce`}),w(`span`,{className:`w-1.5 h-1.5 rounded-full bg-gray-400 animate-bounce`,style:{animationDelay:`0.15s`}}),w(`span`,{className:`w-1.5 h-1.5 rounded-full bg-gray-400 animate-bounce`,style:{animationDelay:`0.3s`}})]}):w(`span`,{className:`whitespace-pre-wrap`,children:se?.content})}):null,T(`div`,{className:`w-full relative mt-4 `+(_?`max-w-md`:``),children:[w(`input`,{value:C,onChange:e=>E(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),oe(C),E(``))},placeholder:i??`Ask ${y.name} a question…`,disabled:O,className:`w-full bg-gray-800/50 border border-gray-700 rounded-lg px-3 py-2 pr-16 text-sm text-gray-200 placeholder:text-gray-500 focus:outline-none focus:ring-1 focus:ring-blue-500 disabled:opacity-60`}),T(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1`,children:[w(ll,{iconSize:`14`,className:`p-1 text-gray-400 hover:text-white transition-colors`,disabled:O,onVoiceRecorded:e=>oe(e),onRecordingStatusChange:()=>{}}),w(`button`,{type:`button`,onClick:()=>{oe(C),E(``)},disabled:O||!C.trim(),className:`p-1 text-gray-400 hover:text-white disabled:opacity-40 transition-colors`,children:w(ml,{className:`w-4 h-4`})})]})]}),a&&w(`div`,{className:`w-full max-w-md border-t border-gray-700/60 pt-3`,children:a})]})}function vl(e){return B({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M20 6 9 17l-5-5`},child:[]}]})(e)}function yl(e){return B({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M15 2H9a1 1 0 0 0-1 1v2c0 .6.4 1 1 1h6c.6 0 1-.4 1-1V3c0-.6-.4-1-1-1Z`},child:[]},{tag:`path`,attr:{d:`M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2M16 4h2a2 2 0 0 1 2 2v2M11 14h10`},child:[]},{tag:`path`,attr:{d:`m17 10 4 4-4 4`},child:[]}]})(e)}function bl(e){return B({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`},child:[]},{tag:`path`,attr:{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`},child:[]}]})(e)}function xl(e){return B({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M4 12h8`},child:[]},{tag:`path`,attr:{d:`M4 18V6`},child:[]},{tag:`path`,attr:{d:`M12 18V6`},child:[]},{tag:`path`,attr:{d:`m17 12 3-2v8`},child:[]}]})(e)}function Sl(e){return B({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M4 12h8`},child:[]},{tag:`path`,attr:{d:`M4 18V6`},child:[]},{tag:`path`,attr:{d:`M12 18V6`},child:[]},{tag:`path`,attr:{d:`M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1`},child:[]}]})(e)}function Cl(e){return B({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M4 12h8`},child:[]},{tag:`path`,attr:{d:`M4 18V6`},child:[]},{tag:`path`,attr:{d:`M12 18V6`},child:[]},{tag:`path`,attr:{d:`M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2`},child:[]},{tag:`path`,attr:{d:`M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2`},child:[]}]})(e)}function wl(e){return B({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`},child:[]},{tag:`path`,attr:{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`},child:[]}]})(e)}function Tl(e){return B({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M12 2v4`},child:[]},{tag:`path`,attr:{d:`m16.2 7.8 2.9-2.9`},child:[]},{tag:`path`,attr:{d:`M18 12h4`},child:[]},{tag:`path`,attr:{d:`m16.2 16.2 2.9 2.9`},child:[]},{tag:`path`,attr:{d:`M12 18v4`},child:[]},{tag:`path`,attr:{d:`m4.9 19.1 2.9-2.9`},child:[]},{tag:`path`,attr:{d:`M2 12h4`},child:[]},{tag:`path`,attr:{d:`m4.9 4.9 2.9 2.9`},child:[]}]})(e)}function El(e){return B({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`15 3 21 3 21 9`},child:[]},{tag:`polyline`,attr:{points:`9 21 3 21 3 15`},child:[]},{tag:`line`,attr:{x1:`21`,x2:`14`,y1:`3`,y2:`10`},child:[]},{tag:`line`,attr:{x1:`3`,x2:`10`,y1:`21`,y2:`14`},child:[]}]})(e)}function Dl(e){return B({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`4 14 10 14 10 20`},child:[]},{tag:`polyline`,attr:{points:`20 10 14 10 14 4`},child:[]},{tag:`line`,attr:{x1:`14`,x2:`21`,y1:`10`,y2:`3`},child:[]},{tag:`line`,attr:{x1:`3`,x2:`10`,y1:`21`,y2:`14`},child:[]}]})(e)}function Ol(e){return B({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z`},child:[]},{tag:`path`,attr:{d:`M20 3v4`},child:[]},{tag:`path`,attr:{d:`M22 5h-4`},child:[]},{tag:`path`,attr:{d:`M4 17v2`},child:[]},{tag:`path`,attr:{d:`M5 18H3`},child:[]}]})(e)}function kl(e){this.content=e}kl.prototype={constructor:kl,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new kl(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new kl(n)},addToStart:function(e,t){return new kl([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new kl(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new kl(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=kl.from(e),e.size?new kl(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=kl.from(e),e.size?new kl(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=kl.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},kl.from=function(e){if(e instanceof kl)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new kl(t)};function Al(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let e=0;i.text[e]==a.text[e];e++)n++;return n}if(i.content.size||a.content.size){let e=Al(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function jl(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=0,t=Math.min(o.text.length,s.text.length);for(;e<t&&o.text[o.text.length-e-1]==s.text[s.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(o.content.size||s.content.size){let e=jl(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}var V=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return Al(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return jl(this,e,t,n)}findIndex(e){if(e==0)return Nl(0,e);if(e==this.size)return Nl(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?Nl(t+1,i):Nl(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};V.empty=new V([],0);var Ml={index:0,offset:0};function Nl(e,t){return Ml.index=e,Ml.offset=t,Ml}function Pl(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!Pl(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!Pl(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var H=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else !n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Pl(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};H.none=[];var Fl=class extends Error{},U=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=Ll(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(Il(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(V.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};U.empty=new U(V.empty,0,0);function Il(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(Il(a.content,t-i-1,n-i-1)))}function Ll(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=Ll(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function Rl(e,t,n){if(n.openStart>e.depth)throw new Fl(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Fl(`Inconsistent open depths`);return zl(e,t,n,0)}function zl(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=zl(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return Wl(a,Kl(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return Wl(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=ql(n,e);return Wl(a,Gl(e,i,o,t,r))}}function Bl(e,t){if(!t.type.compatibleContent(e.type))throw new Fl(`Cannot join `+t.type.name+` onto `+e.type.name)}function Vl(e,t,n){let r=e.node(n);return Bl(r,t.node(n)),r}function Hl(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function Ul(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(Hl(e.nodeAfter,r),a++));for(let e=a;e<o;e++)Hl(i.child(e),r);t&&t.depth==n&&t.textOffset&&Hl(t.nodeBefore,r)}function Wl(e,t){return e.type.checkContent(t),e.copy(t)}function Gl(e,t,n,r,i){let a=e.depth>i&&Vl(e,t,i+1),o=r.depth>i&&Vl(n,r,i+1),s=[];return Ul(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(Bl(a,o),Hl(Wl(a,Gl(e,t,n,r,i+1)),s)):(a&&Hl(Wl(a,Kl(e,t,i+1)),s),Ul(t,n,i,s),o&&Hl(Wl(o,Kl(n,r,i+1)),s)),Ul(r,null,i,s),new V(s)}function Kl(e,t,n){let r=[];return Ul(null,e,n,r),e.depth>n&&Hl(Wl(Vl(e,t,n+1),Kl(e,t,n+1)),r),Ul(t,null,n,r),new V(r)}function ql(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(V.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var Jl=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return H.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Ql(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=Zl.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else Zl.set(t,r=new Yl);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%Xl,i}},Yl=class{constructor(){this.elts=[],this.i=0}},Xl=12,Zl=new WeakMap,Ql=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},$l=Object.create(null),eu=class e{constructor(e,t,n,r=H.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||V.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&Pl(this.attrs,t||e.defaultAttrs||$l)&&H.sameSet(this.marks,n||H.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return U.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new U(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return Rl(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return Jl.resolveCached(this,e)}resolveNoCache(e){return Jl.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),nu(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=V.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=H.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!H.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=V.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};eu.prototype.text=void 0;var tu=class e extends eu{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):nu(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function nu(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var ru=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new iu(t,n);if(r.next==null)return e.empty;let i=au(r);r.next&&r.err(`Unexpected trailing text`);let a=hu(fu(i));return gu(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return V.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
|
|
2
|
+
`),o=r;a.length>o;o++){var s=a[o];if(1024>=s.length){var c=ln.test(s)?s.replace(ln,`$1`):s;if(!c.match(/\S*Error: /)){for(var l of n){var u=l(c,e);if(u){i.push(u);break}}if(i.length>=50)break}}}return function(e){if(!e.length)return[];var t=Array.from(e);return t.reverse(),t.slice(0,50).map((e=>{return N({},e,{filename:e.filename||(n=t,n[n.length-1]||{}).filename,function:e.function||Qt});var n}))}(i)}}(`web:javascript`,an,cn)),this._instance=e,this.po=this._instance.persistence?.get_property(zn)??[],this.yo=Tn(this.bo()),this._o=new En(this.yo)}onConfigChange(){this.yo=Tn(this.bo()),this._o.setConfig(this.yo)}onRemoteConfig(e){if(`errorTracking`in e){var t=e.errorTracking?.suppressionRules??[],n=e.errorTracking?.captureExtensionExceptions;this.po=t,this._instance.persistence&&this._instance.persistence.register({[zn]:this.po,[Bn]:n})}}get wo(){var e,t=!!this._instance.get_property(Bn);return(e=this._instance.config.error_tracking.captureExtensionExceptions??t)!=null&&e}buildProperties(e,t){return this.mo.buildFromUnknown(e,{syntheticException:t?.syntheticException,mechanism:{handled:t?.handled}})}addExceptionStep(e,t){if(this.yo.enabled)try{if(!Ae(e)||e.trim().length===0)return void $s.warn(`Ignoring exception step because message must be a non-empty string`);var{sanitizedProperties:n,droppedKeys:r}=function(e){if(!e)return{sanitizedProperties:{},droppedKeys:[]};var t=[];return{sanitizedProperties:Object.keys(e).reduce(((n,r)=>Cn.has(r)?(t.push(r),n):(n[r]=e[r],n)),{}),droppedKeys:t}}(this.xo(t));r.length>0&&$s.warn(`Ignoring reserved exception step fields`,{droppedKeys:r}),this._o.add(N({[xn]:e,[Sn]:new Date().toISOString()},n))}catch(e){$s.error(`Failed to add exception step. Ignoring breadcrumb.`,e)}}sendExceptionEvent(e){try{var t=e.$exception_list;if(this.So(t)){if(this.ko(t))return this.Co(`Exception dropped: matched a suppression rule`),void $s.info(`Skipping exception capture because a suppression rule matched`);if(!this.wo&&this.Io(t))return this.Co(`Exception dropped: thrown by a browser extension`),void $s.info(`Skipping exception capture because it was thrown by an extension`);if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.To(t))return this.Co(`Exception dropped: thrown by the PostHog SDK`),void $s.info(`Skipping exception capture because it was thrown by the PostHog SDK`)}var n=this.yo.enabled&&L(e.$exception_steps)?this.Eo(e):e;try{var r=this._instance.capture(`$exception`,n,{_noTruncate:!0,_batchKey:`exceptionEvent`,en:!0});return r&&this._o.clear(),r}catch(e){$s.error(`Failed to capture exception event. Dropping this exception.`,e),this._o.clear();return}}catch(e){$s.error(`Failed to process exception event. Ignoring this exception.`,e);return}}Eo(e){try{var t=this._o.getAttachable();return t.length===0?e:N({},e,{$exception_steps:t})}catch(t){return $s.error(`Failed to read buffered exception steps. Capturing exception without steps.`,t),e}}Co(e){this.yo.enabled&&this._o.add({[xn]:e,[Sn]:new Date().toISOString()})}xo(e){return Oe(e)?N({},e):{}}bo(){return this._instance.config.error_tracking?.exception_steps??{}}ko(e){if(e.length===0)return!1;var t=e.reduce(((e,t)=>{var{type:n,value:r}=t;return Ae(n)&&n.length>0&&e.$exception_types.push(n),Ae(r)&&r.length>0&&e.$exception_values.push(r),e}),{$exception_types:[],$exception_values:[]});return this.po.some((e=>{var n=e.values.map((e=>{var n=oo[e.operator],r=F(e.value)?e.value:[e.value],i=t[e.key]??[];return r.length>0&&n(r,i)}));return e.type===`OR`?n.some(Boolean):n.every(Boolean)}))}Io(e){return e.flatMap((e=>e.stacktrace?.frames??[])).some((e=>e.filename&&e.filename.startsWith(`chrome-extension://`)))}To(e){if(e.length>0){var t,n,r=e[0].stacktrace?.frames??[],i=r[r.length-1];return(t=i==null||(n=i.filename)==null?void 0:n.includes(`posthog.com/static`))!=null&&t}return!1}So(e){return!L(e)&&F(e)}}},lc=N({productTours:class{get ni(){return this._instance.persistence}constructor(e){this.Mo=null,this.Po=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){`productTours`in e&&(this.ni&&this.ni.register({[Un]:!!e.productTours}),this.loadIfEnabled())}loadIfEnabled(){var e,t;this.Mo||(e=this._instance).config.disable_product_tours||(t=e.persistence)==null||!t.get_property(Un)||this.lr((()=>this.Ro()))}lr(e){var t,n;(t=M.__PosthogExtensions__)!=null&&t.generateProductTours?e():(n=M.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`product-tours`,(t=>{t?Fs.error(`Could not load product tours script`,t):e()}))}Ro(){var e;!this.Mo&&(e=M.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.Mo=M.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(t===void 0&&(t=!1),!F(this.Po)||t){var n=this.ni;if(n){var r=n.props[ur];if(F(r)&&!t)return this.Po=r,void e(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/product_tours/?token=`+this._instance.config.token),method:`GET`,callback:t=>{var r=t.statusCode;if(r!==200||!t.json){var i=`Product Tours API could not be loaded, status: `+r;Fs.error(i),e([],{isLoaded:!1,error:i});return}var a=F(t.json.product_tours)?t.json.product_tours:[];this.Po=a,n&&n.register({[ur]:a}),e(a,{isLoaded:!0})}})}else e(this.Po,{isLoaded:!0})}getActiveProductTours(e){L(this.Mo)?e([],{isLoaded:!1,error:`Product tours not loaded`}):this.Mo.getActiveProductTours(e)}showProductTour(e){var t;(t=this.Mo)==null||t.showTourById(e)}previewTour(e){this.Mo?this.Mo.previewTour(e):this.lr((()=>{var t;this.Ro(),(t=this.Mo)==null||t.previewTour(e)}))}dismissProductTour(){var e;(e=this.Mo)==null||e.dismissTour(`user_clicked_skip`)}nextStep(){var e;(e=this.Mo)==null||e.nextStep()}previousStep(){var e;(e=this.Mo)==null||e.previousStep()}clearCache(){var e;this.Po=null,(e=this.ni)==null||e.unregister(ur)}resetTour(e){var t;(t=this.Mo)==null||t.resetTour(e)}resetAllTours(){var e;(e=this.Mo)==null||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.Mo)==null||t.cancelPendingTour(e)}}},ac),uc={siteApps:class{constructor(e){this._instance=e,this.Oo=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Lo(e,t){if(t){var n=this.globalsForEvent(t);this.Oo.push(n),this.Oo.length>1e3&&(this.Oo=this.Oo.slice(10))}}get siteAppLoaders(){var e;return(e=M._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}initialize(){if(this.isEnabled){var e=this._instance._addCaptureHook(this.Lo.bind(this));this.Fo=()=>{e(),this.Oo=[],this.Fo=void 0}}}globalsForEvent(e){if(!e)throw Error(`Event payload is required`);var t={},n=this._instance.get_property(`$groups`)||[],r=this._instance.get_property(`$stored_group_properties`)||{};for(var[i,a]of Object.entries(r))t[i]={id:n[i],type:i,properties:a};var{$set_once:o,$set:s}=e;return{event:N({},ue(e,Is),{properties:N({},e.properties,s?{$set:N({},e.properties?.$set??{},s)}:{},o?{$set_once:N({},e.properties?.$set_once??{},o)}:{}),elements_chain:e.properties?.$elements_chain??``,distinct_id:e.properties?.distinct_id}),person:{properties:this._instance.get_property(`$stored_person_properties`)},groups:t}}setupSiteApp(e){var t=this.apps[e.id],n=()=>{var n;!t.errored&&this.Oo.length&&(Ls.info(`Processing `+this.Oo.length+` events for site app with id `+e.id),this.Oo.forEach((e=>t.processEvent==null?void 0:t.processEvent(e))),t.processedBuffer=!0),Object.values(this.apps).every((e=>e.processedBuffer||e.errored))&&((n=this.Fo)==null||n.call(this))},r=!1,i=i=>{t.errored=!i,t.loaded=!0,Ls.info(`Site app with id `+e.id+` `+(i?`loaded`:`errored`)),r&&n()};try{var{processEvent:a}=e.init({posthog:this._instance,callback(e){i(e)}});a&&(t.processEvent=a),r=!0}catch(t){Ls.error(Rs+e.id,t),i(!1)}if(r&&t.loaded)try{n()}catch(n){Ls.error(`Error while processing buffered events PostHog app with config id `+e.id,n),t.errored=!0}}Ao(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var n of e)this.setupSiteApp(n)}No(e){if(Object.keys(this.apps).length!==0){var t=this.globalsForEvent(e);for(var n of Object.values(this.apps))try{n.processEvent==null||n.processEvent(t)}catch(t){Ls.error(`Error while processing event `+e.event+` for site app `+n.id,t)}}}onRemoteConfig(e){var t,n,r,i=this;if((t=this.siteAppLoaders)!=null&&t.length)return this.isEnabled?(this.Ao(),void this._instance.on(`eventCaptured`,(e=>this.No(e)))):void Ls.error(`PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.`);if((n=this.Fo)==null||n.call(this),(r=e.siteApps)!=null&&r.length)if(this.isEnabled){var a=function(e){var t;M[`__$$ph_site_app_`+e]=i._instance,(t=M.__PosthogExtensions__)==null||t.loadSiteApp==null||t.loadSiteApp(i._instance,s,(t=>{if(t)return Ls.error(Rs+e,t)}))};for(var{id:o,url:s}of e.siteApps)a(o)}else Ls.error(`PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.`)}}},dc={tracingHeaders:class{constructor(e){this.$o=void 0,this.Do=void 0,this.oo=()=>{var e,t,n=this.qo()||[];I(this.$o)&&((e=M.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null||e._patchXHR(n,this._instance.get_distinct_id(),this._instance.sessionManager)),I(this.Do)&&((t=M.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null||t._patchFetch(n,this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=e}initialize(){this.startIfEnabledOrStop()}lr(e){var t,n;(t=M.__PosthogExtensions__)!=null&&t.tracingHeadersPatchFns&&e(),(n=M.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`tracing-headers`,(t=>{if(t)return ws.error(`failed to load script`,t);e()}))}qo(){return this._instance.config.addTracingHeaders??this._instance.config.__add_tracing_headers}startIfEnabledOrStop(){var e,t;this.qo()?this.lr(this.oo):((e=this.$o)==null||e.call(this),(t=this.Do)==null||t.call(this),this.$o=void 0,this.Do=void 0)}}},fc=N({surveys:class{get qt(){return this._instance.config}constructor(e){this.jo=void 0,this._surveyManager=null,this.Ho=!1,this.Uo=[],this.Bo=null,this._instance=e,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this.qt.disable_surveys){var t=e.surveys;if(L(t))return z.warn(`Flags not loaded yet. Not loading surveys.`);var n=F(t);this.jo=n?t.length>0:t,z.info(`flags response received, isSurveysEnabled: `+this.jo),this.loadIfEnabled()}}reset(){localStorage.removeItem(`lastSeenSurveyDate`);for(var e=[],t=0;t<localStorage.length;t++){var n=localStorage.key(t);(n!=null&&n.startsWith(mo)||n!=null&&n.startsWith(`inProgressSurvey_`))&&e.push(n)}e.forEach((e=>localStorage.removeItem(e)))}loadIfEnabled(){if(!this._surveyManager)if(this.Ho)z.info(`Already initializing surveys, skipping...`);else if(this.qt.disable_surveys)z.info(Ws);else if(this.qt.cookieless_mode&&this._instance.consent.isOptedOut())z.info(`Not loading surveys in cookieless mode without consent.`);else{var e=M?.__PosthogExtensions__;if(e){if(!I(this.jo)||this.qt.advanced_enable_surveys){var t=this.jo||this.qt.advanced_enable_surveys;this.Ho=!0;try{var n=e.generateSurveys;if(n)return void this.zo(n,t);var r=e.loadExternalDependency;if(!r)return void this.Vo(Dr);r(this._instance,`surveys`,(n=>{n||!e.generateSurveys?this.Vo(`Could not load surveys script`,n):this.zo(e.generateSurveys,t)}))}catch(e){throw this.Vo(`Error initializing surveys`,e),e}finally{this.Ho=!1}}}else z.error(`PostHog Extensions not found.`)}}zo(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new Hs(this._instance),z.info(`Surveys loaded successfully`),this.Wo({isLoaded:!0})}Vo(e,t){z.error(e,t),this.Wo({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.Uo.push(e),this._surveyManager&&this.Wo({isLoaded:!0}),()=>{this.Uo=this.Uo.filter((t=>t!==e))}}getSurveys(e,t){if(t===void 0&&(t=!1),this.qt.disable_surveys)return z.info(Ws),e([]);var n,r=this._instance.get_property(cr);if(r&&!t)return e(r,{isLoaded:!0});typeof Promise<`u`&&this.Bo?this.Bo.then((t=>{var{surveys:n,context:r}=t;return e(n,r)})):(typeof Promise<`u`&&(this.Bo=new Promise((e=>{n=e}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/surveys/?token=`+this.qt.token),method:`GET`,timeout:this.qt.surveys_request_timeout_ms,callback:t=>{var r;this.Bo=null;var i=t.statusCode;if(i!==200||!t.json){var a=`Surveys API could not be loaded, status: `+i;z.error(a);var o={isLoaded:!1,error:a};e([],o),n?.({surveys:[],context:o});return}var s,c=t.json.surveys||[],l=c.filter((e=>function(e){return!(!e.start_date||e.end_date)}(e)&&(function(e){var t;return!((t=e.conditions)==null||(t=t.events)==null||(t=t.values)==null||!t.length)}(e)||function(e){var t;return!((t=e.conditions)==null||(t=t.actions)==null||(t=t.values)==null||!t.length)}(e))));l.length>0&&((s=this._surveyEventReceiver)==null||s.register(l)),(r=this._instance.persistence)==null||r.register({[cr]:c});var u={isLoaded:!0};e(c,u),n?.({surveys:c,context:u})}}))}Wo(e){for(var t of this.Uo)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){z.error(`Error in survey callback`,e)}}getActiveMatchingSurveys(e,t){if(t===void 0&&(t=!1),!L(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);z.warn(`init was not called`)}Zo(e){var t=null;return this.getSurveys((n=>{t=n.find((t=>t.id===e))??null})),t}Go(e){if(L(this._surveyManager))return{eligible:!1,reason:Us};var t=typeof e==`string`?this.Zo(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:`Survey not found`}}canRenderSurvey(e){if(L(this._surveyManager))return z.warn(`init was not called`),{visible:!1,disabledReason:Us};var t=this.Go(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return L(this._surveyManager)?(z.warn(`init was not called`),Promise.resolve({visible:!1,disabledReason:Us})):new Promise((n=>{this.getSurveys((t=>{var r=t.find((t=>t.id===e))??null;if(r){var i=this.Go(r);n({visible:i.eligible,disabledReason:i.reason})}else n({visible:!1,disabledReason:`Survey not found`})}),t)}))}renderSurvey(e,t,n){var r;if(L(this._surveyManager))z.warn(`init was not called`);else{var i=typeof e==`string`?this.Zo(e):e;if(i!=null&&i.id)if(ho.includes(i.type)){var a=A?.querySelector(t);if(a)return(r=i.appearance)!=null&&r.surveyPopupDelaySeconds?(z.info(`Rendering survey `+i.id+` with delay of `+i.appearance.surveyPopupDelaySeconds+` seconds`),void setTimeout((()=>{var e;z.info(`Rendering survey `+i.id+` with delay of `+i.appearance?.surveyPopupDelaySeconds+` seconds`),(e=this._surveyManager)==null||e.renderSurvey(i,a,n),z.info(`Survey `+i.id+` rendered`)}),1e3*i.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(i,a,n);z.warn(`Survey element not found`)}else z.warn(`Surveys of type `+i.type+` cannot be rendered in the app`);else z.warn(`Survey not found`)}}displaySurvey(e,t){var n;if(L(this._surveyManager))z.warn(`init was not called`);else{var r=this.Zo(e);if(r){var i=r;if((n=r.appearance)!=null&&n.surveyPopupDelaySeconds&&t.ignoreDelay&&(i=N({},r,{appearance:N({},r.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==Xi.Popover&&t.initialResponses&&z.warn(`initialResponses is only supported for popover surveys. prefill will not be applied.`),!1===t.ignoreConditions){var a=this.canRenderSurvey(r);if(!a.visible)return void z.warn(`Survey is not eligible to be displayed: `,a.disabledReason)}t.displayType===Xi.Inline?this.renderSurvey(i,t.selector,t.properties):this._surveyManager.handlePopoverSurvey(i,t)}else z.warn(`Survey not found`)}}cancelPendingSurvey(e){L(this._surveyManager)?z.warn(`init was not called`):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;(e=this._surveyManager)==null||e.handlePageUnload()}}},ac),pc={toolbar:class{constructor(e){this.instance=e}Qo(e){M.ph_toolbar_state=e}Jo(){return M.ph_toolbar_state??0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e,t,n){if(e===void 0&&(e=void 0),t===void 0&&(t=void 0),n===void 0&&(n=void 0),Yr(this.instance.config)||!D||!A)return!1;e??=D.location,n??=D.history;try{if(!t){try{D.localStorage.setItem(`test`,`test`),D.localStorage.removeItem(`test`)}catch{return!1}t=D?.localStorage}var r,i=Gs||Oi(e.hash,`__posthog`)||Oi(e.hash,`state`),a=i?Ur((()=>JSON.parse(atob(decodeURIComponent(i)))))||Ur((()=>JSON.parse(decodeURIComponent(i)))):null;return a&&a.action===`ph_authorize`?((r=a).source=`url`,r&&Object.keys(r).length>0&&(a.desiredHash?e.hash=a.desiredHash:n?n.replaceState(n.state,``,e.pathname+e.search):e.hash=``)):((r=JSON.parse(t.getItem(Ks)||`{}`)).source=`localstorage`,delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch{return!1}}Ko(e){var t=M.ph_load_toolbar||M.ph_load_editor;!L(t)&&De(t)?t(e,this.instance):qs.warn(`No toolbar load function found`)}loadToolbar(e){var t=!(A==null||!A.getElementById(Sr));if(!D||t)return!1;var n=this.instance.requestRouter.region===`custom`&&this.instance.config.advanced_disable_toolbar_metrics,r=N({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor(`ui`)},n?{instrument:!1}:{});if(D.localStorage.setItem(Ks,JSON.stringify(N({},r,{source:void 0}))),this.Jo()===2)this.Ko(r);else if(this.Jo()===0){var i;this.Qo(1),(i=M.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this.instance,`toolbar`,(e=>{if(e)return qs.error(`[Toolbar] Failed to load`,e),void this.Qo(0);this.Qo(2),this.Ko(r)})),Jr(D,`turbolinks:load`,(()=>{this.Qo(0),this.loadToolbar(r)}))}return!0}Yo(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,n){return e===void 0&&(e=void 0),t===void 0&&(t=void 0),n===void 0&&(n=void 0),this.maybeLoadToolbar(e,t,n)}}},mc=N({experiments:nc},ac),hc=N({},ac,oc,sc,cc,lc,uc,fc,dc,pc,mc,{conversations:class{constructor(e){this.Xo=void 0,this._conversationsManager=null,this.ea=!1,this.ta=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this._instance.config.disable_conversations){var t=e.conversations;L(t)||(Fe(t)?this.Xo=t:(this.Xo=t.enabled,this.ta=t),this.loadIfEnabled())}}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.Xo=void 0,this.ta=null}loadIfEnabled(){if(!(this._conversationsManager||this.ea||this._instance.config.disable_conversations||Yr(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=M?.__PosthogExtensions__;if(e&&!I(this.Xo)&&this.Xo)if(this.ta&&this.ta.token){this.ea=!0;try{var t=e.initConversations;if(t)return this.ra(t),void(this.ea=!1);var n=e.loadExternalDependency;if(!n)return void this.ia(Dr);n(this._instance,`conversations`,(t=>{t||!e.initConversations?this.ia(`Could not load conversations script`,t):this.ra(e.initConversations),this.ea=!1}))}catch(e){this.ia(`Error initializing conversations`,e),this.ea=!1}}else rc.error(`Conversations enabled but missing token in remote config.`)}}ra(e){if(this.ta)try{this._conversationsManager=e(this.ta,this._instance),rc.info(`Conversations loaded successfully`)}catch(e){this.ia(`Error completing conversations initialization`,e)}else rc.error(`Cannot complete initialization: remote config is null`)}ia(e,t){rc.error(e,t),this._conversationsManager=null,this.ea=!1}show(){this._conversationsManager?this._conversationsManager.show():rc.warn(`Conversations not loaded yet.`)}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.Xo&&!Me(this._conversationsManager)}isVisible(){var e;return(e=this._conversationsManager?.isVisible())!=null&&e}sendMessage(e,t,n){var r=this;return le((function*(){return r._conversationsManager?r._conversationsManager.sendMessage(e,t,n):(rc.warn(ic),null)}))()}getMessages(e,t){var n=this;return le((function*(){return n._conversationsManager?n._conversationsManager.getMessages(e,t):(rc.warn(ic),null)}))()}markAsRead(e){var t=this;return le((function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(rc.warn(ic),null)}))()}getTickets(e){var t=this;return le((function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(rc.warn(ic),null)}))()}requestRestoreLink(e){var t=this;return le((function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(rc.warn(ic),null)}))()}restoreFromToken(e){var t=this;return le((function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(rc.warn(ic),null)}))()}restoreFromUrlToken(){var e=this;return le((function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(rc.warn(ic),null)}))()}getCurrentTicketId(){return this._conversationsManager?.getCurrentTicketId()??null}getWidgetSessionId(){return this._conversationsManager?.getWidgetSessionId()??null}ln(){var e;(e=this._conversationsManager)==null||e.setIdentity()}hn(){var e;(e=this._conversationsManager)==null||e.clearIdentity()}}},{logs:class{constructor(e){var t;this.na=!1,this.sa=!1,this.Gt=kn(`[logs]`),this.oa=[],this.aa=0,this.ua=0,this.la=!1,this._instance=e,this._instance&&(t=this._instance.config.logs)!=null&&t.captureConsoleLogs&&(this.na=!0)}initialize(){this.loadIfEnabled()}onRemoteConfig(e){var t=e.logs?.captureConsoleLogs;!L(t)&&t&&(this.na=!0,this.loadIfEnabled())}reset(){this.oa=[],this.qr&&=(clearTimeout(this.qr),void 0),this.aa=0,this.ua=0,this.la=!1}loadIfEnabled(){if(this.na&&!this.sa){var e=M?.__PosthogExtensions__;if(e){var t=e.loadExternalDependency;t?t(this._instance,`logs`,(t=>{var n;t||(n=e.logs)==null||!n.initializeLogs?this.Gt.error(`Could not load logs script`,t):(e.logs.initializeLogs(this._instance),this.sa=!0)})):this.Gt.error(Dr)}else this.Gt.error(`PostHog Extensions not found.`)}}captureLog(e){if(this._instance.is_capturing())if(e&&e.body){var t=this._instance.config.logs?.flushIntervalMs??3e3,n=this._instance.config.logs?.maxLogsPerInterval??1e3,r=Date.now();if(t>r-this.ua||(this.ua=r,this.aa=0,this.la=!1),n>this.aa){this.aa++;var i=function(e,t){var{text:n,number:r}=Kt[e.level||`info`]||qt,i=String(Date.now())+`000000`,a={};t.distinctId&&(a.posthogDistinctId=t.distinctId),t.sessionId&&(a.sessionId=t.sessionId),t.currentUrl&&(a[`url.full`]=t.currentUrl),t.screenName&&(a[`screen.name`]=t.screenName),t.appState&&(a[`app.state`]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(a.feature_flags=t.activeFeatureFlags);var o=N({},a,e.attributes||{}),s={timeUnixNano:i,observedTimeUnixNano:i,severityNumber:r,severityText:n,body:{stringValue:e.body},attributes:Yt(o)};return e.trace_id&&(s.traceId=e.trace_id),e.span_id&&(s.spanId=e.span_id),I(e.trace_flags)||(s.flags=e.trace_flags),s}(e,this.ha());this.oa.push({record:i}),(this._instance.config.logs?.maxBufferSize??100)>this.oa.length?this.ca():this.flushLogs()}else this.la||=(this.Gt.warn(`captureLog dropping logs: exceeded `+n+` logs per `+t+`ms`),!0)}else this.Gt.warn(`captureLog requires a body`)}get logger(){return this.da||={trace:(e,t)=>this.captureLog({body:e,level:`trace`,attributes:t}),debug:(e,t)=>this.captureLog({body:e,level:`debug`,attributes:t}),info:(e,t)=>this.captureLog({body:e,level:`info`,attributes:t}),warn:(e,t)=>this.captureLog({body:e,level:`warn`,attributes:t}),error:(e,t)=>this.captureLog({body:e,level:`error`,attributes:t}),fatal:(e,t)=>this.captureLog({body:e,level:`fatal`,attributes:t})},this.da}flushLogs(e){if(this.qr&&=(clearTimeout(this.qr),void 0),this.oa.length!==0){var t=this.oa;this.oa=[];var n=this._instance.config.logs,r=N({"service.name":n?.serviceName||`unknown_service`},n?.environment&&{"deployment.environment":n.environment},n?.serviceVersion&&{"service.version":n.serviceVersion},n?.resourceAttributes),i=function(e,t,n,r){return{resourceLogs:[{resource:{attributes:Yt(t)},scopeLogs:[{scope:{name:n,version:r},logRecords:e}]}]}}(t.map((e=>e.record)),r,se.LIB_NAME,se.LIB_VERSION),a=this._instance.requestRouter.endpointFor(`api`,`/i/v1/logs`)+`?token=`+encodeURIComponent(this._instance.config.token);this._instance.Bi({method:`POST`,url:a,data:i,compression:`best-available`,batchKey:`logs`,transport:e})}}ca(){this.qr||=setTimeout((()=>{this.qr=void 0,this.flushLogs()}),this._instance.config.logs?.flushIntervalMs??3e3)}ha(){var e,t={};if(t.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var{sessionId:n}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);t.sessionId=n}if(M!=null&&(e=M.location)!=null&&e.href&&(t.currentUrl=M.location.href),this._instance.featureFlags){var r=this._instance.featureFlags.getFlags();r&&r.length>0&&(t.activeFeatureFlags=r)}return t}}});Po.__defaultExtensionClasses=N({},hc);var gc,_c=(gc=xo[Oo]=new Po,function(){function e(){e.done||(e.done=!0,ko=!1,Br(xo,(function(e){e._dom_loaded()})))}A!=null&&A.addEventListener?A.readyState===`complete`?e():Jr(A,`DOMContentLoaded`,e,{capture:!1}):D&&R.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),gc),vc=({client:e})=>{let[t,n]=b(!1),[r,i]=b({x:0,y:0}),[a,o]=b(0),s=m(null),c=window.innerWidth<768,l=e.plugin.getUserInfo().context_menu_on_select,u=e.plugin.getPluginInfo().installedPlugins.flatMap(e=>e.context_menu_actions).filter(Boolean),d=(e,t=0)=>{let n=window.getSelection();if(!n||!e)return{x:0,y:0,text:e};let r=n.getRangeAt(0).getBoundingClientRect();return{x:r.left+r.width/2-t/2,y:r.bottom+12,text:e}};return g(()=>{e.event.on(`global.contextMenu.createActions`,({data:e})=>{u.push(...e.actions)})},[]),g(()=>{t&&s.current&&o(s.current.offsetWidth)},[t]),g(()=>{let e=e=>{let n=window.getSelection()?.toString().trim();t&&n===r.text||i(c&&n?d(n,a):{x:e.clientX,y:e.clientY,text:n})},o=e=>{var r;let o=window.getSelection()?.toString().trim();if(s.current&&s.current.contains(e.target))return;let u=e.target;if(u&&(u.tagName===`TEXTAREA`||u.tagName===`INPUT`&&u.type===`text`)){n(!1);return}e.button===0&&t?(n(!1),(r=window.getSelection())==null||r.removeAllRanges()):o&&(l||e.button===2)?(e.button===2&&e.preventDefault(),i(c?d(o,a):{x:e.clientX,y:e.clientY,text:o}),n(!0)):n(!1)},u=()=>{let e=window.getSelection()?.toString().trim();!e&&t?n(!1):e&&t&&c&&i(d(e,a))};return document.addEventListener(`mouseup`,o),window.addEventListener(`mousemove`,e),document.addEventListener(`contextmenu`,o),document.addEventListener(`selectionchange`,u),()=>{document.removeEventListener(`mouseup`,o),window.removeEventListener(`mousemove`,e),document.removeEventListener(`contextmenu`,o),document.removeEventListener(`selectionchange`,u)}},[l,t,r.text]),t?w(`div`,{ref:s,className:`fixed bg-gray-400 dark:bg-gray-700 shadow-lg border border-gray-400 rounded-md overflow-hidden dark:text-white z-50`,style:{top:r.y,left:r.x},children:u.map((t,i)=>w(yc,{iconUrl:t.iconUrl,text:t.text,onClick:()=>{var i;n(!1),(i=window.getSelection())==null||i.removeAllRanges(),e.event.emitSidebarAction(t.plugin_id,t.action_key,r.text)}},i))}):null};function yc(e){return T(`button`,{onClick:e.onClick,className:`px-2 md:px-4 py-2 text-left hover:bg-gray-500 dark:hover:bg-gray-600 w-full flex flex-row`,children:[e.iconUrl&&w(`span`,{className:`flex-grow`,children:w(`img`,{src:e.iconUrl,alt:e.text,className:`w-4 h-4 mr-2`})}),w(`span`,{className:`flex-grow`,children:e.text})]})}function bc(e=`system`,t=!1){let n=e===`system`?xc():e===`dark`;if(t)return{isDark:n,theme:e,isDisabled:t};let r=document.documentElement;return r.dataset.theme=n?`dark`:`light`,r.style.colorScheme=n?`dark`:`light`,r.classList[n?`add`:`remove`](`dark`),document.querySelector(`#root`).classList.add(`dark:bg-gradient-to-br`,`dark:from-gray-900`,`dark:to-gray-800`,`dark:text-white`,`min-h-screen`,`bg-fixed`),{isDark:n,theme:e,isDisabled:t}}function xc(){return window.matchMedia(`(prefers-color-scheme: dark)`).matches}S();var Sc=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},Cc=_(null),wc=({children:e,pluginId:t,client:n,userInfo:r,settings:i})=>{let o=!!n,[s,l]=b(n??null),[u,d]=b(!1),[f,p]=b(null),[m,h]=b(void 0),[_,v]=b(r??null);g(()=>{o&&(n&&l(n),r&&v(r))},[n,r,o]),bc(m,o),g(()=>{_c.__loaded||_c.init(`phc_l4vPVZxtjlcQUDivoh5TaUL6oDe8K2lig89405cGnsv`,{cookieless_mode:`always`,api_host:`https://c.rimori.se`,defaults:`2026-01-30`,loaded:e=>{e.register({application:`frontend`,pluginId:t})}})},[]);let y=f===`sidebar`,x=f===`settings`;return g(()=>{if(o)return;Dc(t);let e=window===window.parent;e&&!u&&a.getInstance().then(e=>{e.needsLogin().then(t=>d(t?e:!0))}),(!e&&!s||e&&u===!0)&&c.getInstance(t).then(t=>{l(t),v(t.plugin.getUserInfo()),e||(h(t.plugin.theme),p(t.plugin.applicationMode),t.event.emit(`self.rimori.triggerInitFinished`))})},[t,u,s,o]),g(()=>{_?.user_id&&_c.identify(_.user_id)},[_?.user_id]),g(()=>{if(!s)return;let e=s.plugin.onRimoriInfoUpdate(e=>{v(e.profile)});return()=>e()},[s]),g(()=>{if(!s||y||o)return;let e=history.pushState;history.pushState=(...t)=>{let n=e.apply(history,t);return s.event.emit(`session.triggerUrlChange`,{url:location.hash}),n}},[s,y,o]),g(()=>{if(!s||o)return;let e=()=>{let e=document.documentElement.scrollHeight>window.innerHeight;s.event.emit(`session.triggerScrollbarChange`,{hasScrollbar:e})};e(),window.addEventListener(`resize`,e);let t=new ResizeObserver(()=>e());return t.observe(document.body),()=>{window.removeEventListener(`resize`,e),t.disconnect()}},[s,o]),u instanceof a?w(Oc,{onLogin:(e,t)=>Sc(void 0,void 0,void 0,function*(){(yield u.login(e,t))&&d(!0)})}):!s||!_?``:T(Cc.Provider,{value:{client:s,userInfo:_},children:[!i?.disableContextMenu&&!y&&!x&&w(vc,{client:s}),e]})},Tc=()=>{let e=u(Cc);if(e===null)throw Error(`useRimori must be used within an PluginProvider`);return Object.assign(e.client,{userInfo:e.userInfo})};function Ec(e){let t=window.location.hash.split(`?`);if(t.length>1){let n=new URLSearchParams(t[1]).get(e);if(n)return n}return new URL(window.location.href).searchParams.get(e)}function Dc(e){let t=Ec(`applicationMode`)===`sidebar`;r.getInstance(`Plugin EventBus `+e+` `+(t?`sidebar`:`main`))}function Oc({onLogin:e}){let[t,n]=b(``),[r,i]=b(``);return w(`div`,{style:{position:`fixed`,inset:0,display:`flex`,alignItems:`center`,justifyContent:`center`,backgroundColor:`rgba(0, 0, 0, 0.5)`},children:T(`div`,{style:{backgroundColor:`#343534`,padding:`1rem`,borderRadius:`0.5rem`,width:`500px`,flexDirection:`column`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:[w(`p`,{style:{fontSize:`2rem`,fontWeight:`bold`,marginBottom:`1rem`,textAlign:`center`},children:`Rimori Login Required`}),w(`p`,{style:{marginBottom:`1rem`,textAlign:`center`},children:`Please login with your Rimori developer account for this plugin to be able to access the Rimori platform the same way it would when being deployed.`}),w(`input`,{style:{marginBottom:`1rem`,width:`100%`,padding:`0.5rem`,borderRadius:`0.5rem`,border:`none`,backgroundColor:`#444444`},type:`email`,placeholder:`Email`,onChange:e=>n(e.target.value)}),w(`input`,{style:{marginBottom:`1rem`,width:`100%`,padding:`0.5rem`,borderRadius:`0.5rem`,border:`none`,backgroundColor:`#444444`},type:`password`,placeholder:`Password`,onChange:e=>i(e.target.value)}),w(`button`,{style:{marginBottom:`1rem`,width:`100%`,padding:`0.5rem`,borderRadius:`0.5rem`,border:`none`,backgroundColor:`#928358`},onClick:()=>{e(t,r)},children:`Login`})]})})}S();function kc(e,t){let[n,r]=x.useState([]),[i,a]=x.useState(!1),{ai:o}=Tc(),s=x.useRef({prompt:t?.prompt,promptVariables:t?.promptVariables}),c=x.useRef(!1);return{messages:n,append:i=>{if(c.current)return;let l=[...n.filter(e=>typeof e.content==`string`&&e.content.length>0||e.toolCalls&&e.toolCalls.length>0),...i];r(l),a(!0),c.current=!0;let u=s.current.promptVariables??t?.promptVariables,d=s.current.prompt??t?.prompt,f=()=>{c.current=!1,a(!1)};o.getStreamedText({messages:l,onMessage:(e,t,n,i)=>{a(!n),r(n=>{let r=n.findIndex(t=>t.id===e);if(r!==-1){let e=n.slice();return e[r]=Object.assign(Object.assign({},n[r]),{content:t,toolCalls:i}),e}return[...n,{id:e,role:`assistant`,content:t,toolCalls:i}]}),n&&(c.current=!1)},tools:e,prompt:d,variables:u}).then(f,e=>{console.error(`useChat stream failed`,e),f()})},init:x.useCallback(e=>{s.current=Object.assign(Object.assign({},s.current),e)},[]),isLoading:i,setMessages:r,lastMessage:n[n.length-1]}}S();var Ac=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function jc(e){let t=Tc(),[n,r]=b(e),[i,a]=b(!0);return g(()=>{let n=!1;return t.plugin.getSettings(e).then(e=>{n||(r(e),a(!1))}),()=>{n=!0}},[]),{settings:n,isLoading:i,setSettings:h(e=>Ac(this,void 0,void 0,function*(){let i=Object.assign(Object.assign({},n),e);r(i),yield t.plugin.setSettings(i)}),[n,t])}}S();var Mc=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function Nc(e){let{actionKey:t,skillCategory:n,initialData:r,onAction:i}=e,{event:a,exercise:o}=Tc(),[s,c]=b(!1),[l,u]=b(null),d=m(r??{}),f=m(null),p=m(!1),_=m(i);return y(()=>{_.current=i}),g(()=>{r&&(d.current=Object.assign({},r))},[]),g(()=>{let e=a.onMainPanelAction(e=>Mc(this,void 0,void 0,function*(){console.log(`[useExerciseTracker:${t}] Dashboard action received:`,e),p.current=!0,f.current=Date.now(),c(!0),u(e),d.current=r??{},_.current&&(yield _.current(e)),console.log(`[useExerciseTracker:${t}] onAction complete, exercise active`)}),t);return()=>e.off()},[t]),{isActive:s,actionParams:l,start:h(e=>Mc(this,void 0,void 0,function*(){console.log(`[useExerciseTracker:${t}] start() called (self-initiated)`,e),p.current=!1,yield o.start({actionKey:t,knowledgeId:e?.knowledgeId}),f.current=Date.now(),d.current=r??{},c(!0),console.log(`[useExerciseTracker:${t}] start() complete, session token acquired`)}),[t,o,r]),ready:h(()=>{f.current=Date.now()},[]),micro:h(e=>{let t={type:`micro`,skillCategory:n,accomplishmentKeyword:e.accomplishmentKeyword,description:e.description,meta:e.meta};a.emitAccomplishment(t)},[a,n]),track:h(e=>{d.current=Object.assign(Object.assign({},d.current),e)},[]),end:h(e=>{let r=f.current?Date.now()-f.current:0,i=Math.max(1,Math.round(r/6e4));console.log(`[useExerciseTracker:${t}] end() — keyword=${e.accomplishmentKeyword}, errorRatio=${e.errorRatio}, duration=${i}min, trackedData=`,d.current);let o=[...Object.entries(d.current).map(([e,t])=>({key:e,value:t,description:e})),...e.meta??[]],s={type:`macro`,skillCategory:n,accomplishmentKeyword:e.accomplishmentKeyword,description:e.description,errorRatio:e.errorRatio,durationMinutes:i,meta:o.length>0?o:void 0};a.emitAccomplishment(s),console.log(`[useExerciseTracker:${t}] Macro accomplishment emitted`),c(!1),u(null),f.current=null},[t,a,n])}}S();function Pc(e){let t=Tc(),n=t.userInfo.subscription_tier;return{hasAccess:i.indexOf(n)>=i.indexOf(e),requestUpgrade:h(()=>t.plugin.requestUpgrade(e),[t,e])}}S();var Fc={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Ic=x.createContext&&x.createContext(Fc);S();var Lc=[`attr`,`size`,`title`];function Rc(e,t){if(e==null)return{};var n=zc(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function zc(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function Bc(){return Bc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Bc.apply(this,arguments)}function Vc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Hc(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Vc(Object(n),!0).forEach(function(t){Uc(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Vc(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Uc(e,t,n){return t=Wc(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Wc(e){var t=Gc(e,`string`);return typeof t==`symbol`?t:t+``}function Gc(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Kc(e){return e&&e.map((e,t)=>x.createElement(e.tag,Hc({key:t},e.attr),Kc(e.child)))}function B(e){return t=>x.createElement(qc,Bc({attr:Hc({},e.attr)},t),Kc(e.child))}function qc(e){var t=t=>{var{attr:n,size:r,title:i}=e,a=Rc(e,Lc),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),x.createElement(`svg`,Bc({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:Hc(Hc({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&x.createElement(`title`,null,i),e.children)};return Ic===void 0?t(Fc):x.createElement(Ic.Consumer,null,e=>t(e))}function Jc(e){return B({tag:`svg`,attr:{viewBox:`0 0 384 512`},child:[{tag:`path`,attr:{d:`M333.49 238a122 122 0 0 0 27-65.21C367.87 96.49 308 32 233.42 32H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h31.87v288H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h209.32c70.8 0 134.14-51.75 141-122.4 4.74-48.45-16.39-92.06-50.83-119.6zM145.66 112h87.76a48 48 0 0 1 0 96h-87.76zm87.76 288h-87.76V288h87.76a56 56 0 0 1 0 112z`},child:[]}]})(e)}function Yc(e){return B({tag:`svg`,attr:{viewBox:`0 0 640 512`},child:[{tag:`path`,attr:{d:`M278.9 511.5l-61-17.7c-6.4-1.8-10-8.5-8.2-14.9L346.2 8.7c1.8-6.4 8.5-10 14.9-8.2l61 17.7c6.4 1.8 10 8.5 8.2 14.9L293.8 503.3c-1.9 6.4-8.5 10.1-14.9 8.2zm-114-112.2l43.5-46.4c4.6-4.9 4.3-12.7-.8-17.2L117 256l90.6-79.7c5.1-4.5 5.5-12.3.8-17.2l-43.5-46.4c-4.5-4.8-12.1-5.1-17-.5L3.8 247.2c-5.1 4.7-5.1 12.8 0 17.5l144.1 135.1c4.9 4.6 12.5 4.4 17-.5zm327.2.6l144.1-135.1c5.1-4.7 5.1-12.8 0-17.5L492.1 112.1c-4.8-4.5-12.4-4.3-17 .5L431.6 159c-4.6 4.9-4.3 12.7.8 17.2L523 256l-90.6 79.7c-5.1 4.5-5.5 12.3-.8 17.2l43.5 46.4c4.5 4.9 12.1 5.1 17 .6z`},child:[]}]})(e)}function Xc(e){return B({tag:`svg`,attr:{viewBox:`0 0 320 512`},child:[{tag:`path`,attr:{d:`M320 48v32a16 16 0 0 1-16 16h-62.76l-80 320H208a16 16 0 0 1 16 16v32a16 16 0 0 1-16 16H16a16 16 0 0 1-16-16v-32a16 16 0 0 1 16-16h62.76l80-320H112a16 16 0 0 1-16-16V48a16 16 0 0 1 16-16h192a16 16 0 0 1 16 16z`},child:[]}]})(e)}function Zc(e){return B({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M448 48v32a16 16 0 0 1-16 16h-48v368a16 16 0 0 1-16 16h-32a16 16 0 0 1-16-16V96h-32v368a16 16 0 0 1-16 16h-32a16 16 0 0 1-16-16V352h-32a160 160 0 0 1 0-320h240a16 16 0 0 1 16 16z`},child:[]}]})(e)}function Qc(e){return B({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm115.7 272l-176 101c-15.8 8.8-35.7-2.5-35.7-21V152c0-18.4 19.8-29.8 35.7-21l176 107c16.4 9.2 16.4 32.9 0 42z`},child:[]}]})(e)}function $c(e){return B({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm96 328c0 8.8-7.2 16-16 16H176c-8.8 0-16-7.2-16-16V176c0-8.8 7.2-16 16-16h160c8.8 0 16 7.2 16 16v160z`},child:[]}]})(e)}function el(e){return B({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M496 224H293.9l-87.17-26.83A43.55 43.55 0 0 1 219.55 112h66.79A49.89 49.89 0 0 1 331 139.58a16 16 0 0 0 21.46 7.15l42.94-21.47a16 16 0 0 0 7.16-21.46l-.53-1A128 128 0 0 0 287.51 32h-68a123.68 123.68 0 0 0-123 135.64c2 20.89 10.1 39.83 21.78 56.36H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h480a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm-180.24 96A43 43 0 0 1 336 356.45 43.59 43.59 0 0 1 292.45 400h-66.79A49.89 49.89 0 0 1 181 372.42a16 16 0 0 0-21.46-7.15l-42.94 21.47a16 16 0 0 0-7.16 21.46l.53 1A128 128 0 0 0 224.49 480h68a123.68 123.68 0 0 0 123-135.64 114.25 114.25 0 0 0-5.34-24.36z`},child:[]}]})(e)}S();var tl=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},nl=[.8,.9,1,1.1,1.2,1.5],rl=!1,il=({text:e,voice:t,language:n,hide:r,playListenerEvent:i,initialSpeed:a=1,playOnMount:s=!1,enableSpeedAdjustment:c=!1,cache:l=!0,size:u=`25px`,ttsInstructions:d,disableDialect:f=!1})=>{let[p,h]=b(null),[_,v]=b(a),[x,S]=b(!1),[C,E]=b(!1),{ai:ee,userInfo:D}=Tc(),O=m(null),k=m(null);g(()=>(p&&h(null),()=>{p&&URL.revokeObjectURL(p)}),[e]);let A=()=>tl(void 0,void 0,void 0,function*(){E(!0);let r=d??(!f&&D?.dialect?`Speak with a ${D.dialect} accent and pronunciation.`:void 0),i=yield ee.getVoice(e,t||(n?`aws_default`:`openai_alloy`),1,n,l,r);h(URL.createObjectURL(i)),E(!1)});g(()=>{if(!p||!x){O.current&&=(O.current.pause(),O.current.currentTime=0,null);return}O.current&&(O.current.pause(),O.current.currentTime=0);let e=new Audio(p);return O.current=e,e.playbackRate=_,e.play().then(()=>{e.onended=()=>{S(!1),rl=!1,O.current=null}}).catch(e=>{console.warn(`Error playing audio:`,e),S(!1),O.current=null}),()=>{O.current&&=(O.current.pause(),O.current.currentTime=0,null)}},[p,x,_]),g(()=>()=>{O.current&&=(O.current.pause(),O.current.currentTime=0,null),S(!1)},[]),g(()=>()=>{p&&URL.revokeObjectURL(p)},[p]);let j=()=>{!x&&!p?A().then(()=>S(!0)):S(e=>!e)},te=m(j);return y(()=>{te.current=j}),g(()=>i?(k.current=o.on(i,()=>te.current()),()=>{k.current&&=(k.current.off(),null)}):void 0,[i]),g(()=>{!s||rl||(rl=!0,j())},[s]),w(`div`,{className:`group relative`,children:T(`div`,{className:`flex flex-row items-end`,children:[!r&&w(`button`,{className:`text-gray-400`,onClick:j,disabled:C,children:w(C?al:x?$c:Qc,{size:u})}),c&&T(`div`,{className:`ml-1 opacity-0 group-hover:opacity-100 transition-opacity duration-300 flex flex-row text-sm text-gray-500`,children:[w(`span`,{className:`pr-1`,children:`Speed: `}),w(`select`,{value:_,className:`appearance-none cursor-pointer pr-0 p-0 rounded shadow leading-tight focus:outline-none focus:bg-gray-800 focus:ring bg-transparent border-0`,onChange:e=>v(parseFloat(e.target.value)),disabled:C,children:nl.map(e=>w(`option`,{value:e,children:e},e))})]})]})})},al=({text:e,className:t,size:n=`30px`})=>T(`div`,{className:`flex items-center space-x-2 pl-1 `+t,children:[T(`svg`,{style:{width:n,height:n},className:`animate-spin -ml-1 h-5 w-5 text-white`,xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,children:[w(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),w(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`})]}),e&&w(`span`,{className:``,children:e})]});function ol(e){return B({tag:`svg`,attr:{viewBox:`0 0 384 512`},child:[{tag:`path`,attr:{d:`M192 0C139 0 96 43 96 96l0 160c0 53 43 96 96 96s96-43 96-96l0-160c0-53-43-96-96-96zM64 216c0-13.3-10.7-24-24-24s-24 10.7-24 24l0 40c0 89.1 66.2 162.7 152 174.4l0 33.6-48 0c-13.3 0-24 10.7-24 24s10.7 24 24 24l72 0 72 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-48 0 0-33.6c85.8-11.7 152-85.3 152-174.4l0-40c0-13.3-10.7-24-24-24s-24 10.7-24 24l0 40c0 70.7-57.3 128-128 128s-128-57.3-128-128l0-40z`},child:[]}]})(e)}function sl(e){return B({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M304 48a48 48 0 1 0 -96 0 48 48 0 1 0 96 0zm0 416a48 48 0 1 0 -96 0 48 48 0 1 0 96 0zM48 304a48 48 0 1 0 0-96 48 48 0 1 0 0 96zm464-48a48 48 0 1 0 -96 0 48 48 0 1 0 96 0zM142.9 437A48 48 0 1 0 75 369.1 48 48 0 1 0 142.9 437zm0-294.2A48 48 0 1 0 75 75a48 48 0 1 0 67.9 67.9zM369.1 437A48 48 0 1 0 437 369.1 48 48 0 1 0 369.1 437z`},child:[]}]})(e)}S();var cl=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},ll=v(({onVoiceRecorded:e,iconSize:t,className:n,disabled:r,loading:i,onRecordingStatusChange:a,enablePushToTalk:o=!1,language:s},c)=>{let[u,d]=b(!1),[p,h]=b(!1),_=m(null),{ai:v,plugin:y}=Tc(),x=m(e);g(()=>{x.current=e},[e]);let S=()=>cl(void 0,void 0,void 0,function*(){try{_.current||=new l(y.pluginId),yield _.current.startRecording(),d(!0),a(!0)}catch(e){console.error(`Failed to start recording:`,e)}}),C=()=>cl(void 0,void 0,void 0,function*(){try{if(_.current&&u){let e=yield _.current.stopRecording();h(!0);let t=yield v.getTextFromVoice(e.recording,s);h(!1),x.current(t)}}catch(e){console.error(`Failed to stop recording:`,e)}finally{d(!1),a(!1)}});f(c,()=>({startRecording:S,stopRecording:C}));let T=m(!1);return g(()=>{if(!o)return;let e=e=>cl(void 0,void 0,void 0,function*(){e.code===`Space`&&!T.current&&(T.current=!0,yield S())}),t=e=>{e.code===`Space`&&T.current&&(T.current=!1,C())};return window.addEventListener(`keydown`,e),window.addEventListener(`keyup`,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`keyup`,t)}},[o]),w(`button`,{className:`flex flex-row justify-center items-center rounded-full mx-auto disabled:opacity-50 `+n,onClick:u?C:S,disabled:r||i||p,children:i||p?w(sl,{className:`animate-spin`}):w(ol,{size:t,className:u?`text-red-600`:``})})});S();function ul({imageUrl:e,className:t,isDarkTheme:n=!1,width:r=`150px`,loudnessRef:i}){let a=m(null),o=m(0),s=m(null),c=(e,t,r,i)=>{if(t&&e){e.clearRect(0,0,t.width,t.height);let a=Math.min(t.width,t.height)/3,o=t.width/2,s=t.height/2,c=a+i/2.5;e.beginPath(),e.arc(o,s,c,0,Math.PI*2,!0),e.strokeStyle=n?`rgba(255, 255, 255, 0.5)`:`rgba(0, 0, 0, 0.5)`,e.lineWidth=5,e.stroke(),e.save(),e.beginPath(),e.arc(o,s,a,0,Math.PI*2,!0),e.closePath(),e.clip(),e.drawImage(r,o-a,s-a,a*2,a*2),e.restore(),e.beginPath(),e.arc(o,s,a,0,Math.PI*2,!0),e.strokeStyle=n?`rgba(255, 255, 255, 0.9)`:`rgba(0, 0, 0, 0.9)`,e.lineWidth=5,e.stroke()}};return g(()=>{let t=a.current;if(t){let n=t.getContext(`2d`);if(n){let r=new Image;r.src=e;let a=!0;return r.onload=()=>{if(!a)return;c(n,t,r,0);let e=()=>{let a=i?.current??0;o.current>a?o.current=Math.max(a,o.current-.06*o.current):o.current=a,c(n,t,r,o.current),s.current=requestAnimationFrame(e)};s.current=requestAnimationFrame(e)},()=>{a=!1,s.current&&cancelAnimationFrame(s.current)}}}},[e]),w(`canvas`,{ref:a,className:t,width:500,height:500,style:{width:r}})}function dl(e){let t=[];return e.userMessage&&t.push({id:`1`,role:`user`,content:e.userMessage}),e.assistantMessage&&t.push({id:`2`,role:`assistant`,content:e.assistantMessage}),t}S();function fl({avatarImageUrl:e,voiceId:t,agentTools:n,autoStartConversation:r,children:i,circleSize:a=`300px`,className:o,cache:c=!1,prompt:l,promptVariables:u,onMessage:f,hideCircleAvatar:p=!1,sttLanguage:h}){let{ai:_,plugin:v,userInfo:y}=Tc(),{isDark:x}=bc(v.theme,!0),[S,C]=b(!1),[E,ee]=b(!1),D=m(0),O=y?.dialect?`Speak with a ${y.dialect} accent and pronunciation.`:void 0,k=d(()=>new s((...e)=>_.getVoice(...e),t,c),[t,_,c]);g(()=>{k.setInstructions(O)},[k,O]);let{messages:A,append:j,isLoading:te,lastMessage:ne,setMessages:re}=kc(n,{prompt:l,promptVariables:u});g(()=>{console.log(`messages`,A),f?.(A)},[A,f]),g(()=>{te||ee(!1)},[te]);let ie=m(!1);return g(()=>{t&&(k.setOnLoudnessChange(e=>{D.current=e}),k.setOnEndOfSpeech(()=>C(!1)),r&&(ie.current||(ie.current=!0,re(dl(r)),r.assistantMessage?k.handleNewText(r.assistantMessage,te):r.userMessage&&j([{role:`user`,content:r.userMessage,id:A.length.toString()}]))))},[r,t]),g(()=>()=>{k.cleanup()},[k]),g(()=>{ne?.role===`assistant`&&(k.handleNewText(ne.content,te),ne.toolCalls&&(C(!1),ee(!1)))},[ne,te]),T(`div`,{className:`md:pb-8 ${o||``}`,children:[!p&&w(ul,{width:a,className:`mx-auto`,imageUrl:e,isDarkTheme:x,loudnessRef:D}),i,w(ll,{iconSize:`30`,className:`w-16 h-16 shadow-lg rounded-full bg-gray-400 dark:bg-gray-800`,disabled:S,loading:E,enablePushToTalk:!0,language:h,onVoiceRecorded:e=>{C(!0),j([{role:`user`,content:`Message(`+Math.floor((A.length+1)/2)+`): `+e,id:A.length.toString()}])},onRecordingStatusChange:e=>!e&&ee(!0)})]})}S();function pl(){let{plugin:e}=Tc(),[t,n]=b(null),[r,i]=b(0);return g(()=>{e.getTranslator().then(e=>{n(e),e.onLanguageChanged(()=>{i(e=>e+1)})})},[e]),{t:h((e,n)=>t&&t.t(e,n)||``,[t,r]),ready:t!==null}}function ml(e){return B({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{d:`M5.536 21.886a1.004 1.004 0 0 0 1.033-.064l13-9a1 1 0 0 0 0-1.644l-13-9A1 1 0 0 0 5 3v18a1 1 0 0 0 .536.886z`},child:[]}]})(e)}S();var hl=0,gl=()=>`ba-${++hl}`;function _l({prompt:e,promptVariables:t,autoStartConversation:n,circleSize:r=`160px`,chatPlaceholder:i,bottomAction:a,className:o,voiceSpeed:c=1,tools:l,showName:u=!1}){let{ai:f,plugin:p,userInfo:h}=Tc(),_=p.ttsEnabled,{isDark:v}=bc(p.theme,!0),y=h.study_buddy,x=h?.dialect,S=x?`Speak with a ${x} accent and pronunciation.`:void 0,[C,E]=b(``),[ee,D]=b([]),[O,k]=b(!1),[A,j]=b(!1),te=m(0),ne=m(_);g(()=>{ne.current=_,!_&&A&&(re.stop(),j(!1))},[_]);let re=d(()=>new s((...e)=>f.getVoice(...e),y?.voiceId??``),[y?.voiceId,f]);g(()=>{re.setInstructions(S)},[re,S]),g(()=>(re.setVoiceSpeed(c),re.setOnLoudnessChange(e=>{te.current=e}),re.setOnEndOfSpeech(()=>j(!1)),()=>re.cleanup()),[re]);let ie=e=>e.map(e=>({role:e.role,content:e.content})),ae=n=>{k(!0),f.getStreamedText({messages:ie(n),onMessage:(e,t,n)=>{k(!n);let r=`ai-${e}`;D(e=>{let n=e[e.length-1];return n?.id===r?[...e.slice(0,-1),Object.assign(Object.assign({},n),{content:t})]:[...e,{id:r,role:`assistant`,content:t}]}),ne.current&&(re.handleNewText(t,!n),t&&j(!0))},tools:l,prompt:e,variables:t})},M=m(!1);if(g(()=>{if(!M.current){if(M.current=!0,n?.assistantMessage)D([{id:`init`,role:`assistant`,content:n.assistantMessage}]),ne.current&&(re.handleNewText(n.assistantMessage,!1),j(!0));else if(n?.userMessage){let e={id:`auto-start`,role:`user`,content:n.userMessage};D([e]),ae([e])}}},[]),!y)return w(`div`,{});let oe=e=>{if(!e.trim()||O)return;let t={id:gl(),role:`user`,content:e},n=[...ee,t];D(n),ae(n)},se=[...ee].filter(e=>e.role===`assistant`).pop();return T(`div`,{className:`flex flex-col items-center ${o||``}`,children:[w(ul,{width:r,imageUrl:y.avatarUrl,isDarkTheme:v,loudnessRef:te,className:`mx-auto`}),u&&w(`div`,{className:`flex items-center gap-2`,children:w(`span`,{className:`text-3xl font-semibold`,children:y.name})}),!p.ttsEnabled&&ee.length>1?w(`div`,{className:`w-full rounded-xl bg-gray-200/70 dark:bg-gray-800/70 px-4 py-3 text-sm text-gray-800 dark:text-gray-200 leading-relaxed border border-gray-300/40 dark:border-gray-700/40 mt-4`,children:!se?.content&&O?T(`span`,{className:`inline-flex gap-1 py-0.5`,children:[w(`span`,{className:`w-1.5 h-1.5 rounded-full bg-gray-400 animate-bounce`}),w(`span`,{className:`w-1.5 h-1.5 rounded-full bg-gray-400 animate-bounce`,style:{animationDelay:`0.15s`}}),w(`span`,{className:`w-1.5 h-1.5 rounded-full bg-gray-400 animate-bounce`,style:{animationDelay:`0.3s`}})]}):w(`span`,{className:`whitespace-pre-wrap`,children:se?.content})}):null,T(`div`,{className:`w-full relative mt-4 `+(_?`max-w-md`:``),children:[w(`input`,{value:C,onChange:e=>E(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),oe(C),E(``))},placeholder:i??`Ask ${y.name} a question…`,disabled:O,className:`w-full bg-gray-800/50 border border-gray-700 rounded-lg px-3 py-2 pr-16 text-sm text-gray-200 placeholder:text-gray-500 focus:outline-none focus:ring-1 focus:ring-blue-500 disabled:opacity-60`}),T(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1`,children:[w(ll,{iconSize:`14`,className:`p-1 text-gray-400 hover:text-white transition-colors`,disabled:O,onVoiceRecorded:e=>oe(e),onRecordingStatusChange:()=>{}}),w(`button`,{type:`button`,onClick:()=>{oe(C),E(``)},disabled:O||!C.trim(),className:`p-1 text-gray-400 hover:text-white disabled:opacity-40 transition-colors`,children:w(ml,{className:`w-4 h-4`})})]})]}),a&&w(`div`,{className:`w-full max-w-md border-t border-gray-700/60 pt-3`,children:a})]})}function vl(e){return B({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M20 6 9 17l-5-5`},child:[]}]})(e)}function yl(e){return B({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M15 2H9a1 1 0 0 0-1 1v2c0 .6.4 1 1 1h6c.6 0 1-.4 1-1V3c0-.6-.4-1-1-1Z`},child:[]},{tag:`path`,attr:{d:`M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2M16 4h2a2 2 0 0 1 2 2v2M11 14h10`},child:[]},{tag:`path`,attr:{d:`m17 10 4 4-4 4`},child:[]}]})(e)}function bl(e){return B({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`},child:[]},{tag:`path`,attr:{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`},child:[]}]})(e)}function xl(e){return B({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M4 12h8`},child:[]},{tag:`path`,attr:{d:`M4 18V6`},child:[]},{tag:`path`,attr:{d:`M12 18V6`},child:[]},{tag:`path`,attr:{d:`m17 12 3-2v8`},child:[]}]})(e)}function Sl(e){return B({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M4 12h8`},child:[]},{tag:`path`,attr:{d:`M4 18V6`},child:[]},{tag:`path`,attr:{d:`M12 18V6`},child:[]},{tag:`path`,attr:{d:`M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1`},child:[]}]})(e)}function Cl(e){return B({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M4 12h8`},child:[]},{tag:`path`,attr:{d:`M4 18V6`},child:[]},{tag:`path`,attr:{d:`M12 18V6`},child:[]},{tag:`path`,attr:{d:`M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2`},child:[]},{tag:`path`,attr:{d:`M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2`},child:[]}]})(e)}function wl(e){return B({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`},child:[]},{tag:`path`,attr:{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`},child:[]}]})(e)}function Tl(e){return B({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M12 2v4`},child:[]},{tag:`path`,attr:{d:`m16.2 7.8 2.9-2.9`},child:[]},{tag:`path`,attr:{d:`M18 12h4`},child:[]},{tag:`path`,attr:{d:`m16.2 16.2 2.9 2.9`},child:[]},{tag:`path`,attr:{d:`M12 18v4`},child:[]},{tag:`path`,attr:{d:`m4.9 19.1 2.9-2.9`},child:[]},{tag:`path`,attr:{d:`M2 12h4`},child:[]},{tag:`path`,attr:{d:`m4.9 4.9 2.9 2.9`},child:[]}]})(e)}function El(e){return B({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`15 3 21 3 21 9`},child:[]},{tag:`polyline`,attr:{points:`9 21 3 21 3 15`},child:[]},{tag:`line`,attr:{x1:`21`,x2:`14`,y1:`3`,y2:`10`},child:[]},{tag:`line`,attr:{x1:`3`,x2:`10`,y1:`21`,y2:`14`},child:[]}]})(e)}function Dl(e){return B({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`4 14 10 14 10 20`},child:[]},{tag:`polyline`,attr:{points:`20 10 14 10 14 4`},child:[]},{tag:`line`,attr:{x1:`14`,x2:`21`,y1:`10`,y2:`3`},child:[]},{tag:`line`,attr:{x1:`3`,x2:`10`,y1:`21`,y2:`14`},child:[]}]})(e)}function Ol(e){return B({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z`},child:[]},{tag:`path`,attr:{d:`M20 3v4`},child:[]},{tag:`path`,attr:{d:`M22 5h-4`},child:[]},{tag:`path`,attr:{d:`M4 17v2`},child:[]},{tag:`path`,attr:{d:`M5 18H3`},child:[]}]})(e)}function kl(e){this.content=e}kl.prototype={constructor:kl,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new kl(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new kl(n)},addToStart:function(e,t){return new kl([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new kl(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new kl(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=kl.from(e),e.size?new kl(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=kl.from(e),e.size?new kl(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=kl.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},kl.from=function(e){if(e instanceof kl)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new kl(t)};function Al(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let e=0;i.text[e]==a.text[e];e++)n++;return n}if(i.content.size||a.content.size){let e=Al(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function jl(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=0,t=Math.min(o.text.length,s.text.length);for(;e<t&&o.text[o.text.length-e-1]==s.text[s.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(o.content.size||s.content.size){let e=jl(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}var V=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return Al(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return jl(this,e,t,n)}findIndex(e){if(e==0)return Nl(0,e);if(e==this.size)return Nl(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?Nl(t+1,i):Nl(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};V.empty=new V([],0);var Ml={index:0,offset:0};function Nl(e,t){return Ml.index=e,Ml.offset=t,Ml}function Pl(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!Pl(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!Pl(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var H=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else !n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Pl(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};H.none=[];var Fl=class extends Error{},U=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=Ll(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(Il(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(V.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};U.empty=new U(V.empty,0,0);function Il(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(Il(a.content,t-i-1,n-i-1)))}function Ll(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=Ll(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function Rl(e,t,n){if(n.openStart>e.depth)throw new Fl(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Fl(`Inconsistent open depths`);return zl(e,t,n,0)}function zl(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=zl(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return Wl(a,Kl(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return Wl(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=ql(n,e);return Wl(a,Gl(e,i,o,t,r))}}function Bl(e,t){if(!t.type.compatibleContent(e.type))throw new Fl(`Cannot join `+t.type.name+` onto `+e.type.name)}function Vl(e,t,n){let r=e.node(n);return Bl(r,t.node(n)),r}function Hl(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function Ul(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(Hl(e.nodeAfter,r),a++));for(let e=a;e<o;e++)Hl(i.child(e),r);t&&t.depth==n&&t.textOffset&&Hl(t.nodeBefore,r)}function Wl(e,t){return e.type.checkContent(t),e.copy(t)}function Gl(e,t,n,r,i){let a=e.depth>i&&Vl(e,t,i+1),o=r.depth>i&&Vl(n,r,i+1),s=[];return Ul(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(Bl(a,o),Hl(Wl(a,Gl(e,t,n,r,i+1)),s)):(a&&Hl(Wl(a,Kl(e,t,i+1)),s),Ul(t,n,i,s),o&&Hl(Wl(o,Kl(n,r,i+1)),s)),Ul(r,null,i,s),new V(s)}function Kl(e,t,n){let r=[];return Ul(null,e,n,r),e.depth>n&&Hl(Wl(Vl(e,t,n+1),Kl(e,t,n+1)),r),Ul(t,null,n,r),new V(r)}function ql(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(V.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var Jl=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return H.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Ql(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=Zl.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else Zl.set(t,r=new Yl);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%Xl,i}},Yl=class{constructor(){this.elts=[],this.i=0}},Xl=12,Zl=new WeakMap,Ql=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},$l=Object.create(null),eu=class e{constructor(e,t,n,r=H.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||V.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&Pl(this.attrs,t||e.defaultAttrs||$l)&&H.sameSet(this.marks,n||H.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return U.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new U(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return Rl(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return Jl.resolveCached(this,e)}resolveNoCache(e){return Jl.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),nu(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=V.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=H.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!H.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=V.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};eu.prototype.text=void 0;var tu=class e extends eu{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):nu(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function nu(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var ru=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new iu(t,n);if(r.next==null)return e.empty;let i=au(r);r.next&&r.err(`Unexpected trailing text`);let a=hu(fu(i));return gu(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return V.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
|
|
3
3
|
`)}};ru.empty=new ru(!0);var iu=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function au(e){let t=[];do t.push(ou(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function ou(e){let t=[];do t.push(su(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function su(e){let t=du(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=lu(e,t);else break;return t}function cu(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function lu(e,t){let n=cu(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:cu(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function uu(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function du(e){if(e.eat(`(`)){let t=au(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}else if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=uu(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function fu(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function pu(e,t){return t-e}function mu(e,t){let n=[];return r(t),n.sort(pu);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function hu(e){let t=Object.create(null);return n(mu(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);mu(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new ru(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(pu);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function gu(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function _u(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function vu(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(i===void 0){let t=e[r];if(t.hasDefault)i=t.default;else throw RangeError(`No value supplied for attribute `+r)}n[r]=i}return n}function yu(e,t,n,r){for(let r in t)if(!(r in e))throw RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let n in e){let r=e[n];r.validate&&r.validate(t[n])}}function bu(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new Cu(e,r,t[r]);return n}var xu=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(` `):[],this.attrs=bu(e,n.attrs),this.defaultAttrs=_u(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e==`text`),this.isText=e==`text`}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==ru.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:vu(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new eu(this,this.computeAttrs(e),V.from(t),H.setFrom(n))}createChecked(e=null,t,n){return t=V.from(t),this.checkContent(t),new eu(this,this.computeAttrs(e),t,H.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=V.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(V.empty,!0);return i?new eu(this,e,t.append(i),H.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){yu(this.attrs,e,`node`,this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||=e.slice(0,n);return t?t.length?t:H.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,i)=>r[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function Su(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var Cu=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?Su(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},wu=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=bu(e,r.attrs),this.excluded=null;let i=_u(this.attrs);this.instance=i?new H(this,i):null}create(e=null){return!e&&this.instance?this.instance:new H(this,vu(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){yu(this.attrs,e,`mark`,this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},Tu=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=kl.from(e.nodes),t.marks=kl.from(e.marks||{}),this.nodes=xu.compile(this.spec.nodes,this),this.marks=wu.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=ru.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?Eu(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:Eu(this,n.split(` `))}this.nodeFromJSON=e=>eu.fromJSON(this,e),this.markFromJSON=e=>H.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof xu))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new tu(n,n.defaultAttrs,e,H.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function Eu(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e.marks[i],o=a;if(a)n.push(a);else for(let t in e.marks){let r=e.marks[t];(i==`_`||r.spec.group&&r.spec.group.split(` `).indexOf(i)>-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function Du(e){return e.tag!=null}function Ou(e){return e.style!=null}var ku=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(Du(e))this.tags.push(e);else if(Ou(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new Ru(this,t,!1);return n.addAll(e,H.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Ru(this,t,!0);return n.addAll(e,H.none,t.from,t.to),U.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(Bu(e,n.tag)&&(n.namespace===void 0||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(t===!1)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],a=r.style;if(!(a.indexOf(e)!=0||r.context&&!n.matchesContext(r.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((e.priority==null?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=Vu(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=Vu(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},Au={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},ju={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Mu={ol:!0,ul:!0},Nu=1,Pu=2,Fu=4;function Iu(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?Nu:0)|(t===`full`?Pu:0)}var Lu=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=H.none,this.match=i||(a&Fu?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(V.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Nu)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=V.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(V.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Au.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},Ru=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=Iu(null,t.preserveWhitespace,0)|(n?Fu:0);i=r?new Lu(r.type,r.attrs,H.none,!0,t.topMatch||r.type.contentMatch,a):n?new Lu(null,null,H.none,!0,null,a):new Lu(e.schema.topNodeType,null,H.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&Pu?`full`:this.localPreserveWS||(r.options&Nu)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,`
|
|
4
4
|
`);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;Mu.hasOwnProperty(a)&&this.parser.normalizeLists&&zu(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:ju.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let n,r=this.needsBlock;if(Au.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break out}let o=s&&s.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,s,n,s.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName==`BR`&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
5
5
|
`),t)}ignoreFallback(e,t){e.nodeName==`BR`&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text(`-`),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&=t.match.matchType(e.type);let n=H.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):Hu(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=Iu(e,i,a.options);a.options&Fu&&a.content.length==0&&(o|=Fu);let s=H.none;return n=n.filter(t=>(a.type?a.type.allowsMarkType(t.type):Hu(t.type,e))?(s=t.addToSet(s),!1):!0),this.nodes.push(new Lu(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=Nu);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf(`|`)>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}else{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function zu(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&Mu.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function Bu(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Vu(e){let t={};for(let n in e)t[n]=e[n];return t}function Hu(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||a.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}var Uu=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=Gu(t).createDocumentFragment();let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,a=0;for(;n<i.length&&a<e.marks.length;){let t=e.marks[a];if(!this.marks[t.type.name]){a++;continue}if(!t.eq(i[n][0])||t.type.spec.spanning===!1)break;n++,a++}for(;n<i.length;)r=i.pop()[1];for(;a<e.marks.length;){let n=e.marks[a++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){if(e.isText)return Gu(t).createTextNode(e.text);let{dom:n,contentDOM:r}=Yu(Gu(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError(`Content hole not allowed in a leaf node spec`);this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&Yu(Gu(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return typeof t==`string`?{dom:e.createTextNode(t)}:Yu(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=Wu(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return Wu(e.marks)}};function Wu(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function Gu(e){return e.document||window.document}var Ku=new WeakMap;function qu(e){let t=Ku.get(e);return t===void 0&&Ku.set(e,t=Ju(e)),t}function Ju(e){let t=null;function n(e){if(e&&typeof e==`object`)if(Array.isArray(e))if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}function Yu(e,t,n,r){if(t.nodeType==1)return{dom:t};if(t.dom&&t.dom.nodeType==1)return t;let i=t[0],a;if(typeof i!=`string`)throw RangeError(`Invalid array passed to renderSpec`);if(r&&(a=qu(r))&&a.indexOf(t)>-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;i<t.length;i++){let a=t[i];if(a===0){if(i<t.length-1||i>u)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}else if(typeof a==`string`)c.appendChild(e.createTextNode(a));else{let{dom:t,contentDOM:i}=Yu(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var Xu=65535,Zu=2**16;function Qu(e,t){return e+t*Zu}function $u(e){return e&Xu}function ed(e){return(e-(e&Xu))/Zu}var td=1,nd=2,rd=4,id=8,ad=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&id)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&rd)>0}},od=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=$u(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+ed(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:Qu(o/3,e-s),f=e==s?nd:e==u?td:rd;return(t<0?e!=s:e!=u)&&(f|=id),new ad(a,f,d)}r+=l-c}return n?e+r:new ad(e+r,0,null)}touches(e,t){let n=0,r=$u(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};od.empty=new od([]);var sd=class e{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||=(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||=[],this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new ad(e,r,null)}},cd=Object.create(null),ld=class{getMap(){return od.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=cd[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in cd)throw RangeError(`Duplicate use of step JSON ID `+e);return cd[e]=t,t.prototype.jsonID=e,t}},ud=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof Fl)return e.fail(t.message);throw t}}};function dd(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(dd(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return V.fromArray(r)}var fd=class e extends ld{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new U(dd(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return ud.fromReplace(e,this.from,this.to,i)}invert(){return new pd(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};ld.jsonID(`addMark`,fd);var pd=class e extends ld{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new U(dd(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return ud.fromReplace(e,this.from,this.to,n)}invert(){return new fd(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};ld.jsonID(`removeMark`,pd);var md=class e extends ld{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ud.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return ud.fromReplace(e,this.pos,this.pos+1,new U(V.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new hd(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};ld.jsonID(`addNodeMark`,md);var hd=class e extends ld{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ud.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return ud.fromReplace(e,this.pos,this.pos+1,new U(V.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new md(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};ld.jsonID(`removeNodeMark`,hd);var gd=class e extends ld{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&vd(e,this.from,this.to)?ud.fail(`Structure replace would overwrite content`):ud.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new od([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?U.empty:new U(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?U.empty:new U(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:`replace`,from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,U.fromJSON(t,n.slice),!!n.structure)}};gd.MAP_BIAS=1,ld.jsonID(`replace`,gd);var _d=class e extends ld{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(vd(e,this.from,this.gapFrom)||vd(e,this.gapTo,this.to)))return ud.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return ud.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?ud.fromReplace(e,this.from,this.to,n):ud.fail(`Content does not fit in gap`)}getMap(){return new od([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,U.fromJSON(t,n.slice),n.insert,!!n.structure)}};ld.jsonID(`replaceAround`,_d);function vd(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function yd(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(f)||(o&&o.to==l&&o.mark.eq(u[e])?o.to=d:i.push(o=new pd(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new fd(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function bd(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof wu){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<s.length;e++){let n=s[e],c;for(let e=0;e<i.length;e++){let t=i[e];t.step==a-1&&n.eq(i[e].style)&&(c=t)}c?(c.to=r,c.step=a):i.push({style:n,from:Math.max(o,t),to:r,step:a})}}}),i.forEach(t=>e.step(new pd(t.from,t.to,t.style)))}function xd(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<a.childCount;t++){let c=a.child(t),l=s+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new gd(s,l,U.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new pd(s,l,c.marks[t]));if(i&&c.isText&&n.whitespace!=`pre`){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(c.text);)r||=new U(V.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new gd(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(V.empty,!0);e.replace(s,s,new U(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function Sd(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Cd(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!Sd(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function wd(e,t,n){let{$from:r,$to:i,depth:a}=t,o=r.before(a+1),s=i.after(a+1),c=o,l=s,u=V.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=V.from(r.node(e).copy(u)),d++):c--;let f=V.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=V.from(i.node(e).copy(f)),p++):l++;e.step(new _d(c,l,o,s,new U(u.append(f),d,p),u.size-d,!0))}function Td(e,t,n=null,r=e){let i=Dd(e,t),a=i&&Od(r,t);return a?i.map(Ed).concat({type:t,attrs:n}).concat(a.map(Ed)):null}function Ed(e){return{type:e,attrs:null}}function Dd(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.contentMatchAt(r).findWrapping(t);if(!a)return null;let o=a.length?a[0]:t;return n.canReplaceWith(r,i,o)?a:null}function Od(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.child(r),o=t.contentMatch.findWrapping(a.type);if(!o)return null;let s=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;s&&e<i;e++)s=s.matchType(n.child(e).type);return!s||!s.validEnd?null:o}function kd(e,t,n){let r=V.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=V.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new _d(i,a,i,a,new U(r,0,0),n.length,!0))}function Ad(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&Nd(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&Md(e,t,n,a),xd(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new _d(c,l,c+1,l-1,new U(V.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&jd(e,t,n,a),!1}})}function jd(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function Md(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(`
|