@tscircuit/runframe 0.0.2213 → 0.0.2215
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/standalone.min.js
CHANGED
|
@@ -1041,7 +1041,7 @@ ${g}`)}catch(S){dB(`Failed to convert circuit JSON to SPICE: ${S}`),e.db.simulat
|
|
|
1041
1041
|
[zustand devtools middleware] Unsupported __setState action format.
|
|
1042
1042
|
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
|
|
1043
1043
|
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
|
|
1044
|
-
`);const I=m.state[s];if(I==null)return;JSON.stringify(i.getState())!==JSON.stringify(I)&&d(I);return}i.dispatchFromDevtools&&typeof i.dispatch=="function"&&i.dispatch(m)});case"DISPATCH":switch(_.payload.type){case"RESET":return d(h),s===void 0?l?.init(i.getState()):l?.init(wj(a.name));case"COMMIT":if(s===void 0){l?.init(i.getState());return}return l?.init(wj(a.name));case"ROLLBACK":return Ome(_.state,m=>{if(s===void 0){d(m),l?.init(i.getState());return}d(m[s]),l?.init(wj(a.name))});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return Ome(_.state,m=>{if(s===void 0){d(m);return}JSON.stringify(i.getState())!==JSON.stringify(m[s])&&d(m[s])});case"IMPORT_STATE":{const{nextLiftedState:m}=_.payload,I=(p=m.computedStates.slice(-1)[0])==null?void 0:p.state;if(!I)return;d(s===void 0?I:I[s]),l?.send(null,m);return}case"PAUSE_RECORDING":return u=!u}return}}),h},Ome=(t,e)=>{let n;try{n=JSON.parse(t)}catch(o){console.error("[zustand devtools middleware] Could not parse the received json",o)}n!==void 0&&e(n)},zC=window.TSCIRCUIT_FILESERVER_API_BASE_URL??"/api",u7n=[".tsx",".ts",".jsx",".js",".mjs",".json",".kicad_pcb",".kicad_sch",".kicad_prl",".kicad_pro"],Kme=t=>u7n.some(e=>t.endsWith(e)),XF=qrt.extend("store");async function cAt(t,e){return(await(await fetch(`${zC}/files/upsert`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:t,text_content:e})})).json()).file}async function Ume(t){return(await(await fetch(`${zC}/files/get?file_path=${encodeURIComponent(t)}`)).json()).file}async function h7n(t){const e=t?`${zC}/events/list?since=${encodeURIComponent(t)}`:`${zC}/events/list`;return(await(await fetch(e)).json()).event_list}async function d7n(){const t=await fetch(`${zC}/files/list`),{file_list:e}=await t.json(),n=new Map;for(const o of e){if(Kme(o.file_path)){const i=await Ume(o.file_path);n.set(o.file_path,i.text_content);continue}n.set(o.file_path,"__STATIC_ASSET__")}return n}const _7n=["manual-edits.json","manual_edits.json"],M0=sAt()(aAt((t,e)=>({fsMap:new Map,lastEventTime:new Date().toISOString(),isPolling:!1,error:null,circuitJson:null,lastManualEditsChangeSentAt:0,recentEvents:[],simulateScenarioOrder:void 0,currentMainComponentPath:null,recentlySavedFiles:[],loadInitialFiles:async()=>{const n=await d7n();XF("loaded initial files",{fsMap:n}),t({fsMap:n})},upsertFile:async(n,o)=>{try{const i=await cAt(n,o);t(r=>({fsMap:new Map(r.fsMap).set(i.file_path,i.text_content)}))}catch(i){t({error:i})}},getFile:async n=>{try{const o=await Ume(n);t(i=>({fsMap:new Map(i.fsMap).set(o.file_path,o.text_content)}))}catch(o){t({error:o})}},setCircuitJson:n=>{n!==e().circuitJson&&t({circuitJson:n})},addRecentlySavedFile:n=>{t(o=>{if(_7n.includes(n)||!Kme(n))return o;const i=o.recentlySavedFiles.filter(r=>r!==n);return{recentlySavedFiles:[n,...i].slice(0,10)}})},startPolling:()=>{const n=async()=>{const o=e();if(o.isPolling){try{const i=await h7n(o.lastEventTime);if(i.length>0){const r=i[i.length-1].created_at;XF("received events",i.map(a=>a.event_type)),t(a=>({recentEvents:[...a.recentEvents,...i].slice(0,100),lastEventTime:r}));let A=0;const s=new Map(o.fsMap);for(const a of i)if(a.event_type==="FILE_UPDATED"){A++;const c=await Ume(a.file_path);if(a.file_path==="manual_edits.json"&&Date.now()-o.lastManualEditsChangeSentAt<1e3)continue;Kme(c.file_path)?s.set(c.file_path,c.text_content??""):s.set(c.file_path,"__STATIC_ASSET__"),e().addRecentlySavedFile(a.file_path)}else a.event_type==="FILE_DELETED"&&(A++,s.delete(a.file_path));A>0&&(XF("updating fsMap, fsUpdateCount:",A),t({fsMap:s}))}}catch(i){t({error:i})}setTimeout(n,1e3)}};t({isPolling:!0}),n()},stopPolling:()=>{t({isPolling:!1})},pushEvent:async n=>{await fetch(`${zC}/events/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})},applyEditEventsAndUpdateManualEditsJson:async n=>{XF("applyEditEventsAndUpdateManualEditsJson",{editEvents:n});const o=e();if(!o.circuitJson)return;const i=o.fsMap.get("manual-edits.json"),r=i?JSON.parse(i):{},A=fit({circuitJson:o.circuitJson,editEvents:n,manualEditsFile:r});XF("updatedManualEditsFileContent",A),t(s=>({lastManualEditsChangeSentAt:Date.now(),fsMap:new Map(s.fsMap).set("manual-edits.json",JSON.stringify(A))})),await cAt("manual-edits.json",JSON.stringify(A,null,2))},setSimulateScenarioOrder:n=>t({simulateScenarioOrder:n}),setCurrentMainComponentPath:n=>t({currentMainComponentPath:n})}),{name:"run-frame-store"})),m7n=qrt.extend("useEditEventController"),p7n=()=>{const t=M0(d=>d.applyEditEventsAndUpdateManualEditsJson),[e,n]=j.useState([]),[o,i]=j.useState(!1),r=e.filter(d=>!d._applied),A=e.filter(d=>d._applied),s=o?e:r,a=j.useCallback(d=>{n(h=>[...h,{...d,_applied:!1}])},[]),c=j.useCallback(d=>{n(h=>h.map(_=>_===d?{..._,_applied:!0}:_))},[]),l=j.useCallback(()=>{n(d=>d.map(h=>({...h,_applied:!0})))},[]),g=j.useCallback(()=>{i(!0),e.length!==0&&(m7n("removing edit events that are applied"),n(d=>d.filter(h=>!h._applied)))},[e]),u=j.useCallback(()=>{i(!1)},[]);return j.useEffect(()=>{if(e.filter(h=>!h._applied).length===0)return;const d=setTimeout(()=>{l(),t(e)},1e3);return()=>clearTimeout(d)},[e]),{unappliedEditEvents:r,appliedEditEvents:A,editEventsForRender:s,pushEditEvent:a,markEditEventApplied:c,markRenderStarted:g,markRenderComplete:u,markAllEditEventsApplied:l}},Yme=Ra("run-frame:useHasReceivedInitialFilesLoaded"),I7n=()=>{const[t,e]=j.useState(!1),n=M0(i=>i.recentEvents),o=M0(i=>i.loadInitialFiles);return j.useEffect(()=>{(async()=>{await o();try{const r=await fetch(`${zC}/events/list?event_type=INITIAL_FILES_UPLOADED`);if(r.ok){const{event_list:A}=await r.json();if(A.length>0){Yme("INITIAL_FILES_UPLOADED found in history. Assuming ready."),e(!0);return}}}catch(r){console.error("Failed to check for event history",r)}Yme("No INITIAL_FILES_UPLOADED in history, waiting for polling.")})()},[o]),j.useEffect(()=>{t||n.some(i=>i.event_type==="INITIAL_FILES_UPLOADED")&&(Yme("INITIAL_FILES_UPLOADED received via polling. Assuming ready."),e(!0))},[n,t]),t};function r9(t,e,n){const[o,i]=j.useState(()=>{if(n!==void 0)return n;try{const r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return console.error("Error reading from localStorage:",r),e}});return j.useEffect(()=>{try{window.localStorage.setItem(t,JSON.stringify(o))}catch(r){console.error("Error writing to localStorage:",r)}},[t,o]),[o,i]}function wr(t,e,{checkForDefaultPrevented:n=!0}={}){return function(i){if(t?.(i),n===!1||!i||!i.defaultPrevented)return e?.(i)}}function _B(t,e=[]){let n=[];function o(r,A){const s=j.createContext(A);s.displayName=r+"Context";const a=n.length;n=[...n,A];const c=g=>{const{scope:u,children:d,...h}=g,_=u?.[t]?.[a]||s,p=j.useMemo(()=>h,Object.values(h));return V.jsx(_.Provider,{value:p,children:d})};c.displayName=r+"Provider";function l(g,u,d={}){const{optional:h=!1}=d,_=u?.[t]?.[a]||s,p=j.useContext(_);if(p)return p;if(A!==void 0)return A;if(!h)throw new Error(`\`${g}\` must be used within \`${r}\``)}return[c,l]}const i=()=>{const r=n.map(A=>j.createContext(A));return function(s){const a=s?.[t]||r;return j.useMemo(()=>({[`__scope${t}`]:{...s,[t]:a}}),[s,a])}};return i.scopeName=t,[o,C7n(i,...e)]}function C7n(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const o=t.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(r){const A=o.reduce((s,{useScope:a,scopeName:c})=>{const g=a(r)[`__scope${c}`];return{...s,...g}},{});return j.useMemo(()=>({[`__scope${e.scopeName}`]:A}),[A])}};return n.scopeName=e.scopeName,n}function lAt(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function A9(...t){return e=>{let n=!1;const o=t.map(i=>{const r=lAt(i,e);return!n&&typeof r=="function"&&(n=!0),r});if(n)return()=>{for(let i=0;i<o.length;i++){const r=o[i];typeof r=="function"?r():lAt(t[i],null)}}}}function mg(...t){return j.useCallback(A9(...t),t)}function iP(t){const e=j.forwardRef((n,o)=>{let{children:i,...r}=n,A=null,s=!1;const a=[];uAt(i)&&typeof Pj=="function"&&(i=Pj(i._payload)),j.Children.forEach(i,u=>{if(Q7n(u)){s=!0;const d=u;let h="child"in d.props?d.props.child:d.props.children;uAt(h)&&typeof Pj=="function"&&(h=Pj(h._payload)),A=E7n(d,h),a.push(A?.props?.children)}else a.push(u)}),A?A=j.cloneElement(A,void 0,a):!s&&j.Children.count(i)===1&&j.isValidElement(i)&&(A=i);const c=A?x7n(A):void 0,l=mg(o,c);if(!A){if(i||i===0)throw new Error(s?M7n(t):D7n(t));return i}const g=B7n(r,A.props??{});return A.type!==j.Fragment&&(g.ref=o?l:c),j.cloneElement(A,g)});return e.displayName=`${t}.Slot`,e}var f7n=iP("Slot"),gAt=Symbol.for("radix.slottable");function y7n(t){const e=n=>"child"in n?n.children(n.child):n.children;return e.displayName=`${t}.Slottable`,e.__radixId=gAt,e}var E7n=(t,e)=>{if("child"in t.props){const n=t.props.child;return j.isValidElement(n)?j.cloneElement(n,void 0,t.props.children(n.props.children)):null}return j.isValidElement(e)?e:null};function B7n(t,e){const n={...e};for(const o in e){const i=t[o],r=e[o];/^on[A-Z]/.test(o)?i&&r?n[o]=(...s)=>{const a=r(...s);return i(...s),a}:i&&(n[o]=i):o==="style"?n[o]={...i,...r}:o==="className"&&(n[o]=[i,r].filter(Boolean).join(" "))}return{...t,...n}}function x7n(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function Q7n(t){return j.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===gAt}var S7n=Symbol.for("react.lazy");function uAt(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===S7n&&"_payload"in t&&b7n(t._payload)}function b7n(t){return typeof t=="object"&&t!==null&&"then"in t}var D7n=t=>`${t} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,M7n=t=>`${t} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,Pj=g4[" use ".trim().toString()];function hAt(t){const e=t+"CollectionProvider",[n,o]=_B(e),[i,r]=n(e,{collectionRef:{current:null},itemMap:new Map}),A=_=>{const{scope:p,children:m}=_,I=j.useRef(null),C=j.useRef(new Map).current;return V.jsx(i,{scope:p,itemMap:C,collectionRef:I,children:m})};A.displayName=e;const s=t+"CollectionSlot",a=iP(s),c=j.forwardRef((_,p)=>{const{scope:m,children:I}=_,C=r(s,m),f=mg(p,C.collectionRef);return V.jsx(a,{ref:f,children:I})});c.displayName=s;const l=t+"CollectionItemSlot",g="data-radix-collection-item",u=iP(l),d=j.forwardRef((_,p)=>{const{scope:m,children:I,...C}=_,f=j.useRef(null),y=mg(p,f),B=r(l,m);return j.useEffect(()=>(B.itemMap.set(f,{ref:f,...C}),()=>{B.itemMap.delete(f)})),V.jsx(u,{[g]:"",ref:y,children:I})});d.displayName=l;function h(_){const p=r(t+"CollectionConsumer",_);return j.useCallback(()=>{const I=p.collectionRef.current;if(!I)return[];const C=Array.from(I.querySelectorAll(`[${g}]`));return Array.from(p.itemMap.values()).sort((B,x)=>C.indexOf(B.ref.current)-C.indexOf(x.ref.current))},[p.collectionRef,p.itemMap])}return[{Provider:A,Slot:c,ItemSlot:d},h,o]}var Jx=globalThis?.document?j.useLayoutEffect:()=>{},w7n=g4[" useId ".trim().toString()]||(()=>{}),P7n=0;function bp(t){const[e,n]=j.useState(w7n());return Jx(()=>{n(o=>o??String(P7n++))},[t]),e?`radix-${e}`:""}var rP=Noe();const dAt=V2(rP);var v7n=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Us=v7n.reduce((t,e)=>{const n=iP(`Primitive.${e}`),o=j.forwardRef((i,r)=>{const{asChild:A,...s}=i,a=A?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),V.jsx(a,{...s,ref:r})});return o.displayName=`Primitive.${e}`,{...t,[e]:o}},{});function _At(t,e){t&&rP.flushSync(()=>t.dispatchEvent(e))}function qx(t){const e=j.useRef(t);return j.useEffect(()=>{e.current=t}),j.useMemo(()=>((...n)=>e.current?.(...n)),[])}var N7n=g4[" useInsertionEffect ".trim().toString()]||Jx;function Lb({prop:t,defaultProp:e,onChange:n=()=>{},caller:o}){const[i,r,A]=R7n({defaultProp:e,onChange:n}),s=t!==void 0,a=s?t:i;{const l=j.useRef(t!==void 0);j.useEffect(()=>{const g=l.current;g!==s&&console.warn(`${o} is changing from ${g?"controlled":"uncontrolled"} to ${s?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),l.current=s},[s,o])}const c=j.useCallback(l=>{if(s){const g=T7n(l)?l(t):l;g!==t&&A.current?.(g)}else r(l)},[s,t,r,A]);return[a,c]}function R7n({defaultProp:t,onChange:e}){const[n,o]=j.useState(t),i=j.useRef(n),r=j.useRef(e);return N7n(()=>{r.current=e},[e]),j.useEffect(()=>{i.current!==n&&(r.current?.(n),i.current=n)},[n,i]),[n,o,r]}function T7n(t){return typeof t=="function"}var k7n=j.createContext(void 0);function Vme(t){const e=j.useContext(k7n);return t||e||"ltr"}var zme=!1;function F7n(){const[t,e]=j.useState(zme);return j.useEffect(()=>{zme||(zme=!0,e(!0))},[]),t}var mAt=g4[" useSyncExternalStore ".trim().toString()];function L7n(){return()=>{}}function H7n(){return mAt(L7n,()=>!0,()=>!1)}var G7n=typeof mAt=="function"?H7n:F7n,Jme="rovingFocusGroup.onEntryFocus",O7n={bubbles:!1,cancelable:!0},$F="RovingFocusGroup",[qme,pAt,K7n]=hAt($F),[U7n,vj]=_B($F,[K7n]),[Y7n,V7n]=U7n($F),IAt=j.forwardRef((t,e)=>V.jsx(qme.Provider,{scope:t.__scopeRovingFocusGroup,children:V.jsx(qme.Slot,{scope:t.__scopeRovingFocusGroup,children:V.jsx(z7n,{...t,ref:e})})}));IAt.displayName=$F;var z7n=j.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:o,loop:i=!1,dir:r,currentTabStopId:A,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:a,onEntryFocus:c,preventScrollOnEntryFocus:l=!1,...g}=t,u=j.useRef(null),d=mg(e,u),h=Vme(r),[_,p]=Lb({prop:A,defaultProp:s??null,onChange:a,caller:$F}),[m,I]=j.useState(!1),C=qx(c),f=pAt(n),y=j.useRef(!1),[B,x]=j.useState(0);return j.useEffect(()=>{const S=u.current;if(S)return S.addEventListener(Jme,C),()=>S.removeEventListener(Jme,C)},[C]),V.jsx(Y7n,{scope:n,orientation:o,dir:h,loop:i,currentTabStopId:_,onItemFocus:j.useCallback(S=>p(S),[p]),onItemShiftTab:j.useCallback(()=>I(!0),[]),onFocusableItemAdd:j.useCallback(()=>x(S=>S+1),[]),onFocusableItemRemove:j.useCallback(()=>x(S=>S-1),[]),children:V.jsx(Us.div,{tabIndex:m||B===0?-1:0,"data-orientation":o,...g,ref:d,style:{outline:"none",...t.style},onMouseDown:wr(t.onMouseDown,()=>{y.current=!0}),onFocus:wr(t.onFocus,S=>{const M=!y.current;if(S.target===S.currentTarget&&M&&!m){const w=new CustomEvent(Jme,O7n);if(S.currentTarget.dispatchEvent(w),!w.defaultPrevented){const k=f().filter(J=>J.focusable),N=k.find(J=>J.active),G=k.find(J=>J.id===_),U=[N,G,...k].filter(Boolean).map(J=>J.ref.current);yAt(U,l)}}y.current=!1}),onBlur:wr(t.onBlur,()=>I(!1))})})}),CAt="RovingFocusGroupItem",fAt=j.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:o=!0,active:i=!1,tabStopId:r,children:A,...s}=t,a=bp(),c=r||a,l=V7n(CAt,n),g=l.currentTabStopId===c,u=pAt(n),{onFocusableItemAdd:d,onFocusableItemRemove:h,currentTabStopId:_}=l,p=G7n();return Jx(()=>{if(!(!p||!o))return d(),()=>h()},[p,o,d,h]),j.useEffect(()=>{if(!(p||!o))return d(),()=>h()},[p,o,d,h]),V.jsx(qme.ItemSlot,{scope:n,id:c,focusable:o,active:i,children:V.jsx(Us.span,{tabIndex:g?0:-1,"data-orientation":l.orientation,...s,ref:e,onMouseDown:wr(t.onMouseDown,m=>{o?l.onItemFocus(c):m.preventDefault()}),onFocus:wr(t.onFocus,()=>l.onItemFocus(c)),onKeyDown:wr(t.onKeyDown,m=>{if(m.key==="Tab"&&m.shiftKey){l.onItemShiftTab();return}if(m.target!==m.currentTarget)return;const I=W7n(m,l.orientation,l.dir);if(I!==void 0){if(m.metaKey||m.ctrlKey||m.altKey||m.shiftKey)return;m.preventDefault();let f=u().filter(y=>y.focusable).map(y=>y.ref.current);if(I==="last")f.reverse();else if(I==="prev"||I==="next"){I==="prev"&&f.reverse();const y=f.indexOf(m.currentTarget);f=l.loop?j7n(f,y+1):f.slice(y+1)}setTimeout(()=>yAt(f))}}),children:typeof A=="function"?A({isCurrentTabStop:g,hasTabStop:_!=null}):A})})});fAt.displayName=CAt;var J7n={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function q7n(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function W7n(t,e,n){const o=q7n(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return J7n[o]}function yAt(t,e=!1){const n=document.activeElement;for(const o of t)if(o===n||(o.focus({preventScroll:e}),document.activeElement!==n))return}function j7n(t,e){return t.map((n,o)=>t[(e+o)%t.length])}var EAt=IAt,BAt=fAt;function X7n(t,e){return j.useReducer((n,o)=>e[n][o]??n,t)}var Ry=t=>{const{present:e,children:n}=t,o=$7n(e),i=typeof n=="function"?n({present:o.isPresent}):j.Children.only(n),r=Z7n(o.ref,eNn(i));return typeof n=="function"||o.isPresent?j.cloneElement(i,{ref:r}):null};Ry.displayName="Presence";function $7n(t){const[e,n]=j.useState(),o=j.useRef(null),i=j.useRef(t),r=j.useRef("none"),A=j.useRef(void 0),s=t?"mounted":"unmounted",[a,c]=X7n(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return j.useEffect(()=>{a==="mounted"?(r.current=A.current??ZF(o.current),A.current=void 0):r.current="none"},[a]),Jx(()=>{const l=o.current,g=i.current;if(g!==t){const d=r.current,h=ZF(l);t?(A.current=h,c("MOUNT")):h==="none"||l?.display==="none"?c("UNMOUNT"):c(g&&d!==h?"ANIMATION_OUT":"UNMOUNT"),i.current=t}},[t,c]),Jx(()=>{if(e){let l;const g=e.ownerDocument.defaultView??window,u=h=>{const p=ZF(o.current).includes(CSS.escape(h.animationName));if(h.target===e&&p&&(c("ANIMATION_END"),!i.current)){const m=e.style.animationFillMode;e.style.animationFillMode="forwards",l=g.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=m)})}},d=h=>{h.target===e&&(r.current=ZF(o.current))};return e.addEventListener("animationstart",d),e.addEventListener("animationcancel",u),e.addEventListener("animationend",u),()=>{g.clearTimeout(l),e.removeEventListener("animationstart",d),e.removeEventListener("animationcancel",u),e.removeEventListener("animationend",u)}}else c("ANIMATION_END")},[e,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:j.useCallback(l=>{if(l){const g=getComputedStyle(l);o.current=g,A.current=ZF(g)}else o.current=null;n(l)},[])}}function xAt(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Z7n(...t){const e=j.useRef(t);return e.current=t,j.useCallback(n=>{const o=e.current;let i=!1;const r=o.map(A=>{const s=xAt(A,n);return!i&&typeof s=="function"&&(i=!0),s});if(i)return()=>{for(let A=0;A<r.length;A++){const s=r[A];typeof s=="function"?s():xAt(o[A],null)}}},[])}function ZF(t){return t?.animationName||"none"}function eNn(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var Nj="Tabs",[tNn]=_B(Nj,[vj]),QAt=vj(),[nNn,Wme]=tNn(Nj),SAt=j.forwardRef((t,e)=>{const{__scopeTabs:n,value:o,onValueChange:i,defaultValue:r,orientation:A="horizontal",dir:s,activationMode:a="automatic",...c}=t,l=Vme(s),[g,u]=Lb({prop:o,onChange:i,defaultProp:r??"",caller:Nj});return V.jsx(nNn,{scope:n,baseId:bp(),value:g,onValueChange:u,orientation:A,dir:l,activationMode:a,children:V.jsx(Us.div,{dir:l,"data-orientation":A,...c,ref:e})})});SAt.displayName=Nj;var bAt="TabsList",DAt=j.forwardRef((t,e)=>{const{__scopeTabs:n,loop:o=!0,...i}=t,r=Wme(bAt,n),A=QAt(n);return V.jsx(EAt,{asChild:!0,...A,orientation:r.orientation,dir:r.dir,loop:o,children:V.jsx(Us.div,{role:"tablist","aria-orientation":r.orientation,...i,ref:e})})});DAt.displayName=bAt;var MAt="TabsTrigger",wAt=j.forwardRef((t,e)=>{const{__scopeTabs:n,value:o,disabled:i=!1,...r}=t,A=Wme(MAt,n),s=QAt(n),a=NAt(A.baseId,o),c=RAt(A.baseId,o),l=o===A.value;return V.jsx(BAt,{asChild:!0,...s,focusable:!i,active:l,children:V.jsx(Us.button,{type:"button",role:"tab","aria-selected":l,"aria-controls":c,"data-state":l?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:a,...r,ref:e,onMouseDown:wr(t.onMouseDown,g=>{!i&&g.button===0&&g.ctrlKey===!1?A.onValueChange(o):g.preventDefault()}),onKeyDown:wr(t.onKeyDown,g=>{i||g.target!==g.currentTarget||[" ","Enter"].includes(g.key)&&A.onValueChange(o)}),onFocus:wr(t.onFocus,()=>{const g=A.activationMode!=="manual";!l&&!i&&g&&A.onValueChange(o)})})})});wAt.displayName=MAt;var PAt="TabsContent",vAt=j.forwardRef((t,e)=>{const{__scopeTabs:n,value:o,forceMount:i,children:r,...A}=t,s=Wme(PAt,n),a=NAt(s.baseId,o),c=RAt(s.baseId,o),l=o===s.value,g=j.useRef(l);return j.useEffect(()=>{const u=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(u)},[]),V.jsx(Ry,{present:i||l,children:({present:u})=>V.jsx(Us.div,{"data-state":l?"active":"inactive","data-orientation":s.orientation,role:"tabpanel","aria-labelledby":a,hidden:!u,id:c,tabIndex:0,...A,ref:e,style:{...t.style,animationDuration:g.current?"0s":void 0},children:u&&r})})});vAt.displayName=PAt;function NAt(t,e){return`${t}-trigger-${e}`}function RAt(t,e){return`${t}-content-${e}`}var oNn=SAt,TAt=DAt,kAt=wAt,FAt=vAt;function LAt(t){var e,n,o="";if(typeof t=="string"||typeof t=="number")o+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e<i;e++)t[e]&&(n=LAt(t[e]))&&(o&&(o+=" "),o+=n)}else for(n in t)t[n]&&(o&&(o+=" "),o+=n);return o}function mB(){for(var t,e,n=0,o="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=LAt(t))&&(o&&(o+=" "),o+=e);return o}const jme="-",iNn=t=>{const e=ANn(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:o}=t;return{getClassGroupId:A=>{const s=A.split(jme);return s[0]===""&&s.length!==1&&s.shift(),HAt(s,e)||rNn(A)},getConflictingClassGroupIds:(A,s)=>{const a=n[A]||[];return s&&o[A]?[...a,...o[A]]:a}}},HAt=(t,e)=>{if(t.length===0)return e.classGroupId;const n=t[0],o=e.nextPart.get(n),i=o?HAt(t.slice(1),o):void 0;if(i)return i;if(e.validators.length===0)return;const r=t.join(jme);return e.validators.find(({validator:A})=>A(r))?.classGroupId},GAt=/^\[(.+)\]$/,rNn=t=>{if(GAt.test(t)){const e=GAt.exec(t)[1],n=e?.substring(0,e.indexOf(":"));if(n)return"arbitrary.."+n}},ANn=t=>{const{theme:e,prefix:n}=t,o={nextPart:new Map,validators:[]};return aNn(Object.entries(t.classGroups),n).forEach(([r,A])=>{Xme(A,o,r,e)}),o},Xme=(t,e,n,o)=>{t.forEach(i=>{if(typeof i=="string"){const r=i===""?e:OAt(e,i);r.classGroupId=n;return}if(typeof i=="function"){if(sNn(i)){Xme(i(o),e,n,o);return}e.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([r,A])=>{Xme(A,OAt(e,r),n,o)})})},OAt=(t,e)=>{let n=t;return e.split(jme).forEach(o=>{n.nextPart.has(o)||n.nextPart.set(o,{nextPart:new Map,validators:[]}),n=n.nextPart.get(o)}),n},sNn=t=>t.isThemeGetter,aNn=(t,e)=>e?t.map(([n,o])=>{const i=o.map(r=>typeof r=="string"?e+r:typeof r=="object"?Object.fromEntries(Object.entries(r).map(([A,s])=>[e+A,s])):r);return[n,i]}):t,cNn=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=new Map,o=new Map;const i=(r,A)=>{n.set(r,A),e++,e>t&&(e=0,o=n,n=new Map)};return{get(r){let A=n.get(r);if(A!==void 0)return A;if((A=o.get(r))!==void 0)return i(r,A),A},set(r,A){n.has(r)?n.set(r,A):i(r,A)}}},KAt="!",lNn=t=>{const{separator:e,experimentalParseClassName:n}=t,o=e.length===1,i=e[0],r=e.length,A=s=>{const a=[];let c=0,l=0,g;for(let p=0;p<s.length;p++){let m=s[p];if(c===0){if(m===i&&(o||s.slice(p,p+r)===e)){a.push(s.slice(l,p)),l=p+r;continue}if(m==="/"){g=p;continue}}m==="["?c++:m==="]"&&c--}const u=a.length===0?s:s.substring(l),d=u.startsWith(KAt),h=d?u.substring(1):u,_=g&&g>l?g-l:void 0;return{modifiers:a,hasImportantModifier:d,baseClassName:h,maybePostfixModifierPosition:_}};return n?s=>n({className:s,parseClassName:A}):A},gNn=t=>{if(t.length<=1)return t;const e=[];let n=[];return t.forEach(o=>{o[0]==="["?(e.push(...n.sort(),o),n=[]):n.push(o)}),e.push(...n.sort()),e},uNn=t=>({cache:cNn(t.cacheSize),parseClassName:lNn(t),...iNn(t)}),hNn=/\s+/,dNn=(t,e)=>{const{parseClassName:n,getClassGroupId:o,getConflictingClassGroupIds:i}=e,r=[],A=t.trim().split(hNn);let s="";for(let a=A.length-1;a>=0;a-=1){const c=A[a],{modifiers:l,hasImportantModifier:g,baseClassName:u,maybePostfixModifierPosition:d}=n(c);let h=!!d,_=o(h?u.substring(0,d):u);if(!_){if(!h){s=c+(s.length>0?" "+s:s);continue}if(_=o(u),!_){s=c+(s.length>0?" "+s:s);continue}h=!1}const p=gNn(l).join(":"),m=g?p+KAt:p,I=m+_;if(r.includes(I))continue;r.push(I);const C=i(_,h);for(let f=0;f<C.length;++f){const y=C[f];r.push(m+y)}s=c+(s.length>0?" "+s:s)}return s};function _Nn(){let t=0,e,n,o="";for(;t<arguments.length;)(e=arguments[t++])&&(n=UAt(e))&&(o&&(o+=" "),o+=n);return o}const UAt=t=>{if(typeof t=="string")return t;let e,n="";for(let o=0;o<t.length;o++)t[o]&&(e=UAt(t[o]))&&(n&&(n+=" "),n+=e);return n};function mNn(t,...e){let n,o,i,r=A;function A(a){const c=e.reduce((l,g)=>g(l),t());return n=uNn(c),o=n.cache.get,i=n.cache.set,r=s,s(a)}function s(a){const c=o(a);if(c)return c;const l=dNn(a,n);return i(a,l),l}return function(){return r(_Nn.apply(null,arguments))}}const w0=t=>{const e=n=>n[t]||[];return e.isThemeGetter=!0,e},YAt=/^\[(?:([a-z-]+):)?(.+)\]$/i,pNn=/^\d+\/\d+$/,INn=new Set(["px","full","screen"]),CNn=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,fNn=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,yNn=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,ENn=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,BNn=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,GS=t=>s9(t)||INn.has(t)||pNn.test(t),Hb=t=>a9(t,"length",PNn),s9=t=>!!t&&!Number.isNaN(Number(t)),$me=t=>a9(t,"number",s9),eL=t=>!!t&&Number.isInteger(Number(t)),xNn=t=>t.endsWith("%")&&s9(t.slice(0,-1)),Ss=t=>YAt.test(t),Gb=t=>CNn.test(t),QNn=new Set(["length","size","percentage"]),SNn=t=>a9(t,QNn,VAt),bNn=t=>a9(t,"position",VAt),DNn=new Set(["image","url"]),MNn=t=>a9(t,DNn,NNn),wNn=t=>a9(t,"",vNn),tL=()=>!0,a9=(t,e,n)=>{const o=YAt.exec(t);return o?o[1]?typeof e=="string"?o[1]===e:e.has(o[1]):n(o[2]):!1},PNn=t=>fNn.test(t)&&!yNn.test(t),VAt=()=>!1,vNn=t=>ENn.test(t),NNn=t=>BNn.test(t),RNn=mNn(()=>{const t=w0("colors"),e=w0("spacing"),n=w0("blur"),o=w0("brightness"),i=w0("borderColor"),r=w0("borderRadius"),A=w0("borderSpacing"),s=w0("borderWidth"),a=w0("contrast"),c=w0("grayscale"),l=w0("hueRotate"),g=w0("invert"),u=w0("gap"),d=w0("gradientColorStops"),h=w0("gradientColorStopPositions"),_=w0("inset"),p=w0("margin"),m=w0("opacity"),I=w0("padding"),C=w0("saturate"),f=w0("scale"),y=w0("sepia"),B=w0("skew"),x=w0("space"),S=w0("translate"),M=()=>["auto","contain","none"],w=()=>["auto","hidden","clip","visible","scroll"],k=()=>["auto",Ss,e],N=()=>[Ss,e],G=()=>["",GS,Hb],H=()=>["auto",s9,Ss],U=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],J=()=>["solid","dashed","dotted","double","none"],W=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],X=()=>["start","end","center","between","around","evenly","stretch"],oe=()=>["","0",Ss],ce=()=>["auto","avoid","all","avoid-page","page","left","right","column"],te=()=>[s9,Ss];return{cacheSize:500,separator:":",theme:{colors:[tL],spacing:[GS,Hb],blur:["none","",Gb,Ss],brightness:te(),borderColor:[t],borderRadius:["none","","full",Gb,Ss],borderSpacing:N(),borderWidth:G(),contrast:te(),grayscale:oe(),hueRotate:te(),invert:oe(),gap:N(),gradientColorStops:[t],gradientColorStopPositions:[xNn,Hb],inset:k(),margin:k(),opacity:te(),padding:N(),saturate:te(),scale:te(),sepia:oe(),skew:te(),space:N(),translate:N()},classGroups:{aspect:[{aspect:["auto","square","video",Ss]}],container:["container"],columns:[{columns:[Gb]}],"break-after":[{"break-after":ce()}],"break-before":[{"break-before":ce()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...U(),Ss]}],overflow:[{overflow:w()}],"overflow-x":[{"overflow-x":w()}],"overflow-y":[{"overflow-y":w()}],overscroll:[{overscroll:M()}],"overscroll-x":[{"overscroll-x":M()}],"overscroll-y":[{"overscroll-y":M()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[_]}],"inset-x":[{"inset-x":[_]}],"inset-y":[{"inset-y":[_]}],start:[{start:[_]}],end:[{end:[_]}],top:[{top:[_]}],right:[{right:[_]}],bottom:[{bottom:[_]}],left:[{left:[_]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",eL,Ss]}],basis:[{basis:k()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Ss]}],grow:[{grow:oe()}],shrink:[{shrink:oe()}],order:[{order:["first","last","none",eL,Ss]}],"grid-cols":[{"grid-cols":[tL]}],"col-start-end":[{col:["auto",{span:["full",eL,Ss]},Ss]}],"col-start":[{"col-start":H()}],"col-end":[{"col-end":H()}],"grid-rows":[{"grid-rows":[tL]}],"row-start-end":[{row:["auto",{span:[eL,Ss]},Ss]}],"row-start":[{"row-start":H()}],"row-end":[{"row-end":H()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Ss]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Ss]}],gap:[{gap:[u]}],"gap-x":[{"gap-x":[u]}],"gap-y":[{"gap-y":[u]}],"justify-content":[{justify:["normal",...X()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...X(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...X(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[I]}],px:[{px:[I]}],py:[{py:[I]}],ps:[{ps:[I]}],pe:[{pe:[I]}],pt:[{pt:[I]}],pr:[{pr:[I]}],pb:[{pb:[I]}],pl:[{pl:[I]}],m:[{m:[p]}],mx:[{mx:[p]}],my:[{my:[p]}],ms:[{ms:[p]}],me:[{me:[p]}],mt:[{mt:[p]}],mr:[{mr:[p]}],mb:[{mb:[p]}],ml:[{ml:[p]}],"space-x":[{"space-x":[x]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[x]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Ss,e]}],"min-w":[{"min-w":[Ss,e,"min","max","fit"]}],"max-w":[{"max-w":[Ss,e,"none","full","min","max","fit","prose",{screen:[Gb]},Gb]}],h:[{h:[Ss,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Ss,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Ss,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Ss,e,"auto","min","max","fit"]}],"font-size":[{text:["base",Gb,Hb]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",$me]}],"font-family":[{font:[tL]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",Ss]}],"line-clamp":[{"line-clamp":["none",s9,$me]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",GS,Ss]}],"list-image":[{"list-image":["none",Ss]}],"list-style-type":[{list:["none","disc","decimal",Ss]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[m]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[m]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...J(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",GS,Hb]}],"underline-offset":[{"underline-offset":["auto",GS,Ss]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:N()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ss]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Ss]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[m]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...U(),bNn]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",SNn]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},MNn]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[h]}],"gradient-via-pos":[{via:[h]}],"gradient-to-pos":[{to:[h]}],"gradient-from":[{from:[d]}],"gradient-via":[{via:[d]}],"gradient-to":[{to:[d]}],rounded:[{rounded:[r]}],"rounded-s":[{"rounded-s":[r]}],"rounded-e":[{"rounded-e":[r]}],"rounded-t":[{"rounded-t":[r]}],"rounded-r":[{"rounded-r":[r]}],"rounded-b":[{"rounded-b":[r]}],"rounded-l":[{"rounded-l":[r]}],"rounded-ss":[{"rounded-ss":[r]}],"rounded-se":[{"rounded-se":[r]}],"rounded-ee":[{"rounded-ee":[r]}],"rounded-es":[{"rounded-es":[r]}],"rounded-tl":[{"rounded-tl":[r]}],"rounded-tr":[{"rounded-tr":[r]}],"rounded-br":[{"rounded-br":[r]}],"rounded-bl":[{"rounded-bl":[r]}],"border-w":[{border:[s]}],"border-w-x":[{"border-x":[s]}],"border-w-y":[{"border-y":[s]}],"border-w-s":[{"border-s":[s]}],"border-w-e":[{"border-e":[s]}],"border-w-t":[{"border-t":[s]}],"border-w-r":[{"border-r":[s]}],"border-w-b":[{"border-b":[s]}],"border-w-l":[{"border-l":[s]}],"border-opacity":[{"border-opacity":[m]}],"border-style":[{border:[...J(),"hidden"]}],"divide-x":[{"divide-x":[s]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[s]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[m]}],"divide-style":[{divide:J()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["",...J()]}],"outline-offset":[{"outline-offset":[GS,Ss]}],"outline-w":[{outline:[GS,Hb]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:G()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[m]}],"ring-offset-w":[{"ring-offset":[GS,Hb]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Gb,wNn]}],"shadow-color":[{shadow:[tL]}],opacity:[{opacity:[m]}],"mix-blend":[{"mix-blend":[...W(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":W()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[o]}],contrast:[{contrast:[a]}],"drop-shadow":[{"drop-shadow":["","none",Gb,Ss]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[l]}],invert:[{invert:[g]}],saturate:[{saturate:[C]}],sepia:[{sepia:[y]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[o]}],"backdrop-contrast":[{"backdrop-contrast":[a]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[l]}],"backdrop-invert":[{"backdrop-invert":[g]}],"backdrop-opacity":[{"backdrop-opacity":[m]}],"backdrop-saturate":[{"backdrop-saturate":[C]}],"backdrop-sepia":[{"backdrop-sepia":[y]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[A]}],"border-spacing-x":[{"border-spacing-x":[A]}],"border-spacing-y":[{"border-spacing-y":[A]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",Ss]}],duration:[{duration:te()}],ease:[{ease:["linear","in","out","in-out",Ss]}],delay:[{delay:te()}],animate:[{animate:["none","spin","ping","pulse","bounce",Ss]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[f]}],"scale-x":[{"scale-x":[f]}],"scale-y":[{"scale-y":[f]}],rotate:[{rotate:[eL,Ss]}],"translate-x":[{"translate-x":[S]}],"translate-y":[{"translate-y":[S]}],"skew-x":[{"skew-x":[B]}],"skew-y":[{"skew-y":[B]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Ss]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Ss]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":N()}],"scroll-mx":[{"scroll-mx":N()}],"scroll-my":[{"scroll-my":N()}],"scroll-ms":[{"scroll-ms":N()}],"scroll-me":[{"scroll-me":N()}],"scroll-mt":[{"scroll-mt":N()}],"scroll-mr":[{"scroll-mr":N()}],"scroll-mb":[{"scroll-mb":N()}],"scroll-ml":[{"scroll-ml":N()}],"scroll-p":[{"scroll-p":N()}],"scroll-px":[{"scroll-px":N()}],"scroll-py":[{"scroll-py":N()}],"scroll-ps":[{"scroll-ps":N()}],"scroll-pe":[{"scroll-pe":N()}],"scroll-pt":[{"scroll-pt":N()}],"scroll-pr":[{"scroll-pr":N()}],"scroll-pb":[{"scroll-pb":N()}],"scroll-pl":[{"scroll-pl":N()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Ss]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[GS,Hb,$me]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}});var wn=typeof window<"u"?window:void 0,H_=typeof globalThis<"u"?globalThis:wn;typeof self>"u"&&(H_.self=H_),typeof File>"u"&&(H_.File=function(){});var JC=H_?.navigator,Zo=H_?.document,rd=H_?.location,Zme=H_?.fetch,epe=H_!=null&&H_.XMLHttpRequest&&"withCredentials"in new H_.XMLHttpRequest?H_.XMLHttpRequest:void 0,zAt=H_?.AbortController,TNn=H_?.CompressionStream,y1=JC?.userAgent,_r=wn??{};function JAt(){return!(!wn||wn.navigator.onLine===!1)}var qAt="1.400.0",Au={DEBUG:!1,LIB_VERSION:qAt,LIB_NAME:"web",JS_SDK_VERSION:qAt};function WAt(t,e,n,o,i,r,A){try{var s=t[r](A),a=s.value}catch(c){return void n(c)}s.done?e(a):Promise.resolve(a).then(o,i)}function Ih(t){return function(){var e=this,n=arguments;return new Promise((function(o,i){var r=t.apply(e,n);function A(a){WAt(r,o,i,A,s,"next",a)}function s(a){WAt(r,o,i,A,s,"throw",a)}A(void 0)}))}}function fo(){return fo=Object.assign?Object.assign.bind():function(t){for(var e=1;arguments.length>e;e++){var n=arguments[e];for(var o in n)({}).hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},fo.apply(null,arguments)}function jAt(t,e){if(t==null)return{};var n={};for(var o in t)if({}.hasOwnProperty.call(t,o)){if(e.indexOf(o)!==-1)continue;n[o]=t[o]}return n}var XAt=t=>{if(typeof t!="string")return t;try{return JSON.parse(t)}catch{return t}};function $At(t){return typeof t=="string"||t}function ZAt(t){return typeof t=="string"?t:void 0}var nL,OS=(function(t){return t.AnonymousId="anonymous_id",t.DistinctId="distinct_id",t.Props="props",t.EnablePersonProcessing="enable_person_processing",t.PersonMode="person_mode",t.FeatureFlagDetails="feature_flag_details",t.FeatureFlags="feature_flags",t.FeatureFlagPayloads="feature_flag_payloads",t.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",t.BootstrapFeatureFlags="bootstrap_feature_flags",t.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",t.OverrideFeatureFlags="override_feature_flags",t.Queue="queue",t.AiQueue="ai_queue",t.LogsQueue="logs_queue",t.OptedOut="opted_out",t.SessionId="session_id",t.SessionStartTimestamp="session_start_timestamp",t.SessionLastTimestamp="session_timestamp",t.PersonProperties="person_properties",t.GroupProperties="group_properties",t.InstalledAppBuild="installed_app_build",t.InstalledAppVersion="installed_app_version",t.SessionReplay="session_replay",t.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",t.SurveyLastSeenDate="survey_last_seen_date",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t})({}),est=(function(t){return t.GZipJS="gzip-js",t.Base64="base64",t})({}),kNn=["$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"],FNn=["token"],tst="NativeGzipValidationError",tpe=t=>t.length>=2&&t[0]===31&&t[1]===139,nst=(t,e)=>t===est.GZipJS||e===est.GZipJS||e==="gzip",ost=t=>!(!t||typeof t!="object")&&("name"in t?String(t.name):"")==="NotReadableError",Rj=t=>{var e=new Error("Native gzip produced invalid output: "+t);throw e.name=tst,e},LNn=(function(){var t=Ih((function*(e,n){18>e.size&&Rj("too-short");var o=new Uint8Array(yield e.slice(0,10).arrayBuffer());tpe(o)&&o[2]===8||Rj("invalid-header");var i=new DataView(yield e.slice(e.size-8).arrayBuffer());i.getUint32(0,!0)!==(A=>{for(var s=(()=>{if(nL)return nL;nL=[];for(var l=0;256>l;l++){for(var g=l,u=0;8>u;u++)g=1&g?3988292384^g>>>1:g>>>1;nL[l]=g>>>0}return nL})(),a=4294967295,c=0;A.length>c;c++)a=s[255&(a^A[c])]^a>>>8;return(4294967295^a)>>>0})(n)&&Rj("invalid-crc");var r=n.length>>>0;i.getUint32(4,!0)!==r&&Rj("invalid-size")}));return function(e,n){return t.apply(this,arguments)}})();function npe(){return npe=Ih((function*(t,e,n){e===void 0&&(e=!0);try{var o=new TextEncoder().encode(t),i=new CompressionStream("gzip"),r=i.writable.getWriter(),A=r.write(o).then((()=>r.close())).catch((function(){var c=Ih((function*(l){try{yield r.abort(l)}catch{}throw l}));return function(l){return c.apply(this,arguments)}})()),s=new Response(i.readable).blob(),a=(yield Promise.all([s,A]))[0];return yield LNn(a,o),a}catch(c){if(n!=null&&n.rethrow)throw c;return e&&console.error("Failed to gzip compress data",c),null}})),npe.apply(this,arguments)}var HNn=["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"],ist=function(t,e){if(e===void 0&&(e=[]),!t)return!1;var n=t.toLowerCase();return HNn.concat(e).some((o=>{var i=o.toLowerCase();return n.indexOf(i)!==-1}))};function gA(t,e){return t.indexOf(e)!==-1}var Tj=function(t){return t.trim()},ope=function(t){return t.replace(/^\$/,"")};function rst(t){var e,n=[];return(e=JSON.stringify(t,(function(o,i){if(typeof i=="bigint")return i.toString();if(typeof i!="function"&&typeof i!="symbol"){if(i instanceof Error)return{name:i.name,message:i.message,stack:i.stack};if(i&&typeof i=="object"){for(;n.length>0&&n[n.length-1]!==this;)n.pop();if(n.includes(i))return"[Circular]";n.push(i)}return i}})))!==null&&e!==void 0?e:"null"}var Ast=Object.prototype,sst=Ast.hasOwnProperty,kj=Ast.toString,bs=Array.isArray||function(t){return kj.call(t)==="[object Array]"},pB=t=>typeof t=="function",P0=t=>t===Object(t)&&!bs(t),Ob=t=>{if(P0(t)){for(var e in t)if(sst.call(t,e))return!1;return!0}return!1},To=t=>t===void 0,Xl=t=>kj.call(t)=="[object String]",ipe=t=>Xl(t)&&t.trim().length===0,qC=t=>t===null,as=t=>To(t)||qC(t),Dp=t=>kj.call(t)=="[object Number]"&&t==t,KS=t=>Dp(t)&&t>0,Wx=t=>kj.call(t)==="[object Boolean]",GNn=t=>t instanceof FormData,ONn=t=>gA(kNn,t),KNn=t=>gA(FNn,t);function ast(t){return t===null||typeof t!="object"}function Fj(t,e){return{}.toString.call(t)==="[object "+e+"]"}function rpe(t){return typeof Event<"u"&&(function(e,n){try{return e instanceof n}catch{return!1}})(t,Event)}var UNn=[!0,"true",1,"1","yes"],Ape=t=>gA(UNn,t),YNn=[!1,"false",0,"0","no"];function jx(t,e,n,o,i){return e>n&&(o.warn("min cannot be greater than max."),e=n),Dp(t)?t>n?(o.warn(" cannot be greater than max: "+n+". Using max value instead."),n):e>t?(o.warn(" cannot be less than min: "+e+". Using min value instead."),e):t:(o.warn(" must be a number. using max or fallback. max: "+n+", fallback: "+i),jx(i||n,e,n,o))}class VNn{constructor(e){this.Pe={},this.Oe=e.Oe,this.Fe=jx(e.bucketSize,0,100,e.Ae),this.$e=jx(e.refillRate,0,this.Fe,e.Ae),this.Ne=jx(e.refillInterval,0,864e5,e.Ae)}De(e,n){var o=Math.floor((n-e.lastAccess)/this.Ne);o>0&&(e.tokens=Math.min(e.tokens+o*this.$e,this.Fe),e.lastAccess=e.lastAccess+o*this.Ne)}consumeRateLimit(e){var n,o=Date.now(),i=String(e),r=this.Pe[i];return r?this.De(r,o):this.Pe[i]=r={tokens:this.Fe,lastAccess:o},r.tokens===0||(r.tokens--,r.tokens===0&&((n=this.Oe)==null||n.call(this,e)),r.tokens===0)}stop(){this.Pe={}}}var Ty="Mobile",Lj="iOS",US="Android",c9="Tablet",cst=US+" "+c9,lst="iPad",gst="Apple",ust=gst+" Watch",oL="Safari",l9="BlackBerry",hst="Samsung",dst=hst+"Browser",_st=hst+" Internet",AP="Chrome",zNn=AP+" OS",mst=AP+" "+Lj,spe="Internet Explorer",pst=spe+" "+Ty,ape="Opera",JNn=ape+" Mini",cpe="Edge",Ist="Microsoft "+cpe,g9="Firefox",Cst=g9+" "+Lj,iL="Nintendo",rL="PlayStation",u9="Xbox",fst=US+" "+Ty,yst=Ty+" "+oL,AL="Windows",lpe=AL+" Phone",Est="Nokia",gpe="Ouya",Bst="Generic",qNn=Bst+" "+Ty.toLowerCase(),xst=Bst+" "+c9.toLowerCase(),upe="Konqueror",Qst="Oculus Browser",Hj="Vivaldi",Sst="Yandex",Gj="Whale",hpe="DuckDuckGo",bst="Pale Moon",Oj="Waterfox",sL="Brave",Dst="Google Search App",su="(\\d+(\\.\\d+)?)",dpe=new RegExp("Version/"+su),WNn=new RegExp(u9,"i"),jNn=new RegExp(rL+" \\w+","i"),XNn=new RegExp(iL+" \\w+","i"),_pe=new RegExp(l9+"|PlayBook|BB10","i"),$Nn={"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"},Mst=function(t,e,n,o){e=e||"";var i=(function(r){return r!=null&&r.brave?sL:null})(n);return i||(o!=null&&o.detectGoogleSearchApp&&gA(t,"GSA/")?Dst:gA(t," OPR/")&&gA(t,"Mini")?JNn:gA(t," OPR/")?ape:_pe.test(t)?l9:gA(t,"IE"+Ty)||gA(t,"WPDesktop")?pst:gA(t,"OculusBrowser")?Qst:gA(t,dst)?_st:gA(t,cpe)||gA(t,"Edg/")?Ist:gA(t,Hj+"/")?Hj:gA(t,"YaBrowser/")?Sst:gA(t,Gj+"/")?Gj:gA(t,hpe+"/")||gA(t,"Ddg/")?hpe:gA(t,"FBIOS")?"Facebook "+Ty:gA(t,"UCWEB")||gA(t,"UCBrowser")?"UC Browser":gA(t,"CriOS")?mst:gA(t,"CrMo")||gA(t,AP)?AP:gA(t,US)&&gA(t,oL)?fst:gA(t,"FxiOS")?Cst:gA(t.toLowerCase(),upe.toLowerCase())?upe:gA(t,sL+"/")?sL:((r,A)=>A&&gA(A,gst)||(function(s){return gA(s,oL)&&!gA(s,AP)&&!gA(s,US)})(r))(t,e)?gA(t,Ty)?yst:oL:gA(t,"PaleMoon/")?bst:gA(t,Oj+"/")?Oj:gA(t,g9)?g9:gA(t,"MSIE")||gA(t,"Trident/")?spe:gA(t,"Gecko")?g9:"")},ZNn={[pst]:[new RegExp("rv:"+su)],[Ist]:[new RegExp(cpe+"?\\/"+su)],[AP]:[new RegExp("("+AP+"|CrMo)\\/"+su)],[mst]:[new RegExp("CriOS\\/"+su)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+su)],[oL]:[dpe],[yst]:[dpe],[ape]:[new RegExp("(Opera|OPR)\\/"+su)],[g9]:[new RegExp(g9+"\\/"+su)],[Cst]:[new RegExp("FxiOS\\/"+su)],[upe]:[new RegExp("Konqueror[:/]?"+su,"i")],[l9]:[new RegExp(l9+" "+su),dpe],[fst]:[new RegExp("android\\s"+su,"i")],[_st]:[new RegExp(dst+"\\/"+su)],[Qst]:[new RegExp("OculusBrowser\\/"+su)],[Hj]:[new RegExp(Hj+"\\/"+su)],[Sst]:[new RegExp("YaBrowser\\/"+su)],[Gj]:[new RegExp(Gj+"\\/"+su)],[sL]:[new RegExp(sL+"\\/"+su)],[hpe]:[new RegExp("(DuckDuckGo|Ddg)\\/"+su)],[bst]:[new RegExp("PaleMoon\\/"+su)],[Oj]:[new RegExp(Oj+"\\/"+su)],[Dst]:[new RegExp("GSA\\/"+su)],[spe]:[new RegExp("(rv:|MSIE )"+su)],Mozilla:[new RegExp("rv:"+su)]},eRn=function(t,e,n,o){var i=Mst(t,e,n,o),r=ZNn[i];if(To(r))return null;for(var A=0;r.length>A;A++){var s=t.match(r[A]);if(s)return parseFloat(s[s.length-2])}return null},wst=[[new RegExp(u9+"; "+u9+" (.*?)[);]","i"),t=>[u9,t&&t[1]||""]],[new RegExp(iL,"i"),[iL,""]],[new RegExp(rL,"i"),[rL,""]],[_pe,[l9,""]],[new RegExp(AL,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[lpe,""];if(new RegExp(Ty).test(e)&&!/IEMobile\b/.test(e))return[AL+" "+Ty,""];var n=/Windows NT ([0-9.]+)/i.exec(e);if(n&&n[1]){var o=$Nn[n[1]]||"";return/arm/i.test(e)&&(o="RT"),[AL,o]}return[AL,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?[Lj,[t[3],t[4],t[5]||"0"].join(".")]:[Lj,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var e="";return t&&t.length>=3&&(e=To(t[2])?t[3]:t[2]),["watchOS",e]}],[new RegExp("("+US+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+US+")","i"),t=>t&&t[2]?[US,[t[2],t[3],t[4]||"0"].join(".")]:[US,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{var e=["Mac OS X",""];return t&&t[1]&&(e[1]=[t[1],t[2],t[3]||"0"].join(".")),e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[zNn,""]],[/Linux|debian/i,["Linux",""]]],Pst=function(t){return XNn.test(t)?iL:jNn.test(t)?rL:WNn.test(t)?u9:new RegExp(gpe,"i").test(t)?gpe:new RegExp("("+lpe+"|WPDesktop)","i").test(t)?lpe:/iPad/.test(t)?lst:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?ust:_pe.test(t)?l9:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(Est,"i").test(t)?Est:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?new RegExp(Ty).test(t)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)||/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?US:cst:new RegExp("(pda|"+Ty+")","i").test(t)?qNn:new RegExp(c9,"i").test(t)&&!new RegExp(c9+" pc","i").test(t)?xst:""},tRn=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function vst(t,e){return typeof(n=t)=="string"&&tRn.test(n)?t:e();var n}function Kb(t){return t&&t.split("#")[0]}function Kj(t,e){var n=setTimeout(t,e);return n?.unref&&n?.unref(),n}var nRn=t=>t instanceof Error,Nst={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}},oRn=Nst.info;function Rst(t){if(Wx(t))return{boolValue:t};if(typeof t=="number")return Number.isFinite(t)?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:{stringValue:String(t)};if(typeof t=="string")return{stringValue:t};if(bs(t))return{arrayValue:{values:t.map((e=>Rst(e)))}};try{return{stringValue:JSON.stringify(t)}}catch{return{stringValue:String(t)}}}function Uj(t){var e=[];for(var n in t){var o=t[n];qC(o)||To(o)||e.push({key:n,value:Rst(o)})}return e}function iRn(t,e){var n=Nst[t.level||"info"]||oRn,o=n.text,i=n.number,r=String(Date.now())+"000000",A={};e.distinctId&&(A.posthogDistinctId=e.distinctId),e.sessionId&&(A.sessionId=e.sessionId),e.windowId&&(A["window.id"]=e.windowId),as(e.sessionStartTimestamp)||(A.sessionStartTimestamp=String(e.sessionStartTimestamp)),as(e.lastActivityTimestamp)||(A.lastActivityTimestamp=String(e.lastActivityTimestamp)),e.currentUrl&&(A["url.full"]=e.currentUrl),e.screenName&&(A["screen.name"]=e.screenName),e.appState&&(A["app.state"]=e.appState),e.activeFeatureFlags&&e.activeFeatureFlags.length>0&&(A.feature_flags=e.activeFeatureFlags);var s=fo({},A,t.attributes||{}),a={timeUnixNano:r,observedTimeUnixNano:r,severityNumber:i,severityText:o,body:{stringValue:t.body},attributes:Uj(s)};return t.trace_id&&(a.traceId=t.trace_id),t.span_id&&(a.spanId=t.span_id),To(t.trace_flags)||(a.flags=t.trace_flags),a}function Tst(t,e,n){return fo({},t.resourceAttributes,{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":e,"telemetry.sdk.version":n})}function kst(t,e,n,o){return{resourceLogs:[{resource:{attributes:Uj(e)},scopeLogs:[{scope:{name:n,version:o},logRecords:t}]}]}}let rRn=class{constructor(e,n,o,i,r,A,s){var a;A===void 0&&(A=()=>Promise.resolve()),this._instance=e,this.Se=n,this.Ae=o,this.qe=i,this.je=r,this.Be=A,this.He=s,this.Ue=null,this.ze=0,this.We=0,this.Ve=0,this.Ze=0,this.Ge=!1,this.Qe=n.maxBufferSize,this.Je=Math.max((a=n.maxQueueSize)!==null&&a!==void 0?a:n.maxBufferSize,n.maxBufferSize),this.Ke=n.flushIntervalMs,this.Ye=n.maxBatchRecordsPerPost,this.Xe=n.rateCapWindowMs,this.et=n.maxLogsPerInterval}reset(){this.tt(),this.Ue=null,this.Ve=0,this.Ze=0,this.Ge=!1,this.ze=0,this.We=0,this.Ye=this.Se.maxBatchRecordsPerPost}onReconnect(){this.We=0,this.rt()}captureLog(e){if(!this._instance.isDisabled&&!this._instance.optedOut&&e!=null&&e.body){var n=this.it(e);if(n!==null)if(n.body){if(this.nt()){var o={record:iRn(n,this.qe())};this.je((()=>this.st(o)))}}else this.Ae.info("Log was rejected in beforeSend function")}}it(e){var n=this.Se.beforeSend;if(!n)return e;var o=bs(n)?n:[n],i=e;for(var r of o)try{var A=r(i);if(!A)return this.Ae.info("Log was rejected in beforeSend function"),null;i=A}catch(s){return this.Ae.error("Error in beforeSend function for log:",s),null}return i}nt(){if(this.et===void 0)return!0;var e=Date.now(),n=e-this.Ve;return this.Xe>n&&n>=0||(this.Ve=e,this.Ze=0,this.Ge=!1),this.et>this.Ze?(this.Ze++,!0):(this.Ge||(this.Ae.warn("captureLog dropping logs: exceeded "+this.et+" logs per "+this.Xe+"ms"),this.Ge=!0),!1)}flush(){var e=this;return Ih((function*(){if(!e._instance.isDisabled)return e.Ue||(e.Ue=e.ot().finally((()=>{e.Ue=null}))),e.Ue}))()}ot(){var e=this;return Ih((function*(){var n;e.tt();var o=(n=e._instance.getPersistedProperty(OS.LogsQueue))!==null&&n!==void 0?n:[];if(o.length!==0)for(var i=o.length,r=0;o.length>0&&i>r;){var A,s;e.ze=0;var a=Math.min(o.length,e.Ye),c=o.slice(0,a),l=kst(c.map((u=>u.record)),e.ut(),(A=e.He)!==null&&A!==void 0?A:e._instance.getLibraryId(),e._instance.getLibraryVersion()),g=yield e._instance.ht(l);if(g.kind==="too-large"&&c.length>1)e.Ye=Math.max(1,Math.floor(c.length/2)),e.Ae.warn("Received 413 when sending logs batch of size "+c.length+", reducing batch size to "+e.Ye);else if(g.kind==="retry-later"||(g.kind==="too-large"?e.Ae.warn("Dropping a single log record after 413 with batch size 1 — the record is larger than the server cap and cannot be split further."):g.kind==="ok"&&e.Se.maxBatchRecordsPerPost>e.Ye&&(e.Ye=Math.min(e.Se.maxBatchRecordsPerPost,e.Ye+1)),yield e.dt(c.length),o=(s=e._instance.getPersistedProperty(OS.LogsQueue))!==null&&s!==void 0?s:[],r+=c.length,g.kind==="fatal"))throw g.error}}))()}dt(e){var n=this;return Ih((function*(){var o,i=Math.max(0,e-n.ze),r=(o=n._instance.getPersistedProperty(OS.LogsQueue))!==null&&o!==void 0?o:[];n._instance.setPersistedProperty(OS.LogsQueue,r.slice(i)),yield n.Be()}))()}ut(){return Tst(this.Se,this._instance.getLibraryId(),this._instance.getLibraryVersion())}st(e){var n;if(!this._instance.optedOut){var o=(n=this._instance.getPersistedProperty(OS.LogsQueue))!==null&&n!==void 0?n:[];this.Je>o.length||(o.shift(),this.ze++,this.Ae.info("Logs queue is full, dropping oldest record.")),o.push(e),this._instance.setPersistedProperty(OS.LogsQueue,o),this.Qe>o.length?this.ct():this.rt()}}ct(e){e===void 0&&(e=this.Ke),this.vt||(this.vt=Kj((()=>{this.vt=void 0,this.rt()}),e))}ft(){var e=Math.min(Math.max(0,this.We-1),6);return this.Ke*Math.pow(2,e)}yt(){var e=this._instance.getPersistedProperty(OS.LogsQueue);return!!e&&e.length>0}shutdown(e){var n=this;return Ih((function*(){n.tt();var o=n.flush().catch((()=>{}));e!==void 0?yield Promise.race([o,new Promise((i=>Kj(i,e)))]):yield o}))()}flushWithTimeout(e){var n=this;return Ih((function*(){var o=!1,i=n.flush(),r=new Promise((A=>Kj((()=>{o=!0,A()}),e)));try{yield Promise.race([i,r])}finally{o&&i.catch((()=>{}))}}))()}rt(){this.flush().then((()=>{this.We=0}),(e=>{this.We++,this.Ae.error("PostHog logs flush failed:",e)})).finally((()=>{!this._instance.isDisabled&&this.yt()&&this.ct(this.ft())}))}tt(){this.vt&&(clearTimeout(this.vt),this.vt=void 0)}};var mpe=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function Fst(t){return String(t)+"000000"}function Lst(t,e,n,o){var i="";return o&&(i=Object.keys(o).sort().map((r=>JSON.stringify(r)+":"+JSON.stringify(o[r]))).join(",")),t+"\0"+e+"\0"+(n??"")+"\0"+i}let ARn=class{constructor(e,n,o){this._instance=e,this.Se=n,this.Ae=o,this.bt=new Map,this.Ue=null,this._t=!1,this.wt=new Map,this.xt=new Set}count(e,n,o){n===void 0&&(n=1),this.kt({name:e,type:"count",value:n,unit:o?.unit,attributes:o?.attributes})}gauge(e,n,o){this.kt({name:e,type:"gauge",value:n,unit:o?.unit,attributes:o?.attributes})}histogram(e,n,o){this.kt({name:e,type:"histogram",value:n,unit:o?.unit,attributes:o?.attributes})}flush(){var e=this,n=this.Ue,o=(function(){var r=Ih((function*(){n&&(yield n.catch((()=>{}))),yield e.St()}));return function(){return r.apply(this,arguments)}})(),i=o().finally((()=>{this.Ue===i&&(this.Ue=null)}));return this.Ue=i,i}drainWindow(){if(this.bt.size===0)return null;var e=this.bt;return this.bt=new Map,this._t=!1,this.wt=new Map,this.xt=new Set,this.Ct(e)}reset(){this.tt(),this.bt=new Map,this.Ue=null,this._t=!1,this.wt=new Map,this.xt=new Set}kt(e){if(!this._instance.isDisabled&&!this._instance.optedOut){var n=this.it(e);if(n!==null)if(n.name&&typeof n.name=="string")if(typeof n.value=="number"&&Number.isFinite(n.value))if(n.type==="count"&&0>n.value)this.Ae.warn("Dropping count '"+n.name+"': counters are monotonic, value must be >= 0");else{var o=this.wt.get(n.name);o===void 0?this.wt.set(n.name,n.type):o===n.type||this.xt.has(n.name)||(this.xt.add(n.name),this.Ae.warn("Metric name '"+n.name+"' is already used as a "+o+"; recording it as a "+n.type+" too will blend both series in charts. Use a distinct name."));var i=Lst(n.type,n.name,n.unit,n.attributes),r=this.bt.get(i);if(!r){if(this.bt.size>=this.Se.maxSeriesPerFlush)return void(this._t||(this._t=!0,this.Ae.warn("Metric series cap reached ("+this.Se.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")));r={name:n.name,type:n.type,unit:n.unit,attributes:n.attributes?fo({},n.attributes):void 0,windowStartMs:Date.now()},this.bt.set(i,r)}this.Tt(r,n.value),this.ct()}else this.Ae.warn("Dropping metric '"+n.name+"': value must be a finite number");else this.Ae.warn("Dropping metric with empty name")}}Tt(e,n){var o;switch(e.type){case"count":e.total=((o=e.total)!==null&&o!==void 0?o:0)+n;break;case"gauge":e.last=n;break;case"histogram":e.hist||(e.hist={count:0,sum:0,min:n,max:n,bucketCounts:new Array(mpe.length+1).fill(0)});var i=e.hist;i.count+=1,i.sum+=n,i.min=Math.min(i.min,n),i.max=Math.max(i.max,n),i.bucketCounts[(function(r,A){for(var s=0;A.length>s;s++)if(A[s]>=r)return s;return A.length})(n,mpe)]+=1}}it(e){var n=this.Se.beforeSend;if(!n)return e;var o=bs(n)?n:[n],i=e;for(var r of o)try{var A=r(i);if(!A)return this.Ae.info("Metric was rejected in beforeSend function"),null;i=A}catch(s){return this.Ae.error("Error in beforeSend function for metric:",s),null}return i}ct(){this.vt||(this.vt=Kj((()=>{this.vt=void 0,this.flush().catch((()=>{}))}),this.Se.flushIntervalMs))}tt(){this.vt&&(clearTimeout(this.vt),this.vt=void 0)}St(){var e=this;return Ih((function*(){if(e.bt.size!==0){var n=e.bt;e.bt=new Map,e._t=!1,e.wt=new Map,e.xt=new Set;var o=yield e._instance.It(e.Ct(n));switch(o.kind){case"ok":return;case"retry-later":return e.Mt(n),void e.ct();case"too-large":return void e.Ae.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void e.Ae.error("Failed to send metrics batch:",o.error)}}}))()}Ct(e){return(function(r,A,s,a){return{resourceMetrics:[{resource:{attributes:Uj(A)},scopeMetrics:[{scope:{name:s,version:a},metrics:r}]}]}})(this.Et(e),(n=this.Se,o=this._instance.getLibraryId(),i=this._instance.getLibraryVersion(),fo({},n.resourceAttributes,{"service.name":n.serviceName||"unknown_service"},n.environment&&{"deployment.environment":n.environment},n.serviceVersion&&{"service.version":n.serviceVersion},{"telemetry.sdk.name":o,"telemetry.sdk.version":i})),this._instance.getLibraryId(),this._instance.getLibraryVersion());var n,o,i}Et(e){var n=Fst(Date.now()),o=new Map;for(var i of e.values()){var r,A=Lst(i.type,i.name,i.unit,void 0),s=o.get(A);s||(s=fo({name:i.name},i.unit&&{unit:i.unit}),i.type==="count"?s.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:i.type==="gauge"?s.gauge={dataPoints:[]}:s.histogram={aggregationTemporality:1,dataPoints:[]},o.set(A,s));var a=Uj((r=i.attributes)!==null&&r!==void 0?r:{}),c=Fst(i.windowStartMs);if(i.type==="count"){var l,g={attributes:a,startTimeUnixNano:c,timeUnixNano:n,asDouble:(l=i.total)!==null&&l!==void 0?l:0};s.sum.dataPoints.push(g)}else if(i.type==="gauge"){var u,d={attributes:a,timeUnixNano:n,asDouble:(u=i.last)!==null&&u!==void 0?u:0};s.gauge.dataPoints.push(d)}else i.hist&&s.histogram.dataPoints.push({attributes:a,startTimeUnixNano:c,timeUnixNano:n,count:i.hist.count,sum:i.hist.sum,min:i.hist.min,max:i.hist.max,bucketCounts:i.hist.bucketCounts,explicitBounds:mpe})}return Array.from(o.values())}Mt(e){var n,o;for(var i of e){var r=i[0],A=i[1],s=this.bt.get(r);if(s)switch(s.windowStartMs=Math.min(s.windowStartMs,A.windowStartMs),s.type){case"count":s.total=((n=s.total)!==null&&n!==void 0?n:0)+((o=A.total)!==null&&o!==void 0?o:0);break;case"gauge":break;case"histogram":if(A.hist)if(s.hist){s.hist.count+=A.hist.count,s.hist.sum+=A.hist.sum,s.hist.min=Math.min(s.hist.min,A.hist.min),s.hist.max=Math.max(s.hist.max,A.hist.max);for(var a=0;s.hist.bucketCounts.length>a;a++)s.hist.bucketCounts[a]+=A.hist.bucketCounts[a]}else s.hist=A.hist}else this.bt.set(r,A)}}};var Yj,Hst,ppe;function sRn(t){var e=globalThis._posthogChunkIds;if(e){var n=Object.keys(e);return ppe&&n.length===Hst||(Hst=n.length,ppe=n.reduce(((o,i)=>{Yj||(Yj={});var r=Yj[i];if(r)o[r[0]]=r[1];else for(var A=t(i),s=A.length-1;s>=0;s--){var a=A[s],c=a?.filename,l=e[i];if(c&&l){o[c]=l,Yj[i]=[c,l];break}}return o}),{})),ppe}}class aRn{constructor(e,n,o){o===void 0&&(o=[]),this.coercers=e,this.stackParser=n,this.modifiers=o}buildFromUnknown(e,n){n===void 0&&(n={});var o=n&&n.mechanism||{handled:!0,type:"generic"},i=this.buildCoercingContext(o,n,0).apply(e),r=this.buildParsingContext(n),A=this.parseStacktrace(i,r);return{$exception_list:this.convertToExceptionList(A,o),$exception_level:"error"}}modifyFrames(e){var n=this;return Ih((function*(){for(var o of e)o.stacktrace&&o.stacktrace.frames&&bs(o.stacktrace.frames)&&(o.stacktrace.frames=yield n.applyModifiers(o.stacktrace.frames));return e}))()}coerceFallback(e){var n;return{type:"Error",value:"Unknown error",stack:(n=e.syntheticException)==null?void 0:n.stack,synthetic:!0}}parseStacktrace(e,n){var o,i;return e.cause!=null&&(o=this.parseStacktrace(e.cause,n)),e.stack!=""&&e.stack!=null&&(i=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?n.skipFirstLines:0),n.chunkIdMap)),fo({},e,{cause:o,stack:i})}applyChunkIds(e,n){return e.map((o=>(o.filename&&n&&(o.chunk_id=n[o.filename]),o)))}applyCoercers(e,n){for(var o of this.coercers)if(o.match(e))return o.coerce(e,n);return this.coerceFallback(n)}applyModifiers(e){var n=this;return Ih((function*(){var o=e;for(var i of n.modifiers)o=yield i(o);return o}))()}convertToExceptionList(e,n){var o,i,r,A={type:e.type,value:e.value,mechanism:{type:(o=n.type)!==null&&o!==void 0?o:"generic",handled:(i=n.handled)===null||i===void 0||i,synthetic:(r=e.synthetic)!==null&&r!==void 0&&r}};e.stack&&(A.stacktrace={type:"raw",frames:e.stack});var s=[A];return e.cause!=null&&s.push(...this.convertToExceptionList(e.cause,fo({},n,{handled:!0}))),s}buildParsingContext(e){var n;return{chunkIdMap:sRn(this.stackParser),skipFirstLines:(n=e.skipFirstLines)!==null&&n!==void 0?n:1}}buildCoercingContext(e,n,o){o===void 0&&(o=0);var i=(r,A)=>{if(4>=A){var s=this.buildCoercingContext(e,n,A);return this.applyCoercers(r,s)}};return fo({},n,{syntheticException:o==0?n.syntheticException:void 0,mechanism:e,apply:r=>i(r,o),next:r=>i(r,o+1)})}}var h9="?";function Ipe(t,e,n,o,i){var r={platform:t,filename:e,function:n==="<anonymous>"?h9:n,in_app:!0};return To(o)||(r.lineno=o),To(i)||(r.colno=i),r}var Gst=(t,e)=>{var n=t.indexOf("safari-extension")!==-1,o=t.indexOf("safari-web-extension")!==-1;return n||o?[t.indexOf("@")!==-1?t.split("@")[0]:h9,n?"safari-extension:"+e:"safari-web-extension:"+e]:[t,e]},cRn=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,lRn=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,gRn=/\((\S*)(?::(\d+))(?::(\d+))\)/,uRn=(t,e)=>{var n=cRn.exec(t);if(n)return Ipe(e,n[1],h9,+n[2],+n[3]);var o=lRn.exec(t);if(o){if(o[2]&&o[2].indexOf("eval")===0){var i=gRn.exec(o[2]);i&&(o[2]=i[1],o[3]=i[2],o[4]=i[3])}var r=Gst(o[1]||h9,o[2]);return Ipe(e,r[1],r[0],o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},hRn=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,dRn=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,_Rn=(t,e)=>{var n=hRn.exec(t);if(n){if(n[3]&&n[3].indexOf(" > eval")>-1){var o=dRn.exec(n[3]);o&&(n[1]=n[1]||"eval",n[3]=o[1],n[4]=o[2],n[5]="")}var i=n[3],r=n[1]||h9,A=Gst(r,i);return Ipe(e,i=A[1],r=A[0],n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},Ost=/\(error: (.*)\)/;class mRn{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,n){var o=Xl(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:o?e.stack:void 0,cause:e.cause?n.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var n=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?n+": "+e.message:n}isDOMException(e){return Fj(e,"DOMException")}isDOMError(e){return Fj(e,"DOMError")}}class pRn{match(e){return(n=>n instanceof Error)(e)}coerce(e,n){return{type:this.getType(e),value:this.getMessage(e,n),stack:this.getStack(e),cause:e.cause?n.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,n){var o=e.message;return String(o.error&&typeof o.error.message=="string"?o.error.message:o)}getStack(e){return e.stacktrace||e.stack||void 0}}class IRn{constructor(){}match(e){return Fj(e,"ErrorEvent")&&e.error!=null}coerce(e,n){var o;return n.apply(e.error)||{type:"ErrorEvent",value:e.message,stack:(o=n.syntheticException)==null?void 0:o.stack,synthetic:!0}}}var CRn=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class fRn{match(e){return typeof e=="string"}coerce(e,n){var o,i=this.getInfos(e),r=i[0],A=i[1];return{type:r??"Error",value:A??e,stack:(o=n.syntheticException)==null?void 0:o.stack,synthetic:!0}}getInfos(e){var n="Error",o=e,i=e.match(CRn);return i&&(n=i[1],o=i[2]),[n,o]}}var yRn=["fatal","error","warning","log","info","debug"];function Kst(t,e){e===void 0&&(e=40);var n=Object.keys(t);if(n.sort(),!n.length)return"[object has no keys]";for(var o=n.length;o>0;o--){var i=n.slice(0,o).join(", ");if(e>=i.length)return o===n.length?i:i.length>e?i.slice(0,e)+"...":i}return""}class ERn{match(e){return typeof e=="object"&&e!==null}coerce(e,n){var o,i=this.getErrorPropertyFromObject(e);return i?n.apply(i):{type:this.getType(e),value:this.getValue(e),stack:(o=n.syntheticException)==null?void 0:o.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return rpe(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){var n="'"+e.name+"' captured as exception";return"message"in e&&typeof e.message=="string"&&(n+=" with message: '"+e.message+"'"),n}if("message"in e&&typeof e.message=="string")return e.message;var o=this.getObjectClassName(e);return(o&&o!=="Object"?"'"+o+"'":"Object")+" captured as exception with keys: "+Kst(e)}isSeverityLevel(e){return Xl(e)&&!ipe(e)&&yRn.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var n in e)if({}.hasOwnProperty.call(e,n)){var o=e[n];if(nRn(o))return o}}getObjectClassName(e){try{var n=Object.getPrototypeOf(e);return n?n.constructor.name:void 0}catch{return}}}class BRn{match(e){return rpe(e)}coerce(e,n){var o,i=e.constructor.name;return{type:i,value:i+" captured as exception with keys: "+Kst(e),stack:(o=n.syntheticException)==null?void 0:o.stack,synthetic:!0}}}class xRn{match(e){return ast(e)}coerce(e,n){var o;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:(o=n.syntheticException)==null?void 0:o.stack,synthetic:!0}}}class QRn{match(e){return Fj(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!rpe(e))return!1;try{var n=e.detail;return n!=null&&typeof n=="object"&&"reason"in n}catch{return!1}}coerce(e,n){var o,i=this.getUnhandledRejectionReason(e);return ast(i)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(i),stack:(o=n.syntheticException)==null?void 0:o.stack,synthetic:!0}:n.apply(i)}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}}var Vj="$message",zj="$timestamp",SRn=new Set([Vj,zj]),Cpe={enabled:!0,max_bytes:32768};function Jj(t){var e;return t?{enabled:(e=t.enabled)!==null&&e!==void 0?e:Cpe.enabled,max_bytes:DRn(t.max_bytes,Cpe.max_bytes)}:fo({},Cpe)}class bRn{constructor(e){this.Rt=[],this.Pt=0,this.Se=Jj(e)}setConfig(e){this.Se=Jj(e),this.Ot()}add(e){var n=(function(i){var r;try{r=rst(i)}catch{return}try{var A=JSON.parse(r);if(!P0(A))return;var s=A,a=s[Vj],c=s[zj];return!Xl(a)||a.trim().length===0||!Xl(c)&&!Dp(c)?void 0:{step:s,json:r}}catch{return}})(e);if(n){var o=(function(i){if(typeof TextEncoder<"u")return new TextEncoder().encode(i).length;for(var r=encodeURIComponent(i),A=0,s=0;r.length>s;s++)r[s]==="%"?(A+=1,s+=2):A+=1;return A})(n.json);o>this.Se.max_bytes||(this.Rt.push({step:n.step,bytes:o}),this.Pt+=o,this.Ot())}}getAttachable(){return this.Rt.map((e=>e.step))}clear(){this.Rt=[],this.Pt=0}size(){return this.Rt.length}Ot(){for(;this.Pt>this.Se.max_bytes&&this.Rt.length>0;){var e=this.Rt.shift();e&&(this.Pt-=e.bytes)}}}function DRn(t,e){if(!Dp(t)||t===1/0||t===-1/0)return e;var n=Math.floor(t);return 0>n?e:n}var Ust=function(t,e){var n=(e===void 0?{}:e).debugEnabled,o={k(i){if(wn&&(Au.DEBUG||_r.POSTHOG_DEBUG||n)&&!To(wn.console)&&wn.console){for(var r=("__rrweb_original__"in wn.console[i])?wn.console[i].__rrweb_original__:wn.console[i],A=arguments.length,s=new Array(A>1?A-1:0),a=1;A>a;a++)s[a-1]=arguments[a];r(t,...s)}},debug(){for(var i=arguments.length,r=new Array(i),A=0;i>A;A++)r[A]=arguments[A];o.k("debug",...r)},info(){for(var i=arguments.length,r=new Array(i),A=0;i>A;A++)r[A]=arguments[A];o.k("log",...r)},warn(){for(var i=arguments.length,r=new Array(i),A=0;i>A;A++)r[A]=arguments[A];o.k("warn",...r)},error(){for(var i=arguments.length,r=new Array(i),A=0;i>A;A++)r[A]=arguments[A];o.k("error",...r)},critical(){for(var i=arguments.length,r=new Array(i),A=0;i>A;A++)r[A]=arguments[A];console.error(t,...r)},uninitializedWarning(i){o.error("You must initialize PostHog before calling "+i)},createLogger:(i,r)=>Ust(t+" "+i,r)};return o},wo=Ust("[PostHog.js]"),v0=wo.createLogger,MRn=v0("[ExternalScriptsLoader]"),fpe=(t,e,n)=>{if(t.config.disable_external_dependency_loading)return MRn.warn(e+" was requested but loading of external scripts is disabled."),n("Loading of external scripts is disabled");var o=Zo?.querySelectorAll("script");if(o){for(var i,r=function(){if(o[A].src===e){var a=o[A];return a.__posthog_loading_callback_fired?{v:n()}:(a.addEventListener("load",(c=>{a.__posthog_loading_callback_fired=!0,n(void 0,c)})),a.onerror=c=>n(c),{v:void 0})}},A=0;o.length>A;A++)if(i=r())return i.v}var s=()=>{if(!Zo)return n("document not found");var a=Zo.createElement("script");if(a.type="text/javascript",a.crossOrigin="anonymous",a.src=e,a.onload=g=>{a.__posthog_loading_callback_fired=!0,n(void 0,g)},a.onerror=g=>n(g),t.config.prepare_external_dependency_script&&(a=t.config.prepare_external_dependency_script(a)),!a)return n("prepare_external_dependency_script returned null");if(t.config.external_scripts_inject_target==="head")Zo.head.appendChild(a);else{var c,l=Zo.querySelectorAll("body > script");l.length>0?(c=l[0].parentNode)==null||c.insertBefore(a,l[0]):Zo.body.appendChild(a)}};Zo!=null&&Zo.body?s():Zo?.addEventListener("DOMContentLoaded",s)};_r.__PosthogExtensions__=_r.__PosthogExtensions__||{},_r.__PosthogExtensions__.loadExternalDependency=(t,e,n)=>{if(e!=="remote-config"){var o;if(t.config.strict_script_versioning)o=t.requestRouter.endpointFor("assets","/static/"+t.version+"/"+e+".js");else{var i="/static/"+e+".js?v="+t.version;if(e==="toolbar"){var r=3e5;i=i+"&t="+Math.floor(Date.now()/r)*r}o=t.requestRouter.endpointFor("assets",i)}fpe(t,o,n)}else{var A=t.requestRouter.endpointFor("assets","/array/"+t.config.token+"/config.js");fpe(t,A,n)}},_r.__PosthogExtensions__.loadSiteApp=(t,e,n)=>{var o=t.requestRouter.endpointFor("api",e);fpe(t,o,n)};var Yst="$people_distinct_id",qj="$device_id",ype="$device_model",aL="__alias",cL="__timers",Epe="$autocapture_disabled_server_side",Bpe="$heatmaps_enabled_server_side",xpe="$exception_capture_enabled_server_side",Qpe="$error_tracking_suppression_rules",Spe="$error_tracking_capture_extension_exceptions",bpe="$web_vitals_enabled_server_side",Dpe="$dead_clicks_enabled_server_side",Mpe="$product_tours_enabled_server_side",wpe="$web_vitals_allowed_metrics",sP="$session_recording_remote_config",Vst="$replay_sample_rate",zst="$replay_override_sampling",Jst="$replay_override_linked_flag",qst="$replay_override_url_trigger",Wst="$replay_override_event_trigger",d9="$sesid",Ppe="$session_is_sampled",aP="$enabled_feature_flags",Wj="$active_feature_flags",lL="$early_access_features",vpe="$feature_flag_details",jj="$feature_flag_payloads",Npe="$feature_flag_request_id",YS="$override_feature_flags",_9="$override_feature_flag_payloads",cP="$stored_person_properties",lP="$stored_group_properties",Rpe="$surveys",Xj="$surveys_loaded_at",Tpe="$surveys_activated",gL="ph_product_tours",uL="$flag_call_reported",kpe="$flag_call_reported_session_id",Fpe="$feature_flag_errors",hL="$feature_flag_evaluated_at",IB="$user_state",Lpe="$client_session_props",Hpe="$capture_rate_limit",Gpe="$initial_campaign_params",Ope="$initial_referrer_info",$j="$initial_person_info",Zj="$epp",jst="__POSTHOG_TOOLBAR__",eX="$posthog_cookieless",Xst="$sdk_debug_extensions_init_method",$st="$sdk_debug_extensions_init_time_ms",Zst="$sdk_debug_recording_script_not_loaded",Kpe="PostHog loadExternalDependency extension not found.",gP="on_reject",VS="always",m9="anonymous",p9="identified",Upe="identified_only",tX="visibilitychange",nX="beforeunload",I9="$pageview",Ype="$pageleave",Vpe="$identify",eat="$groupidentify";function oX(t,e){bs(t)&&t.forEach(e)}function pg(t,e){if(!as(t))if(bs(t))t.forEach(e);else if(GNn(t))t.forEach(((o,i)=>e(o,i)));else for(var n in t)sst.call(t,n)&&e(t[n],n)}var jg=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),o=1;e>o;o++)n[o-1]=arguments[o];for(var i of n)for(var r in i)i[r]!==void 0&&(t[r]=i[r]);return t};function iX(t){for(var e=Object.keys(t),n=e.length,o=new Array(n);n--;)o[n]=[e[n],t[e[n]]];return o}var tat=function(t){try{return t()}catch{return}},wRn=function(t){return function(){try{for(var e=arguments.length,n=new Array(e),o=0;e>o;o++)n[o]=arguments[o];return t.apply(this,n)}catch(i){wo.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),wo.critical(i)}}},zpe=function(t){var e={};return pg(t,(function(n,o){(Xl(n)&&n.length>0||Dp(n))&&(e[o]=n)})),e},PRn=["herokuapp.com","vercel.app","netlify.app"];function vRn(t){var e=t?.hostname;if(!Xl(e))return!1;var n=e.split(".").slice(-2).join(".");for(var o of PRn)if(n===o)return!1;return!0}function au(t,e,n,o){var i=o??{},r=i.capture,A=i.passive;t?.addEventListener(e,n,{capture:r!==void 0&&r,passive:A===void 0||A})}function nat(t){return t.name==="ph_toolbar_internal"}Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return Dp(t)&&isFinite(t)&&Math.floor(t)===t});class rX{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,n,o,i){if(!Number.isInteger(e)||!Number.isInteger(n)||!Number.isInteger(o)||!Number.isInteger(i)||0>e||0>n||0>o||0>i||e>0xffffffffffff||n>4095||o>1073741823||i>4294967295)throw new RangeError("invalid field value");var r=new Uint8Array(16);return r[0]=e/Math.pow(2,40),r[1]=e/Math.pow(2,32),r[2]=e/Math.pow(2,24),r[3]=e/Math.pow(2,16),r[4]=e/Math.pow(2,8),r[5]=e,r[6]=112|n>>>8,r[7]=n,r[8]=128|o>>>24,r[9]=o>>>16,r[10]=o>>>8,r[11]=o,r[12]=i>>>24,r[13]=i>>>16,r[14]=i>>>8,r[15]=i,new rX(r)}toString(){for(var e="",n=0;this.bytes.length>n;n++)e=e+(this.bytes[n]>>>4).toString(16)+(15&this.bytes[n]).toString(16),n!==3&&n!==5&&n!==7&&n!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new rX(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var n=0;16>n;n++){var o=this.bytes[n]-e.bytes[n];if(o!==0)return Math.sign(o)}return 0}}class NRn{constructor(){this.S=0,this.C=0,this.I=new RRn}generate(){var e=this.generateOrAbort();if(To(e)){this.S=0;var n=this.generateOrAbort();if(To(n))throw new Error("Could not generate UUID after timestamp reset");return n}return e}generateOrAbort(){var e=Date.now();if(e>this.S)this.S=e,this.M();else{if(this.S>=e+1e4)return;this.C++,this.C>4398046511103&&(this.S++,this.M())}return rX.fromFieldsV7(this.S,Math.trunc(this.C/Math.pow(2,30)),this.C&Math.pow(2,30)-1,this.I.nextUint32())}M(){this.C=1024*this.I.nextUint32()+(1023&this.I.nextUint32())}}var oat,iat=t=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;t.length>e;e++)t[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};wn&&!To(wn.crypto)&&crypto.getRandomValues&&(iat=t=>crypto.getRandomValues(t));class RRn{constructor(){this.R=new Uint32Array(8),this.O=1/0}nextUint32(){return this.R.length>this.O||(iat(this.R),this.O=0),this.R[this.O++]}}var zS=()=>TRn().toString(),TRn=()=>(oat||(oat=new NRn)).generate(),dL="",kRn=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,Xx={N:()=>!!Zo,D(t){wo.error("cookieStore error: "+t)},A(t){if(Zo){try{for(var e=t+"=",n=Zo.cookie.split(";").filter((r=>r.length)),o=0;n.length>o;o++){for(var i=n[o];i.charAt(0)==" ";)i=i.substring(1,i.length);if(i.indexOf(e)===0)return decodeURIComponent(i.substring(e.length,i.length))}}catch{}return null}},F(t){var e;try{e=JSON.parse(Xx.A(t))||{}}catch{}return e},q(t,e,n,o,i){if(!Zo)return!1;try{var r="",A="",s=(function(l,g){if(g){var u=(function(h,_){if(_===void 0&&(_=Zo),dL)return dL;if(!_||["localhost","127.0.0.1"].includes(h))return"";for(var p=h.split("."),m=Math.min(p.length,8),I="dmn_chk_"+zS();!dL&&m--;){var C=p.slice(m).join("."),f=I+"=1;domain=."+C+";path=/";_.cookie=f+";max-age=3",_.cookie.includes(I)&&(_.cookie=f+";max-age=0",dL=C)}return dL})(l);if(!u){var d=(h=>{var _=h.match(kRn);return _?_[0]:""})(l);d!==u&&wo.info("Warning: cookie subdomain discovery mismatch",d,u),u=d}return u?"; domain=."+u:""}return""})(Zo.location.hostname,o);if(n){var a=new Date;a.setTime(a.getTime()+864e5*n),r="; expires="+a.toUTCString()}i&&(A="; secure");var c=t+"="+encodeURIComponent(JSON.stringify(e))+r+"; SameSite=Lax; path=/"+s+A;return c.length>3686.4&&wo.warn("cookieStore warning: large cookie, len="+c.length),Zo.cookie=c,!0}catch{return!1}},P(t,e){if(Zo!=null&&Zo.cookie)try{Xx.q(t,"",-1,e)}catch{return}}},Jpe=null,Ig={N(){if(!qC(Jpe))return Jpe;var t=!0;if(To(wn))t=!1;else try{var e="__mplssupport__";Ig.q(e,"xyz"),Ig.A(e)!=='"xyz"'&&(t=!1),Ig.P(e)}catch{t=!1}return t||wo.error("localStorage unsupported; falling back to cookie store"),Jpe=t,t},D(t){wo.error("localStorage error: "+t)},A(t){try{return wn?.localStorage.getItem(t)}catch(e){Ig.D(e)}return null},F(t){try{return JSON.parse(Ig.A(t))||{}}catch{}return null},q(t,e){try{return wn?.localStorage.setItem(t,JSON.stringify(e)),!0}catch(n){Ig.D(n)}return!1},P(t){try{wn?.localStorage.removeItem(t)}catch(e){Ig.D(e)}}},FRn=[qj,"distinct_id",d9,Ppe,Zj,$j,IB],AX={},LRn={N:()=>!0,D(t){wo.error("memoryStorage error: "+t)},A:t=>AX[t]||null,F:t=>AX[t]||null,q:(t,e)=>(AX[t]=e,!0),P(t){delete AX[t]}},uP=null,Mp={N(){if(!qC(uP))return uP;if(uP=!0,To(wn))uP=!1;else try{var t="__support__";Mp.q(t,"xyz"),Mp.A(t)!=='"xyz"'&&(uP=!1),Mp.P(t)}catch{uP=!1}return uP},D(t){wo.error("sessionStorage error: ",t)},A(t){try{return wn?.sessionStorage.getItem(t)}catch(e){Mp.D(e)}return null},F(t){try{return JSON.parse(Mp.A(t))||null}catch{}return null},q(t,e){try{return wn?.sessionStorage.setItem(t,JSON.stringify(e)),!0}catch(n){Mp.D(n)}return!1},P(t){try{wn?.sessionStorage.removeItem(t)}catch(e){Mp.D(e)}}};class HRn{constructor(e){this._instance=e}get Se(){return this._instance.config}get consent(){return this.At()?0:this.$t}isOptedOut(){return this.Se.cookieless_mode===VS||this.isRejected()||this.consent===-1&&this.Se.cookieless_mode===gP}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Se.opt_out_capturing_by_default}optInOut(e){this.Nt.q(this.Dt,e?1:0,this.Se.cookie_expiration,this.Se.cross_subdomain_cookie,this.Se.secure_cookie)}reset(){this.Nt.P(this.Dt,this.Se.cross_subdomain_cookie)}get Dt(){var e=this._instance.config,n=e.token,o=e.opt_out_capturing_cookie_prefix;return e.consent_persistence_name||(o?o+n:"__ph_opt_in_out_"+n)}get $t(){var e=this.Nt.A(this.Dt);return Ape(e)?1:gA(YNn,e)?0:-1}get Nt(){var e=this.Se.opt_out_capturing_persistence_type,n=e==="localStorage"?Ig:Xx;if(!this.qt||this.qt!==n){this.qt=n;var o=e==="localStorage"?Xx:Ig;o.A(this.Dt)&&(this.qt.A(this.Dt)||this.optInOut(Ape(o.A(this.Dt))),o.P(this.Dt,this.Se.cross_subdomain_cookie))}return this.qt}At(){return!!this.Se.respect_dnt&&[JC?.doNotTrack,JC?.msDoNotTrack,_r.doNotTrack].some((e=>Ape(e)))}}function rat(t,e){var n,o=t==null||(n=t.config)==null?void 0:n.get_current_url;if(!pB(o))return e;try{var i=o(e);return Xl(i)&&i?i:e}catch(r){return wo.error("Error in get_current_url, falling back to window.location.href",r),e}}var GRn=1,ORn=3,KRn=11;function Aat(t){return t instanceof Element&&(t.id===jst||!(t.closest==null||!t.closest(".toolbar-global-fade-container")))}function Ub(t){return!!t&&t.nodeType===GRn}function ky(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function sat(t){return!!t&&t.nodeType===ORn}function aat(t){return!!t&&t.nodeType===KRn&&Ub(t.host)}var cat=1e3;function qpe(t){return t?Tj(t).split(/\s+/):[]}function lat(t,e){var n=(function(o){var i,r=wn==null||(i=wn.location)==null?void 0:i.href;return To(r)?void 0:rat(o,r)})(e);return!!(n&&t&&t.some((o=>n.match(o))))}function sX(t){var e="";switch(typeof t.className){case"string":e=t.className;break;case"object":e=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:e=""}return qpe(e)}function gat(t){return as(t)?null:Tj(t).split(/(\s+)/).filter((e=>mL(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function _L(t){var e="";return Zpe(t)&&!Iat(t)&&t.childNodes&&t.childNodes.length&&pg(t.childNodes,(function(n){var o;sat(n)&&n.textContent&&(e+=(o=gat(n.textContent))!==null&&o!==void 0?o:"")})),Tj(e)}function Wpe(t){return To(t.target)?t.srcElement||null:(e=t.target)!=null&&e.shadowRoot?t.composedPath()[0]||null:t.target||null;var e}var jpe=["a","button","form","input","select","textarea","label"];function Xpe(t,e){if(To(e))return!0;var n,o=function(r){if(e.some((A=>(function(s,a){var c=s.matches||s.matchesSelector||s.msMatchesSelector||s.mozMatchesSelector||s.webkitMatchesSelector||s.oMatchesSelector;try{return!!c&&c.call(s,a)}catch{return!1}})(r,A))))return{v:!0}};for(var i of t)if(n=o(i))return n.v;return!1}function uat(t){var e=t.parentNode;return!(!e||!Ub(e))&&e}var URn=[".ph-no-autocapture","[data-ph-no-autocapture]"],hat=["next","previous","prev",">","<"],YRn=[...hat,"+","-","−","–"],dat=(t,e)=>/[a-z0-9]/i.test(e)?t.includes(e):t===e,_at=[".ph-no-rageclick",".ph-no-capture"],VRn=["","text","search","email","password","url","tel","number"];function mat(t,e){if(!wn||$pe(t))return!1;var n,o,i,r,A;if(Wx(e)?(n=!!e&&_at,o=void 0,i=!1):(n=(r=e?.css_selector_ignorelist)!==null&&r!==void 0?r:_at,o=e?.content_ignorelist,i=(A=e?.ignore_text_selection)!==null&&A!==void 0&&A),n===!1||i&&(function(a){return!(!a||!Ub(a))&&(!!ky(a,"textarea")||(ky(a,"input")?gA(VRn,(a.getAttribute("type")||"").toLowerCase()):(function(c){if(c.isContentEditable)return!0;var l=c.getAttribute==null?void 0:c.getAttribute("contenteditable");return l==="true"||l===""})(a)))})(t))return!1;var s=pat(t,!1).targetElementList;return!(function(a,c){if(a===!1||To(a))return!1;var l;if(a===!0)l=hat;else{if(!bs(a))return!1;if(a.length>10)return wo.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;l=a.map((g=>g.toLowerCase()))}return c.some((g=>{var u=g.safeText,d=g.ariaLabel;return l.some((h=>dat(u,h)||dat(d,h)))}))})(o,s.map((a=>{var c;return{safeText:_L(a).toLowerCase(),ariaLabel:((c=a.getAttribute("aria-label"))==null?void 0:c.toLowerCase().trim())||""}})))&&!Xpe(s,n)}var $pe=t=>!t||ky(t,"html")||!Ub(t),pat=(t,e)=>{if(!wn||$pe(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var n=!1,o=[t],i=t;i.parentNode&&!ky(i,"body");)if(aat(i.parentNode))o.push(i.parentNode.host),i=i.parentNode.host;else{var r=uat(i);if(!r)break;if(e||jpe.indexOf(r.tagName.toLowerCase())>-1)n=!0;else try{var A=wn.getComputedStyle(r);A&&A.getPropertyValue("cursor")==="pointer"&&(n=!0)}catch{}o.push(r),i=r}return{parentIsUsefulElement:n,targetElementList:o}};function Zpe(t){for(var e=new Set,n=0,o=t;o.parentNode&&!ky(o,"body");o=o.parentNode){if(n++>=cat||e.has(o))return!1;e.add(o);var i=sX(o);if(gA(i,"ph-sensitive")||gA(i,"ph-no-capture"))return!1}if(gA(sX(t),"ph-include"))return!0;var r=t.type||"";if(Xl(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var A=t.name||t.id||"";return!Xl(A)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(A.replace(/[^a-zA-Z0-9]/g,""))}function Iat(t){return!!(ky(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||ky(t,"select")||ky(t,"textarea")||t.getAttribute("contenteditable")==="true")}var Cat="(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})",zRn=new RegExp("^(?:"+Cat+")$"),JRn=new RegExp(Cat),fat="\\d{3}-?\\d{2}-?\\d{4}",qRn=new RegExp("^("+fat+")$"),WRn=new RegExp("("+fat+")");function mL(t,e){return e===void 0&&(e=!0),!(as(t)||Xl(t)&&(t=Tj(t),(e?zRn:JRn).test((t||"").replace(/[- ]/g,""))||(e?qRn:WRn).test(t)))}function yat(t){var e=_L(t);return mL(e=(e+" "+Eat(t)).trim())?e:""}function Eat(t){var e="";return t&&t.childNodes&&t.childNodes.length&&pg(t.childNodes,(function(n){var o;if(n&&((o=n.tagName)==null?void 0:o.toLowerCase())==="span")try{var i=_L(n);e=(e+" "+i).trim(),n.childNodes&&n.childNodes.length&&(e=(e+" "+Eat(n)).trim())}catch(r){wo.error("[AutoCapture]",r)}})),e}function Bat(t){return t.replace(/"|\\"/g,'\\"')}function jRn(t){var e=t.attr__class;return e?bs(e)?e:qpe(e):void 0}var aX=v0("[Dead Clicks]"),XRn=()=>!0,$Rn=t=>{var e,n=!((e=t.instance.persistence)==null||!e.get_property(Dpe)),o=t.instance.config.capture_dead_clicks;return Wx(o)?o:!!P0(o)||n};class xat{get lazyLoadedDeadClicksAutocapture(){return this.jt}constructor(e,n,o){this.instance=e,this.isEnabled=n,this.onCapture=o,this.startIfEnabledOrStop()}onRemoteConfig(e){"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[Dpe]:e.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.Bt((()=>{this.Ht()})):this.stop()}Bt(e){var n,o;(n=_r.__PosthogExtensions__)!=null&&n.initDeadClicksAutocapture?e():(o=_r.__PosthogExtensions__)==null||o.loadExternalDependency==null||o.loadExternalDependency(this.instance,"dead-clicks-autocapture",(i=>{i?aX.error("failed to load script",i):e()}))}Ht(){var e;if(Zo){if(!this.jt&&(e=_r.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var n=P0(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};n.__onCapture=this.onCapture,this.jt=_r.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,n),this.jt.start(Zo),aX.info("starting...")}}else aX.error("`document` not found. Cannot start.")}stop(){this.jt&&(this.jt.stop(),this.jt=void 0,aX.info("stopping..."))}}var eIe=v0("[SegmentIntegration]"),Qat="posthog-js";function Sat(t,e){var n=e===void 0?{}:e,o=n.organization,i=n.projectId,r=n.prefix,A=n.severityAllowList,s=A===void 0?["error"]:A,a=n.sendExceptionsToPostHog,c=a===void 0||a;return l=>{var g,u,d,h,_;if(s!=="*"&&!s.includes(l.level)||!t.__loaded)return l;l.tags||(l.tags={});var p=t.requestRouter.endpointFor("ui","/project/"+t.config.token+"/person/"+t.get_distinct_id());l.tags["PostHog Person URL"]=p,t.sessionRecordingStarted()&&(l.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));var m,I=((g=l.exception)==null?void 0:g.values)||[],C=I.map((y=>fo({},y,{stacktrace:y.stacktrace?fo({},y.stacktrace,{type:"raw",frames:(y.stacktrace.frames||[]).map((B=>fo({},B,{platform:"web:javascript"})))}):void 0}))),f={$exception_message:((u=I[0])==null?void 0:u.value)||l.message,$exception_type:(d=I[0])==null?void 0:d.type,$exception_level:l.level,$exception_list:C,$sentry_event_id:l.event_id,$sentry_exception:l.exception,$sentry_exception_message:((h=I[0])==null?void 0:h.value)||l.message,$sentry_exception_type:(_=I[0])==null?void 0:_.type,$sentry_tags:l.tags};return o&&i&&(f.$sentry_url=(r||"https://sentry.io/organizations/")+o+"/issues/?project="+i+"&query="+l.event_id),c&&((m=t.exceptions)==null||m.sendExceptionEvent(f)),l}}class ZRn{constructor(e,n,o,i,r,A){this.name=Qat,this.setupOnce=function(s){s(Sat(e,{organization:n,projectId:o,prefix:i,severityAllowList:r,sendExceptionsToPostHog:A==null||A}))}}}class bat{constructor(e){this.Ut=(n,o,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(wo.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:n,changeReason:i}),this.zt=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.Wt()}Wt(){var e;this.Vt=(e=this._instance.sessionManager)==null?void 0:e.onSessionId(this.Ut)}destroy(){var e;(e=this.Vt)==null||e.call(this),this.Vt=void 0}doPageView(e,n){var o,i=this.Zt(e,n);return this.zt={pathname:(o=wn?.location.pathname)!==null&&o!==void 0?o:"",pageViewId:n,timestamp:e},this._instance.scrollManager.resetContext(),i}doPageLeave(e){var n;return this.Zt(e,(n=this.zt)==null?void 0:n.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.zt)==null?void 0:e.pageViewId}}Zt(e,n){var o=this.zt;if(!o)return{$pageview_id:n};var i={$pageview_id:n,$prev_pageview_id:o.pageViewId},r=this._instance.scrollManager.getContext();if(r&&!this._instance.config.disable_scroll_properties){var A=r.maxScrollHeight,s=r.lastScrollY,a=r.maxScrollY,c=r.maxContentHeight,l=r.lastContentY,g=r.maxContentY;if(!(To(A)||To(s)||To(a)||To(c)||To(l)||To(g))){A=Math.ceil(A),s=Math.ceil(s),a=Math.ceil(a),c=Math.ceil(c),l=Math.ceil(l),g=Math.ceil(g);var u=A>1?jx(s/A,0,1,wo):1,d=A>1?jx(a/A,0,1,wo):1,h=c>1?jx(l/c,0,1,wo):1,_=c>1?jx(g/c,0,1,wo):1;i=jg(i,{$prev_pageview_last_scroll:s,$prev_pageview_last_scroll_percentage:u,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:d,$prev_pageview_last_content:l,$prev_pageview_last_content_percentage:h,$prev_pageview_max_content:g,$prev_pageview_max_content_percentage:_})}}return o.pathname&&(i.$prev_pageview_pathname=o.pathname),o.timestamp&&(i.$prev_pageview_duration=(e.getTime()-o.timestamp.getTime())/1e3),i}}var cX=["flags","surveys"],eTn={[Yst]:{exposure:"hidden"},[aL]:{exposure:"hidden"},__cmpns:{exposure:"hidden"},[cL]:{exposure:"hidden"},[Epe]:{exposure:"event"},[Bpe]:{exposure:"hidden"},[xpe]:{exposure:"event"},[Qpe]:{exposure:"hidden"},[Spe]:{exposure:"event"},[bpe]:{exposure:"event"},[Dpe]:{exposure:"event"},[Mpe]:{exposure:"hidden"},[wpe]:{exposure:"event"},[sP]:{exposure:"hidden"},$session_recording_enabled_server_side:{exposure:"hidden"},[d9]:{exposure:"hidden"},[Ppe]:{exposure:"event"},[Vst]:{exposure:"event",shouldSkipFromEventProperties:t=>qC(t)},$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"},$sess_rec_flush_size:{exposure:"hidden"},[aP]:{exposure:"derived",storageGroup:"flags",shouldSkipFromEventProperties:(t,e)=>e(),transformToEventProperties(t){if(!P0(t))return{};for(var e={},n=Object.keys(t),o=0;n.length>o;o++)e["$feature/"+n[o]]=t[n[o]];return e}},[Wj]:{exposure:"event",storageGroup:"flags"},[lL]:{exposure:"hidden"},[vpe]:{exposure:"hidden",storageGroup:"flags"},[jj]:{exposure:"event",storageGroup:"flags"},[Npe]:{exposure:"event",storageGroup:"flags",volatile:!0},[YS]:{exposure:"event"},[_9]:{exposure:"hidden"},[cP]:{exposure:"hidden"},[lP]:{exposure:"hidden"},[Rpe]:{exposure:"hidden",storageGroup:"surveys"},[Xj]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[Tpe]:{exposure:"event"},[gL]:{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"},[uL]:{exposure:"hidden"},[kpe]:{exposure:"hidden"},[Fpe]:{exposure:"hidden"},[hL]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[IB]:{exposure:"hidden"},[Lpe]:{exposure:"hidden"},[Hpe]:{exposure:"hidden"},[Gpe]:{exposure:"hidden"},[Ope]:{exposure:"hidden"},[$j]:{exposure:"hidden"},[Zj]:{exposure:"hidden"},[zst]:{exposure:"event"},[Jst]:{exposure:"event"},[qst]:{exposure:"event"},[Wst]:{exposure:"event"},[Xst]:{exposure:"event"},[$st]:{exposure:"event"},[Zst]:{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"}},tTn=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],hP=t=>{var e=eTn[t];if(e)return e;for(var n of tTn){var o=n[1];if(t.indexOf(n[0])===0)return o}},pL=t=>{var e=Zo?.createElement("a");return To(e)?null:(e.href=t,e)},C9=function(t,e){for(var n,o=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),i=0;o.length>i;i++){var r=o[i].split("=");if(r[0]===e){n=r;break}}if(!bs(n)||2>n.length)return"";var A=n[1];try{A=decodeURIComponent(A)}catch{wo.error("Skipping decoding for malformed query param: "+A)}return A.replace(/\+/g," ")},IL=function(t,e,n){if(!t||!e||!e.length)return t;for(var o=t.split("#"),i=o[1],r=(o[0]||"").split("?"),A=r[1],s=r[0],a=(A||"").split("&"),c=[],l=0;a.length>l;l++){var g=a[l].split("=");bs(g)&&(e.includes(g[0])?c.push(g[0]+"="+n):c.push(a[l]))}var u=s;return A!=null&&(u+="?"+c.join("&")),i!=null&&(u+="#"+i),u},lX=function(t,e){var n=t.match(new RegExp(e+"=([^&]*)"));return n?n[1]:null},Dat=(t,e)=>t>=e&&JAt(),Mat=(t,e,n,o)=>{if(t===0){if(JAt()){var i=e+1;return i===n&&o(),i}return e}return 0},gX="https?://(.*)",f9=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],nTn=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...f9],CL="<masked>",oTn=["li_fat_id"];function wat(t,e,n){if(!Zo)return{};var o,i=e?[...f9,...n||[]]:[],r=Pat(IL(Zo.URL,i,CL),t),A=(o={},pg(oTn,(function(s){var a=Xx.A(s);o[s]=a||null})),o);return jg(A,r)}function Pat(t,e){var n=nTn.concat(e||[]),o={};return pg(n,(function(i){var r=C9(t,i);o[i]=r||null})),o}function vat(t){var e=(function(r){return r?r.search(gX+"google.([^/?]*)")===0?"google":r.search(gX+"bing.com")===0?"bing":r.search(gX+"yahoo.com")===0?"yahoo":r.search(gX+"duckduckgo.com")===0?"duckduckgo":null:null})(t),n=e!="yahoo"?"q":"p",o={};if(!qC(e)){o.$search_engine=e;var i=Zo?C9(Zo.referrer,n):"";i.length&&(o.ph_keyword=i)}return o}function Nat(){return navigator.language||navigator.userLanguage}var uX="$direct";function Rat(){return Zo?.referrer||uX}function Tat(t,e,n){n===void 0&&(n=!1);var o=t?[...f9,...e||[]]:[],i=n?Kb(rd?.href):rd?.href,r=i?.substring(0,1e3);return{r:Rat().substring(0,1e3),u:r?IL(r,o,CL):void 0}}function kat(t,e){var n;e===void 0&&(e=!1);var o=t.r,i=t.u,r=e?Kb(i):i,A={$referrer:o,$referring_domain:o==null?void 0:o==uX?uX:(n=pL(o))==null?void 0:n.host};if(r){A.$current_url=r;var s=pL(r);A.$host=s?.host,A.$pathname=s?.pathname;var a=Pat(r);jg(A,a)}if(o){var c=vat(o);jg(A,c)}return A}function Fat(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function iTn(){try{return new Date().getTimezoneOffset()}catch{return}}var rTn={flags:hL,surveys:Xj},ATn=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],y9="main";class tIe{constructor(e,n,o){if(o===void 0&&(o=!0),this.Gt={},this.Qt=!1,this.Jt=!1,this.Se=e,this.Kt=o,this.props={},this.Yt=!1,this.Xt=(r=>{var A="";return r.token&&(A=r.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),r.persistence_name?"ph_"+r.persistence_name:"ph_"+A+"_posthog"})(e),this.Nt=this.er(e),this.Jt=this.tr(e),this.load(),e.debug&&wo.info("Persistence loaded",e.persistence,fo({},this.props)),this.update_config(e,e,n),this.save(),wn){var i=()=>this.flush();au(wn,"beforeunload",i,{capture:!1}),au(wn,"pagehide",i,{capture:!1})}}rr(){var e,n=(e=this.Se)==null?void 0:e.persistence_save_debounce_ms;return Dp(n)&&n>0?n:0}isDisabled(){return!!this.ir}er(e){ATn.indexOf(e.persistence.toLowerCase())===-1&&(wo.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var n,o=(function(A,s){A===void 0&&(A=[]),s===void 0&&(s=!1);var a=[...FRn,...A];return fo({},Ig,{F(c){try{var l={};try{l=Xx.F(c)||{}}catch{}var g,u=JSON.parse(Ig.A(c)||"{}");if(s){var d={};for(var h in l){var _=l[h];qC(_)||_===""||(d[h]=_)}g=jg(u,d)}else g=jg(l,u);return Ig.q(c,g),g}catch{}return null},q(c,l,g,u,d,h){var _=Ig.q(c,l,void 0,void 0,h);try{var p={};a.forEach((m=>{l[m]&&(p[m]=l[m])})),Object.keys(p).length&&Xx.q(c,p,g,u,d,h)}catch(m){Ig.D(m)}return _},P(c,l){try{wn?.localStorage.removeItem(c),Xx.P(c,l)}catch(g){Ig.D(g)}}})})(e.cookie_persisted_properties||[],e.__preview_cookie_wins_on_conflict||!1),i=!1,r=e.persistence.toLowerCase();return r==="localstorage"&&Ig.N()?(n=Ig,i=!0):r==="localstorage+cookie"&&o.N()?(n=o,i=!0):r==="sessionstorage"&&Mp.N()?n=Mp:r==="memory"?n=LRn:r==="cookie"?n=Xx:o.N()?(n=o,i=!0):n=Xx,this.Qt=i,n}nr(e){return this.Xt+"__"+e}tr(e){return this.Qt&&!!e.split_storage}sr(e){var n=e??this.Se.feature_flag_cache_ttl_ms;if(!n||0>=n)return!1;var o=this.props[hL];return!o||typeof o!="number"||Date.now()-o>n}properties(){var e={};return pg(this.props,((n,o)=>{var i=hP(o);if(i?.exposure==="derived"){if(i.shouldSkipFromEventProperties!=null&&i.shouldSkipFromEventProperties(n,o===aP?()=>this.sr():()=>!1))return;i.transformToEventProperties&&jg(e,i.transformToEventProperties(n))}else if(!i||i.exposure==="event"){if(i!=null&&i.shouldSkipFromEventProperties!=null&&i.shouldSkipFromEventProperties(n,(()=>!1)))return;e[o]=n}})),e}load(){if(!this.ir){var e=this.Nt.F(this.Xt);e&&(this.props=jg({},e)),this.Jt&&this.ar()}}ar(){for(var e of cX){var n=Ig.F(this.nr(e));if(n&&!Ob(n)){var o=this.lr(e);o.persisted=!0,this.ur(e)||(o.fingerprint=this.hr(n,e)),this.dr(e,n)||jg(this.props,n)}}}ur(e){return Object.keys(this.props).some((n=>{var o;return((o=hP(n))==null?void 0:o.storageGroup)===e}))}dr(e,n){var o=rTn[e];if(!o)return!1;var i=n[o],r=this.props[o];return Dp(i)&&Dp(r)&&r>i}refreshKey(e){var n;if(!this.ir){var o=this.Jt?(n=hP(e))==null?void 0:n.storageGroup:void 0,i=o?Ig.F(this.nr(o)):this.Nt.F(this.Xt);if(i&&e in i)this.cr(e,i[e]);else{if(o){var r=this.Nt.F(this.Xt);if(r&&e in r)return void this.cr(e,r[e])}this.vr(e)}}}save(){if(!this.ir){var e=this.rr();e>0?To(this.pr)&&(this.pr=setTimeout((()=>{this.pr=void 0,this.gr()}),e)):this.gr()}}flush(){To(this.pr)||(clearTimeout(this.pr),this.pr=void 0,this.gr())}gr(){this.ir||(this.Jt?this.mr():this.yr(this.Nt,this.Xt,this.props,y9))}mr(){var e=this.br(),n=e.main,o=e.groups;for(var i of(this.yr(this.Nt,this.Xt,n,y9),cX)){var r,A=o[i];(!Ob(A)||(r=this.Gt[i])!=null&&r.persisted)&&this.yr(Ig,this.nr(i),A,i)}}br(){var e={},n={};for(var o of cX)n[o]={};return pg(this.props,((i,r)=>{var A,s=(A=hP(r))==null?void 0:A.storageGroup;s?n[s][r]=i:e[r]=i})),{main:e,groups:n}}hr(e,n){if(n===y9)return JSON.stringify(e)+"|"+this._r+"|"+this.wr+"|"+this.kr;var o={};return pg(e,((i,r)=>{var A;o[r]=(A=hP(r))!=null&&A.volatile?"__volatile__":i})),JSON.stringify(o)}yr(e,n,o,i){var r=this.lr(i);if(i===y9||r.dirty||To(r.fingerprint)){var A;try{if((A=this.hr(o,i))===r.fingerprint)return void(r.dirty=!1)}catch{A=void 0}e.q(n,o,this._r,this.wr,this.kr,this.Se.debug)?(r.dirty=!1,i!==y9&&(r.persisted=!0),To(A)||(r.fingerprint=A)):this.Se.debug&&wo.warn('failed to persist storage entry "'+n+'"; will retry on next save')}}remove(e){var n=(e===void 0?{}:e).keepGroupEntries,o=n!==void 0&&n;if(To(this.pr)||(clearTimeout(this.pr),this.pr=void 0),this.Nt.P(this.Xt,!1),this.Nt.P(this.Xt,!0),!o&&this.Kt)for(var i of cX)Ig.P(this.nr(i));o?delete this.Gt[y9]:this.Gt={}}clear(){this.remove(),this.props={}}register_once(e,n,o){if(P0(e)){To(n)&&(n="None"),this._r=To(o)?this.Sr:o;var i=!1;if(pg(e,((r,A)=>{this.props.hasOwnProperty(A)&&this.props[A]!==n||(this.cr(A,r),i=!0)})),i)return this.save(),!0}return!1}register(e,n){if(P0(e)){this._r=To(n)?this.Sr:n;var o=!1;if(pg(e,((i,r)=>{e.hasOwnProperty(r)&&this.props[r]!==i&&(this.cr(r,i),o=!0)})),o)return this.save(),!0}return!1}unregister(e){e in this.props&&(this.vr(e),this.save())}update_campaign_params(){if(!this.Yt){var e=wat(this.Se.custom_campaign_params,this.Se.mask_personal_data_properties,this.Se.custom_personal_data_properties);Ob(zpe(e))||this.register(e),this.Yt=!0}}update_search_keyword(){var e;this.register((e=Zo?.referrer)?vat(e):{})}update_referrer_info(){var e;this.register_once({$referrer:Rat(),$referring_domain:Zo!=null&&Zo.referrer&&((e=pL(Zo.referrer))==null?void 0:e.host)||uX},void 0)}set_initial_person_info(){this.props[Gpe]||this.props[Ope]||this.register_once({[$j]:Tat(this.Se.mask_personal_data_properties,this.Se.custom_personal_data_properties,this.Se.disable_capture_url_hashes)},void 0)}get_initial_props(){var e={};pg([Ope,Gpe],(i=>{var r=this.props[i];r&&pg(r,(function(A,s){e["$initial_"+ope(s)]=A}))}));var n=this.props[$j];if(n){var o=(function(i,r){r===void 0&&(r=!1);var A=kat(i,r),s={};return pg(A,(function(a,c){s["$initial_"+ope(c)]=a})),s})(n,this.Se.disable_capture_url_hashes);jg(e,o)}return e}safe_merge(e){return pg(this.props,(function(n,o){o in e||(e[o]=n)})),e}update_config(e,n,o){this.Sr=this._r=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!o),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie);var i=e.persistence!==n.persistence||!((a,c)=>{if(a.length!==c.length)return!1;var l=[...a].sort(),g=[...c].sort();return l.every(((u,d)=>u===g[d]))})(e.cookie_persisted_properties||[],n.cookie_persisted_properties||[]),r=i?this.er(e):this.Nt,A=this.tr(e);if(i||A!==this.Jt){var s=this.props;this.clear(),this.Nt=r,this.Jt=A,this.props=s,this.save()}}set_disabled(e){this.ir=e,this.ir?this.remove():this.save()}set_cross_subdomain(e){e!==this.wr&&(this.wr=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this.kr&&(this.kr=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,n){var o=this.props[cL]||{};o[e]=n,this.cr(cL,o),this.save()}remove_event_timer(e){var n=this.props[cL]||{},o=n[e];return To(o)||(delete n[e],this.cr(cL,n),this.save()),o}get_property(e){return this.props[e]}set_property(e,n){this.cr(e,n),this.save()}cr(e,n){var o;this.props[e]=n,(o=hP(e))!=null&&o.volatile||this.Cr(e)}vr(e){delete this.props[e],this.Cr(e)}Cr(e){var n,o=(n=hP(e))==null?void 0:n.storageGroup;o&&(this.lr(o).dirty=!0)}lr(e){return this.Gt[e]||(this.Gt[e]={})}}var fL={Activation:"events",Cancellation:"cancelEvents"},nIe={Popover:"popover",API:"api",Widget:"widget"},sTn={Always:"always"},JS={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent"},oIe={SURVEY_ID:"$survey_id",SURVEY_ITERATION:"$survey_iteration",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date"},iIe={Popover:"popover",Inline:"inline"},aTn={SHOWN:"product tour shown"},Lat={TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},Hat=v0("[RateLimiter]");class cTn{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=n=>{var o=n.text;if(o&&o.length)try{(JSON.parse(o).quota_limited||[]).forEach((i=>{Hat.info((i||"events")+" is quota limited."),this.serverLimits[i]=new Date().getTime()+6e4}))}catch(i){return void Hat.warn('could not rate limit - continuing. Error: "'+i?.message+'"',{text:o})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)==null?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)==null?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var n,o,i;e===void 0&&(e=!1);var r=this.captureEventsBurstLimit,A=this.captureEventsPerSecond,s=new Date().getTime(),a=(n=(o=this.instance.persistence)==null?void 0:o.get_property(Hpe))!==null&&n!==void 0?n:{tokens:r,last:s};a.tokens+=(s-a.last)/1e3*A,a.last=s,a.tokens>r&&(a.tokens=r);var c=1>a.tokens;return c||e||(a.tokens=Math.max(0,a.tokens-1)),!c||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+A+" events per second and "+r+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=c,(i=this.instance.persistence)==null||i.set_property(Hpe,a),{isRateLimited:c,remainingTokens:a.tokens}}isServerRateLimited(e){var n=this.serverLimits[e||"events"]||!1;return n!==!1&&new Date().getTime()<n}}var yL=v0("[RemoteConfig]");class Gat{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=_r._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}Tr(e){var n,o;(n=_r.__PosthogExtensions__)!=null&&n.loadExternalDependency?(o=_r.__PosthogExtensions__)==null||o.loadExternalDependency==null||o.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):e()}Ir(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback(n){e(n.json)}})}load(){try{if(this.remoteConfig)return yL.info("Using preloaded remote config",this.remoteConfig),this.Mr(this.remoteConfig),void this.Er();if(this._instance.Rr())return void yL.warn("Remote config is disabled. Falling back to local config.");this.Tr((e=>{if(!e)return yL.info("No config found after loading remote JS config. Falling back to JSON."),void this.Ir((n=>{this.Mr(n),this.Er()}));this.Mr(e),this.Er()}))}catch(e){yL.error("Error loading remote config",e)}}stop(){this.Pr&&(clearInterval(this.Pr),this.Pr=void 0)}refresh(){!this._instance.Rr()&&Zo&&Zo.visibilityState!=="hidden"&&this._instance.reloadFeatureFlags()}Er(){var e;if(!this.Pr){var n=(e=this._instance.config.remote_config_refresh_interval_ms)!==null&&e!==void 0?e:3e5;n!==0&&(this.Pr=setInterval((()=>{this.refresh()}),n))}}Mr(e){var n;e||yL.error("Failed to fetch remote config from PostHog."),this._instance.Mr(e??{}),e?.hasFeatureFlags!==!1&&(this._instance.config.advanced_disable_feature_flags_on_first_load||(n=this._instance.featureFlags)==null||n.ensureFlagsLoaded())}}var WC={GZipJS:"gzip-js",Base64:"base64"},r2=Uint8Array,E1=Uint16Array,E9=Uint32Array,rIe=new r2([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]),AIe=new r2([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]),Oat=new r2([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Kat=function(t,e){for(var n=new E1(31),o=0;31>o;++o)n[o]=e+=1<<t[o-1];var i=new E9(n[30]);for(o=1;30>o;++o)for(var r=n[o];n[o+1]>r;++r)i[r]=r-n[o]<<5|o;return[n,i]},Uat=Kat(rIe,2),sIe=Uat[1];Uat[0][28]=258,sIe[258]=28;for(var Yat=Kat(AIe,0)[1],Vat=new E1(32768),N0=0;32768>N0;++N0){var B9=(43690&N0)>>>1|(21845&N0)<<1;Vat[N0]=((65280&(B9=(61680&(B9=(52428&B9)>>>2|(13107&B9)<<2))>>>4|(3855&B9)<<4))>>>8|(255&B9)<<8)>>>1}var EL=function(t,e,n){for(var o=t.length,i=0,r=new E1(e);o>i;++i)++r[t[i]-1];var A,s=new E1(e);for(i=0;e>i;++i)s[i]=s[i-1]+r[i-1]<<1;for(A=new E1(o),i=0;o>i;++i)A[i]=Vat[s[t[i]-1]++]>>>15-t[i];return A},dP=new r2(288);for(N0=0;144>N0;++N0)dP[N0]=8;for(N0=144;256>N0;++N0)dP[N0]=9;for(N0=256;280>N0;++N0)dP[N0]=7;for(N0=280;288>N0;++N0)dP[N0]=8;var hX=new r2(32);for(N0=0;32>N0;++N0)hX[N0]=5;var lTn=EL(dP,9),gTn=EL(hX,5),zat=function(t){return(t/8>>0)+(7&t&&1)},Jat=function(t,e,n){(n==null||n>t.length)&&(n=t.length);var o=new(t instanceof E1?E1:t instanceof E9?E9:r2)(n-e);return o.set(t.subarray(e,n)),o},qS=function(t,e,n){var o=e/8>>0;t[o]|=n<<=7&e,t[o+1]|=n>>>8},BL=function(t,e,n){var o=e/8>>0;t[o]|=n<<=7&e,t[o+1]|=n>>>8,t[o+2]|=n>>>16},aIe=function(t,e){for(var n=[],o=0;t.length>o;++o)t[o]&&n.push({s:o,f:t[o]});var i=n.length,r=n.slice();if(!i)return[new r2(0),0];if(i==1){var A=new r2(n[0].s+1);return A[n[0].s]=1,[A,1]}n.sort((function(y,B){return y.f-B.f})),n.push({s:-1,f:25001});var s=n[0],a=n[1],c=0,l=1,g=2;for(n[0]={s:-1,f:s.f+a.f,l:s,r:a};l!=i-1;)s=n[n[g].f>n[c].f?c++:g++],a=n[c!=l&&n[g].f>n[c].f?c++:g++],n[l++]={s:-1,f:s.f+a.f,l:s,r:a};var u=r[0].s;for(o=1;i>o;++o)r[o].s>u&&(u=r[o].s);var d=new E1(u+1),h=cIe(n[l-1],d,0);if(h>e){o=0;var _=0,p=h-e,m=1<<p;for(r.sort((function(y,B){return d[B.s]-d[y.s]||y.f-B.f}));i>o;++o){var I=r[o].s;if(e>=d[I])break;_+=m-(1<<h-d[I]),d[I]=e}for(_>>>=p;_>0;){var C=r[o].s;e>d[C]?_-=1<<e-d[C]++-1:++o}for(;o>=0&&_;--o){var f=r[o].s;d[f]==e&&(--d[f],++_)}h=e}return[new r2(d),h]},cIe=function(t,e,n){return t.s==-1?Math.max(cIe(t.l,e,n+1),cIe(t.r,e,n+1)):e[t.s]=n},qat=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new E1(++e),o=0,i=t[0],r=1,A=function(a){n[o++]=a},s=1;e>=s;++s)if(t[s]==i&&s!=e)++r;else{if(!i&&r>2){for(;r>138;r-=138)A(32754);r>2&&(A(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(A(i),--r;r>6;r-=6)A(8304);r>2&&(A(r-3<<5|8208),r=0)}for(;r--;)A(i);r=1,i=t[s]}return[n.subarray(0,o),e]},xL=function(t,e){for(var n=0,o=0;e.length>o;++o)n+=t[o]*e[o];return n},lIe=function(t,e,n){var o=n.length,i=zat(e+2);t[i]=255&o,t[i+1]=o>>>8,t[i+2]=255^t[i],t[i+3]=255^t[i+1];for(var r=0;o>r;++r)t[i+r+4]=n[r];return 8*(i+4+o)},Wat=function(t,e,n,o,i,r,A,s,a,c,l){qS(e,l++,n),++i[256];for(var g=aIe(i,15),u=g[0],d=g[1],h=aIe(r,15),_=h[0],p=h[1],m=qat(u),I=m[0],C=m[1],f=qat(_),y=f[0],B=f[1],x=new E1(19),S=0;I.length>S;++S)x[31&I[S]]++;for(S=0;y.length>S;++S)x[31&y[S]]++;for(var M=aIe(x,7),w=M[0],k=M[1],N=19;N>4&&!w[Oat[N-1]];--N);var G,H,U,J,W=c+5<<3,X=xL(i,dP)+xL(r,hX)+A,oe=xL(i,u)+xL(r,_)+A+14+3*N+xL(x,w)+(2*x[16]+3*x[17]+7*x[18]);if(X>=W&&oe>=W)return lIe(e,l,t.subarray(a,a+c));if(qS(e,l,1+(X>oe)),l+=2,X>oe){G=EL(u,d),H=u,U=EL(_,p),J=_;var ce=EL(w,k);for(qS(e,l,C-257),qS(e,l+5,B-1),qS(e,l+10,N-4),l+=14,S=0;N>S;++S)qS(e,l+3*S,w[Oat[S]]);l+=3*N;for(var te=[I,y],ie=0;2>ie;++ie){var ae=te[ie];for(S=0;ae.length>S;++S)qS(e,l,ce[re=31&ae[S]]),l+=w[re],re>15&&(qS(e,l,ae[S]>>>5&127),l+=ae[S]>>>12)}}else G=lTn,H=dP,U=gTn,J=hX;for(S=0;s>S;++S)if(o[S]>255){var re;BL(e,l,G[257+(re=o[S]>>>18&31)]),l+=H[re+257],re>7&&(qS(e,l,o[S]>>>23&31),l+=rIe[re]);var le=31&o[S];BL(e,l,U[le]),l+=J[le],le>3&&(BL(e,l,o[S]>>>5&8191),l+=AIe[le])}else BL(e,l,G[o[S]]),l+=H[o[S]];return BL(e,l,G[256]),l+H[256]},uTn=new E9([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),hTn=(function(){for(var t=new E9(256),e=0;256>e;++e){for(var n=e,o=9;--o;)n=(1&n&&3988292384)^n>>>1;t[e]=n}return t})(),gIe=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8};function dTn(t,e){e===void 0&&(e={});var n=(function(){var g=4294967295;return{p(u){for(var d=g,h=0;u.length>h;++h)d=hTn[255&d^u[h]]^d>>>8;g=d},d(){return 4294967295^g}}})(),o=t.length;n.p(t);var i,r,A,s,a,c=(s=10+((i=e).filename&&i.filename.length+1||0),a=8,(function(g,u,d,h,_,p){var m=g.length,I=new r2(h+m+5*(1+Math.floor(m/7e3))+_),C=I.subarray(h,I.length-_),f=0;if(!u||8>m)for(var y=0;m>=y;y+=65535){var B=y+65535;m>B?f=lIe(C,f,g.subarray(y,B)):(C[y]=!0,f=lIe(C,f,g.subarray(y,m)))}else{for(var x=uTn[u-1],S=x>>>13,M=8191&x,w=(1<<d)-1,k=new E1(32768),N=new E1(w+1),G=Math.ceil(d/3),H=2*G,U=function(Me){return(g[Me]^g[Me+1]<<G^g[Me+2]<<H)&w},J=new E9(25e3),W=new E1(288),X=new E1(32),oe=0,ce=0,te=(y=0,0),ie=0,ae=0;m>y;++y){var re=U(y),le=32767&y,ye=N[re];if(k[le]=ye,N[re]=le,y>=ie){var xe=m-y;if((oe>7e3||te>24576)&&xe>423){f=Wat(g,C,0,J,W,X,ce,te,ae,y-ae,f),te=oe=ce=0,ae=y;for(var be=0;286>be;++be)W[be]=0;for(be=0;30>be;++be)X[be]=0}var he=2,Se=0,Ie=M,He=le-ye&32767;if(xe>2&&re==U(y-He))for(var Je=Math.min(S,xe)-1,et=Math.min(32767,y),pe=Math.min(258,xe);et>=He&&--Ie&&le!=ye;){if(g[y+he]==g[y+he-He]){for(var $e=0;pe>$e&&g[y+$e]==g[y+$e-He];++$e);if($e>he){if(he=$e,Se=He,$e>Je)break;var Ge=Math.min(He,$e-2),Pe=0;for(be=0;Ge>be;++be){var Ue=y-He+be+32768&32767,Ne=Ue-k[Ue]+32768&32767;Ne>Pe&&(Pe=Ne,ye=Ue)}}}He+=(le=ye)-(ye=k[le])+32768&32767}if(Se){J[te++]=268435456|sIe[he]<<18|Yat[Se];var Ee=31&sIe[he],Oe=31&Yat[Se];ce+=rIe[Ee]+AIe[Oe],++W[257+Ee],++X[Oe],ie=y+he,++oe}else J[te++]=g[y],++W[g[y]]}}f=Wat(g,C,!0,J,W,X,ce,te,ae,y-ae,f)}return Jat(I,0,h+zat(f)+_)})(r=t,(A=e).level==null?6:A.level,A.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(r.length)))):12+A.mem,s,a)),l=c.length;return(function(g,u){var d=u.filename;if(g[0]=31,g[1]=139,g[2]=8,g[8]=2>u.level?4:u.level==9?2:0,g[9]=3,u.mtime!=0&&gIe(g,4,Math.floor(new Date(u.mtime||Date.now())/1e3)),d){g[3]=8;for(var h=0;d.length>=h;++h)g[h+10]=d.charCodeAt(h)}})(c,e),gIe(c,l-8,n.d()),gIe(c,l-4,o),c}var _Tn=!!epe||!!Zme,jat="text/plain",dX=!1,uIe=(t,e)=>{var n=t.split("#"),o=n[1],i=n[0].split("?"),r=i[0],A=i[1];if(!A)return t;var s=A.split("&").filter((a=>a.split("=")[0]!==e)).join("&");return r+(s?"?"+s:"")+(o?"#"+o:"")},hIe=function(t,e,n){var o;n===void 0&&(n=!0);var i=t.split("?"),r=i[0],A=i[1],s=fo({},e),a=(o=A?.split("&").map((l=>{var g,u=l.split("="),d=u[0],h=n&&(g=s[d])!==null&&g!==void 0?g:u[1];return delete s[d],d+"="+h})))!==null&&o!==void 0?o:[],c=(function(l,g){var u,d;g===void 0&&(g="&");var h=[];return pg(l,(function(_,p){To(_)||To(p)||p==="undefined"||(u=encodeURIComponent((m=>m instanceof File)(_)?_.name:_.toString()),d=encodeURIComponent(p),h[h.length]=d+"="+u)})),h.join(g)})(s);return c&&a.push(c),r+"?"+a.join("&")},x9=(t,e)=>{try{return JSON.stringify(t,((n,o)=>typeof o=="bigint"?o.toString():o),e)}catch{return rst(t)}},dIe=t=>{if(t.Lt)return t.Lt;var e=t.data,n=t.compression;if(e){if(n===WC.GZipJS){var o=dTn((function(s,a){var c=s.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(s);for(var l=new r2(s.length+(s.length>>>1)),g=0,u=function(p){l[g++]=p},d=0;c>d;++d){if(g+5>l.length){var h=new r2(g+8+(c-d<<1));h.set(l),l=h}var _=s.charCodeAt(d);128>_?u(_):2048>_?(u(192|_>>>6),u(128|63&_)):_>55295&&57344>_?(u(240|(_=65536+(1047552&_)|1023&s.charCodeAt(++d))>>>18),u(128|_>>>12&63),u(128|_>>>6&63),u(128|63&_)):(u(224|_>>>12),u(128|_>>>6&63),u(128|63&_))}return Jat(l,0,g)})(x9(e)),{mtime:0});return{contentType:jat,body:o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength),estimatedSize:o.byteLength}}if(n===WC.Base64){var i=(function(s){return s&&btoa(encodeURIComponent(s).replace(/%([0-9A-F]{2})/g,((a,c)=>String.fromCharCode(parseInt(c,16)))))})(x9(e)),r=(s=>"data="+encodeURIComponent(typeof s=="string"?s:x9(s)))(i);return{contentType:"application/x-www-form-urlencoded",body:r,estimatedSize:new Blob([r]).size}}var A=x9(e);return{contentType:"application/json",body:A,estimatedSize:new Blob([A]).size}}},Xat=t=>{var e,n,o=()=>t.transport==="sendBeacon"?{url:hIe(t.url,{compression:WC.Base64}),encodedBody:dIe(fo({},t,{compression:WC.Base64,Lt:void 0}))}:{url:uIe(t.url,"compression"),encodedBody:dIe(fo({},t,{compression:void 0,Lt:void 0}))};try{e=dIe(t)}catch(i){if(nst(t.compression,C9(t.url,"compression")))return wo.error("Failed to gzip request body, sending uncompressed payload",i),o();throw i}return e&&nst(t.compression,C9(t.url,"compression"))&&!((n=e.body)instanceof ArrayBuffer?tpe(new Uint8Array(n)):ArrayBuffer.isView(n)&&tpe(new Uint8Array(n.buffer,n.byteOffset,n.byteLength)))?(dX=!0,o()):{url:t.url,encodedBody:e}},$at=t=>{try{return Xat(t)}catch(e){return wo.error(e),void(t.callback==null||t.callback({statusCode:0,error:e}))}},mTn=(function(){var t=Ih((function*(e){var n=x9(e.data),o=yield(function(r,A,s){return npe.apply(this,arguments)})(n,Au.DEBUG,{rethrow:!0});if(!o)return e;var i=yield o.arrayBuffer();return fo({},e,{Lt:{contentType:jat,body:i,estimatedSize:i.byteLength}})}));return function(e){return t.apply(this,arguments)}})(),pTn=/Failed to fetch|NetworkError|Load failed/i,Zat=t=>{var e,n=$at(t);if(n){var o=n.url,i=n.encodedBody,r=i??{},A=r.contentType,s=r.body,a=r.estimatedSize,c=new Headers;pg(t.headers,(function(d,h){c.append(h,d)})),A&&c.append("Content-Type",A);var l=null,g=!1;if(zAt){var u=new zAt;l={signal:u.signal,timeout:setTimeout((()=>{var d,h;g=!0,u.abort((d=t.timeout,(h=new Error("PostHog request timed out"+(d?" after "+d+"ms":""))).name="AbortError",h))}),t.timeout)}}Zme(o,fo({method:t?.method||"GET",headers:c,keepalive:t.method==="POST"&&!t.Ft&&52428.8>(a||0),body:s,signal:(e=l)==null?void 0:e.signal},t.fetchOptions)).then((d=>d.text().then((h=>{var _={statusCode:d.status,text:h};if(d.status===200)try{_.json=JSON.parse(h)}catch(p){wo.error(p)}t.callback==null||t.callback(_)})))).catch((d=>{g&&d?.name==="AbortError"||(h=>h?.name==="TypeError"&&pTn.test(h?.message||""))(d)?wo.warn(d):wo.error(d),t.callback==null||t.callback({statusCode:0,error:d})})).finally((()=>l?clearTimeout(l.timeout):null))}},_Ie=t=>{try{var e=Xat(t),n=e.url,o=e.encodedBody,i=o??{},r=i.body,A=i.estimatedSize;if(!r)return;var s=r instanceof Blob?r:new Blob([r],{type:i.contentType});if(JC.sendBeacon(n,s))return;if(bs(t.data)&&t.data.length>1&&(A??0)>16384){var a=Math.ceil(t.data.length/2);return _Ie(fo({},t,{data:t.data.slice(0,a)})),void _Ie(fo({},t,{data:t.data.slice(a)}))}wo.warn("Beacon of ~"+(A??0)+" bytes was rejected by the browser, falling back to fetch"),Zat(fo({},t,{Ft:!0}))}catch(c){wo.warn("Beacon send failed",c)}},ITn=["/e/","/s/"],ect=(t,e)=>{var n=(i=>{var r=(A=>{var s=pL(A),a=s?.pathname||A.split(/[?#]/)[0];return a?a[0]==="/"?a:"/"+a:"/"})(i);return ITn.some((A=>((s,a)=>s.slice(s.length-a.length)===a)(r,A)))})(t),o=n?uIe(t,"ver"):t;return hIe(e===WC.GZipJS?uIe(o,"compression"):o,fo({_:new Date().getTime().toString()},n?{}:{ver:Au.JS_SDK_VERSION},e===WC.GZipJS?{}:{compression:e}))},_X=[];Zme&&_X.push({transport:"fetch",method:Zat}),epe&&_X.push({transport:"XHR",method(t){var e=$at(t);if(e){var n=new epe,o=e.encodedBody;n.open(t.method||"GET",e.url,!0);var i=o??{},r=i.contentType,A=i.body;pg(t.headers,(function(s,a){n.setRequestHeader(a,s)})),r&&n.setRequestHeader("Content-Type",r),t.timeout&&(n.timeout=t.timeout),n.onreadystatechange=()=>{if(n.readyState===4){var s={statusCode:n.status,text:n.responseText};if(n.status===200)try{s.json=JSON.parse(n.responseText)}catch{}t.callback==null||t.callback(s)}},n.send(A)}}}),JC!=null&&JC.sendBeacon&&_X.push({transport:"sendBeacon",method:_Ie});var mIe=3e3;class CTn{constructor(e,n){this.Or=!0,this.Lr=[],this.Fr=jx(n?.flush_interval_ms||mIe,250,5e3,wo.createLogger("flush interval"),mIe),this.Ar=e}enqueue(e){this.Lr.push(e),this.$r||this.Nr()}unload(){this.Dr();var e=this.Lr.length>0?this.qr():{},n=Object.values(e);[...n.filter((o=>o.url.indexOf("/e")===0)),...n.filter((o=>o.url.indexOf("/e")!==0))].map((o=>{this.jr(fo({},o,{transport:"sendBeacon"}))}))}enable(){this.Or=!1,this.Nr()}Nr(){var e=this;this.Or||(this.$r=setTimeout((()=>{if(this.Dr(),this.Lr.length>0){var n=this.qr(),o=function(){var r=n[i],A=new Date().getTime();r.data&&bs(r.data)&&pg(r.data,(s=>{s.offset=Math.abs(s.timestamp-A),delete s.timestamp})),e.jr(r)};for(var i in n)o()}}),this.Fr))}jr(e){try{this.Ar(e)}catch(n){wo.error(n)}}Dr(){clearTimeout(this.$r),this.$r=void 0}qr(){var e={};return pg(this.Lr,(n=>{var o,i=n,r=(i?i.batchKey:null)||i.url;To(e[r])&&(e[r]=fo({},i,{data:[]})),(o=e[r].data)==null||o.push(i.data)})),this.Lr=[],e}}var fTn=["retriesPerformedSoFar"];class yTn{constructor(e){this.Br=!1,this.Hr=3e3,this.Lr=[],this._instance=e,this.Lr=[],this.Ur=!0,!To(wn)&&"onLine"in wn.navigator&&(this.Ur=wn.navigator.onLine,this.zr=()=>{this.Ur=!0,this.Wr()},this.Vr=()=>{this.Ur=!1},au(wn,"online",this.zr),au(wn,"offline",this.Vr))}get length(){return this.Lr.length}retriableRequest(e){var n=e.retriesPerformedSoFar,o=jAt(e,fTn);KS(n)&&(o.url=hIe(o.url,{retry_count:n})),this._instance._send_request(fo({},o,{callback:i=>{if(i.statusCode!==200&&(400>i.statusCode||i.statusCode>=500)){if((i.statusCode===0?3:10)>(n??0))return void this.st(fo({retriesPerformedSoFar:n},o));i.statusCode===0&&wo.warn("Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after "+(n??0)+" retries.")}o.callback==null||o.callback(i)}}))}st(e){var n=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=n+1;var o=(function(A){var s=3e3*Math.pow(2,A),a=s/2,c=Math.min(18e5,s),l=Math.random()-.5;return Math.ceil(c+l*(c-a))})(n),i=Date.now()+o;this.Lr.push({retryAt:i,requestOptions:e});var r="Enqueued failed request for retry in "+o;navigator.onLine||(r+=" (Browser is offline)"),wo.warn(r),this.Br||(this.Br=!0,this.Zr())}Zr(){if(this.Gr&&clearTimeout(this.Gr),this.Lr.length===0)return this.Br=!1,void(this.Gr=void 0);this.Gr=setTimeout((()=>{this.Ur&&this.Lr.length>0&&this.Wr(),this.Zr()}),this.Hr)}Wr(){var e=Date.now(),n=[],o=this.Lr.filter((r=>e>r.retryAt||(n.push(r),!1)));if(this.Lr=n,o.length>0)for(var i of o)this.retriableRequest(i.requestOptions)}unload(){for(var e of(this.Gr&&(clearTimeout(this.Gr),this.Gr=void 0),this.Br=!1,To(wn)||(this.zr&&(wn.removeEventListener("online",this.zr),this.zr=void 0),this.Vr&&(wn.removeEventListener("offline",this.Vr),this.Vr=void 0)),this.Lr)){var n=e.requestOptions;try{this._instance._send_request(fo({},n,{transport:"sendBeacon"}))}catch(o){wo.error(o)}}this.Lr=[]}}class ETn{constructor(e){this.Qr=()=>{var n,o,i,r;this.Jr||(this.Jr={});var A=this.scrollElement(),s=this.scrollY(),a=A?Math.max(0,A.scrollHeight-A.clientHeight):0,c=s+(A?.clientHeight||0),l=A?.scrollHeight||0;this.Jr.lastScrollY=Math.ceil(s),this.Jr.maxScrollY=Math.max(s,(n=this.Jr.maxScrollY)!==null&&n!==void 0?n:0),this.Jr.maxScrollHeight=Math.max(a,(o=this.Jr.maxScrollHeight)!==null&&o!==void 0?o:0),this.Jr.lastContentY=c,this.Jr.maxContentY=Math.max(c,(i=this.Jr.maxContentY)!==null&&i!==void 0?i:0),this.Jr.maxContentHeight=Math.max(l,(r=this.Jr.maxContentHeight)!==null&&r!==void 0?r:0)},this._instance=e}get Kr(){return this._instance.config.scroll_root_selector}getContext(){return this.Jr}resetContext(){var e=this.Jr;return setTimeout(this.Qr,0),e}startMeasuringScrollPosition(){au(wn,"scroll",this.Qr,{capture:!0}),au(wn,"scrollend",this.Qr,{capture:!0}),au(wn,"resize",this.Qr)}scrollElement(){if(!this.Kr)return wn?.document.documentElement;var e=bs(this.Kr)?this.Kr:[this.Kr];for(var n of e){var o=wn?.document.querySelector(n);if(o)return o}}Yr(e){var n=e==="y"?"scrollTop":"scrollLeft";if(this.Kr){var o=this.scrollElement();return o&&o[n]||0}return wn?e==="y"?wn.scrollY||wn.pageYOffset||wn.document.documentElement.scrollTop||0:wn.scrollX||wn.pageXOffset||wn.document.documentElement.scrollLeft||0:0}scrollY(){return this.Yr("y")}scrollX(){return this.Yr("x")}}var BTn=t=>Tat(t?.config.mask_personal_data_properties,t?.config.custom_personal_data_properties,t?.config.disable_capture_url_hashes);class tct{constructor(e,n,o,i){this.Xr=r=>{var A=this.ei();if(!A||A.sessionId!==r){var s={sessionId:r,props:this.ti(this._instance)};this.ri.register({[Lpe]:s})}},this._instance=e,this.ii=n,this.ri=o,this.ti=i||BTn,this.ii.onSessionId(this.Xr)}ei(){return this.ri.props[Lpe]}getSetOnceProps(){var e,n=(e=this.ei())==null?void 0:e.props;return n?"r"in n?kat(n,this._instance.config.disable_capture_url_hashes):{$referring_domain:n.referringDomain,$pathname:n.initialPathName,utm_source:n.utm_source,utm_campaign:n.utm_campaign,utm_medium:n.utm_medium,utm_content:n.utm_content,utm_term:n.utm_term}:{}}getSessionProps(){var e={};return pg(zpe(this.getSetOnceProps()),((n,o)=>{o==="$current_url"&&(o="url"),e["$session_entry_"+ope(o)]=n})),e}}class pIe{constructor(){this.ni={}}on(e,n){return this.ni[e]||(this.ni[e]=[]),this.ni[e].push(n),()=>{this.ni[e]=this.ni[e].filter((o=>o!==n))}}emit(e,n){for(var o of this.ni[e]||[])o(n);for(var i of this.ni["*"]||[])i(e,n)}}var QL=v0("[SessionId]");class nct{on(e,n){return this.si.on(e,n)}constructor(e,n,o){var i;if(this.oi=null,this.ai=[],this.li=void 0,this.ui=!1,this.si=new pIe,this.hi=(c,l)=>!(!KS(c)||!KS(l))&&Math.abs(c-l)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode===VS)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Se=e.config,this.ri=e.persistence,this.di=void 0,this.ci=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.vi=n||zS,this.fi=o||zS;var r=this.Se.persistence_name||this.Se.token;if(this._sessionTimeoutMs=1e3*jx(this.Se.session_idle_timeout_seconds||1800,60,36e3,QL.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.pi(),this.gi="ph_"+r+"_window_id",this.mi="ph_"+r+"_primary_window_exists",this.yi()){var A=Mp.F(this.gi),s=Mp.F(this.mi);A&&!s?this.di=A:Mp.P(this.gi),Mp.q(this.mi,!0)}if((i=this.Se.bootstrap)!=null&&i.sessionID)try{var a=(c=>{var l=this.Se.bootstrap.sessionID.replace(/-/g,"");if(l.length!==32)throw new Error("Not a valid UUID");if(l[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(l.substring(0,12),16)})();this.bi(this.Se.bootstrap.sessionID,new Date().getTime(),a)}catch(c){QL.error("Invalid sessionID in bootstrap",c)}this.wi()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return To(this.ai)&&(this.ai=[]),this.ai.push(e),this.ci&&e(this.ci,this.di),()=>{this.ai=this.ai.filter((n=>n!==e))}}yi(){return this.Se.persistence!=="memory"&&!this.ri.ir&&Mp.N()}xi(e){e!==this.di&&(this.di=e,this.yi()&&Mp.q(this.gi,e))}ki(){return this.di?this.di:this.yi()?Mp.F(this.gi):null}Si(e){var n=this.oi;return!qC(n)&&!qC(e)&&5e3>Math.abs(e-n)}bi(e,n,o){var i=n!==this._sessionActivityTimestamp,r=!(e!==this.ci||o!==this._sessionStartTimestamp);this._sessionStartTimestamp=o,this._sessionActivityTimestamp=n,this.ci=e,r&&!i||r&&this.Si(n)||(this.oi=n,this.ri.register({[d9]:[n,e,o]}))}Ci(){var e,n=(e=this.Se)==null?void 0:e.persistence_save_debounce_ms;return KS(n)&&n>0}Ti(){this.Ci()?this.ri.refreshKey(d9):(this.ri.flush(),this.ri.load())}Ii(){var e;if(!qC(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this.oi){this.Ti();var n=this.Mi();n[1]===this.ci&&n[2]===this._sessionStartTimestamp&&(this.oi=this._sessionActivityTimestamp,this.ri.register({[d9]:[this._sessionActivityTimestamp,(e=this.ci)!==null&&e!==void 0?e:null,this._sessionStartTimestamp]}),this.ri.flush())}}Ei(){var e=this.Mi()[0],n=KS(e)?e:0,o=KS(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(n,o)}Ri(e){return this.Ti(),this.hi(e,this.Ei())}Mi(){var e=this.ri.props[d9];return bs(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.oi=null,clearTimeout(this.Pi),this.Pi=void 0,this.bi(null,null,null)}destroy(){this.ui=!0,this.Ii(),clearTimeout(this.Pi),this.Pi=void 0,this.li&&wn&&(wn.removeEventListener(nX,this.li,{capture:!1}),this.li=void 0),this.ai=[]}wi(){this.li=()=>{this.Ii(),this.yi()&&Mp.P(this.mi)},au(wn,nX,this.li,{capture:!1})}checkAndGetSessionAndWindowId(e,n){if(e===void 0&&(e=!1),n===void 0&&(n=null),this.Se.cookieless_mode===VS)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var o=n||new Date().getTime(),i=this.Mi(),r=i[1],A=i[2],s=this.Ei(),a=this.ki(),c=KS(A)&&Math.abs(o-A)>864e5,l=!1,g=!1,u=!r,d=r,h=!u&&!e&&this.hi(o,s);if(h){(h=this.Ri(o))||QL.info("cross-tab refresh kept the session alive",{sessionId:r});var _=this.Mi();r=_[1],A=_[2]}u||h||c?(r=this.vi(),a=this.fi(),QL.info("new session ID generated",{sessionId:r,windowId:a,changeReason:{noSessionId:u,activityTimeout:h,sessionPastMaximumLength:c}}),A=o,l=!0):(a||(a=this.fi(),l=!0),(g=r!==d)&&(QL.info("adopted cross-tab session id",{sessionId:r,windowId:a}),l=!0));var p=KS(s)&&e&&!c?s:o,m=KS(A)?A:new Date().getTime();this.xi(a),this.bi(r,p,m),e||this.pi();var I={noSessionId:u,activityTimeout:h,sessionPastMaximumLength:c,crossTabAdoption:g};return l&&this.ai.forEach((C=>C(r,a,I))),{sessionId:r,windowId:a,sessionStartTimestamp:m,changeReason:l?I:void 0,lastActivityTimestamp:s}}pi(){this.ui||(clearTimeout(this.Pi),this.Pi=setTimeout((()=>{if(!this.ui)if(this.Ri(new Date().getTime())){var e=this.ci;this.resetSessionId(),this.si.emit("forcedIdleReset",{idleSessionId:e})}else this.pi()}),1.1*this.sessionTimeoutMs))}}var oct=function(t,e){if(!t)return!1;var n=t.userAgent;if(n&&ist(n,e))return!0;try{var o=t?.userAgentData;if(o!=null&&o.brands&&o.brands.some((i=>ist(i?.brand,e))))return!0}catch{}return!!t.webdriver};function ict(){return(ict=Ih((function*(){var t=JC?.userAgentData;if(t!=null&&t.getHighEntropyValues)try{var e=yield t.getHighEntropyValues(["model"]),n=e?.model;return Xl(n)&&n.length>0?n:void 0}catch(o){return void wo.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",o)}}))).apply(this,arguments)}var mX=function(t,e){if(!(function(n){try{new RegExp(n)}catch{return!1}return!0})(e))return!1;try{return new RegExp(e).test(t)}catch{return!1}};function rct(t,e,n){return x9({distinct_id:t,userPropertiesToSet:e,userPropertiesToSetOnce:n})}var Act={exact:(t,e)=>e.some((n=>t.some((o=>n===o)))),is_not:(t,e)=>e.every((n=>t.every((o=>n!==o)))),regex:(t,e)=>e.some((n=>t.some((o=>mX(n,o))))),not_regex:(t,e)=>e.every((n=>t.every((o=>!mX(n,o))))),icontains:(t,e)=>e.map(pX).some((n=>t.map(pX).some((o=>n.includes(o))))),not_icontains:(t,e)=>e.map(pX).every((n=>t.map(pX).every((o=>!n.includes(o))))),gt:(t,e)=>e.some((n=>{var o=parseFloat(n);return!isNaN(o)&&t.some((i=>o>parseFloat(i)))})),lt:(t,e)=>e.some((n=>{var o=parseFloat(n);return!isNaN(o)&&t.some((i=>o<parseFloat(i)))}))},pX=t=>t.toLowerCase();function sct(t,e){return!t||Object.entries(t).every((n=>{var o=n[1],i=e?.[n[0]];if(To(i)||qC(i))return!1;var r=[String(i)],A=Act[o.operator];return!!A&&A(o.values,r)}))}var IIe="custom",act="i.posthog.com",xTn=/^\/static\//;class QTn{constructor(e){this.Oi={},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,n=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return n||(n=this.apiHost.replace("."+act,".posthog.com")),n==="https://app.posthog.com"?"https://us.posthog.com":n}get region(){return this.Oi[this.apiHost]||(this.Oi[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":IIe),this.Oi[this.apiHost]}Li(e){if(xTn.test(e)){var n=this.instance.config.asset_host;if(typeof n=="string")return n.trim().replace(/\/$/,"")||void 0}}endpointFor(e,n){if(n===void 0&&(n=""),n&&(n=n[0]==="/"?n:"/"+n),e==="ui")return this.uiHost+n;if(e==="flags")return this.flagsApiHost+n;if(e==="assets"){var o=this.Li(n);if(o)return""+o+n}if(this.region===IIe)return this.apiHost+n;var i=act+n;switch(e){case"assets":return"https://"+this.region+"-assets."+i;case"api":return"https://"+this.region+"."+i}}}var $l=v0("[Surveys]"),CIe="seenSurvey_",cct=t=>{try{var e=(n=>((o,i)=>{var r=""+CIe+i.id;return i.current_iteration&&i.current_iteration>0&&(r=""+CIe+i.id+"_"+i.current_iteration),r})(0,n))(t);if(localStorage.getItem(e))return;localStorage.setItem(e,"true")}catch(n){$l.error("Failed to persist survey seen state",n)}},STn=[nIe.Popover,nIe.Widget,nIe.API],bTn={ignoreConditions:!1,ignoreDelay:!1,displayType:iIe.Popover},DTn=v0("[PostHog ExternalIntegrations]"),MTn={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class wTn{constructor(e){this._instance=e}Bt(e,n){var o;(o=_r.__PosthogExtensions__)==null||o.loadExternalDependency==null||o.loadExternalDependency(this._instance,e,(i=>{if(i)return DTn.error("failed to load script",i);n()}))}startIfEnabledOrStop(){var e=this,n=function(){var r,A,s,a=o[0],c=o[1];!c||(r=_r.__PosthogExtensions__)!=null&&(r=r.integrations)!=null&&r[a]||e.Bt(MTn[a],(()=>{var l;(l=_r.__PosthogExtensions__)==null||(l=l.integrations)==null||(l=l[a])==null||l.start(e._instance)})),!c&&(A=_r.__PosthogExtensions__)!=null&&(A=A.integrations)!=null&&A[a]&&((s=_r.__PosthogExtensions__)==null||(s=s.integrations)==null||(s=s[a])==null||s.stop())};for(var o of Object.entries((i=this._instance.config.integrations)!==null&&i!==void 0?i:{})){var i;n()}}}var SL={},fIe=0,IX=()=>{},lct='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',bL="Surveys module not available",gct="sanitize_properties is deprecated. Use before_send instead",uct="Invalid value for property_denylist config: ",Q9="posthog",hct=!_Tn&&y1?.indexOf("MSIE")===-1&&y1?.indexOf("Mozilla")===-1,dct=t=>{var e;return fo({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:vRn(Zo?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:IX,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:t??"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:rd&&Xl(rd?.search)&&rd.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,disableDeviceModel:!1,disable_external_dependency_loading:!1,strict_script_versioning:!1,enable_recording_console_log:void 0,secure_cookie:(wn==null||(e=wn.location)==null?void 0:e.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(n){wo.error("Bad HTTP status: "+n.statusCode+" "+n.text)},get_device_id:n=>n,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Upe,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:mIe},error_tracking:{},_onCapture:IX},(n=>({rageclick:n&&n>="2026-05-30"?{content_ignorelist:YRn,ignore_text_selection:!0}:!n||"2025-11-30">n||{content_ignorelist:!0},capture_pageview:!n||"2025-05-24">n||"history_change",session_recording:n&&n>="2026-06-25"?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6},streamNetworkBody:!0}:n&&n>="2026-05-30"?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6}}:n&&n>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:n&&n>="2026-01-30"?"head":"body",internal_or_test_user_hostname:n&&n>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:n&&n>="2026-05-30"?250:0,split_storage:!(!n||"2026-05-30">n),detect_google_search_app:!(!n||"2026-05-30">n),disable_capture_url_hashes:!(!n||"2026-06-25">n)}))(t))},PTn=[["process_person","person_profiles"],["xhr_headers","request_headers"],["cookie_name","persistence_name"],["disable_cookie","disable_persistence"],["__preview_disable_beacon","disable_beacon"],["store_google","save_campaign_params"],["verbose","debug"]],_ct=t=>{var e={};for(var n of PTn){var o=n[0],i=n[1];To(t[o])||(e[i]=t[o])}var r=jg({},e,t),A=t.__preview_external_dependency_versioned_paths;return To(A)||(To(t.strict_script_versioning)&&(r.strict_script_versioning=!!A),Xl(A)&&To(t.asset_host)&&(r.asset_host=A)),bs(t.property_blacklist)&&(To(t.property_denylist)?r.property_denylist=t.property_blacklist:bs(t.property_denylist)?r.property_denylist=[...t.property_blacklist,...t.property_denylist]:wo.error(uct+t.property_denylist)),r};class vTn{constructor(){this.__forceAllowLocalhost=!1}get Fi(){return this.__forceAllowLocalhost}set Fi(e){wo.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class A2{Ai(e,n){if(e){var o=this.$i.indexOf(e);o!==-1&&this.$i.splice(o,1)}return this.$i.push(n),n.initialize==null||n.initialize(),n}Ni(){return this.config.cookieless_mode===VS||this.config.cookieless_mode===gP&&this.consent.isRejected()}get decideEndpointWasHit(){var e,n;return(e=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,n;return(e=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){var e;this.webPerformance=new vTn,this.Di=!1,this.version=Au.LIB_VERSION,this.qi=new pIe,this.$i=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=dct(),this.SentryIntegration=ZRn,this.sentryIntegration=o=>(function(i,r){var A=Sat(i,r);return{name:Qat,processEvent:s=>A(s)}})(this,o),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.ji=!1,this.Bi=null,this.Hi=null,this.Ui=null,this.scrollManager=new ETn(this),this.pageViewManager=new bat(this),this.rateLimiter=new cTn(this),this.requestRouter=new QTn(this),this.consent=new HRn(this),this.externalIntegrations=new wTn(this);var n=(e=A2.__defaultExtensionClasses)!==null&&e!==void 0?e:{};this.featureFlags=n.featureFlags&&new n.featureFlags(this),this.toolbar=n.toolbar&&new n.toolbar(this),this.surveys=n.surveys&&new n.surveys(this),this.conversations=n.conversations&&new n.conversations(this),this.logs=n.logs&&new n.logs(this),this.metrics=n.metrics&&new n.metrics(this),this.experiments=n.experiments&&new n.experiments(this),this.exceptions=n.exceptions&&new n.exceptions(this),this.people={set:(o,i,r)=>{var A=Xl(o)?{[o]:i}:o;this.setPersonProperties(A),r?.({})},set_once:(o,i,r)=>{var A=Xl(o)?{[o]:i}:o;this.setPersonProperties(void 0,A),r?.({})}},this.on("eventCaptured",(o=>wo.info('send "'+o?.event+'"',o)))}init(e,n,o){if(o&&o!==Q9){var i,r=(i=SL[o])!==null&&i!==void 0?i:new A2;return r._init(e,n,o),SL[o]=r,SL[Q9][o]=r,r}return this._init(e,n,o)}_init(e,n,o){var i,r;n===void 0&&(n={});var A=Xl(e)?e.trim():"";if(!A)return wo.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={},n.debug=this.zi(n.debug),this.Wi=n,this.Vi=[],n.person_profiles?this.Hi=n.person_profiles:n.process_person&&(this.Hi=n.process_person);var s=dct(n.defaults),a=_ct(n),c=jg({},s,a,{name:o,token:A});P0(s.rageclick)&&P0(a.rageclick)&&(c.rageclick=jg({},s.rageclick,a.rageclick)),P0(s.session_recording)&&P0(a.session_recording)&&(c.session_recording=jg({},s.session_recording,a.session_recording)),this.set_config(c),this.config.on_xhr_error&&wo.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=n.disable_compression?void 0:WC.GZipJS;var l=this.Zi();this.persistence=new tIe(this.config,l),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new tIe(fo({},this.config,{persistence:"sessionStorage"}),l,!1);var g=fo({},this.persistence.props),u=fo({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Gi=new CTn((f=>this.Qi(f)),this.config.request_queue_config),this.Ji=new yTn(this),this.__request_queue=[];var d=this.Ni();if(d||(this.sessionManager=new nct(this),this.sessionPropsManager=new tct(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(wo.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.Ki(d)}),0)):(wo.info("Initializing extensions synchronously"),this.Ki(d)),Au.DEBUG=Au.DEBUG||this.config.debug,Au.DEBUG&&wo.info("Starting in debug mode",{this:this,config:n,thisC:fo({},this.config),p:g,s:u}),!this.config.identity_distinct_id||(i=n.bootstrap)!=null&&i.distinctID||(n.bootstrap=fo({},n.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),((r=n.bootstrap)==null?void 0:r.distinctID)!==void 0){var h=n.bootstrap.distinctID,_=this.get_distinct_id(),p=this.persistence.get_property(IB);if(n.bootstrap.isIdentifiedID&&_!=null&&_!==h&&p===m9)this.identify(h);else if(n.bootstrap.isIdentifiedID&&_!=null&&_!==h&&p===p9)wo.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 m=this.config.get_device_id(zS()),I=n.bootstrap.isIdentifiedID?m:h;this.persistence.set_property(IB,n.bootstrap.isIdentifiedID?p9:m9),this.register({distinct_id:h,$device_id:I})}}if(d)this.register_once({distinct_id:eX,$device_id:null},"");else if(!this.get_distinct_id()){var C=this.config.get_device_id(zS());this.register_once({distinct_id:C,$device_id:C},""),this.persistence.set_property(IB,m9)}return au(wn,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),n.segment?(function(f,y){var B=f.config.segment;if(!B)return y();(function(x,S){var M=x.config.segment;if(!M)return S();var w=N=>{var G=()=>N.anonymousId()||zS();x.config.get_device_id=G,N.id()&&(x.register({distinct_id:N.id(),$device_id:G()}),x.persistence.set_property(IB,p9)),S()},k=M.user();"then"in k&&pB(k.then)?k.then(w):w(k)})(f,(()=>{B.register((x=>{typeof Promise<"u"&&Promise.resolve||eIe.warn("This browser does not have Promise support, and can not use the segment integration");var S=(M,w)=>{if(!w)return M;M.event.userId||M.event.anonymousId===x.get_distinct_id()||(eIe.info("No userId set, resetting PostHog"),x.reset()),M.event.userId&&M.event.userId!==x.get_distinct_id()&&(eIe.info("UserId set, identifying with PostHog"),x.identify(M.event.userId));var k=x.calculateEventProperties(w,M.event.properties);return M.event.properties=Object.assign({},k,M.event.properties),M};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:M=>S(M,M.event.event),page:M=>S(M,I9),identify:M=>S(M,Vpe),screen:M=>S(M,"$screen")}})(f)).then((()=>{y()}))}))})(this,(()=>this.Yi())):this.Yi(),pB(this.config._onCapture)&&this.config._onCapture!==IX&&(wo.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(f=>this.config._onCapture(f.event,f)))),this.config.ip&&wo.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.config.disableDeviceModel||(function(){return ict.apply(this,arguments)})().then((f=>{f&&this.register({[ype]:f})})).catch(IX),this}Ki(e){var n,o,i,r,A,s,a,c,l=performance.now(),g=fo({},A2.__defaultExtensionClasses,this.config.__extensionClasses),u=[];g.featureFlags&&this.$i.push(this.featureFlags=(n=this.featureFlags)!==null&&n!==void 0?n:new g.featureFlags(this)),g.exceptions&&this.$i.push(this.exceptions=(o=this.exceptions)!==null&&o!==void 0?o:new g.exceptions(this)),g.historyAutocapture&&this.$i.push(this.historyAutocapture=new g.historyAutocapture(this)),g.tracingHeaders&&this.$i.push(this.tracingHeaders=new g.tracingHeaders(this)),g.siteApps&&this.$i.push(this.siteApps=new g.siteApps(this)),g.sessionRecording&&!e&&this.$i.push(this.sessionRecording=new g.sessionRecording(this)),this.config.disable_scroll_properties||u.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),g.autocapture&&this.$i.push(this.autocapture=new g.autocapture(this)),g.surveys&&this.$i.push(this.surveys=(i=this.surveys)!==null&&i!==void 0?i:new g.surveys(this)),g.logs&&this.$i.push(this.logs=(r=this.logs)!==null&&r!==void 0?r:new g.logs(this)),g.metrics&&this.$i.push(this.metrics=(A=this.metrics)!==null&&A!==void 0?A:new g.metrics(this)),g.conversations&&this.$i.push(this.conversations=(s=this.conversations)!==null&&s!==void 0?s:new g.conversations(this)),g.productTours&&this.$i.push(this.productTours=new g.productTours(this)),g.heatmaps&&this.$i.push(this.heatmaps=new g.heatmaps(this)),g.webVitalsAutocapture&&this.$i.push(this.webVitalsAutocapture=new g.webVitalsAutocapture(this)),g.exceptionObserver&&this.$i.push(this.exceptionObserver=new g.exceptionObserver(this)),g.deadClicksAutocapture&&this.$i.push(this.deadClicksAutocapture=new g.deadClicksAutocapture(this,$Rn)),g.toolbar&&this.$i.push(this.toolbar=(a=this.toolbar)!==null&&a!==void 0?a:new g.toolbar(this)),g.experiments&&this.$i.push(this.experiments=(c=this.experiments)!==null&&c!==void 0?c:new g.experiments(this)),this.$i.forEach((d=>{d.initialize&&u.push((()=>{d.initialize==null||d.initialize()}))})),u.push((()=>{if(this.Xi){var d=this.Xi;this.Xi=void 0,this.Mr(d)}})),this.en(u,l)}en(e,n){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-n>=30&&e.length>0)return void setTimeout((()=>{this.en(e,n)}),0);var o=e.shift();if(o)try{o()}catch(r){wo.error("Error initializing extension:",r)}}var i=Math.round(performance.now()-n);this.register_for_session({[Xst]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[$st]:i}),this.config.__preview_deferred_init_extensions&&wo.info("PostHog extensions initialized ("+i+"ms)")}Mr(e){var n;if(!Zo||!Zo.body)return wo.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.Mr(e)}),500);this.config.__preview_deferred_init_extensions&&(this.Xi=e),this.tn=e,this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=gA(e.supportedCompression,WC.GZipJS)?WC.GZipJS:gA(e.supportedCompression,WC.Base64)?WC.Base64:void 0),(n=e.analytics)!=null&&n.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Hi?this.Hi:Upe}),this.$i.forEach((o=>o.onRemoteConfig==null?void 0:o.onRemoteConfig(e)))}Yi(){try{this.config.loaded(this)}catch(o){wo.critical("`loaded` function failed",o)}if(this.rn(),this.config.internal_or_test_user_hostname&&rd!=null&&rd.hostname){var e=rd.hostname,n=this.config.internal_or_test_user_hostname;(typeof n=="string"?e===n:n.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.Ni())&&this.nn()}),1),this.sn=new Gat(this),this.sn.load()}rn(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Gi)==null||e.enable())}_dom_loaded(){this.is_capturing()&&oX(this.__request_queue,(e=>this.Qi(e))),this.__request_queue=[],this.rn()}_handle_unload(){var e,n,o,i,r;(e=this.surveys)==null||e.handlePageUnload==null||e.handlePageUnload(),(n=this.metrics)==null||n.flush("sendBeacon"),this.config.request_batching?(this.an()&&this.capture(Ype),(o=this.logs)==null||o.flushLogs("sendBeacon"),(i=this.Gi)==null||i.unload(),(r=this.Ji)==null||r.unload()):this.an()&&this.capture(Ype,null,{transport:"sendBeacon"})}_send_request(e){this.__loaded?hct?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)?e.fireCallbackOnDrop&&(e.callback==null||e.callback({statusCode:429})):(e.transport=e.transport||this.config.api_transport,e.headers=fo({},this.config.request_headers,e.headers),e.compression=e.compression==="best-available"?this.compression:e.compression,(To(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(n=>{var o,i,r,A=fo({},n);A.timeout=A.timeout||6e4;var s=(o=A.transport)!==null&&o!==void 0?o:"fetch";s==="sendBeacon"&&To(A.compression)&&A.data&&(A.compression=WC.Base64),A.url=ect(A.url,A.compression);var a=_X.filter((l=>!A.disableTransport||!l.transport||!A.disableTransport.includes(l.transport))),c=(i=(r=(function(l,g){for(var u=0;l.length>u;u++)if(l[u].transport===s)return l[u]})(a))==null?void 0:r.method)!==null&&i!==void 0?i:a[0].method;if(!c)throw new Error("No available transport method");s!=="sendBeacon"&&A.data&&A.compression===WC.GZipJS&&TNn&&typeof Promise<"u"&&!dX?mTn(A).then((l=>{c(l)})).catch((l=>{if(ost(l))return dX=!0,void c(fo({},A,{compression:void 0,url:ect(n.url,void 0)}));(g=>{if(!g||typeof g!="object")return!1;var u="name"in g?String(g.name):"";return ost(g)||u===tst})(l)&&(dX=!0),c(A)})):c(A)})(fo({},e,{callback:n=>{var o,i;this.rateLimiter.checkForLimiting(n),400>n.statusCode||(o=(i=this.config).on_request_error)==null||o.call(i,n),e.callback==null||e.callback(n)}}))):e.fireCallbackOnDrop&&(e.callback==null||e.callback({statusCode:0}))}Qi(e){this.Ji?this.Ji.retriableRequest(e):this._send_request(e)}_execute_array(e){fIe++;try{var n,o=[],i=[],r=[];oX(e,(s=>{if(s)if(bs(n=s[0]))r.push(s);else if(pB(s))try{s.call(this)}catch(a){wo.error("Error executing queued PostHog call",s,a)}else bs(s)&&n==="alias"?o.push(s):bs(s)&&n.indexOf("capture")!==-1&&pB(this[n])?r.push(s):i.push(s)}));var A=function(s,a){oX(s,(function(c){try{if(bs(c[0])){var l=a;pg(c,(function(g){l=l[g[0]].apply(l,g.slice(1))}))}else a[c[0]].apply(a,c.slice(1))}catch(g){wo.error("Error executing queued PostHog call",c,g)}}))};A(o,this),A(i,this),A(r,this)}finally{fIe--}}push(e){if(fIe>0&&bs(e)&&Xl(e[0])){var n=A2.prototype[e[0]];pB(n)&&n.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,n,o){var i,r,A,s,a;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Gi){if(this.is_capturing())if(!To(e)&&Xl(e)){var c=!this.config.opt_out_useragent_filter&&this._is_bot();if(!c||this.config.__preview_capture_bot_pageviews){var l=o!=null&&o.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(l==null||!l.isRateLimited){n!=null&&n.$current_url&&!Xl(n?.$current_url)&&(wo.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),n==null||delete n.$current_url),e!=="$exception"||o!=null&&o.ln||wo.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 g=new Date,u=o?.timestamp||g,d=vst(o?.uuid,zS),h={uuid:d,event:e,properties:this.calculateEventProperties(e,n||{},u,d)};e===I9&&this.config.__preview_capture_bot_pageviews&&c&&(h.event="$bot_pageview",h.properties.$browser_type="bot"),l&&(h.properties.$lib_rate_limit_remaining_tokens=l.remainingTokens),o?.$set&&(h.$set=o?.$set);var _=o?.$unset;_&&(h.$unset=_);var p,m,I,C=this.un(o?.$set_once,e!==eat,e===Vpe);if(C&&(h.$set_once=C),o!=null&&o._noTruncate||(r=this.config.properties_string_max_length,A=h,s=w=>Xl(w)?w.slice(0,r):w,a=new Set,h=(function w(k,N){return k!==Object(k)?s?s(k):k:a.has(k)?void 0:(a.add(k),bs(k)?(G=[],oX(k,(H=>{G.push(w(H))}))):(G={},pg(k,((H,U)=>{a.has(H)||(G[U]=w(H))}))),G);var G})(A)),h.timestamp=u,To(o?.timestamp)||(h.properties.$event_time_override_provided=!0,h.properties.$event_time_override_system_time=g),e===JS.DISMISSED||e===JS.SENT){var f=n?.[oIe.SURVEY_ID],y=n?.[oIe.SURVEY_ITERATION];cct({id:f,current_iteration:y}),h.$set=fo({},h.$set,{[(p={id:f,current_iteration:y},m=e===JS.SENT?"responded":"dismissed",I="$survey_"+m+"/"+p.id,p.current_iteration&&p.current_iteration>0&&(I="$survey_"+m+"/"+p.id+"/"+p.current_iteration),I)]:!0})}else e===JS.SHOWN&&(h.$set=fo({},h.$set,{[oIe.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(e===aTn.SHOWN){var B=n?.[Lat.TOUR_TYPE];B&&(h.$set=fo({},h.$set,{[Lat.TOUR_LAST_SEEN_DATE+"/"+B]:new Date().toISOString()}))}var x=fo({},h.properties.$set,h.$set);if(Ob(x)||this.setPersonPropertiesForFlags(x),!as(this.config.before_send)){var S=this.it(h);if(!S)return;(h=S).uuid=vst(h.uuid,zS)}this.qi.emit("eventCaptured",h);var M={method:"POST",url:(i=o?._url)!==null&&i!==void 0?i:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:h,compression:"best-available",batchKey:o?._batchKey,transport:o?.transport};return!this.config.request_batching||o&&(o==null||!o._batchKey)||o!=null&&o.send_instantly?this.Qi(M):this.Gi.enqueue(M),h}wo.critical("This capture call is ignored due to client rate limiting.")}}else wo.error("No event name provided to posthog.capture")}else wo.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(n=>e(n.event,n)))}calculateEventProperties(e,n,o,i,r){if(o=o||new Date,!this.persistence||!this.sessionPersistence)return n;var A=r?void 0:this.persistence.remove_event_timer(e),s=fo({},n);if(s.token=this.config.token,s.$config_defaults=this.config.defaults,this.Ni()&&(s.$cookieless_mode=!0),e==="$snapshot"){var a=fo({},this.persistence.properties(),this.sessionPersistence.properties());return s.distinct_id=a.distinct_id,(!Xl(s.distinct_id)&&!Dp(s.distinct_id)||ipe(s.distinct_id))&&wo.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),s}var c,l=(function(m,I,C,f){var y,B,x,S;if(f===void 0&&(f=!1),!y1)return{};var M,w,k,N,G,H,U,J,W,X=m?[...f9,...I||[]]:[],oe=(function(ae){for(var re=0;wst.length>re;re++){var le=wst[re],ye=le[1],xe=le[0].exec(ae),be=xe&&(pB(ye)?ye(xe,ae):ye);if(be)return be}return["",""]})(y1),ce=(M=typeof navigator<"u"?navigator:void 0)!=null&&M.brave?{brave:!0}:{},te={detectGoogleSearchApp:C},ie=jg(zpe({$os:oe[0],$os_version:oe[1],$browser:Mst(y1,navigator.vendor,ce,te),$device:Pst(y1),$device_type:(k=y1,N={userAgentDataPlatform:(y=navigator)==null||(y=y.userAgentData)==null?void 0:y.platform,maxTouchPoints:(B=navigator)==null?void 0:B.maxTouchPoints,screenWidth:wn==null||(x=wn.screen)==null?void 0:x.width,screenHeight:wn==null||(S=wn.screen)==null?void 0:S.height,devicePixelRatio:wn?.devicePixelRatio},W=Pst(k),W===lst||W===cst||W==="Kobo"||W==="Kindle Fire"||W===xst?c9:W===iL||W===u9||W===rL||W===gpe?"Console":W===ust?"Wearable":W?Ty:N?.userAgentDataPlatform==="Android"&&((G=N?.maxTouchPoints)!==null&&G!==void 0?G:0)>0?600>Math.min((H=N?.screenWidth)!==null&&H!==void 0?H:0,(U=N?.screenHeight)!==null&&U!==void 0?U:0)/((J=N?.devicePixelRatio)!==null&&J!==void 0?J:1)?Ty:c9:"Desktop"),$timezone:Fat(),$timezone_offset:iTn()}),{$current_url:IL(f?Kb(rd?.href):rd?.href,X,CL),$host:rd?.host,$pathname:rd?.pathname,$raw_user_agent:y1.length>1e3?y1.substring(0,997)+"...":y1,$browser_version:eRn(y1,navigator.vendor,ce,te),$browser_language:Nat(),$browser_language_prefix:(w=Nat(),typeof w=="string"?w.split("-")[0]:void 0),$screen_height:wn?.screen.height,$screen_width:wn?.screen.width,$viewport_height:wn?.innerHeight,$viewport_width:wn?.innerWidth,$lib:Au.LIB_NAME,$lib_version:Au.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return Au.SDK_DIST_CHANNEL&&(ie.$sdk_dist_channel=Au.SDK_DIST_CHANNEL),ie})(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){var g=this.sessionManager.checkAndGetSessionAndWindowId(r,o.getTime()),u=g.windowId;s.$session_id=g.sessionId,s.$window_id=u}this.sessionPropsManager&&jg(s,this.sessionPropsManager.getSessionProps());try{var d;this.sessionRecording&&jg(s,this.sessionRecording.sdkDebugProperties),s.$sdk_debug_retry_queue_size=(d=this.Ji)==null?void 0:d.length}catch(m){s.$sdk_debug_error_capturing_properties=String(m)}if(this.requestRouter.region===IIe&&(s.$lib_custom_api_host=this.config.api_host),c=e!==I9||r?e!==Ype||r?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(o):this.pageViewManager.doPageView(o,i),s=jg(s,c),e===I9&&Zo&&(s.title=Zo.title),!To(A)){var h=o.getTime()-A;s.$duration=parseFloat((h/1e3).toFixed(3))}y1&&this.config.opt_out_useragent_filter&&(s.$browser_type=this._is_bot()?"bot":"browser"),(s=jg({},l,this.persistence.properties(),this.sessionPersistence.properties(),s)).$is_identified=this._isIdentified(),bs(this.config.property_denylist)?pg(this.config.property_denylist,(function(m){delete s[m]})):wo.error(uct+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var _=this.config.sanitize_properties;_&&(wo.error(gct),s=_(s,e));var p=this.hn();return s.$process_person_profile=p,p&&!r&&this.dn("_calculate_event_properties"),s}un(e,n,o){var i;if(n===void 0&&(n=!0),o===void 0&&(o=!1),!this.persistence||!this.hn()||this.Di&&!o)return e;var r=this.persistence.get_initial_props(),A=(i=this.sessionPropsManager)==null?void 0:i.getSetOnceProps(),s=jg({},r,A||{},e||{}),a=this.config.sanitize_properties;return a&&(wo.error(gct),s=a(s,"$set_once")),n&&(this.Di=!0),Ob(s)?void 0:s}register(e,n){var o;(o=this.persistence)==null||o.register(e,n)}register_once(e,n,o){var i;(i=this.persistence)==null||i.register_once(e,n,o)}register_for_session(e){var n;(n=this.sessionPersistence)==null||n.register(e)}unregister(e){var n;(n=this.persistence)==null||n.unregister(e)}unregister_for_session(e){var n;(n=this.sessionPersistence)==null||n.unregister(e)}cn(e,n){this.register({[e]:n})}getFeatureFlag(e,n){var o;return(o=this.featureFlags)==null?void 0:o.getFeatureFlag(e,n)}getFeatureFlagPayload(e){var n;return(n=this.featureFlags)==null?void 0:n.getFeatureFlagPayload(e)}getFeatureFlagResult(e,n){var o;return(o=this.featureFlags)==null?void 0:o.getFeatureFlagResult(e,n)}getAllFeatureFlags(){var e,n;return(e=(n=this.featureFlags)==null?void 0:n.getAllFeatureFlags())!==null&&e!==void 0?e:[]}isFeatureEnabled(e,n){var o;return(o=this.featureFlags)==null?void 0:o.isFeatureEnabled(e,n)}reloadFeatureFlags(){var e;(e=this.featureFlags)==null||e.reloadFeatureFlags()}updateFlags(e,n,o){var i;(i=this.featureFlags)==null||i.updateFlags(e,n,o)}updateEarlyAccessFeatureEnrollment(e,n,o){var i;(i=this.featureFlags)==null||i.updateEarlyAccessFeatureEnrollment(e,n,o)}getEarlyAccessFeatures(e,n,o){var i;return n===void 0&&(n=!1),(i=this.featureFlags)==null?void 0:i.getEarlyAccessFeatures(e,n,o)}on(e,n){return this.qi.on(e,n)}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:bL}),()=>{})}onSessionId(e){var n,o;return(n=(o=this.sessionManager)==null?void 0:o.onSessionId(e))!==null&&n!==void 0?n:()=>{}}getSurveys(e,n){n===void 0&&(n=!1),this.surveys?this.surveys.getSurveys(e,n):e([],{isLoaded:!1,error:bL})}getActiveMatchingSurveys(e,n){n===void 0&&(n=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,n):e([],{isLoaded:!1,error:bL})}renderSurvey(e,n){var o;(o=this.surveys)==null||o.renderSurvey(e,n)}displaySurvey(e,n){var o;n===void 0&&(n=bTn),(o=this.surveys)==null||o.displaySurvey(e,n)}cancelPendingSurvey(e){var n;(n=this.surveys)==null||n.cancelPendingSurvey(e)}canRenderSurvey(e){var n,o;return(n=(o=this.surveys)==null?void 0:o.canRenderSurvey(e))!==null&&n!==void 0?n:{visible:!1,disabledReason:bL}}canRenderSurveyAsync(e,n){var o,i;return n===void 0&&(n=!1),(o=(i=this.surveys)==null?void 0:i.canRenderSurveyAsync(e,n))!==null&&o!==void 0?o:Promise.resolve({visible:!1,disabledReason:bL})}vn(e){return!e||ipe(e)?(wo.critical("Unique user id has not been set in posthog.identify"),!1):e===eX?(wo.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())||(wo.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,n,o){if(!this.__loaded||!this.persistence)return wo.uninitializedWarning("posthog.identify");if(Dp(e)&&(e=e.toString(),wo.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this.vn(e)&&this.dn("posthog.identify")){var i=this.get_distinct_id();this.register({$user_id:e}),this.get_property(qj)||this.register_once({$had_persisted_distinct_id:!0,$device_id:i},""),e!==i&&e!==this.get_property(aL)&&(this.unregister(aL),this.register({distinct_id:e}));var r,A=(this.persistence.get_property(IB)||m9)===m9;e!==i&&A?(this.persistence.set_property(IB,p9),this.setPersonPropertiesForFlags({$set:n||{},$set_once:o||{}},!1),this.capture(Vpe,{distinct_id:e,$anon_distinct_id:i},{$set:n||{},$set_once:o||{}}),this.Ui=rct(e,n,o),(r=this.featureFlags)==null||r.setAnonymousDistinctId(i)):(n||o)&&this.setPersonProperties(n,o),e!==i&&(this.reloadFeatureFlags(),this.unregister(uL))}}setPersonProperties(e,n){if((e||n)&&this.dn("posthog.setPersonProperties")){var o=rct(this.get_distinct_id(),e,n);this.Ui!==o?(this.setPersonPropertiesForFlags({$set:e||{},$set_once:n||{}},!0),this.capture("$set",{$set:e||{},$set_once:n||{}}),this.Ui=o):wo.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(e){var n,o=(bs(e)?e:[e]).filter((i=>Xl(i)&&i.length>0));o.length!==0&&this.dn("posthog.unsetPersonProperties")&&((n=this.featureFlags)==null||n.unsetPersonPropertiesForFlags(o,!0),this.capture("$set",{$unset:o}),this.Ui=null)}group(e,n,o){if(e&&n){var i=this.getGroups(),r=i[e]!==n;if(r&&this.resetGroupPropertiesForFlags(e),this.register({$groups:fo({},i,{[e]:n})}),r||o){var A={$group_type:e,$group_key:n};o&&(A.$group_set=o),this.capture(eat,A)}o&&this.setGroupPropertiesForFlags({[e]:o}),r&&!o&&this.reloadFeatureFlags()}else wo.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,n){var o;n===void 0&&(n=!0),(o=this.featureFlags)==null||o.setPersonPropertiesForFlags(e,n)}resetPersonPropertiesForFlags(e){var n;e===void 0&&(e=!0),(n=this.featureFlags)==null||n.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,n){var o;n===void 0&&(n=!0),this.dn("posthog.setGroupPropertiesForFlags")&&((o=this.featureFlags)==null||o.setGroupPropertiesForFlags(e,n))}resetGroupPropertiesForFlags(e){var n;(n=this.featureFlags)==null||n.resetGroupPropertiesForFlags(e)}reset(e){var n,o,i,r,A,s,a,c,l,g;if(wo.info("reset"),!this.__loaded)return wo.uninitializedWarning("posthog.reset");var u,d=this.get_property(qj),h=this.get_property(ype),_=this.get_property(sP);if(this.consent.reset(),(n=this.persistence)==null||n.clear(),(o=this.sessionPersistence)==null||o.clear(),To(_)||(u=this.persistence)==null||u.register({[sP]:_}),(i=this.surveys)==null||i.reset(),(r=this.sn)==null||r.stop(),(A=this.featureFlags)==null||A.reset(),(s=this.conversations)==null||s.reset(),(a=this.logs)==null||a.reset(),(c=this.metrics)==null||c.reset(),(l=this.persistence)==null||l.set_property(IB,m9),(g=this.sessionManager)==null||g.resetSessionId(),this.Ui=null,this.config.cookieless_mode===VS)this.register_once({distinct_id:eX,$device_id:null},"");else{var p=this.config.get_device_id(zS());this.register_once({distinct_id:p,$device_id:e?p:d},""),e||To(h)||this.register({[ype]:h})}this.register({$last_posthog_reset:new Date().toISOString()},1),delete this.config.identity_distinct_id,delete this.config.identity_hash,this.reloadFeatureFlags()}shutdown(e){var n=this;return Ih((function*(){var o,i,r,A,s;n.__loaded?((o=n.logs)==null||o.flushLogs("sendBeacon"),(i=n.metrics)==null||i.flush("sendBeacon"),(r=n.Gi)==null||r.unload(),(A=n.Ji)==null||A.unload(),(s=n.featureFlags)==null||s.destroy()):wo.uninitializedWarning("posthog.shutdown")}))()}setIdentity(e,n){var o;this.config.identity_distinct_id=e,this.config.identity_hash=n,this.alias(e),(o=this.conversations)==null||o.fn()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,(e=this.conversations)==null||e.pn()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,n;return(e=(n=this.sessionManager)==null?void 0:n.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var n=this.sessionManager.checkAndGetSessionAndWindowId(!0),o=n.sessionStartTimestamp,i=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+n.sessionId);if(e!=null&&e.withTimestamp&&o){var r,A=(r=e.timestampLookBack)!==null&&r!==void 0?r:10;if(!o)return i;i+="?t="+Math.max(Math.floor((new Date().getTime()-o)/1e3)-A,0)}return i}alias(e,n){return e===this.get_property(Yst)?(wo.critical("Attempting to create alias for existing People user - aborting."),-2):this.dn("posthog.alias")?(To(n)&&(n=this.get_distinct_id()),e!==n?(this.cn(aL,e),this.capture("$create_alias",{alias:e,distinct_id:n})):(wo.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var n=fo({},this.config);if(P0(e)){var o,i,r,A,s,a,c,l,g,u,d;jg(this.config,_ct(e));var h=this.Zi();(o=this.persistence)==null||o.update_config(this.config,n,h),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new tIe(fo({},this.config,{persistence:"sessionStorage"}),h,!1);var _=this.zi(this.config.debug);Wx(_)&&(this.config.debug=_),Wx(this.config.debug)&&(this.config.debug?(Au.DEBUG=!0,Ig.N()&&Ig.q("ph_debug",!0),wo.info("set_config",{config:e,oldConfig:n,newConfig:fo({},this.config)})):(Au.DEBUG=!1,Ig.N()&&Ig.P("ph_debug"))),(i=this.exceptionObserver)==null||i.onConfigChange(),(r=this.exceptions)==null||r.onConfigChange(),(A=this.sessionRecording)==null||A.startIfEnabledOrStop(),(s=this.tracingHeaders)==null||s.startIfEnabledOrStop(),(a=this.autocapture)==null||a.startIfEnabled(),(c=this.heatmaps)==null||c.startIfEnabled(),(l=this.exceptionObserver)==null||l.startIfEnabledOrStop(),(g=this.deadClicksAutocapture)==null||g.startIfEnabledOrStop(),(u=this.surveys)==null||u.loadIfEnabled(),this.gn(),(d=this.externalIntegrations)==null||d.startIfEnabledOrStop()}}_overrideSDKInfo(e,n){Au.LIB_NAME=e,Au.LIB_VERSION=n}startSessionRecording(e){var n,o,i,r,A,s=e===!0,a={sampling:s||!(e==null||!e.sampling),linked_flag:s||!(e==null||!e.linked_flag),url_trigger:s||!(e==null||!e.url_trigger),event_trigger:s||!(e==null||!e.event_trigger)};Object.values(a).some(Boolean)&&((n=this.sessionManager)==null||n.checkAndGetSessionAndWindowId(),a.sampling&&((o=this.sessionRecording)==null||o.overrideSampling()),a.linked_flag&&((i=this.sessionRecording)==null||i.overrideLinkedFlag()),a.url_trigger&&((r=this.sessionRecording)==null||r.overrideTrigger("url")),a.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,n){if(this.exceptions){var o=new Error("PostHog syntheticException"),i=this.exceptions.buildProperties(e,{handled:!0,syntheticException:o});return this.exceptions.sendExceptionEvent(fo({},i,n))}}addExceptionStep(e,n){var o;(o=this.exceptions)==null||o.addExceptionStep(e,n)}captureLog(e){var n;(n=this.logs)==null||n.captureLog(e)}get logger(){var e,n;return(e=(n=this.logs)==null?void 0:n.logger)!==null&&e!==void 0?e:A2.mn}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var n,o;return(n=(o=this.toolbar)==null?void 0:o.loadToolbar(e))!==null&&n!==void 0&&n}get_property(e){var n;return(n=this.persistence)==null?void 0:n.props[e]}getSessionProperty(e){var n;return(n=this.sessionPersistence)==null?void 0:n.props[e]}toString(){var e,n=(e=this.config.name)!==null&&e!==void 0?e:Q9;return n!==Q9&&(n=Q9+"."+n),n}_isIdentified(){var e,n;return((e=this.persistence)==null?void 0:e.get_property(IB))===p9||((n=this.sessionPersistence)==null?void 0:n.get_property(IB))===p9}hn(){var e,n;return!(this.config.person_profiles==="never"||this.config.person_profiles===Upe&&!this._isIdentified()&&Ob(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[aL])&&((n=this.persistence)==null||(n=n.props)==null||!n[Zj]))}an(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&(this.config.capture_pageview===!0||this.config.capture_pageview==="history_change")}createPersonProfile(){this.hn()||this.dn("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.dn("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}dn(e){return this.config.person_profiles==="never"?(wo.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.cn(Zj,!0),!0)}Zi(){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!==gP)}gn(){var e,n,o,i,r=this.Zi();return((e=this.persistence)==null?void 0:e.ir)!==r&&((o=this.persistence)==null||o.set_disabled(r)),((n=this.sessionPersistence)==null?void 0:n.ir)!==r&&((i=this.sessionPersistence)==null||i.set_disabled(r)),r}opt_in_capturing(e){var n;if(this.config.cookieless_mode!==VS){if(this.Ni()){var o,i,r,A,s;this.reset(!0),(o=this.sessionManager)==null||o.destroy(),(i=this.pageViewManager)==null||i.destroy(),this.sessionManager=new nct(this),this.pageViewManager=new bat(this),this.persistence&&(this.sessionPropsManager=new tct(this,this.sessionManager,this.persistence));var a,c=(r=(A=this.config.__extensionClasses)==null?void 0:A.sessionRecording)!==null&&r!==void 0?r:(s=A2.__defaultExtensionClasses)==null?void 0:s.sessionRecording;c&&(this.sessionRecording=this.Ai(this.sessionRecording,new c(this)),this.tn&&((a=this.sessionRecording)==null||a.onRemoteConfig==null||a.onRemoteConfig(this.tn)))}var l,g;this.consent.optInOut(!0),this.gn(),this.rn(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),this.config.cookieless_mode==gP&&((l=this.surveys)==null||l.loadIfEnabled()),(To(e?.captureEventName)||e!=null&&e.captureEventName)&&this.capture((g=e?.captureEventName)!==null&&g!==void 0?g:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.nn()}else wo.warn(lct)}opt_out_capturing(){var e,n,o;this.config.cookieless_mode!==VS?(this.config.cookieless_mode===gP&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.gn(),this.config.cookieless_mode===gP&&(this.register({distinct_id:eX,$device_id:null}),(e=this.sessionRecording)==null||e.stopRecording(),this.sessionRecording=void 0,(n=this.sessionManager)==null||n.destroy(),(o=this.pageViewManager)==null||o.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.nn(),this.rn())):wo.warn(lct)}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===VS||(this.config.cookieless_mode===gP?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.gn()}_is_bot(){return JC?oct(JC,this.config.custom_blocked_useragents):void 0}nn(){Zo&&(Zo.visibilityState==="visible"?this.ji||(this.ji=!0,this.capture(I9,{title:Zo.title},{send_instantly:!0}),this.Bi&&(Zo.removeEventListener(tX,this.Bi),this.Bi=null)):this.Bi||(this.Bi=this.nn.bind(this),au(Zo,tX,this.Bi)))}debug(e){e===!1?(wn?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(wn?.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}))}Rr(){var e,n,o,i,r,A,s=this.Wi||{};return"advanced_disable_flags"in s?!!s.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(wo.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):(o="advanced_disable_decide",i=wo,r=(n="advanced_disable_flags")in(e=s)&&!as(e[n]),A=o in e&&!as(e[o]),r?e[n]:!!A&&(i&&i.warn("Config field '"+o+"' is deprecated. Please use '"+n+"' instead. The old field will be removed in a future major version."),e[o]))}it(e){var n;if(as(this.config.before_send))return e;var o=Object.keys((n=e.properties)!==null&&n!==void 0?n:{}).filter(KNn),i=bs(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(var A of i){if(r=A(r),as(r)){var s="Event '"+e.event+"' was rejected in beforeSend function";return ONn(e.event)?wo.warn(s+". This can cause unexpected behavior."):wo.info(s),null}r.properties&&!Ob(r.properties)||wo.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}for(var a of o)if(r.properties&&as(r.properties[a]))return wo.warn("Event '"+e.event+"' had its '"+a+"' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped."),null;return r}getPageViewId(){var e;return(e=this.pageViewManager.zt)==null?void 0:e.pageViewId}captureTraceFeedback(e,n){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:n})}captureTraceMetric(e,n,o){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:n,$ai_metric_value:String(o)})}zi(e){var n=Wx(e)&&!e,o=Ig.N()&&Ig.A("ph_debug")==="true";return!n&&(!!o||e)}}A2.__defaultExtensionClasses={},A2.mn=(()=>{var t=()=>{};return{trace:t,debug:t,info:t,warn:t,error:t,fatal:t}})(),(function(t,e){for(var n=0;e.length>n;n++)t.prototype[e[n]]=wRn(t.prototype[e[n]])})(A2,["identify"]);class mct{constructor(e){this.disabled=e===!1;var n=P0(e)?e:{};this.thresholdPx=n.threshold_px||30,this.timeoutMs=n.timeout_ms||1e3,this.clickCount=n.click_count||3,this.clicks=[]}isRageClick(e,n,o){if(this.disabled)return!1;var i=this.clicks[this.clicks.length-1];if(i&&Math.abs(e-i.x)+Math.abs(n-i.y)<this.thresholdPx&&this.timeoutMs>o-i.timestamp){if(this.clicks.push({x:e,y:n,timestamp:o}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:n,timestamp:o}];return!1}}var yIe="$copy_autocapture",EIe=v0("[AutoCapture]");function BIe(t,e){return e.length>t?e.slice(0,t)+"...":e}function NTn(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do e=e.previousSibling;while(e&&!Ub(e));return e}function RTn(t,e){var n,o,i=e.e,r=e.maskAllElementAttributes,A=e.maskAllText,s=e.elementAttributeIgnoreList,a=e.elementsChainAsString,c=e.disableCaptureUrlHashes;if(!Ub(t))return{props:{}};for(var l=[t],g=new Set([t]),u=t;u.parentNode&&!ky(u,"body")&&cat>l.length;)if(aat(u.parentNode)){var d=u.parentNode.host;if(g.has(d))break;g.add(d),l.push(d),u=d}else{if(!Ub(u.parentNode)||g.has(u.parentNode))break;g.add(u.parentNode),l.push(u.parentNode),u=u.parentNode}var h,_,p=[],m={},I=!1,C=!1;if(pg(l,(S=>{var M=Zpe(S);if(ky(S,"a")){var w=S.getAttribute("href");I=!!(M&&w&&mL(w))&&(c?Kb(w):w)}gA(sX(S),"ph-no-capture")&&(C=!0),p.push((function(N,G,H,U,J){J===void 0&&(J=!1);var W=N.tagName.toLowerCase(),X={tag_name:W};jpe.indexOf(W)>-1&&!H&&(X.$el_text=W.toLowerCase()==="a"||W.toLowerCase()==="button"?BIe(1024,yat(N)):BIe(1024,_L(N)));var oe=sX(N);oe.length>0&&(X.classes=oe.filter((function(ae){return ae!==""}))),pg(N.attributes,(function(ae){var re;if((!Iat(N)||["name","id","class","aria-label"].indexOf(ae.name)!==-1)&&(U==null||!U.includes(ae.name))&&!G&&mL(ae.value)&&(!Xl(re=ae.name)||re.substring(0,10)!=="_ngcontent"&&re.substring(0,7)!=="_nghost")){var le=ae.value;ae.name==="class"&&(le=qpe(le).join(" ")),X["attr__"+ae.name]=BIe(1024,ae.name==="href"&&J?Kb(le):le)}}));for(var ce=1,te=1,ie=N;ie=NTn(ie);)ce++,ie.tagName===N.tagName&&te++;return X.nth_child=ce,X.nth_of_type=te,X})(S,r,A,s,c));var k=(function(N){if(!Zpe(N))return{};var G={};return pg(N.attributes,(function(H){if(H.name&&H.name.indexOf("data-ph-capture-attribute")===0){var U=H.name.replace("data-ph-capture-attribute-",""),J=H.value;U&&J&&mL(J)&&(G[U]=J)}})),G})(S);jg(m,k)})),C)return{props:{},explicitNoCapture:C};if(A||(p[0].$el_text=ky(t,"a")||ky(t,"button")?yat(t):_L(t)),I){var f,y;p[0].attr__href=I;var B=(f=pL(I))==null?void 0:f.host,x=wn==null||(y=wn.location)==null?void 0:y.host;B&&x&&B!==x&&(h=I)}return{props:jg({$event_type:i.type,$ce_version:1},a?{}:{$elements:p},{$elements_chain:(_=p,(function(S){return S.map((M=>{var w,k,N="";if(M.tag_name&&(N+=M.tag_name),M.attr_class)for(var G of(M.attr_class.sort(),M.attr_class))N+="."+G.replace(/"/g,"");var H=fo({},M.text?{text:M.text}:{},{"nth-child":(w=M.nth_child)!==null&&w!==void 0?w:0,"nth-of-type":(k=M.nth_of_type)!==null&&k!==void 0?k:0},M.href?{href:M.href}:{},M.attr_id?{attr_id:M.attr_id}:{},M.attributes),U={};return iX(H).sort(((J,W)=>J[0].localeCompare(W[0]))).forEach((J=>{var W=J[1];return U[Bat(J[0].toString())]=Bat(W.toString())})),(N+=":")+iX(U).map((J=>J[0]+'="'+J[1]+'"')).join("")})).join(";")})((function(S){return S.map((M=>{var w,k,N={text:(w=M.$el_text)==null?void 0:w.slice(0,400),tag_name:M.tag_name,href:(k=M.attr__href)==null?void 0:k.slice(0,2048),attr_class:jRn(M),attr_id:M.attr__id,nth_child:M.nth_child,nth_of_type:M.nth_of_type,attributes:{}};return iX(M).filter((G=>G[0].indexOf("attr__")===0)).forEach((G=>N.attributes[G[0]]=G[1])),N}))})(_)))},(n=p[0])!=null&&n.$el_text?{$el_text:(o=p[0])==null?void 0:o.$el_text}:{},h&&i.type==="click"?{$external_click_url:h}:{},m)}}var DL=v0("[ExceptionAutocapture]"),pct=()=>{},TTn=v0("[TracingHeaders]"),_P=v0("[Web Vitals]"),Ict=9e5,Cct="disabled",fct="lazy_loading",ML="awaiting_config",CX="missing_config";v0("[SessionRecording]"),v0("[SessionRecording]");var xIe="[SessionRecording]",WS=v0(xIe),kTn=v0("[Heatmaps]");function yct(t){return P0(t)&&"clientX"in t&&"clientY"in t&&Dp(t.clientX)&&Dp(t.clientY)}var QIe=v0("[Product Tours]"),SIe=t=>{var e;return!t.config.disable_product_tours&&!((e=t.persistence)==null||!e.get_property(Mpe))},FTn=["$set_once","$set"],$x=v0("[SiteApps]"),Ect="Error while initializing PostHog app with config id ";function S9(t,e,n){if(as(t))return!1;switch(n){case"exact":return t===e;case"contains":var o=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(o,"i").test(t);case"regex":try{return new RegExp(e).test(t)}catch{return!1}default:return!1}}class LTn{constructor(e){this.yn=new pIe,this.bn=(n,o)=>this._n(n,o)&&this.wn(n,o)&&this.xn(n,o)&&this.kn(n,o),this._n=(n,o)=>o==null||!o.event||n?.event===o?.event,this._instance=e,this.Sn=new Set,this.Cn=new Set}init(){var e,n;To((e=this._instance)==null?void 0:e._addCaptureHook)||(n=this._instance)==null||n._addCaptureHook(((o,i)=>{this.on(o,i)}))}register(e){var n,o;if(!To((n=this._instance)==null?void 0:n._addCaptureHook)&&(e.forEach((A=>{var s,a;(s=this.Cn)==null||s.add(A),(a=A.steps)==null||a.forEach((c=>{var l;(l=this.Sn)==null||l.add(c?.event||"")}))})),(o=this._instance)!=null&&o.autocapture)){var i,r=new Set;e.forEach((A=>{var s;(s=A.steps)==null||s.forEach((a=>{a!=null&&a.selector&&r.add(a?.selector)}))})),(i=this._instance)==null||i.autocapture.setElementSelectors(r)}}on(e,n){var o;n!=null&&e.length!=0&&(this.Sn.has(e)||this.Sn.has(n?.event))&&this.Cn&&((o=this.Cn)==null?void 0:o.size)>0&&this.Cn.forEach((i=>{this.Tn(n,i)&&this.yn.emit("actionCaptured",i.name)}))}In(e){this.onAction("actionCaptured",(n=>e(n)))}Tn(e,n){if(n?.steps==null)return!1;for(var o of n.steps)if(this.bn(e,o))return!0;return!1}onAction(e,n){return this.yn.on(e,n)}wn(e,n){if(n!=null&&n.url){var o,i=e==null||(o=e.properties)==null?void 0:o.$current_url;if(!i||typeof i!="string"||!S9(i,n.url,n.url_matching||"contains"))return!1}return!0}xn(e,n){return!!this.Mn(e,n)&&!!this.En(e,n)&&!!this.Rn(e,n)}Mn(e,n){var o;if(n==null||!n.href)return!0;var i=this.Pn(e);if(i.length>0)return i.some((s=>S9(s.href,n.href,n.href_matching||"exact")));var r,A=(e==null||(o=e.properties)==null?void 0:o.$elements_chain)||"";return!!A&&S9((r=A.match(/(?::|")href="(.*?)"/))?r[1]:"",n.href,n.href_matching||"exact")}En(e,n){var o;if(n==null||!n.text)return!0;var i=this.Pn(e);if(i.length>0)return i.some((c=>S9(c.text,n.text,n.text_matching||"exact")||S9(c.$el_text,n.text,n.text_matching||"exact")));var r,A,s,a=(e==null||(o=e.properties)==null?void 0:o.$elements_chain)||"";return!!a&&(r=(function(c){for(var l,g=[],u=/(?::|")text="(.*?)"/g;!as(l=u.exec(c));)g.includes(l[1])||g.push(l[1]);return g})(a),A=n.text,s=n.text_matching||"exact",r.some((c=>S9(c,A,s))))}Rn(e,n){var o,i;if(n==null||!n.selector)return!0;var r=e==null||(o=e.properties)==null?void 0:o.$element_selectors;if(r!=null&&r.includes(n.selector))return!0;var A=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";if(n.selector_regex&&A)try{return new RegExp(n.selector_regex).test(A)}catch{return!1}return!1}Pn(e){var n;return(e==null||(n=e.properties)==null?void 0:n.$elements)==null?[]:e?.properties.$elements}kn(e,n){return n==null||!n.properties||n.properties.length===0||sct(n.properties.reduce(((o,i)=>{var r=bs(i.value)?i.value.map(String):i.value!=null?[String(i.value)]:[];return o[i.key]={values:r,operator:i.operator||"exact"},o}),{}),e?.properties)}}class HTn{constructor(e){this.On=[],this._instance=e,this.Ln=new Map,this.Fn=new Map,this.An=new Map}$n(e,n){return!!e&&sct(e.propertyFilters,n?.properties)}Nn(e,n){var o=new Map;return e.forEach((i=>{var r;(r=i.conditions)==null||(r=r[n])==null||(r=r.values)==null||r.forEach((A=>{if(A!=null&&A.name){var s=o.get(A.name)||[];s.push(i.id),o.set(A.name,s)}}))})),o}Dn(e,n,o){var i=(o===fL.Activation?this.Ln:this.Fn).get(e),r=[];return this.qn((A=>{r=A.filter((s=>i?.includes(s.id)))})),r.filter((A=>{var s,a=(s=A.conditions)==null||(s=s[o])==null||(s=s.values)==null?void 0:s.find((c=>c.name===e));return this.$n(a,n)}))}register(e){var n;To((n=this._instance)==null?void 0:n._addCaptureHook)||(this.jn(e),this.Bn(e))}Bn(e){var n=e.filter((o=>{var i,r;return((i=o.conditions)==null?void 0:i.actions)&&((r=o.conditions)==null||(r=r.actions)==null||(r=r.values)==null?void 0:r.length)>0}));n.length!==0&&(this.Hn==null&&(this.Hn=new LTn(this._instance),this.Hn.init(),this.Hn.In((o=>{this.onAction(o)}))),n.forEach((o=>{var i,r,A,s,a;o.conditions&&(i=o.conditions)!=null&&i.actions&&(r=o.conditions)!=null&&(r=r.actions)!=null&&r.values&&((A=o.conditions)==null||(A=A.actions)==null||(A=A.values)==null?void 0:A.length)>0&&((s=this.Hn)==null||s.register(o.conditions.actions.values),(a=o.conditions)==null||(a=a.actions)==null||(a=a.values)==null||a.forEach((c=>{if(c&&c.name){var l=this.An.get(c.name);l&&l.push(o.id),this.An.set(c.name,l||[o.id])}})))})))}jn(e){var n,o=e.filter((r=>{var A,s;return((A=r.conditions)==null?void 0:A.events)&&((s=r.conditions)==null||(s=s.events)==null||(s=s.values)==null?void 0:s.length)>0})),i=e.filter((r=>{var A,s;return((A=r.conditions)==null?void 0:A.cancelEvents)&&((s=r.conditions)==null||(s=s.cancelEvents)==null||(s=s.values)==null?void 0:s.length)>0}));o.length===0&&i.length===0||((n=this._instance)==null||n._addCaptureHook(((r,A)=>{this.onEvent(r,A)})),this.Ln=this.Nn(e,fL.Activation),this.Fn=this.Nn(e,fL.Cancellation))}onEvent(e,n){var o,i,r=this.Un(),A=(n==null||(o=n.properties)==null?void 0:o.$survey_id)||(n==null||(i=n.properties)==null?void 0:i.$product_tour_id);if(A&&this.getActivatedIds().includes(A)){var s=this.zn(e,A);if(s==="consume")return r.info("event consumed activated item, removing it",{event:e,itemId:A}),void this.Wn([A]);if(s==="persist")return r.info("shown item promoted to persisted activation",{event:e,itemId:A}),void this.Vn(A)}if(this.Fn.has(e)){var a=this.Dn(e,n,fL.Cancellation);a.length>0&&(r.info("cancel event matched, cancelling items",{event:e,itemsToCancel:a.map((l=>l.id))}),this.Wn(a.map((l=>l.id))),a.forEach((l=>this.Zn(l.id))))}if(this.Ln.has(e)){r.info("event name matched",{event:e,eventPayload:n,items:this.Ln.get(e)});var c=this.Dn(e,n,fL.Activation);this.Gn(c.map((l=>l.id)))}}onAction(e){this.An.has(e)&&this.Gn(this.An.get(e)||[])}Gn(e){e.length!==0&&(this.On=[...new Set([...this.On,...e])],this.Un().info("updating activated items",{activatedItems:this.getActivatedIds()}))}Vn(e){this.On=this.On.filter((o=>o!==e));var n=this.Qn();n.includes(e)||this.Jn([...n,e])}Wn(e){var n=new Set(e);this.On=this.On.filter((r=>!n.has(r)));var o=this.Qn(),i=o.filter((r=>!n.has(r)));i.length!==o.length&&this.Jn(i)}Qn(){var e,n=this.Kn();return((e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[n])||[]}getActivatedIds(){return[...new Set([...this.Qn(),...this.On])].filter((e=>!this.Yn(e)))}reset(){this.On=[],this.Qn().length>0&&this.Jn([])}getEventToItemsMap(){return this.Ln}Xn(){return this.Hn}}class GTn extends HTn{constructor(e){super(e)}Kn(){return Tpe}es(){return JS.SHOWN}qn(e){var n;(n=this._instance)==null||n.getSurveys(e)}Zn(e){var n;(n=this._instance)==null||n.cancelPendingSurvey(e)}Un(){return $l}Jn(e){var n;(n=this._instance)==null||(n=n.persistence)==null||n.register({[Tpe]:e})}Yn(){return!1}zn(e,n){var o;this.qn((r=>{o=r.find((A=>A.id===n))}));var i=!o||(function(r){var A,s,a,c=((A=(s=r.conditions)==null||(s=s.events)==null||(s=s.values)==null?void 0:s.length)!==null&&A!==void 0?A:0)>0;return r.schedule===sTn.Always||!((a=r.conditions)==null||(a=a.events)==null||!a.repeatedActivation||!c)})(o);return i?e===JS.SHOWN?"consume":"ignore":e===JS.SHOWN?"persist":e===JS.DISMISSED||e===JS.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var bIe="SDK is not enabled or survey functionality is not yet loaded",Bct="Disabled. Not loading surveys.",OTn=wn!=null&&wn.location?lX(wn.location.hash,"__posthog")||lX(location.hash,"state"):null,xct="_postHogToolbarParams",Qct=v0("[Toolbar]"),Wd=v0("[FeatureFlags]"),mP=v0("[FeatureFlags]",{debugEnabled:!0}),DIe=`" failed. Feature flags didn't load in time.`,Sct=t=>{for(var e={},n=0;t.length>n;n++)e[t[n]]=!0;return e},bct=t=>{var e={};for(var n of iX(t||{})){var o=n[1];o&&(e[n[0]]=o)}return e},jS=v0("[Error tracking]"),Dct="Refusing to render web experiment since the viewer is a likely bot",KTn={icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())===-1,regex:(t,e)=>mX(e,t),not_regex:(t,e)=>!mX(e,t),exact:(t,e)=>e===t,is_not:(t,e)=>e!==t};class GI{get Se(){return this._instance.config}constructor(e){var n=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(o){o===void 0&&(o=!1),n.getWebExperiments((i=>{GI.ts("retrieved web experiments from the server"),n.rs=new Map,i.forEach((r=>{if(r.feature_flag_key){var A;n.rs&&(GI.ts("setting flag key ",r.feature_flag_key," to web experiment ",r),(A=n.rs)==null||A.set(r.feature_flag_key,r));var s=n._instance.getFeatureFlag(r.feature_flag_key);Xl(s)&&r.variants[s]&&n.ns(r.name,s,r.variants[s].transforms)}else if(r.variants)for(var a in r.variants){var c=r.variants[a];GI.ss(c,n._instance)&&n.ns(r.name,a,c.transforms)}}))}),o)},this._instance=e,this._instance.onFeatureFlags((o=>{this.onFeatureFlags(o)}))}initialize(){}onFeatureFlags(e){if(this._is_bot())GI.ts(Dct);else if(!this.Se.disable_web_experiments){if(as(this.rs))return this.rs=new Map,this.loadIfEnabled(),void this.previewWebExperiment();GI.ts("applying feature flags",e),e.forEach((n=>{var o;if(this.rs&&(o=this.rs)!=null&&o.has(n)){var i,r=this._instance.getFeatureFlag(n),A=(i=this.rs)==null?void 0:i.get(n);r&&A!=null&&A.variants[r]&&this.ns(A.name,r,A.variants[r].transforms)}}))}}previewWebExperiment(){var e=GI.getWindowLocation();if(e!=null&&e.search){var n=C9(e?.search,"__experiment_id"),o=C9(e?.search,"__experiment_variant");n&&o&&(GI.ts("previewing web experiments "+n+" && "+o),this.getWebExperiments((i=>{this.os(parseInt(n),o,i)}),!1,!0))}}loadIfEnabled(){this.Se.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,n,o){if(this.Se.disable_web_experiments&&!o)return e([]);var i=this._instance.get_property("$web_experiments");if(i&&!n)return e(i);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.Se.token),method:"GET",callback:r=>e(r.statusCode===200&&r.json&&r.json.experiments||[])})}os(e,n,o){var i=o.filter((r=>r.id===e));i&&i.length>0&&(GI.ts("Previewing web experiment ["+i[0].name+"] with variant ["+n+"]"),this.ns(i[0].name,n,i[0].variants[n].transforms))}static ss(e,n){return!as(e.conditions)&&GI.ls(e,n)&&GI.us(e)}static ls(e,n){var o;if(as(e.conditions)||as((o=e.conditions)==null?void 0:o.url))return!0;var i=GI.getWindowLocation();if(i){var r,A,s,a=rat(n,i.href);return(r=e.conditions)==null||!r.url||KTn[(A=(s=e.conditions)==null?void 0:s.urlMatchType)!==null&&A!==void 0?A:"icontains"](e.conditions.url,a)}return!1}static getWindowLocation(){return wn?.location}static us(e){var n;if(as(e.conditions)||as((n=e.conditions)==null?void 0:n.utm))return!0;var o=wat();if(o.utm_source){var i,r,A,s,a,c,l,g,u=(i=e.conditions)==null||(i=i.utm)==null||!i.utm_campaign||((r=e.conditions)==null||(r=r.utm)==null?void 0:r.utm_campaign)==o.utm_campaign,d=(A=e.conditions)==null||(A=A.utm)==null||!A.utm_source||((s=e.conditions)==null||(s=s.utm)==null?void 0:s.utm_source)==o.utm_source,h=(a=e.conditions)==null||(a=a.utm)==null||!a.utm_medium||((c=e.conditions)==null||(c=c.utm)==null?void 0:c.utm_medium)==o.utm_medium,_=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_term||((g=e.conditions)==null||(g=g.utm)==null?void 0:g.utm_term)==o.utm_term;return u&&h&&_&&d}return!1}static ts(e){for(var n=arguments.length,o=new Array(n>1?n-1:0),i=1;n>i;i++)o[i-1]=arguments[i];wo.info("[WebExperiments] "+e,o)}ns(e,n,o){this._is_bot()?GI.ts(Dct):n!=="control"?o.forEach((i=>{if(i.selector){var r;GI.ts("applying transform of variant "+n+" for experiment "+e+" ",i);var A=(r=document)==null?void 0:r.querySelectorAll(i.selector);A?.forEach((s=>{var a=s;i.html&&(a.innerHTML=i.html),i.css&&a.setAttribute("style",i.css)}))}})):GI.ts("Control variants leave the page unmodified.")}_is_bot(){return JC&&this._instance?oct(JC,this.Se.custom_blocked_useragents):void 0}}var s2=v0("[Conversations]"),pP="Conversations not available yet.",Mct="console",fX={featureFlags:class{constructor(t){this.hs=!1,this.ds=!1,this.cs=!1,this.vs=!1,this.fs=!1,this.ps=!1,this.gs=!1,this.ys=!1,this.bs=0,this._s=()=>{var e=this.ws();this.bs=0,e&&this.reloadFeatureFlags()},this._instance=t,this.featureFlagEventHandlers=[],wn&&au(wn,"online",this._s)}destroy(){wn?.removeEventListener("online",this._s)}get Se(){return this._instance.config}get ri(){return this._instance.persistence}xs(t){return this._instance.get_property(t)}ks(){var t,e;return(t=(e=this.ri)==null?void 0:e.sr(this.Se.feature_flag_cache_ttl_ms))!==null&&t!==void 0&&t}Ss(){return!!this.ks()&&(this.ys||this.cs||(this.ys=!0,Wd.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Cs(){var t,e=(t=this.Se.evaluation_contexts)!==null&&t!==void 0?t:this.Se.evaluation_environments;return!this.Se.evaluation_environments||this.Se.evaluation_contexts||this.gs||(Wd.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.gs=!0),e!=null&&e.length?e.filter((n=>{var o=n&&typeof n=="string"&&n.trim().length>0;return o||Wd.error("Invalid evaluation context found:",n,"Expected non-empty string"),o})):[]}Ts(){return this.Cs().length>0}Is(){var t=this.Se.flag_keys;if(!To(t)){if(bs(t))return t.filter((e=>{var n=e&&typeof e=="string"&&e.trim().length>0;return n||Wd.error("Invalid flag key found:",e,"Expected non-empty string"),n}));Wd.error("Invalid flag_keys found:",t,"Expected array of non-empty strings")}}initialize(){var t,e,n=this._instance.config,o=(t=(e=n.bootstrap)==null?void 0:e.featureFlags)!==null&&t!==void 0?t:{};if(Object.keys(o).length){var i,r,A=(i=(r=n.bootstrap)==null?void 0:r.featureFlagPayloads)!==null&&i!==void 0?i:{},s=Object.keys(o).filter((c=>!!o[c])).reduce(((c,l)=>(c[l]=o[l]||!1,c)),{}),a=Object.keys(A).filter((c=>s[c])).reduce(((c,l)=>(A[l]&&(c[l]=A[l]),c)),{});this.receivedFeatureFlags({featureFlags:s,featureFlagPayloads:a})}}updateFlags(t,e,n){var o,i,r=n!=null&&n.merge&&(o=this.xs(aP))!==null&&o!==void 0?o:{},A=n!=null&&n.merge&&(i=this.xs(jj))!==null&&i!==void 0?i:{},s=fo({},r,t),a=fo({},A,e),c={};for(var l of Object.entries(s)){var g=l[0],u=l[1];c[g]={key:g,enabled:$At(u),variant:ZAt(u),reason:void 0,metadata:To(a?.[g])?void 0:{id:0,version:void 0,description:void 0,payload:a[g]}}}this.receivedFeatureFlags({flags:c})}get hasLoadedFlags(){return this.ds}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.xs(vpe),e=this.xs(YS),n=this.xs(_9);if(!n&&!e)return t||{};var o=jg({},t||{}),i=[...new Set([...Object.keys(n||{}),...Object.keys(e||{})])];for(var r of i){var A,s,a=o[r],c=e?.[r],l=To(c)?(A=a?.enabled)!==null&&A!==void 0&&A:!!c,g=To(c)?a.variant:typeof c=="string"?c:void 0,u=n?.[r],d=fo({},a,{enabled:l,variant:l?g??a?.variant:void 0});l!==a?.enabled&&(d.original_enabled=a?.enabled),g!==a?.variant&&(d.original_variant=a?.variant),u&&(d.metadata=fo({},a?.metadata,{payload:u,original_payload:a==null||(s=a.metadata)==null?void 0:s.payload})),o[r]=d}return this.hs||(Wd.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:n,finalDetails:o}),this.hs=!0),o}getAllFeatureFlags(){var t=this.getFlagVariants(),e=this.getFlagPayloads();return Object.keys(t).map((n=>{var o=t[n];return{key:n,enabled:$At(o),variant:ZAt(o),payload:XAt(e[n])}}))}getFlagVariants(){var t=this.xs(aP),e=this.xs(YS);if(!e)return t||{};for(var n=jg({},t),o=Object.keys(e),i=0;o.length>i;i++)n[o[i]]=e[o[i]];return this.hs||(Wd.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:n}),this.hs=!0),n}getFlagPayloads(){var t=this.xs(jj),e=this.xs(_9);if(!e)return t||{};for(var n=jg({},t||{}),o=Object.keys(e),i=0;o.length>i;i++)n[o[i]]=e[o[i]];return this.hs||(Wd.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:n}),this.hs=!0),n}reloadFeatureFlags(){this.vs||this.Se.advanced_disable_feature_flags||this.ws()||this.Ms||(this._instance.qi.emit("featureFlagsReloading",!0),this.Ms=setTimeout((()=>{this.Es()}),5))}Rs(){clearTimeout(this.Ms),this.Ms=void 0}ensureFlagsLoaded(){this.ds||this.cs||this.Ms||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.vs=t}Es(t){var e;if(this.Rs(),!this._instance.Rr()&&!this.ws())if(this.cs)this.fs=!0;else{var n=this.Se.token,o=this.xs(qj),i={token:n,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:fo({},((e=this.ri)==null?void 0:e.get_initial_props())||{},this.xs(cP)||{}),group_properties:this.xs(lP),timezone:Fat()};qC(o)||To(o)||(i.$device_id=o),(t!=null&&t.disableFlags||this.Se.advanced_disable_feature_flags)&&(i.disable_flags=!0),this.Ts()&&(i.evaluation_contexts=this.Cs());var r=this.Is();To(r)||(i.flag_keys=r);var A=!!this.Se.advanced_only_evaluate_survey_feature_flags,s=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this.Se.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this.cs=!0,this._instance._send_request({method:"POST",url:s,data:i,compression:this.Se.disable_compression?void 0:WC.Base64,timeout:this.Se.feature_flag_request_timeout_ms,callback:a=>{var c,l,g,u=!0;if(this.Ps(a.statusCode),a.statusCode===200&&(this.fs||(this.$anon_distinct_id=void 0),u=!1),this.cs=!1,!i.disable_flags||this.fs){this.ps=!u;var d=[];a.error?a.error instanceof Error?d.push(a.error.name==="AbortError"?"timeout":"connection_error"):d.push("unknown_error"):a.statusCode!==200&&d.push("api_error_"+a.statusCode),(c=a.json)!=null&&c.errorsWhileComputingFlags&&d.push("errors_while_computing_flags");var h,_=!((l=a.json)==null||(l=l.quotaLimited)==null||!l.includes("feature_flags"));_&&d.push("quota_limited"),(g=this.ri)==null||g.register({[Fpe]:d}),_?Wd.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."):(i.disable_flags||this.receivedFeatureFlags((h=a.json)!==null&&h!==void 0?h:{},u,{partialResponse:A}),this.fs&&(this.fs=!1,this.Es()))}}})}}ws(){return Dat(this.bs,3)}Ps(t){this.bs=Mat(t,this.bs,3,(()=>Wd.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes.")))}getFeatureFlag(t,e){var n;if(e===void 0&&(e={}),!e.fresh||this.ps)if(this.ds||this.getFlags()&&this.getFlags().length>0){if(!this.Ss()){var o=this.getFeatureFlagResult(t,e);return(n=o?.variant)!==null&&n!==void 0?n:o?.enabled}}else Wd.warn('getFeatureFlag for key "'+t+DIe)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var e=this.getFeatureFlagResult(t,{send_event:!1});return e?.payload}getFeatureFlagResult(t,e){if(e===void 0&&(e={}),!e.fresh||this.ps)if(this.ds||this.getFlags()&&this.getFlags().length>0){if(!this.Ss()){var n=this.getFlagVariants(),o=t in n,i=n[t],r=this.getFlagPayloads()[t],A=String(i),s=this.xs(Npe)||void 0,a=this.xs(hL)||void 0,c=this.xs(uL)||{};if(this.Se.advanced_feature_flags_dedup_per_session){var l,g=this._instance.get_session_id(),u=this.xs(kpe);g&&g!==u&&(c={},(l=this.ri)==null||l.register({[uL]:c,[kpe]:g}))}if((e.send_event||!("send_event"in e))&&(!(t in c)||!c[t].includes(A))){var d,h,_,p,m,I,C,f,y,B;bs(c[t])?c[t].push(A):c[t]=[A],(d=this.ri)==null||d.register({[uL]:c});var x=this.getFeatureFlagDetails(t),S=[...(h=this.xs(Fpe))!==null&&h!==void 0?h:[]];To(i)&&S.push("flag_missing");var M={$feature_flag:t,$feature_flag_response:i,$feature_flag_payload:r||null,$feature_flag_request_id:s,$feature_flag_evaluated_at:a,$feature_flag_bootstrapped_response:((_=this.Se.bootstrap)==null||(_=_.featureFlags)==null?void 0:_[t])||null,$feature_flag_bootstrapped_payload:((p=this.Se.bootstrap)==null||(p=p.featureFlagPayloads)==null?void 0:p[t])||null,$used_bootstrap_value:!this.ps};To(x==null||(m=x.metadata)==null?void 0:m.version)||(M.$feature_flag_version=x.metadata.version);var w,k=(I=x==null||(C=x.reason)==null?void 0:C.description)!==null&&I!==void 0?I:x==null||(f=x.reason)==null?void 0:f.code;k&&(M.$feature_flag_reason=k),x!=null&&(y=x.metadata)!=null&&y.id&&(M.$feature_flag_id=x.metadata.id),To(x?.original_variant)&&To(x?.original_enabled)||(M.$feature_flag_original_response=To(x.original_variant)?x.original_enabled:x.original_variant),x!=null&&(B=x.metadata)!=null&&B.original_payload&&(M.$feature_flag_original_payload=x==null||(w=x.metadata)==null?void 0:w.original_payload),S.length&&(M.$feature_flag_error=S.join(",")),this._instance.capture("$feature_flag_called",M)}if(o)return{key:t,enabled:!!i,variant:typeof i=="string"?i:void 0,payload:XAt(r)}}}else Wd.warn('getFeatureFlagResult for key "'+t+DIe)}getRemoteConfigPayload(t,e){var n=this.Se.token,o={distinct_id:this._instance.get_distinct_id(),token:n};this.Ts()&&(o.evaluation_contexts=this.Cs());var i=this.Is();To(i)||(o.flag_keys=i),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:o,compression:this.Se.disable_compression?void 0:WC.Base64,timeout:this.Se.feature_flag_request_timeout_ms,callback(r){var A,s=(A=r.json)==null?void 0:A.featureFlagPayloads;e(s?.[t]||void 0)}})}isFeatureEnabled(t,e){if(e===void 0&&(e={}),!e.fresh||this.ps){if(this.ds||this.getFlags()&&this.getFlags().length>0){var n=this.getFeatureFlag(t,e);return To(n)?void 0:!!n}Wd.warn('isFeatureEnabled for key "'+t+DIe)}}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((e=>e!==t))}receivedFeatureFlags(t,e,n){if(this.ri){this.ds=!0;var o=this.getFlagVariants(),i=this.getFlagPayloads(),r=this.getFlagsWithDetails();(function(A,s,a,c,l,g){a===void 0&&(a={}),c===void 0&&(c={}),l===void 0&&(l={});var u=(S=>{var M=S.flags;return M?(S.featureFlags=Object.fromEntries(Object.keys(M).map((w=>{var k;return[w,(k=M[w].variant)!==null&&k!==void 0?k:M[w].enabled]}))),S.featureFlagPayloads=Object.fromEntries(Object.keys(M).filter((w=>M[w].enabled)).filter((w=>{var k;return(k=M[w].metadata)==null?void 0:k.payload})).map((w=>{var k;return[w,(k=M[w].metadata)==null?void 0:k.payload]})))):S.featureFlags&&Wd.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),S})(A),d=u.flags,h=u.featureFlags,_=u.featureFlagPayloads;if(h){var p=A.requestId,m=A.evaluatedAt;if(bs(h)){Wd.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var I={};if(h)for(var C=0;h.length>C;C++)I[h[C]]=!0;s&&s.register({[Wj]:h,[aP]:I})}else{var f=h,y=_,B=d;if(g!=null&&g.partialResponse)f=fo({},a,f),y=fo({},c,y),B=fo({},l,B);else if(A.errorsWhileComputingFlags)if(d){var x=new Set(Object.keys(d).filter((S=>{var M;return!((M=d[S])!=null&&M.failed)})));f=fo({},a,Object.fromEntries(Object.entries(f).filter((S=>x.has(S[0]))))),y=fo({},c,Object.fromEntries(Object.entries(y||{}).filter((S=>x.has(S[0]))))),B=fo({},l,Object.fromEntries(Object.entries(B||{}).filter((S=>x.has(S[0])))))}else f=fo({},a,f),y=fo({},c,y),B=fo({},l,B);s&&s.register(fo({[Wj]:Object.keys(bct(f)),[aP]:f||{},[jj]:y||{},[vpe]:B||{}},p?{[Npe]:p}:{},m?{[hL]:m}:{}))}}})(t,this.ri,o,i,r,n),e||(this.ys=!1),this.Os(e)}}override(t,e){e===void 0&&(e=!1),Wd.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){if(!this._instance.__loaded||!this.ri)return Wd.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(t===!1)return this.ri.unregister(YS),this.ri.unregister(_9),this.Os(),mP.info("All overrides cleared");if(bs(t)){var e=Sct(t);return this.ri.register({[YS]:e}),this.Os(),mP.info("Flag overrides set",{flags:t})}if(t&&typeof t=="object"&&("flags"in t||"payloads"in t)){var n,o=t;if(this.hs=!!((n=o.suppressWarning)!==null&&n!==void 0&&n),"flags"in o){if(o.flags===!1)this.ri.unregister(YS),mP.info("Flag overrides cleared");else if(o.flags){if(bs(o.flags)){var i=Sct(o.flags);this.ri.register({[YS]:i})}else this.ri.register({[YS]:o.flags});mP.info("Flag overrides set",{flags:o.flags})}}return"payloads"in o&&(o.payloads===!1?(this.ri.unregister(_9),mP.info("Payload overrides cleared")):o.payloads&&(this.ri.register({[_9]:o.payloads}),mP.info("Payload overrides set",{payloads:o.payloads}))),void this.Os()}if(t&&typeof t=="object")return this.ri.register({[YS]:t}),this.Os(),mP.info("Flag overrides set",{flags:t});Wd.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.ds){var e=this.Ls(),n=e.flags,o=e.flagVariants;try{t(n,o)}catch(i){Wd.error("Error while running feature flags callback",i)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,n){var o,i=(this.xs(lL)||[]).find((a=>a.flagKey===t)),r={["$feature_enrollment/"+t]:e},A={$feature_flag:t,$feature_enrollment:e,$set:r};i&&(A.$early_access_feature_name=i.name),n&&(A.$feature_enrollment_stage=n),this._instance.capture("$feature_enrollment_update",A),this.setPersonPropertiesForFlags(r,!1);var s=fo({},this.getFlagVariants(),{[t]:e});(o=this.ri)==null||o.register({[Wj]:Object.keys(bct(s)),[aP]:s}),this.Os()}getEarlyAccessFeatures(t,e,n){e===void 0&&(e=!1);var o=this.xs(lL),i=n?"&"+n.map((r=>"stage="+r)).join("&"):"";if(o&&!e)return t(o);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this.Se.token+i),method:"GET",callback:r=>{var A,s;if(r.json){var a=r.json.earlyAccessFeatures;return(A=this.ri)==null||A.unregister(lL),(s=this.ri)==null||s.register({[lL]:a}),t(a)}}})}Ls(){var t=this.getFlags(),e=this.getFlagVariants();return{flags:t.filter((n=>e[n])),flagVariants:Object.keys(e).filter((n=>e[n])).reduce(((n,o)=>(n[o]=e[o],n)),{})}}Os(t){var e=this.Ls(),n=e.flags,o=e.flagVariants;this.featureFlagEventHandlers.forEach((i=>{try{i(n,o,{errorsLoading:t})}catch(r){Wd.error("Error while running feature flags callback",r)}}))}setPersonPropertiesForFlags(t,e){e===void 0&&(e=!0);var n=this.xs(cP)||{},o=t?.$set||(t!=null&&t.$set_once?{}:t),i=t?.$set_once,r={};if(i)for(var A in i)({}).hasOwnProperty.call(i,A)&&(A in n||(r[A]=i[A]));this._instance.register({[cP]:fo({},n,r,o)}),e&&this._instance.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,e){e===void 0&&(e=!0);var n=fo({},this.xs(cP)||{});t.forEach((o=>{delete n[o]})),this._instance.register({[cP]:n}),e&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){t===void 0&&(t=!0),this._instance.unregister(cP),t&&this._instance.reloadFeatureFlags()}setGroupPropertiesForFlags(t,e){e===void 0&&(e=!0);var n=this.xs(lP)||{};Object.keys(n).length!==0&&Object.keys(n).forEach((o=>{n[o]=fo({},n[o],t[o]),delete t[o]})),this._instance.register({[lP]:fo({},n,t)}),e&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var e=this.xs(lP)||{};this._instance.register({[lP]:fo({},e,{[t]:{}})})}else this._instance.unregister(lP)}reset(){this.ds=!1,this.cs=!1,this.vs=!1,this.fs=!1,this.ps=!1,this.$anon_distinct_id=void 0,this.Rs(),this.hs=!1,this.bs=0}}},UTn={sessionRecording:class{get Se(){return this._instance.config}get ri(){return this._instance.persistence}get started(){var t;return!((t=this.Fs)==null||!t.isStarted)}get status(){var t,e;return this.As===ML||this.As===CX?this.As:(t=(e=this.Fs)==null?void 0:e.status)!==null&&t!==void 0?t:this.As}constructor(t){if(this._forceAllowLocalhostNetworkCapture=!1,this.As=Cct,this.$s=void 0,this._instance=t,!this._instance.sessionManager)throw WS.error("started without valid sessionManager"),new Error(xIe+" started without valid sessionManager. This is a bug.");if(this.Se.cookieless_mode===VS)throw new Error(xIe+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get Ns(){var t,e=!((t=this._instance.get_property(sP))==null||!t.enabled),n=!this.Se.disable_session_recording,o=this.Se.disable_session_recording||this._instance.consent.isOptedOut();return wn&&e&&n&&!o}startIfEnabledOrStop(t){var e;if(!this.Ns||(e=this.Fs)==null||!e.isStarted){var n=!To(Object.assign)&&!To(Array.from);this.Ns&&n?(this.Ds(t),WS.info("starting")):(this.As=Cct,this.stopRecording())}}Ds(t){var e,n,o;this.Ns&&(this.As!==ML&&this.As!==CX&&(this.As=fct),_r!=null&&(e=_r.__PosthogExtensions__)!=null&&(e=e.rrweb)!=null&&e.record&&(n=_r.__PosthogExtensions__)!=null&&n.initSessionRecording?this.qs(t):(o=_r.__PosthogExtensions__)==null||o.loadExternalDependency==null||o.loadExternalDependency(this._instance,this.js,(i=>{if(i)return WS.error("could not load recorder",i);this.qs(t)})))}stopRecording(){var t,e;(t=this.$s)==null||t.call(this),this.$s=void 0,(e=this.Fs)==null||e.stop()}Bs(){var t,e;(t=this.$s)==null||t.call(this),this.$s=void 0,(e=this.Fs)==null||e.discard()}Hs(){var t,e;(t=this.ri)==null||t.unregister(Ppe),(e=this.ri)==null||e.unregister(Vst)}Us(t,e){if(as(t))return null;var n,o=Dp(t)?t:parseFloat(t);return typeof(n=o)!="number"||!Number.isFinite(n)||0>n||n>1?(WS.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):o}zs(t){if(this.ri){var e,n,o=this.ri,i=()=>{var r,A=t.sessionRecording===!1?void 0:t.sessionRecording,s=this.Us((r=this.Se.session_recording)==null?void 0:r.sampleRate,"session_recording.sampleRate"),a=this.Us(A?.sampleRate,"remote config sampleRate"),c=s??a;as(c)&&this.Hs();var l=A?.minimumDurationMilliseconds;o.register({[sP]:fo({cache_timestamp:Date.now(),enabled:!!A},A,{networkPayloadCapture:fo({capturePerformance:t.capturePerformance},A?.networkPayloadCapture),canvasRecording:{enabled:A?.recordCanvas,fps:A?.canvasFps,quality:A?.canvasQuality},sampleRate:c,minimumDurationMilliseconds:To(l)?null:l,endpoint:A?.endpoint,triggerMatchType:A?.triggerMatchType,masking:A?.masking,urlTriggers:A?.urlTriggers,version:A?.version,triggerGroups:A?.triggerGroups})})};i(),(e=this.$s)==null||e.call(this),this.$s=(n=this._instance.sessionManager)==null?void 0:n.onSessionId(i)}}onRemoteConfig(t){return"sessionRecording"in t?t.sessionRecording===!1?(this.zs(t),void this.Bs()):(this.zs(t),void this.startIfEnabledOrStop()):(this.As===ML&&(this.As=CX,WS.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,e){var n;e===void 0&&(e="log"),(n=this.Fs)!=null&&n.log?this.Fs.log(t,e):WS.warn("log called before recorder was ready")}get js(){var t,e,n=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.get_property(sP);return(n==null||(e=n.scriptConfig)==null?void 0:e.script)||"lazy-recorder"}Ws(){var t,e,n=this._instance.get_property(sP);if(!n)return!1;try{e=typeof n=="object"?n:JSON.parse(n)}catch(i){return WS.warn("persisted remote config for session recording is invalid and will be ignored",i),!1}var o=(t=e.cache_timestamp)!==null&&t!==void 0?t:Date.now();return 36e5>=Date.now()-o}qs(t){var e,n;if((e=_r.__PosthogExtensions__)==null||!e.initSessionRecording)return WS.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[Zst]:!0});if(this.Fs||(this.Fs=(n=_r.__PosthogExtensions__)==null?void 0:n.initSessionRecording(this._instance),this.Fs._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Ws())return this.As===CX||this.As===ML?void 0:(this.As=ML,WS.info("persisted remote config is stale, requesting fresh config before starting"),void new Gat(this._instance).load());this.As=fct,this.Fs.start(t)}onRRwebEmit(t){var e;(e=this.Fs)==null||e.onRRwebEmit==null||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.Fs||(e=this.ri)==null||e.register({[Jst]:!0}),(t=this.Fs)==null||t.overrideLinkedFlag()}overrideSampling(){var t,e;this.Fs||(e=this.ri)==null||e.register({[zst]:!0}),(t=this.Fs)==null||t.overrideSampling()}overrideTrigger(t){var e,n;this.Fs||(n=this.ri)==null||n.register({[t==="url"?qst:Wst]:!0}),(e=this.Fs)==null||e.overrideTrigger(t)}get sdkDebugProperties(){var t;return((t=this.Fs)==null?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,e){var n;return!((n=this.Fs)==null||!n.tryAddCustomEvent(t,e))}}},YTn={autocapture:class{constructor(t){this.Vs=!1,this.Zs=null,this.Gs=!1,this.instance=t,this.rageclicks=new mct(t.config.rageclick),this.Qs=null}initialize(){this.startIfEnabled()}get Se(){var t,e,n=P0(this.instance.config.autocapture)?this.instance.config.autocapture:{};return n.url_allowlist=(t=n.url_allowlist)==null?void 0:t.map((o=>new RegExp(o))),n.url_ignorelist=(e=n.url_ignorelist)==null?void 0:e.map((o=>new RegExp(o))),n}Js(){if(this.isBrowserSupported()){if(wn&&Zo){var t=n=>{n=n||wn?.event;try{this.Ks(n)}catch(o){EIe.error("Failed to capture event",o)}};if(au(Zo,"submit",t,{capture:!0}),au(Zo,"change",t,{capture:!0}),au(Zo,"click",t,{capture:!0}),this.Se.capture_copied_text){var e=n=>{n=n||wn?.event;try{this.Ks(n,yIe)}catch(o){EIe.error("Failed to capture copy/cut event",o)}};au(Zo,"copy",e,{capture:!0}),au(Zo,"cut",e,{capture:!0})}}}else EIe.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.Vs&&(this.Js(),this.Vs=!0)}onRemoteConfig(t){t.elementsChainAsString&&(this.Gs=t.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Epe]:!!t.autocapture_opt_out}),this.Zs=!!t.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(t){this.Qs=t}getElementSelectors(t){var e,n=[];return(e=this.Qs)==null||e.forEach((o=>{var i=Zo?.querySelectorAll(o);i?.forEach((r=>{t===r&&n.push(o)}))})),n}get isEnabled(){var t,e,n=(t=this.instance.persistence)==null?void 0:t.props[Epe];if(qC(this.Zs)&&!Wx(n)&&!this.instance.Rr())return!1;var o=(e=this.Zs)!==null&&e!==void 0?e:!!n;return!!this.instance.config.autocapture&&!o}Ks(t,e){if(e===void 0&&(e="$autocapture"),this.isEnabled){var n,o=Wpe(t);sat(o)&&(o=o.parentNode||null),e==="$autocapture"&&t.type==="click"&&t instanceof MouseEvent&&this.instance.config.rageclick&&(n=this.rageclicks)!=null&&n.isRageClick(t.clientX,t.clientY,t.timeStamp||new Date().getTime())&&mat(o,this.instance.config.rageclick)&&this.Ks(t,"$rageclick");var i=e===yIe;if(o&&(function(g,u,d,h,_,p){var m,I,C,f,y,B;if(d===void 0&&(d=void 0),!wn||$pe(g)||(m=d)!=null&&m.url_allowlist&&!lat(d.url_allowlist,p)||(I=d)!=null&&I.url_ignorelist&&lat(d.url_ignorelist,p))return!1;if((C=d)!=null&&C.dom_event_allowlist){var x=d.dom_event_allowlist;if(x&&!x.some((G=>u.type===G)))return!1}var S=pat(g,h),M=S.parentIsUsefulElement,w=S.targetElementList;if(!(function(G,H){var U=H?.element_allowlist;if(To(U))return!0;var J,W=function(oe){if(U.some((ce=>oe.tagName.toLowerCase()===ce)))return{v:!0}};for(var X of G)if(J=W(X))return J.v;return!1})(w,d)||!Xpe(w,(f=d)==null?void 0:f.css_selector_allowlist)||Xpe(w,(y=(B=d)==null?void 0:B.css_selector_ignorelist)!==null&&y!==void 0?y:URn))return!1;try{var k=wn.getComputedStyle(g);if(k&&k.getPropertyValue("cursor")==="pointer"&&u.type==="click")return!0}catch{}var N=g.tagName.toLowerCase();switch(N){case"html":return!1;case"form":return(_||["submit"]).indexOf(u.type)>=0;case"input":case"select":case"textarea":return(_||["change","click"]).indexOf(u.type)>=0;default:return M?(_||["click"]).indexOf(u.type)>=0:(_||["click"]).indexOf(u.type)>=0&&(jpe.indexOf(N)>-1||g.getAttribute("contenteditable")==="true")}})(o,t,this.Se,i,i?["copy","cut"]:void 0,this.instance)){var r=RTn(o,{e:t,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.Se.element_attribute_ignorelist,elementsChainAsString:this.Gs,disableCaptureUrlHashes:this.instance.config.disable_capture_url_hashes}),A=r.props;if(r.explicitNoCapture)return!1;var s=this.getElementSelectors(o);if(s&&s.length>0&&(A.$element_selectors=s),e===yIe){var a,c=gat(wn==null||(a=wn.getSelection())==null?void 0:a.toString()),l=t.type||"clipboard";if(!c)return!1;A.$selected_content=c,A.$copy_type=l}return this.instance.capture(e,A),!0}}}isBrowserSupported(){return pB(Zo?.querySelectorAll)}},historyAutocapture:class{constructor(t){var e;this._instance=t,this.Ys=(wn==null||(e=wn.location)==null?void 0:e.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(wo.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.Xs&&this.Xs(),this.Xs=void 0,wo.info("History API monitoring stopped")}monitorHistoryChanges(){wn&&wn.history&&(this.eo("pushState"),this.eo("replaceState"),this.ro())}eo(t){var e;if(wn&&((e=wn.history[t])==null||!e.__posthog_wrapped__)){var n=this;(function(o,i,r){try{if(!(i in o))return pct;var A={next:o[i]},s=r((function(){for(var a=arguments.length,c=new Array(a),l=0;a>l;l++)c[l]=arguments[l];return A.next.apply(this,c)}));return pB(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:A}})),o[i]=s,()=>{if(o[i]!==s)for(var a=o[i];pB(a)&&a.__posthog_layer__;){var c=a.__posthog_layer__;if(c.next===s)return void(c.next=A.next);a=c.next}else o[i]=A.next}}catch{return pct}})(wn.history,t,(o=>function(i,r,A){o.call(this,i,r,A),n.io(t)}))}}io(t){try{var e,n=wn==null||(e=wn.location)==null?void 0:e.pathname;if(!n)return;n!==this.Ys&&this.isEnabled&&this._instance.capture(I9,{navigation_type:t}),this.Ys=n}catch(o){wo.error("Error capturing "+t+" pageview",o)}}ro(){if(!this.Xs){var t=()=>{this.io("popstate")};au(wn,"popstate",t),this.Xs=()=>{wn&&wn.removeEventListener("popstate",t)}}}},heatmaps:class{get Se(){return this.instance.config}constructor(t){var e;this.no=!1,this.Vs=!1,this.so=null,this.instance=t,this.no=!((e=this.instance.persistence)==null||!e.props[Bpe]),this.rageclicks=new mct(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return P0(this.Se.capture_heatmaps)&&this.Se.capture_heatmaps.flush_interval_milliseconds&&(t=this.Se.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return as(this.Se.capture_heatmaps)?as(this.Se.enable_heatmaps)?this.no:this.Se.enable_heatmaps:this.Se.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.Vs)return;kTn.info("starting..."),this.oo(),this.ke()}else{var t;clearInterval((t=this.so)!==null&&t!==void 0?t:void 0),this.ao(),this.getAndClearBuffer()}}onRemoteConfig(t){if("heatmaps"in t){var e=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Bpe]:e}),this.no=e,this.startIfEnabled()}}getAndClearBuffer(){var t=this.R;return this.R=void 0,t}lo(t){this.fe(t.originalEvent,"deadclick")}ke(){this.so&&clearInterval(this.so),this.so=Zo?.visibilityState==="visible"?setInterval(this.Wr.bind(this),this.flushIntervalMilliseconds):null}oo(){wn&&Zo&&(this.uo=this.Wr.bind(this),au(wn,nX,this.uo),this.ho=t=>this.fe(t||wn?.event),au(Zo,"click",this.ho,{capture:!0}),this.do=t=>this.co(t||wn?.event),au(Zo,"mousemove",this.do,{capture:!0}),this.vo=new xat(this.instance,XRn,this.lo.bind(this)),this.vo.startIfEnabledOrStop(),this.fo=this.ke.bind(this),au(Zo,tX,this.fo),this.Vs=!0)}ao(){var t;wn&&Zo&&(this.uo&&wn.removeEventListener(nX,this.uo),this.ho&&Zo.removeEventListener("click",this.ho,{capture:!0}),this.do&&Zo.removeEventListener("mousemove",this.do,{capture:!0}),this.fo&&Zo.removeEventListener(tX,this.fo),clearTimeout(this.po),(t=this.vo)==null||t.stop(),this.Vs=!1)}mo(t,e){var n=this.instance.scrollManager.scrollY(),o=this.instance.scrollManager.scrollX(),i=this.instance.scrollManager.scrollElement(),r=(function(A,s,a){for(var c=A;c&&Ub(c)&&!ky(c,"body");){if(c===a)return!1;var l=void 0;try{var g,u,d;l=(g=(u=(d=c.ownerDocument)==null?void 0:d.defaultView)!==null&&u!==void 0?u:wn)==null?void 0:g.getComputedStyle(c).position}catch{return!1}if(gA(s,l))return!0;c=uat(c)}return!1})(Wpe(t),["fixed","sticky"],i);return{x:t.clientX+(r?0:o),y:t.clientY+(r?0:n),target_fixed:r,type:e}}fe(t,e){var n;if(e===void 0&&(e="click"),!Aat(t.target)&&yct(t)){var o=this.mo(t,e);(n=this.rageclicks)!=null&&n.isRageClick(t.clientX,t.clientY,new Date().getTime())&&mat(Wpe(t),this.instance.config.rageclick)&&this.kt(fo({},o,{type:"rageclick"})),this.kt(o)}}co(t){!Aat(t.target)&&yct(t)&&(clearTimeout(this.po),this.po=setTimeout((()=>{this.kt(this.mo(t,"mousemove"))}),500))}kt(t){if(wn){var e=this.Se.disable_capture_url_hashes?Kb(wn.location.href):wn.location.href,n=this.Se.custom_personal_data_properties,o=this.Se.mask_personal_data_properties?[...f9,...n||[]]:[],i=IL(e,o,CL);this.R=this.R||{},this.R[i]||(this.R[i]=[]),this.R[i].push(t)}}Wr(){this.R&&!Ob(this.R)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:xat,webVitalsAutocapture:class{constructor(t){var e;this.no=!1,this.Vs=!1,this.R={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.yo=()=>{clearTimeout(this.bo),this.R.metrics.length!==0&&(this._instance.capture("$web_vitals",this.R.metrics.reduce(((n,o)=>fo({},n,{["$web_vitals_"+o.name+"_event"]:fo({},o),["$web_vitals_"+o.name+"_value"]:o.value})),{})),this.R={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this._o=n=>{var o;this.R=this.R||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var i=this.wo();if(!To(i))if(as(n?.name)||as(n?.value))_P.error("Invalid metric received",n);else if(!this.xo||this.xo>n.value){this.R.url!==i&&(this.yo(),this.bo=setTimeout(this.yo,this.flushToCaptureTimeoutMs)),To(this.R.url)&&(this.R.url=i),this.R.firstMetricTimestamp=To(this.R.firstMetricTimestamp)?Date.now():this.R.firstMetricTimestamp,n.attribution&&n.attribution.interactionTargetElement&&(n.attribution.interactionTargetElement=void 0);var r=(o=this._instance.sessionManager)==null?void 0:o.checkAndGetSessionAndWindowId(!0),A=fo({},n,{$current_url:i,timestamp:Date.now()});To(r)||(A.$session_id=r.sessionId,A.$window_id=r.windowId),this.R.metrics.push(A),this.R.metrics.length===this.allowedMetrics.length&&this.yo()}else _P.error("Ignoring metric with value >= "+this.xo,n)},this.ko=()=>{if(!this.Vs){var n,o,i,r,A=_r.__PosthogExtensions__;if(!To(A)&&!To(A.postHogWebVitalsCallbacks)){var s=A.postHogWebVitalsCallbacks;n=s.onLCP,o=s.onCLS,i=s.onFCP,r=s.onINP}n&&o&&i&&r?(this.allowedMetrics.indexOf("LCP")>-1&&n(this._o.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&o(this._o.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&i(this._o.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&r(this._o.bind(this)),this.Vs=!0):_P.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.no=!((e=this._instance.persistence)==null||!e.props[bpe]),this.startIfEnabled()}get So(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,n=P0(this.So)?(t=this.So)==null?void 0:t.web_vitals_allowed_metrics:void 0;return as(n)?((e=this._instance.persistence)==null?void 0:e.props[wpe])||["CLS","FCP","INP","LCP"]:n}get flushToCaptureTimeoutMs(){return(P0(this.So)?this.So.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var t=P0(this.So)?this.So.web_vitals_attribution:void 0;return t!=null&&t}get xo(){var t=P0(this.So)&&Dp(this.So.__web_vitals_max_value)?this.So.__web_vitals_max_value:Ict;return t>0&&6e4>=t?Ict:t}get isEnabled(){var t=rd?.protocol;if(t!=="http:"&&t!=="https:")return _P.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=P0(this.So)?this.So.web_vitals:Wx(this.So)?this.So:void 0;return Wx(e)?e:this.no}startIfEnabled(){this.isEnabled&&!this.Vs&&(_P.info("enabled, starting..."),this.Bt(this.ko))}onRemoteConfig(t){if("capturePerformance"in t){var e=P0(t.capturePerformance)&&!!t.capturePerformance.web_vitals,n=P0(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[bpe]:e}),this._instance.persistence.register({[wpe]:n})),this.no=e,this.startIfEnabled()}}Bt(t){var e,n;(e=_r.__PosthogExtensions__)!=null&&e.postHogWebVitalsCallbacks?t():(n=_r.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,this.useAttribution?"web-vitals-with-attribution":"web-vitals",(o=>{o?_P.error("failed to load script",o):t()}))}wo(){var t=wn?this._instance.config.disable_capture_url_hashes?Kb(wn.location.href):wn.location.href:void 0;if(t){var e=this._instance.config.custom_personal_data_properties,n=this._instance.config.mask_personal_data_properties?[...f9,...e||[]]:[];return IL(t,n,CL)}_P.error("Could not determine current URL")}}},VTn={exceptionObserver:class{constructor(t){var e,n,o,i,r,A;this.ko=()=>{var s;if(wn&&this.isEnabled&&(s=_r.__PosthogExtensions__)!=null&&s.errorWrappingFunctions){var a=_r.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,c=_r.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,l=_r.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Co&&this.Se.capture_unhandled_errors&&(this.Co=a(this.captureException.bind(this))),!this.To&&this.Se.capture_unhandled_rejections&&(this.To=c(this.captureException.bind(this))),!this.Io&&this.Se.capture_console_errors&&(this.Io=l(this.captureException.bind(this)))}catch(g){DL.error("failed to start",g),this.Mo()}}},this._instance=t,this.Eo=!((e=this._instance.persistence)==null||!e.props[xpe]),this.Ro=new VNn(fo({},((n=this._instance.config.error_tracking)===void 0&&(n={}),{refillRate:(o=(i=n.exceptionRateLimiterRefillRate)!==null&&i!==void 0?i:n.__exceptionRateLimiterRefillRate)!==null&&o!==void 0?o:1,bucketSize:(r=(A=n.exceptionRateLimiterBucketSize)!==null&&A!==void 0?A:n.__exceptionRateLimiterBucketSize)!==null&&r!==void 0?r:10}),{refillInterval:1e4,Ae:DL})),this.Se=this.Po(),this.startIfEnabledOrStop()}Po(){var t=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return P0(t)?e=fo({},e,t):(To(t)?this.Eo:t)&&(e=fo({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.Se.capture_console_errors||this.Se.capture_unhandled_errors||this.Se.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(DL.info("enabled"),this.Mo(),this.Bt(this.ko)):this.Mo()}Bt(t){var e,n;(e=_r.__PosthogExtensions__)!=null&&e.errorWrappingFunctions?t():(n=_r.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"exception-autocapture",(o=>{if(o)return DL.error("failed to load script",o);t()}))}Mo(){var t,e,n;(t=this.Co)==null||t.call(this),this.Co=void 0,(e=this.To)==null||e.call(this),this.To=void 0,(n=this.Io)==null||n.call(this),this.Io=void 0}onRemoteConfig(t){"autocaptureExceptions"in t&&(this.Eo=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[xpe]:this.Eo}),this.Se=this.Po(),this.startIfEnabledOrStop())}onConfigChange(){this.Se=this.Po()}captureException(t){var e,n,o,i=(e=t==null||(n=t.$exception_list)==null||(n=n[0])==null?void 0:n.type)!==null&&e!==void 0?e:"Exception";this.Ro.consumeRateLimit(i)?DL.info("Skipping exception capture because of client rate limiting.",{exception:i}):(o=this._instance.exceptions)==null||o.sendExceptionEvent(t)}},exceptions:class{constructor(t){var e,n;this.Oo=[],this.Lo=new aRn([new mRn,new QRn,new IRn,new pRn,new BRn,new ERn,new fRn,new xRn],(function(o){for(var i=arguments.length,r=new Array(i>1?i-1:0),A=1;i>A;A++)r[A-1]=arguments[A];return function(s,a){a===void 0&&(a=0);for(var c=[],l=s.split(`
|
|
1044
|
+
`);const I=m.state[s];if(I==null)return;JSON.stringify(i.getState())!==JSON.stringify(I)&&d(I);return}i.dispatchFromDevtools&&typeof i.dispatch=="function"&&i.dispatch(m)});case"DISPATCH":switch(_.payload.type){case"RESET":return d(h),s===void 0?l?.init(i.getState()):l?.init(wj(a.name));case"COMMIT":if(s===void 0){l?.init(i.getState());return}return l?.init(wj(a.name));case"ROLLBACK":return Ome(_.state,m=>{if(s===void 0){d(m),l?.init(i.getState());return}d(m[s]),l?.init(wj(a.name))});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return Ome(_.state,m=>{if(s===void 0){d(m);return}JSON.stringify(i.getState())!==JSON.stringify(m[s])&&d(m[s])});case"IMPORT_STATE":{const{nextLiftedState:m}=_.payload,I=(p=m.computedStates.slice(-1)[0])==null?void 0:p.state;if(!I)return;d(s===void 0?I:I[s]),l?.send(null,m);return}case"PAUSE_RECORDING":return u=!u}return}}),h},Ome=(t,e)=>{let n;try{n=JSON.parse(t)}catch(o){console.error("[zustand devtools middleware] Could not parse the received json",o)}n!==void 0&&e(n)},zC=window.TSCIRCUIT_FILESERVER_API_BASE_URL??"/api",u7n=[".tsx",".ts",".jsx",".js",".mjs",".json",".kicad_pcb",".kicad_sym",".kicad_sch",".kicad_prl",".kicad_pro"],Kme=t=>u7n.some(e=>t.endsWith(e)),XF=qrt.extend("store");async function cAt(t,e){return(await(await fetch(`${zC}/files/upsert`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:t,text_content:e})})).json()).file}async function Ume(t){return(await(await fetch(`${zC}/files/get?file_path=${encodeURIComponent(t)}`)).json()).file}async function h7n(t){const e=t?`${zC}/events/list?since=${encodeURIComponent(t)}`:`${zC}/events/list`;return(await(await fetch(e)).json()).event_list}async function d7n(){const t=await fetch(`${zC}/files/list`),{file_list:e}=await t.json(),n=new Map;for(const o of e){if(Kme(o.file_path)){const i=await Ume(o.file_path);n.set(o.file_path,i.text_content);continue}n.set(o.file_path,"__STATIC_ASSET__")}return n}const _7n=["manual-edits.json","manual_edits.json"],M0=sAt()(aAt((t,e)=>({fsMap:new Map,lastEventTime:new Date().toISOString(),isPolling:!1,error:null,circuitJson:null,lastManualEditsChangeSentAt:0,recentEvents:[],simulateScenarioOrder:void 0,currentMainComponentPath:null,recentlySavedFiles:[],loadInitialFiles:async()=>{const n=await d7n();XF("loaded initial files",{fsMap:n}),t({fsMap:n})},upsertFile:async(n,o)=>{try{const i=await cAt(n,o);t(r=>({fsMap:new Map(r.fsMap).set(i.file_path,i.text_content)}))}catch(i){t({error:i})}},getFile:async n=>{try{const o=await Ume(n);t(i=>({fsMap:new Map(i.fsMap).set(o.file_path,o.text_content)}))}catch(o){t({error:o})}},setCircuitJson:n=>{n!==e().circuitJson&&t({circuitJson:n})},addRecentlySavedFile:n=>{t(o=>{if(_7n.includes(n)||!Kme(n))return o;const i=o.recentlySavedFiles.filter(r=>r!==n);return{recentlySavedFiles:[n,...i].slice(0,10)}})},startPolling:()=>{const n=async()=>{const o=e();if(o.isPolling){try{const i=await h7n(o.lastEventTime);if(i.length>0){const r=i[i.length-1].created_at;XF("received events",i.map(a=>a.event_type)),t(a=>({recentEvents:[...a.recentEvents,...i].slice(0,100),lastEventTime:r}));let A=0;const s=new Map(o.fsMap);for(const a of i)if(a.event_type==="FILE_UPDATED"){A++;const c=await Ume(a.file_path);if(a.file_path==="manual_edits.json"&&Date.now()-o.lastManualEditsChangeSentAt<1e3)continue;Kme(c.file_path)?s.set(c.file_path,c.text_content??""):s.set(c.file_path,"__STATIC_ASSET__"),e().addRecentlySavedFile(a.file_path)}else a.event_type==="FILE_DELETED"&&(A++,s.delete(a.file_path));A>0&&(XF("updating fsMap, fsUpdateCount:",A),t({fsMap:s}))}}catch(i){t({error:i})}setTimeout(n,1e3)}};t({isPolling:!0}),n()},stopPolling:()=>{t({isPolling:!1})},pushEvent:async n=>{await fetch(`${zC}/events/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})},applyEditEventsAndUpdateManualEditsJson:async n=>{XF("applyEditEventsAndUpdateManualEditsJson",{editEvents:n});const o=e();if(!o.circuitJson)return;const i=o.fsMap.get("manual-edits.json"),r=i?JSON.parse(i):{},A=fit({circuitJson:o.circuitJson,editEvents:n,manualEditsFile:r});XF("updatedManualEditsFileContent",A),t(s=>({lastManualEditsChangeSentAt:Date.now(),fsMap:new Map(s.fsMap).set("manual-edits.json",JSON.stringify(A))})),await cAt("manual-edits.json",JSON.stringify(A,null,2))},setSimulateScenarioOrder:n=>t({simulateScenarioOrder:n}),setCurrentMainComponentPath:n=>t({currentMainComponentPath:n})}),{name:"run-frame-store"})),m7n=qrt.extend("useEditEventController"),p7n=()=>{const t=M0(d=>d.applyEditEventsAndUpdateManualEditsJson),[e,n]=j.useState([]),[o,i]=j.useState(!1),r=e.filter(d=>!d._applied),A=e.filter(d=>d._applied),s=o?e:r,a=j.useCallback(d=>{n(h=>[...h,{...d,_applied:!1}])},[]),c=j.useCallback(d=>{n(h=>h.map(_=>_===d?{..._,_applied:!0}:_))},[]),l=j.useCallback(()=>{n(d=>d.map(h=>({...h,_applied:!0})))},[]),g=j.useCallback(()=>{i(!0),e.length!==0&&(m7n("removing edit events that are applied"),n(d=>d.filter(h=>!h._applied)))},[e]),u=j.useCallback(()=>{i(!1)},[]);return j.useEffect(()=>{if(e.filter(h=>!h._applied).length===0)return;const d=setTimeout(()=>{l(),t(e)},1e3);return()=>clearTimeout(d)},[e]),{unappliedEditEvents:r,appliedEditEvents:A,editEventsForRender:s,pushEditEvent:a,markEditEventApplied:c,markRenderStarted:g,markRenderComplete:u,markAllEditEventsApplied:l}},Yme=Ra("run-frame:useHasReceivedInitialFilesLoaded"),I7n=()=>{const[t,e]=j.useState(!1),n=M0(i=>i.recentEvents),o=M0(i=>i.loadInitialFiles);return j.useEffect(()=>{(async()=>{await o();try{const r=await fetch(`${zC}/events/list?event_type=INITIAL_FILES_UPLOADED`);if(r.ok){const{event_list:A}=await r.json();if(A.length>0){Yme("INITIAL_FILES_UPLOADED found in history. Assuming ready."),e(!0);return}}}catch(r){console.error("Failed to check for event history",r)}Yme("No INITIAL_FILES_UPLOADED in history, waiting for polling.")})()},[o]),j.useEffect(()=>{t||n.some(i=>i.event_type==="INITIAL_FILES_UPLOADED")&&(Yme("INITIAL_FILES_UPLOADED received via polling. Assuming ready."),e(!0))},[n,t]),t};function r9(t,e,n){const[o,i]=j.useState(()=>{if(n!==void 0)return n;try{const r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return console.error("Error reading from localStorage:",r),e}});return j.useEffect(()=>{try{window.localStorage.setItem(t,JSON.stringify(o))}catch(r){console.error("Error writing to localStorage:",r)}},[t,o]),[o,i]}function wr(t,e,{checkForDefaultPrevented:n=!0}={}){return function(i){if(t?.(i),n===!1||!i||!i.defaultPrevented)return e?.(i)}}function _B(t,e=[]){let n=[];function o(r,A){const s=j.createContext(A);s.displayName=r+"Context";const a=n.length;n=[...n,A];const c=g=>{const{scope:u,children:d,...h}=g,_=u?.[t]?.[a]||s,p=j.useMemo(()=>h,Object.values(h));return V.jsx(_.Provider,{value:p,children:d})};c.displayName=r+"Provider";function l(g,u,d={}){const{optional:h=!1}=d,_=u?.[t]?.[a]||s,p=j.useContext(_);if(p)return p;if(A!==void 0)return A;if(!h)throw new Error(`\`${g}\` must be used within \`${r}\``)}return[c,l]}const i=()=>{const r=n.map(A=>j.createContext(A));return function(s){const a=s?.[t]||r;return j.useMemo(()=>({[`__scope${t}`]:{...s,[t]:a}}),[s,a])}};return i.scopeName=t,[o,C7n(i,...e)]}function C7n(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const o=t.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(r){const A=o.reduce((s,{useScope:a,scopeName:c})=>{const g=a(r)[`__scope${c}`];return{...s,...g}},{});return j.useMemo(()=>({[`__scope${e.scopeName}`]:A}),[A])}};return n.scopeName=e.scopeName,n}function lAt(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function A9(...t){return e=>{let n=!1;const o=t.map(i=>{const r=lAt(i,e);return!n&&typeof r=="function"&&(n=!0),r});if(n)return()=>{for(let i=0;i<o.length;i++){const r=o[i];typeof r=="function"?r():lAt(t[i],null)}}}}function mg(...t){return j.useCallback(A9(...t),t)}function iP(t){const e=j.forwardRef((n,o)=>{let{children:i,...r}=n,A=null,s=!1;const a=[];uAt(i)&&typeof Pj=="function"&&(i=Pj(i._payload)),j.Children.forEach(i,u=>{if(Q7n(u)){s=!0;const d=u;let h="child"in d.props?d.props.child:d.props.children;uAt(h)&&typeof Pj=="function"&&(h=Pj(h._payload)),A=E7n(d,h),a.push(A?.props?.children)}else a.push(u)}),A?A=j.cloneElement(A,void 0,a):!s&&j.Children.count(i)===1&&j.isValidElement(i)&&(A=i);const c=A?x7n(A):void 0,l=mg(o,c);if(!A){if(i||i===0)throw new Error(s?M7n(t):D7n(t));return i}const g=B7n(r,A.props??{});return A.type!==j.Fragment&&(g.ref=o?l:c),j.cloneElement(A,g)});return e.displayName=`${t}.Slot`,e}var f7n=iP("Slot"),gAt=Symbol.for("radix.slottable");function y7n(t){const e=n=>"child"in n?n.children(n.child):n.children;return e.displayName=`${t}.Slottable`,e.__radixId=gAt,e}var E7n=(t,e)=>{if("child"in t.props){const n=t.props.child;return j.isValidElement(n)?j.cloneElement(n,void 0,t.props.children(n.props.children)):null}return j.isValidElement(e)?e:null};function B7n(t,e){const n={...e};for(const o in e){const i=t[o],r=e[o];/^on[A-Z]/.test(o)?i&&r?n[o]=(...s)=>{const a=r(...s);return i(...s),a}:i&&(n[o]=i):o==="style"?n[o]={...i,...r}:o==="className"&&(n[o]=[i,r].filter(Boolean).join(" "))}return{...t,...n}}function x7n(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function Q7n(t){return j.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===gAt}var S7n=Symbol.for("react.lazy");function uAt(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===S7n&&"_payload"in t&&b7n(t._payload)}function b7n(t){return typeof t=="object"&&t!==null&&"then"in t}var D7n=t=>`${t} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,M7n=t=>`${t} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,Pj=g4[" use ".trim().toString()];function hAt(t){const e=t+"CollectionProvider",[n,o]=_B(e),[i,r]=n(e,{collectionRef:{current:null},itemMap:new Map}),A=_=>{const{scope:p,children:m}=_,I=j.useRef(null),C=j.useRef(new Map).current;return V.jsx(i,{scope:p,itemMap:C,collectionRef:I,children:m})};A.displayName=e;const s=t+"CollectionSlot",a=iP(s),c=j.forwardRef((_,p)=>{const{scope:m,children:I}=_,C=r(s,m),f=mg(p,C.collectionRef);return V.jsx(a,{ref:f,children:I})});c.displayName=s;const l=t+"CollectionItemSlot",g="data-radix-collection-item",u=iP(l),d=j.forwardRef((_,p)=>{const{scope:m,children:I,...C}=_,f=j.useRef(null),y=mg(p,f),B=r(l,m);return j.useEffect(()=>(B.itemMap.set(f,{ref:f,...C}),()=>{B.itemMap.delete(f)})),V.jsx(u,{[g]:"",ref:y,children:I})});d.displayName=l;function h(_){const p=r(t+"CollectionConsumer",_);return j.useCallback(()=>{const I=p.collectionRef.current;if(!I)return[];const C=Array.from(I.querySelectorAll(`[${g}]`));return Array.from(p.itemMap.values()).sort((B,x)=>C.indexOf(B.ref.current)-C.indexOf(x.ref.current))},[p.collectionRef,p.itemMap])}return[{Provider:A,Slot:c,ItemSlot:d},h,o]}var Jx=globalThis?.document?j.useLayoutEffect:()=>{},w7n=g4[" useId ".trim().toString()]||(()=>{}),P7n=0;function bp(t){const[e,n]=j.useState(w7n());return Jx(()=>{n(o=>o??String(P7n++))},[t]),e?`radix-${e}`:""}var rP=Noe();const dAt=V2(rP);var v7n=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Us=v7n.reduce((t,e)=>{const n=iP(`Primitive.${e}`),o=j.forwardRef((i,r)=>{const{asChild:A,...s}=i,a=A?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),V.jsx(a,{...s,ref:r})});return o.displayName=`Primitive.${e}`,{...t,[e]:o}},{});function _At(t,e){t&&rP.flushSync(()=>t.dispatchEvent(e))}function qx(t){const e=j.useRef(t);return j.useEffect(()=>{e.current=t}),j.useMemo(()=>((...n)=>e.current?.(...n)),[])}var N7n=g4[" useInsertionEffect ".trim().toString()]||Jx;function Lb({prop:t,defaultProp:e,onChange:n=()=>{},caller:o}){const[i,r,A]=R7n({defaultProp:e,onChange:n}),s=t!==void 0,a=s?t:i;{const l=j.useRef(t!==void 0);j.useEffect(()=>{const g=l.current;g!==s&&console.warn(`${o} is changing from ${g?"controlled":"uncontrolled"} to ${s?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),l.current=s},[s,o])}const c=j.useCallback(l=>{if(s){const g=T7n(l)?l(t):l;g!==t&&A.current?.(g)}else r(l)},[s,t,r,A]);return[a,c]}function R7n({defaultProp:t,onChange:e}){const[n,o]=j.useState(t),i=j.useRef(n),r=j.useRef(e);return N7n(()=>{r.current=e},[e]),j.useEffect(()=>{i.current!==n&&(r.current?.(n),i.current=n)},[n,i]),[n,o,r]}function T7n(t){return typeof t=="function"}var k7n=j.createContext(void 0);function Vme(t){const e=j.useContext(k7n);return t||e||"ltr"}var zme=!1;function F7n(){const[t,e]=j.useState(zme);return j.useEffect(()=>{zme||(zme=!0,e(!0))},[]),t}var mAt=g4[" useSyncExternalStore ".trim().toString()];function L7n(){return()=>{}}function H7n(){return mAt(L7n,()=>!0,()=>!1)}var G7n=typeof mAt=="function"?H7n:F7n,Jme="rovingFocusGroup.onEntryFocus",O7n={bubbles:!1,cancelable:!0},$F="RovingFocusGroup",[qme,pAt,K7n]=hAt($F),[U7n,vj]=_B($F,[K7n]),[Y7n,V7n]=U7n($F),IAt=j.forwardRef((t,e)=>V.jsx(qme.Provider,{scope:t.__scopeRovingFocusGroup,children:V.jsx(qme.Slot,{scope:t.__scopeRovingFocusGroup,children:V.jsx(z7n,{...t,ref:e})})}));IAt.displayName=$F;var z7n=j.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:o,loop:i=!1,dir:r,currentTabStopId:A,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:a,onEntryFocus:c,preventScrollOnEntryFocus:l=!1,...g}=t,u=j.useRef(null),d=mg(e,u),h=Vme(r),[_,p]=Lb({prop:A,defaultProp:s??null,onChange:a,caller:$F}),[m,I]=j.useState(!1),C=qx(c),f=pAt(n),y=j.useRef(!1),[B,x]=j.useState(0);return j.useEffect(()=>{const S=u.current;if(S)return S.addEventListener(Jme,C),()=>S.removeEventListener(Jme,C)},[C]),V.jsx(Y7n,{scope:n,orientation:o,dir:h,loop:i,currentTabStopId:_,onItemFocus:j.useCallback(S=>p(S),[p]),onItemShiftTab:j.useCallback(()=>I(!0),[]),onFocusableItemAdd:j.useCallback(()=>x(S=>S+1),[]),onFocusableItemRemove:j.useCallback(()=>x(S=>S-1),[]),children:V.jsx(Us.div,{tabIndex:m||B===0?-1:0,"data-orientation":o,...g,ref:d,style:{outline:"none",...t.style},onMouseDown:wr(t.onMouseDown,()=>{y.current=!0}),onFocus:wr(t.onFocus,S=>{const M=!y.current;if(S.target===S.currentTarget&&M&&!m){const w=new CustomEvent(Jme,O7n);if(S.currentTarget.dispatchEvent(w),!w.defaultPrevented){const k=f().filter(J=>J.focusable),N=k.find(J=>J.active),G=k.find(J=>J.id===_),U=[N,G,...k].filter(Boolean).map(J=>J.ref.current);yAt(U,l)}}y.current=!1}),onBlur:wr(t.onBlur,()=>I(!1))})})}),CAt="RovingFocusGroupItem",fAt=j.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:o=!0,active:i=!1,tabStopId:r,children:A,...s}=t,a=bp(),c=r||a,l=V7n(CAt,n),g=l.currentTabStopId===c,u=pAt(n),{onFocusableItemAdd:d,onFocusableItemRemove:h,currentTabStopId:_}=l,p=G7n();return Jx(()=>{if(!(!p||!o))return d(),()=>h()},[p,o,d,h]),j.useEffect(()=>{if(!(p||!o))return d(),()=>h()},[p,o,d,h]),V.jsx(qme.ItemSlot,{scope:n,id:c,focusable:o,active:i,children:V.jsx(Us.span,{tabIndex:g?0:-1,"data-orientation":l.orientation,...s,ref:e,onMouseDown:wr(t.onMouseDown,m=>{o?l.onItemFocus(c):m.preventDefault()}),onFocus:wr(t.onFocus,()=>l.onItemFocus(c)),onKeyDown:wr(t.onKeyDown,m=>{if(m.key==="Tab"&&m.shiftKey){l.onItemShiftTab();return}if(m.target!==m.currentTarget)return;const I=W7n(m,l.orientation,l.dir);if(I!==void 0){if(m.metaKey||m.ctrlKey||m.altKey||m.shiftKey)return;m.preventDefault();let f=u().filter(y=>y.focusable).map(y=>y.ref.current);if(I==="last")f.reverse();else if(I==="prev"||I==="next"){I==="prev"&&f.reverse();const y=f.indexOf(m.currentTarget);f=l.loop?j7n(f,y+1):f.slice(y+1)}setTimeout(()=>yAt(f))}}),children:typeof A=="function"?A({isCurrentTabStop:g,hasTabStop:_!=null}):A})})});fAt.displayName=CAt;var J7n={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function q7n(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function W7n(t,e,n){const o=q7n(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return J7n[o]}function yAt(t,e=!1){const n=document.activeElement;for(const o of t)if(o===n||(o.focus({preventScroll:e}),document.activeElement!==n))return}function j7n(t,e){return t.map((n,o)=>t[(e+o)%t.length])}var EAt=IAt,BAt=fAt;function X7n(t,e){return j.useReducer((n,o)=>e[n][o]??n,t)}var Ry=t=>{const{present:e,children:n}=t,o=$7n(e),i=typeof n=="function"?n({present:o.isPresent}):j.Children.only(n),r=Z7n(o.ref,eNn(i));return typeof n=="function"||o.isPresent?j.cloneElement(i,{ref:r}):null};Ry.displayName="Presence";function $7n(t){const[e,n]=j.useState(),o=j.useRef(null),i=j.useRef(t),r=j.useRef("none"),A=j.useRef(void 0),s=t?"mounted":"unmounted",[a,c]=X7n(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return j.useEffect(()=>{a==="mounted"?(r.current=A.current??ZF(o.current),A.current=void 0):r.current="none"},[a]),Jx(()=>{const l=o.current,g=i.current;if(g!==t){const d=r.current,h=ZF(l);t?(A.current=h,c("MOUNT")):h==="none"||l?.display==="none"?c("UNMOUNT"):c(g&&d!==h?"ANIMATION_OUT":"UNMOUNT"),i.current=t}},[t,c]),Jx(()=>{if(e){let l;const g=e.ownerDocument.defaultView??window,u=h=>{const p=ZF(o.current).includes(CSS.escape(h.animationName));if(h.target===e&&p&&(c("ANIMATION_END"),!i.current)){const m=e.style.animationFillMode;e.style.animationFillMode="forwards",l=g.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=m)})}},d=h=>{h.target===e&&(r.current=ZF(o.current))};return e.addEventListener("animationstart",d),e.addEventListener("animationcancel",u),e.addEventListener("animationend",u),()=>{g.clearTimeout(l),e.removeEventListener("animationstart",d),e.removeEventListener("animationcancel",u),e.removeEventListener("animationend",u)}}else c("ANIMATION_END")},[e,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:j.useCallback(l=>{if(l){const g=getComputedStyle(l);o.current=g,A.current=ZF(g)}else o.current=null;n(l)},[])}}function xAt(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Z7n(...t){const e=j.useRef(t);return e.current=t,j.useCallback(n=>{const o=e.current;let i=!1;const r=o.map(A=>{const s=xAt(A,n);return!i&&typeof s=="function"&&(i=!0),s});if(i)return()=>{for(let A=0;A<r.length;A++){const s=r[A];typeof s=="function"?s():xAt(o[A],null)}}},[])}function ZF(t){return t?.animationName||"none"}function eNn(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var Nj="Tabs",[tNn]=_B(Nj,[vj]),QAt=vj(),[nNn,Wme]=tNn(Nj),SAt=j.forwardRef((t,e)=>{const{__scopeTabs:n,value:o,onValueChange:i,defaultValue:r,orientation:A="horizontal",dir:s,activationMode:a="automatic",...c}=t,l=Vme(s),[g,u]=Lb({prop:o,onChange:i,defaultProp:r??"",caller:Nj});return V.jsx(nNn,{scope:n,baseId:bp(),value:g,onValueChange:u,orientation:A,dir:l,activationMode:a,children:V.jsx(Us.div,{dir:l,"data-orientation":A,...c,ref:e})})});SAt.displayName=Nj;var bAt="TabsList",DAt=j.forwardRef((t,e)=>{const{__scopeTabs:n,loop:o=!0,...i}=t,r=Wme(bAt,n),A=QAt(n);return V.jsx(EAt,{asChild:!0,...A,orientation:r.orientation,dir:r.dir,loop:o,children:V.jsx(Us.div,{role:"tablist","aria-orientation":r.orientation,...i,ref:e})})});DAt.displayName=bAt;var MAt="TabsTrigger",wAt=j.forwardRef((t,e)=>{const{__scopeTabs:n,value:o,disabled:i=!1,...r}=t,A=Wme(MAt,n),s=QAt(n),a=NAt(A.baseId,o),c=RAt(A.baseId,o),l=o===A.value;return V.jsx(BAt,{asChild:!0,...s,focusable:!i,active:l,children:V.jsx(Us.button,{type:"button",role:"tab","aria-selected":l,"aria-controls":c,"data-state":l?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:a,...r,ref:e,onMouseDown:wr(t.onMouseDown,g=>{!i&&g.button===0&&g.ctrlKey===!1?A.onValueChange(o):g.preventDefault()}),onKeyDown:wr(t.onKeyDown,g=>{i||g.target!==g.currentTarget||[" ","Enter"].includes(g.key)&&A.onValueChange(o)}),onFocus:wr(t.onFocus,()=>{const g=A.activationMode!=="manual";!l&&!i&&g&&A.onValueChange(o)})})})});wAt.displayName=MAt;var PAt="TabsContent",vAt=j.forwardRef((t,e)=>{const{__scopeTabs:n,value:o,forceMount:i,children:r,...A}=t,s=Wme(PAt,n),a=NAt(s.baseId,o),c=RAt(s.baseId,o),l=o===s.value,g=j.useRef(l);return j.useEffect(()=>{const u=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(u)},[]),V.jsx(Ry,{present:i||l,children:({present:u})=>V.jsx(Us.div,{"data-state":l?"active":"inactive","data-orientation":s.orientation,role:"tabpanel","aria-labelledby":a,hidden:!u,id:c,tabIndex:0,...A,ref:e,style:{...t.style,animationDuration:g.current?"0s":void 0},children:u&&r})})});vAt.displayName=PAt;function NAt(t,e){return`${t}-trigger-${e}`}function RAt(t,e){return`${t}-content-${e}`}var oNn=SAt,TAt=DAt,kAt=wAt,FAt=vAt;function LAt(t){var e,n,o="";if(typeof t=="string"||typeof t=="number")o+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e<i;e++)t[e]&&(n=LAt(t[e]))&&(o&&(o+=" "),o+=n)}else for(n in t)t[n]&&(o&&(o+=" "),o+=n);return o}function mB(){for(var t,e,n=0,o="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=LAt(t))&&(o&&(o+=" "),o+=e);return o}const jme="-",iNn=t=>{const e=ANn(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:o}=t;return{getClassGroupId:A=>{const s=A.split(jme);return s[0]===""&&s.length!==1&&s.shift(),HAt(s,e)||rNn(A)},getConflictingClassGroupIds:(A,s)=>{const a=n[A]||[];return s&&o[A]?[...a,...o[A]]:a}}},HAt=(t,e)=>{if(t.length===0)return e.classGroupId;const n=t[0],o=e.nextPart.get(n),i=o?HAt(t.slice(1),o):void 0;if(i)return i;if(e.validators.length===0)return;const r=t.join(jme);return e.validators.find(({validator:A})=>A(r))?.classGroupId},GAt=/^\[(.+)\]$/,rNn=t=>{if(GAt.test(t)){const e=GAt.exec(t)[1],n=e?.substring(0,e.indexOf(":"));if(n)return"arbitrary.."+n}},ANn=t=>{const{theme:e,prefix:n}=t,o={nextPart:new Map,validators:[]};return aNn(Object.entries(t.classGroups),n).forEach(([r,A])=>{Xme(A,o,r,e)}),o},Xme=(t,e,n,o)=>{t.forEach(i=>{if(typeof i=="string"){const r=i===""?e:OAt(e,i);r.classGroupId=n;return}if(typeof i=="function"){if(sNn(i)){Xme(i(o),e,n,o);return}e.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([r,A])=>{Xme(A,OAt(e,r),n,o)})})},OAt=(t,e)=>{let n=t;return e.split(jme).forEach(o=>{n.nextPart.has(o)||n.nextPart.set(o,{nextPart:new Map,validators:[]}),n=n.nextPart.get(o)}),n},sNn=t=>t.isThemeGetter,aNn=(t,e)=>e?t.map(([n,o])=>{const i=o.map(r=>typeof r=="string"?e+r:typeof r=="object"?Object.fromEntries(Object.entries(r).map(([A,s])=>[e+A,s])):r);return[n,i]}):t,cNn=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=new Map,o=new Map;const i=(r,A)=>{n.set(r,A),e++,e>t&&(e=0,o=n,n=new Map)};return{get(r){let A=n.get(r);if(A!==void 0)return A;if((A=o.get(r))!==void 0)return i(r,A),A},set(r,A){n.has(r)?n.set(r,A):i(r,A)}}},KAt="!",lNn=t=>{const{separator:e,experimentalParseClassName:n}=t,o=e.length===1,i=e[0],r=e.length,A=s=>{const a=[];let c=0,l=0,g;for(let p=0;p<s.length;p++){let m=s[p];if(c===0){if(m===i&&(o||s.slice(p,p+r)===e)){a.push(s.slice(l,p)),l=p+r;continue}if(m==="/"){g=p;continue}}m==="["?c++:m==="]"&&c--}const u=a.length===0?s:s.substring(l),d=u.startsWith(KAt),h=d?u.substring(1):u,_=g&&g>l?g-l:void 0;return{modifiers:a,hasImportantModifier:d,baseClassName:h,maybePostfixModifierPosition:_}};return n?s=>n({className:s,parseClassName:A}):A},gNn=t=>{if(t.length<=1)return t;const e=[];let n=[];return t.forEach(o=>{o[0]==="["?(e.push(...n.sort(),o),n=[]):n.push(o)}),e.push(...n.sort()),e},uNn=t=>({cache:cNn(t.cacheSize),parseClassName:lNn(t),...iNn(t)}),hNn=/\s+/,dNn=(t,e)=>{const{parseClassName:n,getClassGroupId:o,getConflictingClassGroupIds:i}=e,r=[],A=t.trim().split(hNn);let s="";for(let a=A.length-1;a>=0;a-=1){const c=A[a],{modifiers:l,hasImportantModifier:g,baseClassName:u,maybePostfixModifierPosition:d}=n(c);let h=!!d,_=o(h?u.substring(0,d):u);if(!_){if(!h){s=c+(s.length>0?" "+s:s);continue}if(_=o(u),!_){s=c+(s.length>0?" "+s:s);continue}h=!1}const p=gNn(l).join(":"),m=g?p+KAt:p,I=m+_;if(r.includes(I))continue;r.push(I);const C=i(_,h);for(let f=0;f<C.length;++f){const y=C[f];r.push(m+y)}s=c+(s.length>0?" "+s:s)}return s};function _Nn(){let t=0,e,n,o="";for(;t<arguments.length;)(e=arguments[t++])&&(n=UAt(e))&&(o&&(o+=" "),o+=n);return o}const UAt=t=>{if(typeof t=="string")return t;let e,n="";for(let o=0;o<t.length;o++)t[o]&&(e=UAt(t[o]))&&(n&&(n+=" "),n+=e);return n};function mNn(t,...e){let n,o,i,r=A;function A(a){const c=e.reduce((l,g)=>g(l),t());return n=uNn(c),o=n.cache.get,i=n.cache.set,r=s,s(a)}function s(a){const c=o(a);if(c)return c;const l=dNn(a,n);return i(a,l),l}return function(){return r(_Nn.apply(null,arguments))}}const w0=t=>{const e=n=>n[t]||[];return e.isThemeGetter=!0,e},YAt=/^\[(?:([a-z-]+):)?(.+)\]$/i,pNn=/^\d+\/\d+$/,INn=new Set(["px","full","screen"]),CNn=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,fNn=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,yNn=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,ENn=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,BNn=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,GS=t=>s9(t)||INn.has(t)||pNn.test(t),Hb=t=>a9(t,"length",PNn),s9=t=>!!t&&!Number.isNaN(Number(t)),$me=t=>a9(t,"number",s9),eL=t=>!!t&&Number.isInteger(Number(t)),xNn=t=>t.endsWith("%")&&s9(t.slice(0,-1)),Ss=t=>YAt.test(t),Gb=t=>CNn.test(t),QNn=new Set(["length","size","percentage"]),SNn=t=>a9(t,QNn,VAt),bNn=t=>a9(t,"position",VAt),DNn=new Set(["image","url"]),MNn=t=>a9(t,DNn,NNn),wNn=t=>a9(t,"",vNn),tL=()=>!0,a9=(t,e,n)=>{const o=YAt.exec(t);return o?o[1]?typeof e=="string"?o[1]===e:e.has(o[1]):n(o[2]):!1},PNn=t=>fNn.test(t)&&!yNn.test(t),VAt=()=>!1,vNn=t=>ENn.test(t),NNn=t=>BNn.test(t),RNn=mNn(()=>{const t=w0("colors"),e=w0("spacing"),n=w0("blur"),o=w0("brightness"),i=w0("borderColor"),r=w0("borderRadius"),A=w0("borderSpacing"),s=w0("borderWidth"),a=w0("contrast"),c=w0("grayscale"),l=w0("hueRotate"),g=w0("invert"),u=w0("gap"),d=w0("gradientColorStops"),h=w0("gradientColorStopPositions"),_=w0("inset"),p=w0("margin"),m=w0("opacity"),I=w0("padding"),C=w0("saturate"),f=w0("scale"),y=w0("sepia"),B=w0("skew"),x=w0("space"),S=w0("translate"),M=()=>["auto","contain","none"],w=()=>["auto","hidden","clip","visible","scroll"],k=()=>["auto",Ss,e],N=()=>[Ss,e],G=()=>["",GS,Hb],H=()=>["auto",s9,Ss],U=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],J=()=>["solid","dashed","dotted","double","none"],W=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],X=()=>["start","end","center","between","around","evenly","stretch"],oe=()=>["","0",Ss],ce=()=>["auto","avoid","all","avoid-page","page","left","right","column"],te=()=>[s9,Ss];return{cacheSize:500,separator:":",theme:{colors:[tL],spacing:[GS,Hb],blur:["none","",Gb,Ss],brightness:te(),borderColor:[t],borderRadius:["none","","full",Gb,Ss],borderSpacing:N(),borderWidth:G(),contrast:te(),grayscale:oe(),hueRotate:te(),invert:oe(),gap:N(),gradientColorStops:[t],gradientColorStopPositions:[xNn,Hb],inset:k(),margin:k(),opacity:te(),padding:N(),saturate:te(),scale:te(),sepia:oe(),skew:te(),space:N(),translate:N()},classGroups:{aspect:[{aspect:["auto","square","video",Ss]}],container:["container"],columns:[{columns:[Gb]}],"break-after":[{"break-after":ce()}],"break-before":[{"break-before":ce()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...U(),Ss]}],overflow:[{overflow:w()}],"overflow-x":[{"overflow-x":w()}],"overflow-y":[{"overflow-y":w()}],overscroll:[{overscroll:M()}],"overscroll-x":[{"overscroll-x":M()}],"overscroll-y":[{"overscroll-y":M()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[_]}],"inset-x":[{"inset-x":[_]}],"inset-y":[{"inset-y":[_]}],start:[{start:[_]}],end:[{end:[_]}],top:[{top:[_]}],right:[{right:[_]}],bottom:[{bottom:[_]}],left:[{left:[_]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",eL,Ss]}],basis:[{basis:k()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Ss]}],grow:[{grow:oe()}],shrink:[{shrink:oe()}],order:[{order:["first","last","none",eL,Ss]}],"grid-cols":[{"grid-cols":[tL]}],"col-start-end":[{col:["auto",{span:["full",eL,Ss]},Ss]}],"col-start":[{"col-start":H()}],"col-end":[{"col-end":H()}],"grid-rows":[{"grid-rows":[tL]}],"row-start-end":[{row:["auto",{span:[eL,Ss]},Ss]}],"row-start":[{"row-start":H()}],"row-end":[{"row-end":H()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Ss]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Ss]}],gap:[{gap:[u]}],"gap-x":[{"gap-x":[u]}],"gap-y":[{"gap-y":[u]}],"justify-content":[{justify:["normal",...X()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...X(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...X(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[I]}],px:[{px:[I]}],py:[{py:[I]}],ps:[{ps:[I]}],pe:[{pe:[I]}],pt:[{pt:[I]}],pr:[{pr:[I]}],pb:[{pb:[I]}],pl:[{pl:[I]}],m:[{m:[p]}],mx:[{mx:[p]}],my:[{my:[p]}],ms:[{ms:[p]}],me:[{me:[p]}],mt:[{mt:[p]}],mr:[{mr:[p]}],mb:[{mb:[p]}],ml:[{ml:[p]}],"space-x":[{"space-x":[x]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[x]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Ss,e]}],"min-w":[{"min-w":[Ss,e,"min","max","fit"]}],"max-w":[{"max-w":[Ss,e,"none","full","min","max","fit","prose",{screen:[Gb]},Gb]}],h:[{h:[Ss,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Ss,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Ss,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Ss,e,"auto","min","max","fit"]}],"font-size":[{text:["base",Gb,Hb]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",$me]}],"font-family":[{font:[tL]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",Ss]}],"line-clamp":[{"line-clamp":["none",s9,$me]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",GS,Ss]}],"list-image":[{"list-image":["none",Ss]}],"list-style-type":[{list:["none","disc","decimal",Ss]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[m]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[m]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...J(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",GS,Hb]}],"underline-offset":[{"underline-offset":["auto",GS,Ss]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:N()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ss]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Ss]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[m]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...U(),bNn]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",SNn]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},MNn]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[h]}],"gradient-via-pos":[{via:[h]}],"gradient-to-pos":[{to:[h]}],"gradient-from":[{from:[d]}],"gradient-via":[{via:[d]}],"gradient-to":[{to:[d]}],rounded:[{rounded:[r]}],"rounded-s":[{"rounded-s":[r]}],"rounded-e":[{"rounded-e":[r]}],"rounded-t":[{"rounded-t":[r]}],"rounded-r":[{"rounded-r":[r]}],"rounded-b":[{"rounded-b":[r]}],"rounded-l":[{"rounded-l":[r]}],"rounded-ss":[{"rounded-ss":[r]}],"rounded-se":[{"rounded-se":[r]}],"rounded-ee":[{"rounded-ee":[r]}],"rounded-es":[{"rounded-es":[r]}],"rounded-tl":[{"rounded-tl":[r]}],"rounded-tr":[{"rounded-tr":[r]}],"rounded-br":[{"rounded-br":[r]}],"rounded-bl":[{"rounded-bl":[r]}],"border-w":[{border:[s]}],"border-w-x":[{"border-x":[s]}],"border-w-y":[{"border-y":[s]}],"border-w-s":[{"border-s":[s]}],"border-w-e":[{"border-e":[s]}],"border-w-t":[{"border-t":[s]}],"border-w-r":[{"border-r":[s]}],"border-w-b":[{"border-b":[s]}],"border-w-l":[{"border-l":[s]}],"border-opacity":[{"border-opacity":[m]}],"border-style":[{border:[...J(),"hidden"]}],"divide-x":[{"divide-x":[s]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[s]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[m]}],"divide-style":[{divide:J()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["",...J()]}],"outline-offset":[{"outline-offset":[GS,Ss]}],"outline-w":[{outline:[GS,Hb]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:G()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[m]}],"ring-offset-w":[{"ring-offset":[GS,Hb]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Gb,wNn]}],"shadow-color":[{shadow:[tL]}],opacity:[{opacity:[m]}],"mix-blend":[{"mix-blend":[...W(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":W()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[o]}],contrast:[{contrast:[a]}],"drop-shadow":[{"drop-shadow":["","none",Gb,Ss]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[l]}],invert:[{invert:[g]}],saturate:[{saturate:[C]}],sepia:[{sepia:[y]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[o]}],"backdrop-contrast":[{"backdrop-contrast":[a]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[l]}],"backdrop-invert":[{"backdrop-invert":[g]}],"backdrop-opacity":[{"backdrop-opacity":[m]}],"backdrop-saturate":[{"backdrop-saturate":[C]}],"backdrop-sepia":[{"backdrop-sepia":[y]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[A]}],"border-spacing-x":[{"border-spacing-x":[A]}],"border-spacing-y":[{"border-spacing-y":[A]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",Ss]}],duration:[{duration:te()}],ease:[{ease:["linear","in","out","in-out",Ss]}],delay:[{delay:te()}],animate:[{animate:["none","spin","ping","pulse","bounce",Ss]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[f]}],"scale-x":[{"scale-x":[f]}],"scale-y":[{"scale-y":[f]}],rotate:[{rotate:[eL,Ss]}],"translate-x":[{"translate-x":[S]}],"translate-y":[{"translate-y":[S]}],"skew-x":[{"skew-x":[B]}],"skew-y":[{"skew-y":[B]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Ss]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Ss]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":N()}],"scroll-mx":[{"scroll-mx":N()}],"scroll-my":[{"scroll-my":N()}],"scroll-ms":[{"scroll-ms":N()}],"scroll-me":[{"scroll-me":N()}],"scroll-mt":[{"scroll-mt":N()}],"scroll-mr":[{"scroll-mr":N()}],"scroll-mb":[{"scroll-mb":N()}],"scroll-ml":[{"scroll-ml":N()}],"scroll-p":[{"scroll-p":N()}],"scroll-px":[{"scroll-px":N()}],"scroll-py":[{"scroll-py":N()}],"scroll-ps":[{"scroll-ps":N()}],"scroll-pe":[{"scroll-pe":N()}],"scroll-pt":[{"scroll-pt":N()}],"scroll-pr":[{"scroll-pr":N()}],"scroll-pb":[{"scroll-pb":N()}],"scroll-pl":[{"scroll-pl":N()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Ss]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[GS,Hb,$me]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}});var wn=typeof window<"u"?window:void 0,H_=typeof globalThis<"u"?globalThis:wn;typeof self>"u"&&(H_.self=H_),typeof File>"u"&&(H_.File=function(){});var JC=H_?.navigator,Zo=H_?.document,rd=H_?.location,Zme=H_?.fetch,epe=H_!=null&&H_.XMLHttpRequest&&"withCredentials"in new H_.XMLHttpRequest?H_.XMLHttpRequest:void 0,zAt=H_?.AbortController,TNn=H_?.CompressionStream,y1=JC?.userAgent,_r=wn??{};function JAt(){return!(!wn||wn.navigator.onLine===!1)}var qAt="1.400.0",Au={DEBUG:!1,LIB_VERSION:qAt,LIB_NAME:"web",JS_SDK_VERSION:qAt};function WAt(t,e,n,o,i,r,A){try{var s=t[r](A),a=s.value}catch(c){return void n(c)}s.done?e(a):Promise.resolve(a).then(o,i)}function Ih(t){return function(){var e=this,n=arguments;return new Promise((function(o,i){var r=t.apply(e,n);function A(a){WAt(r,o,i,A,s,"next",a)}function s(a){WAt(r,o,i,A,s,"throw",a)}A(void 0)}))}}function fo(){return fo=Object.assign?Object.assign.bind():function(t){for(var e=1;arguments.length>e;e++){var n=arguments[e];for(var o in n)({}).hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},fo.apply(null,arguments)}function jAt(t,e){if(t==null)return{};var n={};for(var o in t)if({}.hasOwnProperty.call(t,o)){if(e.indexOf(o)!==-1)continue;n[o]=t[o]}return n}var XAt=t=>{if(typeof t!="string")return t;try{return JSON.parse(t)}catch{return t}};function $At(t){return typeof t=="string"||t}function ZAt(t){return typeof t=="string"?t:void 0}var nL,OS=(function(t){return t.AnonymousId="anonymous_id",t.DistinctId="distinct_id",t.Props="props",t.EnablePersonProcessing="enable_person_processing",t.PersonMode="person_mode",t.FeatureFlagDetails="feature_flag_details",t.FeatureFlags="feature_flags",t.FeatureFlagPayloads="feature_flag_payloads",t.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",t.BootstrapFeatureFlags="bootstrap_feature_flags",t.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",t.OverrideFeatureFlags="override_feature_flags",t.Queue="queue",t.AiQueue="ai_queue",t.LogsQueue="logs_queue",t.OptedOut="opted_out",t.SessionId="session_id",t.SessionStartTimestamp="session_start_timestamp",t.SessionLastTimestamp="session_timestamp",t.PersonProperties="person_properties",t.GroupProperties="group_properties",t.InstalledAppBuild="installed_app_build",t.InstalledAppVersion="installed_app_version",t.SessionReplay="session_replay",t.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",t.SurveyLastSeenDate="survey_last_seen_date",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t})({}),est=(function(t){return t.GZipJS="gzip-js",t.Base64="base64",t})({}),kNn=["$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"],FNn=["token"],tst="NativeGzipValidationError",tpe=t=>t.length>=2&&t[0]===31&&t[1]===139,nst=(t,e)=>t===est.GZipJS||e===est.GZipJS||e==="gzip",ost=t=>!(!t||typeof t!="object")&&("name"in t?String(t.name):"")==="NotReadableError",Rj=t=>{var e=new Error("Native gzip produced invalid output: "+t);throw e.name=tst,e},LNn=(function(){var t=Ih((function*(e,n){18>e.size&&Rj("too-short");var o=new Uint8Array(yield e.slice(0,10).arrayBuffer());tpe(o)&&o[2]===8||Rj("invalid-header");var i=new DataView(yield e.slice(e.size-8).arrayBuffer());i.getUint32(0,!0)!==(A=>{for(var s=(()=>{if(nL)return nL;nL=[];for(var l=0;256>l;l++){for(var g=l,u=0;8>u;u++)g=1&g?3988292384^g>>>1:g>>>1;nL[l]=g>>>0}return nL})(),a=4294967295,c=0;A.length>c;c++)a=s[255&(a^A[c])]^a>>>8;return(4294967295^a)>>>0})(n)&&Rj("invalid-crc");var r=n.length>>>0;i.getUint32(4,!0)!==r&&Rj("invalid-size")}));return function(e,n){return t.apply(this,arguments)}})();function npe(){return npe=Ih((function*(t,e,n){e===void 0&&(e=!0);try{var o=new TextEncoder().encode(t),i=new CompressionStream("gzip"),r=i.writable.getWriter(),A=r.write(o).then((()=>r.close())).catch((function(){var c=Ih((function*(l){try{yield r.abort(l)}catch{}throw l}));return function(l){return c.apply(this,arguments)}})()),s=new Response(i.readable).blob(),a=(yield Promise.all([s,A]))[0];return yield LNn(a,o),a}catch(c){if(n!=null&&n.rethrow)throw c;return e&&console.error("Failed to gzip compress data",c),null}})),npe.apply(this,arguments)}var HNn=["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"],ist=function(t,e){if(e===void 0&&(e=[]),!t)return!1;var n=t.toLowerCase();return HNn.concat(e).some((o=>{var i=o.toLowerCase();return n.indexOf(i)!==-1}))};function gA(t,e){return t.indexOf(e)!==-1}var Tj=function(t){return t.trim()},ope=function(t){return t.replace(/^\$/,"")};function rst(t){var e,n=[];return(e=JSON.stringify(t,(function(o,i){if(typeof i=="bigint")return i.toString();if(typeof i!="function"&&typeof i!="symbol"){if(i instanceof Error)return{name:i.name,message:i.message,stack:i.stack};if(i&&typeof i=="object"){for(;n.length>0&&n[n.length-1]!==this;)n.pop();if(n.includes(i))return"[Circular]";n.push(i)}return i}})))!==null&&e!==void 0?e:"null"}var Ast=Object.prototype,sst=Ast.hasOwnProperty,kj=Ast.toString,bs=Array.isArray||function(t){return kj.call(t)==="[object Array]"},pB=t=>typeof t=="function",P0=t=>t===Object(t)&&!bs(t),Ob=t=>{if(P0(t)){for(var e in t)if(sst.call(t,e))return!1;return!0}return!1},To=t=>t===void 0,Xl=t=>kj.call(t)=="[object String]",ipe=t=>Xl(t)&&t.trim().length===0,qC=t=>t===null,as=t=>To(t)||qC(t),Dp=t=>kj.call(t)=="[object Number]"&&t==t,KS=t=>Dp(t)&&t>0,Wx=t=>kj.call(t)==="[object Boolean]",GNn=t=>t instanceof FormData,ONn=t=>gA(kNn,t),KNn=t=>gA(FNn,t);function ast(t){return t===null||typeof t!="object"}function Fj(t,e){return{}.toString.call(t)==="[object "+e+"]"}function rpe(t){return typeof Event<"u"&&(function(e,n){try{return e instanceof n}catch{return!1}})(t,Event)}var UNn=[!0,"true",1,"1","yes"],Ape=t=>gA(UNn,t),YNn=[!1,"false",0,"0","no"];function jx(t,e,n,o,i){return e>n&&(o.warn("min cannot be greater than max."),e=n),Dp(t)?t>n?(o.warn(" cannot be greater than max: "+n+". Using max value instead."),n):e>t?(o.warn(" cannot be less than min: "+e+". Using min value instead."),e):t:(o.warn(" must be a number. using max or fallback. max: "+n+", fallback: "+i),jx(i||n,e,n,o))}class VNn{constructor(e){this.Pe={},this.Oe=e.Oe,this.Fe=jx(e.bucketSize,0,100,e.Ae),this.$e=jx(e.refillRate,0,this.Fe,e.Ae),this.Ne=jx(e.refillInterval,0,864e5,e.Ae)}De(e,n){var o=Math.floor((n-e.lastAccess)/this.Ne);o>0&&(e.tokens=Math.min(e.tokens+o*this.$e,this.Fe),e.lastAccess=e.lastAccess+o*this.Ne)}consumeRateLimit(e){var n,o=Date.now(),i=String(e),r=this.Pe[i];return r?this.De(r,o):this.Pe[i]=r={tokens:this.Fe,lastAccess:o},r.tokens===0||(r.tokens--,r.tokens===0&&((n=this.Oe)==null||n.call(this,e)),r.tokens===0)}stop(){this.Pe={}}}var Ty="Mobile",Lj="iOS",US="Android",c9="Tablet",cst=US+" "+c9,lst="iPad",gst="Apple",ust=gst+" Watch",oL="Safari",l9="BlackBerry",hst="Samsung",dst=hst+"Browser",_st=hst+" Internet",AP="Chrome",zNn=AP+" OS",mst=AP+" "+Lj,spe="Internet Explorer",pst=spe+" "+Ty,ape="Opera",JNn=ape+" Mini",cpe="Edge",Ist="Microsoft "+cpe,g9="Firefox",Cst=g9+" "+Lj,iL="Nintendo",rL="PlayStation",u9="Xbox",fst=US+" "+Ty,yst=Ty+" "+oL,AL="Windows",lpe=AL+" Phone",Est="Nokia",gpe="Ouya",Bst="Generic",qNn=Bst+" "+Ty.toLowerCase(),xst=Bst+" "+c9.toLowerCase(),upe="Konqueror",Qst="Oculus Browser",Hj="Vivaldi",Sst="Yandex",Gj="Whale",hpe="DuckDuckGo",bst="Pale Moon",Oj="Waterfox",sL="Brave",Dst="Google Search App",su="(\\d+(\\.\\d+)?)",dpe=new RegExp("Version/"+su),WNn=new RegExp(u9,"i"),jNn=new RegExp(rL+" \\w+","i"),XNn=new RegExp(iL+" \\w+","i"),_pe=new RegExp(l9+"|PlayBook|BB10","i"),$Nn={"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"},Mst=function(t,e,n,o){e=e||"";var i=(function(r){return r!=null&&r.brave?sL:null})(n);return i||(o!=null&&o.detectGoogleSearchApp&&gA(t,"GSA/")?Dst:gA(t," OPR/")&&gA(t,"Mini")?JNn:gA(t," OPR/")?ape:_pe.test(t)?l9:gA(t,"IE"+Ty)||gA(t,"WPDesktop")?pst:gA(t,"OculusBrowser")?Qst:gA(t,dst)?_st:gA(t,cpe)||gA(t,"Edg/")?Ist:gA(t,Hj+"/")?Hj:gA(t,"YaBrowser/")?Sst:gA(t,Gj+"/")?Gj:gA(t,hpe+"/")||gA(t,"Ddg/")?hpe:gA(t,"FBIOS")?"Facebook "+Ty:gA(t,"UCWEB")||gA(t,"UCBrowser")?"UC Browser":gA(t,"CriOS")?mst:gA(t,"CrMo")||gA(t,AP)?AP:gA(t,US)&&gA(t,oL)?fst:gA(t,"FxiOS")?Cst:gA(t.toLowerCase(),upe.toLowerCase())?upe:gA(t,sL+"/")?sL:((r,A)=>A&&gA(A,gst)||(function(s){return gA(s,oL)&&!gA(s,AP)&&!gA(s,US)})(r))(t,e)?gA(t,Ty)?yst:oL:gA(t,"PaleMoon/")?bst:gA(t,Oj+"/")?Oj:gA(t,g9)?g9:gA(t,"MSIE")||gA(t,"Trident/")?spe:gA(t,"Gecko")?g9:"")},ZNn={[pst]:[new RegExp("rv:"+su)],[Ist]:[new RegExp(cpe+"?\\/"+su)],[AP]:[new RegExp("("+AP+"|CrMo)\\/"+su)],[mst]:[new RegExp("CriOS\\/"+su)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+su)],[oL]:[dpe],[yst]:[dpe],[ape]:[new RegExp("(Opera|OPR)\\/"+su)],[g9]:[new RegExp(g9+"\\/"+su)],[Cst]:[new RegExp("FxiOS\\/"+su)],[upe]:[new RegExp("Konqueror[:/]?"+su,"i")],[l9]:[new RegExp(l9+" "+su),dpe],[fst]:[new RegExp("android\\s"+su,"i")],[_st]:[new RegExp(dst+"\\/"+su)],[Qst]:[new RegExp("OculusBrowser\\/"+su)],[Hj]:[new RegExp(Hj+"\\/"+su)],[Sst]:[new RegExp("YaBrowser\\/"+su)],[Gj]:[new RegExp(Gj+"\\/"+su)],[sL]:[new RegExp(sL+"\\/"+su)],[hpe]:[new RegExp("(DuckDuckGo|Ddg)\\/"+su)],[bst]:[new RegExp("PaleMoon\\/"+su)],[Oj]:[new RegExp(Oj+"\\/"+su)],[Dst]:[new RegExp("GSA\\/"+su)],[spe]:[new RegExp("(rv:|MSIE )"+su)],Mozilla:[new RegExp("rv:"+su)]},eRn=function(t,e,n,o){var i=Mst(t,e,n,o),r=ZNn[i];if(To(r))return null;for(var A=0;r.length>A;A++){var s=t.match(r[A]);if(s)return parseFloat(s[s.length-2])}return null},wst=[[new RegExp(u9+"; "+u9+" (.*?)[);]","i"),t=>[u9,t&&t[1]||""]],[new RegExp(iL,"i"),[iL,""]],[new RegExp(rL,"i"),[rL,""]],[_pe,[l9,""]],[new RegExp(AL,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[lpe,""];if(new RegExp(Ty).test(e)&&!/IEMobile\b/.test(e))return[AL+" "+Ty,""];var n=/Windows NT ([0-9.]+)/i.exec(e);if(n&&n[1]){var o=$Nn[n[1]]||"";return/arm/i.test(e)&&(o="RT"),[AL,o]}return[AL,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?[Lj,[t[3],t[4],t[5]||"0"].join(".")]:[Lj,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var e="";return t&&t.length>=3&&(e=To(t[2])?t[3]:t[2]),["watchOS",e]}],[new RegExp("("+US+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+US+")","i"),t=>t&&t[2]?[US,[t[2],t[3],t[4]||"0"].join(".")]:[US,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{var e=["Mac OS X",""];return t&&t[1]&&(e[1]=[t[1],t[2],t[3]||"0"].join(".")),e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[zNn,""]],[/Linux|debian/i,["Linux",""]]],Pst=function(t){return XNn.test(t)?iL:jNn.test(t)?rL:WNn.test(t)?u9:new RegExp(gpe,"i").test(t)?gpe:new RegExp("("+lpe+"|WPDesktop)","i").test(t)?lpe:/iPad/.test(t)?lst:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?ust:_pe.test(t)?l9:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(Est,"i").test(t)?Est:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?new RegExp(Ty).test(t)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)||/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?US:cst:new RegExp("(pda|"+Ty+")","i").test(t)?qNn:new RegExp(c9,"i").test(t)&&!new RegExp(c9+" pc","i").test(t)?xst:""},tRn=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function vst(t,e){return typeof(n=t)=="string"&&tRn.test(n)?t:e();var n}function Kb(t){return t&&t.split("#")[0]}function Kj(t,e){var n=setTimeout(t,e);return n?.unref&&n?.unref(),n}var nRn=t=>t instanceof Error,Nst={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}},oRn=Nst.info;function Rst(t){if(Wx(t))return{boolValue:t};if(typeof t=="number")return Number.isFinite(t)?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:{stringValue:String(t)};if(typeof t=="string")return{stringValue:t};if(bs(t))return{arrayValue:{values:t.map((e=>Rst(e)))}};try{return{stringValue:JSON.stringify(t)}}catch{return{stringValue:String(t)}}}function Uj(t){var e=[];for(var n in t){var o=t[n];qC(o)||To(o)||e.push({key:n,value:Rst(o)})}return e}function iRn(t,e){var n=Nst[t.level||"info"]||oRn,o=n.text,i=n.number,r=String(Date.now())+"000000",A={};e.distinctId&&(A.posthogDistinctId=e.distinctId),e.sessionId&&(A.sessionId=e.sessionId),e.windowId&&(A["window.id"]=e.windowId),as(e.sessionStartTimestamp)||(A.sessionStartTimestamp=String(e.sessionStartTimestamp)),as(e.lastActivityTimestamp)||(A.lastActivityTimestamp=String(e.lastActivityTimestamp)),e.currentUrl&&(A["url.full"]=e.currentUrl),e.screenName&&(A["screen.name"]=e.screenName),e.appState&&(A["app.state"]=e.appState),e.activeFeatureFlags&&e.activeFeatureFlags.length>0&&(A.feature_flags=e.activeFeatureFlags);var s=fo({},A,t.attributes||{}),a={timeUnixNano:r,observedTimeUnixNano:r,severityNumber:i,severityText:o,body:{stringValue:t.body},attributes:Uj(s)};return t.trace_id&&(a.traceId=t.trace_id),t.span_id&&(a.spanId=t.span_id),To(t.trace_flags)||(a.flags=t.trace_flags),a}function Tst(t,e,n){return fo({},t.resourceAttributes,{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":e,"telemetry.sdk.version":n})}function kst(t,e,n,o){return{resourceLogs:[{resource:{attributes:Uj(e)},scopeLogs:[{scope:{name:n,version:o},logRecords:t}]}]}}let rRn=class{constructor(e,n,o,i,r,A,s){var a;A===void 0&&(A=()=>Promise.resolve()),this._instance=e,this.Se=n,this.Ae=o,this.qe=i,this.je=r,this.Be=A,this.He=s,this.Ue=null,this.ze=0,this.We=0,this.Ve=0,this.Ze=0,this.Ge=!1,this.Qe=n.maxBufferSize,this.Je=Math.max((a=n.maxQueueSize)!==null&&a!==void 0?a:n.maxBufferSize,n.maxBufferSize),this.Ke=n.flushIntervalMs,this.Ye=n.maxBatchRecordsPerPost,this.Xe=n.rateCapWindowMs,this.et=n.maxLogsPerInterval}reset(){this.tt(),this.Ue=null,this.Ve=0,this.Ze=0,this.Ge=!1,this.ze=0,this.We=0,this.Ye=this.Se.maxBatchRecordsPerPost}onReconnect(){this.We=0,this.rt()}captureLog(e){if(!this._instance.isDisabled&&!this._instance.optedOut&&e!=null&&e.body){var n=this.it(e);if(n!==null)if(n.body){if(this.nt()){var o={record:iRn(n,this.qe())};this.je((()=>this.st(o)))}}else this.Ae.info("Log was rejected in beforeSend function")}}it(e){var n=this.Se.beforeSend;if(!n)return e;var o=bs(n)?n:[n],i=e;for(var r of o)try{var A=r(i);if(!A)return this.Ae.info("Log was rejected in beforeSend function"),null;i=A}catch(s){return this.Ae.error("Error in beforeSend function for log:",s),null}return i}nt(){if(this.et===void 0)return!0;var e=Date.now(),n=e-this.Ve;return this.Xe>n&&n>=0||(this.Ve=e,this.Ze=0,this.Ge=!1),this.et>this.Ze?(this.Ze++,!0):(this.Ge||(this.Ae.warn("captureLog dropping logs: exceeded "+this.et+" logs per "+this.Xe+"ms"),this.Ge=!0),!1)}flush(){var e=this;return Ih((function*(){if(!e._instance.isDisabled)return e.Ue||(e.Ue=e.ot().finally((()=>{e.Ue=null}))),e.Ue}))()}ot(){var e=this;return Ih((function*(){var n;e.tt();var o=(n=e._instance.getPersistedProperty(OS.LogsQueue))!==null&&n!==void 0?n:[];if(o.length!==0)for(var i=o.length,r=0;o.length>0&&i>r;){var A,s;e.ze=0;var a=Math.min(o.length,e.Ye),c=o.slice(0,a),l=kst(c.map((u=>u.record)),e.ut(),(A=e.He)!==null&&A!==void 0?A:e._instance.getLibraryId(),e._instance.getLibraryVersion()),g=yield e._instance.ht(l);if(g.kind==="too-large"&&c.length>1)e.Ye=Math.max(1,Math.floor(c.length/2)),e.Ae.warn("Received 413 when sending logs batch of size "+c.length+", reducing batch size to "+e.Ye);else if(g.kind==="retry-later"||(g.kind==="too-large"?e.Ae.warn("Dropping a single log record after 413 with batch size 1 — the record is larger than the server cap and cannot be split further."):g.kind==="ok"&&e.Se.maxBatchRecordsPerPost>e.Ye&&(e.Ye=Math.min(e.Se.maxBatchRecordsPerPost,e.Ye+1)),yield e.dt(c.length),o=(s=e._instance.getPersistedProperty(OS.LogsQueue))!==null&&s!==void 0?s:[],r+=c.length,g.kind==="fatal"))throw g.error}}))()}dt(e){var n=this;return Ih((function*(){var o,i=Math.max(0,e-n.ze),r=(o=n._instance.getPersistedProperty(OS.LogsQueue))!==null&&o!==void 0?o:[];n._instance.setPersistedProperty(OS.LogsQueue,r.slice(i)),yield n.Be()}))()}ut(){return Tst(this.Se,this._instance.getLibraryId(),this._instance.getLibraryVersion())}st(e){var n;if(!this._instance.optedOut){var o=(n=this._instance.getPersistedProperty(OS.LogsQueue))!==null&&n!==void 0?n:[];this.Je>o.length||(o.shift(),this.ze++,this.Ae.info("Logs queue is full, dropping oldest record.")),o.push(e),this._instance.setPersistedProperty(OS.LogsQueue,o),this.Qe>o.length?this.ct():this.rt()}}ct(e){e===void 0&&(e=this.Ke),this.vt||(this.vt=Kj((()=>{this.vt=void 0,this.rt()}),e))}ft(){var e=Math.min(Math.max(0,this.We-1),6);return this.Ke*Math.pow(2,e)}yt(){var e=this._instance.getPersistedProperty(OS.LogsQueue);return!!e&&e.length>0}shutdown(e){var n=this;return Ih((function*(){n.tt();var o=n.flush().catch((()=>{}));e!==void 0?yield Promise.race([o,new Promise((i=>Kj(i,e)))]):yield o}))()}flushWithTimeout(e){var n=this;return Ih((function*(){var o=!1,i=n.flush(),r=new Promise((A=>Kj((()=>{o=!0,A()}),e)));try{yield Promise.race([i,r])}finally{o&&i.catch((()=>{}))}}))()}rt(){this.flush().then((()=>{this.We=0}),(e=>{this.We++,this.Ae.error("PostHog logs flush failed:",e)})).finally((()=>{!this._instance.isDisabled&&this.yt()&&this.ct(this.ft())}))}tt(){this.vt&&(clearTimeout(this.vt),this.vt=void 0)}};var mpe=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function Fst(t){return String(t)+"000000"}function Lst(t,e,n,o){var i="";return o&&(i=Object.keys(o).sort().map((r=>JSON.stringify(r)+":"+JSON.stringify(o[r]))).join(",")),t+"\0"+e+"\0"+(n??"")+"\0"+i}let ARn=class{constructor(e,n,o){this._instance=e,this.Se=n,this.Ae=o,this.bt=new Map,this.Ue=null,this._t=!1,this.wt=new Map,this.xt=new Set}count(e,n,o){n===void 0&&(n=1),this.kt({name:e,type:"count",value:n,unit:o?.unit,attributes:o?.attributes})}gauge(e,n,o){this.kt({name:e,type:"gauge",value:n,unit:o?.unit,attributes:o?.attributes})}histogram(e,n,o){this.kt({name:e,type:"histogram",value:n,unit:o?.unit,attributes:o?.attributes})}flush(){var e=this,n=this.Ue,o=(function(){var r=Ih((function*(){n&&(yield n.catch((()=>{}))),yield e.St()}));return function(){return r.apply(this,arguments)}})(),i=o().finally((()=>{this.Ue===i&&(this.Ue=null)}));return this.Ue=i,i}drainWindow(){if(this.bt.size===0)return null;var e=this.bt;return this.bt=new Map,this._t=!1,this.wt=new Map,this.xt=new Set,this.Ct(e)}reset(){this.tt(),this.bt=new Map,this.Ue=null,this._t=!1,this.wt=new Map,this.xt=new Set}kt(e){if(!this._instance.isDisabled&&!this._instance.optedOut){var n=this.it(e);if(n!==null)if(n.name&&typeof n.name=="string")if(typeof n.value=="number"&&Number.isFinite(n.value))if(n.type==="count"&&0>n.value)this.Ae.warn("Dropping count '"+n.name+"': counters are monotonic, value must be >= 0");else{var o=this.wt.get(n.name);o===void 0?this.wt.set(n.name,n.type):o===n.type||this.xt.has(n.name)||(this.xt.add(n.name),this.Ae.warn("Metric name '"+n.name+"' is already used as a "+o+"; recording it as a "+n.type+" too will blend both series in charts. Use a distinct name."));var i=Lst(n.type,n.name,n.unit,n.attributes),r=this.bt.get(i);if(!r){if(this.bt.size>=this.Se.maxSeriesPerFlush)return void(this._t||(this._t=!0,this.Ae.warn("Metric series cap reached ("+this.Se.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")));r={name:n.name,type:n.type,unit:n.unit,attributes:n.attributes?fo({},n.attributes):void 0,windowStartMs:Date.now()},this.bt.set(i,r)}this.Tt(r,n.value),this.ct()}else this.Ae.warn("Dropping metric '"+n.name+"': value must be a finite number");else this.Ae.warn("Dropping metric with empty name")}}Tt(e,n){var o;switch(e.type){case"count":e.total=((o=e.total)!==null&&o!==void 0?o:0)+n;break;case"gauge":e.last=n;break;case"histogram":e.hist||(e.hist={count:0,sum:0,min:n,max:n,bucketCounts:new Array(mpe.length+1).fill(0)});var i=e.hist;i.count+=1,i.sum+=n,i.min=Math.min(i.min,n),i.max=Math.max(i.max,n),i.bucketCounts[(function(r,A){for(var s=0;A.length>s;s++)if(A[s]>=r)return s;return A.length})(n,mpe)]+=1}}it(e){var n=this.Se.beforeSend;if(!n)return e;var o=bs(n)?n:[n],i=e;for(var r of o)try{var A=r(i);if(!A)return this.Ae.info("Metric was rejected in beforeSend function"),null;i=A}catch(s){return this.Ae.error("Error in beforeSend function for metric:",s),null}return i}ct(){this.vt||(this.vt=Kj((()=>{this.vt=void 0,this.flush().catch((()=>{}))}),this.Se.flushIntervalMs))}tt(){this.vt&&(clearTimeout(this.vt),this.vt=void 0)}St(){var e=this;return Ih((function*(){if(e.bt.size!==0){var n=e.bt;e.bt=new Map,e._t=!1,e.wt=new Map,e.xt=new Set;var o=yield e._instance.It(e.Ct(n));switch(o.kind){case"ok":return;case"retry-later":return e.Mt(n),void e.ct();case"too-large":return void e.Ae.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void e.Ae.error("Failed to send metrics batch:",o.error)}}}))()}Ct(e){return(function(r,A,s,a){return{resourceMetrics:[{resource:{attributes:Uj(A)},scopeMetrics:[{scope:{name:s,version:a},metrics:r}]}]}})(this.Et(e),(n=this.Se,o=this._instance.getLibraryId(),i=this._instance.getLibraryVersion(),fo({},n.resourceAttributes,{"service.name":n.serviceName||"unknown_service"},n.environment&&{"deployment.environment":n.environment},n.serviceVersion&&{"service.version":n.serviceVersion},{"telemetry.sdk.name":o,"telemetry.sdk.version":i})),this._instance.getLibraryId(),this._instance.getLibraryVersion());var n,o,i}Et(e){var n=Fst(Date.now()),o=new Map;for(var i of e.values()){var r,A=Lst(i.type,i.name,i.unit,void 0),s=o.get(A);s||(s=fo({name:i.name},i.unit&&{unit:i.unit}),i.type==="count"?s.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:i.type==="gauge"?s.gauge={dataPoints:[]}:s.histogram={aggregationTemporality:1,dataPoints:[]},o.set(A,s));var a=Uj((r=i.attributes)!==null&&r!==void 0?r:{}),c=Fst(i.windowStartMs);if(i.type==="count"){var l,g={attributes:a,startTimeUnixNano:c,timeUnixNano:n,asDouble:(l=i.total)!==null&&l!==void 0?l:0};s.sum.dataPoints.push(g)}else if(i.type==="gauge"){var u,d={attributes:a,timeUnixNano:n,asDouble:(u=i.last)!==null&&u!==void 0?u:0};s.gauge.dataPoints.push(d)}else i.hist&&s.histogram.dataPoints.push({attributes:a,startTimeUnixNano:c,timeUnixNano:n,count:i.hist.count,sum:i.hist.sum,min:i.hist.min,max:i.hist.max,bucketCounts:i.hist.bucketCounts,explicitBounds:mpe})}return Array.from(o.values())}Mt(e){var n,o;for(var i of e){var r=i[0],A=i[1],s=this.bt.get(r);if(s)switch(s.windowStartMs=Math.min(s.windowStartMs,A.windowStartMs),s.type){case"count":s.total=((n=s.total)!==null&&n!==void 0?n:0)+((o=A.total)!==null&&o!==void 0?o:0);break;case"gauge":break;case"histogram":if(A.hist)if(s.hist){s.hist.count+=A.hist.count,s.hist.sum+=A.hist.sum,s.hist.min=Math.min(s.hist.min,A.hist.min),s.hist.max=Math.max(s.hist.max,A.hist.max);for(var a=0;s.hist.bucketCounts.length>a;a++)s.hist.bucketCounts[a]+=A.hist.bucketCounts[a]}else s.hist=A.hist}else this.bt.set(r,A)}}};var Yj,Hst,ppe;function sRn(t){var e=globalThis._posthogChunkIds;if(e){var n=Object.keys(e);return ppe&&n.length===Hst||(Hst=n.length,ppe=n.reduce(((o,i)=>{Yj||(Yj={});var r=Yj[i];if(r)o[r[0]]=r[1];else for(var A=t(i),s=A.length-1;s>=0;s--){var a=A[s],c=a?.filename,l=e[i];if(c&&l){o[c]=l,Yj[i]=[c,l];break}}return o}),{})),ppe}}class aRn{constructor(e,n,o){o===void 0&&(o=[]),this.coercers=e,this.stackParser=n,this.modifiers=o}buildFromUnknown(e,n){n===void 0&&(n={});var o=n&&n.mechanism||{handled:!0,type:"generic"},i=this.buildCoercingContext(o,n,0).apply(e),r=this.buildParsingContext(n),A=this.parseStacktrace(i,r);return{$exception_list:this.convertToExceptionList(A,o),$exception_level:"error"}}modifyFrames(e){var n=this;return Ih((function*(){for(var o of e)o.stacktrace&&o.stacktrace.frames&&bs(o.stacktrace.frames)&&(o.stacktrace.frames=yield n.applyModifiers(o.stacktrace.frames));return e}))()}coerceFallback(e){var n;return{type:"Error",value:"Unknown error",stack:(n=e.syntheticException)==null?void 0:n.stack,synthetic:!0}}parseStacktrace(e,n){var o,i;return e.cause!=null&&(o=this.parseStacktrace(e.cause,n)),e.stack!=""&&e.stack!=null&&(i=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?n.skipFirstLines:0),n.chunkIdMap)),fo({},e,{cause:o,stack:i})}applyChunkIds(e,n){return e.map((o=>(o.filename&&n&&(o.chunk_id=n[o.filename]),o)))}applyCoercers(e,n){for(var o of this.coercers)if(o.match(e))return o.coerce(e,n);return this.coerceFallback(n)}applyModifiers(e){var n=this;return Ih((function*(){var o=e;for(var i of n.modifiers)o=yield i(o);return o}))()}convertToExceptionList(e,n){var o,i,r,A={type:e.type,value:e.value,mechanism:{type:(o=n.type)!==null&&o!==void 0?o:"generic",handled:(i=n.handled)===null||i===void 0||i,synthetic:(r=e.synthetic)!==null&&r!==void 0&&r}};e.stack&&(A.stacktrace={type:"raw",frames:e.stack});var s=[A];return e.cause!=null&&s.push(...this.convertToExceptionList(e.cause,fo({},n,{handled:!0}))),s}buildParsingContext(e){var n;return{chunkIdMap:sRn(this.stackParser),skipFirstLines:(n=e.skipFirstLines)!==null&&n!==void 0?n:1}}buildCoercingContext(e,n,o){o===void 0&&(o=0);var i=(r,A)=>{if(4>=A){var s=this.buildCoercingContext(e,n,A);return this.applyCoercers(r,s)}};return fo({},n,{syntheticException:o==0?n.syntheticException:void 0,mechanism:e,apply:r=>i(r,o),next:r=>i(r,o+1)})}}var h9="?";function Ipe(t,e,n,o,i){var r={platform:t,filename:e,function:n==="<anonymous>"?h9:n,in_app:!0};return To(o)||(r.lineno=o),To(i)||(r.colno=i),r}var Gst=(t,e)=>{var n=t.indexOf("safari-extension")!==-1,o=t.indexOf("safari-web-extension")!==-1;return n||o?[t.indexOf("@")!==-1?t.split("@")[0]:h9,n?"safari-extension:"+e:"safari-web-extension:"+e]:[t,e]},cRn=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,lRn=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,gRn=/\((\S*)(?::(\d+))(?::(\d+))\)/,uRn=(t,e)=>{var n=cRn.exec(t);if(n)return Ipe(e,n[1],h9,+n[2],+n[3]);var o=lRn.exec(t);if(o){if(o[2]&&o[2].indexOf("eval")===0){var i=gRn.exec(o[2]);i&&(o[2]=i[1],o[3]=i[2],o[4]=i[3])}var r=Gst(o[1]||h9,o[2]);return Ipe(e,r[1],r[0],o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},hRn=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,dRn=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,_Rn=(t,e)=>{var n=hRn.exec(t);if(n){if(n[3]&&n[3].indexOf(" > eval")>-1){var o=dRn.exec(n[3]);o&&(n[1]=n[1]||"eval",n[3]=o[1],n[4]=o[2],n[5]="")}var i=n[3],r=n[1]||h9,A=Gst(r,i);return Ipe(e,i=A[1],r=A[0],n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},Ost=/\(error: (.*)\)/;class mRn{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,n){var o=Xl(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:o?e.stack:void 0,cause:e.cause?n.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var n=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?n+": "+e.message:n}isDOMException(e){return Fj(e,"DOMException")}isDOMError(e){return Fj(e,"DOMError")}}class pRn{match(e){return(n=>n instanceof Error)(e)}coerce(e,n){return{type:this.getType(e),value:this.getMessage(e,n),stack:this.getStack(e),cause:e.cause?n.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,n){var o=e.message;return String(o.error&&typeof o.error.message=="string"?o.error.message:o)}getStack(e){return e.stacktrace||e.stack||void 0}}class IRn{constructor(){}match(e){return Fj(e,"ErrorEvent")&&e.error!=null}coerce(e,n){var o;return n.apply(e.error)||{type:"ErrorEvent",value:e.message,stack:(o=n.syntheticException)==null?void 0:o.stack,synthetic:!0}}}var CRn=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class fRn{match(e){return typeof e=="string"}coerce(e,n){var o,i=this.getInfos(e),r=i[0],A=i[1];return{type:r??"Error",value:A??e,stack:(o=n.syntheticException)==null?void 0:o.stack,synthetic:!0}}getInfos(e){var n="Error",o=e,i=e.match(CRn);return i&&(n=i[1],o=i[2]),[n,o]}}var yRn=["fatal","error","warning","log","info","debug"];function Kst(t,e){e===void 0&&(e=40);var n=Object.keys(t);if(n.sort(),!n.length)return"[object has no keys]";for(var o=n.length;o>0;o--){var i=n.slice(0,o).join(", ");if(e>=i.length)return o===n.length?i:i.length>e?i.slice(0,e)+"...":i}return""}class ERn{match(e){return typeof e=="object"&&e!==null}coerce(e,n){var o,i=this.getErrorPropertyFromObject(e);return i?n.apply(i):{type:this.getType(e),value:this.getValue(e),stack:(o=n.syntheticException)==null?void 0:o.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return rpe(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){var n="'"+e.name+"' captured as exception";return"message"in e&&typeof e.message=="string"&&(n+=" with message: '"+e.message+"'"),n}if("message"in e&&typeof e.message=="string")return e.message;var o=this.getObjectClassName(e);return(o&&o!=="Object"?"'"+o+"'":"Object")+" captured as exception with keys: "+Kst(e)}isSeverityLevel(e){return Xl(e)&&!ipe(e)&&yRn.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var n in e)if({}.hasOwnProperty.call(e,n)){var o=e[n];if(nRn(o))return o}}getObjectClassName(e){try{var n=Object.getPrototypeOf(e);return n?n.constructor.name:void 0}catch{return}}}class BRn{match(e){return rpe(e)}coerce(e,n){var o,i=e.constructor.name;return{type:i,value:i+" captured as exception with keys: "+Kst(e),stack:(o=n.syntheticException)==null?void 0:o.stack,synthetic:!0}}}class xRn{match(e){return ast(e)}coerce(e,n){var o;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:(o=n.syntheticException)==null?void 0:o.stack,synthetic:!0}}}class QRn{match(e){return Fj(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!rpe(e))return!1;try{var n=e.detail;return n!=null&&typeof n=="object"&&"reason"in n}catch{return!1}}coerce(e,n){var o,i=this.getUnhandledRejectionReason(e);return ast(i)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(i),stack:(o=n.syntheticException)==null?void 0:o.stack,synthetic:!0}:n.apply(i)}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}}var Vj="$message",zj="$timestamp",SRn=new Set([Vj,zj]),Cpe={enabled:!0,max_bytes:32768};function Jj(t){var e;return t?{enabled:(e=t.enabled)!==null&&e!==void 0?e:Cpe.enabled,max_bytes:DRn(t.max_bytes,Cpe.max_bytes)}:fo({},Cpe)}class bRn{constructor(e){this.Rt=[],this.Pt=0,this.Se=Jj(e)}setConfig(e){this.Se=Jj(e),this.Ot()}add(e){var n=(function(i){var r;try{r=rst(i)}catch{return}try{var A=JSON.parse(r);if(!P0(A))return;var s=A,a=s[Vj],c=s[zj];return!Xl(a)||a.trim().length===0||!Xl(c)&&!Dp(c)?void 0:{step:s,json:r}}catch{return}})(e);if(n){var o=(function(i){if(typeof TextEncoder<"u")return new TextEncoder().encode(i).length;for(var r=encodeURIComponent(i),A=0,s=0;r.length>s;s++)r[s]==="%"?(A+=1,s+=2):A+=1;return A})(n.json);o>this.Se.max_bytes||(this.Rt.push({step:n.step,bytes:o}),this.Pt+=o,this.Ot())}}getAttachable(){return this.Rt.map((e=>e.step))}clear(){this.Rt=[],this.Pt=0}size(){return this.Rt.length}Ot(){for(;this.Pt>this.Se.max_bytes&&this.Rt.length>0;){var e=this.Rt.shift();e&&(this.Pt-=e.bytes)}}}function DRn(t,e){if(!Dp(t)||t===1/0||t===-1/0)return e;var n=Math.floor(t);return 0>n?e:n}var Ust=function(t,e){var n=(e===void 0?{}:e).debugEnabled,o={k(i){if(wn&&(Au.DEBUG||_r.POSTHOG_DEBUG||n)&&!To(wn.console)&&wn.console){for(var r=("__rrweb_original__"in wn.console[i])?wn.console[i].__rrweb_original__:wn.console[i],A=arguments.length,s=new Array(A>1?A-1:0),a=1;A>a;a++)s[a-1]=arguments[a];r(t,...s)}},debug(){for(var i=arguments.length,r=new Array(i),A=0;i>A;A++)r[A]=arguments[A];o.k("debug",...r)},info(){for(var i=arguments.length,r=new Array(i),A=0;i>A;A++)r[A]=arguments[A];o.k("log",...r)},warn(){for(var i=arguments.length,r=new Array(i),A=0;i>A;A++)r[A]=arguments[A];o.k("warn",...r)},error(){for(var i=arguments.length,r=new Array(i),A=0;i>A;A++)r[A]=arguments[A];o.k("error",...r)},critical(){for(var i=arguments.length,r=new Array(i),A=0;i>A;A++)r[A]=arguments[A];console.error(t,...r)},uninitializedWarning(i){o.error("You must initialize PostHog before calling "+i)},createLogger:(i,r)=>Ust(t+" "+i,r)};return o},wo=Ust("[PostHog.js]"),v0=wo.createLogger,MRn=v0("[ExternalScriptsLoader]"),fpe=(t,e,n)=>{if(t.config.disable_external_dependency_loading)return MRn.warn(e+" was requested but loading of external scripts is disabled."),n("Loading of external scripts is disabled");var o=Zo?.querySelectorAll("script");if(o){for(var i,r=function(){if(o[A].src===e){var a=o[A];return a.__posthog_loading_callback_fired?{v:n()}:(a.addEventListener("load",(c=>{a.__posthog_loading_callback_fired=!0,n(void 0,c)})),a.onerror=c=>n(c),{v:void 0})}},A=0;o.length>A;A++)if(i=r())return i.v}var s=()=>{if(!Zo)return n("document not found");var a=Zo.createElement("script");if(a.type="text/javascript",a.crossOrigin="anonymous",a.src=e,a.onload=g=>{a.__posthog_loading_callback_fired=!0,n(void 0,g)},a.onerror=g=>n(g),t.config.prepare_external_dependency_script&&(a=t.config.prepare_external_dependency_script(a)),!a)return n("prepare_external_dependency_script returned null");if(t.config.external_scripts_inject_target==="head")Zo.head.appendChild(a);else{var c,l=Zo.querySelectorAll("body > script");l.length>0?(c=l[0].parentNode)==null||c.insertBefore(a,l[0]):Zo.body.appendChild(a)}};Zo!=null&&Zo.body?s():Zo?.addEventListener("DOMContentLoaded",s)};_r.__PosthogExtensions__=_r.__PosthogExtensions__||{},_r.__PosthogExtensions__.loadExternalDependency=(t,e,n)=>{if(e!=="remote-config"){var o;if(t.config.strict_script_versioning)o=t.requestRouter.endpointFor("assets","/static/"+t.version+"/"+e+".js");else{var i="/static/"+e+".js?v="+t.version;if(e==="toolbar"){var r=3e5;i=i+"&t="+Math.floor(Date.now()/r)*r}o=t.requestRouter.endpointFor("assets",i)}fpe(t,o,n)}else{var A=t.requestRouter.endpointFor("assets","/array/"+t.config.token+"/config.js");fpe(t,A,n)}},_r.__PosthogExtensions__.loadSiteApp=(t,e,n)=>{var o=t.requestRouter.endpointFor("api",e);fpe(t,o,n)};var Yst="$people_distinct_id",qj="$device_id",ype="$device_model",aL="__alias",cL="__timers",Epe="$autocapture_disabled_server_side",Bpe="$heatmaps_enabled_server_side",xpe="$exception_capture_enabled_server_side",Qpe="$error_tracking_suppression_rules",Spe="$error_tracking_capture_extension_exceptions",bpe="$web_vitals_enabled_server_side",Dpe="$dead_clicks_enabled_server_side",Mpe="$product_tours_enabled_server_side",wpe="$web_vitals_allowed_metrics",sP="$session_recording_remote_config",Vst="$replay_sample_rate",zst="$replay_override_sampling",Jst="$replay_override_linked_flag",qst="$replay_override_url_trigger",Wst="$replay_override_event_trigger",d9="$sesid",Ppe="$session_is_sampled",aP="$enabled_feature_flags",Wj="$active_feature_flags",lL="$early_access_features",vpe="$feature_flag_details",jj="$feature_flag_payloads",Npe="$feature_flag_request_id",YS="$override_feature_flags",_9="$override_feature_flag_payloads",cP="$stored_person_properties",lP="$stored_group_properties",Rpe="$surveys",Xj="$surveys_loaded_at",Tpe="$surveys_activated",gL="ph_product_tours",uL="$flag_call_reported",kpe="$flag_call_reported_session_id",Fpe="$feature_flag_errors",hL="$feature_flag_evaluated_at",IB="$user_state",Lpe="$client_session_props",Hpe="$capture_rate_limit",Gpe="$initial_campaign_params",Ope="$initial_referrer_info",$j="$initial_person_info",Zj="$epp",jst="__POSTHOG_TOOLBAR__",eX="$posthog_cookieless",Xst="$sdk_debug_extensions_init_method",$st="$sdk_debug_extensions_init_time_ms",Zst="$sdk_debug_recording_script_not_loaded",Kpe="PostHog loadExternalDependency extension not found.",gP="on_reject",VS="always",m9="anonymous",p9="identified",Upe="identified_only",tX="visibilitychange",nX="beforeunload",I9="$pageview",Ype="$pageleave",Vpe="$identify",eat="$groupidentify";function oX(t,e){bs(t)&&t.forEach(e)}function pg(t,e){if(!as(t))if(bs(t))t.forEach(e);else if(GNn(t))t.forEach(((o,i)=>e(o,i)));else for(var n in t)sst.call(t,n)&&e(t[n],n)}var jg=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),o=1;e>o;o++)n[o-1]=arguments[o];for(var i of n)for(var r in i)i[r]!==void 0&&(t[r]=i[r]);return t};function iX(t){for(var e=Object.keys(t),n=e.length,o=new Array(n);n--;)o[n]=[e[n],t[e[n]]];return o}var tat=function(t){try{return t()}catch{return}},wRn=function(t){return function(){try{for(var e=arguments.length,n=new Array(e),o=0;e>o;o++)n[o]=arguments[o];return t.apply(this,n)}catch(i){wo.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),wo.critical(i)}}},zpe=function(t){var e={};return pg(t,(function(n,o){(Xl(n)&&n.length>0||Dp(n))&&(e[o]=n)})),e},PRn=["herokuapp.com","vercel.app","netlify.app"];function vRn(t){var e=t?.hostname;if(!Xl(e))return!1;var n=e.split(".").slice(-2).join(".");for(var o of PRn)if(n===o)return!1;return!0}function au(t,e,n,o){var i=o??{},r=i.capture,A=i.passive;t?.addEventListener(e,n,{capture:r!==void 0&&r,passive:A===void 0||A})}function nat(t){return t.name==="ph_toolbar_internal"}Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return Dp(t)&&isFinite(t)&&Math.floor(t)===t});class rX{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,n,o,i){if(!Number.isInteger(e)||!Number.isInteger(n)||!Number.isInteger(o)||!Number.isInteger(i)||0>e||0>n||0>o||0>i||e>0xffffffffffff||n>4095||o>1073741823||i>4294967295)throw new RangeError("invalid field value");var r=new Uint8Array(16);return r[0]=e/Math.pow(2,40),r[1]=e/Math.pow(2,32),r[2]=e/Math.pow(2,24),r[3]=e/Math.pow(2,16),r[4]=e/Math.pow(2,8),r[5]=e,r[6]=112|n>>>8,r[7]=n,r[8]=128|o>>>24,r[9]=o>>>16,r[10]=o>>>8,r[11]=o,r[12]=i>>>24,r[13]=i>>>16,r[14]=i>>>8,r[15]=i,new rX(r)}toString(){for(var e="",n=0;this.bytes.length>n;n++)e=e+(this.bytes[n]>>>4).toString(16)+(15&this.bytes[n]).toString(16),n!==3&&n!==5&&n!==7&&n!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new rX(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var n=0;16>n;n++){var o=this.bytes[n]-e.bytes[n];if(o!==0)return Math.sign(o)}return 0}}class NRn{constructor(){this.S=0,this.C=0,this.I=new RRn}generate(){var e=this.generateOrAbort();if(To(e)){this.S=0;var n=this.generateOrAbort();if(To(n))throw new Error("Could not generate UUID after timestamp reset");return n}return e}generateOrAbort(){var e=Date.now();if(e>this.S)this.S=e,this.M();else{if(this.S>=e+1e4)return;this.C++,this.C>4398046511103&&(this.S++,this.M())}return rX.fromFieldsV7(this.S,Math.trunc(this.C/Math.pow(2,30)),this.C&Math.pow(2,30)-1,this.I.nextUint32())}M(){this.C=1024*this.I.nextUint32()+(1023&this.I.nextUint32())}}var oat,iat=t=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;t.length>e;e++)t[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};wn&&!To(wn.crypto)&&crypto.getRandomValues&&(iat=t=>crypto.getRandomValues(t));class RRn{constructor(){this.R=new Uint32Array(8),this.O=1/0}nextUint32(){return this.R.length>this.O||(iat(this.R),this.O=0),this.R[this.O++]}}var zS=()=>TRn().toString(),TRn=()=>(oat||(oat=new NRn)).generate(),dL="",kRn=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,Xx={N:()=>!!Zo,D(t){wo.error("cookieStore error: "+t)},A(t){if(Zo){try{for(var e=t+"=",n=Zo.cookie.split(";").filter((r=>r.length)),o=0;n.length>o;o++){for(var i=n[o];i.charAt(0)==" ";)i=i.substring(1,i.length);if(i.indexOf(e)===0)return decodeURIComponent(i.substring(e.length,i.length))}}catch{}return null}},F(t){var e;try{e=JSON.parse(Xx.A(t))||{}}catch{}return e},q(t,e,n,o,i){if(!Zo)return!1;try{var r="",A="",s=(function(l,g){if(g){var u=(function(h,_){if(_===void 0&&(_=Zo),dL)return dL;if(!_||["localhost","127.0.0.1"].includes(h))return"";for(var p=h.split("."),m=Math.min(p.length,8),I="dmn_chk_"+zS();!dL&&m--;){var C=p.slice(m).join("."),f=I+"=1;domain=."+C+";path=/";_.cookie=f+";max-age=3",_.cookie.includes(I)&&(_.cookie=f+";max-age=0",dL=C)}return dL})(l);if(!u){var d=(h=>{var _=h.match(kRn);return _?_[0]:""})(l);d!==u&&wo.info("Warning: cookie subdomain discovery mismatch",d,u),u=d}return u?"; domain=."+u:""}return""})(Zo.location.hostname,o);if(n){var a=new Date;a.setTime(a.getTime()+864e5*n),r="; expires="+a.toUTCString()}i&&(A="; secure");var c=t+"="+encodeURIComponent(JSON.stringify(e))+r+"; SameSite=Lax; path=/"+s+A;return c.length>3686.4&&wo.warn("cookieStore warning: large cookie, len="+c.length),Zo.cookie=c,!0}catch{return!1}},P(t,e){if(Zo!=null&&Zo.cookie)try{Xx.q(t,"",-1,e)}catch{return}}},Jpe=null,Ig={N(){if(!qC(Jpe))return Jpe;var t=!0;if(To(wn))t=!1;else try{var e="__mplssupport__";Ig.q(e,"xyz"),Ig.A(e)!=='"xyz"'&&(t=!1),Ig.P(e)}catch{t=!1}return t||wo.error("localStorage unsupported; falling back to cookie store"),Jpe=t,t},D(t){wo.error("localStorage error: "+t)},A(t){try{return wn?.localStorage.getItem(t)}catch(e){Ig.D(e)}return null},F(t){try{return JSON.parse(Ig.A(t))||{}}catch{}return null},q(t,e){try{return wn?.localStorage.setItem(t,JSON.stringify(e)),!0}catch(n){Ig.D(n)}return!1},P(t){try{wn?.localStorage.removeItem(t)}catch(e){Ig.D(e)}}},FRn=[qj,"distinct_id",d9,Ppe,Zj,$j,IB],AX={},LRn={N:()=>!0,D(t){wo.error("memoryStorage error: "+t)},A:t=>AX[t]||null,F:t=>AX[t]||null,q:(t,e)=>(AX[t]=e,!0),P(t){delete AX[t]}},uP=null,Mp={N(){if(!qC(uP))return uP;if(uP=!0,To(wn))uP=!1;else try{var t="__support__";Mp.q(t,"xyz"),Mp.A(t)!=='"xyz"'&&(uP=!1),Mp.P(t)}catch{uP=!1}return uP},D(t){wo.error("sessionStorage error: ",t)},A(t){try{return wn?.sessionStorage.getItem(t)}catch(e){Mp.D(e)}return null},F(t){try{return JSON.parse(Mp.A(t))||null}catch{}return null},q(t,e){try{return wn?.sessionStorage.setItem(t,JSON.stringify(e)),!0}catch(n){Mp.D(n)}return!1},P(t){try{wn?.sessionStorage.removeItem(t)}catch(e){Mp.D(e)}}};class HRn{constructor(e){this._instance=e}get Se(){return this._instance.config}get consent(){return this.At()?0:this.$t}isOptedOut(){return this.Se.cookieless_mode===VS||this.isRejected()||this.consent===-1&&this.Se.cookieless_mode===gP}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Se.opt_out_capturing_by_default}optInOut(e){this.Nt.q(this.Dt,e?1:0,this.Se.cookie_expiration,this.Se.cross_subdomain_cookie,this.Se.secure_cookie)}reset(){this.Nt.P(this.Dt,this.Se.cross_subdomain_cookie)}get Dt(){var e=this._instance.config,n=e.token,o=e.opt_out_capturing_cookie_prefix;return e.consent_persistence_name||(o?o+n:"__ph_opt_in_out_"+n)}get $t(){var e=this.Nt.A(this.Dt);return Ape(e)?1:gA(YNn,e)?0:-1}get Nt(){var e=this.Se.opt_out_capturing_persistence_type,n=e==="localStorage"?Ig:Xx;if(!this.qt||this.qt!==n){this.qt=n;var o=e==="localStorage"?Xx:Ig;o.A(this.Dt)&&(this.qt.A(this.Dt)||this.optInOut(Ape(o.A(this.Dt))),o.P(this.Dt,this.Se.cross_subdomain_cookie))}return this.qt}At(){return!!this.Se.respect_dnt&&[JC?.doNotTrack,JC?.msDoNotTrack,_r.doNotTrack].some((e=>Ape(e)))}}function rat(t,e){var n,o=t==null||(n=t.config)==null?void 0:n.get_current_url;if(!pB(o))return e;try{var i=o(e);return Xl(i)&&i?i:e}catch(r){return wo.error("Error in get_current_url, falling back to window.location.href",r),e}}var GRn=1,ORn=3,KRn=11;function Aat(t){return t instanceof Element&&(t.id===jst||!(t.closest==null||!t.closest(".toolbar-global-fade-container")))}function Ub(t){return!!t&&t.nodeType===GRn}function ky(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function sat(t){return!!t&&t.nodeType===ORn}function aat(t){return!!t&&t.nodeType===KRn&&Ub(t.host)}var cat=1e3;function qpe(t){return t?Tj(t).split(/\s+/):[]}function lat(t,e){var n=(function(o){var i,r=wn==null||(i=wn.location)==null?void 0:i.href;return To(r)?void 0:rat(o,r)})(e);return!!(n&&t&&t.some((o=>n.match(o))))}function sX(t){var e="";switch(typeof t.className){case"string":e=t.className;break;case"object":e=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:e=""}return qpe(e)}function gat(t){return as(t)?null:Tj(t).split(/(\s+)/).filter((e=>mL(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function _L(t){var e="";return Zpe(t)&&!Iat(t)&&t.childNodes&&t.childNodes.length&&pg(t.childNodes,(function(n){var o;sat(n)&&n.textContent&&(e+=(o=gat(n.textContent))!==null&&o!==void 0?o:"")})),Tj(e)}function Wpe(t){return To(t.target)?t.srcElement||null:(e=t.target)!=null&&e.shadowRoot?t.composedPath()[0]||null:t.target||null;var e}var jpe=["a","button","form","input","select","textarea","label"];function Xpe(t,e){if(To(e))return!0;var n,o=function(r){if(e.some((A=>(function(s,a){var c=s.matches||s.matchesSelector||s.msMatchesSelector||s.mozMatchesSelector||s.webkitMatchesSelector||s.oMatchesSelector;try{return!!c&&c.call(s,a)}catch{return!1}})(r,A))))return{v:!0}};for(var i of t)if(n=o(i))return n.v;return!1}function uat(t){var e=t.parentNode;return!(!e||!Ub(e))&&e}var URn=[".ph-no-autocapture","[data-ph-no-autocapture]"],hat=["next","previous","prev",">","<"],YRn=[...hat,"+","-","−","–"],dat=(t,e)=>/[a-z0-9]/i.test(e)?t.includes(e):t===e,_at=[".ph-no-rageclick",".ph-no-capture"],VRn=["","text","search","email","password","url","tel","number"];function mat(t,e){if(!wn||$pe(t))return!1;var n,o,i,r,A;if(Wx(e)?(n=!!e&&_at,o=void 0,i=!1):(n=(r=e?.css_selector_ignorelist)!==null&&r!==void 0?r:_at,o=e?.content_ignorelist,i=(A=e?.ignore_text_selection)!==null&&A!==void 0&&A),n===!1||i&&(function(a){return!(!a||!Ub(a))&&(!!ky(a,"textarea")||(ky(a,"input")?gA(VRn,(a.getAttribute("type")||"").toLowerCase()):(function(c){if(c.isContentEditable)return!0;var l=c.getAttribute==null?void 0:c.getAttribute("contenteditable");return l==="true"||l===""})(a)))})(t))return!1;var s=pat(t,!1).targetElementList;return!(function(a,c){if(a===!1||To(a))return!1;var l;if(a===!0)l=hat;else{if(!bs(a))return!1;if(a.length>10)return wo.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;l=a.map((g=>g.toLowerCase()))}return c.some((g=>{var u=g.safeText,d=g.ariaLabel;return l.some((h=>dat(u,h)||dat(d,h)))}))})(o,s.map((a=>{var c;return{safeText:_L(a).toLowerCase(),ariaLabel:((c=a.getAttribute("aria-label"))==null?void 0:c.toLowerCase().trim())||""}})))&&!Xpe(s,n)}var $pe=t=>!t||ky(t,"html")||!Ub(t),pat=(t,e)=>{if(!wn||$pe(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var n=!1,o=[t],i=t;i.parentNode&&!ky(i,"body");)if(aat(i.parentNode))o.push(i.parentNode.host),i=i.parentNode.host;else{var r=uat(i);if(!r)break;if(e||jpe.indexOf(r.tagName.toLowerCase())>-1)n=!0;else try{var A=wn.getComputedStyle(r);A&&A.getPropertyValue("cursor")==="pointer"&&(n=!0)}catch{}o.push(r),i=r}return{parentIsUsefulElement:n,targetElementList:o}};function Zpe(t){for(var e=new Set,n=0,o=t;o.parentNode&&!ky(o,"body");o=o.parentNode){if(n++>=cat||e.has(o))return!1;e.add(o);var i=sX(o);if(gA(i,"ph-sensitive")||gA(i,"ph-no-capture"))return!1}if(gA(sX(t),"ph-include"))return!0;var r=t.type||"";if(Xl(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var A=t.name||t.id||"";return!Xl(A)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(A.replace(/[^a-zA-Z0-9]/g,""))}function Iat(t){return!!(ky(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||ky(t,"select")||ky(t,"textarea")||t.getAttribute("contenteditable")==="true")}var Cat="(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})",zRn=new RegExp("^(?:"+Cat+")$"),JRn=new RegExp(Cat),fat="\\d{3}-?\\d{2}-?\\d{4}",qRn=new RegExp("^("+fat+")$"),WRn=new RegExp("("+fat+")");function mL(t,e){return e===void 0&&(e=!0),!(as(t)||Xl(t)&&(t=Tj(t),(e?zRn:JRn).test((t||"").replace(/[- ]/g,""))||(e?qRn:WRn).test(t)))}function yat(t){var e=_L(t);return mL(e=(e+" "+Eat(t)).trim())?e:""}function Eat(t){var e="";return t&&t.childNodes&&t.childNodes.length&&pg(t.childNodes,(function(n){var o;if(n&&((o=n.tagName)==null?void 0:o.toLowerCase())==="span")try{var i=_L(n);e=(e+" "+i).trim(),n.childNodes&&n.childNodes.length&&(e=(e+" "+Eat(n)).trim())}catch(r){wo.error("[AutoCapture]",r)}})),e}function Bat(t){return t.replace(/"|\\"/g,'\\"')}function jRn(t){var e=t.attr__class;return e?bs(e)?e:qpe(e):void 0}var aX=v0("[Dead Clicks]"),XRn=()=>!0,$Rn=t=>{var e,n=!((e=t.instance.persistence)==null||!e.get_property(Dpe)),o=t.instance.config.capture_dead_clicks;return Wx(o)?o:!!P0(o)||n};class xat{get lazyLoadedDeadClicksAutocapture(){return this.jt}constructor(e,n,o){this.instance=e,this.isEnabled=n,this.onCapture=o,this.startIfEnabledOrStop()}onRemoteConfig(e){"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[Dpe]:e.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.Bt((()=>{this.Ht()})):this.stop()}Bt(e){var n,o;(n=_r.__PosthogExtensions__)!=null&&n.initDeadClicksAutocapture?e():(o=_r.__PosthogExtensions__)==null||o.loadExternalDependency==null||o.loadExternalDependency(this.instance,"dead-clicks-autocapture",(i=>{i?aX.error("failed to load script",i):e()}))}Ht(){var e;if(Zo){if(!this.jt&&(e=_r.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var n=P0(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};n.__onCapture=this.onCapture,this.jt=_r.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,n),this.jt.start(Zo),aX.info("starting...")}}else aX.error("`document` not found. Cannot start.")}stop(){this.jt&&(this.jt.stop(),this.jt=void 0,aX.info("stopping..."))}}var eIe=v0("[SegmentIntegration]"),Qat="posthog-js";function Sat(t,e){var n=e===void 0?{}:e,o=n.organization,i=n.projectId,r=n.prefix,A=n.severityAllowList,s=A===void 0?["error"]:A,a=n.sendExceptionsToPostHog,c=a===void 0||a;return l=>{var g,u,d,h,_;if(s!=="*"&&!s.includes(l.level)||!t.__loaded)return l;l.tags||(l.tags={});var p=t.requestRouter.endpointFor("ui","/project/"+t.config.token+"/person/"+t.get_distinct_id());l.tags["PostHog Person URL"]=p,t.sessionRecordingStarted()&&(l.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));var m,I=((g=l.exception)==null?void 0:g.values)||[],C=I.map((y=>fo({},y,{stacktrace:y.stacktrace?fo({},y.stacktrace,{type:"raw",frames:(y.stacktrace.frames||[]).map((B=>fo({},B,{platform:"web:javascript"})))}):void 0}))),f={$exception_message:((u=I[0])==null?void 0:u.value)||l.message,$exception_type:(d=I[0])==null?void 0:d.type,$exception_level:l.level,$exception_list:C,$sentry_event_id:l.event_id,$sentry_exception:l.exception,$sentry_exception_message:((h=I[0])==null?void 0:h.value)||l.message,$sentry_exception_type:(_=I[0])==null?void 0:_.type,$sentry_tags:l.tags};return o&&i&&(f.$sentry_url=(r||"https://sentry.io/organizations/")+o+"/issues/?project="+i+"&query="+l.event_id),c&&((m=t.exceptions)==null||m.sendExceptionEvent(f)),l}}class ZRn{constructor(e,n,o,i,r,A){this.name=Qat,this.setupOnce=function(s){s(Sat(e,{organization:n,projectId:o,prefix:i,severityAllowList:r,sendExceptionsToPostHog:A==null||A}))}}}class bat{constructor(e){this.Ut=(n,o,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(wo.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:n,changeReason:i}),this.zt=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.Wt()}Wt(){var e;this.Vt=(e=this._instance.sessionManager)==null?void 0:e.onSessionId(this.Ut)}destroy(){var e;(e=this.Vt)==null||e.call(this),this.Vt=void 0}doPageView(e,n){var o,i=this.Zt(e,n);return this.zt={pathname:(o=wn?.location.pathname)!==null&&o!==void 0?o:"",pageViewId:n,timestamp:e},this._instance.scrollManager.resetContext(),i}doPageLeave(e){var n;return this.Zt(e,(n=this.zt)==null?void 0:n.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.zt)==null?void 0:e.pageViewId}}Zt(e,n){var o=this.zt;if(!o)return{$pageview_id:n};var i={$pageview_id:n,$prev_pageview_id:o.pageViewId},r=this._instance.scrollManager.getContext();if(r&&!this._instance.config.disable_scroll_properties){var A=r.maxScrollHeight,s=r.lastScrollY,a=r.maxScrollY,c=r.maxContentHeight,l=r.lastContentY,g=r.maxContentY;if(!(To(A)||To(s)||To(a)||To(c)||To(l)||To(g))){A=Math.ceil(A),s=Math.ceil(s),a=Math.ceil(a),c=Math.ceil(c),l=Math.ceil(l),g=Math.ceil(g);var u=A>1?jx(s/A,0,1,wo):1,d=A>1?jx(a/A,0,1,wo):1,h=c>1?jx(l/c,0,1,wo):1,_=c>1?jx(g/c,0,1,wo):1;i=jg(i,{$prev_pageview_last_scroll:s,$prev_pageview_last_scroll_percentage:u,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:d,$prev_pageview_last_content:l,$prev_pageview_last_content_percentage:h,$prev_pageview_max_content:g,$prev_pageview_max_content_percentage:_})}}return o.pathname&&(i.$prev_pageview_pathname=o.pathname),o.timestamp&&(i.$prev_pageview_duration=(e.getTime()-o.timestamp.getTime())/1e3),i}}var cX=["flags","surveys"],eTn={[Yst]:{exposure:"hidden"},[aL]:{exposure:"hidden"},__cmpns:{exposure:"hidden"},[cL]:{exposure:"hidden"},[Epe]:{exposure:"event"},[Bpe]:{exposure:"hidden"},[xpe]:{exposure:"event"},[Qpe]:{exposure:"hidden"},[Spe]:{exposure:"event"},[bpe]:{exposure:"event"},[Dpe]:{exposure:"event"},[Mpe]:{exposure:"hidden"},[wpe]:{exposure:"event"},[sP]:{exposure:"hidden"},$session_recording_enabled_server_side:{exposure:"hidden"},[d9]:{exposure:"hidden"},[Ppe]:{exposure:"event"},[Vst]:{exposure:"event",shouldSkipFromEventProperties:t=>qC(t)},$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"},$sess_rec_flush_size:{exposure:"hidden"},[aP]:{exposure:"derived",storageGroup:"flags",shouldSkipFromEventProperties:(t,e)=>e(),transformToEventProperties(t){if(!P0(t))return{};for(var e={},n=Object.keys(t),o=0;n.length>o;o++)e["$feature/"+n[o]]=t[n[o]];return e}},[Wj]:{exposure:"event",storageGroup:"flags"},[lL]:{exposure:"hidden"},[vpe]:{exposure:"hidden",storageGroup:"flags"},[jj]:{exposure:"event",storageGroup:"flags"},[Npe]:{exposure:"event",storageGroup:"flags",volatile:!0},[YS]:{exposure:"event"},[_9]:{exposure:"hidden"},[cP]:{exposure:"hidden"},[lP]:{exposure:"hidden"},[Rpe]:{exposure:"hidden",storageGroup:"surveys"},[Xj]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[Tpe]:{exposure:"event"},[gL]:{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"},[uL]:{exposure:"hidden"},[kpe]:{exposure:"hidden"},[Fpe]:{exposure:"hidden"},[hL]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[IB]:{exposure:"hidden"},[Lpe]:{exposure:"hidden"},[Hpe]:{exposure:"hidden"},[Gpe]:{exposure:"hidden"},[Ope]:{exposure:"hidden"},[$j]:{exposure:"hidden"},[Zj]:{exposure:"hidden"},[zst]:{exposure:"event"},[Jst]:{exposure:"event"},[qst]:{exposure:"event"},[Wst]:{exposure:"event"},[Xst]:{exposure:"event"},[$st]:{exposure:"event"},[Zst]:{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"}},tTn=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],hP=t=>{var e=eTn[t];if(e)return e;for(var n of tTn){var o=n[1];if(t.indexOf(n[0])===0)return o}},pL=t=>{var e=Zo?.createElement("a");return To(e)?null:(e.href=t,e)},C9=function(t,e){for(var n,o=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),i=0;o.length>i;i++){var r=o[i].split("=");if(r[0]===e){n=r;break}}if(!bs(n)||2>n.length)return"";var A=n[1];try{A=decodeURIComponent(A)}catch{wo.error("Skipping decoding for malformed query param: "+A)}return A.replace(/\+/g," ")},IL=function(t,e,n){if(!t||!e||!e.length)return t;for(var o=t.split("#"),i=o[1],r=(o[0]||"").split("?"),A=r[1],s=r[0],a=(A||"").split("&"),c=[],l=0;a.length>l;l++){var g=a[l].split("=");bs(g)&&(e.includes(g[0])?c.push(g[0]+"="+n):c.push(a[l]))}var u=s;return A!=null&&(u+="?"+c.join("&")),i!=null&&(u+="#"+i),u},lX=function(t,e){var n=t.match(new RegExp(e+"=([^&]*)"));return n?n[1]:null},Dat=(t,e)=>t>=e&&JAt(),Mat=(t,e,n,o)=>{if(t===0){if(JAt()){var i=e+1;return i===n&&o(),i}return e}return 0},gX="https?://(.*)",f9=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],nTn=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...f9],CL="<masked>",oTn=["li_fat_id"];function wat(t,e,n){if(!Zo)return{};var o,i=e?[...f9,...n||[]]:[],r=Pat(IL(Zo.URL,i,CL),t),A=(o={},pg(oTn,(function(s){var a=Xx.A(s);o[s]=a||null})),o);return jg(A,r)}function Pat(t,e){var n=nTn.concat(e||[]),o={};return pg(n,(function(i){var r=C9(t,i);o[i]=r||null})),o}function vat(t){var e=(function(r){return r?r.search(gX+"google.([^/?]*)")===0?"google":r.search(gX+"bing.com")===0?"bing":r.search(gX+"yahoo.com")===0?"yahoo":r.search(gX+"duckduckgo.com")===0?"duckduckgo":null:null})(t),n=e!="yahoo"?"q":"p",o={};if(!qC(e)){o.$search_engine=e;var i=Zo?C9(Zo.referrer,n):"";i.length&&(o.ph_keyword=i)}return o}function Nat(){return navigator.language||navigator.userLanguage}var uX="$direct";function Rat(){return Zo?.referrer||uX}function Tat(t,e,n){n===void 0&&(n=!1);var o=t?[...f9,...e||[]]:[],i=n?Kb(rd?.href):rd?.href,r=i?.substring(0,1e3);return{r:Rat().substring(0,1e3),u:r?IL(r,o,CL):void 0}}function kat(t,e){var n;e===void 0&&(e=!1);var o=t.r,i=t.u,r=e?Kb(i):i,A={$referrer:o,$referring_domain:o==null?void 0:o==uX?uX:(n=pL(o))==null?void 0:n.host};if(r){A.$current_url=r;var s=pL(r);A.$host=s?.host,A.$pathname=s?.pathname;var a=Pat(r);jg(A,a)}if(o){var c=vat(o);jg(A,c)}return A}function Fat(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function iTn(){try{return new Date().getTimezoneOffset()}catch{return}}var rTn={flags:hL,surveys:Xj},ATn=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],y9="main";class tIe{constructor(e,n,o){if(o===void 0&&(o=!0),this.Gt={},this.Qt=!1,this.Jt=!1,this.Se=e,this.Kt=o,this.props={},this.Yt=!1,this.Xt=(r=>{var A="";return r.token&&(A=r.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),r.persistence_name?"ph_"+r.persistence_name:"ph_"+A+"_posthog"})(e),this.Nt=this.er(e),this.Jt=this.tr(e),this.load(),e.debug&&wo.info("Persistence loaded",e.persistence,fo({},this.props)),this.update_config(e,e,n),this.save(),wn){var i=()=>this.flush();au(wn,"beforeunload",i,{capture:!1}),au(wn,"pagehide",i,{capture:!1})}}rr(){var e,n=(e=this.Se)==null?void 0:e.persistence_save_debounce_ms;return Dp(n)&&n>0?n:0}isDisabled(){return!!this.ir}er(e){ATn.indexOf(e.persistence.toLowerCase())===-1&&(wo.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var n,o=(function(A,s){A===void 0&&(A=[]),s===void 0&&(s=!1);var a=[...FRn,...A];return fo({},Ig,{F(c){try{var l={};try{l=Xx.F(c)||{}}catch{}var g,u=JSON.parse(Ig.A(c)||"{}");if(s){var d={};for(var h in l){var _=l[h];qC(_)||_===""||(d[h]=_)}g=jg(u,d)}else g=jg(l,u);return Ig.q(c,g),g}catch{}return null},q(c,l,g,u,d,h){var _=Ig.q(c,l,void 0,void 0,h);try{var p={};a.forEach((m=>{l[m]&&(p[m]=l[m])})),Object.keys(p).length&&Xx.q(c,p,g,u,d,h)}catch(m){Ig.D(m)}return _},P(c,l){try{wn?.localStorage.removeItem(c),Xx.P(c,l)}catch(g){Ig.D(g)}}})})(e.cookie_persisted_properties||[],e.__preview_cookie_wins_on_conflict||!1),i=!1,r=e.persistence.toLowerCase();return r==="localstorage"&&Ig.N()?(n=Ig,i=!0):r==="localstorage+cookie"&&o.N()?(n=o,i=!0):r==="sessionstorage"&&Mp.N()?n=Mp:r==="memory"?n=LRn:r==="cookie"?n=Xx:o.N()?(n=o,i=!0):n=Xx,this.Qt=i,n}nr(e){return this.Xt+"__"+e}tr(e){return this.Qt&&!!e.split_storage}sr(e){var n=e??this.Se.feature_flag_cache_ttl_ms;if(!n||0>=n)return!1;var o=this.props[hL];return!o||typeof o!="number"||Date.now()-o>n}properties(){var e={};return pg(this.props,((n,o)=>{var i=hP(o);if(i?.exposure==="derived"){if(i.shouldSkipFromEventProperties!=null&&i.shouldSkipFromEventProperties(n,o===aP?()=>this.sr():()=>!1))return;i.transformToEventProperties&&jg(e,i.transformToEventProperties(n))}else if(!i||i.exposure==="event"){if(i!=null&&i.shouldSkipFromEventProperties!=null&&i.shouldSkipFromEventProperties(n,(()=>!1)))return;e[o]=n}})),e}load(){if(!this.ir){var e=this.Nt.F(this.Xt);e&&(this.props=jg({},e)),this.Jt&&this.ar()}}ar(){for(var e of cX){var n=Ig.F(this.nr(e));if(n&&!Ob(n)){var o=this.lr(e);o.persisted=!0,this.ur(e)||(o.fingerprint=this.hr(n,e)),this.dr(e,n)||jg(this.props,n)}}}ur(e){return Object.keys(this.props).some((n=>{var o;return((o=hP(n))==null?void 0:o.storageGroup)===e}))}dr(e,n){var o=rTn[e];if(!o)return!1;var i=n[o],r=this.props[o];return Dp(i)&&Dp(r)&&r>i}refreshKey(e){var n;if(!this.ir){var o=this.Jt?(n=hP(e))==null?void 0:n.storageGroup:void 0,i=o?Ig.F(this.nr(o)):this.Nt.F(this.Xt);if(i&&e in i)this.cr(e,i[e]);else{if(o){var r=this.Nt.F(this.Xt);if(r&&e in r)return void this.cr(e,r[e])}this.vr(e)}}}save(){if(!this.ir){var e=this.rr();e>0?To(this.pr)&&(this.pr=setTimeout((()=>{this.pr=void 0,this.gr()}),e)):this.gr()}}flush(){To(this.pr)||(clearTimeout(this.pr),this.pr=void 0,this.gr())}gr(){this.ir||(this.Jt?this.mr():this.yr(this.Nt,this.Xt,this.props,y9))}mr(){var e=this.br(),n=e.main,o=e.groups;for(var i of(this.yr(this.Nt,this.Xt,n,y9),cX)){var r,A=o[i];(!Ob(A)||(r=this.Gt[i])!=null&&r.persisted)&&this.yr(Ig,this.nr(i),A,i)}}br(){var e={},n={};for(var o of cX)n[o]={};return pg(this.props,((i,r)=>{var A,s=(A=hP(r))==null?void 0:A.storageGroup;s?n[s][r]=i:e[r]=i})),{main:e,groups:n}}hr(e,n){if(n===y9)return JSON.stringify(e)+"|"+this._r+"|"+this.wr+"|"+this.kr;var o={};return pg(e,((i,r)=>{var A;o[r]=(A=hP(r))!=null&&A.volatile?"__volatile__":i})),JSON.stringify(o)}yr(e,n,o,i){var r=this.lr(i);if(i===y9||r.dirty||To(r.fingerprint)){var A;try{if((A=this.hr(o,i))===r.fingerprint)return void(r.dirty=!1)}catch{A=void 0}e.q(n,o,this._r,this.wr,this.kr,this.Se.debug)?(r.dirty=!1,i!==y9&&(r.persisted=!0),To(A)||(r.fingerprint=A)):this.Se.debug&&wo.warn('failed to persist storage entry "'+n+'"; will retry on next save')}}remove(e){var n=(e===void 0?{}:e).keepGroupEntries,o=n!==void 0&&n;if(To(this.pr)||(clearTimeout(this.pr),this.pr=void 0),this.Nt.P(this.Xt,!1),this.Nt.P(this.Xt,!0),!o&&this.Kt)for(var i of cX)Ig.P(this.nr(i));o?delete this.Gt[y9]:this.Gt={}}clear(){this.remove(),this.props={}}register_once(e,n,o){if(P0(e)){To(n)&&(n="None"),this._r=To(o)?this.Sr:o;var i=!1;if(pg(e,((r,A)=>{this.props.hasOwnProperty(A)&&this.props[A]!==n||(this.cr(A,r),i=!0)})),i)return this.save(),!0}return!1}register(e,n){if(P0(e)){this._r=To(n)?this.Sr:n;var o=!1;if(pg(e,((i,r)=>{e.hasOwnProperty(r)&&this.props[r]!==i&&(this.cr(r,i),o=!0)})),o)return this.save(),!0}return!1}unregister(e){e in this.props&&(this.vr(e),this.save())}update_campaign_params(){if(!this.Yt){var e=wat(this.Se.custom_campaign_params,this.Se.mask_personal_data_properties,this.Se.custom_personal_data_properties);Ob(zpe(e))||this.register(e),this.Yt=!0}}update_search_keyword(){var e;this.register((e=Zo?.referrer)?vat(e):{})}update_referrer_info(){var e;this.register_once({$referrer:Rat(),$referring_domain:Zo!=null&&Zo.referrer&&((e=pL(Zo.referrer))==null?void 0:e.host)||uX},void 0)}set_initial_person_info(){this.props[Gpe]||this.props[Ope]||this.register_once({[$j]:Tat(this.Se.mask_personal_data_properties,this.Se.custom_personal_data_properties,this.Se.disable_capture_url_hashes)},void 0)}get_initial_props(){var e={};pg([Ope,Gpe],(i=>{var r=this.props[i];r&&pg(r,(function(A,s){e["$initial_"+ope(s)]=A}))}));var n=this.props[$j];if(n){var o=(function(i,r){r===void 0&&(r=!1);var A=kat(i,r),s={};return pg(A,(function(a,c){s["$initial_"+ope(c)]=a})),s})(n,this.Se.disable_capture_url_hashes);jg(e,o)}return e}safe_merge(e){return pg(this.props,(function(n,o){o in e||(e[o]=n)})),e}update_config(e,n,o){this.Sr=this._r=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!o),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie);var i=e.persistence!==n.persistence||!((a,c)=>{if(a.length!==c.length)return!1;var l=[...a].sort(),g=[...c].sort();return l.every(((u,d)=>u===g[d]))})(e.cookie_persisted_properties||[],n.cookie_persisted_properties||[]),r=i?this.er(e):this.Nt,A=this.tr(e);if(i||A!==this.Jt){var s=this.props;this.clear(),this.Nt=r,this.Jt=A,this.props=s,this.save()}}set_disabled(e){this.ir=e,this.ir?this.remove():this.save()}set_cross_subdomain(e){e!==this.wr&&(this.wr=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this.kr&&(this.kr=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,n){var o=this.props[cL]||{};o[e]=n,this.cr(cL,o),this.save()}remove_event_timer(e){var n=this.props[cL]||{},o=n[e];return To(o)||(delete n[e],this.cr(cL,n),this.save()),o}get_property(e){return this.props[e]}set_property(e,n){this.cr(e,n),this.save()}cr(e,n){var o;this.props[e]=n,(o=hP(e))!=null&&o.volatile||this.Cr(e)}vr(e){delete this.props[e],this.Cr(e)}Cr(e){var n,o=(n=hP(e))==null?void 0:n.storageGroup;o&&(this.lr(o).dirty=!0)}lr(e){return this.Gt[e]||(this.Gt[e]={})}}var fL={Activation:"events",Cancellation:"cancelEvents"},nIe={Popover:"popover",API:"api",Widget:"widget"},sTn={Always:"always"},JS={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent"},oIe={SURVEY_ID:"$survey_id",SURVEY_ITERATION:"$survey_iteration",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date"},iIe={Popover:"popover",Inline:"inline"},aTn={SHOWN:"product tour shown"},Lat={TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},Hat=v0("[RateLimiter]");class cTn{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=n=>{var o=n.text;if(o&&o.length)try{(JSON.parse(o).quota_limited||[]).forEach((i=>{Hat.info((i||"events")+" is quota limited."),this.serverLimits[i]=new Date().getTime()+6e4}))}catch(i){return void Hat.warn('could not rate limit - continuing. Error: "'+i?.message+'"',{text:o})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)==null?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)==null?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var n,o,i;e===void 0&&(e=!1);var r=this.captureEventsBurstLimit,A=this.captureEventsPerSecond,s=new Date().getTime(),a=(n=(o=this.instance.persistence)==null?void 0:o.get_property(Hpe))!==null&&n!==void 0?n:{tokens:r,last:s};a.tokens+=(s-a.last)/1e3*A,a.last=s,a.tokens>r&&(a.tokens=r);var c=1>a.tokens;return c||e||(a.tokens=Math.max(0,a.tokens-1)),!c||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+A+" events per second and "+r+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=c,(i=this.instance.persistence)==null||i.set_property(Hpe,a),{isRateLimited:c,remainingTokens:a.tokens}}isServerRateLimited(e){var n=this.serverLimits[e||"events"]||!1;return n!==!1&&new Date().getTime()<n}}var yL=v0("[RemoteConfig]");class Gat{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=_r._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}Tr(e){var n,o;(n=_r.__PosthogExtensions__)!=null&&n.loadExternalDependency?(o=_r.__PosthogExtensions__)==null||o.loadExternalDependency==null||o.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):e()}Ir(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback(n){e(n.json)}})}load(){try{if(this.remoteConfig)return yL.info("Using preloaded remote config",this.remoteConfig),this.Mr(this.remoteConfig),void this.Er();if(this._instance.Rr())return void yL.warn("Remote config is disabled. Falling back to local config.");this.Tr((e=>{if(!e)return yL.info("No config found after loading remote JS config. Falling back to JSON."),void this.Ir((n=>{this.Mr(n),this.Er()}));this.Mr(e),this.Er()}))}catch(e){yL.error("Error loading remote config",e)}}stop(){this.Pr&&(clearInterval(this.Pr),this.Pr=void 0)}refresh(){!this._instance.Rr()&&Zo&&Zo.visibilityState!=="hidden"&&this._instance.reloadFeatureFlags()}Er(){var e;if(!this.Pr){var n=(e=this._instance.config.remote_config_refresh_interval_ms)!==null&&e!==void 0?e:3e5;n!==0&&(this.Pr=setInterval((()=>{this.refresh()}),n))}}Mr(e){var n;e||yL.error("Failed to fetch remote config from PostHog."),this._instance.Mr(e??{}),e?.hasFeatureFlags!==!1&&(this._instance.config.advanced_disable_feature_flags_on_first_load||(n=this._instance.featureFlags)==null||n.ensureFlagsLoaded())}}var WC={GZipJS:"gzip-js",Base64:"base64"},r2=Uint8Array,E1=Uint16Array,E9=Uint32Array,rIe=new r2([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]),AIe=new r2([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]),Oat=new r2([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Kat=function(t,e){for(var n=new E1(31),o=0;31>o;++o)n[o]=e+=1<<t[o-1];var i=new E9(n[30]);for(o=1;30>o;++o)for(var r=n[o];n[o+1]>r;++r)i[r]=r-n[o]<<5|o;return[n,i]},Uat=Kat(rIe,2),sIe=Uat[1];Uat[0][28]=258,sIe[258]=28;for(var Yat=Kat(AIe,0)[1],Vat=new E1(32768),N0=0;32768>N0;++N0){var B9=(43690&N0)>>>1|(21845&N0)<<1;Vat[N0]=((65280&(B9=(61680&(B9=(52428&B9)>>>2|(13107&B9)<<2))>>>4|(3855&B9)<<4))>>>8|(255&B9)<<8)>>>1}var EL=function(t,e,n){for(var o=t.length,i=0,r=new E1(e);o>i;++i)++r[t[i]-1];var A,s=new E1(e);for(i=0;e>i;++i)s[i]=s[i-1]+r[i-1]<<1;for(A=new E1(o),i=0;o>i;++i)A[i]=Vat[s[t[i]-1]++]>>>15-t[i];return A},dP=new r2(288);for(N0=0;144>N0;++N0)dP[N0]=8;for(N0=144;256>N0;++N0)dP[N0]=9;for(N0=256;280>N0;++N0)dP[N0]=7;for(N0=280;288>N0;++N0)dP[N0]=8;var hX=new r2(32);for(N0=0;32>N0;++N0)hX[N0]=5;var lTn=EL(dP,9),gTn=EL(hX,5),zat=function(t){return(t/8>>0)+(7&t&&1)},Jat=function(t,e,n){(n==null||n>t.length)&&(n=t.length);var o=new(t instanceof E1?E1:t instanceof E9?E9:r2)(n-e);return o.set(t.subarray(e,n)),o},qS=function(t,e,n){var o=e/8>>0;t[o]|=n<<=7&e,t[o+1]|=n>>>8},BL=function(t,e,n){var o=e/8>>0;t[o]|=n<<=7&e,t[o+1]|=n>>>8,t[o+2]|=n>>>16},aIe=function(t,e){for(var n=[],o=0;t.length>o;++o)t[o]&&n.push({s:o,f:t[o]});var i=n.length,r=n.slice();if(!i)return[new r2(0),0];if(i==1){var A=new r2(n[0].s+1);return A[n[0].s]=1,[A,1]}n.sort((function(y,B){return y.f-B.f})),n.push({s:-1,f:25001});var s=n[0],a=n[1],c=0,l=1,g=2;for(n[0]={s:-1,f:s.f+a.f,l:s,r:a};l!=i-1;)s=n[n[g].f>n[c].f?c++:g++],a=n[c!=l&&n[g].f>n[c].f?c++:g++],n[l++]={s:-1,f:s.f+a.f,l:s,r:a};var u=r[0].s;for(o=1;i>o;++o)r[o].s>u&&(u=r[o].s);var d=new E1(u+1),h=cIe(n[l-1],d,0);if(h>e){o=0;var _=0,p=h-e,m=1<<p;for(r.sort((function(y,B){return d[B.s]-d[y.s]||y.f-B.f}));i>o;++o){var I=r[o].s;if(e>=d[I])break;_+=m-(1<<h-d[I]),d[I]=e}for(_>>>=p;_>0;){var C=r[o].s;e>d[C]?_-=1<<e-d[C]++-1:++o}for(;o>=0&&_;--o){var f=r[o].s;d[f]==e&&(--d[f],++_)}h=e}return[new r2(d),h]},cIe=function(t,e,n){return t.s==-1?Math.max(cIe(t.l,e,n+1),cIe(t.r,e,n+1)):e[t.s]=n},qat=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new E1(++e),o=0,i=t[0],r=1,A=function(a){n[o++]=a},s=1;e>=s;++s)if(t[s]==i&&s!=e)++r;else{if(!i&&r>2){for(;r>138;r-=138)A(32754);r>2&&(A(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(A(i),--r;r>6;r-=6)A(8304);r>2&&(A(r-3<<5|8208),r=0)}for(;r--;)A(i);r=1,i=t[s]}return[n.subarray(0,o),e]},xL=function(t,e){for(var n=0,o=0;e.length>o;++o)n+=t[o]*e[o];return n},lIe=function(t,e,n){var o=n.length,i=zat(e+2);t[i]=255&o,t[i+1]=o>>>8,t[i+2]=255^t[i],t[i+3]=255^t[i+1];for(var r=0;o>r;++r)t[i+r+4]=n[r];return 8*(i+4+o)},Wat=function(t,e,n,o,i,r,A,s,a,c,l){qS(e,l++,n),++i[256];for(var g=aIe(i,15),u=g[0],d=g[1],h=aIe(r,15),_=h[0],p=h[1],m=qat(u),I=m[0],C=m[1],f=qat(_),y=f[0],B=f[1],x=new E1(19),S=0;I.length>S;++S)x[31&I[S]]++;for(S=0;y.length>S;++S)x[31&y[S]]++;for(var M=aIe(x,7),w=M[0],k=M[1],N=19;N>4&&!w[Oat[N-1]];--N);var G,H,U,J,W=c+5<<3,X=xL(i,dP)+xL(r,hX)+A,oe=xL(i,u)+xL(r,_)+A+14+3*N+xL(x,w)+(2*x[16]+3*x[17]+7*x[18]);if(X>=W&&oe>=W)return lIe(e,l,t.subarray(a,a+c));if(qS(e,l,1+(X>oe)),l+=2,X>oe){G=EL(u,d),H=u,U=EL(_,p),J=_;var ce=EL(w,k);for(qS(e,l,C-257),qS(e,l+5,B-1),qS(e,l+10,N-4),l+=14,S=0;N>S;++S)qS(e,l+3*S,w[Oat[S]]);l+=3*N;for(var te=[I,y],ie=0;2>ie;++ie){var ae=te[ie];for(S=0;ae.length>S;++S)qS(e,l,ce[re=31&ae[S]]),l+=w[re],re>15&&(qS(e,l,ae[S]>>>5&127),l+=ae[S]>>>12)}}else G=lTn,H=dP,U=gTn,J=hX;for(S=0;s>S;++S)if(o[S]>255){var re;BL(e,l,G[257+(re=o[S]>>>18&31)]),l+=H[re+257],re>7&&(qS(e,l,o[S]>>>23&31),l+=rIe[re]);var le=31&o[S];BL(e,l,U[le]),l+=J[le],le>3&&(BL(e,l,o[S]>>>5&8191),l+=AIe[le])}else BL(e,l,G[o[S]]),l+=H[o[S]];return BL(e,l,G[256]),l+H[256]},uTn=new E9([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),hTn=(function(){for(var t=new E9(256),e=0;256>e;++e){for(var n=e,o=9;--o;)n=(1&n&&3988292384)^n>>>1;t[e]=n}return t})(),gIe=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8};function dTn(t,e){e===void 0&&(e={});var n=(function(){var g=4294967295;return{p(u){for(var d=g,h=0;u.length>h;++h)d=hTn[255&d^u[h]]^d>>>8;g=d},d(){return 4294967295^g}}})(),o=t.length;n.p(t);var i,r,A,s,a,c=(s=10+((i=e).filename&&i.filename.length+1||0),a=8,(function(g,u,d,h,_,p){var m=g.length,I=new r2(h+m+5*(1+Math.floor(m/7e3))+_),C=I.subarray(h,I.length-_),f=0;if(!u||8>m)for(var y=0;m>=y;y+=65535){var B=y+65535;m>B?f=lIe(C,f,g.subarray(y,B)):(C[y]=!0,f=lIe(C,f,g.subarray(y,m)))}else{for(var x=uTn[u-1],S=x>>>13,M=8191&x,w=(1<<d)-1,k=new E1(32768),N=new E1(w+1),G=Math.ceil(d/3),H=2*G,U=function(Me){return(g[Me]^g[Me+1]<<G^g[Me+2]<<H)&w},J=new E9(25e3),W=new E1(288),X=new E1(32),oe=0,ce=0,te=(y=0,0),ie=0,ae=0;m>y;++y){var re=U(y),le=32767&y,ye=N[re];if(k[le]=ye,N[re]=le,y>=ie){var xe=m-y;if((oe>7e3||te>24576)&&xe>423){f=Wat(g,C,0,J,W,X,ce,te,ae,y-ae,f),te=oe=ce=0,ae=y;for(var be=0;286>be;++be)W[be]=0;for(be=0;30>be;++be)X[be]=0}var he=2,Se=0,Ie=M,He=le-ye&32767;if(xe>2&&re==U(y-He))for(var Je=Math.min(S,xe)-1,et=Math.min(32767,y),pe=Math.min(258,xe);et>=He&&--Ie&&le!=ye;){if(g[y+he]==g[y+he-He]){for(var $e=0;pe>$e&&g[y+$e]==g[y+$e-He];++$e);if($e>he){if(he=$e,Se=He,$e>Je)break;var Ge=Math.min(He,$e-2),Pe=0;for(be=0;Ge>be;++be){var Ue=y-He+be+32768&32767,Ne=Ue-k[Ue]+32768&32767;Ne>Pe&&(Pe=Ne,ye=Ue)}}}He+=(le=ye)-(ye=k[le])+32768&32767}if(Se){J[te++]=268435456|sIe[he]<<18|Yat[Se];var Ee=31&sIe[he],Oe=31&Yat[Se];ce+=rIe[Ee]+AIe[Oe],++W[257+Ee],++X[Oe],ie=y+he,++oe}else J[te++]=g[y],++W[g[y]]}}f=Wat(g,C,!0,J,W,X,ce,te,ae,y-ae,f)}return Jat(I,0,h+zat(f)+_)})(r=t,(A=e).level==null?6:A.level,A.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(r.length)))):12+A.mem,s,a)),l=c.length;return(function(g,u){var d=u.filename;if(g[0]=31,g[1]=139,g[2]=8,g[8]=2>u.level?4:u.level==9?2:0,g[9]=3,u.mtime!=0&&gIe(g,4,Math.floor(new Date(u.mtime||Date.now())/1e3)),d){g[3]=8;for(var h=0;d.length>=h;++h)g[h+10]=d.charCodeAt(h)}})(c,e),gIe(c,l-8,n.d()),gIe(c,l-4,o),c}var _Tn=!!epe||!!Zme,jat="text/plain",dX=!1,uIe=(t,e)=>{var n=t.split("#"),o=n[1],i=n[0].split("?"),r=i[0],A=i[1];if(!A)return t;var s=A.split("&").filter((a=>a.split("=")[0]!==e)).join("&");return r+(s?"?"+s:"")+(o?"#"+o:"")},hIe=function(t,e,n){var o;n===void 0&&(n=!0);var i=t.split("?"),r=i[0],A=i[1],s=fo({},e),a=(o=A?.split("&").map((l=>{var g,u=l.split("="),d=u[0],h=n&&(g=s[d])!==null&&g!==void 0?g:u[1];return delete s[d],d+"="+h})))!==null&&o!==void 0?o:[],c=(function(l,g){var u,d;g===void 0&&(g="&");var h=[];return pg(l,(function(_,p){To(_)||To(p)||p==="undefined"||(u=encodeURIComponent((m=>m instanceof File)(_)?_.name:_.toString()),d=encodeURIComponent(p),h[h.length]=d+"="+u)})),h.join(g)})(s);return c&&a.push(c),r+"?"+a.join("&")},x9=(t,e)=>{try{return JSON.stringify(t,((n,o)=>typeof o=="bigint"?o.toString():o),e)}catch{return rst(t)}},dIe=t=>{if(t.Lt)return t.Lt;var e=t.data,n=t.compression;if(e){if(n===WC.GZipJS){var o=dTn((function(s,a){var c=s.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(s);for(var l=new r2(s.length+(s.length>>>1)),g=0,u=function(p){l[g++]=p},d=0;c>d;++d){if(g+5>l.length){var h=new r2(g+8+(c-d<<1));h.set(l),l=h}var _=s.charCodeAt(d);128>_?u(_):2048>_?(u(192|_>>>6),u(128|63&_)):_>55295&&57344>_?(u(240|(_=65536+(1047552&_)|1023&s.charCodeAt(++d))>>>18),u(128|_>>>12&63),u(128|_>>>6&63),u(128|63&_)):(u(224|_>>>12),u(128|_>>>6&63),u(128|63&_))}return Jat(l,0,g)})(x9(e)),{mtime:0});return{contentType:jat,body:o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength),estimatedSize:o.byteLength}}if(n===WC.Base64){var i=(function(s){return s&&btoa(encodeURIComponent(s).replace(/%([0-9A-F]{2})/g,((a,c)=>String.fromCharCode(parseInt(c,16)))))})(x9(e)),r=(s=>"data="+encodeURIComponent(typeof s=="string"?s:x9(s)))(i);return{contentType:"application/x-www-form-urlencoded",body:r,estimatedSize:new Blob([r]).size}}var A=x9(e);return{contentType:"application/json",body:A,estimatedSize:new Blob([A]).size}}},Xat=t=>{var e,n,o=()=>t.transport==="sendBeacon"?{url:hIe(t.url,{compression:WC.Base64}),encodedBody:dIe(fo({},t,{compression:WC.Base64,Lt:void 0}))}:{url:uIe(t.url,"compression"),encodedBody:dIe(fo({},t,{compression:void 0,Lt:void 0}))};try{e=dIe(t)}catch(i){if(nst(t.compression,C9(t.url,"compression")))return wo.error("Failed to gzip request body, sending uncompressed payload",i),o();throw i}return e&&nst(t.compression,C9(t.url,"compression"))&&!((n=e.body)instanceof ArrayBuffer?tpe(new Uint8Array(n)):ArrayBuffer.isView(n)&&tpe(new Uint8Array(n.buffer,n.byteOffset,n.byteLength)))?(dX=!0,o()):{url:t.url,encodedBody:e}},$at=t=>{try{return Xat(t)}catch(e){return wo.error(e),void(t.callback==null||t.callback({statusCode:0,error:e}))}},mTn=(function(){var t=Ih((function*(e){var n=x9(e.data),o=yield(function(r,A,s){return npe.apply(this,arguments)})(n,Au.DEBUG,{rethrow:!0});if(!o)return e;var i=yield o.arrayBuffer();return fo({},e,{Lt:{contentType:jat,body:i,estimatedSize:i.byteLength}})}));return function(e){return t.apply(this,arguments)}})(),pTn=/Failed to fetch|NetworkError|Load failed/i,Zat=t=>{var e,n=$at(t);if(n){var o=n.url,i=n.encodedBody,r=i??{},A=r.contentType,s=r.body,a=r.estimatedSize,c=new Headers;pg(t.headers,(function(d,h){c.append(h,d)})),A&&c.append("Content-Type",A);var l=null,g=!1;if(zAt){var u=new zAt;l={signal:u.signal,timeout:setTimeout((()=>{var d,h;g=!0,u.abort((d=t.timeout,(h=new Error("PostHog request timed out"+(d?" after "+d+"ms":""))).name="AbortError",h))}),t.timeout)}}Zme(o,fo({method:t?.method||"GET",headers:c,keepalive:t.method==="POST"&&!t.Ft&&52428.8>(a||0),body:s,signal:(e=l)==null?void 0:e.signal},t.fetchOptions)).then((d=>d.text().then((h=>{var _={statusCode:d.status,text:h};if(d.status===200)try{_.json=JSON.parse(h)}catch(p){wo.error(p)}t.callback==null||t.callback(_)})))).catch((d=>{g&&d?.name==="AbortError"||(h=>h?.name==="TypeError"&&pTn.test(h?.message||""))(d)?wo.warn(d):wo.error(d),t.callback==null||t.callback({statusCode:0,error:d})})).finally((()=>l?clearTimeout(l.timeout):null))}},_Ie=t=>{try{var e=Xat(t),n=e.url,o=e.encodedBody,i=o??{},r=i.body,A=i.estimatedSize;if(!r)return;var s=r instanceof Blob?r:new Blob([r],{type:i.contentType});if(JC.sendBeacon(n,s))return;if(bs(t.data)&&t.data.length>1&&(A??0)>16384){var a=Math.ceil(t.data.length/2);return _Ie(fo({},t,{data:t.data.slice(0,a)})),void _Ie(fo({},t,{data:t.data.slice(a)}))}wo.warn("Beacon of ~"+(A??0)+" bytes was rejected by the browser, falling back to fetch"),Zat(fo({},t,{Ft:!0}))}catch(c){wo.warn("Beacon send failed",c)}},ITn=["/e/","/s/"],ect=(t,e)=>{var n=(i=>{var r=(A=>{var s=pL(A),a=s?.pathname||A.split(/[?#]/)[0];return a?a[0]==="/"?a:"/"+a:"/"})(i);return ITn.some((A=>((s,a)=>s.slice(s.length-a.length)===a)(r,A)))})(t),o=n?uIe(t,"ver"):t;return hIe(e===WC.GZipJS?uIe(o,"compression"):o,fo({_:new Date().getTime().toString()},n?{}:{ver:Au.JS_SDK_VERSION},e===WC.GZipJS?{}:{compression:e}))},_X=[];Zme&&_X.push({transport:"fetch",method:Zat}),epe&&_X.push({transport:"XHR",method(t){var e=$at(t);if(e){var n=new epe,o=e.encodedBody;n.open(t.method||"GET",e.url,!0);var i=o??{},r=i.contentType,A=i.body;pg(t.headers,(function(s,a){n.setRequestHeader(a,s)})),r&&n.setRequestHeader("Content-Type",r),t.timeout&&(n.timeout=t.timeout),n.onreadystatechange=()=>{if(n.readyState===4){var s={statusCode:n.status,text:n.responseText};if(n.status===200)try{s.json=JSON.parse(n.responseText)}catch{}t.callback==null||t.callback(s)}},n.send(A)}}}),JC!=null&&JC.sendBeacon&&_X.push({transport:"sendBeacon",method:_Ie});var mIe=3e3;class CTn{constructor(e,n){this.Or=!0,this.Lr=[],this.Fr=jx(n?.flush_interval_ms||mIe,250,5e3,wo.createLogger("flush interval"),mIe),this.Ar=e}enqueue(e){this.Lr.push(e),this.$r||this.Nr()}unload(){this.Dr();var e=this.Lr.length>0?this.qr():{},n=Object.values(e);[...n.filter((o=>o.url.indexOf("/e")===0)),...n.filter((o=>o.url.indexOf("/e")!==0))].map((o=>{this.jr(fo({},o,{transport:"sendBeacon"}))}))}enable(){this.Or=!1,this.Nr()}Nr(){var e=this;this.Or||(this.$r=setTimeout((()=>{if(this.Dr(),this.Lr.length>0){var n=this.qr(),o=function(){var r=n[i],A=new Date().getTime();r.data&&bs(r.data)&&pg(r.data,(s=>{s.offset=Math.abs(s.timestamp-A),delete s.timestamp})),e.jr(r)};for(var i in n)o()}}),this.Fr))}jr(e){try{this.Ar(e)}catch(n){wo.error(n)}}Dr(){clearTimeout(this.$r),this.$r=void 0}qr(){var e={};return pg(this.Lr,(n=>{var o,i=n,r=(i?i.batchKey:null)||i.url;To(e[r])&&(e[r]=fo({},i,{data:[]})),(o=e[r].data)==null||o.push(i.data)})),this.Lr=[],e}}var fTn=["retriesPerformedSoFar"];class yTn{constructor(e){this.Br=!1,this.Hr=3e3,this.Lr=[],this._instance=e,this.Lr=[],this.Ur=!0,!To(wn)&&"onLine"in wn.navigator&&(this.Ur=wn.navigator.onLine,this.zr=()=>{this.Ur=!0,this.Wr()},this.Vr=()=>{this.Ur=!1},au(wn,"online",this.zr),au(wn,"offline",this.Vr))}get length(){return this.Lr.length}retriableRequest(e){var n=e.retriesPerformedSoFar,o=jAt(e,fTn);KS(n)&&(o.url=hIe(o.url,{retry_count:n})),this._instance._send_request(fo({},o,{callback:i=>{if(i.statusCode!==200&&(400>i.statusCode||i.statusCode>=500)){if((i.statusCode===0?3:10)>(n??0))return void this.st(fo({retriesPerformedSoFar:n},o));i.statusCode===0&&wo.warn("Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after "+(n??0)+" retries.")}o.callback==null||o.callback(i)}}))}st(e){var n=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=n+1;var o=(function(A){var s=3e3*Math.pow(2,A),a=s/2,c=Math.min(18e5,s),l=Math.random()-.5;return Math.ceil(c+l*(c-a))})(n),i=Date.now()+o;this.Lr.push({retryAt:i,requestOptions:e});var r="Enqueued failed request for retry in "+o;navigator.onLine||(r+=" (Browser is offline)"),wo.warn(r),this.Br||(this.Br=!0,this.Zr())}Zr(){if(this.Gr&&clearTimeout(this.Gr),this.Lr.length===0)return this.Br=!1,void(this.Gr=void 0);this.Gr=setTimeout((()=>{this.Ur&&this.Lr.length>0&&this.Wr(),this.Zr()}),this.Hr)}Wr(){var e=Date.now(),n=[],o=this.Lr.filter((r=>e>r.retryAt||(n.push(r),!1)));if(this.Lr=n,o.length>0)for(var i of o)this.retriableRequest(i.requestOptions)}unload(){for(var e of(this.Gr&&(clearTimeout(this.Gr),this.Gr=void 0),this.Br=!1,To(wn)||(this.zr&&(wn.removeEventListener("online",this.zr),this.zr=void 0),this.Vr&&(wn.removeEventListener("offline",this.Vr),this.Vr=void 0)),this.Lr)){var n=e.requestOptions;try{this._instance._send_request(fo({},n,{transport:"sendBeacon"}))}catch(o){wo.error(o)}}this.Lr=[]}}class ETn{constructor(e){this.Qr=()=>{var n,o,i,r;this.Jr||(this.Jr={});var A=this.scrollElement(),s=this.scrollY(),a=A?Math.max(0,A.scrollHeight-A.clientHeight):0,c=s+(A?.clientHeight||0),l=A?.scrollHeight||0;this.Jr.lastScrollY=Math.ceil(s),this.Jr.maxScrollY=Math.max(s,(n=this.Jr.maxScrollY)!==null&&n!==void 0?n:0),this.Jr.maxScrollHeight=Math.max(a,(o=this.Jr.maxScrollHeight)!==null&&o!==void 0?o:0),this.Jr.lastContentY=c,this.Jr.maxContentY=Math.max(c,(i=this.Jr.maxContentY)!==null&&i!==void 0?i:0),this.Jr.maxContentHeight=Math.max(l,(r=this.Jr.maxContentHeight)!==null&&r!==void 0?r:0)},this._instance=e}get Kr(){return this._instance.config.scroll_root_selector}getContext(){return this.Jr}resetContext(){var e=this.Jr;return setTimeout(this.Qr,0),e}startMeasuringScrollPosition(){au(wn,"scroll",this.Qr,{capture:!0}),au(wn,"scrollend",this.Qr,{capture:!0}),au(wn,"resize",this.Qr)}scrollElement(){if(!this.Kr)return wn?.document.documentElement;var e=bs(this.Kr)?this.Kr:[this.Kr];for(var n of e){var o=wn?.document.querySelector(n);if(o)return o}}Yr(e){var n=e==="y"?"scrollTop":"scrollLeft";if(this.Kr){var o=this.scrollElement();return o&&o[n]||0}return wn?e==="y"?wn.scrollY||wn.pageYOffset||wn.document.documentElement.scrollTop||0:wn.scrollX||wn.pageXOffset||wn.document.documentElement.scrollLeft||0:0}scrollY(){return this.Yr("y")}scrollX(){return this.Yr("x")}}var BTn=t=>Tat(t?.config.mask_personal_data_properties,t?.config.custom_personal_data_properties,t?.config.disable_capture_url_hashes);class tct{constructor(e,n,o,i){this.Xr=r=>{var A=this.ei();if(!A||A.sessionId!==r){var s={sessionId:r,props:this.ti(this._instance)};this.ri.register({[Lpe]:s})}},this._instance=e,this.ii=n,this.ri=o,this.ti=i||BTn,this.ii.onSessionId(this.Xr)}ei(){return this.ri.props[Lpe]}getSetOnceProps(){var e,n=(e=this.ei())==null?void 0:e.props;return n?"r"in n?kat(n,this._instance.config.disable_capture_url_hashes):{$referring_domain:n.referringDomain,$pathname:n.initialPathName,utm_source:n.utm_source,utm_campaign:n.utm_campaign,utm_medium:n.utm_medium,utm_content:n.utm_content,utm_term:n.utm_term}:{}}getSessionProps(){var e={};return pg(zpe(this.getSetOnceProps()),((n,o)=>{o==="$current_url"&&(o="url"),e["$session_entry_"+ope(o)]=n})),e}}class pIe{constructor(){this.ni={}}on(e,n){return this.ni[e]||(this.ni[e]=[]),this.ni[e].push(n),()=>{this.ni[e]=this.ni[e].filter((o=>o!==n))}}emit(e,n){for(var o of this.ni[e]||[])o(n);for(var i of this.ni["*"]||[])i(e,n)}}var QL=v0("[SessionId]");class nct{on(e,n){return this.si.on(e,n)}constructor(e,n,o){var i;if(this.oi=null,this.ai=[],this.li=void 0,this.ui=!1,this.si=new pIe,this.hi=(c,l)=>!(!KS(c)||!KS(l))&&Math.abs(c-l)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode===VS)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Se=e.config,this.ri=e.persistence,this.di=void 0,this.ci=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.vi=n||zS,this.fi=o||zS;var r=this.Se.persistence_name||this.Se.token;if(this._sessionTimeoutMs=1e3*jx(this.Se.session_idle_timeout_seconds||1800,60,36e3,QL.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.pi(),this.gi="ph_"+r+"_window_id",this.mi="ph_"+r+"_primary_window_exists",this.yi()){var A=Mp.F(this.gi),s=Mp.F(this.mi);A&&!s?this.di=A:Mp.P(this.gi),Mp.q(this.mi,!0)}if((i=this.Se.bootstrap)!=null&&i.sessionID)try{var a=(c=>{var l=this.Se.bootstrap.sessionID.replace(/-/g,"");if(l.length!==32)throw new Error("Not a valid UUID");if(l[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(l.substring(0,12),16)})();this.bi(this.Se.bootstrap.sessionID,new Date().getTime(),a)}catch(c){QL.error("Invalid sessionID in bootstrap",c)}this.wi()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return To(this.ai)&&(this.ai=[]),this.ai.push(e),this.ci&&e(this.ci,this.di),()=>{this.ai=this.ai.filter((n=>n!==e))}}yi(){return this.Se.persistence!=="memory"&&!this.ri.ir&&Mp.N()}xi(e){e!==this.di&&(this.di=e,this.yi()&&Mp.q(this.gi,e))}ki(){return this.di?this.di:this.yi()?Mp.F(this.gi):null}Si(e){var n=this.oi;return!qC(n)&&!qC(e)&&5e3>Math.abs(e-n)}bi(e,n,o){var i=n!==this._sessionActivityTimestamp,r=!(e!==this.ci||o!==this._sessionStartTimestamp);this._sessionStartTimestamp=o,this._sessionActivityTimestamp=n,this.ci=e,r&&!i||r&&this.Si(n)||(this.oi=n,this.ri.register({[d9]:[n,e,o]}))}Ci(){var e,n=(e=this.Se)==null?void 0:e.persistence_save_debounce_ms;return KS(n)&&n>0}Ti(){this.Ci()?this.ri.refreshKey(d9):(this.ri.flush(),this.ri.load())}Ii(){var e;if(!qC(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this.oi){this.Ti();var n=this.Mi();n[1]===this.ci&&n[2]===this._sessionStartTimestamp&&(this.oi=this._sessionActivityTimestamp,this.ri.register({[d9]:[this._sessionActivityTimestamp,(e=this.ci)!==null&&e!==void 0?e:null,this._sessionStartTimestamp]}),this.ri.flush())}}Ei(){var e=this.Mi()[0],n=KS(e)?e:0,o=KS(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(n,o)}Ri(e){return this.Ti(),this.hi(e,this.Ei())}Mi(){var e=this.ri.props[d9];return bs(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.oi=null,clearTimeout(this.Pi),this.Pi=void 0,this.bi(null,null,null)}destroy(){this.ui=!0,this.Ii(),clearTimeout(this.Pi),this.Pi=void 0,this.li&&wn&&(wn.removeEventListener(nX,this.li,{capture:!1}),this.li=void 0),this.ai=[]}wi(){this.li=()=>{this.Ii(),this.yi()&&Mp.P(this.mi)},au(wn,nX,this.li,{capture:!1})}checkAndGetSessionAndWindowId(e,n){if(e===void 0&&(e=!1),n===void 0&&(n=null),this.Se.cookieless_mode===VS)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var o=n||new Date().getTime(),i=this.Mi(),r=i[1],A=i[2],s=this.Ei(),a=this.ki(),c=KS(A)&&Math.abs(o-A)>864e5,l=!1,g=!1,u=!r,d=r,h=!u&&!e&&this.hi(o,s);if(h){(h=this.Ri(o))||QL.info("cross-tab refresh kept the session alive",{sessionId:r});var _=this.Mi();r=_[1],A=_[2]}u||h||c?(r=this.vi(),a=this.fi(),QL.info("new session ID generated",{sessionId:r,windowId:a,changeReason:{noSessionId:u,activityTimeout:h,sessionPastMaximumLength:c}}),A=o,l=!0):(a||(a=this.fi(),l=!0),(g=r!==d)&&(QL.info("adopted cross-tab session id",{sessionId:r,windowId:a}),l=!0));var p=KS(s)&&e&&!c?s:o,m=KS(A)?A:new Date().getTime();this.xi(a),this.bi(r,p,m),e||this.pi();var I={noSessionId:u,activityTimeout:h,sessionPastMaximumLength:c,crossTabAdoption:g};return l&&this.ai.forEach((C=>C(r,a,I))),{sessionId:r,windowId:a,sessionStartTimestamp:m,changeReason:l?I:void 0,lastActivityTimestamp:s}}pi(){this.ui||(clearTimeout(this.Pi),this.Pi=setTimeout((()=>{if(!this.ui)if(this.Ri(new Date().getTime())){var e=this.ci;this.resetSessionId(),this.si.emit("forcedIdleReset",{idleSessionId:e})}else this.pi()}),1.1*this.sessionTimeoutMs))}}var oct=function(t,e){if(!t)return!1;var n=t.userAgent;if(n&&ist(n,e))return!0;try{var o=t?.userAgentData;if(o!=null&&o.brands&&o.brands.some((i=>ist(i?.brand,e))))return!0}catch{}return!!t.webdriver};function ict(){return(ict=Ih((function*(){var t=JC?.userAgentData;if(t!=null&&t.getHighEntropyValues)try{var e=yield t.getHighEntropyValues(["model"]),n=e?.model;return Xl(n)&&n.length>0?n:void 0}catch(o){return void wo.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",o)}}))).apply(this,arguments)}var mX=function(t,e){if(!(function(n){try{new RegExp(n)}catch{return!1}return!0})(e))return!1;try{return new RegExp(e).test(t)}catch{return!1}};function rct(t,e,n){return x9({distinct_id:t,userPropertiesToSet:e,userPropertiesToSetOnce:n})}var Act={exact:(t,e)=>e.some((n=>t.some((o=>n===o)))),is_not:(t,e)=>e.every((n=>t.every((o=>n!==o)))),regex:(t,e)=>e.some((n=>t.some((o=>mX(n,o))))),not_regex:(t,e)=>e.every((n=>t.every((o=>!mX(n,o))))),icontains:(t,e)=>e.map(pX).some((n=>t.map(pX).some((o=>n.includes(o))))),not_icontains:(t,e)=>e.map(pX).every((n=>t.map(pX).every((o=>!n.includes(o))))),gt:(t,e)=>e.some((n=>{var o=parseFloat(n);return!isNaN(o)&&t.some((i=>o>parseFloat(i)))})),lt:(t,e)=>e.some((n=>{var o=parseFloat(n);return!isNaN(o)&&t.some((i=>o<parseFloat(i)))}))},pX=t=>t.toLowerCase();function sct(t,e){return!t||Object.entries(t).every((n=>{var o=n[1],i=e?.[n[0]];if(To(i)||qC(i))return!1;var r=[String(i)],A=Act[o.operator];return!!A&&A(o.values,r)}))}var IIe="custom",act="i.posthog.com",xTn=/^\/static\//;class QTn{constructor(e){this.Oi={},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,n=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return n||(n=this.apiHost.replace("."+act,".posthog.com")),n==="https://app.posthog.com"?"https://us.posthog.com":n}get region(){return this.Oi[this.apiHost]||(this.Oi[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":IIe),this.Oi[this.apiHost]}Li(e){if(xTn.test(e)){var n=this.instance.config.asset_host;if(typeof n=="string")return n.trim().replace(/\/$/,"")||void 0}}endpointFor(e,n){if(n===void 0&&(n=""),n&&(n=n[0]==="/"?n:"/"+n),e==="ui")return this.uiHost+n;if(e==="flags")return this.flagsApiHost+n;if(e==="assets"){var o=this.Li(n);if(o)return""+o+n}if(this.region===IIe)return this.apiHost+n;var i=act+n;switch(e){case"assets":return"https://"+this.region+"-assets."+i;case"api":return"https://"+this.region+"."+i}}}var $l=v0("[Surveys]"),CIe="seenSurvey_",cct=t=>{try{var e=(n=>((o,i)=>{var r=""+CIe+i.id;return i.current_iteration&&i.current_iteration>0&&(r=""+CIe+i.id+"_"+i.current_iteration),r})(0,n))(t);if(localStorage.getItem(e))return;localStorage.setItem(e,"true")}catch(n){$l.error("Failed to persist survey seen state",n)}},STn=[nIe.Popover,nIe.Widget,nIe.API],bTn={ignoreConditions:!1,ignoreDelay:!1,displayType:iIe.Popover},DTn=v0("[PostHog ExternalIntegrations]"),MTn={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class wTn{constructor(e){this._instance=e}Bt(e,n){var o;(o=_r.__PosthogExtensions__)==null||o.loadExternalDependency==null||o.loadExternalDependency(this._instance,e,(i=>{if(i)return DTn.error("failed to load script",i);n()}))}startIfEnabledOrStop(){var e=this,n=function(){var r,A,s,a=o[0],c=o[1];!c||(r=_r.__PosthogExtensions__)!=null&&(r=r.integrations)!=null&&r[a]||e.Bt(MTn[a],(()=>{var l;(l=_r.__PosthogExtensions__)==null||(l=l.integrations)==null||(l=l[a])==null||l.start(e._instance)})),!c&&(A=_r.__PosthogExtensions__)!=null&&(A=A.integrations)!=null&&A[a]&&((s=_r.__PosthogExtensions__)==null||(s=s.integrations)==null||(s=s[a])==null||s.stop())};for(var o of Object.entries((i=this._instance.config.integrations)!==null&&i!==void 0?i:{})){var i;n()}}}var SL={},fIe=0,IX=()=>{},lct='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',bL="Surveys module not available",gct="sanitize_properties is deprecated. Use before_send instead",uct="Invalid value for property_denylist config: ",Q9="posthog",hct=!_Tn&&y1?.indexOf("MSIE")===-1&&y1?.indexOf("Mozilla")===-1,dct=t=>{var e;return fo({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:vRn(Zo?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:IX,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:t??"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:rd&&Xl(rd?.search)&&rd.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,disableDeviceModel:!1,disable_external_dependency_loading:!1,strict_script_versioning:!1,enable_recording_console_log:void 0,secure_cookie:(wn==null||(e=wn.location)==null?void 0:e.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(n){wo.error("Bad HTTP status: "+n.statusCode+" "+n.text)},get_device_id:n=>n,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Upe,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:mIe},error_tracking:{},_onCapture:IX},(n=>({rageclick:n&&n>="2026-05-30"?{content_ignorelist:YRn,ignore_text_selection:!0}:!n||"2025-11-30">n||{content_ignorelist:!0},capture_pageview:!n||"2025-05-24">n||"history_change",session_recording:n&&n>="2026-06-25"?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6},streamNetworkBody:!0}:n&&n>="2026-05-30"?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6}}:n&&n>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:n&&n>="2026-01-30"?"head":"body",internal_or_test_user_hostname:n&&n>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:n&&n>="2026-05-30"?250:0,split_storage:!(!n||"2026-05-30">n),detect_google_search_app:!(!n||"2026-05-30">n),disable_capture_url_hashes:!(!n||"2026-06-25">n)}))(t))},PTn=[["process_person","person_profiles"],["xhr_headers","request_headers"],["cookie_name","persistence_name"],["disable_cookie","disable_persistence"],["__preview_disable_beacon","disable_beacon"],["store_google","save_campaign_params"],["verbose","debug"]],_ct=t=>{var e={};for(var n of PTn){var o=n[0],i=n[1];To(t[o])||(e[i]=t[o])}var r=jg({},e,t),A=t.__preview_external_dependency_versioned_paths;return To(A)||(To(t.strict_script_versioning)&&(r.strict_script_versioning=!!A),Xl(A)&&To(t.asset_host)&&(r.asset_host=A)),bs(t.property_blacklist)&&(To(t.property_denylist)?r.property_denylist=t.property_blacklist:bs(t.property_denylist)?r.property_denylist=[...t.property_blacklist,...t.property_denylist]:wo.error(uct+t.property_denylist)),r};class vTn{constructor(){this.__forceAllowLocalhost=!1}get Fi(){return this.__forceAllowLocalhost}set Fi(e){wo.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class A2{Ai(e,n){if(e){var o=this.$i.indexOf(e);o!==-1&&this.$i.splice(o,1)}return this.$i.push(n),n.initialize==null||n.initialize(),n}Ni(){return this.config.cookieless_mode===VS||this.config.cookieless_mode===gP&&this.consent.isRejected()}get decideEndpointWasHit(){var e,n;return(e=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,n;return(e=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){var e;this.webPerformance=new vTn,this.Di=!1,this.version=Au.LIB_VERSION,this.qi=new pIe,this.$i=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=dct(),this.SentryIntegration=ZRn,this.sentryIntegration=o=>(function(i,r){var A=Sat(i,r);return{name:Qat,processEvent:s=>A(s)}})(this,o),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.ji=!1,this.Bi=null,this.Hi=null,this.Ui=null,this.scrollManager=new ETn(this),this.pageViewManager=new bat(this),this.rateLimiter=new cTn(this),this.requestRouter=new QTn(this),this.consent=new HRn(this),this.externalIntegrations=new wTn(this);var n=(e=A2.__defaultExtensionClasses)!==null&&e!==void 0?e:{};this.featureFlags=n.featureFlags&&new n.featureFlags(this),this.toolbar=n.toolbar&&new n.toolbar(this),this.surveys=n.surveys&&new n.surveys(this),this.conversations=n.conversations&&new n.conversations(this),this.logs=n.logs&&new n.logs(this),this.metrics=n.metrics&&new n.metrics(this),this.experiments=n.experiments&&new n.experiments(this),this.exceptions=n.exceptions&&new n.exceptions(this),this.people={set:(o,i,r)=>{var A=Xl(o)?{[o]:i}:o;this.setPersonProperties(A),r?.({})},set_once:(o,i,r)=>{var A=Xl(o)?{[o]:i}:o;this.setPersonProperties(void 0,A),r?.({})}},this.on("eventCaptured",(o=>wo.info('send "'+o?.event+'"',o)))}init(e,n,o){if(o&&o!==Q9){var i,r=(i=SL[o])!==null&&i!==void 0?i:new A2;return r._init(e,n,o),SL[o]=r,SL[Q9][o]=r,r}return this._init(e,n,o)}_init(e,n,o){var i,r;n===void 0&&(n={});var A=Xl(e)?e.trim():"";if(!A)return wo.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={},n.debug=this.zi(n.debug),this.Wi=n,this.Vi=[],n.person_profiles?this.Hi=n.person_profiles:n.process_person&&(this.Hi=n.process_person);var s=dct(n.defaults),a=_ct(n),c=jg({},s,a,{name:o,token:A});P0(s.rageclick)&&P0(a.rageclick)&&(c.rageclick=jg({},s.rageclick,a.rageclick)),P0(s.session_recording)&&P0(a.session_recording)&&(c.session_recording=jg({},s.session_recording,a.session_recording)),this.set_config(c),this.config.on_xhr_error&&wo.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=n.disable_compression?void 0:WC.GZipJS;var l=this.Zi();this.persistence=new tIe(this.config,l),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new tIe(fo({},this.config,{persistence:"sessionStorage"}),l,!1);var g=fo({},this.persistence.props),u=fo({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Gi=new CTn((f=>this.Qi(f)),this.config.request_queue_config),this.Ji=new yTn(this),this.__request_queue=[];var d=this.Ni();if(d||(this.sessionManager=new nct(this),this.sessionPropsManager=new tct(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(wo.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.Ki(d)}),0)):(wo.info("Initializing extensions synchronously"),this.Ki(d)),Au.DEBUG=Au.DEBUG||this.config.debug,Au.DEBUG&&wo.info("Starting in debug mode",{this:this,config:n,thisC:fo({},this.config),p:g,s:u}),!this.config.identity_distinct_id||(i=n.bootstrap)!=null&&i.distinctID||(n.bootstrap=fo({},n.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),((r=n.bootstrap)==null?void 0:r.distinctID)!==void 0){var h=n.bootstrap.distinctID,_=this.get_distinct_id(),p=this.persistence.get_property(IB);if(n.bootstrap.isIdentifiedID&&_!=null&&_!==h&&p===m9)this.identify(h);else if(n.bootstrap.isIdentifiedID&&_!=null&&_!==h&&p===p9)wo.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 m=this.config.get_device_id(zS()),I=n.bootstrap.isIdentifiedID?m:h;this.persistence.set_property(IB,n.bootstrap.isIdentifiedID?p9:m9),this.register({distinct_id:h,$device_id:I})}}if(d)this.register_once({distinct_id:eX,$device_id:null},"");else if(!this.get_distinct_id()){var C=this.config.get_device_id(zS());this.register_once({distinct_id:C,$device_id:C},""),this.persistence.set_property(IB,m9)}return au(wn,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),n.segment?(function(f,y){var B=f.config.segment;if(!B)return y();(function(x,S){var M=x.config.segment;if(!M)return S();var w=N=>{var G=()=>N.anonymousId()||zS();x.config.get_device_id=G,N.id()&&(x.register({distinct_id:N.id(),$device_id:G()}),x.persistence.set_property(IB,p9)),S()},k=M.user();"then"in k&&pB(k.then)?k.then(w):w(k)})(f,(()=>{B.register((x=>{typeof Promise<"u"&&Promise.resolve||eIe.warn("This browser does not have Promise support, and can not use the segment integration");var S=(M,w)=>{if(!w)return M;M.event.userId||M.event.anonymousId===x.get_distinct_id()||(eIe.info("No userId set, resetting PostHog"),x.reset()),M.event.userId&&M.event.userId!==x.get_distinct_id()&&(eIe.info("UserId set, identifying with PostHog"),x.identify(M.event.userId));var k=x.calculateEventProperties(w,M.event.properties);return M.event.properties=Object.assign({},k,M.event.properties),M};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:M=>S(M,M.event.event),page:M=>S(M,I9),identify:M=>S(M,Vpe),screen:M=>S(M,"$screen")}})(f)).then((()=>{y()}))}))})(this,(()=>this.Yi())):this.Yi(),pB(this.config._onCapture)&&this.config._onCapture!==IX&&(wo.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(f=>this.config._onCapture(f.event,f)))),this.config.ip&&wo.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.config.disableDeviceModel||(function(){return ict.apply(this,arguments)})().then((f=>{f&&this.register({[ype]:f})})).catch(IX),this}Ki(e){var n,o,i,r,A,s,a,c,l=performance.now(),g=fo({},A2.__defaultExtensionClasses,this.config.__extensionClasses),u=[];g.featureFlags&&this.$i.push(this.featureFlags=(n=this.featureFlags)!==null&&n!==void 0?n:new g.featureFlags(this)),g.exceptions&&this.$i.push(this.exceptions=(o=this.exceptions)!==null&&o!==void 0?o:new g.exceptions(this)),g.historyAutocapture&&this.$i.push(this.historyAutocapture=new g.historyAutocapture(this)),g.tracingHeaders&&this.$i.push(this.tracingHeaders=new g.tracingHeaders(this)),g.siteApps&&this.$i.push(this.siteApps=new g.siteApps(this)),g.sessionRecording&&!e&&this.$i.push(this.sessionRecording=new g.sessionRecording(this)),this.config.disable_scroll_properties||u.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),g.autocapture&&this.$i.push(this.autocapture=new g.autocapture(this)),g.surveys&&this.$i.push(this.surveys=(i=this.surveys)!==null&&i!==void 0?i:new g.surveys(this)),g.logs&&this.$i.push(this.logs=(r=this.logs)!==null&&r!==void 0?r:new g.logs(this)),g.metrics&&this.$i.push(this.metrics=(A=this.metrics)!==null&&A!==void 0?A:new g.metrics(this)),g.conversations&&this.$i.push(this.conversations=(s=this.conversations)!==null&&s!==void 0?s:new g.conversations(this)),g.productTours&&this.$i.push(this.productTours=new g.productTours(this)),g.heatmaps&&this.$i.push(this.heatmaps=new g.heatmaps(this)),g.webVitalsAutocapture&&this.$i.push(this.webVitalsAutocapture=new g.webVitalsAutocapture(this)),g.exceptionObserver&&this.$i.push(this.exceptionObserver=new g.exceptionObserver(this)),g.deadClicksAutocapture&&this.$i.push(this.deadClicksAutocapture=new g.deadClicksAutocapture(this,$Rn)),g.toolbar&&this.$i.push(this.toolbar=(a=this.toolbar)!==null&&a!==void 0?a:new g.toolbar(this)),g.experiments&&this.$i.push(this.experiments=(c=this.experiments)!==null&&c!==void 0?c:new g.experiments(this)),this.$i.forEach((d=>{d.initialize&&u.push((()=>{d.initialize==null||d.initialize()}))})),u.push((()=>{if(this.Xi){var d=this.Xi;this.Xi=void 0,this.Mr(d)}})),this.en(u,l)}en(e,n){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-n>=30&&e.length>0)return void setTimeout((()=>{this.en(e,n)}),0);var o=e.shift();if(o)try{o()}catch(r){wo.error("Error initializing extension:",r)}}var i=Math.round(performance.now()-n);this.register_for_session({[Xst]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[$st]:i}),this.config.__preview_deferred_init_extensions&&wo.info("PostHog extensions initialized ("+i+"ms)")}Mr(e){var n;if(!Zo||!Zo.body)return wo.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.Mr(e)}),500);this.config.__preview_deferred_init_extensions&&(this.Xi=e),this.tn=e,this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=gA(e.supportedCompression,WC.GZipJS)?WC.GZipJS:gA(e.supportedCompression,WC.Base64)?WC.Base64:void 0),(n=e.analytics)!=null&&n.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Hi?this.Hi:Upe}),this.$i.forEach((o=>o.onRemoteConfig==null?void 0:o.onRemoteConfig(e)))}Yi(){try{this.config.loaded(this)}catch(o){wo.critical("`loaded` function failed",o)}if(this.rn(),this.config.internal_or_test_user_hostname&&rd!=null&&rd.hostname){var e=rd.hostname,n=this.config.internal_or_test_user_hostname;(typeof n=="string"?e===n:n.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.Ni())&&this.nn()}),1),this.sn=new Gat(this),this.sn.load()}rn(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Gi)==null||e.enable())}_dom_loaded(){this.is_capturing()&&oX(this.__request_queue,(e=>this.Qi(e))),this.__request_queue=[],this.rn()}_handle_unload(){var e,n,o,i,r;(e=this.surveys)==null||e.handlePageUnload==null||e.handlePageUnload(),(n=this.metrics)==null||n.flush("sendBeacon"),this.config.request_batching?(this.an()&&this.capture(Ype),(o=this.logs)==null||o.flushLogs("sendBeacon"),(i=this.Gi)==null||i.unload(),(r=this.Ji)==null||r.unload()):this.an()&&this.capture(Ype,null,{transport:"sendBeacon"})}_send_request(e){this.__loaded?hct?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)?e.fireCallbackOnDrop&&(e.callback==null||e.callback({statusCode:429})):(e.transport=e.transport||this.config.api_transport,e.headers=fo({},this.config.request_headers,e.headers),e.compression=e.compression==="best-available"?this.compression:e.compression,(To(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(n=>{var o,i,r,A=fo({},n);A.timeout=A.timeout||6e4;var s=(o=A.transport)!==null&&o!==void 0?o:"fetch";s==="sendBeacon"&&To(A.compression)&&A.data&&(A.compression=WC.Base64),A.url=ect(A.url,A.compression);var a=_X.filter((l=>!A.disableTransport||!l.transport||!A.disableTransport.includes(l.transport))),c=(i=(r=(function(l,g){for(var u=0;l.length>u;u++)if(l[u].transport===s)return l[u]})(a))==null?void 0:r.method)!==null&&i!==void 0?i:a[0].method;if(!c)throw new Error("No available transport method");s!=="sendBeacon"&&A.data&&A.compression===WC.GZipJS&&TNn&&typeof Promise<"u"&&!dX?mTn(A).then((l=>{c(l)})).catch((l=>{if(ost(l))return dX=!0,void c(fo({},A,{compression:void 0,url:ect(n.url,void 0)}));(g=>{if(!g||typeof g!="object")return!1;var u="name"in g?String(g.name):"";return ost(g)||u===tst})(l)&&(dX=!0),c(A)})):c(A)})(fo({},e,{callback:n=>{var o,i;this.rateLimiter.checkForLimiting(n),400>n.statusCode||(o=(i=this.config).on_request_error)==null||o.call(i,n),e.callback==null||e.callback(n)}}))):e.fireCallbackOnDrop&&(e.callback==null||e.callback({statusCode:0}))}Qi(e){this.Ji?this.Ji.retriableRequest(e):this._send_request(e)}_execute_array(e){fIe++;try{var n,o=[],i=[],r=[];oX(e,(s=>{if(s)if(bs(n=s[0]))r.push(s);else if(pB(s))try{s.call(this)}catch(a){wo.error("Error executing queued PostHog call",s,a)}else bs(s)&&n==="alias"?o.push(s):bs(s)&&n.indexOf("capture")!==-1&&pB(this[n])?r.push(s):i.push(s)}));var A=function(s,a){oX(s,(function(c){try{if(bs(c[0])){var l=a;pg(c,(function(g){l=l[g[0]].apply(l,g.slice(1))}))}else a[c[0]].apply(a,c.slice(1))}catch(g){wo.error("Error executing queued PostHog call",c,g)}}))};A(o,this),A(i,this),A(r,this)}finally{fIe--}}push(e){if(fIe>0&&bs(e)&&Xl(e[0])){var n=A2.prototype[e[0]];pB(n)&&n.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,n,o){var i,r,A,s,a;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Gi){if(this.is_capturing())if(!To(e)&&Xl(e)){var c=!this.config.opt_out_useragent_filter&&this._is_bot();if(!c||this.config.__preview_capture_bot_pageviews){var l=o!=null&&o.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(l==null||!l.isRateLimited){n!=null&&n.$current_url&&!Xl(n?.$current_url)&&(wo.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),n==null||delete n.$current_url),e!=="$exception"||o!=null&&o.ln||wo.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 g=new Date,u=o?.timestamp||g,d=vst(o?.uuid,zS),h={uuid:d,event:e,properties:this.calculateEventProperties(e,n||{},u,d)};e===I9&&this.config.__preview_capture_bot_pageviews&&c&&(h.event="$bot_pageview",h.properties.$browser_type="bot"),l&&(h.properties.$lib_rate_limit_remaining_tokens=l.remainingTokens),o?.$set&&(h.$set=o?.$set);var _=o?.$unset;_&&(h.$unset=_);var p,m,I,C=this.un(o?.$set_once,e!==eat,e===Vpe);if(C&&(h.$set_once=C),o!=null&&o._noTruncate||(r=this.config.properties_string_max_length,A=h,s=w=>Xl(w)?w.slice(0,r):w,a=new Set,h=(function w(k,N){return k!==Object(k)?s?s(k):k:a.has(k)?void 0:(a.add(k),bs(k)?(G=[],oX(k,(H=>{G.push(w(H))}))):(G={},pg(k,((H,U)=>{a.has(H)||(G[U]=w(H))}))),G);var G})(A)),h.timestamp=u,To(o?.timestamp)||(h.properties.$event_time_override_provided=!0,h.properties.$event_time_override_system_time=g),e===JS.DISMISSED||e===JS.SENT){var f=n?.[oIe.SURVEY_ID],y=n?.[oIe.SURVEY_ITERATION];cct({id:f,current_iteration:y}),h.$set=fo({},h.$set,{[(p={id:f,current_iteration:y},m=e===JS.SENT?"responded":"dismissed",I="$survey_"+m+"/"+p.id,p.current_iteration&&p.current_iteration>0&&(I="$survey_"+m+"/"+p.id+"/"+p.current_iteration),I)]:!0})}else e===JS.SHOWN&&(h.$set=fo({},h.$set,{[oIe.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(e===aTn.SHOWN){var B=n?.[Lat.TOUR_TYPE];B&&(h.$set=fo({},h.$set,{[Lat.TOUR_LAST_SEEN_DATE+"/"+B]:new Date().toISOString()}))}var x=fo({},h.properties.$set,h.$set);if(Ob(x)||this.setPersonPropertiesForFlags(x),!as(this.config.before_send)){var S=this.it(h);if(!S)return;(h=S).uuid=vst(h.uuid,zS)}this.qi.emit("eventCaptured",h);var M={method:"POST",url:(i=o?._url)!==null&&i!==void 0?i:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:h,compression:"best-available",batchKey:o?._batchKey,transport:o?.transport};return!this.config.request_batching||o&&(o==null||!o._batchKey)||o!=null&&o.send_instantly?this.Qi(M):this.Gi.enqueue(M),h}wo.critical("This capture call is ignored due to client rate limiting.")}}else wo.error("No event name provided to posthog.capture")}else wo.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(n=>e(n.event,n)))}calculateEventProperties(e,n,o,i,r){if(o=o||new Date,!this.persistence||!this.sessionPersistence)return n;var A=r?void 0:this.persistence.remove_event_timer(e),s=fo({},n);if(s.token=this.config.token,s.$config_defaults=this.config.defaults,this.Ni()&&(s.$cookieless_mode=!0),e==="$snapshot"){var a=fo({},this.persistence.properties(),this.sessionPersistence.properties());return s.distinct_id=a.distinct_id,(!Xl(s.distinct_id)&&!Dp(s.distinct_id)||ipe(s.distinct_id))&&wo.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),s}var c,l=(function(m,I,C,f){var y,B,x,S;if(f===void 0&&(f=!1),!y1)return{};var M,w,k,N,G,H,U,J,W,X=m?[...f9,...I||[]]:[],oe=(function(ae){for(var re=0;wst.length>re;re++){var le=wst[re],ye=le[1],xe=le[0].exec(ae),be=xe&&(pB(ye)?ye(xe,ae):ye);if(be)return be}return["",""]})(y1),ce=(M=typeof navigator<"u"?navigator:void 0)!=null&&M.brave?{brave:!0}:{},te={detectGoogleSearchApp:C},ie=jg(zpe({$os:oe[0],$os_version:oe[1],$browser:Mst(y1,navigator.vendor,ce,te),$device:Pst(y1),$device_type:(k=y1,N={userAgentDataPlatform:(y=navigator)==null||(y=y.userAgentData)==null?void 0:y.platform,maxTouchPoints:(B=navigator)==null?void 0:B.maxTouchPoints,screenWidth:wn==null||(x=wn.screen)==null?void 0:x.width,screenHeight:wn==null||(S=wn.screen)==null?void 0:S.height,devicePixelRatio:wn?.devicePixelRatio},W=Pst(k),W===lst||W===cst||W==="Kobo"||W==="Kindle Fire"||W===xst?c9:W===iL||W===u9||W===rL||W===gpe?"Console":W===ust?"Wearable":W?Ty:N?.userAgentDataPlatform==="Android"&&((G=N?.maxTouchPoints)!==null&&G!==void 0?G:0)>0?600>Math.min((H=N?.screenWidth)!==null&&H!==void 0?H:0,(U=N?.screenHeight)!==null&&U!==void 0?U:0)/((J=N?.devicePixelRatio)!==null&&J!==void 0?J:1)?Ty:c9:"Desktop"),$timezone:Fat(),$timezone_offset:iTn()}),{$current_url:IL(f?Kb(rd?.href):rd?.href,X,CL),$host:rd?.host,$pathname:rd?.pathname,$raw_user_agent:y1.length>1e3?y1.substring(0,997)+"...":y1,$browser_version:eRn(y1,navigator.vendor,ce,te),$browser_language:Nat(),$browser_language_prefix:(w=Nat(),typeof w=="string"?w.split("-")[0]:void 0),$screen_height:wn?.screen.height,$screen_width:wn?.screen.width,$viewport_height:wn?.innerHeight,$viewport_width:wn?.innerWidth,$lib:Au.LIB_NAME,$lib_version:Au.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return Au.SDK_DIST_CHANNEL&&(ie.$sdk_dist_channel=Au.SDK_DIST_CHANNEL),ie})(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){var g=this.sessionManager.checkAndGetSessionAndWindowId(r,o.getTime()),u=g.windowId;s.$session_id=g.sessionId,s.$window_id=u}this.sessionPropsManager&&jg(s,this.sessionPropsManager.getSessionProps());try{var d;this.sessionRecording&&jg(s,this.sessionRecording.sdkDebugProperties),s.$sdk_debug_retry_queue_size=(d=this.Ji)==null?void 0:d.length}catch(m){s.$sdk_debug_error_capturing_properties=String(m)}if(this.requestRouter.region===IIe&&(s.$lib_custom_api_host=this.config.api_host),c=e!==I9||r?e!==Ype||r?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(o):this.pageViewManager.doPageView(o,i),s=jg(s,c),e===I9&&Zo&&(s.title=Zo.title),!To(A)){var h=o.getTime()-A;s.$duration=parseFloat((h/1e3).toFixed(3))}y1&&this.config.opt_out_useragent_filter&&(s.$browser_type=this._is_bot()?"bot":"browser"),(s=jg({},l,this.persistence.properties(),this.sessionPersistence.properties(),s)).$is_identified=this._isIdentified(),bs(this.config.property_denylist)?pg(this.config.property_denylist,(function(m){delete s[m]})):wo.error(uct+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var _=this.config.sanitize_properties;_&&(wo.error(gct),s=_(s,e));var p=this.hn();return s.$process_person_profile=p,p&&!r&&this.dn("_calculate_event_properties"),s}un(e,n,o){var i;if(n===void 0&&(n=!0),o===void 0&&(o=!1),!this.persistence||!this.hn()||this.Di&&!o)return e;var r=this.persistence.get_initial_props(),A=(i=this.sessionPropsManager)==null?void 0:i.getSetOnceProps(),s=jg({},r,A||{},e||{}),a=this.config.sanitize_properties;return a&&(wo.error(gct),s=a(s,"$set_once")),n&&(this.Di=!0),Ob(s)?void 0:s}register(e,n){var o;(o=this.persistence)==null||o.register(e,n)}register_once(e,n,o){var i;(i=this.persistence)==null||i.register_once(e,n,o)}register_for_session(e){var n;(n=this.sessionPersistence)==null||n.register(e)}unregister(e){var n;(n=this.persistence)==null||n.unregister(e)}unregister_for_session(e){var n;(n=this.sessionPersistence)==null||n.unregister(e)}cn(e,n){this.register({[e]:n})}getFeatureFlag(e,n){var o;return(o=this.featureFlags)==null?void 0:o.getFeatureFlag(e,n)}getFeatureFlagPayload(e){var n;return(n=this.featureFlags)==null?void 0:n.getFeatureFlagPayload(e)}getFeatureFlagResult(e,n){var o;return(o=this.featureFlags)==null?void 0:o.getFeatureFlagResult(e,n)}getAllFeatureFlags(){var e,n;return(e=(n=this.featureFlags)==null?void 0:n.getAllFeatureFlags())!==null&&e!==void 0?e:[]}isFeatureEnabled(e,n){var o;return(o=this.featureFlags)==null?void 0:o.isFeatureEnabled(e,n)}reloadFeatureFlags(){var e;(e=this.featureFlags)==null||e.reloadFeatureFlags()}updateFlags(e,n,o){var i;(i=this.featureFlags)==null||i.updateFlags(e,n,o)}updateEarlyAccessFeatureEnrollment(e,n,o){var i;(i=this.featureFlags)==null||i.updateEarlyAccessFeatureEnrollment(e,n,o)}getEarlyAccessFeatures(e,n,o){var i;return n===void 0&&(n=!1),(i=this.featureFlags)==null?void 0:i.getEarlyAccessFeatures(e,n,o)}on(e,n){return this.qi.on(e,n)}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:bL}),()=>{})}onSessionId(e){var n,o;return(n=(o=this.sessionManager)==null?void 0:o.onSessionId(e))!==null&&n!==void 0?n:()=>{}}getSurveys(e,n){n===void 0&&(n=!1),this.surveys?this.surveys.getSurveys(e,n):e([],{isLoaded:!1,error:bL})}getActiveMatchingSurveys(e,n){n===void 0&&(n=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,n):e([],{isLoaded:!1,error:bL})}renderSurvey(e,n){var o;(o=this.surveys)==null||o.renderSurvey(e,n)}displaySurvey(e,n){var o;n===void 0&&(n=bTn),(o=this.surveys)==null||o.displaySurvey(e,n)}cancelPendingSurvey(e){var n;(n=this.surveys)==null||n.cancelPendingSurvey(e)}canRenderSurvey(e){var n,o;return(n=(o=this.surveys)==null?void 0:o.canRenderSurvey(e))!==null&&n!==void 0?n:{visible:!1,disabledReason:bL}}canRenderSurveyAsync(e,n){var o,i;return n===void 0&&(n=!1),(o=(i=this.surveys)==null?void 0:i.canRenderSurveyAsync(e,n))!==null&&o!==void 0?o:Promise.resolve({visible:!1,disabledReason:bL})}vn(e){return!e||ipe(e)?(wo.critical("Unique user id has not been set in posthog.identify"),!1):e===eX?(wo.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())||(wo.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,n,o){if(!this.__loaded||!this.persistence)return wo.uninitializedWarning("posthog.identify");if(Dp(e)&&(e=e.toString(),wo.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this.vn(e)&&this.dn("posthog.identify")){var i=this.get_distinct_id();this.register({$user_id:e}),this.get_property(qj)||this.register_once({$had_persisted_distinct_id:!0,$device_id:i},""),e!==i&&e!==this.get_property(aL)&&(this.unregister(aL),this.register({distinct_id:e}));var r,A=(this.persistence.get_property(IB)||m9)===m9;e!==i&&A?(this.persistence.set_property(IB,p9),this.setPersonPropertiesForFlags({$set:n||{},$set_once:o||{}},!1),this.capture(Vpe,{distinct_id:e,$anon_distinct_id:i},{$set:n||{},$set_once:o||{}}),this.Ui=rct(e,n,o),(r=this.featureFlags)==null||r.setAnonymousDistinctId(i)):(n||o)&&this.setPersonProperties(n,o),e!==i&&(this.reloadFeatureFlags(),this.unregister(uL))}}setPersonProperties(e,n){if((e||n)&&this.dn("posthog.setPersonProperties")){var o=rct(this.get_distinct_id(),e,n);this.Ui!==o?(this.setPersonPropertiesForFlags({$set:e||{},$set_once:n||{}},!0),this.capture("$set",{$set:e||{},$set_once:n||{}}),this.Ui=o):wo.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(e){var n,o=(bs(e)?e:[e]).filter((i=>Xl(i)&&i.length>0));o.length!==0&&this.dn("posthog.unsetPersonProperties")&&((n=this.featureFlags)==null||n.unsetPersonPropertiesForFlags(o,!0),this.capture("$set",{$unset:o}),this.Ui=null)}group(e,n,o){if(e&&n){var i=this.getGroups(),r=i[e]!==n;if(r&&this.resetGroupPropertiesForFlags(e),this.register({$groups:fo({},i,{[e]:n})}),r||o){var A={$group_type:e,$group_key:n};o&&(A.$group_set=o),this.capture(eat,A)}o&&this.setGroupPropertiesForFlags({[e]:o}),r&&!o&&this.reloadFeatureFlags()}else wo.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,n){var o;n===void 0&&(n=!0),(o=this.featureFlags)==null||o.setPersonPropertiesForFlags(e,n)}resetPersonPropertiesForFlags(e){var n;e===void 0&&(e=!0),(n=this.featureFlags)==null||n.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,n){var o;n===void 0&&(n=!0),this.dn("posthog.setGroupPropertiesForFlags")&&((o=this.featureFlags)==null||o.setGroupPropertiesForFlags(e,n))}resetGroupPropertiesForFlags(e){var n;(n=this.featureFlags)==null||n.resetGroupPropertiesForFlags(e)}reset(e){var n,o,i,r,A,s,a,c,l,g;if(wo.info("reset"),!this.__loaded)return wo.uninitializedWarning("posthog.reset");var u,d=this.get_property(qj),h=this.get_property(ype),_=this.get_property(sP);if(this.consent.reset(),(n=this.persistence)==null||n.clear(),(o=this.sessionPersistence)==null||o.clear(),To(_)||(u=this.persistence)==null||u.register({[sP]:_}),(i=this.surveys)==null||i.reset(),(r=this.sn)==null||r.stop(),(A=this.featureFlags)==null||A.reset(),(s=this.conversations)==null||s.reset(),(a=this.logs)==null||a.reset(),(c=this.metrics)==null||c.reset(),(l=this.persistence)==null||l.set_property(IB,m9),(g=this.sessionManager)==null||g.resetSessionId(),this.Ui=null,this.config.cookieless_mode===VS)this.register_once({distinct_id:eX,$device_id:null},"");else{var p=this.config.get_device_id(zS());this.register_once({distinct_id:p,$device_id:e?p:d},""),e||To(h)||this.register({[ype]:h})}this.register({$last_posthog_reset:new Date().toISOString()},1),delete this.config.identity_distinct_id,delete this.config.identity_hash,this.reloadFeatureFlags()}shutdown(e){var n=this;return Ih((function*(){var o,i,r,A,s;n.__loaded?((o=n.logs)==null||o.flushLogs("sendBeacon"),(i=n.metrics)==null||i.flush("sendBeacon"),(r=n.Gi)==null||r.unload(),(A=n.Ji)==null||A.unload(),(s=n.featureFlags)==null||s.destroy()):wo.uninitializedWarning("posthog.shutdown")}))()}setIdentity(e,n){var o;this.config.identity_distinct_id=e,this.config.identity_hash=n,this.alias(e),(o=this.conversations)==null||o.fn()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,(e=this.conversations)==null||e.pn()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,n;return(e=(n=this.sessionManager)==null?void 0:n.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var n=this.sessionManager.checkAndGetSessionAndWindowId(!0),o=n.sessionStartTimestamp,i=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+n.sessionId);if(e!=null&&e.withTimestamp&&o){var r,A=(r=e.timestampLookBack)!==null&&r!==void 0?r:10;if(!o)return i;i+="?t="+Math.max(Math.floor((new Date().getTime()-o)/1e3)-A,0)}return i}alias(e,n){return e===this.get_property(Yst)?(wo.critical("Attempting to create alias for existing People user - aborting."),-2):this.dn("posthog.alias")?(To(n)&&(n=this.get_distinct_id()),e!==n?(this.cn(aL,e),this.capture("$create_alias",{alias:e,distinct_id:n})):(wo.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var n=fo({},this.config);if(P0(e)){var o,i,r,A,s,a,c,l,g,u,d;jg(this.config,_ct(e));var h=this.Zi();(o=this.persistence)==null||o.update_config(this.config,n,h),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new tIe(fo({},this.config,{persistence:"sessionStorage"}),h,!1);var _=this.zi(this.config.debug);Wx(_)&&(this.config.debug=_),Wx(this.config.debug)&&(this.config.debug?(Au.DEBUG=!0,Ig.N()&&Ig.q("ph_debug",!0),wo.info("set_config",{config:e,oldConfig:n,newConfig:fo({},this.config)})):(Au.DEBUG=!1,Ig.N()&&Ig.P("ph_debug"))),(i=this.exceptionObserver)==null||i.onConfigChange(),(r=this.exceptions)==null||r.onConfigChange(),(A=this.sessionRecording)==null||A.startIfEnabledOrStop(),(s=this.tracingHeaders)==null||s.startIfEnabledOrStop(),(a=this.autocapture)==null||a.startIfEnabled(),(c=this.heatmaps)==null||c.startIfEnabled(),(l=this.exceptionObserver)==null||l.startIfEnabledOrStop(),(g=this.deadClicksAutocapture)==null||g.startIfEnabledOrStop(),(u=this.surveys)==null||u.loadIfEnabled(),this.gn(),(d=this.externalIntegrations)==null||d.startIfEnabledOrStop()}}_overrideSDKInfo(e,n){Au.LIB_NAME=e,Au.LIB_VERSION=n}startSessionRecording(e){var n,o,i,r,A,s=e===!0,a={sampling:s||!(e==null||!e.sampling),linked_flag:s||!(e==null||!e.linked_flag),url_trigger:s||!(e==null||!e.url_trigger),event_trigger:s||!(e==null||!e.event_trigger)};Object.values(a).some(Boolean)&&((n=this.sessionManager)==null||n.checkAndGetSessionAndWindowId(),a.sampling&&((o=this.sessionRecording)==null||o.overrideSampling()),a.linked_flag&&((i=this.sessionRecording)==null||i.overrideLinkedFlag()),a.url_trigger&&((r=this.sessionRecording)==null||r.overrideTrigger("url")),a.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,n){if(this.exceptions){var o=new Error("PostHog syntheticException"),i=this.exceptions.buildProperties(e,{handled:!0,syntheticException:o});return this.exceptions.sendExceptionEvent(fo({},i,n))}}addExceptionStep(e,n){var o;(o=this.exceptions)==null||o.addExceptionStep(e,n)}captureLog(e){var n;(n=this.logs)==null||n.captureLog(e)}get logger(){var e,n;return(e=(n=this.logs)==null?void 0:n.logger)!==null&&e!==void 0?e:A2.mn}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var n,o;return(n=(o=this.toolbar)==null?void 0:o.loadToolbar(e))!==null&&n!==void 0&&n}get_property(e){var n;return(n=this.persistence)==null?void 0:n.props[e]}getSessionProperty(e){var n;return(n=this.sessionPersistence)==null?void 0:n.props[e]}toString(){var e,n=(e=this.config.name)!==null&&e!==void 0?e:Q9;return n!==Q9&&(n=Q9+"."+n),n}_isIdentified(){var e,n;return((e=this.persistence)==null?void 0:e.get_property(IB))===p9||((n=this.sessionPersistence)==null?void 0:n.get_property(IB))===p9}hn(){var e,n;return!(this.config.person_profiles==="never"||this.config.person_profiles===Upe&&!this._isIdentified()&&Ob(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[aL])&&((n=this.persistence)==null||(n=n.props)==null||!n[Zj]))}an(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&(this.config.capture_pageview===!0||this.config.capture_pageview==="history_change")}createPersonProfile(){this.hn()||this.dn("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.dn("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}dn(e){return this.config.person_profiles==="never"?(wo.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.cn(Zj,!0),!0)}Zi(){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!==gP)}gn(){var e,n,o,i,r=this.Zi();return((e=this.persistence)==null?void 0:e.ir)!==r&&((o=this.persistence)==null||o.set_disabled(r)),((n=this.sessionPersistence)==null?void 0:n.ir)!==r&&((i=this.sessionPersistence)==null||i.set_disabled(r)),r}opt_in_capturing(e){var n;if(this.config.cookieless_mode!==VS){if(this.Ni()){var o,i,r,A,s;this.reset(!0),(o=this.sessionManager)==null||o.destroy(),(i=this.pageViewManager)==null||i.destroy(),this.sessionManager=new nct(this),this.pageViewManager=new bat(this),this.persistence&&(this.sessionPropsManager=new tct(this,this.sessionManager,this.persistence));var a,c=(r=(A=this.config.__extensionClasses)==null?void 0:A.sessionRecording)!==null&&r!==void 0?r:(s=A2.__defaultExtensionClasses)==null?void 0:s.sessionRecording;c&&(this.sessionRecording=this.Ai(this.sessionRecording,new c(this)),this.tn&&((a=this.sessionRecording)==null||a.onRemoteConfig==null||a.onRemoteConfig(this.tn)))}var l,g;this.consent.optInOut(!0),this.gn(),this.rn(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),this.config.cookieless_mode==gP&&((l=this.surveys)==null||l.loadIfEnabled()),(To(e?.captureEventName)||e!=null&&e.captureEventName)&&this.capture((g=e?.captureEventName)!==null&&g!==void 0?g:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.nn()}else wo.warn(lct)}opt_out_capturing(){var e,n,o;this.config.cookieless_mode!==VS?(this.config.cookieless_mode===gP&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.gn(),this.config.cookieless_mode===gP&&(this.register({distinct_id:eX,$device_id:null}),(e=this.sessionRecording)==null||e.stopRecording(),this.sessionRecording=void 0,(n=this.sessionManager)==null||n.destroy(),(o=this.pageViewManager)==null||o.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.nn(),this.rn())):wo.warn(lct)}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===VS||(this.config.cookieless_mode===gP?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.gn()}_is_bot(){return JC?oct(JC,this.config.custom_blocked_useragents):void 0}nn(){Zo&&(Zo.visibilityState==="visible"?this.ji||(this.ji=!0,this.capture(I9,{title:Zo.title},{send_instantly:!0}),this.Bi&&(Zo.removeEventListener(tX,this.Bi),this.Bi=null)):this.Bi||(this.Bi=this.nn.bind(this),au(Zo,tX,this.Bi)))}debug(e){e===!1?(wn?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(wn?.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}))}Rr(){var e,n,o,i,r,A,s=this.Wi||{};return"advanced_disable_flags"in s?!!s.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(wo.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):(o="advanced_disable_decide",i=wo,r=(n="advanced_disable_flags")in(e=s)&&!as(e[n]),A=o in e&&!as(e[o]),r?e[n]:!!A&&(i&&i.warn("Config field '"+o+"' is deprecated. Please use '"+n+"' instead. The old field will be removed in a future major version."),e[o]))}it(e){var n;if(as(this.config.before_send))return e;var o=Object.keys((n=e.properties)!==null&&n!==void 0?n:{}).filter(KNn),i=bs(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(var A of i){if(r=A(r),as(r)){var s="Event '"+e.event+"' was rejected in beforeSend function";return ONn(e.event)?wo.warn(s+". This can cause unexpected behavior."):wo.info(s),null}r.properties&&!Ob(r.properties)||wo.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}for(var a of o)if(r.properties&&as(r.properties[a]))return wo.warn("Event '"+e.event+"' had its '"+a+"' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped."),null;return r}getPageViewId(){var e;return(e=this.pageViewManager.zt)==null?void 0:e.pageViewId}captureTraceFeedback(e,n){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:n})}captureTraceMetric(e,n,o){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:n,$ai_metric_value:String(o)})}zi(e){var n=Wx(e)&&!e,o=Ig.N()&&Ig.A("ph_debug")==="true";return!n&&(!!o||e)}}A2.__defaultExtensionClasses={},A2.mn=(()=>{var t=()=>{};return{trace:t,debug:t,info:t,warn:t,error:t,fatal:t}})(),(function(t,e){for(var n=0;e.length>n;n++)t.prototype[e[n]]=wRn(t.prototype[e[n]])})(A2,["identify"]);class mct{constructor(e){this.disabled=e===!1;var n=P0(e)?e:{};this.thresholdPx=n.threshold_px||30,this.timeoutMs=n.timeout_ms||1e3,this.clickCount=n.click_count||3,this.clicks=[]}isRageClick(e,n,o){if(this.disabled)return!1;var i=this.clicks[this.clicks.length-1];if(i&&Math.abs(e-i.x)+Math.abs(n-i.y)<this.thresholdPx&&this.timeoutMs>o-i.timestamp){if(this.clicks.push({x:e,y:n,timestamp:o}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:n,timestamp:o}];return!1}}var yIe="$copy_autocapture",EIe=v0("[AutoCapture]");function BIe(t,e){return e.length>t?e.slice(0,t)+"...":e}function NTn(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do e=e.previousSibling;while(e&&!Ub(e));return e}function RTn(t,e){var n,o,i=e.e,r=e.maskAllElementAttributes,A=e.maskAllText,s=e.elementAttributeIgnoreList,a=e.elementsChainAsString,c=e.disableCaptureUrlHashes;if(!Ub(t))return{props:{}};for(var l=[t],g=new Set([t]),u=t;u.parentNode&&!ky(u,"body")&&cat>l.length;)if(aat(u.parentNode)){var d=u.parentNode.host;if(g.has(d))break;g.add(d),l.push(d),u=d}else{if(!Ub(u.parentNode)||g.has(u.parentNode))break;g.add(u.parentNode),l.push(u.parentNode),u=u.parentNode}var h,_,p=[],m={},I=!1,C=!1;if(pg(l,(S=>{var M=Zpe(S);if(ky(S,"a")){var w=S.getAttribute("href");I=!!(M&&w&&mL(w))&&(c?Kb(w):w)}gA(sX(S),"ph-no-capture")&&(C=!0),p.push((function(N,G,H,U,J){J===void 0&&(J=!1);var W=N.tagName.toLowerCase(),X={tag_name:W};jpe.indexOf(W)>-1&&!H&&(X.$el_text=W.toLowerCase()==="a"||W.toLowerCase()==="button"?BIe(1024,yat(N)):BIe(1024,_L(N)));var oe=sX(N);oe.length>0&&(X.classes=oe.filter((function(ae){return ae!==""}))),pg(N.attributes,(function(ae){var re;if((!Iat(N)||["name","id","class","aria-label"].indexOf(ae.name)!==-1)&&(U==null||!U.includes(ae.name))&&!G&&mL(ae.value)&&(!Xl(re=ae.name)||re.substring(0,10)!=="_ngcontent"&&re.substring(0,7)!=="_nghost")){var le=ae.value;ae.name==="class"&&(le=qpe(le).join(" ")),X["attr__"+ae.name]=BIe(1024,ae.name==="href"&&J?Kb(le):le)}}));for(var ce=1,te=1,ie=N;ie=NTn(ie);)ce++,ie.tagName===N.tagName&&te++;return X.nth_child=ce,X.nth_of_type=te,X})(S,r,A,s,c));var k=(function(N){if(!Zpe(N))return{};var G={};return pg(N.attributes,(function(H){if(H.name&&H.name.indexOf("data-ph-capture-attribute")===0){var U=H.name.replace("data-ph-capture-attribute-",""),J=H.value;U&&J&&mL(J)&&(G[U]=J)}})),G})(S);jg(m,k)})),C)return{props:{},explicitNoCapture:C};if(A||(p[0].$el_text=ky(t,"a")||ky(t,"button")?yat(t):_L(t)),I){var f,y;p[0].attr__href=I;var B=(f=pL(I))==null?void 0:f.host,x=wn==null||(y=wn.location)==null?void 0:y.host;B&&x&&B!==x&&(h=I)}return{props:jg({$event_type:i.type,$ce_version:1},a?{}:{$elements:p},{$elements_chain:(_=p,(function(S){return S.map((M=>{var w,k,N="";if(M.tag_name&&(N+=M.tag_name),M.attr_class)for(var G of(M.attr_class.sort(),M.attr_class))N+="."+G.replace(/"/g,"");var H=fo({},M.text?{text:M.text}:{},{"nth-child":(w=M.nth_child)!==null&&w!==void 0?w:0,"nth-of-type":(k=M.nth_of_type)!==null&&k!==void 0?k:0},M.href?{href:M.href}:{},M.attr_id?{attr_id:M.attr_id}:{},M.attributes),U={};return iX(H).sort(((J,W)=>J[0].localeCompare(W[0]))).forEach((J=>{var W=J[1];return U[Bat(J[0].toString())]=Bat(W.toString())})),(N+=":")+iX(U).map((J=>J[0]+'="'+J[1]+'"')).join("")})).join(";")})((function(S){return S.map((M=>{var w,k,N={text:(w=M.$el_text)==null?void 0:w.slice(0,400),tag_name:M.tag_name,href:(k=M.attr__href)==null?void 0:k.slice(0,2048),attr_class:jRn(M),attr_id:M.attr__id,nth_child:M.nth_child,nth_of_type:M.nth_of_type,attributes:{}};return iX(M).filter((G=>G[0].indexOf("attr__")===0)).forEach((G=>N.attributes[G[0]]=G[1])),N}))})(_)))},(n=p[0])!=null&&n.$el_text?{$el_text:(o=p[0])==null?void 0:o.$el_text}:{},h&&i.type==="click"?{$external_click_url:h}:{},m)}}var DL=v0("[ExceptionAutocapture]"),pct=()=>{},TTn=v0("[TracingHeaders]"),_P=v0("[Web Vitals]"),Ict=9e5,Cct="disabled",fct="lazy_loading",ML="awaiting_config",CX="missing_config";v0("[SessionRecording]"),v0("[SessionRecording]");var xIe="[SessionRecording]",WS=v0(xIe),kTn=v0("[Heatmaps]");function yct(t){return P0(t)&&"clientX"in t&&"clientY"in t&&Dp(t.clientX)&&Dp(t.clientY)}var QIe=v0("[Product Tours]"),SIe=t=>{var e;return!t.config.disable_product_tours&&!((e=t.persistence)==null||!e.get_property(Mpe))},FTn=["$set_once","$set"],$x=v0("[SiteApps]"),Ect="Error while initializing PostHog app with config id ";function S9(t,e,n){if(as(t))return!1;switch(n){case"exact":return t===e;case"contains":var o=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(o,"i").test(t);case"regex":try{return new RegExp(e).test(t)}catch{return!1}default:return!1}}class LTn{constructor(e){this.yn=new pIe,this.bn=(n,o)=>this._n(n,o)&&this.wn(n,o)&&this.xn(n,o)&&this.kn(n,o),this._n=(n,o)=>o==null||!o.event||n?.event===o?.event,this._instance=e,this.Sn=new Set,this.Cn=new Set}init(){var e,n;To((e=this._instance)==null?void 0:e._addCaptureHook)||(n=this._instance)==null||n._addCaptureHook(((o,i)=>{this.on(o,i)}))}register(e){var n,o;if(!To((n=this._instance)==null?void 0:n._addCaptureHook)&&(e.forEach((A=>{var s,a;(s=this.Cn)==null||s.add(A),(a=A.steps)==null||a.forEach((c=>{var l;(l=this.Sn)==null||l.add(c?.event||"")}))})),(o=this._instance)!=null&&o.autocapture)){var i,r=new Set;e.forEach((A=>{var s;(s=A.steps)==null||s.forEach((a=>{a!=null&&a.selector&&r.add(a?.selector)}))})),(i=this._instance)==null||i.autocapture.setElementSelectors(r)}}on(e,n){var o;n!=null&&e.length!=0&&(this.Sn.has(e)||this.Sn.has(n?.event))&&this.Cn&&((o=this.Cn)==null?void 0:o.size)>0&&this.Cn.forEach((i=>{this.Tn(n,i)&&this.yn.emit("actionCaptured",i.name)}))}In(e){this.onAction("actionCaptured",(n=>e(n)))}Tn(e,n){if(n?.steps==null)return!1;for(var o of n.steps)if(this.bn(e,o))return!0;return!1}onAction(e,n){return this.yn.on(e,n)}wn(e,n){if(n!=null&&n.url){var o,i=e==null||(o=e.properties)==null?void 0:o.$current_url;if(!i||typeof i!="string"||!S9(i,n.url,n.url_matching||"contains"))return!1}return!0}xn(e,n){return!!this.Mn(e,n)&&!!this.En(e,n)&&!!this.Rn(e,n)}Mn(e,n){var o;if(n==null||!n.href)return!0;var i=this.Pn(e);if(i.length>0)return i.some((s=>S9(s.href,n.href,n.href_matching||"exact")));var r,A=(e==null||(o=e.properties)==null?void 0:o.$elements_chain)||"";return!!A&&S9((r=A.match(/(?::|")href="(.*?)"/))?r[1]:"",n.href,n.href_matching||"exact")}En(e,n){var o;if(n==null||!n.text)return!0;var i=this.Pn(e);if(i.length>0)return i.some((c=>S9(c.text,n.text,n.text_matching||"exact")||S9(c.$el_text,n.text,n.text_matching||"exact")));var r,A,s,a=(e==null||(o=e.properties)==null?void 0:o.$elements_chain)||"";return!!a&&(r=(function(c){for(var l,g=[],u=/(?::|")text="(.*?)"/g;!as(l=u.exec(c));)g.includes(l[1])||g.push(l[1]);return g})(a),A=n.text,s=n.text_matching||"exact",r.some((c=>S9(c,A,s))))}Rn(e,n){var o,i;if(n==null||!n.selector)return!0;var r=e==null||(o=e.properties)==null?void 0:o.$element_selectors;if(r!=null&&r.includes(n.selector))return!0;var A=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";if(n.selector_regex&&A)try{return new RegExp(n.selector_regex).test(A)}catch{return!1}return!1}Pn(e){var n;return(e==null||(n=e.properties)==null?void 0:n.$elements)==null?[]:e?.properties.$elements}kn(e,n){return n==null||!n.properties||n.properties.length===0||sct(n.properties.reduce(((o,i)=>{var r=bs(i.value)?i.value.map(String):i.value!=null?[String(i.value)]:[];return o[i.key]={values:r,operator:i.operator||"exact"},o}),{}),e?.properties)}}class HTn{constructor(e){this.On=[],this._instance=e,this.Ln=new Map,this.Fn=new Map,this.An=new Map}$n(e,n){return!!e&&sct(e.propertyFilters,n?.properties)}Nn(e,n){var o=new Map;return e.forEach((i=>{var r;(r=i.conditions)==null||(r=r[n])==null||(r=r.values)==null||r.forEach((A=>{if(A!=null&&A.name){var s=o.get(A.name)||[];s.push(i.id),o.set(A.name,s)}}))})),o}Dn(e,n,o){var i=(o===fL.Activation?this.Ln:this.Fn).get(e),r=[];return this.qn((A=>{r=A.filter((s=>i?.includes(s.id)))})),r.filter((A=>{var s,a=(s=A.conditions)==null||(s=s[o])==null||(s=s.values)==null?void 0:s.find((c=>c.name===e));return this.$n(a,n)}))}register(e){var n;To((n=this._instance)==null?void 0:n._addCaptureHook)||(this.jn(e),this.Bn(e))}Bn(e){var n=e.filter((o=>{var i,r;return((i=o.conditions)==null?void 0:i.actions)&&((r=o.conditions)==null||(r=r.actions)==null||(r=r.values)==null?void 0:r.length)>0}));n.length!==0&&(this.Hn==null&&(this.Hn=new LTn(this._instance),this.Hn.init(),this.Hn.In((o=>{this.onAction(o)}))),n.forEach((o=>{var i,r,A,s,a;o.conditions&&(i=o.conditions)!=null&&i.actions&&(r=o.conditions)!=null&&(r=r.actions)!=null&&r.values&&((A=o.conditions)==null||(A=A.actions)==null||(A=A.values)==null?void 0:A.length)>0&&((s=this.Hn)==null||s.register(o.conditions.actions.values),(a=o.conditions)==null||(a=a.actions)==null||(a=a.values)==null||a.forEach((c=>{if(c&&c.name){var l=this.An.get(c.name);l&&l.push(o.id),this.An.set(c.name,l||[o.id])}})))})))}jn(e){var n,o=e.filter((r=>{var A,s;return((A=r.conditions)==null?void 0:A.events)&&((s=r.conditions)==null||(s=s.events)==null||(s=s.values)==null?void 0:s.length)>0})),i=e.filter((r=>{var A,s;return((A=r.conditions)==null?void 0:A.cancelEvents)&&((s=r.conditions)==null||(s=s.cancelEvents)==null||(s=s.values)==null?void 0:s.length)>0}));o.length===0&&i.length===0||((n=this._instance)==null||n._addCaptureHook(((r,A)=>{this.onEvent(r,A)})),this.Ln=this.Nn(e,fL.Activation),this.Fn=this.Nn(e,fL.Cancellation))}onEvent(e,n){var o,i,r=this.Un(),A=(n==null||(o=n.properties)==null?void 0:o.$survey_id)||(n==null||(i=n.properties)==null?void 0:i.$product_tour_id);if(A&&this.getActivatedIds().includes(A)){var s=this.zn(e,A);if(s==="consume")return r.info("event consumed activated item, removing it",{event:e,itemId:A}),void this.Wn([A]);if(s==="persist")return r.info("shown item promoted to persisted activation",{event:e,itemId:A}),void this.Vn(A)}if(this.Fn.has(e)){var a=this.Dn(e,n,fL.Cancellation);a.length>0&&(r.info("cancel event matched, cancelling items",{event:e,itemsToCancel:a.map((l=>l.id))}),this.Wn(a.map((l=>l.id))),a.forEach((l=>this.Zn(l.id))))}if(this.Ln.has(e)){r.info("event name matched",{event:e,eventPayload:n,items:this.Ln.get(e)});var c=this.Dn(e,n,fL.Activation);this.Gn(c.map((l=>l.id)))}}onAction(e){this.An.has(e)&&this.Gn(this.An.get(e)||[])}Gn(e){e.length!==0&&(this.On=[...new Set([...this.On,...e])],this.Un().info("updating activated items",{activatedItems:this.getActivatedIds()}))}Vn(e){this.On=this.On.filter((o=>o!==e));var n=this.Qn();n.includes(e)||this.Jn([...n,e])}Wn(e){var n=new Set(e);this.On=this.On.filter((r=>!n.has(r)));var o=this.Qn(),i=o.filter((r=>!n.has(r)));i.length!==o.length&&this.Jn(i)}Qn(){var e,n=this.Kn();return((e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[n])||[]}getActivatedIds(){return[...new Set([...this.Qn(),...this.On])].filter((e=>!this.Yn(e)))}reset(){this.On=[],this.Qn().length>0&&this.Jn([])}getEventToItemsMap(){return this.Ln}Xn(){return this.Hn}}class GTn extends HTn{constructor(e){super(e)}Kn(){return Tpe}es(){return JS.SHOWN}qn(e){var n;(n=this._instance)==null||n.getSurveys(e)}Zn(e){var n;(n=this._instance)==null||n.cancelPendingSurvey(e)}Un(){return $l}Jn(e){var n;(n=this._instance)==null||(n=n.persistence)==null||n.register({[Tpe]:e})}Yn(){return!1}zn(e,n){var o;this.qn((r=>{o=r.find((A=>A.id===n))}));var i=!o||(function(r){var A,s,a,c=((A=(s=r.conditions)==null||(s=s.events)==null||(s=s.values)==null?void 0:s.length)!==null&&A!==void 0?A:0)>0;return r.schedule===sTn.Always||!((a=r.conditions)==null||(a=a.events)==null||!a.repeatedActivation||!c)})(o);return i?e===JS.SHOWN?"consume":"ignore":e===JS.SHOWN?"persist":e===JS.DISMISSED||e===JS.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var bIe="SDK is not enabled or survey functionality is not yet loaded",Bct="Disabled. Not loading surveys.",OTn=wn!=null&&wn.location?lX(wn.location.hash,"__posthog")||lX(location.hash,"state"):null,xct="_postHogToolbarParams",Qct=v0("[Toolbar]"),Wd=v0("[FeatureFlags]"),mP=v0("[FeatureFlags]",{debugEnabled:!0}),DIe=`" failed. Feature flags didn't load in time.`,Sct=t=>{for(var e={},n=0;t.length>n;n++)e[t[n]]=!0;return e},bct=t=>{var e={};for(var n of iX(t||{})){var o=n[1];o&&(e[n[0]]=o)}return e},jS=v0("[Error tracking]"),Dct="Refusing to render web experiment since the viewer is a likely bot",KTn={icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())===-1,regex:(t,e)=>mX(e,t),not_regex:(t,e)=>!mX(e,t),exact:(t,e)=>e===t,is_not:(t,e)=>e!==t};class GI{get Se(){return this._instance.config}constructor(e){var n=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(o){o===void 0&&(o=!1),n.getWebExperiments((i=>{GI.ts("retrieved web experiments from the server"),n.rs=new Map,i.forEach((r=>{if(r.feature_flag_key){var A;n.rs&&(GI.ts("setting flag key ",r.feature_flag_key," to web experiment ",r),(A=n.rs)==null||A.set(r.feature_flag_key,r));var s=n._instance.getFeatureFlag(r.feature_flag_key);Xl(s)&&r.variants[s]&&n.ns(r.name,s,r.variants[s].transforms)}else if(r.variants)for(var a in r.variants){var c=r.variants[a];GI.ss(c,n._instance)&&n.ns(r.name,a,c.transforms)}}))}),o)},this._instance=e,this._instance.onFeatureFlags((o=>{this.onFeatureFlags(o)}))}initialize(){}onFeatureFlags(e){if(this._is_bot())GI.ts(Dct);else if(!this.Se.disable_web_experiments){if(as(this.rs))return this.rs=new Map,this.loadIfEnabled(),void this.previewWebExperiment();GI.ts("applying feature flags",e),e.forEach((n=>{var o;if(this.rs&&(o=this.rs)!=null&&o.has(n)){var i,r=this._instance.getFeatureFlag(n),A=(i=this.rs)==null?void 0:i.get(n);r&&A!=null&&A.variants[r]&&this.ns(A.name,r,A.variants[r].transforms)}}))}}previewWebExperiment(){var e=GI.getWindowLocation();if(e!=null&&e.search){var n=C9(e?.search,"__experiment_id"),o=C9(e?.search,"__experiment_variant");n&&o&&(GI.ts("previewing web experiments "+n+" && "+o),this.getWebExperiments((i=>{this.os(parseInt(n),o,i)}),!1,!0))}}loadIfEnabled(){this.Se.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,n,o){if(this.Se.disable_web_experiments&&!o)return e([]);var i=this._instance.get_property("$web_experiments");if(i&&!n)return e(i);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.Se.token),method:"GET",callback:r=>e(r.statusCode===200&&r.json&&r.json.experiments||[])})}os(e,n,o){var i=o.filter((r=>r.id===e));i&&i.length>0&&(GI.ts("Previewing web experiment ["+i[0].name+"] with variant ["+n+"]"),this.ns(i[0].name,n,i[0].variants[n].transforms))}static ss(e,n){return!as(e.conditions)&&GI.ls(e,n)&&GI.us(e)}static ls(e,n){var o;if(as(e.conditions)||as((o=e.conditions)==null?void 0:o.url))return!0;var i=GI.getWindowLocation();if(i){var r,A,s,a=rat(n,i.href);return(r=e.conditions)==null||!r.url||KTn[(A=(s=e.conditions)==null?void 0:s.urlMatchType)!==null&&A!==void 0?A:"icontains"](e.conditions.url,a)}return!1}static getWindowLocation(){return wn?.location}static us(e){var n;if(as(e.conditions)||as((n=e.conditions)==null?void 0:n.utm))return!0;var o=wat();if(o.utm_source){var i,r,A,s,a,c,l,g,u=(i=e.conditions)==null||(i=i.utm)==null||!i.utm_campaign||((r=e.conditions)==null||(r=r.utm)==null?void 0:r.utm_campaign)==o.utm_campaign,d=(A=e.conditions)==null||(A=A.utm)==null||!A.utm_source||((s=e.conditions)==null||(s=s.utm)==null?void 0:s.utm_source)==o.utm_source,h=(a=e.conditions)==null||(a=a.utm)==null||!a.utm_medium||((c=e.conditions)==null||(c=c.utm)==null?void 0:c.utm_medium)==o.utm_medium,_=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_term||((g=e.conditions)==null||(g=g.utm)==null?void 0:g.utm_term)==o.utm_term;return u&&h&&_&&d}return!1}static ts(e){for(var n=arguments.length,o=new Array(n>1?n-1:0),i=1;n>i;i++)o[i-1]=arguments[i];wo.info("[WebExperiments] "+e,o)}ns(e,n,o){this._is_bot()?GI.ts(Dct):n!=="control"?o.forEach((i=>{if(i.selector){var r;GI.ts("applying transform of variant "+n+" for experiment "+e+" ",i);var A=(r=document)==null?void 0:r.querySelectorAll(i.selector);A?.forEach((s=>{var a=s;i.html&&(a.innerHTML=i.html),i.css&&a.setAttribute("style",i.css)}))}})):GI.ts("Control variants leave the page unmodified.")}_is_bot(){return JC&&this._instance?oct(JC,this.Se.custom_blocked_useragents):void 0}}var s2=v0("[Conversations]"),pP="Conversations not available yet.",Mct="console",fX={featureFlags:class{constructor(t){this.hs=!1,this.ds=!1,this.cs=!1,this.vs=!1,this.fs=!1,this.ps=!1,this.gs=!1,this.ys=!1,this.bs=0,this._s=()=>{var e=this.ws();this.bs=0,e&&this.reloadFeatureFlags()},this._instance=t,this.featureFlagEventHandlers=[],wn&&au(wn,"online",this._s)}destroy(){wn?.removeEventListener("online",this._s)}get Se(){return this._instance.config}get ri(){return this._instance.persistence}xs(t){return this._instance.get_property(t)}ks(){var t,e;return(t=(e=this.ri)==null?void 0:e.sr(this.Se.feature_flag_cache_ttl_ms))!==null&&t!==void 0&&t}Ss(){return!!this.ks()&&(this.ys||this.cs||(this.ys=!0,Wd.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Cs(){var t,e=(t=this.Se.evaluation_contexts)!==null&&t!==void 0?t:this.Se.evaluation_environments;return!this.Se.evaluation_environments||this.Se.evaluation_contexts||this.gs||(Wd.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.gs=!0),e!=null&&e.length?e.filter((n=>{var o=n&&typeof n=="string"&&n.trim().length>0;return o||Wd.error("Invalid evaluation context found:",n,"Expected non-empty string"),o})):[]}Ts(){return this.Cs().length>0}Is(){var t=this.Se.flag_keys;if(!To(t)){if(bs(t))return t.filter((e=>{var n=e&&typeof e=="string"&&e.trim().length>0;return n||Wd.error("Invalid flag key found:",e,"Expected non-empty string"),n}));Wd.error("Invalid flag_keys found:",t,"Expected array of non-empty strings")}}initialize(){var t,e,n=this._instance.config,o=(t=(e=n.bootstrap)==null?void 0:e.featureFlags)!==null&&t!==void 0?t:{};if(Object.keys(o).length){var i,r,A=(i=(r=n.bootstrap)==null?void 0:r.featureFlagPayloads)!==null&&i!==void 0?i:{},s=Object.keys(o).filter((c=>!!o[c])).reduce(((c,l)=>(c[l]=o[l]||!1,c)),{}),a=Object.keys(A).filter((c=>s[c])).reduce(((c,l)=>(A[l]&&(c[l]=A[l]),c)),{});this.receivedFeatureFlags({featureFlags:s,featureFlagPayloads:a})}}updateFlags(t,e,n){var o,i,r=n!=null&&n.merge&&(o=this.xs(aP))!==null&&o!==void 0?o:{},A=n!=null&&n.merge&&(i=this.xs(jj))!==null&&i!==void 0?i:{},s=fo({},r,t),a=fo({},A,e),c={};for(var l of Object.entries(s)){var g=l[0],u=l[1];c[g]={key:g,enabled:$At(u),variant:ZAt(u),reason:void 0,metadata:To(a?.[g])?void 0:{id:0,version:void 0,description:void 0,payload:a[g]}}}this.receivedFeatureFlags({flags:c})}get hasLoadedFlags(){return this.ds}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.xs(vpe),e=this.xs(YS),n=this.xs(_9);if(!n&&!e)return t||{};var o=jg({},t||{}),i=[...new Set([...Object.keys(n||{}),...Object.keys(e||{})])];for(var r of i){var A,s,a=o[r],c=e?.[r],l=To(c)?(A=a?.enabled)!==null&&A!==void 0&&A:!!c,g=To(c)?a.variant:typeof c=="string"?c:void 0,u=n?.[r],d=fo({},a,{enabled:l,variant:l?g??a?.variant:void 0});l!==a?.enabled&&(d.original_enabled=a?.enabled),g!==a?.variant&&(d.original_variant=a?.variant),u&&(d.metadata=fo({},a?.metadata,{payload:u,original_payload:a==null||(s=a.metadata)==null?void 0:s.payload})),o[r]=d}return this.hs||(Wd.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:n,finalDetails:o}),this.hs=!0),o}getAllFeatureFlags(){var t=this.getFlagVariants(),e=this.getFlagPayloads();return Object.keys(t).map((n=>{var o=t[n];return{key:n,enabled:$At(o),variant:ZAt(o),payload:XAt(e[n])}}))}getFlagVariants(){var t=this.xs(aP),e=this.xs(YS);if(!e)return t||{};for(var n=jg({},t),o=Object.keys(e),i=0;o.length>i;i++)n[o[i]]=e[o[i]];return this.hs||(Wd.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:n}),this.hs=!0),n}getFlagPayloads(){var t=this.xs(jj),e=this.xs(_9);if(!e)return t||{};for(var n=jg({},t||{}),o=Object.keys(e),i=0;o.length>i;i++)n[o[i]]=e[o[i]];return this.hs||(Wd.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:n}),this.hs=!0),n}reloadFeatureFlags(){this.vs||this.Se.advanced_disable_feature_flags||this.ws()||this.Ms||(this._instance.qi.emit("featureFlagsReloading",!0),this.Ms=setTimeout((()=>{this.Es()}),5))}Rs(){clearTimeout(this.Ms),this.Ms=void 0}ensureFlagsLoaded(){this.ds||this.cs||this.Ms||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.vs=t}Es(t){var e;if(this.Rs(),!this._instance.Rr()&&!this.ws())if(this.cs)this.fs=!0;else{var n=this.Se.token,o=this.xs(qj),i={token:n,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:fo({},((e=this.ri)==null?void 0:e.get_initial_props())||{},this.xs(cP)||{}),group_properties:this.xs(lP),timezone:Fat()};qC(o)||To(o)||(i.$device_id=o),(t!=null&&t.disableFlags||this.Se.advanced_disable_feature_flags)&&(i.disable_flags=!0),this.Ts()&&(i.evaluation_contexts=this.Cs());var r=this.Is();To(r)||(i.flag_keys=r);var A=!!this.Se.advanced_only_evaluate_survey_feature_flags,s=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this.Se.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this.cs=!0,this._instance._send_request({method:"POST",url:s,data:i,compression:this.Se.disable_compression?void 0:WC.Base64,timeout:this.Se.feature_flag_request_timeout_ms,callback:a=>{var c,l,g,u=!0;if(this.Ps(a.statusCode),a.statusCode===200&&(this.fs||(this.$anon_distinct_id=void 0),u=!1),this.cs=!1,!i.disable_flags||this.fs){this.ps=!u;var d=[];a.error?a.error instanceof Error?d.push(a.error.name==="AbortError"?"timeout":"connection_error"):d.push("unknown_error"):a.statusCode!==200&&d.push("api_error_"+a.statusCode),(c=a.json)!=null&&c.errorsWhileComputingFlags&&d.push("errors_while_computing_flags");var h,_=!((l=a.json)==null||(l=l.quotaLimited)==null||!l.includes("feature_flags"));_&&d.push("quota_limited"),(g=this.ri)==null||g.register({[Fpe]:d}),_?Wd.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."):(i.disable_flags||this.receivedFeatureFlags((h=a.json)!==null&&h!==void 0?h:{},u,{partialResponse:A}),this.fs&&(this.fs=!1,this.Es()))}}})}}ws(){return Dat(this.bs,3)}Ps(t){this.bs=Mat(t,this.bs,3,(()=>Wd.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes.")))}getFeatureFlag(t,e){var n;if(e===void 0&&(e={}),!e.fresh||this.ps)if(this.ds||this.getFlags()&&this.getFlags().length>0){if(!this.Ss()){var o=this.getFeatureFlagResult(t,e);return(n=o?.variant)!==null&&n!==void 0?n:o?.enabled}}else Wd.warn('getFeatureFlag for key "'+t+DIe)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var e=this.getFeatureFlagResult(t,{send_event:!1});return e?.payload}getFeatureFlagResult(t,e){if(e===void 0&&(e={}),!e.fresh||this.ps)if(this.ds||this.getFlags()&&this.getFlags().length>0){if(!this.Ss()){var n=this.getFlagVariants(),o=t in n,i=n[t],r=this.getFlagPayloads()[t],A=String(i),s=this.xs(Npe)||void 0,a=this.xs(hL)||void 0,c=this.xs(uL)||{};if(this.Se.advanced_feature_flags_dedup_per_session){var l,g=this._instance.get_session_id(),u=this.xs(kpe);g&&g!==u&&(c={},(l=this.ri)==null||l.register({[uL]:c,[kpe]:g}))}if((e.send_event||!("send_event"in e))&&(!(t in c)||!c[t].includes(A))){var d,h,_,p,m,I,C,f,y,B;bs(c[t])?c[t].push(A):c[t]=[A],(d=this.ri)==null||d.register({[uL]:c});var x=this.getFeatureFlagDetails(t),S=[...(h=this.xs(Fpe))!==null&&h!==void 0?h:[]];To(i)&&S.push("flag_missing");var M={$feature_flag:t,$feature_flag_response:i,$feature_flag_payload:r||null,$feature_flag_request_id:s,$feature_flag_evaluated_at:a,$feature_flag_bootstrapped_response:((_=this.Se.bootstrap)==null||(_=_.featureFlags)==null?void 0:_[t])||null,$feature_flag_bootstrapped_payload:((p=this.Se.bootstrap)==null||(p=p.featureFlagPayloads)==null?void 0:p[t])||null,$used_bootstrap_value:!this.ps};To(x==null||(m=x.metadata)==null?void 0:m.version)||(M.$feature_flag_version=x.metadata.version);var w,k=(I=x==null||(C=x.reason)==null?void 0:C.description)!==null&&I!==void 0?I:x==null||(f=x.reason)==null?void 0:f.code;k&&(M.$feature_flag_reason=k),x!=null&&(y=x.metadata)!=null&&y.id&&(M.$feature_flag_id=x.metadata.id),To(x?.original_variant)&&To(x?.original_enabled)||(M.$feature_flag_original_response=To(x.original_variant)?x.original_enabled:x.original_variant),x!=null&&(B=x.metadata)!=null&&B.original_payload&&(M.$feature_flag_original_payload=x==null||(w=x.metadata)==null?void 0:w.original_payload),S.length&&(M.$feature_flag_error=S.join(",")),this._instance.capture("$feature_flag_called",M)}if(o)return{key:t,enabled:!!i,variant:typeof i=="string"?i:void 0,payload:XAt(r)}}}else Wd.warn('getFeatureFlagResult for key "'+t+DIe)}getRemoteConfigPayload(t,e){var n=this.Se.token,o={distinct_id:this._instance.get_distinct_id(),token:n};this.Ts()&&(o.evaluation_contexts=this.Cs());var i=this.Is();To(i)||(o.flag_keys=i),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:o,compression:this.Se.disable_compression?void 0:WC.Base64,timeout:this.Se.feature_flag_request_timeout_ms,callback(r){var A,s=(A=r.json)==null?void 0:A.featureFlagPayloads;e(s?.[t]||void 0)}})}isFeatureEnabled(t,e){if(e===void 0&&(e={}),!e.fresh||this.ps){if(this.ds||this.getFlags()&&this.getFlags().length>0){var n=this.getFeatureFlag(t,e);return To(n)?void 0:!!n}Wd.warn('isFeatureEnabled for key "'+t+DIe)}}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((e=>e!==t))}receivedFeatureFlags(t,e,n){if(this.ri){this.ds=!0;var o=this.getFlagVariants(),i=this.getFlagPayloads(),r=this.getFlagsWithDetails();(function(A,s,a,c,l,g){a===void 0&&(a={}),c===void 0&&(c={}),l===void 0&&(l={});var u=(S=>{var M=S.flags;return M?(S.featureFlags=Object.fromEntries(Object.keys(M).map((w=>{var k;return[w,(k=M[w].variant)!==null&&k!==void 0?k:M[w].enabled]}))),S.featureFlagPayloads=Object.fromEntries(Object.keys(M).filter((w=>M[w].enabled)).filter((w=>{var k;return(k=M[w].metadata)==null?void 0:k.payload})).map((w=>{var k;return[w,(k=M[w].metadata)==null?void 0:k.payload]})))):S.featureFlags&&Wd.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),S})(A),d=u.flags,h=u.featureFlags,_=u.featureFlagPayloads;if(h){var p=A.requestId,m=A.evaluatedAt;if(bs(h)){Wd.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var I={};if(h)for(var C=0;h.length>C;C++)I[h[C]]=!0;s&&s.register({[Wj]:h,[aP]:I})}else{var f=h,y=_,B=d;if(g!=null&&g.partialResponse)f=fo({},a,f),y=fo({},c,y),B=fo({},l,B);else if(A.errorsWhileComputingFlags)if(d){var x=new Set(Object.keys(d).filter((S=>{var M;return!((M=d[S])!=null&&M.failed)})));f=fo({},a,Object.fromEntries(Object.entries(f).filter((S=>x.has(S[0]))))),y=fo({},c,Object.fromEntries(Object.entries(y||{}).filter((S=>x.has(S[0]))))),B=fo({},l,Object.fromEntries(Object.entries(B||{}).filter((S=>x.has(S[0])))))}else f=fo({},a,f),y=fo({},c,y),B=fo({},l,B);s&&s.register(fo({[Wj]:Object.keys(bct(f)),[aP]:f||{},[jj]:y||{},[vpe]:B||{}},p?{[Npe]:p}:{},m?{[hL]:m}:{}))}}})(t,this.ri,o,i,r,n),e||(this.ys=!1),this.Os(e)}}override(t,e){e===void 0&&(e=!1),Wd.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){if(!this._instance.__loaded||!this.ri)return Wd.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(t===!1)return this.ri.unregister(YS),this.ri.unregister(_9),this.Os(),mP.info("All overrides cleared");if(bs(t)){var e=Sct(t);return this.ri.register({[YS]:e}),this.Os(),mP.info("Flag overrides set",{flags:t})}if(t&&typeof t=="object"&&("flags"in t||"payloads"in t)){var n,o=t;if(this.hs=!!((n=o.suppressWarning)!==null&&n!==void 0&&n),"flags"in o){if(o.flags===!1)this.ri.unregister(YS),mP.info("Flag overrides cleared");else if(o.flags){if(bs(o.flags)){var i=Sct(o.flags);this.ri.register({[YS]:i})}else this.ri.register({[YS]:o.flags});mP.info("Flag overrides set",{flags:o.flags})}}return"payloads"in o&&(o.payloads===!1?(this.ri.unregister(_9),mP.info("Payload overrides cleared")):o.payloads&&(this.ri.register({[_9]:o.payloads}),mP.info("Payload overrides set",{payloads:o.payloads}))),void this.Os()}if(t&&typeof t=="object")return this.ri.register({[YS]:t}),this.Os(),mP.info("Flag overrides set",{flags:t});Wd.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.ds){var e=this.Ls(),n=e.flags,o=e.flagVariants;try{t(n,o)}catch(i){Wd.error("Error while running feature flags callback",i)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,n){var o,i=(this.xs(lL)||[]).find((a=>a.flagKey===t)),r={["$feature_enrollment/"+t]:e},A={$feature_flag:t,$feature_enrollment:e,$set:r};i&&(A.$early_access_feature_name=i.name),n&&(A.$feature_enrollment_stage=n),this._instance.capture("$feature_enrollment_update",A),this.setPersonPropertiesForFlags(r,!1);var s=fo({},this.getFlagVariants(),{[t]:e});(o=this.ri)==null||o.register({[Wj]:Object.keys(bct(s)),[aP]:s}),this.Os()}getEarlyAccessFeatures(t,e,n){e===void 0&&(e=!1);var o=this.xs(lL),i=n?"&"+n.map((r=>"stage="+r)).join("&"):"";if(o&&!e)return t(o);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this.Se.token+i),method:"GET",callback:r=>{var A,s;if(r.json){var a=r.json.earlyAccessFeatures;return(A=this.ri)==null||A.unregister(lL),(s=this.ri)==null||s.register({[lL]:a}),t(a)}}})}Ls(){var t=this.getFlags(),e=this.getFlagVariants();return{flags:t.filter((n=>e[n])),flagVariants:Object.keys(e).filter((n=>e[n])).reduce(((n,o)=>(n[o]=e[o],n)),{})}}Os(t){var e=this.Ls(),n=e.flags,o=e.flagVariants;this.featureFlagEventHandlers.forEach((i=>{try{i(n,o,{errorsLoading:t})}catch(r){Wd.error("Error while running feature flags callback",r)}}))}setPersonPropertiesForFlags(t,e){e===void 0&&(e=!0);var n=this.xs(cP)||{},o=t?.$set||(t!=null&&t.$set_once?{}:t),i=t?.$set_once,r={};if(i)for(var A in i)({}).hasOwnProperty.call(i,A)&&(A in n||(r[A]=i[A]));this._instance.register({[cP]:fo({},n,r,o)}),e&&this._instance.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,e){e===void 0&&(e=!0);var n=fo({},this.xs(cP)||{});t.forEach((o=>{delete n[o]})),this._instance.register({[cP]:n}),e&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){t===void 0&&(t=!0),this._instance.unregister(cP),t&&this._instance.reloadFeatureFlags()}setGroupPropertiesForFlags(t,e){e===void 0&&(e=!0);var n=this.xs(lP)||{};Object.keys(n).length!==0&&Object.keys(n).forEach((o=>{n[o]=fo({},n[o],t[o]),delete t[o]})),this._instance.register({[lP]:fo({},n,t)}),e&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var e=this.xs(lP)||{};this._instance.register({[lP]:fo({},e,{[t]:{}})})}else this._instance.unregister(lP)}reset(){this.ds=!1,this.cs=!1,this.vs=!1,this.fs=!1,this.ps=!1,this.$anon_distinct_id=void 0,this.Rs(),this.hs=!1,this.bs=0}}},UTn={sessionRecording:class{get Se(){return this._instance.config}get ri(){return this._instance.persistence}get started(){var t;return!((t=this.Fs)==null||!t.isStarted)}get status(){var t,e;return this.As===ML||this.As===CX?this.As:(t=(e=this.Fs)==null?void 0:e.status)!==null&&t!==void 0?t:this.As}constructor(t){if(this._forceAllowLocalhostNetworkCapture=!1,this.As=Cct,this.$s=void 0,this._instance=t,!this._instance.sessionManager)throw WS.error("started without valid sessionManager"),new Error(xIe+" started without valid sessionManager. This is a bug.");if(this.Se.cookieless_mode===VS)throw new Error(xIe+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get Ns(){var t,e=!((t=this._instance.get_property(sP))==null||!t.enabled),n=!this.Se.disable_session_recording,o=this.Se.disable_session_recording||this._instance.consent.isOptedOut();return wn&&e&&n&&!o}startIfEnabledOrStop(t){var e;if(!this.Ns||(e=this.Fs)==null||!e.isStarted){var n=!To(Object.assign)&&!To(Array.from);this.Ns&&n?(this.Ds(t),WS.info("starting")):(this.As=Cct,this.stopRecording())}}Ds(t){var e,n,o;this.Ns&&(this.As!==ML&&this.As!==CX&&(this.As=fct),_r!=null&&(e=_r.__PosthogExtensions__)!=null&&(e=e.rrweb)!=null&&e.record&&(n=_r.__PosthogExtensions__)!=null&&n.initSessionRecording?this.qs(t):(o=_r.__PosthogExtensions__)==null||o.loadExternalDependency==null||o.loadExternalDependency(this._instance,this.js,(i=>{if(i)return WS.error("could not load recorder",i);this.qs(t)})))}stopRecording(){var t,e;(t=this.$s)==null||t.call(this),this.$s=void 0,(e=this.Fs)==null||e.stop()}Bs(){var t,e;(t=this.$s)==null||t.call(this),this.$s=void 0,(e=this.Fs)==null||e.discard()}Hs(){var t,e;(t=this.ri)==null||t.unregister(Ppe),(e=this.ri)==null||e.unregister(Vst)}Us(t,e){if(as(t))return null;var n,o=Dp(t)?t:parseFloat(t);return typeof(n=o)!="number"||!Number.isFinite(n)||0>n||n>1?(WS.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):o}zs(t){if(this.ri){var e,n,o=this.ri,i=()=>{var r,A=t.sessionRecording===!1?void 0:t.sessionRecording,s=this.Us((r=this.Se.session_recording)==null?void 0:r.sampleRate,"session_recording.sampleRate"),a=this.Us(A?.sampleRate,"remote config sampleRate"),c=s??a;as(c)&&this.Hs();var l=A?.minimumDurationMilliseconds;o.register({[sP]:fo({cache_timestamp:Date.now(),enabled:!!A},A,{networkPayloadCapture:fo({capturePerformance:t.capturePerformance},A?.networkPayloadCapture),canvasRecording:{enabled:A?.recordCanvas,fps:A?.canvasFps,quality:A?.canvasQuality},sampleRate:c,minimumDurationMilliseconds:To(l)?null:l,endpoint:A?.endpoint,triggerMatchType:A?.triggerMatchType,masking:A?.masking,urlTriggers:A?.urlTriggers,version:A?.version,triggerGroups:A?.triggerGroups})})};i(),(e=this.$s)==null||e.call(this),this.$s=(n=this._instance.sessionManager)==null?void 0:n.onSessionId(i)}}onRemoteConfig(t){return"sessionRecording"in t?t.sessionRecording===!1?(this.zs(t),void this.Bs()):(this.zs(t),void this.startIfEnabledOrStop()):(this.As===ML&&(this.As=CX,WS.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,e){var n;e===void 0&&(e="log"),(n=this.Fs)!=null&&n.log?this.Fs.log(t,e):WS.warn("log called before recorder was ready")}get js(){var t,e,n=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.get_property(sP);return(n==null||(e=n.scriptConfig)==null?void 0:e.script)||"lazy-recorder"}Ws(){var t,e,n=this._instance.get_property(sP);if(!n)return!1;try{e=typeof n=="object"?n:JSON.parse(n)}catch(i){return WS.warn("persisted remote config for session recording is invalid and will be ignored",i),!1}var o=(t=e.cache_timestamp)!==null&&t!==void 0?t:Date.now();return 36e5>=Date.now()-o}qs(t){var e,n;if((e=_r.__PosthogExtensions__)==null||!e.initSessionRecording)return WS.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[Zst]:!0});if(this.Fs||(this.Fs=(n=_r.__PosthogExtensions__)==null?void 0:n.initSessionRecording(this._instance),this.Fs._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Ws())return this.As===CX||this.As===ML?void 0:(this.As=ML,WS.info("persisted remote config is stale, requesting fresh config before starting"),void new Gat(this._instance).load());this.As=fct,this.Fs.start(t)}onRRwebEmit(t){var e;(e=this.Fs)==null||e.onRRwebEmit==null||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.Fs||(e=this.ri)==null||e.register({[Jst]:!0}),(t=this.Fs)==null||t.overrideLinkedFlag()}overrideSampling(){var t,e;this.Fs||(e=this.ri)==null||e.register({[zst]:!0}),(t=this.Fs)==null||t.overrideSampling()}overrideTrigger(t){var e,n;this.Fs||(n=this.ri)==null||n.register({[t==="url"?qst:Wst]:!0}),(e=this.Fs)==null||e.overrideTrigger(t)}get sdkDebugProperties(){var t;return((t=this.Fs)==null?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,e){var n;return!((n=this.Fs)==null||!n.tryAddCustomEvent(t,e))}}},YTn={autocapture:class{constructor(t){this.Vs=!1,this.Zs=null,this.Gs=!1,this.instance=t,this.rageclicks=new mct(t.config.rageclick),this.Qs=null}initialize(){this.startIfEnabled()}get Se(){var t,e,n=P0(this.instance.config.autocapture)?this.instance.config.autocapture:{};return n.url_allowlist=(t=n.url_allowlist)==null?void 0:t.map((o=>new RegExp(o))),n.url_ignorelist=(e=n.url_ignorelist)==null?void 0:e.map((o=>new RegExp(o))),n}Js(){if(this.isBrowserSupported()){if(wn&&Zo){var t=n=>{n=n||wn?.event;try{this.Ks(n)}catch(o){EIe.error("Failed to capture event",o)}};if(au(Zo,"submit",t,{capture:!0}),au(Zo,"change",t,{capture:!0}),au(Zo,"click",t,{capture:!0}),this.Se.capture_copied_text){var e=n=>{n=n||wn?.event;try{this.Ks(n,yIe)}catch(o){EIe.error("Failed to capture copy/cut event",o)}};au(Zo,"copy",e,{capture:!0}),au(Zo,"cut",e,{capture:!0})}}}else EIe.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.Vs&&(this.Js(),this.Vs=!0)}onRemoteConfig(t){t.elementsChainAsString&&(this.Gs=t.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Epe]:!!t.autocapture_opt_out}),this.Zs=!!t.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(t){this.Qs=t}getElementSelectors(t){var e,n=[];return(e=this.Qs)==null||e.forEach((o=>{var i=Zo?.querySelectorAll(o);i?.forEach((r=>{t===r&&n.push(o)}))})),n}get isEnabled(){var t,e,n=(t=this.instance.persistence)==null?void 0:t.props[Epe];if(qC(this.Zs)&&!Wx(n)&&!this.instance.Rr())return!1;var o=(e=this.Zs)!==null&&e!==void 0?e:!!n;return!!this.instance.config.autocapture&&!o}Ks(t,e){if(e===void 0&&(e="$autocapture"),this.isEnabled){var n,o=Wpe(t);sat(o)&&(o=o.parentNode||null),e==="$autocapture"&&t.type==="click"&&t instanceof MouseEvent&&this.instance.config.rageclick&&(n=this.rageclicks)!=null&&n.isRageClick(t.clientX,t.clientY,t.timeStamp||new Date().getTime())&&mat(o,this.instance.config.rageclick)&&this.Ks(t,"$rageclick");var i=e===yIe;if(o&&(function(g,u,d,h,_,p){var m,I,C,f,y,B;if(d===void 0&&(d=void 0),!wn||$pe(g)||(m=d)!=null&&m.url_allowlist&&!lat(d.url_allowlist,p)||(I=d)!=null&&I.url_ignorelist&&lat(d.url_ignorelist,p))return!1;if((C=d)!=null&&C.dom_event_allowlist){var x=d.dom_event_allowlist;if(x&&!x.some((G=>u.type===G)))return!1}var S=pat(g,h),M=S.parentIsUsefulElement,w=S.targetElementList;if(!(function(G,H){var U=H?.element_allowlist;if(To(U))return!0;var J,W=function(oe){if(U.some((ce=>oe.tagName.toLowerCase()===ce)))return{v:!0}};for(var X of G)if(J=W(X))return J.v;return!1})(w,d)||!Xpe(w,(f=d)==null?void 0:f.css_selector_allowlist)||Xpe(w,(y=(B=d)==null?void 0:B.css_selector_ignorelist)!==null&&y!==void 0?y:URn))return!1;try{var k=wn.getComputedStyle(g);if(k&&k.getPropertyValue("cursor")==="pointer"&&u.type==="click")return!0}catch{}var N=g.tagName.toLowerCase();switch(N){case"html":return!1;case"form":return(_||["submit"]).indexOf(u.type)>=0;case"input":case"select":case"textarea":return(_||["change","click"]).indexOf(u.type)>=0;default:return M?(_||["click"]).indexOf(u.type)>=0:(_||["click"]).indexOf(u.type)>=0&&(jpe.indexOf(N)>-1||g.getAttribute("contenteditable")==="true")}})(o,t,this.Se,i,i?["copy","cut"]:void 0,this.instance)){var r=RTn(o,{e:t,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.Se.element_attribute_ignorelist,elementsChainAsString:this.Gs,disableCaptureUrlHashes:this.instance.config.disable_capture_url_hashes}),A=r.props;if(r.explicitNoCapture)return!1;var s=this.getElementSelectors(o);if(s&&s.length>0&&(A.$element_selectors=s),e===yIe){var a,c=gat(wn==null||(a=wn.getSelection())==null?void 0:a.toString()),l=t.type||"clipboard";if(!c)return!1;A.$selected_content=c,A.$copy_type=l}return this.instance.capture(e,A),!0}}}isBrowserSupported(){return pB(Zo?.querySelectorAll)}},historyAutocapture:class{constructor(t){var e;this._instance=t,this.Ys=(wn==null||(e=wn.location)==null?void 0:e.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(wo.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.Xs&&this.Xs(),this.Xs=void 0,wo.info("History API monitoring stopped")}monitorHistoryChanges(){wn&&wn.history&&(this.eo("pushState"),this.eo("replaceState"),this.ro())}eo(t){var e;if(wn&&((e=wn.history[t])==null||!e.__posthog_wrapped__)){var n=this;(function(o,i,r){try{if(!(i in o))return pct;var A={next:o[i]},s=r((function(){for(var a=arguments.length,c=new Array(a),l=0;a>l;l++)c[l]=arguments[l];return A.next.apply(this,c)}));return pB(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:A}})),o[i]=s,()=>{if(o[i]!==s)for(var a=o[i];pB(a)&&a.__posthog_layer__;){var c=a.__posthog_layer__;if(c.next===s)return void(c.next=A.next);a=c.next}else o[i]=A.next}}catch{return pct}})(wn.history,t,(o=>function(i,r,A){o.call(this,i,r,A),n.io(t)}))}}io(t){try{var e,n=wn==null||(e=wn.location)==null?void 0:e.pathname;if(!n)return;n!==this.Ys&&this.isEnabled&&this._instance.capture(I9,{navigation_type:t}),this.Ys=n}catch(o){wo.error("Error capturing "+t+" pageview",o)}}ro(){if(!this.Xs){var t=()=>{this.io("popstate")};au(wn,"popstate",t),this.Xs=()=>{wn&&wn.removeEventListener("popstate",t)}}}},heatmaps:class{get Se(){return this.instance.config}constructor(t){var e;this.no=!1,this.Vs=!1,this.so=null,this.instance=t,this.no=!((e=this.instance.persistence)==null||!e.props[Bpe]),this.rageclicks=new mct(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return P0(this.Se.capture_heatmaps)&&this.Se.capture_heatmaps.flush_interval_milliseconds&&(t=this.Se.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return as(this.Se.capture_heatmaps)?as(this.Se.enable_heatmaps)?this.no:this.Se.enable_heatmaps:this.Se.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.Vs)return;kTn.info("starting..."),this.oo(),this.ke()}else{var t;clearInterval((t=this.so)!==null&&t!==void 0?t:void 0),this.ao(),this.getAndClearBuffer()}}onRemoteConfig(t){if("heatmaps"in t){var e=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Bpe]:e}),this.no=e,this.startIfEnabled()}}getAndClearBuffer(){var t=this.R;return this.R=void 0,t}lo(t){this.fe(t.originalEvent,"deadclick")}ke(){this.so&&clearInterval(this.so),this.so=Zo?.visibilityState==="visible"?setInterval(this.Wr.bind(this),this.flushIntervalMilliseconds):null}oo(){wn&&Zo&&(this.uo=this.Wr.bind(this),au(wn,nX,this.uo),this.ho=t=>this.fe(t||wn?.event),au(Zo,"click",this.ho,{capture:!0}),this.do=t=>this.co(t||wn?.event),au(Zo,"mousemove",this.do,{capture:!0}),this.vo=new xat(this.instance,XRn,this.lo.bind(this)),this.vo.startIfEnabledOrStop(),this.fo=this.ke.bind(this),au(Zo,tX,this.fo),this.Vs=!0)}ao(){var t;wn&&Zo&&(this.uo&&wn.removeEventListener(nX,this.uo),this.ho&&Zo.removeEventListener("click",this.ho,{capture:!0}),this.do&&Zo.removeEventListener("mousemove",this.do,{capture:!0}),this.fo&&Zo.removeEventListener(tX,this.fo),clearTimeout(this.po),(t=this.vo)==null||t.stop(),this.Vs=!1)}mo(t,e){var n=this.instance.scrollManager.scrollY(),o=this.instance.scrollManager.scrollX(),i=this.instance.scrollManager.scrollElement(),r=(function(A,s,a){for(var c=A;c&&Ub(c)&&!ky(c,"body");){if(c===a)return!1;var l=void 0;try{var g,u,d;l=(g=(u=(d=c.ownerDocument)==null?void 0:d.defaultView)!==null&&u!==void 0?u:wn)==null?void 0:g.getComputedStyle(c).position}catch{return!1}if(gA(s,l))return!0;c=uat(c)}return!1})(Wpe(t),["fixed","sticky"],i);return{x:t.clientX+(r?0:o),y:t.clientY+(r?0:n),target_fixed:r,type:e}}fe(t,e){var n;if(e===void 0&&(e="click"),!Aat(t.target)&&yct(t)){var o=this.mo(t,e);(n=this.rageclicks)!=null&&n.isRageClick(t.clientX,t.clientY,new Date().getTime())&&mat(Wpe(t),this.instance.config.rageclick)&&this.kt(fo({},o,{type:"rageclick"})),this.kt(o)}}co(t){!Aat(t.target)&&yct(t)&&(clearTimeout(this.po),this.po=setTimeout((()=>{this.kt(this.mo(t,"mousemove"))}),500))}kt(t){if(wn){var e=this.Se.disable_capture_url_hashes?Kb(wn.location.href):wn.location.href,n=this.Se.custom_personal_data_properties,o=this.Se.mask_personal_data_properties?[...f9,...n||[]]:[],i=IL(e,o,CL);this.R=this.R||{},this.R[i]||(this.R[i]=[]),this.R[i].push(t)}}Wr(){this.R&&!Ob(this.R)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:xat,webVitalsAutocapture:class{constructor(t){var e;this.no=!1,this.Vs=!1,this.R={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.yo=()=>{clearTimeout(this.bo),this.R.metrics.length!==0&&(this._instance.capture("$web_vitals",this.R.metrics.reduce(((n,o)=>fo({},n,{["$web_vitals_"+o.name+"_event"]:fo({},o),["$web_vitals_"+o.name+"_value"]:o.value})),{})),this.R={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this._o=n=>{var o;this.R=this.R||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var i=this.wo();if(!To(i))if(as(n?.name)||as(n?.value))_P.error("Invalid metric received",n);else if(!this.xo||this.xo>n.value){this.R.url!==i&&(this.yo(),this.bo=setTimeout(this.yo,this.flushToCaptureTimeoutMs)),To(this.R.url)&&(this.R.url=i),this.R.firstMetricTimestamp=To(this.R.firstMetricTimestamp)?Date.now():this.R.firstMetricTimestamp,n.attribution&&n.attribution.interactionTargetElement&&(n.attribution.interactionTargetElement=void 0);var r=(o=this._instance.sessionManager)==null?void 0:o.checkAndGetSessionAndWindowId(!0),A=fo({},n,{$current_url:i,timestamp:Date.now()});To(r)||(A.$session_id=r.sessionId,A.$window_id=r.windowId),this.R.metrics.push(A),this.R.metrics.length===this.allowedMetrics.length&&this.yo()}else _P.error("Ignoring metric with value >= "+this.xo,n)},this.ko=()=>{if(!this.Vs){var n,o,i,r,A=_r.__PosthogExtensions__;if(!To(A)&&!To(A.postHogWebVitalsCallbacks)){var s=A.postHogWebVitalsCallbacks;n=s.onLCP,o=s.onCLS,i=s.onFCP,r=s.onINP}n&&o&&i&&r?(this.allowedMetrics.indexOf("LCP")>-1&&n(this._o.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&o(this._o.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&i(this._o.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&r(this._o.bind(this)),this.Vs=!0):_P.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.no=!((e=this._instance.persistence)==null||!e.props[bpe]),this.startIfEnabled()}get So(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,n=P0(this.So)?(t=this.So)==null?void 0:t.web_vitals_allowed_metrics:void 0;return as(n)?((e=this._instance.persistence)==null?void 0:e.props[wpe])||["CLS","FCP","INP","LCP"]:n}get flushToCaptureTimeoutMs(){return(P0(this.So)?this.So.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var t=P0(this.So)?this.So.web_vitals_attribution:void 0;return t!=null&&t}get xo(){var t=P0(this.So)&&Dp(this.So.__web_vitals_max_value)?this.So.__web_vitals_max_value:Ict;return t>0&&6e4>=t?Ict:t}get isEnabled(){var t=rd?.protocol;if(t!=="http:"&&t!=="https:")return _P.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=P0(this.So)?this.So.web_vitals:Wx(this.So)?this.So:void 0;return Wx(e)?e:this.no}startIfEnabled(){this.isEnabled&&!this.Vs&&(_P.info("enabled, starting..."),this.Bt(this.ko))}onRemoteConfig(t){if("capturePerformance"in t){var e=P0(t.capturePerformance)&&!!t.capturePerformance.web_vitals,n=P0(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[bpe]:e}),this._instance.persistence.register({[wpe]:n})),this.no=e,this.startIfEnabled()}}Bt(t){var e,n;(e=_r.__PosthogExtensions__)!=null&&e.postHogWebVitalsCallbacks?t():(n=_r.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,this.useAttribution?"web-vitals-with-attribution":"web-vitals",(o=>{o?_P.error("failed to load script",o):t()}))}wo(){var t=wn?this._instance.config.disable_capture_url_hashes?Kb(wn.location.href):wn.location.href:void 0;if(t){var e=this._instance.config.custom_personal_data_properties,n=this._instance.config.mask_personal_data_properties?[...f9,...e||[]]:[];return IL(t,n,CL)}_P.error("Could not determine current URL")}}},VTn={exceptionObserver:class{constructor(t){var e,n,o,i,r,A;this.ko=()=>{var s;if(wn&&this.isEnabled&&(s=_r.__PosthogExtensions__)!=null&&s.errorWrappingFunctions){var a=_r.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,c=_r.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,l=_r.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Co&&this.Se.capture_unhandled_errors&&(this.Co=a(this.captureException.bind(this))),!this.To&&this.Se.capture_unhandled_rejections&&(this.To=c(this.captureException.bind(this))),!this.Io&&this.Se.capture_console_errors&&(this.Io=l(this.captureException.bind(this)))}catch(g){DL.error("failed to start",g),this.Mo()}}},this._instance=t,this.Eo=!((e=this._instance.persistence)==null||!e.props[xpe]),this.Ro=new VNn(fo({},((n=this._instance.config.error_tracking)===void 0&&(n={}),{refillRate:(o=(i=n.exceptionRateLimiterRefillRate)!==null&&i!==void 0?i:n.__exceptionRateLimiterRefillRate)!==null&&o!==void 0?o:1,bucketSize:(r=(A=n.exceptionRateLimiterBucketSize)!==null&&A!==void 0?A:n.__exceptionRateLimiterBucketSize)!==null&&r!==void 0?r:10}),{refillInterval:1e4,Ae:DL})),this.Se=this.Po(),this.startIfEnabledOrStop()}Po(){var t=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return P0(t)?e=fo({},e,t):(To(t)?this.Eo:t)&&(e=fo({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.Se.capture_console_errors||this.Se.capture_unhandled_errors||this.Se.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(DL.info("enabled"),this.Mo(),this.Bt(this.ko)):this.Mo()}Bt(t){var e,n;(e=_r.__PosthogExtensions__)!=null&&e.errorWrappingFunctions?t():(n=_r.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"exception-autocapture",(o=>{if(o)return DL.error("failed to load script",o);t()}))}Mo(){var t,e,n;(t=this.Co)==null||t.call(this),this.Co=void 0,(e=this.To)==null||e.call(this),this.To=void 0,(n=this.Io)==null||n.call(this),this.Io=void 0}onRemoteConfig(t){"autocaptureExceptions"in t&&(this.Eo=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[xpe]:this.Eo}),this.Se=this.Po(),this.startIfEnabledOrStop())}onConfigChange(){this.Se=this.Po()}captureException(t){var e,n,o,i=(e=t==null||(n=t.$exception_list)==null||(n=n[0])==null?void 0:n.type)!==null&&e!==void 0?e:"Exception";this.Ro.consumeRateLimit(i)?DL.info("Skipping exception capture because of client rate limiting.",{exception:i}):(o=this._instance.exceptions)==null||o.sendExceptionEvent(t)}},exceptions:class{constructor(t){var e,n;this.Oo=[],this.Lo=new aRn([new mRn,new QRn,new IRn,new pRn,new BRn,new ERn,new fRn,new xRn],(function(o){for(var i=arguments.length,r=new Array(i>1?i-1:0),A=1;i>A;A++)r[A-1]=arguments[A];return function(s,a){a===void 0&&(a=0);for(var c=[],l=s.split(`
|
|
1045
1045
|
`),g=a;l.length>g;g++){var u=l[g];if(1024>=u.length){var d=Ost.test(u)?u.replace(Ost,"$1"):u;if(!d.match(/\S*Error: /)){for(var h of r){var _=h(d,o);if(_){c.push(_);break}}if(c.length>=50)break}}}return(function(p){if(!p.length)return[];var m=Array.from(p);return m.reverse(),m.slice(0,50).map((I=>{return fo({},I,{filename:I.filename||(C=m,C[C.length-1]||{}).filename,function:I.function||h9});var C}))})(c)}})("web:javascript",uRn,_Rn)),this._instance=t,this.Oo=(e=(n=this._instance.persistence)==null?void 0:n.get_property(Qpe))!==null&&e!==void 0?e:[],this.Fo=Jj(this.Ao()),this.$o=new bRn(this.Fo)}onConfigChange(){this.Fo=Jj(this.Ao()),this.$o.setConfig(this.Fo)}onRemoteConfig(t){var e,n,o;if("errorTracking"in t){var i=(e=(n=t.errorTracking)==null?void 0:n.suppressionRules)!==null&&e!==void 0?e:[],r=(o=t.errorTracking)==null?void 0:o.captureExtensionExceptions;this.Oo=i,this._instance.persistence&&this._instance.persistence.register({[Qpe]:this.Oo,[Spe]:r})}}get No(){var t,e=!!this._instance.get_property(Spe),n=this._instance.config.error_tracking.captureExtensionExceptions;return(t=n??e)!==null&&t!==void 0&&t}buildProperties(t,e){return this.Lo.buildFromUnknown(t,{syntheticException:e?.syntheticException,mechanism:{handled:e?.handled}})}addExceptionStep(t,e){if(this.Fo.enabled)try{if(!Xl(t)||t.trim().length===0)return void jS.warn("Ignoring exception step because message must be a non-empty string");var n=(function(r){if(!r)return{sanitizedProperties:{},droppedKeys:[]};var A=[];return{sanitizedProperties:Object.keys(r).reduce(((s,a)=>SRn.has(a)?(A.push(a),s):(s[a]=r[a],s)),{}),droppedKeys:A}})(this.Do(e)),o=n.sanitizedProperties,i=n.droppedKeys;i.length>0&&jS.warn("Ignoring reserved exception step fields",{droppedKeys:i}),this.$o.add(fo({[Vj]:t,[zj]:new Date().toISOString()},o))}catch(r){jS.error("Failed to add exception step. Ignoring breadcrumb.",r)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.qo(e)){if(this.jo(e))return this.Bo("Exception dropped: matched a suppression rule"),void jS.info("Skipping exception capture because a suppression rule matched");if(!this.No&&this.Ho(e))return this.Bo("Exception dropped: thrown by a browser extension"),void jS.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Uo(e))return this.Bo("Exception dropped: thrown by the PostHog SDK"),void jS.info("Skipping exception capture because it was thrown by the PostHog SDK")}var n=this.Fo.enabled&&as(t.$exception_steps)?this.zo(t):t;try{var o=this._instance.capture("$exception",n,{_noTruncate:!0,_batchKey:"exceptionEvent",ln:!0});return o&&this.$o.clear(),o}catch(i){return jS.error("Failed to capture exception event. Dropping this exception.",i),void this.$o.clear()}}catch(i){return void jS.error("Failed to process exception event. Ignoring this exception.",i)}}zo(t){try{var e=this.$o.getAttachable();return e.length===0?t:fo({},t,{$exception_steps:e})}catch(n){return jS.error("Failed to read buffered exception steps. Capturing exception without steps.",n),t}}Bo(t){this.Fo.enabled&&this.$o.add({[Vj]:t,[zj]:new Date().toISOString()})}Do(t){return P0(t)?fo({},t):{}}Ao(){var t,e;return(t=(e=this._instance.config.error_tracking)==null?void 0:e.exception_steps)!==null&&t!==void 0?t:{}}jo(t){if(t.length===0)return!1;var e=t.reduce(((n,o)=>{var i=o.type,r=o.value;return Xl(i)&&i.length>0&&n.$exception_types.push(i),Xl(r)&&r.length>0&&n.$exception_values.push(r),n}),{$exception_types:[],$exception_values:[]});return this.Oo.some((n=>{var o=n.values.map((i=>{var r,A=Act[i.operator],s=bs(i.value)?i.value:[i.value],a=(r=e[i.key])!==null&&r!==void 0?r:[];return s.length>0&&A(s,a)}));return n.type==="OR"?o.some(Boolean):o.every(Boolean)}))}Ho(t){return t.flatMap((e=>{var n,o;return(n=(o=e.stacktrace)==null?void 0:o.frames)!==null&&n!==void 0?n:[]})).some((e=>e.filename&&e.filename.startsWith("chrome-extension://")))}Uo(t){if(t.length>0){var e,n,o,i,r=(e=(n=t[0].stacktrace)==null?void 0:n.frames)!==null&&e!==void 0?e:[],A=r[r.length-1];return(o=A==null||(i=A.filename)==null?void 0:i.includes("posthog.com/static"))!==null&&o!==void 0&&o}return!1}qo(t){return!as(t)&&bs(t)}}},zTn=fo({productTours:class{get ri(){return this._instance.persistence}constructor(t){this.Wo=null,this.Vo=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if("productTours"in t){var e,n;if(this.ri&&this.ri.register({[Mpe]:!!t.productTours}),!SIe(this._instance))return!this.Wo&&as((e=this.ri)==null?void 0:e.props[gL])||QIe.info("product tours disabled; stopping and clearing cached tours"),(n=this.Wo)==null||n.stop(),this.Wo=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this.Wo&&SIe(this._instance)&&this.Bt((()=>this.Zo()))}Bt(t){var e,n;(e=_r.__PosthogExtensions__)!=null&&e.generateProductTours?t():(n=_r.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"product-tours",(o=>{o?QIe.error("Could not load product tours script",o):t()}))}Zo(){var t;!this.Wo&&(t=_r.__PosthogExtensions__)!=null&&t.generateProductTours&&(this.Wo=_r.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(e===void 0&&(e=!1),!bs(this.Vo)||e){var n=this.ri;if(n){var o=n.props[gL];if(bs(o)&&!e)return this.Vo=o,void t(o,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:i=>{if(SIe(this._instance)){var r=i.statusCode;if(r!==200||!i.json){var A="Product Tours API could not be loaded, status: "+r;return QIe.error(A),void t([],{isLoaded:!1,error:A})}var s=bs(i.json.product_tours)?i.json.product_tours:[];this.Vo=s,n&&n.register({[gL]:s}),t(s,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.Vo,{isLoaded:!0})}getActiveProductTours(t){as(this.Wo)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.Wo.getActiveProductTours(t)}showProductTour(t){var e;(e=this.Wo)==null||e.showTourById(t)}previewTour(t){this.Wo?this.Wo.previewTour(t):this.Bt((()=>{var e;this.Zo(),(e=this.Wo)==null||e.previewTour(t)}))}dismissProductTour(){var t;(t=this.Wo)==null||t.dismissTour("user_clicked_skip")}nextStep(){var t;(t=this.Wo)==null||t.nextStep()}previousStep(){var t;(t=this.Wo)==null||t.previousStep()}clearCache(){var t;this.Vo=null,(t=this.ri)==null||t.unregister(gL)}resetTour(t){var e;(e=this.Wo)==null||e.resetTour(t)}resetAllTours(){var t;(t=this.Wo)==null||t.resetAllTours()}cancelPendingTour(t){var e;(e=this.Wo)==null||e.cancelPendingTour(t)}}},fX),JTn={siteApps:class{constructor(t){this.Go=0,this._instance=t,this.Qo=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Jo(t,e){if(e){var n=this.globalsForEvent(e);this.Qo.push(n),this.Qo.length>1e3&&(this.Qo=this.Qo.slice(10))}}get siteAppLoaders(){var t;return(t=_r._POSTHOG_REMOTE_CONFIG)==null||(t=t[this._instance.config.token])==null?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.Jo.bind(this));this.Ko=()=>{t(),this.Qo=[],this.Ko=void 0}}}globalsForEvent(t){var e,n,o,i,r,A,s;if(!t)throw new Error("Event payload is required");var a={},c=this._instance.get_property("$groups")||[],l=this._instance.get_property("$stored_group_properties")||{};for(var g of Object.entries(l)){var u=g[0];a[u]={id:c[u],type:u,properties:g[1]}}var d=t.$set_once,h=t.$set;return{event:fo({},jAt(t,FTn),{properties:fo({},t.properties,h?{$set:fo({},(e=(n=t.properties)==null?void 0:n.$set)!==null&&e!==void 0?e:{},h)}:{},d?{$set_once:fo({},(o=(i=t.properties)==null?void 0:i.$set_once)!==null&&o!==void 0?o:{},d)}:{}),elements_chain:(r=(A=t.properties)==null?void 0:A.$elements_chain)!==null&&r!==void 0?r:"",distinct_id:(s=t.properties)==null?void 0:s.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:a}}Yo(t){var e,n=(e=t.tagName)==null?void 0:e.toLowerCase();return n==="style"&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(t)||($x.error("prepare_external_dependency_stylesheet returned null"),null):n==="script"&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(t)||($x.error("prepare_external_dependency_script returned null"),null):t}Xo(){var t,e,n,o,i,r,A,s;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var a=Zo?.defaultView,c=a==null||(t=a.Node)==null?void 0:t.prototype;if(!a||!c)return()=>{};if(this.Go++,this.ea)return this.ta();var l=[],g=this,u=new WeakSet,d=(p,m,I)=>{if(p!=null&&p[m]){var C=p[m];p[m]=I(C),l.push((()=>{p[m]=C}))}},h=p=>{if(u.has(p))return p;var m=g.Yo(p);return m&&u.add(m),m},_=p=>p.map((m=>typeof m=="string"?m:h(m))).filter((m=>!qC(m)));return d(c,"appendChild",(p=>function(m){var I=h(m);return I?p.call(this,I):m})),d(c,"insertBefore",(p=>function(m,I){var C=h(m);return C?p.call(this,C,I):m})),d(c,"replaceChild",(p=>function(m,I){var C=h(m);return C?p.call(this,C,I):I})),[(e=a.Element)==null?void 0:e.prototype,(n=a.Document)==null?void 0:n.prototype,(o=a.DocumentFragment)==null?void 0:o.prototype].forEach((p=>{d(p,"append",(m=>function(){for(var I=arguments.length,C=new Array(I),f=0;I>f;f++)C[f]=arguments[f];return m.apply(this,_(C))})),d(p,"prepend",(m=>function(){for(var I=arguments.length,C=new Array(I),f=0;I>f;f++)C[f]=arguments[f];return m.apply(this,_(C))}))})),[(i=a.Element)==null?void 0:i.prototype,(r=a.CharacterData)==null?void 0:r.prototype,(A=a.DocumentType)==null?void 0:A.prototype].forEach((p=>{d(p,"before",(m=>function(){for(var I=arguments.length,C=new Array(I),f=0;I>f;f++)C[f]=arguments[f];return m.apply(this,_(C))})),d(p,"after",(m=>function(){for(var I=arguments.length,C=new Array(I),f=0;I>f;f++)C[f]=arguments[f];return m.apply(this,_(C))})),d(p,"replaceWith",(m=>function(){for(var I=arguments.length,C=new Array(I),f=0;I>f;f++)C[f]=arguments[f];var y=_(C);return C.length&&!y.length?void 0:m.apply(this,y)}))})),d((s=a.Element)==null?void 0:s.prototype,"insertAdjacentElement",(p=>function(m,I){var C=h(I);return C?p.call(this,m,C):null})),this.ea=()=>{l.forEach((p=>p())),this.ea=void 0},this.ta()}ta(){var t=!1;return()=>{var e;t||(t=!0,this.Go--,this.Go===0&&((e=this.ea)==null||e.call(this)))}}ra(t,e){e===void 0&&(e=!0);var n=this.Xo();try{var o=t(n);return e&&n(),o}catch(i){throw n(),i}}setupSiteApp(t){var e=this.apps[t.id],n=()=>{var A;!e.errored&&this.Qo.length&&($x.info("Processing "+this.Qo.length+" events for site app with id "+t.id),this.Qo.forEach((s=>this.ra((()=>e.processEvent==null?void 0:e.processEvent(s))))),e.processedBuffer=!0),Object.values(this.apps).every((s=>s.processedBuffer||s.errored))&&((A=this.Ko)==null||A.call(this))},o=!1,i=A=>{e.errored=!A,e.loaded=!0,$x.info("Site app with id "+t.id+" "+(A?"loaded":"errored")),o&&n()};try{var r=this.ra((A=>t.init({posthog:this._instance,callback(s){A(),i(s)}})),!1).processEvent;r&&(e.processEvent=r),o=!0}catch(A){$x.error(Ect+t.id,A),i(!1)}if(o&&e.loaded)try{n()}catch(A){$x.error("Error while processing buffered events PostHog app with config id "+t.id,A),e.errored=!0}}ia(){var t=this.siteAppLoaders||[];for(var e of t)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(var n of t)this.setupSiteApp(n)}na(t){var e=this;if(Object.keys(this.apps).length!==0){var n=this.globalsForEvent(t),o=function(r){try{e.ra((()=>r.processEvent==null?void 0:r.processEvent(n)))}catch(A){$x.error("Error while processing event "+t.event+" for site app "+r.id,A)}};for(var i of Object.values(this.apps))o(i)}}onRemoteConfig(t){var e,n,o,i=this;if((e=this.siteAppLoaders)!=null&&e.length)return this.isEnabled?(this.ia(),void this._instance.on("eventCaptured",(s=>this.na(s)))):void $x.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((n=this.Ko)==null||n.call(this),(o=t.siteApps)!=null&&o.length)if(this.isEnabled){var r=function(){var s,a=A.id,c=A.url;_r["__$$ph_site_app_"+a]=i._instance,(s=_r.__PosthogExtensions__)==null||s.loadSiteApp==null||s.loadSiteApp(i._instance,c,(l=>{if(l)return $x.error(Ect+a,l)}))};for(var A of t.siteApps)r()}else $x.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},qTn={tracingHeaders:class{constructor(t){this.sa=void 0,this.oa=void 0,this.aa=void 0,this.ko=()=>{var e,n,o=this.la();o?(To(this.sa)&&(this.sa=(e=_r.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null?void 0:e._patchXHR(o,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),To(this.oa)&&(this.oa=(n=_r.__PosthogExtensions__)==null||(n=n.tracingHeadersPatchFns)==null?void 0:n._patchFetch(o,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this.Mo()},this._instance=t}initialize(){this.startIfEnabledOrStop()}Bt(t){var e,n;(e=_r.__PosthogExtensions__)!=null&&e.tracingHeadersPatchFns?t():(n=_r.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"tracing-headers",(o=>{if(o)return TTn.error("failed to load script",o);t()}))}ua(){var t,e;return(t=(e=this._instance.config.tracing_headers)!==null&&e!==void 0?e:this._instance.config.addTracingHeaders)!==null&&t!==void 0?t:this._instance.config.__add_tracing_headers}la(){var t=this.ua();return bs(t)?(bs(this.aa)?this.aa.splice(0,this.aa.length,...t):this.aa=[...t],t.length>0?this.aa:void 0):(bs(this.aa)&&this.aa.splice(0),this.aa=t||void 0,this.aa)}Mo(){var t,e;(t=this.sa)==null||t.call(this),(e=this.oa)==null||e.call(this),this.sa=void 0,this.oa=void 0}startIfEnabledOrStop(){this.la()?this.Bt(this.ko):this.Mo()}}},WTn=fo({surveys:class{get Se(){return this._instance.config}constructor(t){this.ha=void 0,this._surveyManager=null,this.da=!1,this.ca=[],this.va=null,this.fa=null,this._instance=t,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this.Se.disable_surveys){var e=t.surveys;if(as(e))return $l.warn("Flags not loaded yet. Not loading surveys.");var n=bs(e);this.ha=n?e.length>0:e,$l.info("flags response received, isSurveysEnabled: "+this.ha),this.loadIfEnabled()}}reset(){try{var t;(t=this._surveyEventReceiver)==null||t.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var e=[],n=0;n<localStorage.length;n++){var o=localStorage.key(n);(o!=null&&o.startsWith(CIe)||o!=null&&o.startsWith("inProgressSurvey_"))&&e.push(o)}e.forEach((i=>localStorage.removeItem(i)))}catch{}}loadIfEnabled(){if(!this._surveyManager)if(this.da)$l.info("Already initializing surveys, skipping...");else if(this.Se.disable_surveys)$l.info(Bct);else if(this.Se.cookieless_mode&&this._instance.consent.isOptedOut())$l.info("Not loading surveys in cookieless mode without consent.");else{var t=_r?.__PosthogExtensions__;if(t){if(!To(this.ha)||this.Se.advanced_enable_surveys){var e=this.ha||this.Se.advanced_enable_surveys;this.da=!0;try{var n=t.generateSurveys;if(n)return void this.pa(n,e);var o=t.loadExternalDependency;if(!o)return void this.ga(Kpe);o(this._instance,"surveys",(i=>{i||!t.generateSurveys?this.ga("Could not load surveys script",i):this.pa(t.generateSurveys,e)}))}catch(i){throw this.ga("Error initializing surveys",i),i}finally{this.da=!1}}}else $l.error("PostHog Extensions not found.")}}pa(t,e){this._surveyManager=t(this._instance,e),this._surveyEventReceiver=new GTn(this._instance),$l.info("Surveys loaded successfully"),this.ma({isLoaded:!0})}ga(t,e){$l.error(t,e),this.ma({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.ca.push(t),this._surveyManager&&this.ma({isLoaded:!0}),()=>{this.ca=this.ca.filter((e=>e!==t))}}getSurveys(t,e){if(e===void 0&&(e=!1),this.Se.disable_surveys)return $l.info(Bct),t([]);var n,o=this._instance.get_property(Rpe);if(o&&!e)return t(o,{isLoaded:!0}),void(this.ya()&&this.getSurveys((()=>{}),!0));typeof Promise<"u"&&this.va?this.va.then((i=>t(i.surveys,i.context))):(typeof Promise<"u"&&(this.va=new Promise((i=>{n=i}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this.Se.token),method:"GET",timeout:this.Se.surveys_request_timeout_ms,callback:i=>{var r;this.va=null;var A=i.statusCode;if(A!==200||!i.json){var s="Surveys API could not be loaded, status: "+A;$l.error(s),this.fa=Date.now();var a={isLoaded:!1,error:s};return t([],a),void(n==null||n({surveys:[],context:a}))}this.fa=null;var c,l=i.json.surveys||[],g=l.filter((d=>(function(h){return!(!h.start_date||h.end_date)})(d)&&((function(h){var _;return!((_=h.conditions)==null||(_=_.events)==null||(_=_.values)==null||!_.length)})(d)||(function(h){var _;return!((_=h.conditions)==null||(_=_.actions)==null||(_=_.values)==null||!_.length)})(d))));g.length>0&&((c=this._surveyEventReceiver)==null||c.register(g)),(r=this._instance.persistence)==null||r.register({[Rpe]:l,[Xj]:Date.now()});var u={isLoaded:!0};t(l,u),n?.({surveys:l,context:u})}}))}ya(){return this.ba()&&!this.va&&!this._a()}ba(){var t=this._instance.get_property(Xj);return Dp(t)&&Date.now()-t>3e5}_a(){return Dp(this.fa)&&3e5>Date.now()-this.fa}markSurveyAsSeen(t,e){var n,o={id:t,current_iteration:(n=e?.iteration)!==null&&n!==void 0?n:null};cct(o);try{localStorage.setItem("lastSeenSurveyDate",new Date().toISOString())}catch{}}ma(t){for(var e of this.ca)try{if(!t.isLoaded)return e([],t);this.getSurveys(e)}catch(n){$l.error("Error in survey callback",n)}}getActiveMatchingSurveys(t,e){if(e===void 0&&(e=!1),!as(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);$l.warn("init was not called")}wa(t){var e=null;return this.getSurveys((n=>{var o;e=(o=n.find((i=>i.id===t)))!==null&&o!==void 0?o:null})),e}xa(t){if(as(this._surveyManager))return{eligible:!1,reason:bIe};var e=typeof t=="string"?this.wa(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(as(this._surveyManager))return $l.warn("init was not called"),{visible:!1,disabledReason:bIe};var e=this.xa(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return as(this._surveyManager)?($l.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:bIe})):new Promise((n=>{this.getSurveys((o=>{var i,r=(i=o.find((s=>s.id===t)))!==null&&i!==void 0?i:null;if(r){var A=this.xa(r);n({visible:A.eligible,disabledReason:A.reason})}else n({visible:!1,disabledReason:"Survey not found"})}),e)}))}renderSurvey(t,e,n){var o;if(as(this._surveyManager))$l.warn("init was not called");else{var i=typeof t=="string"?this.wa(t):t;if(i!=null&&i.id)if(STn.includes(i.type)){var r=Zo?.querySelector(e);if(r)return(o=i.appearance)!=null&&o.surveyPopupDelaySeconds?($l.info("Rendering survey "+i.id+" with delay of "+i.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var A,s;$l.info("Rendering survey "+i.id+" with delay of "+((A=i.appearance)==null?void 0:A.surveyPopupDelaySeconds)+" seconds"),(s=this._surveyManager)==null||s.renderSurvey(i,r,n),$l.info("Survey "+i.id+" rendered")}),1e3*i.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(i,r,n);$l.warn("Survey element not found")}else $l.warn("Surveys of type "+i.type+" cannot be rendered in the app");else $l.warn("Survey not found")}}displaySurvey(t,e){var n;if(as(this._surveyManager))$l.warn("init was not called");else{var o=this.wa(t);if(o){var i=o;if((n=o.appearance)!=null&&n.surveyPopupDelaySeconds&&e.ignoreDelay&&(i=fo({},o,{appearance:fo({},o.appearance,{surveyPopupDelaySeconds:0})})),e.displayType!==iIe.Popover&&e.initialResponses&&$l.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),e.ignoreConditions===!1){var r=this.canRenderSurvey(o);if(!r.visible)return void $l.warn("Survey is not eligible to be displayed: ",r.disabledReason)}e.displayType!==iIe.Inline?this._surveyManager.handlePopoverSurvey(i,e):this.renderSurvey(i,e.selector,e.properties)}else $l.warn("Survey not found")}}cancelPendingSurvey(t){as(this._surveyManager)?$l.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;(t=this._surveyManager)==null||t.handlePageUnload==null||t.handlePageUnload()}}},fX),jTn={toolbar:class{constructor(t){this.instance=t}ka(t){_r.ph_toolbar_state=t}Sa(){var t;return(t=_r.ph_toolbar_state)!==null&&t!==void 0?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t,e,n){if(t===void 0&&(t=void 0),e===void 0&&(e=void 0),n===void 0&&(n=void 0),nat(this.instance.config)||!wn||!Zo)return!1;t=t??wn.location,n=n??wn.history;try{if(!e){try{wn.localStorage.setItem("test","test"),wn.localStorage.removeItem("test")}catch{return!1}e=wn?.localStorage}var o,i=OTn||lX(t.hash,"__posthog")||lX(t.hash,"state"),r=i?tat((()=>JSON.parse(atob(decodeURIComponent(i)))))||tat((()=>JSON.parse(decodeURIComponent(i)))):null;return r&&r.action==="ph_authorize"?((o=r).source="url",o&&Object.keys(o).length>0&&(r.desiredHash?t.hash=r.desiredHash:n?n.replaceState(n.state,"",t.pathname+t.search):t.hash="")):((o=JSON.parse(e.getItem(xct)||"{}")).source="localstorage",delete o.userIntent),!(!o.token||this.instance.config.token!==o.token||(this.loadToolbar(o),0))}catch{return!1}}Ca(t){var e=_r.ph_load_toolbar||_r.ph_load_editor;!as(e)&&pB(e)?e(t,this.instance):Qct.warn("No toolbar load function found")}loadToolbar(t){var e=!(Zo==null||!Zo.getElementById(jst));if(!wn||e)return!1;var n=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,o=fo({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor("ui")},n?{instrument:!1}:{});if(wn.localStorage.setItem(xct,JSON.stringify(fo({},o,{source:void 0}))),this.Sa()===2)this.Ca(o);else if(this.Sa()===0){var i;this.ka(1),(i=_r.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this.instance,"toolbar",(r=>{if(r)return Qct.error("[Toolbar] Failed to load",r),void this.ka(0);this.ka(2),this.Ca(o)})),au(wn,"turbolinks:load",(()=>{this.ka(0),this.loadToolbar(o)}))}return!0}Ta(t){return this.loadToolbar(t)}maybeLoadEditor(t,e,n){return t===void 0&&(t=void 0),e===void 0&&(e=void 0),n===void 0&&(n=void 0),this.maybeLoadToolbar(t,e,n)}}},XTn=fo({experiments:GI},fX),$Tn={conversations:class{constructor(t){this.Ia=void 0,this._conversationsManager=null,this.Ma=!1,this.Ea=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations){var e=t.conversations;as(e)||(Wx(e)?this.Ia=e:(this.Ia=e.enabled,this.Ea=e),this.loadIfEnabled())}}reset(){var t;(t=this._conversationsManager)==null||t.reset(),this._conversationsManager=null,this.Ia=void 0,this.Ea=null}loadIfEnabled(){if(!(this._conversationsManager||this.Ma||this._instance.config.disable_conversations||nat(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=_r?.__PosthogExtensions__;if(t&&!To(this.Ia)&&this.Ia)if(this.Ea&&this.Ea.token){this.Ma=!0;try{var e=t.initConversations;if(e)return this.Ra(e),void(this.Ma=!1);var n=t.loadExternalDependency;if(!n)return void this.Pa(Kpe);n(this._instance,"conversations",(o=>{o||!t.initConversations?this.Pa("Could not load conversations script",o):this.Ra(t.initConversations),this.Ma=!1}))}catch(o){this.Pa("Error initializing conversations",o),this.Ma=!1}}else s2.error("Conversations enabled but missing token in remote config.")}}Ra(t){if(this.Ea)try{this._conversationsManager=t(this.Ea,this._instance),s2.info("Conversations loaded successfully")}catch(e){this.Pa("Error completing conversations initialization",e)}else s2.error("Cannot complete initialization: remote config is null")}Pa(t,e){s2.error(t,e),this._conversationsManager=null,this.Ma=!1}show(){this._conversationsManager?this._conversationsManager.show():s2.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.Ia===!0&&!qC(this._conversationsManager)}isVisible(){var t,e;return(t=(e=this._conversationsManager)==null?void 0:e.isVisible())!==null&&t!==void 0&&t}sendMessage(t,e,n){var o=this;return Ih((function*(){return o._conversationsManager?o._conversationsManager.sendMessage(t,e,n):(s2.warn(pP),null)}))()}getMessages(t,e){var n=this;return Ih((function*(){return n._conversationsManager?n._conversationsManager.getMessages(t,e):(s2.warn(pP),null)}))()}markAsRead(t){var e=this;return Ih((function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(s2.warn(pP),null)}))()}getTickets(t){var e=this;return Ih((function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(s2.warn(pP),null)}))()}requestRestoreLink(t){var e=this;return Ih((function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(s2.warn(pP),null)}))()}restoreFromToken(t){var e=this;return Ih((function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(s2.warn(pP),null)}))()}restoreFromUrlToken(){var t=this;return Ih((function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(s2.warn(pP),null)}))()}getCurrentTicketId(){var t,e;return(t=(e=this._conversationsManager)==null?void 0:e.getCurrentTicketId())!==null&&t!==void 0?t:null}getWidgetSessionId(){var t,e;return(t=(e=this._conversationsManager)==null?void 0:e.getWidgetSessionId())!==null&&t!==void 0?t:null}fn(){var t;(t=this._conversationsManager)==null||t.setIdentity()}pn(){var t;(t=this._conversationsManager)==null||t.clearIdentity()}}},ZTn={logs:class{constructor(t){var e;this.Oa=!1,this.La=!1,this.Ae=v0("[logs]"),this.Lr=[],this.Fa=[],this.bs=0,this.Aa=()=>{var n,o;this.bs=0,(n=this.$a)==null||n.onReconnect(),(o=this.Na)==null||o.onReconnect()},this._instance=t,this._instance&&(e=this._instance.config.logs)!=null&&e.captureConsoleLogs&&(this.Oa=!0),wn&&au(wn,"online",this.Aa)}Da(t,e,n,o){var i,r=(function(A,s){var a,c,l,g,u,d,h,_=(a=A?.flushIntervalMs)!==null&&a!==void 0?a:3e3,p=(c=A?.maxBufferSize)!==null&&c!==void 0?c:100,m=s!=null&&s.consoleCapture?void 0:(l=A?.maxLogsPerInterval)!==null&&l!==void 0?l:1e3,I=To(m)?Math.max(p,2048):Math.max(p,m),C=A?.resourceAttributes;return{serviceName:(g=(u=C?.["service.name"])!==null&&u!==void 0?u:A?.serviceName)!==null&&g!==void 0?g:s?.serviceNameDefault,serviceVersion:(d=C?.["service.version"])!==null&&d!==void 0?d:A?.serviceVersion,environment:(h=C?.["deployment.environment"])!==null&&h!==void 0?h:A?.environment,resourceAttributes:C,beforeSend:A?.beforeSend,flushIntervalMs:_,maxBufferSize:p,maxQueueSize:I,maxBatchRecordsPerPost:100,rateCapWindowMs:_,maxLogsPerInterval:m,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}})((i=this._instance)==null||(i=i.config)==null?void 0:i.logs,n);return[new rRn(this.qa(t,e),r,this.Ae,(()=>this.ja()),(A=>A()),void 0,o),r]}Ba(){var t,e=(t=this._instance)==null||(t=t.config)==null?void 0:t.logs;if(!this.$a||this.Ha!==e){var n;(n=this.$a)==null||n.reset(),this.Ha=e;var o=this.Da((()=>this.Lr),(i=>{this.Lr=i}));this.$a=o[0],this.Ua=o[1]}return this.$a}za(){var t,e=(t=this._instance)==null||(t=t.config)==null?void 0:t.logs;if(!this.Na||this.Wa!==e){var n;(n=this.Na)==null||n.reset(),this.Wa=e;var o=this.Da((()=>this.Fa),(i=>{this.Fa=i}),{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},Mct);this.Na=o[0],this.Va=o[1]}return this.Na}initialize(){this.loadIfEnabled()}onRemoteConfig(t){var e,n=(e=t.logs)==null?void 0:e.captureConsoleLogs;!as(n)&&n&&(this.Oa=!0,this.loadIfEnabled())}reset(){var t,e;this.Lr=[],(t=this.$a)==null||t.reset(),this.Fa=[],(e=this.Na)==null||e.reset(),this.bs=0}captureLog(t){this.Ba().captureLog(t)}le(t){this.za().captureLog(t)}get logger(){return this.Za||(this.Za={trace:(t,e)=>this.captureLog({body:t,level:"trace",attributes:e}),debug:(t,e)=>this.captureLog({body:t,level:"debug",attributes:e}),info:(t,e)=>this.captureLog({body:t,level:"info",attributes:e}),warn:(t,e)=>this.captureLog({body:t,level:"warn",attributes:e}),error:(t,e)=>this.captureLog({body:t,level:"error",attributes:e}),fatal:(t,e)=>this.captureLog({body:t,level:"fatal",attributes:e})}),this.Za}flushLogs(t){t?this.Ga(t):(this.$a&&this.$a.flush().catch((e=>this.Ae.error("PostHog logs flush failed:",e))),this.Na&&this.Na.flush().catch((e=>this.Ae.error("PostHog logs flush failed:",e))))}loadIfEnabled(){if(this.Oa&&!this.La){var t=_r?.__PosthogExtensions__;if(t){var e=t.loadExternalDependency;e?e(this._instance,"logs",(n=>{var o;n||(o=t.logs)==null||!o.initializeLogs?this.Ae.error("Could not load logs script",n):(t.logs.initializeLogs(this._instance),this.La=!0)})):this.Ae.error(Kpe)}else this.Ae.error("PostHog Extensions not found.")}}qa(t,e){var n=this._instance;return{get isDisabled(){return!1},get optedOut(){return!n.is_capturing()},getPersistedProperty:o=>o===OS.LogsQueue?t():void 0,setPersistedProperty(o,i){var r;o===OS.LogsQueue&&e((r=i)!==null&&r!==void 0?r:[])},ht:o=>this.ht(o),getLibraryId:()=>Au.LIB_NAME,getLibraryVersion:()=>Au.LIB_VERSION}}ht(t){return new Promise((e=>{if(Dat(this.bs,3))e({kind:"fatal",error:new Error("logs endpoint is unreachable, dropping batch")});else{var n=!1,o=r=>{n||(n=!0,clearTimeout(i),e(r))},i=setTimeout((()=>o({kind:"retry-later",error:new Error("logs request timed out")})),9e4);this._instance._send_request({method:"POST",url:this.Qa(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:r=>{var A=r.statusCode;if(this.Ja(A),A>=200&&300>A)o({kind:"ok"});else if(A===413)o({kind:"too-large"});else if(A!==0&&A!==429&&500>A)o({kind:"fatal",error:new Error("logs request failed with status "+A)});else{var s;o({kind:"retry-later",error:(s=r.error)!==null&&s!==void 0?s:new Error("logs request failed with status "+A)})}}})}}))}Ja(t){(t!==0||this._instance.__loaded)&&(this.bs=Mat(t,this.bs,3,(()=>this.Ae.warn("Log requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped sending logs; will try again when connectivity changes."))))}Ga(t){this.Lr.length>0&&this.Ka(t,this.Lr,this.Ua,Au.LIB_NAME,(e=>{this.Lr=e})),this.Fa.length>0&&this.Ka(t,this.Fa,this.Va,Mct,(e=>{this.Fa=e}))}Ka(t,e,n,o,i){if(e.length!==0){var r=e.map((s=>s.record));i([]);var A=kst(r,Tst(n,Au.LIB_NAME,Au.LIB_VERSION),o,Au.LIB_VERSION);this._instance._send_request({method:"POST",url:this.Qa(),data:A,compression:"best-available",batchKey:"logs",transport:t})}}Qa(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}ja(){var t,e={};if(e.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var n=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0),o=n.windowId,i=n.sessionStartTimestamp,r=n.lastActivityTimestamp;e.sessionId=n.sessionId,e.windowId=o,as(i)||(e.sessionStartTimestamp=i),as(r)||(e.lastActivityTimestamp=r)}if(_r!=null&&(t=_r.location)!=null&&t.href&&(e.currentUrl=this._instance.config.disable_capture_url_hashes?Kb(_r.location.href):_r.location.href),this._instance.featureFlags){var A=this._instance.featureFlags.getFlags();A&&A.length>0&&(e.activeFeatureFlags=A)}return e}}},ekn={metrics:class{constructor(t){this.Ae=v0("[metrics]"),this._instance=t}initialize(){}Ba(){var t,e,n,o,i,r,A,s,a,c=(t=this._instance)==null||(t=t.config)==null?void 0:t.metrics;return this.$a&&this.Ha===c||((e=this.$a)==null||e.reset(),this.Ha=c,this.$a=new ARn(this.qa(),{serviceName:(o=(a=(n=c)==null?void 0:n.resourceAttributes)==null?void 0:a["service.name"])!==null&&o!==void 0?o:n?.serviceName,serviceVersion:(i=a?.["service.version"])!==null&&i!==void 0?i:n?.serviceVersion,environment:(r=a?.["deployment.environment"])!==null&&r!==void 0?r:n?.environment,resourceAttributes:a,beforeSend:n?.beforeSend,flushIntervalMs:(A=n?.flushIntervalMs)!==null&&A!==void 0?A:1e4,maxSeriesPerFlush:(s=n?.maxSeriesPerFlush)!==null&&s!==void 0?s:1e3},this.Ae)),this.$a}count(t,e,n){e===void 0&&(e=1),this.Ba().count(t,e,n)}gauge(t,e,n){this.Ba().gauge(t,e,n)}histogram(t,e,n){this.Ba().histogram(t,e,n)}flush(t){if(!this.$a)return Promise.resolve();if(t){var e=this.$a.drainWindow();return e&&this.It(e,t),Promise.resolve()}return this.$a.flush().catch((n=>this.Ae.error("PostHog metrics flush failed:",n)))}reset(){var t;(t=this.$a)==null||t.reset()}qa(){var t=this._instance,e=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},It:n=>e.It(n),getLibraryId:()=>Au.LIB_NAME,getLibraryVersion:()=>Au.LIB_VERSION}}It(t,e){return new Promise((n=>{var o=!1,i=A=>{o||(o=!0,clearTimeout(r),n(A))},r=setTimeout((()=>i({kind:"retry-later",error:new Error("metrics request timed out")})),9e4);this._instance._send_request(fo({method:"POST",url:this.Ya(),data:t,compression:"best-available",batchKey:"metrics"},e&&{transport:e},{fireCallbackOnDrop:!0,callback(A){var s=A.statusCode;if(s>=200&&300>s)i({kind:"ok"});else if(s===413)i({kind:"too-large"});else if(s!==0&&s!==429&&500>s)i({kind:"fatal",error:new Error("metrics request failed with status "+s)});else{var a;i({kind:"retry-later",error:(a=A.error)!==null&&a!==void 0?a:new Error("metrics request failed with status "+s)})}}}))}))}Ya(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},tkn=fo({},fX,UTn,YTn,VTn,zTn,JTn,WTn,qTn,jTn,XTn,$Tn,ZTn,ekn);A2.__defaultExtensionClasses=fo({},tkn);var b9=(function(){Au.SDK_DIST_CHANNEL="npm";var t=SL[Q9]=new A2;return(function(){function e(){e.done||(e.done=!0,hct=!1,pg(SL,(function(n){n._dom_loaded()})))}Zo!=null&&Zo.addEventListener?Zo.readyState==="complete"?e():au(Zo,"DOMContentLoaded",e,{capture:!1}):wn&&wo.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),t})();class Yb extends Error{response;request;options;constructor(e,n,o){const i=e.status||e.status===0?e.status:"",r=e.statusText??"",A=`${i} ${r}`.trim(),s=A?`status code ${A}`:"an unknown error";super(`Request failed with ${s}: ${n.method} ${n.url}`),this.name="HTTPError",this.response=e,this.request=n,this.options=o}}class wct extends Error{name="NonError";value;constructor(e){let n="Non-error value was thrown";try{typeof e=="string"?n=e:e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"&&(n=e.message)}catch{}super(n),this.value=e}}class MIe extends Error{name="ForceRetryError";customDelay;code;customRequest;constructor(e){const n=e?.cause?e.cause instanceof Error?e.cause:new wct(e.cause):void 0;super(e?.code?`Forced retry: ${e.code}`:"Forced retry",n?{cause:n}:void 0),this.customDelay=e?.delay,this.code=e?.code,this.customRequest=e?.request}}const Pct=(()=>{let t=!1,e=!1;const n=typeof globalThis.ReadableStream=="function",o=typeof globalThis.Request=="function";if(n&&o)try{e=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type")}catch(i){if(i instanceof Error&&i.message==="unsupported BodyInit type")return!1;throw i}return t&&!e})(),nkn=typeof globalThis.AbortController=="function",vct=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",okn=typeof globalThis.ReadableStream=="function",ikn=typeof globalThis.FormData=="function",Nct=["get","post","put","patch","head","delete"],rkn={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},wIe=2147483647,Akn=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,Rct=Symbol("stop");class Tct{options;constructor(e){this.options=e}}const skn=t=>new Tct(t),akn={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0,context:!0},ckn={next:!0},lkn={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,duplex:!0},gkn=t=>{if(!t)return 0;if(t instanceof FormData){let e=0;for(const[n,o]of t)e+=Akn,e+=new TextEncoder().encode(`Content-Disposition: form-data; name="${n}"`).length,e+=typeof o=="string"?new TextEncoder().encode(o).length:o.size;return e}if(t instanceof Blob)return t.size;if(t instanceof ArrayBuffer)return t.byteLength;if(typeof t=="string")return new TextEncoder().encode(t).length;if(t instanceof URLSearchParams)return new TextEncoder().encode(t.toString()).length;if("byteLength"in t)return t.byteLength;if(typeof t=="object"&&t!==null)try{const e=JSON.stringify(t);return new TextEncoder().encode(e).length}catch{return 0}return 0},kct=(t,e,n)=>{let o,i=0;return t.pipeThrough(new TransformStream({transform(r,A){if(A.enqueue(r),o){i+=o.byteLength;let s=e===0?0:i/e;s>=1&&(s=1-Number.EPSILON),n?.({percent:s,totalBytes:Math.max(e,i),transferredBytes:i},o)}o=r},flush(){o&&(i+=o.byteLength,n?.({percent:1,totalBytes:Math.max(e,i),transferredBytes:i},o))}}))},ukn=(t,e)=>{if(!t.body)return t;if(t.status===204)return new Response(null,{status:t.status,statusText:t.statusText,headers:t.headers});const n=Math.max(0,Number(t.headers.get("content-length"))||0);return new Response(kct(t.body,n,e),{status:t.status,statusText:t.statusText,headers:t.headers})},hkn=(t,e,n)=>{if(!t.body)return t;const o=gkn(n??t.body);return new Request(t,{duplex:"half",body:kct(t.body,o,e)})},IP=t=>t!==null&&typeof t=="object",yX=(...t)=>{for(const e of t)if((!IP(e)||Array.isArray(e))&&e!==void 0)throw new TypeError("The `options` argument must be an object");return PIe({},...t)},Fct=(t={},e={})=>{const n=new globalThis.Headers(t),o=e instanceof globalThis.Headers,i=new globalThis.Headers(e);for(const[r,A]of i.entries())o&&A==="undefined"||A===void 0?n.delete(r):n.set(r,A);return n};function EX(t,e,n){return Object.hasOwn(e,n)&&e[n]===void 0?[]:PIe(t[n]??[],e[n]??[])}const Lct=(t={},e={})=>({beforeRequest:EX(t,e,"beforeRequest"),beforeRetry:EX(t,e,"beforeRetry"),afterResponse:EX(t,e,"afterResponse"),beforeError:EX(t,e,"beforeError")}),dkn=(t,e)=>{const n=new URLSearchParams;for(const o of[t,e])if(o!==void 0)if(o instanceof URLSearchParams)for(const[i,r]of o.entries())n.append(i,r);else if(Array.isArray(o))for(const i of o){if(!Array.isArray(i)||i.length!==2)throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");n.append(String(i[0]),String(i[1]))}else if(IP(o))for(const[i,r]of Object.entries(o))r!==void 0&&n.append(i,String(r));else{const i=new URLSearchParams(o);for(const[r,A]of i.entries())n.append(r,A)}return n},PIe=(...t)=>{let e={},n={},o={},i;const r=[];for(const A of t)if(Array.isArray(A))Array.isArray(e)||(e=[]),e=[...e,...A];else if(IP(A)){for(let[s,a]of Object.entries(A)){if(s==="signal"&&a instanceof globalThis.AbortSignal){r.push(a);continue}if(s==="context"){if(a!=null&&(!IP(a)||Array.isArray(a)))throw new TypeError("The `context` option must be an object");e={...e,context:a==null?{}:{...e.context,...a}};continue}if(s==="searchParams"){a==null?i=void 0:i=i===void 0?a:dkn(i,a);continue}IP(a)&&s in e&&(a=PIe(e[s],a)),e={...e,[s]:a}}IP(A.hooks)&&(o=Lct(o,A.hooks),e.hooks=o),IP(A.headers)&&(n=Fct(n,A.headers),e.headers=n)}return i!==void 0&&(e.searchParams=i),r.length>0&&(r.length===1?e.signal=r[0]:vct?e.signal=AbortSignal.any(r):e.signal=r.at(-1)),e},_kn=t=>Nct.includes(t)?t.toUpperCase():t,Hct={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:t=>.3*2**(t-1)*1e3,jitter:void 0,retryOnTimeout:!1},mkn=(t={})=>{if(typeof t=="number")return{...Hct,limit:t};if(t.methods&&!Array.isArray(t.methods))throw new Error("retry.methods must be an array");if(t.methods&&=t.methods.map(n=>n.toLowerCase()),t.statusCodes&&!Array.isArray(t.statusCodes))throw new Error("retry.statusCodes must be an array");const e=Object.fromEntries(Object.entries(t).filter(([,n])=>n!==void 0));return{...Hct,...e}};class vIe extends Error{request;constructor(e){super(`Request timed out: ${e.method} ${e.url}`),this.name="TimeoutError",this.request=e}}async function pkn(t,e,n,o){return new Promise((i,r)=>{const A=setTimeout(()=>{n&&n.abort(),r(new vIe(t))},o.timeout);o.fetch(t,e).then(i).catch(r).then(()=>{clearTimeout(A)})})}async function Ikn(t,{signal:e}){return new Promise((n,o)=>{e&&(e.throwIfAborted(),e.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(r),o(e.reason)}const r=setTimeout(()=>{e?.removeEventListener("abort",i),n()},t)})}const Ckn=(t,e)=>{const n={};for(const o in e)Object.hasOwn(e,o)&&!(o in lkn)&&!(o in akn)&&(!(o in t)||o in ckn)&&(n[o]=e[o]);return n},fkn=t=>t===void 0?!1:Array.isArray(t)?t.length>0:t instanceof URLSearchParams?t.size>0:typeof t=="object"?Object.keys(t).length>0:typeof t=="string"?t.trim().length>0:!!t;function ykn(t){return t instanceof Yb||t?.name===Yb.name}function Ekn(t){return t instanceof vIe||t?.name===vIe.name}class wL{static create(e,n){const o=new wL(e,n),i=async()=>{if(typeof o.#e.timeout=="number"&&o.#e.timeout>wIe)throw new RangeError(`The \`timeout\` option cannot be greater than ${wIe}`);await Promise.resolve();let A=await o.#p();for(const s of o.#e.hooks.afterResponse){const a=o.#u(A.clone());let c;try{c=await s(o.request,o.#g(),a,{retryCount:o.#o})}catch(g){throw o.#a(a),o.#a(A),g}if(c instanceof Tct)throw o.#a(a),o.#a(A),new MIe(c.options);const l=c instanceof globalThis.Response?c:A;a!==l&&o.#a(a),A!==l&&o.#a(A),A=l}if(o.#u(A),!A.ok&&(typeof o.#e.throwHttpErrors=="function"?o.#e.throwHttpErrors(A.status):o.#e.throwHttpErrors)){let s=new Yb(A,o.request,o.#g());for(const a of o.#e.hooks.beforeError)s=await a(s,{retryCount:o.#o});throw s}if(o.#e.onDownloadProgress){if(typeof o.#e.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!okn)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");const s=A.clone();return o.#a(A),ukn(s,o.#e.onDownloadProgress)}return A},r=o.#m(i).finally(()=>{const A=o.#A;o.#h(A?.body??void 0),o.#h(o.request.body??void 0)});for(const[A,s]of Object.entries(rkn))A==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(r[A]=async()=>{o.request.headers.set("accept",o.request.headers.get("accept")||s);const a=await r;if(A==="json"){if(a.status===204)return"";const c=await a.text();return c===""?"":n.parseJson?n.parseJson(c):JSON.parse(c)}return a[A]()});return r}static#i(e){return e&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof URLSearchParams)?Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0)):e}request;#n;#o=0;#t;#e;#A;#r;#c;constructor(e,n={}){if(this.#t=e,this.#e={...n,headers:Fct(this.#t.headers,n.headers),hooks:Lct({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},n.hooks),method:_kn(n.method??this.#t.method??"GET"),prefixUrl:String(n.prefixUrl||""),retry:mkn(n.retry),throwHttpErrors:n.throwHttpErrors??!0,timeout:n.timeout??1e4,fetch:n.fetch??globalThis.fetch.bind(globalThis),context:n.context??{}},typeof this.#t!="string"&&!(this.#t instanceof URL||this.#t instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this.#e.prefixUrl&&typeof this.#t=="string"){if(this.#t.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this.#e.prefixUrl.endsWith("/")||(this.#e.prefixUrl+="/"),this.#t=this.#e.prefixUrl+this.#t}nkn&&vct&&(this.#r=this.#e.signal??this.#t.signal,this.#n=new globalThis.AbortController,this.#e.signal=this.#r?AbortSignal.any([this.#r,this.#n.signal]):this.#n.signal),Pct&&(this.#e.duplex="half"),this.#e.json!==void 0&&(this.#e.body=this.#e.stringifyJson?.(this.#e.json)??JSON.stringify(this.#e.json),this.#e.headers.set("content-type",this.#e.headers.get("content-type")??"application/json"));const o=n.headers&&new globalThis.Headers(n.headers).has("content-type");if(this.#t instanceof globalThis.Request&&(ikn&&this.#e.body instanceof globalThis.FormData||this.#e.body instanceof URLSearchParams)&&!o&&this.#e.headers.delete("content-type"),this.request=new globalThis.Request(this.#t,this.#e),fkn(this.#e.searchParams)){const r="?"+(typeof this.#e.searchParams=="string"?this.#e.searchParams.replace(/^\?/,""):new URLSearchParams(wL.#i(this.#e.searchParams)).toString()),A=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,r);this.request=new globalThis.Request(A,this.#e)}if(this.#e.onUploadProgress){if(typeof this.#e.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!Pct)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request=this.#_(this.request,this.#e.body??void 0)}}#s(){const e=this.#e.retry.delay(this.#o);let n=e;this.#e.retry.jitter===!0?n=Math.random()*e:typeof this.#e.retry.jitter=="function"&&(n=this.#e.retry.jitter(e),(!Number.isFinite(n)||n<0)&&(n=e));const o=this.#e.retry.backoffLimit??Number.POSITIVE_INFINITY;return Math.min(o,n)}async#l(e){if(this.#o++,this.#o>this.#e.retry.limit)throw e;const n=e instanceof Error?e:new wct(e);if(n instanceof MIe)return n.customDelay??this.#s();if(!this.#e.retry.methods.includes(this.request.method.toLowerCase()))throw e;if(this.#e.retry.shouldRetry!==void 0){const o=await this.#e.retry.shouldRetry({error:n,retryCount:this.#o});if(o===!1)throw e;if(o===!0)return this.#s()}if(Ekn(e)&&!this.#e.retry.retryOnTimeout)throw e;if(ykn(e)){if(!this.#e.retry.statusCodes.includes(e.response.status))throw e;const o=e.response.headers.get("Retry-After")??e.response.headers.get("RateLimit-Reset")??e.response.headers.get("X-RateLimit-Retry-After")??e.response.headers.get("X-RateLimit-Reset")??e.response.headers.get("X-Rate-Limit-Reset");if(o&&this.#e.retry.afterStatusCodes.includes(e.response.status)){let i=Number(o)*1e3;Number.isNaN(i)?i=Date.parse(o)-Date.now():i>=Date.parse("2024-01-01")&&(i-=Date.now());const r=this.#e.retry.maxRetryAfter??i;return i<r?i:r}if(e.response.status===413)throw e}return this.#s()}#u(e){return this.#e.parseJson&&(e.json=async()=>this.#e.parseJson(await e.text())),e}#h(e){e&&e.cancel().catch(()=>{})}#a(e){this.#h(e.body??void 0)}async#m(e){try{return await e()}catch(n){const o=Math.min(await this.#l(n),wIe);if(this.#o<1)throw n;if(await Ikn(o,this.#r?{signal:this.#r}:{}),n instanceof MIe&&n.customRequest){const i=this.#e.signal?new globalThis.Request(n.customRequest,{signal:this.#e.signal}):new globalThis.Request(n.customRequest);this.#d(i)}for(const i of this.#e.hooks.beforeRetry){const r=await i({request:this.request,options:this.#g(),error:n,retryCount:this.#o});if(r instanceof globalThis.Request){this.#d(r);break}if(r instanceof globalThis.Response)return r;if(r===Rct)return}return this.#m(e)}}async#p(){this.#n?.signal.aborted&&(this.#n=new globalThis.AbortController,this.#e.signal=this.#r?AbortSignal.any([this.#r,this.#n.signal]):this.#n.signal,this.request=new globalThis.Request(this.request,{signal:this.#e.signal}));for(const n of this.#e.hooks.beforeRequest){const o=await n(this.request,this.#g(),{retryCount:this.#o});if(o instanceof Response)return o;if(o instanceof globalThis.Request){this.#d(o);break}}const e=Ckn(this.request,this.#e);return this.#A=this.request,this.request=this.#A.clone(),this.#e.timeout===!1?this.#e.fetch(this.#A,e):pkn(this.#A,e,this.#n,this.#e)}#g(){if(!this.#c){const{hooks:e,...n}=this.#e;this.#c=Object.freeze(n)}return this.#c}#d(e){this.#c=void 0,this.request=this.#_(e)}#_(e,n){return!this.#e.onUploadProgress||!e.body?e:hkn(e,this.#e.onUploadProgress,n??this.#e.body??void 0)}}const NIe=t=>{const e=(n,o)=>wL.create(n,yX(t,o));for(const n of Nct)e[n]=(o,i)=>wL.create(o,yX(t,i,{method:n}));return e.create=n=>NIe(yX(n)),e.extend=n=>(typeof n=="function"&&(n=n(t??{})),NIe(yX(t,n))),e.stop=Rct,e.retry=skn,e},Bkn=NIe();class xkn extends Yb{constructor(e,n,o,i){super(e,n,o),this.name="RegistryHTTPError",this.message=i}}function PL(t){return typeof window<"u"?window[t]:null}function Vb(){const t=PL("TSCIRCUIT_REGISTRY_API_BASE_URL")||void 0||"https://registry-api.tscircuit.com",e=PL("TSCIRCUIT_REGISTRY_TOKEN");return Bkn.create({prefixUrl:t,headers:{Authorization:`Bearer ${e}`},timeout:3e4,hooks:{afterResponse:[async(n,o,i)=>{if(i.ok)return i;let r=null;try{r=await i.clone().json()}catch(g){console.error("Failed to parse registry error response",g)}const A=r?.error?.message??r?.error?.error_message??r?.message,s=r?.error?.error_code??r?.error_code,a=new URL(i.url),l=[`Registry request failed for ${`${a.pathname}${a.search}`} (${i.status})`];throw A&&l.push(`Server message: ${A}`),s&&l.push(`Error code: ${s}`),new xkn(i,n,o,l.join(" | "))}]}})}function BX(){return!!PL("TSCIRCUIT_REGISTRY_TOKEN")}const vL={get:(t,e)=>Vb().get(t,e),post:(t,e)=>Vb().post(t,e),put:(t,e)=>Vb().put(t,e),delete:(t,e)=>Vb().delete(t,e),patch:(t,e)=>Vb().patch(t,e)},Qkn="phc_htd8AQjSfVEsFCLQMAiUooG4Q0DKBCjqYuQglc9V3Wo",Skn="https://postpig.tscircuit.com",Gct="runframe:anonymous-id",RIe=()=>typeof window<"u",Oct=t=>t.includes("localhost")||t.includes("127.0.0.1"),bkn=t=>{try{return new URL(t).hostname}catch{return null}},Dkn=()=>{if(!RIe())return null;let t=null;return document.referrer&&(t=bkn(document.referrer)),t??window.location.hostname},Mkn=()=>typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,wkn=()=>{if(!RIe())return null;try{const t=window.localStorage.getItem(Gct);if(t)return t;const e=Mkn();return window.localStorage.setItem(Gct,e),e}catch{return null}},Pkn=()=>PL("TSCIRCUIT_USE_RUNFRAME_FOR_CLI")===!0,Kct=()=>!RIe()||Oct(window.location.hostname)&&!Pkn()?!1:(b9.__loaded||b9.init(Qkn,{api_host:Skn,person_profiles:"always"}),!0),vkn=()=>{if(!Kct())return null;const t=Dkn(),e=t!=null&&!Oct(t);let n=null;e||(n=wkn());let o,i;return e?(o=`domain:${t}`,i="domain"):(o=void 0,n&&(o=`anonymous:${n}`),i="anonymous_id"),{embedDomain:t,anonymousId:n,distinctId:o,identityType:i}},Nkn=(t,{source:e,...n})=>{const o=vkn();if(!o)return;const{embedDomain:i,anonymousId:r,distinctId:A,identityType:s}=o;if(A){const a={};s==="domain"&&i&&(a.embed_domain=i),s==="anonymous_id"&&r&&(a.runframe_anonymous_id=r),b9.identify(A,a)}b9.capture(t,{...n,source:e,embed_domain:i,runframe_anonymous_id:r,identity_type:s})},Rkn=t=>{Nkn("runframe_activity",t)};Kct();function Tkn(t){const e=String.fromCodePoint(...t);return btoa(e)}function kkn(t,e){const n=JSON.stringify(t),o=QZe(DZe(n));return`https://tscircuit.com/editor?#data:application/gzip;base64,${Tkn(o)}`}function Ui(...t){return RNn(mB(t))}const Uct=t=>t.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()),TIe=oNn,xX=j.forwardRef(({className:t,...e},n)=>V.jsx(TAt,{ref:n,className:Ui("rf-inline-flex rf-h-9 rf-items-center rf-justify-center rf-rounded-lg rf-bg-zinc-100 rf-p-1 rf-text-zinc-500 dark:rf-bg-zinc-800 dark:rf-text-zinc-400",t),...e}));xX.displayName=TAt.displayName;const Zx=j.forwardRef(({className:t,...e},n)=>V.jsx(kAt,{ref:n,className:Ui("rf-inline-flex rf-items-center rf-justify-center rf-whitespace-nowrap rf-rounded-md rf-px-3 rf-py-1 rf-text-sm rf-font-medium rf-ring-offset-white rf-transition-all focus-visible:rf-outline-none focus-visible:rf-ring-2 focus-visible:rf-ring-zinc-950 focus-visible:rf-ring-offset-2 disabled:rf-pointer-events-none disabled:rf-opacity-50 data-[state=active]:rf-bg-white data-[state=active]:rf-text-zinc-950 data-[state=active]:rf-shadow dark:rf-ring-offset-zinc-950 dark:focus-visible:rf-ring-zinc-300 dark:data-[state=active]:rf-bg-zinc-950 dark:data-[state=active]:rf-text-zinc-50",t),...e}));Zx.displayName=kAt.displayName;const OI=j.forwardRef(({className:t,...e},n)=>V.jsx(FAt,{ref:n,className:Ui("rf-h-full rf-mt-2 rf-ring-offset-white focus-visible:rf-outline-none focus-visible:rf-ring-2 focus-visible:rf-ring-zinc-950 focus-visible:rf-ring-offset-2 dark:rf-ring-offset-zinc-950 dark:focus-visible:rf-ring-zinc-300",t),...e}));OI.displayName=FAt.displayName;const QX="165",zb={ROTATE:0,DOLLY:1,PAN:2},D9={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Fkn=0,Yct=1,Lkn=2,Vct=1,zct=2,XS=3,B1=0,wp=1,G_=2,Jb=0,M9=1,Jct=2,qct=3,Wct=4,Hkn=5,CP=100,Gkn=101,Okn=102,Kkn=103,Ukn=104,Ykn=200,Vkn=201,zkn=202,Jkn=203,kIe=204,FIe=205,qkn=206,Wkn=207,jkn=208,Xkn=209,$kn=210,Zkn=211,eFn=212,tFn=213,nFn=214,oFn=0,iFn=1,rFn=2,SX=3,AFn=4,sFn=5,aFn=6,cFn=7,LIe=0,lFn=1,gFn=2,qb=0,uFn=1,hFn=2,dFn=3,jct=4,_Fn=5,mFn=6,pFn=7,Xct="attached",IFn="detached",$ct=300,w9=301,P9=302,bX=303,HIe=304,DX=306,a2=1e3,Fy=1001,NL=1002,KI=1003,GIe=1004,v9=1005,Bl=1006,RL=1007,Ad=1008,Wb=1009,CFn=1010,fFn=1011,MX=1012,Zct=1013,N9=1014,eQ=1015,wX=1016,elt=1017,tlt=1018,R9=1020,yFn=35902,EFn=1021,BFn=1022,c2=1023,xFn=1024,QFn=1025,T9=1026,k9=1027,nlt=1028,olt=1029,SFn=1030,ilt=1031,rlt=1033,OIe=33776,KIe=33777,UIe=33778,YIe=33779,Alt=35840,slt=35841,alt=35842,clt=35843,llt=36196,glt=37492,ult=37496,hlt=37808,dlt=37809,_lt=37810,mlt=37811,plt=37812,Ilt=37813,Clt=37814,flt=37815,ylt=37816,Elt=37817,Blt=37818,xlt=37819,Qlt=37820,Slt=37821,VIe=36492,blt=36494,Dlt=36495,bFn=36283,Mlt=36284,wlt=36285,Plt=36286,F9=2300,L9=2301,zIe=2302,vlt=2400,Nlt=2401,Rlt=2402,DFn=2500,MFn=0,Tlt=1,JIe=2,wFn=3200,klt=3201,qIe=0,PFn=1,jb="",CB="srgb",Xb="srgb-linear",WIe="display-p3",PX="display-p3-linear",vX="linear",R0="srgb",NX="rec709",RX="p3",H9=7680,Flt=519,vFn=512,NFn=513,RFn=514,Llt=515,TFn=516,kFn=517,FFn=518,LFn=519,jIe=35044,Hlt="300 es",$S=2e3,TX=2001;class fP{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const o=this._listeners;o[e]===void 0&&(o[e]=[]),o[e].indexOf(n)===-1&&o[e].push(n)}hasEventListener(e,n){if(this._listeners===void 0)return!1;const o=this._listeners;return o[e]!==void 0&&o[e].indexOf(n)!==-1}removeEventListener(e,n){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const r=i.indexOf(n);r!==-1&&i.splice(r,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const o=this._listeners[e.type];if(o!==void 0){e.target=this;const i=o.slice(0);for(let r=0,A=i.length;r<A;r++)i[r].call(this,e);e.target=null}}}const UI=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Glt=1234567;const G9=Math.PI/180,O9=180/Math.PI;function fB(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,o=Math.random()*4294967295|0;return(UI[t&255]+UI[t>>8&255]+UI[t>>16&255]+UI[t>>24&255]+"-"+UI[e&255]+UI[e>>8&255]+"-"+UI[e>>16&15|64]+UI[e>>24&255]+"-"+UI[n&63|128]+UI[n>>8&255]+"-"+UI[n>>16&255]+UI[n>>24&255]+UI[o&255]+UI[o>>8&255]+UI[o>>16&255]+UI[o>>24&255]).toLowerCase()}function Pp(t,e,n){return Math.max(e,Math.min(n,t))}function XIe(t,e){return(t%e+e)%e}function HFn(t,e,n,o,i){return o+(t-e)*(i-o)/(n-e)}function GFn(t,e,n){return t!==e?(n-t)/(e-t):0}function TL(t,e,n){return(1-n)*t+n*e}function OFn(t,e,n,o){return TL(t,e,1-Math.exp(-n*o))}function KFn(t,e=1){return e-Math.abs(XIe(t,e*2)-e)}function UFn(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function YFn(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function VFn(t,e){return t+Math.floor(Math.random()*(e-t+1))}function zFn(t,e){return t+Math.random()*(e-t)}function JFn(t){return t*(.5-Math.random())}function qFn(t){t!==void 0&&(Glt=t);let e=Glt+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function WFn(t){return t*G9}function jFn(t){return t*O9}function XFn(t){return(t&t-1)===0&&t!==0}function $Fn(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function ZFn(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function eLn(t,e,n,o,i){const r=Math.cos,A=Math.sin,s=r(n/2),a=A(n/2),c=r((e+o)/2),l=A((e+o)/2),g=r((e-o)/2),u=A((e-o)/2),d=r((o-e)/2),h=A((o-e)/2);switch(i){case"XYX":t.set(s*l,a*g,a*u,s*c);break;case"YZY":t.set(a*u,s*l,a*g,s*c);break;case"ZXZ":t.set(a*g,a*u,s*l,s*c);break;case"XZX":t.set(s*l,a*h,a*d,s*c);break;case"YXY":t.set(a*d,s*l,a*h,s*c);break;case"ZYZ":t.set(a*h,a*d,s*l,s*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function yB(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function xl(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(t*4294967295);case Uint16Array:return Math.round(t*65535);case Uint8Array:return Math.round(t*255);case Int32Array:return Math.round(t*2147483647);case Int16Array:return Math.round(t*32767);case Int8Array:return Math.round(t*127);default:throw new Error("Invalid component type.")}}const kL={DEG2RAD:G9,RAD2DEG:O9,generateUUID:fB,clamp:Pp,euclideanModulo:XIe,mapLinear:HFn,inverseLerp:GFn,lerp:TL,damp:OFn,pingpong:KFn,smoothstep:UFn,smootherstep:YFn,randInt:VFn,randFloat:zFn,randFloatSpread:JFn,seededRandom:qFn,degToRad:WFn,radToDeg:jFn,isPowerOfTwo:XFn,ceilPowerOfTwo:$Fn,floorPowerOfTwo:ZFn,setQuaternionFromProperEuler:eLn,normalize:xl,denormalize:yB};class Xi{constructor(e=0,n=0){Xi.prototype.isVector2=!0,this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const n=this.x,o=this.y,i=e.elements;return this.x=i[0]*n+i[3]*o+i[6],this.y=i[1]*n+i[4]*o+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this}clampLength(e,n){const o=this.length();return this.divideScalar(o||1).multiplyScalar(Math.max(e,Math.min(n,o)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const o=this.dot(e)/n;return Math.acos(Pp(o,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,o=this.y-e.y;return n*n+o*o}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,o){return this.x=e.x+(n.x-e.x)*o,this.y=e.y+(n.y-e.y)*o,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const o=Math.cos(n),i=Math.sin(n),r=this.x-e.x,A=this.y-e.y;return this.x=r*o-A*i+e.x,this.y=r*i+A*o+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ds{constructor(e,n,o,i,r,A,s,a,c){Ds.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,o,i,r,A,s,a,c)}set(e,n,o,i,r,A,s,a,c){const l=this.elements;return l[0]=e,l[1]=i,l[2]=s,l[3]=n,l[4]=r,l[5]=a,l[6]=o,l[7]=A,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,o=e.elements;return n[0]=o[0],n[1]=o[1],n[2]=o[2],n[3]=o[3],n[4]=o[4],n[5]=o[5],n[6]=o[6],n[7]=o[7],n[8]=o[8],this}extractBasis(e,n,o){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),o.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const o=e.elements,i=n.elements,r=this.elements,A=o[0],s=o[3],a=o[6],c=o[1],l=o[4],g=o[7],u=o[2],d=o[5],h=o[8],_=i[0],p=i[3],m=i[6],I=i[1],C=i[4],f=i[7],y=i[2],B=i[5],x=i[8];return r[0]=A*_+s*I+a*y,r[3]=A*p+s*C+a*B,r[6]=A*m+s*f+a*x,r[1]=c*_+l*I+g*y,r[4]=c*p+l*C+g*B,r[7]=c*m+l*f+g*x,r[2]=u*_+d*I+h*y,r[5]=u*p+d*C+h*B,r[8]=u*m+d*f+h*x,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],o=e[1],i=e[2],r=e[3],A=e[4],s=e[5],a=e[6],c=e[7],l=e[8];return n*A*l-n*s*c-o*r*l+o*s*a+i*r*c-i*A*a}invert(){const e=this.elements,n=e[0],o=e[1],i=e[2],r=e[3],A=e[4],s=e[5],a=e[6],c=e[7],l=e[8],g=l*A-s*c,u=s*a-l*r,d=c*r-A*a,h=n*g+o*u+i*d;if(h===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/h;return e[0]=g*_,e[1]=(i*c-l*o)*_,e[2]=(s*o-i*A)*_,e[3]=u*_,e[4]=(l*n-i*a)*_,e[5]=(i*r-s*n)*_,e[6]=d*_,e[7]=(o*a-c*n)*_,e[8]=(A*n-o*r)*_,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,o,i,r,A,s){const a=Math.cos(r),c=Math.sin(r);return this.set(o*a,o*c,-o*(a*A+c*s)+A+e,-i*c,i*a,-i*(-c*A+a*s)+s+n,0,0,1),this}scale(e,n){return this.premultiply($Ie.makeScale(e,n)),this}rotate(e){return this.premultiply($Ie.makeRotation(-e)),this}translate(e,n){return this.premultiply($Ie.makeTranslation(e,n)),this}makeTranslation(e,n){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,n,0,0,1),this}makeRotation(e){const n=Math.cos(e),o=Math.sin(e);return this.set(n,-o,0,o,n,0,0,0,1),this}makeScale(e,n){return this.set(e,0,0,0,n,0,0,0,1),this}equals(e){const n=this.elements,o=e.elements;for(let i=0;i<9;i++)if(n[i]!==o[i])return!1;return!0}fromArray(e,n=0){for(let o=0;o<9;o++)this.elements[o]=e[o+n];return this}toArray(e=[],n=0){const o=this.elements;return e[n]=o[0],e[n+1]=o[1],e[n+2]=o[2],e[n+3]=o[3],e[n+4]=o[4],e[n+5]=o[5],e[n+6]=o[6],e[n+7]=o[7],e[n+8]=o[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const $Ie=new Ds;function Olt(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function FL(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function tLn(){const t=FL("canvas");return t.style.display="block",t}const Klt={};function ZIe(t){t in Klt||(Klt[t]=!0,console.warn(t))}function nLn(t,e,n){return new Promise(function(o,i){function r(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:i();break;case t.TIMEOUT_EXPIRED:setTimeout(r,n);break;default:o()}}setTimeout(r,n)})}const Ult=new Ds().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),Ylt=new Ds().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),kX={[Xb]:{transfer:vX,primaries:NX,toReference:t=>t,fromReference:t=>t},[CB]:{transfer:R0,primaries:NX,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[PX]:{transfer:vX,primaries:RX,toReference:t=>t.applyMatrix3(Ylt),fromReference:t=>t.applyMatrix3(Ult)},[WIe]:{transfer:R0,primaries:RX,toReference:t=>t.convertSRGBToLinear().applyMatrix3(Ylt),fromReference:t=>t.applyMatrix3(Ult).convertLinearToSRGB()}},oLn=new Set([Xb,PX]),Ql={enabled:!0,_workingColorSpace:Xb,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(t){if(!oLn.has(t))throw new Error(`Unsupported working color space, "${t}".`);this._workingColorSpace=t},convert:function(t,e,n){if(this.enabled===!1||e===n||!e||!n)return t;const o=kX[e].toReference,i=kX[n].fromReference;return i(o(t))},fromWorkingColorSpace:function(t,e){return this.convert(t,this._workingColorSpace,e)},toWorkingColorSpace:function(t,e){return this.convert(t,e,this._workingColorSpace)},getPrimaries:function(t){return kX[t].primaries},getTransfer:function(t){return t===jb?vX:kX[t].transfer}};function K9(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function eCe(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let U9;class iLn{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{U9===void 0&&(U9=FL("canvas")),U9.width=e.width,U9.height=e.height;const o=U9.getContext("2d");e instanceof ImageData?o.putImageData(e,0,0):o.drawImage(e,0,0,e.width,e.height),n=U9}return n.width>2048||n.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),n.toDataURL("image/jpeg",.6)):n.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const n=FL("canvas");n.width=e.width,n.height=e.height;const o=n.getContext("2d");o.drawImage(e,0,0,e.width,e.height);const i=o.getImageData(0,0,e.width,e.height),r=i.data;for(let A=0;A<r.length;A++)r[A]=K9(r[A]/255)*255;return o.putImageData(i,0,0),n}else if(e.data){const n=e.data.slice(0);for(let o=0;o<n.length;o++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[o]=Math.floor(K9(n[o]/255)*255):n[o]=K9(n[o]);return{data:n,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let rLn=0;class Vlt{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:rLn++}),this.uuid=fB(),this.data=e,this.dataReady=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const o={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let A=0,s=i.length;A<s;A++)i[A].isDataTexture?r.push(tCe(i[A].image)):r.push(tCe(i[A]))}else r=tCe(i);o.url=r}return n||(e.images[this.uuid]=o),o}}function tCe(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?iLn.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let ALn=0;class Xg extends fP{constructor(e=Xg.DEFAULT_IMAGE,n=Xg.DEFAULT_MAPPING,o=Fy,i=Fy,r=Bl,A=Ad,s=c2,a=Wb,c=Xg.DEFAULT_ANISOTROPY,l=jb){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:ALn++}),this.uuid=fB(),this.name="",this.source=new Vlt(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=o,this.wrapT=i,this.magFilter=r,this.minFilter=A,this.anisotropy=c,this.format=s,this.internalFormat=null,this.type=a,this.offset=new Xi(0,0),this.repeat=new Xi(1,1),this.center=new Xi(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ds,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=l,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const o={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(o.userData=this.userData),n||(e.textures[this.uuid]=o),o}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==$ct)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case a2:e.x=e.x-Math.floor(e.x);break;case Fy:e.x=e.x<0?0:1;break;case NL:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case a2:e.y=e.y-Math.floor(e.y);break;case Fy:e.y=e.y<0?0:1;break;case NL:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Xg.DEFAULT_IMAGE=null,Xg.DEFAULT_MAPPING=$ct,Xg.DEFAULT_ANISOTROPY=1;class Sl{constructor(e=0,n=0,o=0,i=1){Sl.prototype.isVector4=!0,this.x=e,this.y=n,this.z=o,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,o,i){return this.x=e,this.y=n,this.z=o,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,o=this.y,i=this.z,r=this.w,A=e.elements;return this.x=A[0]*n+A[4]*o+A[8]*i+A[12]*r,this.y=A[1]*n+A[5]*o+A[9]*i+A[13]*r,this.z=A[2]*n+A[6]*o+A[10]*i+A[14]*r,this.w=A[3]*n+A[7]*o+A[11]*i+A[15]*r,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,o,i,r;const a=e.elements,c=a[0],l=a[4],g=a[8],u=a[1],d=a[5],h=a[9],_=a[2],p=a[6],m=a[10];if(Math.abs(l-u)<.01&&Math.abs(g-_)<.01&&Math.abs(h-p)<.01){if(Math.abs(l+u)<.1&&Math.abs(g+_)<.1&&Math.abs(h+p)<.1&&Math.abs(c+d+m-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const C=(c+1)/2,f=(d+1)/2,y=(m+1)/2,B=(l+u)/4,x=(g+_)/4,S=(h+p)/4;return C>f&&C>y?C<.01?(o=0,i=.707106781,r=.707106781):(o=Math.sqrt(C),i=B/o,r=x/o):f>y?f<.01?(o=.707106781,i=0,r=.707106781):(i=Math.sqrt(f),o=B/i,r=S/i):y<.01?(o=.707106781,i=.707106781,r=0):(r=Math.sqrt(y),o=x/r,i=S/r),this.set(o,i,r,n),this}let I=Math.sqrt((p-h)*(p-h)+(g-_)*(g-_)+(u-l)*(u-l));return Math.abs(I)<.001&&(I=1),this.x=(p-h)/I,this.y=(g-_)/I,this.z=(u-l)/I,this.w=Math.acos((c+d+m-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this.w=Math.max(e.w,Math.min(n.w,this.w)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this.w=Math.max(e,Math.min(n,this.w)),this}clampLength(e,n){const o=this.length();return this.divideScalar(o||1).multiplyScalar(Math.max(e,Math.min(n,o)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,o){return this.x=e.x+(n.x-e.x)*o,this.y=e.y+(n.y-e.y)*o,this.z=e.z+(n.z-e.z)*o,this.w=e.w+(n.w-e.w)*o,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class sLn extends fP{constructor(e=1,n=1,o={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new Sl(0,0,e,n),this.scissorTest=!1,this.viewport=new Sl(0,0,e,n);const i={width:e,height:n,depth:1};o=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Bl,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},o);const r=new Xg(i,o.mapping,o.wrapS,o.wrapT,o.magFilter,o.minFilter,o.format,o.type,o.anisotropy,o.colorSpace);r.flipY=!1,r.generateMipmaps=o.generateMipmaps,r.internalFormat=o.internalFormat,this.textures=[];const A=o.count;for(let s=0;s<A;s++)this.textures[s]=r.clone(),this.textures[s].isRenderTargetTexture=!0;this.depthBuffer=o.depthBuffer,this.stencilBuffer=o.stencilBuffer,this.resolveDepthBuffer=o.resolveDepthBuffer,this.resolveStencilBuffer=o.resolveStencilBuffer,this.depthTexture=o.depthTexture,this.samples=o.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}setSize(e,n,o=1){if(this.width!==e||this.height!==n||this.depth!==o){this.width=e,this.height=n,this.depth=o;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=e,this.textures[i].image.height=n,this.textures[i].image.depth=o;this.dispose()}this.viewport.set(0,0,e,n),this.scissor.set(0,0,e,n)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let o=0,i=e.textures.length;o<i;o++)this.textures[o]=e.textures[o].clone(),this.textures[o].isRenderTargetTexture=!0;const n=Object.assign({},e.texture.image);return this.texture.source=new Vlt(n),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class yP extends sLn{constructor(e=1,n=1,o={}){super(e,n,o),this.isWebGLRenderTarget=!0}}class zlt extends Xg{constructor(e=null,n=1,o=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:o,depth:i},this.magFilter=KI,this.minFilter=KI,this.wrapR=Fy,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class aLn extends Xg{constructor(e=null,n=1,o=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:n,height:o,depth:i},this.magFilter=KI,this.minFilter=KI,this.wrapR=Fy,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class jC{constructor(e=0,n=0,o=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=o,this._w=i}static slerpFlat(e,n,o,i,r,A,s){let a=o[i+0],c=o[i+1],l=o[i+2],g=o[i+3];const u=r[A+0],d=r[A+1],h=r[A+2],_=r[A+3];if(s===0){e[n+0]=a,e[n+1]=c,e[n+2]=l,e[n+3]=g;return}if(s===1){e[n+0]=u,e[n+1]=d,e[n+2]=h,e[n+3]=_;return}if(g!==_||a!==u||c!==d||l!==h){let p=1-s;const m=a*u+c*d+l*h+g*_,I=m>=0?1:-1,C=1-m*m;if(C>Number.EPSILON){const y=Math.sqrt(C),B=Math.atan2(y,m*I);p=Math.sin(p*B)/y,s=Math.sin(s*B)/y}const f=s*I;if(a=a*p+u*f,c=c*p+d*f,l=l*p+h*f,g=g*p+_*f,p===1-s){const y=1/Math.sqrt(a*a+c*c+l*l+g*g);a*=y,c*=y,l*=y,g*=y}}e[n]=a,e[n+1]=c,e[n+2]=l,e[n+3]=g}static multiplyQuaternionsFlat(e,n,o,i,r,A){const s=o[i],a=o[i+1],c=o[i+2],l=o[i+3],g=r[A],u=r[A+1],d=r[A+2],h=r[A+3];return e[n]=s*h+l*g+a*d-c*u,e[n+1]=a*h+l*u+c*g-s*d,e[n+2]=c*h+l*d+s*u-a*g,e[n+3]=l*h-s*g-a*u-c*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,o,i){return this._x=e,this._y=n,this._z=o,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n=!0){const o=e._x,i=e._y,r=e._z,A=e._order,s=Math.cos,a=Math.sin,c=s(o/2),l=s(i/2),g=s(r/2),u=a(o/2),d=a(i/2),h=a(r/2);switch(A){case"XYZ":this._x=u*l*g+c*d*h,this._y=c*d*g-u*l*h,this._z=c*l*h+u*d*g,this._w=c*l*g-u*d*h;break;case"YXZ":this._x=u*l*g+c*d*h,this._y=c*d*g-u*l*h,this._z=c*l*h-u*d*g,this._w=c*l*g+u*d*h;break;case"ZXY":this._x=u*l*g-c*d*h,this._y=c*d*g+u*l*h,this._z=c*l*h+u*d*g,this._w=c*l*g-u*d*h;break;case"ZYX":this._x=u*l*g-c*d*h,this._y=c*d*g+u*l*h,this._z=c*l*h-u*d*g,this._w=c*l*g+u*d*h;break;case"YZX":this._x=u*l*g+c*d*h,this._y=c*d*g+u*l*h,this._z=c*l*h-u*d*g,this._w=c*l*g-u*d*h;break;case"XZY":this._x=u*l*g-c*d*h,this._y=c*d*g-u*l*h,this._z=c*l*h+u*d*g,this._w=c*l*g+u*d*h;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+A)}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const o=n/2,i=Math.sin(o);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(o),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,o=n[0],i=n[4],r=n[8],A=n[1],s=n[5],a=n[9],c=n[2],l=n[6],g=n[10],u=o+s+g;if(u>0){const d=.5/Math.sqrt(u+1);this._w=.25/d,this._x=(l-a)*d,this._y=(r-c)*d,this._z=(A-i)*d}else if(o>s&&o>g){const d=2*Math.sqrt(1+o-s-g);this._w=(l-a)/d,this._x=.25*d,this._y=(i+A)/d,this._z=(r+c)/d}else if(s>g){const d=2*Math.sqrt(1+s-o-g);this._w=(r-c)/d,this._x=(i+A)/d,this._y=.25*d,this._z=(a+l)/d}else{const d=2*Math.sqrt(1+g-o-s);this._w=(A-i)/d,this._x=(r+c)/d,this._y=(a+l)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let o=e.dot(n)+1;return o<Number.EPSILON?(o=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=o):(this._x=0,this._y=-e.z,this._z=e.y,this._w=o)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=o),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Pp(this.dot(e),-1,1)))}rotateTowards(e,n){const o=this.angleTo(e);if(o===0)return this;const i=Math.min(1,n/o);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const o=e._x,i=e._y,r=e._z,A=e._w,s=n._x,a=n._y,c=n._z,l=n._w;return this._x=o*l+A*s+i*c-r*a,this._y=i*l+A*a+r*s-o*c,this._z=r*l+A*c+o*a-i*s,this._w=A*l-o*s-i*a-r*c,this._onChangeCallback(),this}slerp(e,n){if(n===0)return this;if(n===1)return this.copy(e);const o=this._x,i=this._y,r=this._z,A=this._w;let s=A*e._w+o*e._x+i*e._y+r*e._z;if(s<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,s=-s):this.copy(e),s>=1)return this._w=A,this._x=o,this._y=i,this._z=r,this;const a=1-s*s;if(a<=Number.EPSILON){const d=1-n;return this._w=d*A+n*this._w,this._x=d*o+n*this._x,this._y=d*i+n*this._y,this._z=d*r+n*this._z,this.normalize(),this}const c=Math.sqrt(a),l=Math.atan2(c,s),g=Math.sin((1-n)*l)/c,u=Math.sin(n*l)/c;return this._w=A*g+this._w*u,this._x=o*g+this._x*u,this._y=i*g+this._y*u,this._z=r*g+this._z*u,this._onChangeCallback(),this}slerpQuaternions(e,n,o){return this.copy(e).slerp(n,o)}random(){const e=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),o=Math.random(),i=Math.sqrt(1-o),r=Math.sqrt(o);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(n),r*Math.cos(n))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Rt{constructor(e=0,n=0,o=0){Rt.prototype.isVector3=!0,this.x=e,this.y=n,this.z=o}set(e,n,o){return o===void 0&&(o=this.z),this.x=e,this.y=n,this.z=o,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,n){return this.x=e.x*n.x,this.y=e.y*n.y,this.z=e.z*n.z,this}applyEuler(e){return this.applyQuaternion(Jlt.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(Jlt.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,o=this.y,i=this.z,r=e.elements;return this.x=r[0]*n+r[3]*o+r[6]*i,this.y=r[1]*n+r[4]*o+r[7]*i,this.z=r[2]*n+r[5]*o+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,o=this.y,i=this.z,r=e.elements,A=1/(r[3]*n+r[7]*o+r[11]*i+r[15]);return this.x=(r[0]*n+r[4]*o+r[8]*i+r[12])*A,this.y=(r[1]*n+r[5]*o+r[9]*i+r[13])*A,this.z=(r[2]*n+r[6]*o+r[10]*i+r[14])*A,this}applyQuaternion(e){const n=this.x,o=this.y,i=this.z,r=e.x,A=e.y,s=e.z,a=e.w,c=2*(A*i-s*o),l=2*(s*n-r*i),g=2*(r*o-A*n);return this.x=n+a*c+A*g-s*l,this.y=o+a*l+s*c-r*g,this.z=i+a*g+r*l-A*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,o=this.y,i=this.z,r=e.elements;return this.x=r[0]*n+r[4]*o+r[8]*i,this.y=r[1]*n+r[5]*o+r[9]*i,this.z=r[2]*n+r[6]*o+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this}clampLength(e,n){const o=this.length();return this.divideScalar(o||1).multiplyScalar(Math.max(e,Math.min(n,o)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,o){return this.x=e.x+(n.x-e.x)*o,this.y=e.y+(n.y-e.y)*o,this.z=e.z+(n.z-e.z)*o,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const o=e.x,i=e.y,r=e.z,A=n.x,s=n.y,a=n.z;return this.x=i*a-r*s,this.y=r*A-o*a,this.z=o*s-i*A,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const o=e.dot(this)/n;return this.copy(e).multiplyScalar(o)}projectOnPlane(e){return nCe.copy(this).projectOnVector(e),this.sub(nCe)}reflect(e){return this.sub(nCe.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const o=this.dot(e)/n;return Math.acos(Pp(o,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,o=this.y-e.y,i=this.z-e.z;return n*n+o*o+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,n,o){const i=Math.sin(n)*e;return this.x=i*Math.sin(o),this.y=Math.cos(n)*e,this.z=i*Math.cos(o),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,o){return this.x=e*Math.sin(n),this.y=o,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){const n=this.setFromMatrixColumn(e,0).length(),o=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=o,this.z=i,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,n*4)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,n*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,n=Math.random()*2-1,o=Math.sqrt(1-n*n);return this.x=o*Math.cos(e),this.y=n,this.z=o*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const nCe=new Rt,Jlt=new jC;class l2{constructor(e=new Rt(1/0,1/0,1/0),n=new Rt(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,o=e.length;n<o;n+=3)this.expandByPoint(EB.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,o=e.count;n<o;n++)this.expandByPoint(EB.fromBufferAttribute(e,n));return this}setFromPoints(e){this.makeEmpty();for(let n=0,o=e.length;n<o;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){const o=EB.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(o),this.max.copy(e).add(o),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const o=e.geometry;if(o!==void 0){const r=o.getAttribute("position");if(n===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let A=0,s=r.count;A<s;A++)e.isMesh===!0?e.getVertexPosition(A,EB):EB.fromBufferAttribute(r,A),EB.applyMatrix4(e.matrixWorld),this.expandByPoint(EB);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),FX.copy(e.boundingBox)):(o.boundingBox===null&&o.computeBoundingBox(),FX.copy(o.boundingBox)),FX.applyMatrix4(e.matrixWorld),this.union(FX)}const i=e.children;for(let r=0,A=i.length;r<A;r++)this.expandByObject(i[r],n);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,EB),EB.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,o;return e.normal.x>0?(n=e.normal.x*this.min.x,o=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,o=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,o+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,o+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,o+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,o+=e.normal.z*this.min.z),n<=-e.constant&&o>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(LL),LX.subVectors(this.max,LL),Y9.subVectors(e.a,LL),V9.subVectors(e.b,LL),z9.subVectors(e.c,LL),$b.subVectors(V9,Y9),Zb.subVectors(z9,V9),EP.subVectors(Y9,z9);let n=[0,-$b.z,$b.y,0,-Zb.z,Zb.y,0,-EP.z,EP.y,$b.z,0,-$b.x,Zb.z,0,-Zb.x,EP.z,0,-EP.x,-$b.y,$b.x,0,-Zb.y,Zb.x,0,-EP.y,EP.x,0];return!oCe(n,Y9,V9,z9,LX)||(n=[1,0,0,0,1,0,0,0,1],!oCe(n,Y9,V9,z9,LX))?!1:(HX.crossVectors($b,Zb),n=[HX.x,HX.y,HX.z],oCe(n,Y9,V9,z9,LX))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,EB).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(EB).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(ZS[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ZS[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ZS[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ZS[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ZS[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ZS[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ZS[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ZS[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ZS),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const ZS=[new Rt,new Rt,new Rt,new Rt,new Rt,new Rt,new Rt,new Rt],EB=new Rt,FX=new l2,Y9=new Rt,V9=new Rt,z9=new Rt,$b=new Rt,Zb=new Rt,EP=new Rt,LL=new Rt,LX=new Rt,HX=new Rt,BP=new Rt;function oCe(t,e,n,o,i){for(let r=0,A=t.length-3;r<=A;r+=3){BP.fromArray(t,r);const s=i.x*Math.abs(BP.x)+i.y*Math.abs(BP.y)+i.z*Math.abs(BP.z),a=e.dot(BP),c=n.dot(BP),l=o.dot(BP);if(Math.max(-Math.max(a,c,l),Math.min(a,c,l))>s)return!1}return!0}const cLn=new l2,HL=new Rt,iCe=new Rt;let BB=class{constructor(e=new Rt,n=-1){this.isSphere=!0,this.center=e,this.radius=n}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){const o=this.center;n!==void 0?o.copy(n):cLn.setFromPoints(e).getCenter(o);let i=0;for(let r=0,A=e.length;r<A;r++)i=Math.max(i,o.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const o=this.center.distanceToSquared(e);return n.copy(e),o>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;HL.subVectors(e,this.center);const n=HL.lengthSq();if(n>this.radius*this.radius){const o=Math.sqrt(n),i=(o-this.radius)*.5;this.center.addScaledVector(HL,i/o),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(iCe.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(HL.copy(e.center).add(iCe)),this.expandByPoint(HL.copy(e.center).sub(iCe))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}};const e5=new Rt,rCe=new Rt,GX=new Rt,eD=new Rt,ACe=new Rt,OX=new Rt,sCe=new Rt;class J9{constructor(e=new Rt,n=new Rt(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,e5)),this}closestPointToPoint(e,n){n.subVectors(e,this.origin);const o=n.dot(this.direction);return o<0?n.copy(this.origin):n.copy(this.origin).addScaledVector(this.direction,o)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const n=e5.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(e5.copy(this.origin).addScaledVector(this.direction,n),e5.distanceToSquared(e))}distanceSqToSegment(e,n,o,i){rCe.copy(e).add(n).multiplyScalar(.5),GX.copy(n).sub(e).normalize(),eD.copy(this.origin).sub(rCe);const r=e.distanceTo(n)*.5,A=-this.direction.dot(GX),s=eD.dot(this.direction),a=-eD.dot(GX),c=eD.lengthSq(),l=Math.abs(1-A*A);let g,u,d,h;if(l>0)if(g=A*a-s,u=A*s-a,h=r*l,g>=0)if(u>=-h)if(u<=h){const _=1/l;g*=_,u*=_,d=g*(g+A*u+2*s)+u*(A*g+u+2*a)+c}else u=r,g=Math.max(0,-(A*u+s)),d=-g*g+u*(u+2*a)+c;else u=-r,g=Math.max(0,-(A*u+s)),d=-g*g+u*(u+2*a)+c;else u<=-h?(g=Math.max(0,-(-A*r+s)),u=g>0?-r:Math.min(Math.max(-r,-a),r),d=-g*g+u*(u+2*a)+c):u<=h?(g=0,u=Math.min(Math.max(-r,-a),r),d=u*(u+2*a)+c):(g=Math.max(0,-(A*r+s)),u=g>0?r:Math.min(Math.max(-r,-a),r),d=-g*g+u*(u+2*a)+c);else u=A>0?-r:r,g=Math.max(0,-(A*u+s)),d=-g*g+u*(u+2*a)+c;return o&&o.copy(this.origin).addScaledVector(this.direction,g),i&&i.copy(rCe).addScaledVector(GX,u),d}intersectSphere(e,n){e5.subVectors(e.center,this.origin);const o=e5.dot(this.direction),i=e5.dot(e5)-o*o,r=e.radius*e.radius;if(i>r)return null;const A=Math.sqrt(r-i),s=o-A,a=o+A;return a<0?null:s<0?this.at(a,n):this.at(s,n)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const o=-(this.origin.dot(e.normal)+e.constant)/n;return o>=0?o:null}intersectPlane(e,n){const o=this.distanceToPlane(e);return o===null?null:this.at(o,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let o,i,r,A,s,a;const c=1/this.direction.x,l=1/this.direction.y,g=1/this.direction.z,u=this.origin;return c>=0?(o=(e.min.x-u.x)*c,i=(e.max.x-u.x)*c):(o=(e.max.x-u.x)*c,i=(e.min.x-u.x)*c),l>=0?(r=(e.min.y-u.y)*l,A=(e.max.y-u.y)*l):(r=(e.max.y-u.y)*l,A=(e.min.y-u.y)*l),o>A||r>i||((r>o||isNaN(o))&&(o=r),(A<i||isNaN(i))&&(i=A),g>=0?(s=(e.min.z-u.z)*g,a=(e.max.z-u.z)*g):(s=(e.max.z-u.z)*g,a=(e.min.z-u.z)*g),o>a||s>i)||((s>o||o!==o)&&(o=s),(a<i||i!==i)&&(i=a),i<0)?null:this.at(o>=0?o:i,n)}intersectsBox(e){return this.intersectBox(e,e5)!==null}intersectTriangle(e,n,o,i,r){ACe.subVectors(n,e),OX.subVectors(o,e),sCe.crossVectors(ACe,OX);let A=this.direction.dot(sCe),s;if(A>0){if(i)return null;s=1}else if(A<0)s=-1,A=-A;else return null;eD.subVectors(this.origin,e);const a=s*this.direction.dot(OX.crossVectors(eD,OX));if(a<0)return null;const c=s*this.direction.dot(ACe.cross(eD));if(c<0||a+c>A)return null;const l=-s*eD.dot(sCe);return l<0?null:this.at(l/A,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class wA{constructor(e,n,o,i,r,A,s,a,c,l,g,u,d,h,_,p){wA.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,o,i,r,A,s,a,c,l,g,u,d,h,_,p)}set(e,n,o,i,r,A,s,a,c,l,g,u,d,h,_,p){const m=this.elements;return m[0]=e,m[4]=n,m[8]=o,m[12]=i,m[1]=r,m[5]=A,m[9]=s,m[13]=a,m[2]=c,m[6]=l,m[10]=g,m[14]=u,m[3]=d,m[7]=h,m[11]=_,m[15]=p,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new wA().fromArray(this.elements)}copy(e){const n=this.elements,o=e.elements;return n[0]=o[0],n[1]=o[1],n[2]=o[2],n[3]=o[3],n[4]=o[4],n[5]=o[5],n[6]=o[6],n[7]=o[7],n[8]=o[8],n[9]=o[9],n[10]=o[10],n[11]=o[11],n[12]=o[12],n[13]=o[13],n[14]=o[14],n[15]=o[15],this}copyPosition(e){const n=this.elements,o=e.elements;return n[12]=o[12],n[13]=o[13],n[14]=o[14],this}setFromMatrix3(e){const n=e.elements;return this.set(n[0],n[3],n[6],0,n[1],n[4],n[7],0,n[2],n[5],n[8],0,0,0,0,1),this}extractBasis(e,n,o){return e.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),o.setFromMatrixColumn(this,2),this}makeBasis(e,n,o){return this.set(e.x,n.x,o.x,0,e.y,n.y,o.y,0,e.z,n.z,o.z,0,0,0,0,1),this}extractRotation(e){const n=this.elements,o=e.elements,i=1/q9.setFromMatrixColumn(e,0).length(),r=1/q9.setFromMatrixColumn(e,1).length(),A=1/q9.setFromMatrixColumn(e,2).length();return n[0]=o[0]*i,n[1]=o[1]*i,n[2]=o[2]*i,n[3]=0,n[4]=o[4]*r,n[5]=o[5]*r,n[6]=o[6]*r,n[7]=0,n[8]=o[8]*A,n[9]=o[9]*A,n[10]=o[10]*A,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){const n=this.elements,o=e.x,i=e.y,r=e.z,A=Math.cos(o),s=Math.sin(o),a=Math.cos(i),c=Math.sin(i),l=Math.cos(r),g=Math.sin(r);if(e.order==="XYZ"){const u=A*l,d=A*g,h=s*l,_=s*g;n[0]=a*l,n[4]=-a*g,n[8]=c,n[1]=d+h*c,n[5]=u-_*c,n[9]=-s*a,n[2]=_-u*c,n[6]=h+d*c,n[10]=A*a}else if(e.order==="YXZ"){const u=a*l,d=a*g,h=c*l,_=c*g;n[0]=u+_*s,n[4]=h*s-d,n[8]=A*c,n[1]=A*g,n[5]=A*l,n[9]=-s,n[2]=d*s-h,n[6]=_+u*s,n[10]=A*a}else if(e.order==="ZXY"){const u=a*l,d=a*g,h=c*l,_=c*g;n[0]=u-_*s,n[4]=-A*g,n[8]=h+d*s,n[1]=d+h*s,n[5]=A*l,n[9]=_-u*s,n[2]=-A*c,n[6]=s,n[10]=A*a}else if(e.order==="ZYX"){const u=A*l,d=A*g,h=s*l,_=s*g;n[0]=a*l,n[4]=h*c-d,n[8]=u*c+_,n[1]=a*g,n[5]=_*c+u,n[9]=d*c-h,n[2]=-c,n[6]=s*a,n[10]=A*a}else if(e.order==="YZX"){const u=A*a,d=A*c,h=s*a,_=s*c;n[0]=a*l,n[4]=_-u*g,n[8]=h*g+d,n[1]=g,n[5]=A*l,n[9]=-s*l,n[2]=-c*l,n[6]=d*g+h,n[10]=u-_*g}else if(e.order==="XZY"){const u=A*a,d=A*c,h=s*a,_=s*c;n[0]=a*l,n[4]=-g,n[8]=c*l,n[1]=u*g+_,n[5]=A*l,n[9]=d*g-h,n[2]=h*g-d,n[6]=s*l,n[10]=_*g+u}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(lLn,e,gLn)}lookAt(e,n,o){const i=this.elements;return Ly.subVectors(e,n),Ly.lengthSq()===0&&(Ly.z=1),Ly.normalize(),tD.crossVectors(o,Ly),tD.lengthSq()===0&&(Math.abs(o.z)===1?Ly.x+=1e-4:Ly.z+=1e-4,Ly.normalize(),tD.crossVectors(o,Ly)),tD.normalize(),KX.crossVectors(Ly,tD),i[0]=tD.x,i[4]=KX.x,i[8]=Ly.x,i[1]=tD.y,i[5]=KX.y,i[9]=Ly.y,i[2]=tD.z,i[6]=KX.z,i[10]=Ly.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const o=e.elements,i=n.elements,r=this.elements,A=o[0],s=o[4],a=o[8],c=o[12],l=o[1],g=o[5],u=o[9],d=o[13],h=o[2],_=o[6],p=o[10],m=o[14],I=o[3],C=o[7],f=o[11],y=o[15],B=i[0],x=i[4],S=i[8],M=i[12],w=i[1],k=i[5],N=i[9],G=i[13],H=i[2],U=i[6],J=i[10],W=i[14],X=i[3],oe=i[7],ce=i[11],te=i[15];return r[0]=A*B+s*w+a*H+c*X,r[4]=A*x+s*k+a*U+c*oe,r[8]=A*S+s*N+a*J+c*ce,r[12]=A*M+s*G+a*W+c*te,r[1]=l*B+g*w+u*H+d*X,r[5]=l*x+g*k+u*U+d*oe,r[9]=l*S+g*N+u*J+d*ce,r[13]=l*M+g*G+u*W+d*te,r[2]=h*B+_*w+p*H+m*X,r[6]=h*x+_*k+p*U+m*oe,r[10]=h*S+_*N+p*J+m*ce,r[14]=h*M+_*G+p*W+m*te,r[3]=I*B+C*w+f*H+y*X,r[7]=I*x+C*k+f*U+y*oe,r[11]=I*S+C*N+f*J+y*ce,r[15]=I*M+C*G+f*W+y*te,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],o=e[4],i=e[8],r=e[12],A=e[1],s=e[5],a=e[9],c=e[13],l=e[2],g=e[6],u=e[10],d=e[14],h=e[3],_=e[7],p=e[11],m=e[15];return h*(+r*a*g-i*c*g-r*s*u+o*c*u+i*s*d-o*a*d)+_*(+n*a*d-n*c*u+r*A*u-i*A*d+i*c*l-r*a*l)+p*(+n*c*g-n*s*d-r*A*g+o*A*d+r*s*l-o*c*l)+m*(-i*s*l-n*a*g+n*s*u+i*A*g-o*A*u+o*a*l)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,o){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=n,i[14]=o),this}invert(){const e=this.elements,n=e[0],o=e[1],i=e[2],r=e[3],A=e[4],s=e[5],a=e[6],c=e[7],l=e[8],g=e[9],u=e[10],d=e[11],h=e[12],_=e[13],p=e[14],m=e[15],I=g*p*c-_*u*c+_*a*d-s*p*d-g*a*m+s*u*m,C=h*u*c-l*p*c-h*a*d+A*p*d+l*a*m-A*u*m,f=l*_*c-h*g*c+h*s*d-A*_*d-l*s*m+A*g*m,y=h*g*a-l*_*a-h*s*u+A*_*u+l*s*p-A*g*p,B=n*I+o*C+i*f+r*y;if(B===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const x=1/B;return e[0]=I*x,e[1]=(_*u*r-g*p*r-_*i*d+o*p*d+g*i*m-o*u*m)*x,e[2]=(s*p*r-_*a*r+_*i*c-o*p*c-s*i*m+o*a*m)*x,e[3]=(g*a*r-s*u*r-g*i*c+o*u*c+s*i*d-o*a*d)*x,e[4]=C*x,e[5]=(l*p*r-h*u*r+h*i*d-n*p*d-l*i*m+n*u*m)*x,e[6]=(h*a*r-A*p*r-h*i*c+n*p*c+A*i*m-n*a*m)*x,e[7]=(A*u*r-l*a*r+l*i*c-n*u*c-A*i*d+n*a*d)*x,e[8]=f*x,e[9]=(h*g*r-l*_*r-h*o*d+n*_*d+l*o*m-n*g*m)*x,e[10]=(A*_*r-h*s*r+h*o*c-n*_*c-A*o*m+n*s*m)*x,e[11]=(l*s*r-A*g*r-l*o*c+n*g*c+A*o*d-n*s*d)*x,e[12]=y*x,e[13]=(l*_*i-h*g*i+h*o*u-n*_*u-l*o*p+n*g*p)*x,e[14]=(h*s*i-A*_*i-h*o*a+n*_*a+A*o*p-n*s*p)*x,e[15]=(A*g*i-l*s*i+l*o*a-n*g*a-A*o*u+n*s*u)*x,this}scale(e){const n=this.elements,o=e.x,i=e.y,r=e.z;return n[0]*=o,n[4]*=i,n[8]*=r,n[1]*=o,n[5]*=i,n[9]*=r,n[2]*=o,n[6]*=i,n[10]*=r,n[3]*=o,n[7]*=i,n[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],o=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,o,i))}makeTranslation(e,n,o){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,o,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),o=Math.sin(e);return this.set(1,0,0,0,0,n,-o,0,0,o,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),o=Math.sin(e);return this.set(n,0,o,0,0,1,0,0,-o,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),o=Math.sin(e);return this.set(n,-o,0,0,o,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const o=Math.cos(n),i=Math.sin(n),r=1-o,A=e.x,s=e.y,a=e.z,c=r*A,l=r*s;return this.set(c*A+o,c*s-i*a,c*a+i*s,0,c*s+i*a,l*s+o,l*a-i*A,0,c*a-i*s,l*a+i*A,r*a*a+o,0,0,0,0,1),this}makeScale(e,n,o){return this.set(e,0,0,0,0,n,0,0,0,0,o,0,0,0,0,1),this}makeShear(e,n,o,i,r,A){return this.set(1,o,r,0,e,1,A,0,n,i,1,0,0,0,0,1),this}compose(e,n,o){const i=this.elements,r=n._x,A=n._y,s=n._z,a=n._w,c=r+r,l=A+A,g=s+s,u=r*c,d=r*l,h=r*g,_=A*l,p=A*g,m=s*g,I=a*c,C=a*l,f=a*g,y=o.x,B=o.y,x=o.z;return i[0]=(1-(_+m))*y,i[1]=(d+f)*y,i[2]=(h-C)*y,i[3]=0,i[4]=(d-f)*B,i[5]=(1-(u+m))*B,i[6]=(p+I)*B,i[7]=0,i[8]=(h+C)*x,i[9]=(p-I)*x,i[10]=(1-(u+_))*x,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,n,o){const i=this.elements;let r=q9.set(i[0],i[1],i[2]).length();const A=q9.set(i[4],i[5],i[6]).length(),s=q9.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],xB.copy(this);const c=1/r,l=1/A,g=1/s;return xB.elements[0]*=c,xB.elements[1]*=c,xB.elements[2]*=c,xB.elements[4]*=l,xB.elements[5]*=l,xB.elements[6]*=l,xB.elements[8]*=g,xB.elements[9]*=g,xB.elements[10]*=g,n.setFromRotationMatrix(xB),o.x=r,o.y=A,o.z=s,this}makePerspective(e,n,o,i,r,A,s=$S){const a=this.elements,c=2*r/(n-e),l=2*r/(o-i),g=(n+e)/(n-e),u=(o+i)/(o-i);let d,h;if(s===$S)d=-(A+r)/(A-r),h=-2*A*r/(A-r);else if(s===TX)d=-A/(A-r),h=-A*r/(A-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+s);return a[0]=c,a[4]=0,a[8]=g,a[12]=0,a[1]=0,a[5]=l,a[9]=u,a[13]=0,a[2]=0,a[6]=0,a[10]=d,a[14]=h,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(e,n,o,i,r,A,s=$S){const a=this.elements,c=1/(n-e),l=1/(o-i),g=1/(A-r),u=(n+e)*c,d=(o+i)*l;let h,_;if(s===$S)h=(A+r)*g,_=-2*g;else if(s===TX)h=r*g,_=-1*g;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+s);return a[0]=2*c,a[4]=0,a[8]=0,a[12]=-u,a[1]=0,a[5]=2*l,a[9]=0,a[13]=-d,a[2]=0,a[6]=0,a[10]=_,a[14]=-h,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(e){const n=this.elements,o=e.elements;for(let i=0;i<16;i++)if(n[i]!==o[i])return!1;return!0}fromArray(e,n=0){for(let o=0;o<16;o++)this.elements[o]=e[o+n];return this}toArray(e=[],n=0){const o=this.elements;return e[n]=o[0],e[n+1]=o[1],e[n+2]=o[2],e[n+3]=o[3],e[n+4]=o[4],e[n+5]=o[5],e[n+6]=o[6],e[n+7]=o[7],e[n+8]=o[8],e[n+9]=o[9],e[n+10]=o[10],e[n+11]=o[11],e[n+12]=o[12],e[n+13]=o[13],e[n+14]=o[14],e[n+15]=o[15],e}}const q9=new Rt,xB=new wA,lLn=new Rt(0,0,0),gLn=new Rt(1,1,1),tD=new Rt,KX=new Rt,Ly=new Rt,qlt=new wA,Wlt=new jC;class XC{constructor(e=0,n=0,o=0,i=XC.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=o,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,o,i=this._order){return this._x=e,this._y=n,this._z=o,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,o=!0){const i=e.elements,r=i[0],A=i[4],s=i[8],a=i[1],c=i[5],l=i[9],g=i[2],u=i[6],d=i[10];switch(n){case"XYZ":this._y=Math.asin(Pp(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,d),this._z=Math.atan2(-A,r)):(this._x=Math.atan2(u,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Pp(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(s,d),this._z=Math.atan2(a,c)):(this._y=Math.atan2(-g,r),this._z=0);break;case"ZXY":this._x=Math.asin(Pp(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-g,d),this._z=Math.atan2(-A,c)):(this._y=0,this._z=Math.atan2(a,r));break;case"ZYX":this._y=Math.asin(-Pp(g,-1,1)),Math.abs(g)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(a,r)):(this._x=0,this._z=Math.atan2(-A,c));break;case"YZX":this._z=Math.asin(Pp(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-g,r)):(this._x=0,this._y=Math.atan2(s,d));break;case"XZY":this._z=Math.asin(-Pp(A,-1,1)),Math.abs(A)<.9999999?(this._x=Math.atan2(u,c),this._y=Math.atan2(s,r)):(this._x=Math.atan2(-l,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,o===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,o){return qlt.makeRotationFromQuaternion(e),this.setFromRotationMatrix(qlt,n,o)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return Wlt.setFromEuler(this),this.setFromQuaternion(Wlt,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}XC.DEFAULT_ORDER="XYZ";class aCe{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let uLn=0;const jlt=new Rt,W9=new jC,t5=new wA,UX=new Rt,GL=new Rt,hLn=new Rt,dLn=new jC,Xlt=new Rt(1,0,0),$lt=new Rt(0,1,0),Zlt=new Rt(0,0,1),egt={type:"added"},_Ln={type:"removed"},j9={type:"childadded",child:null},cCe={type:"childremoved",child:null};class tl extends fP{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:uLn++}),this.uuid=fB(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=tl.DEFAULT_UP.clone();const e=new Rt,n=new XC,o=new jC,i=new Rt(1,1,1);function r(){o.setFromEuler(n,!1)}function A(){n.setFromQuaternion(o,void 0,!1)}n._onChange(r),o._onChange(A),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:o},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new wA},normalMatrix:{value:new Ds}}),this.matrix=new wA,this.matrixWorld=new wA,this.matrixAutoUpdate=tl.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=tl.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new aCe,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,n){this.quaternion.setFromAxisAngle(e,n)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,n){return W9.setFromAxisAngle(e,n),this.quaternion.multiply(W9),this}rotateOnWorldAxis(e,n){return W9.setFromAxisAngle(e,n),this.quaternion.premultiply(W9),this}rotateX(e){return this.rotateOnAxis(Xlt,e)}rotateY(e){return this.rotateOnAxis($lt,e)}rotateZ(e){return this.rotateOnAxis(Zlt,e)}translateOnAxis(e,n){return jlt.copy(e).applyQuaternion(this.quaternion),this.position.add(jlt.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(Xlt,e)}translateY(e){return this.translateOnAxis($lt,e)}translateZ(e){return this.translateOnAxis(Zlt,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(t5.copy(this.matrixWorld).invert())}lookAt(e,n,o){e.isVector3?UX.copy(e):UX.set(e,n,o);const i=this.parent;this.updateWorldMatrix(!0,!1),GL.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?t5.lookAt(GL,UX,this.up):t5.lookAt(UX,GL,this.up),this.quaternion.setFromRotationMatrix(t5),i&&(t5.extractRotation(i.matrixWorld),W9.setFromRotationMatrix(t5),this.quaternion.premultiply(W9.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(egt),j9.child=e,this.dispatchEvent(j9),j9.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let o=0;o<arguments.length;o++)this.remove(arguments[o]);return this}const n=this.children.indexOf(e);return n!==-1&&(e.parent=null,this.children.splice(n,1),e.dispatchEvent(_Ln),cCe.child=e,this.dispatchEvent(cCe),cCe.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),t5.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),t5.multiply(e.parent.matrixWorld)),e.applyMatrix4(t5),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(egt),j9.child=e,this.dispatchEvent(j9),j9.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let o=0,i=this.children.length;o<i;o++){const A=this.children[o].getObjectByProperty(e,n);if(A!==void 0)return A}}getObjectsByProperty(e,n,o=[]){this[e]===n&&o.push(this);const i=this.children;for(let r=0,A=i.length;r<A;r++)i[r].getObjectsByProperty(e,n,o);return o}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(GL,e,hLn),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(GL,dLn,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let o=0,i=n.length;o<i;o++)n[o].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let o=0,i=n.length;o<i;o++)n[o].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let o=0,i=n.length;o<i;o++){const r=n[o];(r.matrixWorldAutoUpdate===!0||e===!0)&&r.updateMatrixWorld(e)}}updateWorldMatrix(e,n){const o=this.parent;if(e===!0&&o!==null&&o.matrixWorldAutoUpdate===!0&&o.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),n===!0){const i=this.children;for(let r=0,A=i.length;r<A;r++){const s=i[r];s.matrixWorldAutoUpdate===!0&&s.updateWorldMatrix(!1,!0)}}}toJSON(e){const n=e===void 0||typeof e=="string",o={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},o.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(s=>({boxInitialized:s.boxInitialized,boxMin:s.box.min.toArray(),boxMax:s.box.max.toArray(),sphereInitialized:s.sphereInitialized,sphereRadius:s.sphere.radius,sphereCenter:s.sphere.center.toArray()})),i.maxGeometryCount=this._maxGeometryCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function r(s,a){return s[a.uuid]===void 0&&(s[a.uuid]=a.toJSON(e)),a.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);const s=this.geometry.parameters;if(s!==void 0&&s.shapes!==void 0){const a=s.shapes;if(Array.isArray(a))for(let c=0,l=a.length;c<l;c++){const g=a[c];r(e.shapes,g)}else r(e.shapes,a)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const s=[];for(let a=0,c=this.material.length;a<c;a++)s.push(r(e.materials,this.material[a]));i.material=s}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let s=0;s<this.children.length;s++)i.children.push(this.children[s].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let s=0;s<this.animations.length;s++){const a=this.animations[s];i.animations.push(r(e.animations,a))}}if(n){const s=A(e.geometries),a=A(e.materials),c=A(e.textures),l=A(e.images),g=A(e.shapes),u=A(e.skeletons),d=A(e.animations),h=A(e.nodes);s.length>0&&(o.geometries=s),a.length>0&&(o.materials=a),c.length>0&&(o.textures=c),l.length>0&&(o.images=l),g.length>0&&(o.shapes=g),u.length>0&&(o.skeletons=u),d.length>0&&(o.animations=d),h.length>0&&(o.nodes=h)}return o.object=i,o;function A(s){const a=[];for(const c in s){const l=s[c];delete l.metadata,a.push(l)}return a}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let o=0;o<e.children.length;o++){const i=e.children[o];this.add(i.clone())}return this}}tl.DEFAULT_UP=new Rt(0,1,0),tl.DEFAULT_MATRIX_AUTO_UPDATE=!0,tl.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const QB=new Rt,n5=new Rt,lCe=new Rt,o5=new Rt,X9=new Rt,$9=new Rt,tgt=new Rt,gCe=new Rt,uCe=new Rt,hCe=new Rt;class SB{constructor(e=new Rt,n=new Rt,o=new Rt){this.a=e,this.b=n,this.c=o}static getNormal(e,n,o,i){i.subVectors(o,n),QB.subVectors(e,n),i.cross(QB);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,n,o,i,r){QB.subVectors(i,n),n5.subVectors(o,n),lCe.subVectors(e,n);const A=QB.dot(QB),s=QB.dot(n5),a=QB.dot(lCe),c=n5.dot(n5),l=n5.dot(lCe),g=A*c-s*s;if(g===0)return r.set(0,0,0),null;const u=1/g,d=(c*a-s*l)*u,h=(A*l-s*a)*u;return r.set(1-d-h,h,d)}static containsPoint(e,n,o,i){return this.getBarycoord(e,n,o,i,o5)===null?!1:o5.x>=0&&o5.y>=0&&o5.x+o5.y<=1}static getInterpolation(e,n,o,i,r,A,s,a){return this.getBarycoord(e,n,o,i,o5)===null?(a.x=0,a.y=0,"z"in a&&(a.z=0),"w"in a&&(a.w=0),null):(a.setScalar(0),a.addScaledVector(r,o5.x),a.addScaledVector(A,o5.y),a.addScaledVector(s,o5.z),a)}static isFrontFacing(e,n,o,i){return QB.subVectors(o,n),n5.subVectors(e,n),QB.cross(n5).dot(i)<0}set(e,n,o){return this.a.copy(e),this.b.copy(n),this.c.copy(o),this}setFromPointsAndIndices(e,n,o,i){return this.a.copy(e[n]),this.b.copy(e[o]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,n,o,i){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,o),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return QB.subVectors(this.c,this.b),n5.subVectors(this.a,this.b),QB.cross(n5).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return SB.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return SB.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,o,i,r){return SB.getInterpolation(e,this.a,this.b,this.c,n,o,i,r)}containsPoint(e){return SB.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return SB.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const o=this.a,i=this.b,r=this.c;let A,s;X9.subVectors(i,o),$9.subVectors(r,o),gCe.subVectors(e,o);const a=X9.dot(gCe),c=$9.dot(gCe);if(a<=0&&c<=0)return n.copy(o);uCe.subVectors(e,i);const l=X9.dot(uCe),g=$9.dot(uCe);if(l>=0&&g<=l)return n.copy(i);const u=a*g-l*c;if(u<=0&&a>=0&&l<=0)return A=a/(a-l),n.copy(o).addScaledVector(X9,A);hCe.subVectors(e,r);const d=X9.dot(hCe),h=$9.dot(hCe);if(h>=0&&d<=h)return n.copy(r);const _=d*c-a*h;if(_<=0&&c>=0&&h<=0)return s=c/(c-h),n.copy(o).addScaledVector($9,s);const p=l*h-d*g;if(p<=0&&g-l>=0&&d-h>=0)return tgt.subVectors(r,i),s=(g-l)/(g-l+(d-h)),n.copy(i).addScaledVector(tgt,s);const m=1/(p+_+u);return A=_*m,s=u*m,n.copy(o).addScaledVector(X9,A).addScaledVector($9,s)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const ngt={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},nD={h:0,s:0,l:0},YX={h:0,s:0,l:0};function dCe(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*6*(2/3-n):t}class yi{constructor(e,n,o){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,o)}set(e,n,o){if(n===void 0&&o===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,n,o);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=CB){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Ql.toWorkingColorSpace(this,n),this}setRGB(e,n,o,i=Ql.workingColorSpace){return this.r=e,this.g=n,this.b=o,Ql.toWorkingColorSpace(this,i),this}setHSL(e,n,o,i=Ql.workingColorSpace){if(e=XIe(e,1),n=Pp(n,0,1),o=Pp(o,0,1),n===0)this.r=this.g=this.b=o;else{const r=o<=.5?o*(1+n):o+n-o*n,A=2*o-r;this.r=dCe(A,r,e+1/3),this.g=dCe(A,r,e),this.b=dCe(A,r,e-1/3)}return Ql.toWorkingColorSpace(this,i),this}setStyle(e,n=CB){function o(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const A=i[1],s=i[2];switch(A){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return o(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,n);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return o(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,n);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return o(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,n);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=i[1],A=r.length;if(A===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,n);if(A===6)return this.setHex(parseInt(r,16),n);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=CB){const o=ngt[e.toLowerCase()];return o!==void 0?this.setHex(o,n):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=K9(e.r),this.g=K9(e.g),this.b=K9(e.b),this}copyLinearToSRGB(e){return this.r=eCe(e.r),this.g=eCe(e.g),this.b=eCe(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=CB){return Ql.fromWorkingColorSpace(YI.copy(this),e),Math.round(Pp(YI.r*255,0,255))*65536+Math.round(Pp(YI.g*255,0,255))*256+Math.round(Pp(YI.b*255,0,255))}getHexString(e=CB){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Ql.workingColorSpace){Ql.fromWorkingColorSpace(YI.copy(this),n);const o=YI.r,i=YI.g,r=YI.b,A=Math.max(o,i,r),s=Math.min(o,i,r);let a,c;const l=(s+A)/2;if(s===A)a=0,c=0;else{const g=A-s;switch(c=l<=.5?g/(A+s):g/(2-A-s),A){case o:a=(i-r)/g+(i<r?6:0);break;case i:a=(r-o)/g+2;break;case r:a=(o-i)/g+4;break}a/=6}return e.h=a,e.s=c,e.l=l,e}getRGB(e,n=Ql.workingColorSpace){return Ql.fromWorkingColorSpace(YI.copy(this),n),e.r=YI.r,e.g=YI.g,e.b=YI.b,e}getStyle(e=CB){Ql.fromWorkingColorSpace(YI.copy(this),e);const n=YI.r,o=YI.g,i=YI.b;return e!==CB?`color(${e} ${n.toFixed(3)} ${o.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(n*255)},${Math.round(o*255)},${Math.round(i*255)})`}offsetHSL(e,n,o){return this.getHSL(nD),this.setHSL(nD.h+e,nD.s+n,nD.l+o)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,n){return this.r=e.r+n.r,this.g=e.g+n.g,this.b=e.b+n.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,n){return this.r+=(e.r-this.r)*n,this.g+=(e.g-this.g)*n,this.b+=(e.b-this.b)*n,this}lerpColors(e,n,o){return this.r=e.r+(n.r-e.r)*o,this.g=e.g+(n.g-e.g)*o,this.b=e.b+(n.b-e.b)*o,this}lerpHSL(e,n){this.getHSL(nD),e.getHSL(YX);const o=TL(nD.h,YX.h,n),i=TL(nD.s,YX.s,n),r=TL(nD.l,YX.l,n);return this.setHSL(o,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,o=this.g,i=this.b,r=e.elements;return this.r=r[0]*n+r[3]*o+r[6]*i,this.g=r[1]*n+r[4]*o+r[7]*i,this.b=r[2]*n+r[5]*o+r[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const YI=new yi;yi.NAMES=ngt;let mLn=0;class $C extends fP{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:mLn++}),this.uuid=fB(),this.name="",this.type="Material",this.blending=M9,this.side=B1,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=kIe,this.blendDst=FIe,this.blendEquation=CP,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new yi(0,0,0),this.blendAlpha=0,this.depthFunc=SX,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Flt,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=H9,this.stencilZFail=H9,this.stencilZPass=H9,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const n in e){const o=e[n];if(o===void 0){console.warn(`THREE.Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){console.warn(`THREE.Material: '${n}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(o):i&&i.isVector3&&o&&o.isVector3?i.copy(o):this[n]=o}}toJSON(e){const n=e===void 0||typeof e=="string";n&&(e={textures:{},images:{}});const o={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};o.uuid=this.uuid,o.type=this.type,this.name!==""&&(o.name=this.name),this.color&&this.color.isColor&&(o.color=this.color.getHex()),this.roughness!==void 0&&(o.roughness=this.roughness),this.metalness!==void 0&&(o.metalness=this.metalness),this.sheen!==void 0&&(o.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(o.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(o.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(o.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(o.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(o.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(o.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(o.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(o.shininess=this.shininess),this.clearcoat!==void 0&&(o.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(o.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(o.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(o.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(o.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,o.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(o.dispersion=this.dispersion),this.iridescence!==void 0&&(o.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(o.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(o.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(o.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(o.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(o.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(o.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(o.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(o.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(o.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(o.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(o.lightMap=this.lightMap.toJSON(e).uuid,o.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(o.aoMap=this.aoMap.toJSON(e).uuid,o.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(o.bumpMap=this.bumpMap.toJSON(e).uuid,o.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(o.normalMap=this.normalMap.toJSON(e).uuid,o.normalMapType=this.normalMapType,o.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(o.displacementMap=this.displacementMap.toJSON(e).uuid,o.displacementScale=this.displacementScale,o.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(o.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(o.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(o.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(o.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(o.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(o.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(o.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(o.combine=this.combine)),this.envMapRotation!==void 0&&(o.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(o.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(o.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(o.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(o.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(o.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(o.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(o.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(o.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(o.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(o.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(o.size=this.size),this.shadowSide!==null&&(o.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(o.sizeAttenuation=this.sizeAttenuation),this.blending!==M9&&(o.blending=this.blending),this.side!==B1&&(o.side=this.side),this.vertexColors===!0&&(o.vertexColors=!0),this.opacity<1&&(o.opacity=this.opacity),this.transparent===!0&&(o.transparent=!0),this.blendSrc!==kIe&&(o.blendSrc=this.blendSrc),this.blendDst!==FIe&&(o.blendDst=this.blendDst),this.blendEquation!==CP&&(o.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(o.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(o.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(o.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(o.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(o.blendAlpha=this.blendAlpha),this.depthFunc!==SX&&(o.depthFunc=this.depthFunc),this.depthTest===!1&&(o.depthTest=this.depthTest),this.depthWrite===!1&&(o.depthWrite=this.depthWrite),this.colorWrite===!1&&(o.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(o.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Flt&&(o.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(o.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(o.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==H9&&(o.stencilFail=this.stencilFail),this.stencilZFail!==H9&&(o.stencilZFail=this.stencilZFail),this.stencilZPass!==H9&&(o.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(o.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(o.rotation=this.rotation),this.polygonOffset===!0&&(o.polygonOffset=!0),this.polygonOffsetFactor!==0&&(o.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(o.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(o.linewidth=this.linewidth),this.dashSize!==void 0&&(o.dashSize=this.dashSize),this.gapSize!==void 0&&(o.gapSize=this.gapSize),this.scale!==void 0&&(o.scale=this.scale),this.dithering===!0&&(o.dithering=!0),this.alphaTest>0&&(o.alphaTest=this.alphaTest),this.alphaHash===!0&&(o.alphaHash=!0),this.alphaToCoverage===!0&&(o.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(o.premultipliedAlpha=!0),this.forceSinglePass===!0&&(o.forceSinglePass=!0),this.wireframe===!0&&(o.wireframe=!0),this.wireframeLinewidth>1&&(o.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(o.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(o.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(o.flatShading=!0),this.visible===!1&&(o.visible=!1),this.toneMapped===!1&&(o.toneMapped=!1),this.fog===!1&&(o.fog=!1),Object.keys(this.userData).length>0&&(o.userData=this.userData);function i(r){const A=[];for(const s in r){const a=r[s];delete a.metadata,A.push(a)}return A}if(n){const r=i(e.textures),A=i(e.images);r.length>0&&(o.textures=r),A.length>0&&(o.images=A)}return o}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const n=e.clippingPlanes;let o=null;if(n!==null){const i=n.length;o=new Array(i);for(let r=0;r!==i;++r)o[r]=n[r].clone()}return this.clippingPlanes=o,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class ZC extends $C{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new yi(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new XC,this.combine=LIe,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const jd=new Rt,VX=new Xi;class Cg{constructor(e,n,o=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=o,this.usage=jIe,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=eQ,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return ZIe("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,o){e*=this.itemSize,o*=n.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=n.array[o+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,o=this.count;n<o;n++)VX.fromBufferAttribute(this,n),VX.applyMatrix3(e),this.setXY(n,VX.x,VX.y);else if(this.itemSize===3)for(let n=0,o=this.count;n<o;n++)jd.fromBufferAttribute(this,n),jd.applyMatrix3(e),this.setXYZ(n,jd.x,jd.y,jd.z);return this}applyMatrix4(e){for(let n=0,o=this.count;n<o;n++)jd.fromBufferAttribute(this,n),jd.applyMatrix4(e),this.setXYZ(n,jd.x,jd.y,jd.z);return this}applyNormalMatrix(e){for(let n=0,o=this.count;n<o;n++)jd.fromBufferAttribute(this,n),jd.applyNormalMatrix(e),this.setXYZ(n,jd.x,jd.y,jd.z);return this}transformDirection(e){for(let n=0,o=this.count;n<o;n++)jd.fromBufferAttribute(this,n),jd.transformDirection(e),this.setXYZ(n,jd.x,jd.y,jd.z);return this}set(e,n=0){return this.array.set(e,n),this}getComponent(e,n){let o=this.array[e*this.itemSize+n];return this.normalized&&(o=yB(o,this.array)),o}setComponent(e,n,o){return this.normalized&&(o=xl(o,this.array)),this.array[e*this.itemSize+n]=o,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=yB(n,this.array)),n}setX(e,n){return this.normalized&&(n=xl(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=yB(n,this.array)),n}setY(e,n){return this.normalized&&(n=xl(n,this.array)),this.array[e*this.itemSize+1]=n,this}getZ(e){let n=this.array[e*this.itemSize+2];return this.normalized&&(n=yB(n,this.array)),n}setZ(e,n){return this.normalized&&(n=xl(n,this.array)),this.array[e*this.itemSize+2]=n,this}getW(e){let n=this.array[e*this.itemSize+3];return this.normalized&&(n=yB(n,this.array)),n}setW(e,n){return this.normalized&&(n=xl(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,o){return e*=this.itemSize,this.normalized&&(n=xl(n,this.array),o=xl(o,this.array)),this.array[e+0]=n,this.array[e+1]=o,this}setXYZ(e,n,o,i){return e*=this.itemSize,this.normalized&&(n=xl(n,this.array),o=xl(o,this.array),i=xl(i,this.array)),this.array[e+0]=n,this.array[e+1]=o,this.array[e+2]=i,this}setXYZW(e,n,o,i,r){return e*=this.itemSize,this.normalized&&(n=xl(n,this.array),o=xl(o,this.array),i=xl(i,this.array),r=xl(r,this.array)),this.array[e+0]=n,this.array[e+1]=o,this.array[e+2]=i,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==jIe&&(e.usage=this.usage),e}}class ogt extends Cg{constructor(e,n,o){super(new Uint16Array(e),n,o)}}class _Ce extends Cg{constructor(e,n,o){super(new Uint32Array(e),n,o)}}class PA extends Cg{constructor(e,n,o){super(new Float32Array(e),n,o)}}let pLn=0;const g2=new wA,mCe=new tl,Z9=new Rt,Hy=new l2,OL=new l2,Tm=new Rt;class bl extends fP{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:pLn++}),this.uuid=fB(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Olt(e)?_Ce:ogt)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,o=0){this.groups.push({start:e,count:n,materialIndex:o})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const o=this.attributes.normal;if(o!==void 0){const r=new Ds().getNormalMatrix(e);o.applyNormalMatrix(r),o.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return g2.makeRotationFromQuaternion(e),this.applyMatrix4(g2),this}rotateX(e){return g2.makeRotationX(e),this.applyMatrix4(g2),this}rotateY(e){return g2.makeRotationY(e),this.applyMatrix4(g2),this}rotateZ(e){return g2.makeRotationZ(e),this.applyMatrix4(g2),this}translate(e,n,o){return g2.makeTranslation(e,n,o),this.applyMatrix4(g2),this}scale(e,n,o){return g2.makeScale(e,n,o),this.applyMatrix4(g2),this}lookAt(e){return mCe.lookAt(e),mCe.updateMatrix(),this.applyMatrix4(mCe.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Z9).negate(),this.translate(Z9.x,Z9.y,Z9.z),this}setFromPoints(e){const n=[];for(let o=0,i=e.length;o<i;o++){const r=e[o];n.push(r.x,r.y,r.z||0)}return this.setAttribute("position",new PA(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new l2);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new Rt(-1/0,-1/0,-1/0),new Rt(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let o=0,i=n.length;o<i;o++){const r=n[o];Hy.setFromBufferAttribute(r),this.morphTargetsRelative?(Tm.addVectors(this.boundingBox.min,Hy.min),this.boundingBox.expandByPoint(Tm),Tm.addVectors(this.boundingBox.max,Hy.max),this.boundingBox.expandByPoint(Tm)):(this.boundingBox.expandByPoint(Hy.min),this.boundingBox.expandByPoint(Hy.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new BB);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new Rt,1/0);return}if(e){const o=this.boundingSphere.center;if(Hy.setFromBufferAttribute(e),n)for(let r=0,A=n.length;r<A;r++){const s=n[r];OL.setFromBufferAttribute(s),this.morphTargetsRelative?(Tm.addVectors(Hy.min,OL.min),Hy.expandByPoint(Tm),Tm.addVectors(Hy.max,OL.max),Hy.expandByPoint(Tm)):(Hy.expandByPoint(OL.min),Hy.expandByPoint(OL.max))}Hy.getCenter(o);let i=0;for(let r=0,A=e.count;r<A;r++)Tm.fromBufferAttribute(e,r),i=Math.max(i,o.distanceToSquared(Tm));if(n)for(let r=0,A=n.length;r<A;r++){const s=n[r],a=this.morphTargetsRelative;for(let c=0,l=s.count;c<l;c++)Tm.fromBufferAttribute(s,c),a&&(Z9.fromBufferAttribute(e,c),Tm.add(Z9)),i=Math.max(i,o.distanceToSquared(Tm))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const o=n.position,i=n.normal,r=n.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Cg(new Float32Array(4*o.count),4));const A=this.getAttribute("tangent"),s=[],a=[];for(let S=0;S<o.count;S++)s[S]=new Rt,a[S]=new Rt;const c=new Rt,l=new Rt,g=new Rt,u=new Xi,d=new Xi,h=new Xi,_=new Rt,p=new Rt;function m(S,M,w){c.fromBufferAttribute(o,S),l.fromBufferAttribute(o,M),g.fromBufferAttribute(o,w),u.fromBufferAttribute(r,S),d.fromBufferAttribute(r,M),h.fromBufferAttribute(r,w),l.sub(c),g.sub(c),d.sub(u),h.sub(u);const k=1/(d.x*h.y-h.x*d.y);isFinite(k)&&(_.copy(l).multiplyScalar(h.y).addScaledVector(g,-d.y).multiplyScalar(k),p.copy(g).multiplyScalar(d.x).addScaledVector(l,-h.x).multiplyScalar(k),s[S].add(_),s[M].add(_),s[w].add(_),a[S].add(p),a[M].add(p),a[w].add(p))}let I=this.groups;I.length===0&&(I=[{start:0,count:e.count}]);for(let S=0,M=I.length;S<M;++S){const w=I[S],k=w.start,N=w.count;for(let G=k,H=k+N;G<H;G+=3)m(e.getX(G+0),e.getX(G+1),e.getX(G+2))}const C=new Rt,f=new Rt,y=new Rt,B=new Rt;function x(S){y.fromBufferAttribute(i,S),B.copy(y);const M=s[S];C.copy(M),C.sub(y.multiplyScalar(y.dot(M))).normalize(),f.crossVectors(B,M);const k=f.dot(a[S])<0?-1:1;A.setXYZW(S,C.x,C.y,C.z,k)}for(let S=0,M=I.length;S<M;++S){const w=I[S],k=w.start,N=w.count;for(let G=k,H=k+N;G<H;G+=3)x(e.getX(G+0)),x(e.getX(G+1)),x(e.getX(G+2))}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let o=this.getAttribute("normal");if(o===void 0)o=new Cg(new Float32Array(n.count*3),3),this.setAttribute("normal",o);else for(let u=0,d=o.count;u<d;u++)o.setXYZ(u,0,0,0);const i=new Rt,r=new Rt,A=new Rt,s=new Rt,a=new Rt,c=new Rt,l=new Rt,g=new Rt;if(e)for(let u=0,d=e.count;u<d;u+=3){const h=e.getX(u+0),_=e.getX(u+1),p=e.getX(u+2);i.fromBufferAttribute(n,h),r.fromBufferAttribute(n,_),A.fromBufferAttribute(n,p),l.subVectors(A,r),g.subVectors(i,r),l.cross(g),s.fromBufferAttribute(o,h),a.fromBufferAttribute(o,_),c.fromBufferAttribute(o,p),s.add(l),a.add(l),c.add(l),o.setXYZ(h,s.x,s.y,s.z),o.setXYZ(_,a.x,a.y,a.z),o.setXYZ(p,c.x,c.y,c.z)}else for(let u=0,d=n.count;u<d;u+=3)i.fromBufferAttribute(n,u+0),r.fromBufferAttribute(n,u+1),A.fromBufferAttribute(n,u+2),l.subVectors(A,r),g.subVectors(i,r),l.cross(g),o.setXYZ(u+0,l.x,l.y,l.z),o.setXYZ(u+1,l.x,l.y,l.z),o.setXYZ(u+2,l.x,l.y,l.z);this.normalizeNormals(),o.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let n=0,o=e.count;n<o;n++)Tm.fromBufferAttribute(e,n),Tm.normalize(),e.setXYZ(n,Tm.x,Tm.y,Tm.z)}toNonIndexed(){function e(s,a){const c=s.array,l=s.itemSize,g=s.normalized,u=new c.constructor(a.length*l);let d=0,h=0;for(let _=0,p=a.length;_<p;_++){s.isInterleavedBufferAttribute?d=a[_]*s.data.stride+s.offset:d=a[_]*l;for(let m=0;m<l;m++)u[h++]=c[d++]}return new Cg(u,l,g)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new bl,o=this.index.array,i=this.attributes;for(const s in i){const a=i[s],c=e(a,o);n.setAttribute(s,c)}const r=this.morphAttributes;for(const s in r){const a=[],c=r[s];for(let l=0,g=c.length;l<g;l++){const u=c[l],d=e(u,o);a.push(d)}n.morphAttributes[s]=a}n.morphTargetsRelative=this.morphTargetsRelative;const A=this.groups;for(let s=0,a=A.length;s<a;s++){const c=A[s];n.addGroup(c.start,c.count,c.materialIndex)}return n}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const a=this.parameters;for(const c in a)a[c]!==void 0&&(e[c]=a[c]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const o=this.attributes;for(const a in o){const c=o[a];e.data.attributes[a]=c.toJSON(e.data)}const i={};let r=!1;for(const a in this.morphAttributes){const c=this.morphAttributes[a],l=[];for(let g=0,u=c.length;g<u;g++){const d=c[g];l.push(d.toJSON(e.data))}l.length>0&&(i[a]=l,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const A=this.groups;A.length>0&&(e.data.groups=JSON.parse(JSON.stringify(A)));const s=this.boundingSphere;return s!==null&&(e.data.boundingSphere={center:s.center.toArray(),radius:s.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const o=e.index;o!==null&&this.setIndex(o.clone(n));const i=e.attributes;for(const c in i){const l=i[c];this.setAttribute(c,l.clone(n))}const r=e.morphAttributes;for(const c in r){const l=[],g=r[c];for(let u=0,d=g.length;u<d;u++)l.push(g[u].clone(n));this.morphAttributes[c]=l}this.morphTargetsRelative=e.morphTargetsRelative;const A=e.groups;for(let c=0,l=A.length;c<l;c++){const g=A[c];this.addGroup(g.start,g.count,g.materialIndex)}const s=e.boundingBox;s!==null&&(this.boundingBox=s.clone());const a=e.boundingSphere;return a!==null&&(this.boundingSphere=a.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const igt=new wA,xP=new J9,zX=new BB,rgt=new Rt,e7=new Rt,t7=new Rt,n7=new Rt,pCe=new Rt,JX=new Rt,qX=new Xi,WX=new Xi,jX=new Xi,Agt=new Rt,sgt=new Rt,agt=new Rt,XX=new Rt,$X=new Rt;class Fr extends tl{constructor(e=new bl,n=new ZC){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,o=Object.keys(n);if(o.length>0){const i=n[o[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,A=i.length;r<A;r++){const s=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[s]=r}}}}getVertexPosition(e,n){const o=this.geometry,i=o.attributes.position,r=o.morphAttributes.position,A=o.morphTargetsRelative;n.fromBufferAttribute(i,e);const s=this.morphTargetInfluences;if(r&&s){JX.set(0,0,0);for(let a=0,c=r.length;a<c;a++){const l=s[a],g=r[a];l!==0&&(pCe.fromBufferAttribute(g,e),A?JX.addScaledVector(pCe,l):JX.addScaledVector(pCe.sub(n),l))}n.add(JX)}return n}raycast(e,n){const o=this.geometry,i=this.material,r=this.matrixWorld;i!==void 0&&(o.boundingSphere===null&&o.computeBoundingSphere(),zX.copy(o.boundingSphere),zX.applyMatrix4(r),xP.copy(e.ray).recast(e.near),!(zX.containsPoint(xP.origin)===!1&&(xP.intersectSphere(zX,rgt)===null||xP.origin.distanceToSquared(rgt)>(e.far-e.near)**2))&&(igt.copy(r).invert(),xP.copy(e.ray).applyMatrix4(igt),!(o.boundingBox!==null&&xP.intersectsBox(o.boundingBox)===!1)&&this._computeIntersections(e,n,xP)))}_computeIntersections(e,n,o){let i;const r=this.geometry,A=this.material,s=r.index,a=r.attributes.position,c=r.attributes.uv,l=r.attributes.uv1,g=r.attributes.normal,u=r.groups,d=r.drawRange;if(s!==null)if(Array.isArray(A))for(let h=0,_=u.length;h<_;h++){const p=u[h],m=A[p.materialIndex],I=Math.max(p.start,d.start),C=Math.min(s.count,Math.min(p.start+p.count,d.start+d.count));for(let f=I,y=C;f<y;f+=3){const B=s.getX(f),x=s.getX(f+1),S=s.getX(f+2);i=ZX(this,m,e,o,c,l,g,B,x,S),i&&(i.faceIndex=Math.floor(f/3),i.face.materialIndex=p.materialIndex,n.push(i))}}else{const h=Math.max(0,d.start),_=Math.min(s.count,d.start+d.count);for(let p=h,m=_;p<m;p+=3){const I=s.getX(p),C=s.getX(p+1),f=s.getX(p+2);i=ZX(this,A,e,o,c,l,g,I,C,f),i&&(i.faceIndex=Math.floor(p/3),n.push(i))}}else if(a!==void 0)if(Array.isArray(A))for(let h=0,_=u.length;h<_;h++){const p=u[h],m=A[p.materialIndex],I=Math.max(p.start,d.start),C=Math.min(a.count,Math.min(p.start+p.count,d.start+d.count));for(let f=I,y=C;f<y;f+=3){const B=f,x=f+1,S=f+2;i=ZX(this,m,e,o,c,l,g,B,x,S),i&&(i.faceIndex=Math.floor(f/3),i.face.materialIndex=p.materialIndex,n.push(i))}}else{const h=Math.max(0,d.start),_=Math.min(a.count,d.start+d.count);for(let p=h,m=_;p<m;p+=3){const I=p,C=p+1,f=p+2;i=ZX(this,A,e,o,c,l,g,I,C,f),i&&(i.faceIndex=Math.floor(p/3),n.push(i))}}}}function ILn(t,e,n,o,i,r,A,s){let a;if(e.side===wp?a=o.intersectTriangle(A,r,i,!0,s):a=o.intersectTriangle(i,r,A,e.side===B1,s),a===null)return null;$X.copy(s),$X.applyMatrix4(t.matrixWorld);const c=n.ray.origin.distanceTo($X);return c<n.near||c>n.far?null:{distance:c,point:$X.clone(),object:t}}function ZX(t,e,n,o,i,r,A,s,a,c){t.getVertexPosition(s,e7),t.getVertexPosition(a,t7),t.getVertexPosition(c,n7);const l=ILn(t,e,n,o,e7,t7,n7,XX);if(l){i&&(qX.fromBufferAttribute(i,s),WX.fromBufferAttribute(i,a),jX.fromBufferAttribute(i,c),l.uv=SB.getInterpolation(XX,e7,t7,n7,qX,WX,jX,new Xi)),r&&(qX.fromBufferAttribute(r,s),WX.fromBufferAttribute(r,a),jX.fromBufferAttribute(r,c),l.uv1=SB.getInterpolation(XX,e7,t7,n7,qX,WX,jX,new Xi)),A&&(Agt.fromBufferAttribute(A,s),sgt.fromBufferAttribute(A,a),agt.fromBufferAttribute(A,c),l.normal=SB.getInterpolation(XX,e7,t7,n7,Agt,sgt,agt,new Rt),l.normal.dot(o.direction)>0&&l.normal.multiplyScalar(-1));const g={a:s,b:a,c,normal:new Rt,materialIndex:0};SB.getNormal(e7,t7,n7,g.normal),l.face=g}return l}class bB extends bl{constructor(e=1,n=1,o=1,i=1,r=1,A=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:o,widthSegments:i,heightSegments:r,depthSegments:A};const s=this;i=Math.floor(i),r=Math.floor(r),A=Math.floor(A);const a=[],c=[],l=[],g=[];let u=0,d=0;h("z","y","x",-1,-1,o,n,e,A,r,0),h("z","y","x",1,-1,o,n,-e,A,r,1),h("x","z","y",1,1,e,o,n,i,A,2),h("x","z","y",1,-1,e,o,-n,i,A,3),h("x","y","z",1,-1,e,n,o,i,r,4),h("x","y","z",-1,-1,e,n,-o,i,r,5),this.setIndex(a),this.setAttribute("position",new PA(c,3)),this.setAttribute("normal",new PA(l,3)),this.setAttribute("uv",new PA(g,2));function h(_,p,m,I,C,f,y,B,x,S,M){const w=f/x,k=y/S,N=f/2,G=y/2,H=B/2,U=x+1,J=S+1;let W=0,X=0;const oe=new Rt;for(let ce=0;ce<J;ce++){const te=ce*k-G;for(let ie=0;ie<U;ie++){const ae=ie*w-N;oe[_]=ae*I,oe[p]=te*C,oe[m]=H,c.push(oe.x,oe.y,oe.z),oe[_]=0,oe[p]=0,oe[m]=B>0?1:-1,l.push(oe.x,oe.y,oe.z),g.push(ie/x),g.push(1-ce/S),W+=1}}for(let ce=0;ce<S;ce++)for(let te=0;te<x;te++){const ie=u+te+U*ce,ae=u+te+U*(ce+1),re=u+(te+1)+U*(ce+1),le=u+(te+1)+U*ce;a.push(ie,ae,le),a.push(ae,re,le),X+=6}s.addGroup(d,X,M),d+=X,u+=W}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new bB(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function o7(t){const e={};for(const n in t){e[n]={};for(const o in t[n]){const i=t[n][o];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][o]=null):e[n][o]=i.clone():Array.isArray(i)?e[n][o]=i.slice():e[n][o]=i}}return e}function ef(t){const e={};for(let n=0;n<t.length;n++){const o=o7(t[n]);for(const i in o)e[i]=o[i]}return e}function CLn(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function cgt(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Ql.workingColorSpace}const lgt={clone:o7,merge:ef};var fLn=`void main() {
|
|
1046
1046
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
1047
1047
|
}`,yLn=`void main() {
|
|
@@ -5783,7 +5783,7 @@ test("${c} should solve problem correctly", () => {
|
|
|
5783
5783
|
// Add more specific assertions based on expected output
|
|
5784
5784
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5785
5785
|
})
|
|
5786
|
-
`,g=new Blob([l],{type:"text/plain"}),u=URL.createObjectURL(g),d=document.createElement("a");d.href=u,d.download=`${c}.test.ts`,d.click(),URL.revokeObjectURL(u)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}o(!1)};return V.jsxs("div",{className:`relative ${e}`,ref:i,children:[V.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>o(!n),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),n&&V.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:A,children:"Download page.tsx"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download test.ts"})]})]})},S3t=t=>t.activeSubSolver?[t,...S3t(t.activeSubSolver)]:[t],t3o=({solver:t})=>{const e=S3t(t);return V.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>V.jsxs("div",{className:"flex items-center",children:[o>0&&V.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),V.jsx(e3o,{solver:n})]},n.constructor.name))})},n3o=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,A]=j.useReducer(_=>!_,!1),s=j.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),e())},c=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),i&&i(t))},l=()=>{r?(s.current&&(clearInterval(s.current),s.current=void 0),A()):(A(),s.current=setInterval(()=>{if(t.solved||t.failed){s.current&&(clearInterval(s.current),s.current=void 0),A(),e(),i&&t.solved&&i(t);return}t.step(),e()},n))},g=()=>{const _=t;if(_.getCurrentPhase&&!t.solved&&!t.failed){const p=_.getCurrentPhase();for(;_.getCurrentPhase()===p&&!t.solved&&!t.failed;)t.step();e()}},u=()=>{if(t.solved||t.failed||r)return;const _=window.prompt("Step until which iteration?",`${t.iterations}`);if(_===null)return;const p=Number(_);if(!Number.isFinite(p)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<p&&!t.solved&&!t.failed;)t.step();e(),t.solved&&i&&i(t)};j.useEffect(()=>()=>{s.current&&clearInterval(s.current)},[]),j.useEffect(()=>{(t.solved||t.failed)&&r&&(s.current&&(clearInterval(s.current),s.current=void 0),A())},[t.solved,t.failed,r]);const d=t.getCurrentPhase!==void 0,h=d?t.getCurrentPhase():null;return V.jsxs("div",{className:"space-y-2 p-2 border-b",children:[V.jsx("div",{className:"flex items-center",children:V.jsx(t3o,{solver:t})}),V.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[V.jsx("button",{onClick:a,disabled:t.solved||t.failed||r,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),V.jsx("button",{onClick:c,disabled:t.solved||t.failed||r,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),V.jsx("button",{onClick:l,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${r?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:r?"Stop":"Animate"}),V.jsx("button",{onClick:u,disabled:t.solved||t.failed||r,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),d&&V.jsx("button",{onClick:g,disabled:t.solved||t.failed||r,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),V.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",V.jsx("span",{className:"font-medium",children:h})]}),t.solved&&V.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&V.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&V.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},o3o=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},i3o=(t,e)=>{const o=t.pipelineDef[e].solverName,i=o3o(t,e),r=t[o],A=t.firstIterationOfPhase?.[o]??null,s=t.iterations;let a=0;if(i==="Completed"){const u=t.pipelineDef[e+1],d=u?t.firstIterationOfPhase?.[u.solverName]:void 0;d!==void 0&&A!==null?a=d-A:A!==null&&(a=s-A)}else i==="In Progress"&&A!==null&&(a=s-A);const c=t.timeSpentOnPhase?.[o]??0;let l=0;i==="Completed"?l=1:i==="In Progress"&&r&&(l=r.progress??0);const g=r?.stats??null;return{index:e,name:o,status:i,firstIteration:A,iterations:a,progress:l,timeSpent:c,stats:g&&Object.keys(g).length>0?g:null,solverInstance:r??null}},r3o=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return V.jsx("span",{className:`font-medium ${e[t]}`,children:t})},A3o=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:V.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),V.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},s3o=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),a3o=({stats:t})=>{if(!t||Object.keys(t).length===0)return V.jsx("span",{children:"-"});const e=Object.entries(t),n=s3o(t);return V.jsxs("details",{className:"cursor-pointer",children:[V.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),V.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>V.jsxs("div",{children:[o,": ",String(i)]},o))})]})},TMe=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(TMe);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=TMe(o));return e},c3o=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=TMe(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),i=URL.createObjectURL(o),r=document.createElement("a");r.href=i,r.download=`${e}_input.json`,r.click(),URL.revokeObjectURL(i)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},l3o=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((s,a)=>i3o(t,a)),i=s=>{e?.(s)},r=s=>{s.solverInstance&&(n?n(s.solverInstance,s.name):c3o(s.solverInstance,s.name))},A=s=>`${(s/1e3).toFixed(2)}s`;return V.jsxs("div",{className:"border-t border-gray-200",children:[V.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:V.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),V.jsx("div",{className:"overflow-x-auto",children:V.jsxs("table",{className:"w-full text-sm",children:[V.jsx("thead",{children:V.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),V.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",V.jsx("sub",{children:"0"})]}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),V.jsx("tbody",{children:o.map(s=>V.jsxs("tr",{className:`border-b border-gray-100 ${s.status==="In Progress"?"bg-yellow-50":""}`,children:[V.jsx("td",{className:"px-4 py-2",children:V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("span",{className:"text-gray-400 w-6",children:String(s.index+1).padStart(2,"0")}),V.jsx("button",{onClick:()=>i(s.name),disabled:s.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${s.name} completes`,children:V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),V.jsx("span",{className:"font-medium text-gray-900",children:s.name})]})}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(r3o,{status:s.status})}),V.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:s.firstIteration!==null?s.firstIteration:""}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:s.iterations}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(A3o,{progress:s.progress})}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:A(s.timeSpent)}),V.jsx("td",{className:"px-4 py-2 text-gray-500",children:V.jsx(a3o,{stats:s.stats})}),V.jsx("td",{className:"px-4 py-2",children:s.solverInstance?V.jsxs("button",{onClick:()=>r(s),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${s.name}`,children:[V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),V.jsx("span",{children:"Input"})]}):null})]},s.name))})]})})]})},g3o=class extends Jr.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function u3o({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],i=t.circles??[],r=t.texts??[];let A=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY;const l=(p,m)=>{typeof p=="number"&&(p<A&&(A=p),p>a&&(a=p)),typeof m=="number"&&(m<s&&(s=m),m>c&&(c=m))};for(const p of e)l(p.x,p.y);for(const p of n){const m=p.points??[];for(const I of m)l(I.x,I.y)}for(const p of o){const m=p.x??0,I=p.y??0,C=p.width??0,f=p.height??0;l(m,I),l(m+C,I+f)}for(const p of i){const m=p.x??0,I=p.y??0,C=p.radius??1;l(m-C,I-C),l(m+C,I+C)}for(const p of r)l(p.x,p.y);(!isFinite(A)||!isFinite(s)||!isFinite(a)||!isFinite(c))&&(A=-20,s=-20,a=20,c=20);const g=10,u=A-g,d=s-g,h=Math.max(1,a-A+2*g),_=Math.max(1,c-s+2*g);return V.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${u} ${d} ${h} ${_}`,role:"img","aria-label":"Graphics fallback",children:[o.map((p,m)=>V.jsx("rect",{x:p.x??0,y:p.y??0,width:p.width??0,height:p.height??0,fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1},`rect-${m}`)),n.map((p,m)=>V.jsx("polyline",{fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1,points:(p.points??[]).map(I=>`${I.x??0},${I.y??0}`).join(" ")},`line-${m}`)),i.map((p,m)=>V.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.fillColor??"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1},`circle-${m}`)),e.map((p,m)=>V.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.color??"black"},`point-${m}`)),r.map((p,m)=>V.jsx("text",{x:p.x??0,y:p.y??0,fontSize:p.fontSize??10,fill:p.color??"black",children:p.text??""},`text-${m}`))]})}var h3o=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[i,r]=j.useReducer(l=>l+1,0),A=j.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(l){return console.error("Visualization error:",l),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),s=j.useMemo(()=>(A.rects?.length||0)===0&&(A.lines?.length||0)===0&&(A.points?.length||0)===0&&(A.circles?.length||0)===0,[A]);j.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const l=document.createElement("script");l.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(l)}},[]);const a=t.pipelineDef!==void 0,c=l=>{const g=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&g.currentPipelineStepIndex<=g.pipelineDef.findIndex(u=>u.solverName===l);)t.step();r()}};return V.jsxs("div",{children:[V.jsx(n3o,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),s?V.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):V.jsx(g3o,{fallback:V.jsx(u3o,{graphics:A}),children:V.jsx(ZPo,{graphics:A})}),a&&V.jsx(l3o,{solver:t,onStepUntilPhase:c})]})};const d3o=()=>{j.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const n=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),n)return;const o=document.createElement("script");o.id=t,o.src="https://cdn.tailwindcss.com",document.head.appendChild(o)},[])},_3o=1e3,MQ=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,i=t instanceof Blob?t:new Blob([t],{type:o}),r=URL.createObjectURL(i),A=document.createElement("a");A.href=r,A.download=n,A.target="_blank",A.rel="noopener noreferrer",A.style.display="none",document.body.appendChild(A),A.click(),document.body.removeChild(A),setTimeout(()=>{URL.revokeObjectURL(r)},_3o)},b3t=t=>{let e=t.trim().replace(/[\\/:*?"<>|]/g,"_").replace(/[\x00-\x1f]/g,"").replace(/^\.+/,"").replace(/\.+$/,"").replace(/\s+/g," ").replace(/_+/g,"_");return/^(con|prn|aux|nul|com[0-9]|lpt[0-9])$/i.test(e)&&(e=`_${e}`),e=e.slice(0,200),e||"untitled"},wQ="https://github.com/tscircuit/tscircuit-autorouter/issues/new",D3t="https://github.com/tscircuit/copper-pour-solver/issues/new",M3t="https://github.com/tscircuit/calculate-packing/issues/new",w3t="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",m3o={PackSolver2:M3t,AutoroutingPipelineSolver:wQ,AssignableAutoroutingPipeline2:wQ,AssignableAutoroutingPipeline3:wQ,AutoroutingPipeline1_OriginalUnravel:wQ,AutoroutingPipelineSolver3_HgPortPointPathing:wQ,AutoroutingPipelineSolver4:wQ,AutoroutingPipelineSolver5:wQ,AutoroutingPipelineSolver7_MultiGraph:wQ,AutoroutingPipelineSolver8:wQ,CopperPourPipelineSolver:D3t,SchematicTracePipelineSolver:w3t},p3o=t=>t.toLowerCase().includes("pack")?JIo:t.toLowerCase().includes("rout")?ZIo:RIo,P3t=t=>{const e=m3o[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?wQ:n.includes("schematic")&&n.includes("trace")?w3t:n.includes("copperpour")?D3t:n.includes("pack")?M3t:null},I3o=t=>`${b3t(`${t.componentName}-${t.solverName}`)}-solver-input.json`,v3t=t=>{MQ(JSON.stringify(t.solverParams,null,2),{fileName:I3o(t),mimeType:"application/json"})},C3o=({solverEvent:t})=>{const e=P3t(t.solverName);return V.jsxs("div",{className:"rf-flex rf-items-center rf-justify-end rf-gap-2 rf-border-b rf-border-gray-200 rf-bg-gray-50 rf-px-4 rf-py-2",children:[V.jsxs(Vs,{type:"button",variant:"outline",size:"sm",onClick:()=>v3t(t),children:[V.jsx(j4e,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?V.jsx(Vs,{asChild:!0,variant:"outline",size:"sm",children:V.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[V.jsx(pee,{className:"rf-w-4 rf-h-4"}),"Report"]})}):V.jsxs(Vs,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[V.jsx(pee,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},f3o=({solverEvent:t})=>{const e=P3t(t.solverName);return e?V.jsx(Vs,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:V.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:V.jsx(pee,{className:"rf-w-4 rf-h-4"})})}):V.jsx(Vs,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",disabled:!0,title:"No report link configured for this solver","aria-label":"Report solver bug",children:V.jsx(pee,{className:"rf-w-4 rf-h-4"})})},y3o=({solverEvents:t=[]})=>{const[e,n]=j.useState(null);d3o();const o=j.useMemo(()=>{const s=new Map;for(const a of t){const c=`${a.componentName}-${a.solverName}`;s.set(c,a)}return s},[t]),i=j.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,A=j.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const s=_me[r.solverName];if(!s)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(_me).join(", ")}`,classFound:!1};try{const a=r.solverParams,c=a?.input!==void 0?a.input:a;return{instance:new s(c),error:null,classFound:!0}}catch(a){const c=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${c}`,classFound:!0}}},[r]);return t.length===0?V.jsx("div",{className:"rf-p-4",children:V.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:V.jsxs("div",{className:"rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),V.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):V.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[V.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[V.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[i.length," ",i.length===1?"Solver":"Solvers"]}),i.map(s=>{const a=o.get(s),c=e===s;return V.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${c?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(s),children:(()=>{const l=p3o(a.solverName);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[V.jsx(l,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),V.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},s)})]}),V.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?A.instance?V.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[V.jsx(C3o,{solverEvent:r}),V.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:V.jsx(y2,{fallback:V.jsx("div",{className:"rf-p-4",children:V.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),V.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:V.jsx(h3o,{solver:A.instance})})})]}):V.jsxs("div",{className:"rf-p-4",children:[V.jsxs("div",{className:"rf-mb-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),V.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),A.error&&V.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${A.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:V.jsx("p",{className:`rf-text-sm ${A.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:A.error})}),V.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[V.jsxs("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50 rf-flex rf-items-center rf-justify-between rf-gap-2",children:[V.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[V.jsx(f3o,{solverEvent:r}),V.jsx(Vs,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8","aria-label":"Download solver input JSON",title:"Download solver input JSON",onClick:()=>v3t(r),children:V.jsx(j4e,{className:"rf-w-4 rf-h-4"})})]})]}),V.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:V.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(r.solverParams,null,2)})})]})]}):V.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},N3t=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{j.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{b9.captureException(o)}catch{}}},[t,e]),j.useEffect(()=>{if(n&&n.length>0)for(const o of n){const i=new Error(o.message||"Circuit JSON Error");o.stack&&(i.stack=o.stack);try{b9.captureException(i,{error_type:o.type})}catch{}}},[n])},R3t=t=>{j.useEffect(()=>{try{Rkn(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},T3t="0.0.2212",E3o={version:T3t},ene=sAt()(aAt(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{t({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),B3o=t=>{const[e,n]=j.useState([]),[o,i]=j.useState(null),[r,A]=j.useState(""),[s,a]=r9("eval-version-selection",null),c=ene(d=>d.setLastRunEvalVersion),l=ene(d=>d.lastRunEvalVersion);return j.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(d=>d.json()).then(d=>{if(Array.isArray(d?.versions)){let h=[...d.versions];d.tags?.latest&&(i(d.tags.latest),h=h.filter(_=>_!==d.tags.latest)),n(h)}}).catch(()=>{})},[t]),j.useEffect(()=>{t&&(s?(window.TSCIRCUIT_LATEST_EVAL_VERSION=s,c(s)):o&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=o,c(o)))},[t,s,o]),{versions:j.useMemo(()=>e.filter(d=>d.includes(r)).slice(0,50),[e,r]),latestVersion:o,lastRunEvalVersion:l,search:r,setSearch:A,selectVersion:d=>{a(d),A("")}}},x3o=({snippetNames:t,onSelect:e,onCancel:n,isOpen:o})=>{const[i,r]=j.useState(""),[A,s]=j.useState("");if(!o)return null;const a=t.filter(g=>g.toLowerCase().includes(A.toLowerCase())),c=A&&!t.includes(A),l=g=>{g.key==="Enter"&&(a.length===1?r(a[0]):c&&r(A))};return V.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:V.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[V.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),V.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:A,onChange:g=>s(g.target.value),onKeyDown:l}),V.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[a.map(g=>V.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${i===g?"bg-blue-50":""}`,onClick:()=>r(g),children:g},g)),c&&V.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${i===A?"bg-blue-50":""}`,onClick:()=>r(A),children:['Create new "',A,'"']})]}),V.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[V.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:n,children:"Cancel"}),V.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>i&&e(i),disabled:!i,children:i===A?`Create "${i}"`:`Save to ${i}`})]})]})})},Q3o=t=>{const e=j.useRef(null),n=M0(o=>o.recentEvents);j.useEffect(()=>{if(n.length===0)return;const o=n[0];o.event_id!==e.current&&(t(o),e.current=o.event_id)},[n,t])};var tne="Dialog",[k3t,F3t]=_B(tne),[S3o,OB]=k3t(tne),nne=t=>{const{__scopeDialog:e,children:n,open:o,defaultOpen:i,onOpenChange:r,modal:A=!0}=t,s=j.useRef(null),a=j.useRef(null),[c,l]=Lb({prop:o,defaultProp:i??!1,onChange:r,caller:tne});return V.jsx(S3o,{scope:e,triggerRef:s,contentRef:a,contentId:bp(),titleId:bp(),descriptionId:bp(),open:c,onOpenChange:l,onOpenToggle:j.useCallback(()=>l(g=>!g),[l]),modal:A,children:n})};nne.displayName=tne;var L3t="DialogTrigger",H3t=j.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=OB(L3t,n),r=mg(e,i.triggerRef);return V.jsx(Us.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":LMe(i.open),...o,ref:r,onClick:wr(t.onClick,i.onOpenToggle)})});H3t.displayName=L3t;var kMe="DialogPortal",[b3o,G3t]=k3t(kMe,{forceMount:void 0}),one=t=>{const{__scopeDialog:e,forceMount:n,children:o,container:i}=t,r=OB(kMe,e);return V.jsx(b3o,{scope:e,forceMount:n,children:j.Children.map(o,A=>V.jsx(Ry,{present:n||r.open,children:V.jsx(Nee,{asChild:!0,container:i,children:A})}))})};one.displayName=kMe;var ine="DialogOverlay",lO=j.forwardRef((t,e)=>{const n=G3t(ine,t.__scopeDialog),{forceMount:o=n.forceMount,...i}=t,r=OB(ine,t.__scopeDialog);return r.modal?V.jsx(Ry,{present:o||r.open,children:V.jsx(M3o,{...i,ref:e})}):null});lO.displayName=ine;var D3o=iP("DialogOverlay.RemoveScroll"),M3o=j.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=OB(ine,n),r=dCo(),A=mg(e,r);return V.jsx(Oee,{as:D3o,allowPinchZoom:!0,shards:[i.contentRef],children:V.jsx(Us.div,{"data-state":LMe(i.open),...o,ref:A,style:{pointerEvents:"auto",...o.style}})})}),wN="DialogContent",gO=j.forwardRef((t,e)=>{const n=G3t(wN,t.__scopeDialog),{forceMount:o=n.forceMount,...i}=t,r=OB(wN,t.__scopeDialog);return V.jsx(Ry,{present:o||r.open,children:r.modal?V.jsx(w3o,{...i,ref:e}):V.jsx(P3o,{...i,ref:e})})});gO.displayName=wN;var w3o=j.forwardRef((t,e)=>{const n=OB(wN,t.__scopeDialog),o=j.useRef(null),i=mg(e,n.contentRef,o);return j.useEffect(()=>{const r=o.current;if(r)return fbe(r)},[]),V.jsx(O3t,{...t,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:wr(t.onCloseAutoFocus,r=>{r.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:wr(t.onPointerDownOutside,r=>{const A=r.detail.originalEvent,s=A.button===0&&A.ctrlKey===!0;(A.button===2||s)&&r.preventDefault()}),onFocusOutside:wr(t.onFocusOutside,r=>r.preventDefault())})}),P3o=j.forwardRef((t,e)=>{const n=OB(wN,t.__scopeDialog),o=j.useRef(!1),i=j.useRef(!1);return V.jsx(O3t,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:r=>{t.onCloseAutoFocus?.(r),r.defaultPrevented||(o.current||n.triggerRef.current?.focus(),r.preventDefault()),o.current=!1,i.current=!1},onInteractOutside:r=>{t.onInteractOutside?.(r),r.defaultPrevented||(o.current=!0,r.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const A=r.target;n.triggerRef.current?.contains(A)&&r.preventDefault(),r.detail.originalEvent.type==="focusin"&&i.current&&r.preventDefault()}})}),O3t=j.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:i,onCloseAutoFocus:r,...A}=t,s=OB(wN,n);return ebe(),V.jsx(V.Fragment,{children:V.jsx(Cee,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:i,onUnmountAutoFocus:r,children:V.jsx(IG,{role:"dialog",id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":LMe(s.open),...A,ref:e,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})}),K3t="DialogTitle",rne=j.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=OB(K3t,n);return V.jsx(Us.h2,{id:i.titleId,...o,ref:e})});rne.displayName=K3t;var U3t="DialogDescription",Ane=j.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=OB(U3t,n);return V.jsx(Us.p,{id:i.descriptionId,...o,ref:e})});Ane.displayName=U3t;var Y3t="DialogClose",FMe=j.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=OB(Y3t,n);return V.jsx(Us.button,{type:"button",...o,ref:e,onClick:wr(t.onClick,()=>i.onOpenChange(!1))})});FMe.displayName=Y3t;function LMe(t){return t?"open":"closed"}var V3t="AlertDialog",[v3o]=_B(V3t,[F3t]),B5=F3t(),z3t=t=>{const{__scopeAlertDialog:e,...n}=t,o=B5(e);return V.jsx(nne,{...o,...n,modal:!0})};z3t.displayName=V3t;var N3o="AlertDialogTrigger",R3o=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=B5(n);return V.jsx(H3t,{...i,...o,ref:e})});R3o.displayName=N3o;var T3o="AlertDialogPortal",J3t=t=>{const{__scopeAlertDialog:e,...n}=t,o=B5(e);return V.jsx(one,{...o,...n})};J3t.displayName=T3o;var k3o="AlertDialogOverlay",q3t=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=B5(n);return V.jsx(lO,{...i,...o,ref:e})});q3t.displayName=k3o;var W3t="AlertDialogContent",[F3o,L3o]=v3o(W3t),j3t=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,children:o,...i}=t,r=B5(n),A=j.useRef(null),s=mg(e,A),a=j.useRef(null);return V.jsx(F3o,{scope:n,cancelRef:a,children:V.jsx(gO,{role:"alertdialog",...r,...i,ref:s,onOpenAutoFocus:wr(i.onOpenAutoFocus,c=>{c.preventDefault(),a.current?.focus({preventScroll:!0})}),onPointerDownOutside:c=>c.preventDefault(),onInteractOutside:c=>c.preventDefault(),children:o})})});j3t.displayName=W3t;var H3o="AlertDialogTitle",X3t=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=B5(n);return V.jsx(rne,{...i,...o,ref:e})});X3t.displayName=H3o;var G3o="AlertDialogDescription",$3t=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=B5(n);return V.jsx(Ane,{...i,...o,ref:e})});$3t.displayName=G3o;var O3o="AlertDialogAction",Z3t=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=B5(n);return V.jsx(FMe,{...i,...o,ref:e})});Z3t.displayName=O3o;var evt="AlertDialogCancel",tvt=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,{cancelRef:i}=L3o(evt,n),r=B5(n),A=mg(e,i);return V.jsx(FMe,{...r,...o,ref:A})});tvt.displayName=evt;var K3o=z3t,U3o=J3t,nvt=q3t,ovt=j3t,ivt=Z3t,rvt=tvt,Avt=X3t,svt=$3t;const avt=K3o,Y3o=U3o,cvt=j.forwardRef(({className:t,...e},n)=>V.jsx(nvt,{className:Ui("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",t),...e,ref:n}));cvt.displayName=nvt.displayName;const HMe=j.forwardRef(({className:t,...e},n)=>V.jsxs(Y3o,{children:[V.jsx(cvt,{}),V.jsx(ovt,{ref:n,className:Ui("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",t),...e})]}));HMe.displayName=ovt.displayName;const GMe=({className:t,...e})=>V.jsx("div",{className:Ui("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});GMe.displayName="AlertDialogHeader";const OMe=({className:t,...e})=>V.jsx("div",{className:Ui("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});OMe.displayName="AlertDialogFooter";const KMe=j.forwardRef(({className:t,...e},n)=>V.jsx(Avt,{ref:n,className:Ui("rf-text-lg rf-font-semibold",t),...e}));KMe.displayName=Avt.displayName;const UMe=j.forwardRef(({className:t,...e},n)=>V.jsx(svt,{ref:n,className:Ui("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));UMe.displayName=svt.displayName;const V3o=j.forwardRef(({className:t,...e},n)=>V.jsx(ivt,{ref:n,className:Ui($7(),t),...e}));V3o.displayName=ivt.displayName;const YMe=j.forwardRef(({className:t,...e},n)=>V.jsx(rvt,{ref:n,className:Ui($7({variant:"outline"}),"rf-mt-2 sm:rf-mt-0",t),...e}));YMe.displayName=rvt.displayName;function z3o(t){const e=j.useRef({value:t,previous:t});return j.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var sne="Checkbox",[J3o]=_B(sne),[q3o,VMe]=J3o(sne);function W3o(t){const{__scopeCheckbox:e,checked:n,children:o,defaultChecked:i,disabled:r,form:A,name:s,onCheckedChange:a,required:c,value:l="on",internal_do_not_use_render:g}=t,[u,d]=Lb({prop:n,defaultProp:i??!1,onChange:a,caller:sne}),[h,_]=j.useState(null),[p,m]=j.useState(null),I=j.useRef(!1),C=h?!!A||!!h.closest("form"):!0,f={checked:u,disabled:r,setChecked:d,control:h,setControl:_,name:s,form:A,value:l,hasConsumerStoppedPropagationRef:I,required:c,defaultChecked:YD(i)?!1:i,isFormControl:C,bubbleInput:p,setBubbleInput:m};return V.jsx(q3o,{scope:e,...f,children:j3o(g)?g(f):o})}var lvt="CheckboxTrigger",gvt=j.forwardRef(({__scopeCheckbox:t,onKeyDown:e,onClick:n,...o},i)=>{const{control:r,value:A,disabled:s,checked:a,required:c,setControl:l,setChecked:g,hasConsumerStoppedPropagationRef:u,isFormControl:d,bubbleInput:h}=VMe(lvt,t),_=mg(i,l),p=j.useRef(a);return j.useEffect(()=>{const m=r?.form;if(m){const I=()=>g(p.current);return m.addEventListener("reset",I),()=>m.removeEventListener("reset",I)}},[r,g]),V.jsx(Us.button,{type:"button",role:"checkbox","aria-checked":YD(a)?"mixed":a,"aria-required":c,"data-state":mvt(a),"data-disabled":s?"":void 0,disabled:s,value:A,...o,ref:_,onKeyDown:wr(e,m=>{m.key==="Enter"&&m.preventDefault()}),onClick:wr(n,m=>{g(I=>YD(I)?!0:!I),h&&d&&(u.current=m.isPropagationStopped(),u.current||m.stopPropagation())})})});gvt.displayName=lvt;var zMe=j.forwardRef((t,e)=>{const{__scopeCheckbox:n,name:o,checked:i,defaultChecked:r,required:A,disabled:s,value:a,onCheckedChange:c,form:l,...g}=t;return V.jsx(W3o,{__scopeCheckbox:n,checked:i,defaultChecked:r,disabled:s,required:A,onCheckedChange:c,name:o,form:l,value:a,internal_do_not_use_render:({isFormControl:u})=>V.jsxs(V.Fragment,{children:[V.jsx(gvt,{...g,ref:e,__scopeCheckbox:n}),u&&V.jsx(_vt,{__scopeCheckbox:n})]})})});zMe.displayName=sne;var uvt="CheckboxIndicator",hvt=j.forwardRef((t,e)=>{const{__scopeCheckbox:n,forceMount:o,...i}=t,r=VMe(uvt,n);return V.jsx(Ry,{present:o||YD(r.checked)||r.checked===!0,children:V.jsx(Us.span,{"data-state":mvt(r.checked),"data-disabled":r.disabled?"":void 0,...i,ref:e,style:{pointerEvents:"none",...t.style}})})});hvt.displayName=uvt;var dvt="CheckboxBubbleInput",_vt=j.forwardRef(({__scopeCheckbox:t,...e},n)=>{const{control:o,hasConsumerStoppedPropagationRef:i,checked:r,defaultChecked:A,required:s,disabled:a,name:c,value:l,form:g,bubbleInput:u,setBubbleInput:d}=VMe(dvt,t),h=mg(n,d),_=z3o(r),p=rSt(o);j.useEffect(()=>{const I=u;if(!I)return;const C=window.HTMLInputElement.prototype,y=Object.getOwnPropertyDescriptor(C,"checked").set,B=!i.current;if(_!==r&&y){const x=new Event("click",{bubbles:B});I.indeterminate=YD(r),y.call(I,YD(r)?!1:r),I.dispatchEvent(x)}},[u,_,r,i]);const m=j.useRef(YD(r)?!1:r);return V.jsx(Us.input,{type:"checkbox","aria-hidden":!0,defaultChecked:A??m.current,required:s,disabled:a,name:c,value:l,form:g,...e,tabIndex:-1,ref:h,style:{...e.style,...p,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});_vt.displayName=dvt;function j3o(t){return typeof t=="function"}function YD(t){return t==="indeterminate"}function mvt(t){return YD(t)?"indeterminate":t?"checked":"unchecked"}const uO=j.forwardRef(({className:t,...e},n)=>V.jsx(zMe,{ref:n,className:Ui("rf-peer rf-h-4 rf-w-4 rf-shrink-0 rf-rounded-sm rf-border rf-border-zinc-200 rf-border-zinc-900 rf-shadow focus-visible:rf-outline-none focus-visible:rf-ring-1 focus-visible:rf-ring-zinc-950 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 data-[state=checked]:rf-bg-zinc-900 data-[state=checked]:rf-text-zinc-50 dark:rf-border-zinc-800 dark:rf-border-zinc-50 dark:focus-visible:rf-ring-zinc-300 dark:data-[state=checked]:rf-bg-zinc-50 dark:data-[state=checked]:rf-text-zinc-900",t),...e,children:V.jsx(hvt,{className:Ui("rf-flex rf-items-center rf-justify-center rf-text-current"),children:V.jsx(r3,{className:"rf-h-4 rf-w-4"})})}));uO.displayName=zMe.displayName;const PN=nne,X3o=one,pvt=j.forwardRef(({className:t,...e},n)=>V.jsx(lO,{className:Ui("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",t),...e,ref:n}));pvt.displayName=lO.displayName;const f3=j.forwardRef(({className:t,children:e,showOverlay:n=!0,...o},i)=>V.jsxs(X3o,{children:[V.jsx(pvt,{className:Ui(n?"":"rf-hidden")}),V.jsx(gO,{ref:i,className:Ui("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",t),...o,children:e})]}));f3.displayName=gO.displayName;const y3=({className:t,...e})=>V.jsx("div",{className:Ui("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});y3.displayName="DialogHeader";const hO=({className:t,...e})=>V.jsx("div",{className:Ui("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});hO.displayName="DialogFooter";const E3=j.forwardRef(({className:t,...e},n)=>V.jsx(rne,{ref:n,className:Ui("rf-text-lg rf-font-semibold",t),...e}));E3.displayName=rne.displayName;const vN=j.forwardRef(({className:t,...e},n)=>V.jsx(Ane,{ref:n,className:Ui("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));vN.displayName=Ane.displayName;const ane={"tscircuit.com":{label:"tscircuit.com",placeholder:"Search tscircuit packages...",emptyMessage:"No packages found"},jlcpcb:{label:"JLCPCB Parts",placeholder:"Search JLCPCB parts (e.g. C14663)...",emptyMessage:"No parts found"},kicad:{label:"KiCad Footprints",placeholder:"Search KiCad footprints...",emptyMessage:"No footprints found"}},$3o="https://cdn.jsdelivr.net/npm/easyeda@latest/dist/browser/index.js";let JMe=null;const qMe=async()=>(JMe||(JMe=import($3o)),JMe),Z3o=t=>(e,n)=>{const o=new Headers(n?.headers),i={};return o.forEach((r,A)=>{i[A]=r}),fetch(`${t?.apiBase??zC}/proxy`,{...n,headers:{...i,"X-Target-Url":e.toString(),"X-Sender-Origin":i.origin??"","X-Sender-Host":i.host??"https://easyeda.com","X-Sender-Referer":i.referer??"","X-Sender-User-Agent":i["user-agent"]??"","X-Sender-Cookie":i.cookie??"",authority:i.authority??"","content-type":i["content-type"]??"",...t?.headers}})},evo=async(t,e=10)=>{const n=encodeURIComponent(t),o=await fetch(`https://jlcsearch.tscircuit.com/api/search?limit=${e}&q=${n}`);if(!o.ok)throw new Error(`JLCPCB API error: ${o.status}`);return(await o.json()).components??[]},tvo=t=>({lcscId:t.lcsc,manufacturer:t.mfr,description:t.description,partNumber:`C${t.lcsc}`,package:t.package,price:t.price,stock:t.stock,isBasic:t.is_basic}),Ivt=async(t,e)=>{const{fetchEasyEDAComponent:n}=await qMe();return n(t,{fetch:Z3o(e),includeModelMetadata:e?.includeModelMetadata})},nvo=async(t,e)=>{const{convertRawEasyToTsx:n}=await qMe(),o=await Ivt(t,e);return n({rawEasy:o})},ovo=async(t,e)=>{const{EasyEdaJsonSchema:n,convertEasyEdaJsonToCircuitJson:o}=await qMe(),i=await Ivt(t,{...e,includeModelMetadata:!1}),r=n.parse(i);return o(r,{shouldRecenter:!0,showDesignator:!0,useModelCdn:!1})};function VD(t){return Array.isArray?Array.isArray(t):fvt(t)==="[object Array]"}function ivo(t){if(typeof t=="string")return t;if(typeof t=="bigint")return t.toString();const e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function WMe(t){return t==null?"":ivo(t)}function ZI(t){return typeof t=="string"}function cne(t){return typeof t=="number"}function rvo(t){return t===!0||t===!1||Avo(t)&&fvt(t)=="[object Boolean]"}function Cvt(t){return typeof t=="object"}function Avo(t){return Cvt(t)&&t!==null}function eE(t){return t!=null}function lne(t){return!t.trim().length}function fvt(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const svo="Incorrect 'index' type",jMe="Invalid doc index: must be a non-negative integer within the bounds of the docs array",avo=t=>`Invalid value for key ${t}`,cvo=t=>`Pattern length exceeds max of ${t}.`,lvo=t=>`Missing ${t} property in key`,gvo=t=>`Property 'weight' in key '${t}' must be a positive integer`,uvo="Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.",yvt=Object.prototype.hasOwnProperty;var hvo=class{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(n=>{const o=Evt(n);this._keys.push(o),this._keyMap[o.id]=o,e+=o.weight}),this._keys.forEach(n=>{n.weight/=e})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function Evt(t){let e=null,n=null,o=null,i=1,r=null;if(ZI(t)||VD(t))o=t,e=Bvt(t),n=gne(t);else{if(!yvt.call(t,"name"))throw new Error(lvo("name"));const A=t.name;if(o=A,yvt.call(t,"weight")&&t.weight!==void 0&&(i=t.weight,i<=0))throw new Error(gvo(gne(A)));e=Bvt(A),n=gne(A),r=t.getFn??null}return{path:e,id:n,weight:i,src:o,getFn:r}}function Bvt(t){return VD(t)?t:t.split(".")}function gne(t){return VD(t)?t.join("."):t}function dvo(t,e){const n=[];let o=!1;const i=(r,A,s,a)=>{if(eE(r))if(!A[s])n.push(a!==void 0?{v:r,i:a}:r);else{const c=r[A[s]];if(!eE(c))return;if(s===A.length-1&&(ZI(c)||cne(c)||rvo(c)||typeof c=="bigint"))n.push(a!==void 0?{v:WMe(c),i:a}:WMe(c));else if(VD(c)){o=!0;for(let l=0,g=c.length;l<g;l+=1)i(c[l],A,s+1,l)}else A.length&&i(c,A,s+1,a)}};return i(t,ZI(e)?e.split("."):e,0),o?n:n[0]}const bA=Object.freeze({...{isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1},...{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},...{location:0,threshold:.6,distance:100},...{useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:dvo,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}});function _vo(t){return t>=9&&t<=13||t===32||t===160}function mvo(t=1,e=3){const n=new Map,o=Math.pow(10,e);return{get(i){let r=0,A=!1;for(let a=0;a<i.length;a++)_vo(i.charCodeAt(a))?A=!1:A||(r++,A=!0);if(r===0&&(r=1),n.has(r))return n.get(r);const s=Math.round(o/Math.pow(r,.5*t))/o;return n.set(r,s),s},clear(){n.clear()}}}var XMe=class{constructor({getFn:t=bA.getFn,fieldNormWeight:e=bA.fieldNormWeight}={}){this.norm=mvo(e,3),this.getFn=t,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((e,n)=>{this._keysMap[e.id]=n})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;const t=this.docs.length;this.records=new Array(t);let e=0;if(ZI(this.docs[0]))for(let n=0;n<t;n++){const o=this._createStringRecord(this.docs[n],n);o&&(this.records[e++]=o)}else for(let n=0;n<t;n++)this.records[e++]=this._createObjectRecord(this.docs[n],n);this.records.length=e,this.norm.clear()}add(t,e){if(!Number.isInteger(e)||e<0)throw new Error(jMe);if(ZI(t)){const o=this._createStringRecord(t,e);return o&&this.records.push(o),o}const n=this._createObjectRecord(t,e);return this.records.push(n),n}removeAt(t){if(!Number.isInteger(t)||t<0)throw new Error(jMe);for(let e=0,n=this.records.length;e<n;e+=1)if(this.records[e].i===t){this.records.splice(e,1);break}for(let e=0,n=this.records.length;e<n;e+=1)this.records[e].i>t&&(this.records[e].i-=1)}removeAll(t){const e=new Set;for(const o of t)Number.isInteger(o)&&o>=0&&e.add(o);if(e.size===0)return;this.records=this.records.filter(o=>!e.has(o.i));const n=Array.from(e).sort((o,i)=>o-i);for(const o of this.records){let i=0,r=n.length;for(;i<r;){const A=i+r>>>1;n[A]<o.i?i=A+1:r=A}o.i-=i}}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_createStringRecord(t,e){return!eE(t)||lne(t)?null:{v:t,i:e,n:this.norm.get(t)}}_createObjectRecord(t,e){const n={i:e,$:{}};for(let o=0,i=this.keys.length;o<i;o++){const r=this.keys[o],A=r.getFn?r.getFn(t):this.getFn(t,r.path);if(eE(A)){if(VD(A)){const s=[];for(let a=0,c=A.length;a<c;a+=1){const l=A[a];if(eE(l)){if(ZI(l)){if(!lne(l)){const g={v:l,i:a,n:this.norm.get(l)};s.push(g)}}else if(eE(l.v)){const g=ZI(l.v)?l.v:WMe(l.v);if(!lne(g)){const u={v:g,i:l.i,n:this.norm.get(g)};s.push(u)}}}}n.$[o]=s}else if(ZI(A)&&!lne(A)){const s={v:A,n:this.norm.get(A)};n.$[o]=s}}}return n}toJSON(){return{keys:this.keys.map(({getFn:t,...e})=>e),records:this.records}}};function xvt(t,e,{getFn:n=bA.getFn,fieldNormWeight:o=bA.fieldNormWeight}={}){const i=new XMe({getFn:n,fieldNormWeight:o});return i.setKeys(t.map(Evt)),i.setSources(e),i.create(),i}function pvo(t,{getFn:e=bA.getFn,fieldNormWeight:n=bA.fieldNormWeight}={}){const{keys:o,records:i}=t,r=new XMe({getFn:e,fieldNormWeight:n});return r.setKeys(o),r.setIndexRecords(i),r}function Ivo(t=[],e=bA.minMatchCharLength){const n=[];let o=-1,i=-1,r=0;for(let A=t.length;r<A;r+=1){const s=t[r];s&&o===-1?o=r:!s&&o!==-1&&(i=r-1,i-o+1>=e&&n.push([o,i]),o=-1)}return t[r-1]&&r-o>=e&&n.push([o,r-1]),n}function Cvo(t,e,n,{location:o=bA.location,distance:i=bA.distance,threshold:r=bA.threshold,findAllMatches:A=bA.findAllMatches,minMatchCharLength:s=bA.minMatchCharLength,includeMatches:a=bA.includeMatches,ignoreLocation:c=bA.ignoreLocation}={}){if(e.length>32)throw new Error(cvo(32));const l=e.length,g=t.length,u=Math.max(0,Math.min(o,g));let d=r,h=u;const _=(M,w)=>{const k=M/l;if(c)return k;const N=Math.abs(u-w);return i?k+N/i:N?1:k},p=s>1||a,m=p?Array(g):[];let I;for(;(I=t.indexOf(e,h))>-1;){const M=_(0,I);if(d=Math.min(M,d),h=I+l,p){let w=0;for(;w<l;)m[I+w]=1,w+=1}}h=-1;let C=[],f=1,y=0,B=l+g;const x=1<<l-1;for(let M=0;M<l;M+=1){let w=0,k=B;for(;w<k;)_(M,u+k)<=d?w=k:B=k,k=Math.floor((B-w)/2+w);B=k;let N=Math.max(1,u-k+1);const G=A?g:Math.min(u+k,g)+l,H=Array(G+2);H[G+1]=(1<<M)-1;for(let U=G;U>=N;U-=1){const J=U-1,W=n[t[J]];if(H[U]=(H[U+1]<<1|1)&W,M&&(H[U]|=(C[U+1]|C[U])<<1|1|C[U+1]),H[U]&x&&(f=_(M,J),f<=d)){if(d=f,h=J,y=M,h<=u)break;N=Math.max(1,2*u-h)}}if(_(M+1,u)>d)break;C=H}if(p&&h>=0){const M=Math.min(g-1,h+l-1+y);for(let w=h;w<=M;w+=1)n[t[w]]&&(m[w]=1)}const S={isMatch:h>=0,score:Math.max(.001,f)};if(p){const M=Ivo(m,s);M.length?a&&(S.indices=M):S.isMatch=!1}return S}function fvo(t){const e={};for(let n=0,o=t.length;n<o;n+=1){const i=t.charAt(n);e[i]=(e[i]||0)|1<<o-n-1}return e}function $Me(t){if(t.length<=1)return t;t.sort((n,o)=>n[0]-o[0]||n[1]-o[1]);const e=[t[0]];for(let n=1,o=t.length;n<o;n+=1){const i=e[e.length-1],r=t[n];r[0]<=i[1]+1?i[1]=Math.max(i[1],r[1]):e.push(r)}return e}const Qvt={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},yvo=new RegExp("["+Object.keys(Qvt).join("")+"]","g"),dO=typeof String.prototype.normalize=="function"?t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"").replace(yvo,e=>Qvt[e]):t=>t;var ZMe=class{constructor(t,{location:e=bA.location,threshold:n=bA.threshold,distance:o=bA.distance,includeMatches:i=bA.includeMatches,findAllMatches:r=bA.findAllMatches,minMatchCharLength:A=bA.minMatchCharLength,isCaseSensitive:s=bA.isCaseSensitive,ignoreDiacritics:a=bA.ignoreDiacritics,ignoreLocation:c=bA.ignoreLocation}={}){if(this.options={location:e,threshold:n,distance:o,includeMatches:i,findAllMatches:r,minMatchCharLength:A,isCaseSensitive:s,ignoreDiacritics:a,ignoreLocation:c},t=s?t:t.toLowerCase(),t=a?dO(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const l=(u,d)=>{this.chunks.push({pattern:u,alphabet:fvo(u),startIndex:d})},g=this.pattern.length;if(g>32){let u=0;const d=g%32,h=g-d;for(;u<h;)l(this.pattern.substr(u,32),u),u+=32;if(d){const _=g-32;l(this.pattern.substr(_),_)}}else l(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o}=this.options;if(t=e?t:t.toLowerCase(),t=n?dO(t):t,this.pattern===t){if(t.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};const h={isMatch:!0,score:0};return o&&(h.indices=[[0,t.length-1]]),h}const{location:i,distance:r,threshold:A,findAllMatches:s,minMatchCharLength:a,ignoreLocation:c}=this.options,l=[];let g=0,u=!1;this.chunks.forEach(({pattern:h,alphabet:_,startIndex:p})=>{const{isMatch:m,score:I,indices:C}=Cvo(t,h,_,{location:i+p,distance:r,threshold:A,findAllMatches:s,minMatchCharLength:a,includeMatches:o,ignoreLocation:c});m&&(u=!0),g+=I,m&&C&&l.push(...C)});const d={isMatch:u,score:u?g/this.chunks.length:1};return u&&o&&(d.indices=$Me(l)),d}};const Evo=new Set(["fuzzy","include"]);function Bvo(t){return t.startsWith("inverse")}const ewe=[{type:"exact",multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:t=>({type:"exact",search(e){const n=e===t;return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"include",multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:t=>({type:"include",search(e){let n=0,o;const i=[],r=t.length;for(;(o=e.indexOf(t,n))>-1;)n=o+r,i.push([o,n-1]);const A=!!i.length;return{isMatch:A,score:A?0:1,indices:i}}})},{type:"prefix-exact",multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:t=>({type:"prefix-exact",search(e){const n=e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"inverse-prefix-exact",multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:t=>({type:"inverse-prefix-exact",search(e){const n=!e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"inverse-suffix-exact",multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:t=>({type:"inverse-suffix-exact",search(e){const n=!e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"suffix-exact",multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:t=>({type:"suffix-exact",search(e){const n=e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[e.length-t.length,e.length-1]}}})},{type:"inverse-exact",multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:t=>({type:"inverse-exact",search(e){const n=e.indexOf(t)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"fuzzy",multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(t,e={})=>{const n=new ZMe(t,{location:e.location??bA.location,threshold:e.threshold??bA.threshold,distance:e.distance??bA.distance,includeMatches:e.includeMatches??bA.includeMatches,findAllMatches:e.findAllMatches??bA.findAllMatches,minMatchCharLength:e.minMatchCharLength??bA.minMatchCharLength,isCaseSensitive:e.isCaseSensitive??bA.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics??bA.ignoreDiacritics,ignoreLocation:e.ignoreLocation??bA.ignoreLocation});return{type:"fuzzy",search(o){return n.searchIn(o)}}}}],Svt=ewe.length,xvo="\0",Qvo="|";function Svo(t){const e=[],n=t.length;let o=0;for(;o<n;){for(;o<n&&t[o]===" ";)o++;if(o>=n)break;let i=o;for(;i<n&&t[i]!==" "&&t[i]!=='"';)i++;if(i<n&&t[i]==='"'){for(i++;i<n;){if(t[i]==='"'){const r=i+1;if(r>=n||t[r]===" "){i++;break}if(t[r]==="$"&&(r+1>=n||t[r+1]===" ")){i+=2;break}}i++}e.push(t.substring(o,i)),o=i}else{for(;i<n&&t[i]!==" ";)i++;e.push(t.substring(o,i)),o=i}}return e}function bvt(t,e){const n=t.match(e);return n?n[1]:null}function bvo(t,e={}){return t.replace(/\\\|/g,xvo).split(Qvo).map(n=>{const o=Svo(n.replace(/\u0000/g,"|").trim()).filter(r=>r&&!!r.trim()),i=[];for(let r=0,A=o.length;r<A;r+=1){const s=o[r];let a=!1,c=-1;for(;!a&&++c<Svt;){const l=ewe[c],g=bvt(s,l.multiRegex);g&&(i.push(l.create(g,e)),a=!0)}if(!a)for(c=-1;++c<Svt;){const l=ewe[c],g=bvt(s,l.singleRegex);if(g){i.push(l.create(g,e));break}}}return i})}var Dvo=class{constructor(t,{isCaseSensitive:e=bA.isCaseSensitive,ignoreDiacritics:n=bA.ignoreDiacritics,includeMatches:o=bA.includeMatches,minMatchCharLength:i=bA.minMatchCharLength,ignoreLocation:r=bA.ignoreLocation,findAllMatches:A=bA.findAllMatches,location:s=bA.location,threshold:a=bA.threshold,distance:c=bA.distance}={}){this.query=null,this.options={isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o,minMatchCharLength:i,findAllMatches:A,ignoreLocation:r,location:s,threshold:a,distance:c},t=e?t:t.toLowerCase(),t=n?dO(t):t,this.pattern=t,this.query=bvo(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:o,ignoreDiacritics:i}=this.options;t=o?t:t.toLowerCase(),t=i?dO(t):t;let r=0;const A=[];let s=0,a=!1;for(let c=0,l=e.length;c<l;c+=1){const g=e[c];A.length=0,r=0,a=!1;for(let u=0,d=g.length;u<d;u+=1){const h=g[u],{isMatch:_,indices:p,score:m}=h.search(t);if(_)r+=1,s+=m,Bvo(h.type)&&(a=!0),n&&(Evo.has(h.type)?A.push(...p):A.push(p));else{s=0,r=0,A.length=0,a=!1;break}}if(r){const u={isMatch:!0,score:s/r};return a&&(u.hasInverse=!0),n&&(u.indices=$Me(A)),u}}return{isMatch:!1,score:1}}};const twe=[];function nwe(...t){twe.push(...t)}function une(t,e){for(let n=0,o=twe.length;n<o;n+=1){const i=twe[n];if(i.condition(t,e))return new i(t,e)}return new ZMe(t,e)}const hne={AND:"$and",OR:"$or"},owe={PATH:"$path",PATTERN:"$val"},iwe=t=>!!(t[hne.AND]||t[hne.OR]),Mvo=t=>!!t[owe.PATH],wvo=t=>!VD(t)&&Cvt(t)&&!iwe(t),Dvt=t=>({[hne.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function Mvt(t,e,{auto:n=!0}={}){const o=i=>{if(ZI(i)){const a={keyId:null,pattern:i};return n&&(a.searcher=une(i,e)),a}const r=Object.keys(i),A=Mvo(i);if(!A&&r.length>1&&!iwe(i))return o(Dvt(i));if(wvo(i)){const a=A?i[owe.PATH]:r[0],c=A?i[owe.PATTERN]:i[a];if(!ZI(c))throw new Error(avo(a));const l={keyId:gne(a),pattern:c};return n&&(l.searcher=une(c,e)),l}const s={children:[],operator:r[0]};return r.forEach(a=>{const c=i[a];VD(c)&&c.forEach(l=>{s.children.push(o(l))})}),s};return iwe(t)||(t=Dvt(t)),o(t)}function rwe(t,{ignoreFieldNorm:e=bA.ignoreFieldNorm}){let n=1;return t.forEach(({key:o,norm:i,score:r})=>{const A=o?o.weight:null;n*=Math.pow(r===0&&A?Number.EPSILON:r,(A||1)*(e?1:i))}),n}function Pvo(t,{ignoreFieldNorm:e=bA.ignoreFieldNorm}){t.forEach(n=>{n.score=rwe(n.matches,{ignoreFieldNorm:e})})}var vvo=class{constructor(t,e){this.limit=t,this.heap=[],this.comparator=e}get size(){return this.heap.length}insert(t){this.size<this.limit?(this.heap.push(t),this._bubbleUp(this.size-1)):this.comparator(t,this.heap[0])<0&&(this.heap[0]=t,this._sinkDown(0))}extractSorted(){return this.heap.sort(this.comparator)}_bubbleUp(t){const e=this.heap;for(;t>0;){const n=t-1>>1;if(this.comparator(e[t],e[n])<=0)break;const o=e[t];e[t]=e[n],e[n]=o,t=n}}_sinkDown(t){const e=this.heap,n=e.length;let o=t;do{t=o;const i=2*t+1,r=2*t+2;if(i<n&&this.comparator(e[i],e[o])>0&&(o=i),r<n&&this.comparator(e[r],e[o])>0&&(o=r),o!==t){const A=e[t];e[t]=e[o],e[o]=A}}while(o!==t)}};function Nvo(t){const e=[];return t.matches.forEach(n=>{if(!eE(n.indices)||!n.indices.length)return;const o={indices:n.indices,value:n.value};n.key&&(o.key=n.key.id),n.idx>-1&&(o.refIndex=n.idx),e.push(o)}),e}function Rvo(t,e,{includeMatches:n=bA.includeMatches,includeScore:o=bA.includeScore}={}){return t.map(i=>{const{idx:r}=i,A={item:e[r],refIndex:r};return n&&(A.matches=Nvo(i)),o&&(A.score=i.score),A})}const Tvo=/[\p{L}\p{M}\p{N}_]+/gu,wvt=new WeakSet;function kvo(t){wvt.has(t)||(wvt.add(t),console.warn(`[Fuse] tokenize regex ${t} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`))}function Fvo(t){if(typeof t=="function"){let e=!1;return n=>{const o=t(n);if(!e&&(e=!0,!Array.isArray(o)||o.some(i=>typeof i!="string")))throw new Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(o)?"array containing non-strings":typeof o}.`);return o}}return t instanceof RegExp?(t.global||kvo(t),e=>e.match(t)||[]):e=>e.match(Tvo)||[]}function Awe({isCaseSensitive:t=!1,ignoreDiacritics:e=!1,tokenize:n}={}){const o=Fvo(n);return{tokenize(i){return t||(i=i.toLowerCase()),e&&(i=dO(i)),o(i)}}}var Lvo=class{static condition(t,e){return e.useTokenSearch}constructor(t,e){this.options=e,this.analyzer=Awe({isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,tokenize:e.tokenize});const n=this.analyzer.tokenize(t),{df:o,fieldCount:i}=e._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(const r of n){this.termSearchers.push(new ZMe(r,{location:e.location,threshold:e.threshold,distance:e.distance,includeMatches:e.includeMatches,findAllMatches:e.findAllMatches,minMatchCharLength:e.minMatchCharLength,isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,ignoreLocation:!0}));const A=o.get(r)||0,s=Math.log(1+(i-A+.5)/(A+.5));this.idfWeights.push(s)}this.combineAll=e.tokenMatch==="all",this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(t){if(!this.termSearchers.length)return{isMatch:!1,score:1};const e=[];let n=0,o=0,i=0,r=0;const A=this.combineAll&&!this.useMask?new Set:null;for(let c=0;c<this.termSearchers.length;c++){const l=this.termSearchers[c].searchIn(t),g=this.idfWeights[c];o+=g,l.isMatch&&(i++,n+=g*(1-l.score),l.indices&&e.push(...l.indices),this.combineAll&&(this.useMask?r|=1<<c:A.add(c)))}if(i===0)return{isMatch:!1,score:1};const s=o>0?1-n/o:0,a={isMatch:!0,score:Math.max(.001,s)};return this.options.includeMatches&&e.length&&(a.indices=$Me(e)),this.combineAll&&(this.useMask?a.matchedMask=r:a.matchedTerms=A,a.termCount=this.numTerms),a}};function swe(t,e,n,o){const i=o.tokenize(e);if(!i.length)return;t.fieldCount++,t.docFieldCount.set(n,(t.docFieldCount.get(n)||0)+1);const r=new Set(i);let A=t.docTermFieldHits.get(n);A||(A=new Map,t.docTermFieldHits.set(n,A));for(const s of r)A.set(s,(A.get(s)||0)+1),t.df.set(s,(t.df.get(s)||0)+1)}function Pvt(t,e,n,o){const{i,v:r,$:A}=e;if(r!==void 0){swe(t,r,i,o);return}if(A)for(let s=0;s<n;s++){const a=A[s];if(a)if(Array.isArray(a))for(const c of a)swe(t,c.v,i,o);else swe(t,a.v,i,o)}}function Hvo(t,e,n){const o={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const i of t)Pvt(o,i,e,n);return o}function Gvo(t,e,n,o){Pvt(t,e,n,o)}function Ovo(t,e){const n=t.docFieldCount.get(e);if(n===void 0)return;t.fieldCount-=n,t.docFieldCount.delete(e);const o=t.docTermFieldHits.get(e);if(o){for(const[i,r]of o){const A=(t.df.get(i)||0)-r;A<=0?t.df.delete(i):t.df.set(i,A)}t.docTermFieldHits.delete(e)}}function vvt(t,e){if(e.length===0)return;const n=Array.from(new Set(e)).sort((s,a)=>s-a);for(const s of n)Ovo(t,s);const o=s=>{let a=0,c=n.length;for(;a<c;){const l=a+c>>>1;n[l]<s?a=l+1:c=l}return s-a},i=n[0],r=new Map;for(const[s,a]of t.docFieldCount)r.set(s>i?o(s):s,a);t.docFieldCount=r;const A=new Map;for(const[s,a]of t.docTermFieldHits)A.set(s>i?o(s):s,a);t.docTermFieldHits=A}var zD=class{constructor(t,e,n){this.options={...bA,...e},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new hvo(this.options.keys),this._docs=t,this._myIndex=null,this._invertedIndex=null,this.setCollection(t,n),this._lastQuery=null,this._lastSearcher=null}_getSearcher(t){if(this._lastQuery===t)return this._lastSearcher;const e=une(t,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=t,this._lastSearcher=e,e}setCollection(t,e){if(this._docs=t,e&&!(e instanceof XMe))throw new Error(svo);if(this._myIndex=e||xvt(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const n=Awe({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=Hvo(this._myIndex.records,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}add(t){if(!eE(t))return;this._docs.push(t);const e=this._myIndex.add(t,this._docs.length-1);if(this._invertedIndex&&e){const n=Awe({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});Gvo(this._invertedIndex,e,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}remove(t=()=>!1){const e=[],n=[];for(let o=0,i=this._docs.length;o<i;o+=1)t(this._docs[o],o)&&(e.push(this._docs[o]),n.push(o));if(n.length){this._invertedIndex&&vvt(this._invertedIndex,n);const o=new Set(n);this._docs=this._docs.filter((i,r)=>!o.has(r)),this._myIndex.removeAll(n),this._invalidateSearcherCache()}return e}removeAt(t){if(!Number.isInteger(t)||t<0||t>=this._docs.length)throw new Error(jMe);this._invertedIndex&&vvt(this._invertedIndex,[t]);const e=this._docs.splice(t,1)[0];return this._myIndex.removeAt(t),this._invalidateSearcherCache(),e}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}_normalizedKeys(){return this._myIndex.keys.map(t=>this._keyStore.get(t.id)||t)}search(t,e){const{limit:n=-1}=e||{},{includeMatches:o,includeScore:i,shouldSort:r,sortFn:A,ignoreFieldNorm:s}=this.options;if(ZI(t)&&!t.trim()){let u=this._docs.map((d,h)=>({item:d,refIndex:h}));return cne(n)&&n>-1&&(u=u.slice(0,n)),u}const a=r&&cne(n)&&n>0&&ZI(t),c=A,l=(u,d)=>c(u,d)||u.idx-d.idx;let g;if(a){const u=new vvo(n,l);ZI(this._docs[0])?this._searchStringList(t,{heap:u,ignoreFieldNorm:s}):this._searchObjectList(t,{heap:u,ignoreFieldNorm:s}),g=u.extractSorted()}else g=ZI(t)?ZI(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t),Pvo(g,{ignoreFieldNorm:s}),r&&g.sort(ZI(t)?l:c),cne(n)&&n>-1&&(g=g.slice(0,n));return Rvo(g,this._docs,{includeMatches:o,includeScore:i})}_searchStringList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:r}=this._myIndex,A=e?null:[];return r.forEach(({v:s,i:a,n:c})=>{if(!eE(s))return;const l=o.searchIn(s);if(l.isMatch){const g={score:l.score,value:s,norm:c,indices:l.indices};i&&(g.matchedMask=l.matchedMask,g.matchedTerms=l.matchedTerms,g.termCount=l.termCount);const u=[g];if(!i||this._coversAllTokens(u)){const d={item:s,idx:a,matches:u};e?(d.score=rwe(d.matches,{ignoreFieldNorm:n}),e.insert(d)):A.push(d)}}}),A}_searchLogical(t){const e=Mvt(t,this.options),n=this._normalizedKeys(),o=(s,a,c)=>{if(!("children"in s)){const{keyId:d,searcher:h}=s;let _;return d===null?(_=[],n.forEach((p,m)=>{_.push(...this._findMatches({key:p,value:a[m],searcher:h}))})):_=this._findMatches({key:this._keyStore.get(d),value:this._myIndex.getValueForItemAtKeyId(a,d),searcher:h}),_&&_.length?[{idx:c,item:a,matches:_}]:[]}const{children:l,operator:g}=s,u=[];for(let d=0,h=l.length;d<h;d+=1){const _=l[d],p=o(_,a,c);if(p.length)u.push(...p);else if(g===hne.AND)return[]}return u},i=this._myIndex.records,r=new Map,A=[];return i.forEach(({$:s,i:a})=>{if(eE(s)){const c=o(e,s,a);c.length&&(r.has(a)||(r.set(a,{idx:a,item:s,matches:[]}),A.push(r.get(a))),c.forEach(({matches:l})=>{r.get(a).matches.push(...l)}))}}),A}_searchObjectList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:r}=this._myIndex,A=this._normalizedKeys(),s=e?null:[];return r.forEach(({$:a,i:c})=>{if(!eE(a))return;const l=[];let g=!1,u=!1;if(A.forEach((d,h)=>{const _=this._findMatches({key:d,value:a[h],searcher:o});_.length?(l.push(..._),_[0].hasInverse&&(u=!0)):g=!0}),!(u&&g)&&l.length&&(!i||this._coversAllTokens(l))){const d={idx:c,item:a,matches:l};e?(d.score=rwe(d.matches,{ignoreFieldNorm:n}),e.insert(d)):s.push(d)}}),s}_findMatches({key:t,value:e,searcher:n}){if(!eE(e))return[];const o=[];if(VD(e))e.forEach(({v:i,i:r,n:A})=>{if(!eE(i))return;const s=n.searchIn(i);if(s.isMatch){const a={score:s.score,key:t,value:i,idx:r,norm:A,indices:s.indices,hasInverse:s.hasInverse};s.termCount!==void 0&&(a.matchedMask=s.matchedMask,a.matchedTerms=s.matchedTerms,a.termCount=s.termCount),o.push(a)}});else{const{v:i,n:r}=e,A=n.searchIn(i);if(A.isMatch){const s={score:A.score,key:t,value:i,norm:r,indices:A.indices,hasInverse:A.hasInverse};A.termCount!==void 0&&(s.matchedMask=A.matchedMask,s.matchedTerms=A.matchedTerms,s.termCount=A.termCount),o.push(s)}}return o}_coversAllTokens(t){const e=t.length?t[0].termCount:void 0;if(e===void 0)return!0;if(e<=31){let o=0;for(let i=0;i<t.length;i++)o|=t[i].matchedMask||0;return o===2**e-1}const n=new Set;for(let o=0;o<t.length;o++){const i=t[o].matchedTerms;if(i)for(const r of i)n.add(r)}return n.size===e}};zD.version="7.5.0",zD.createIndex=xvt,zD.parseIndex=pvo,zD.config=bA,zD.match=function(t,e,n){if(n&&n.useTokenSearch)throw new Error(uvo);return une(t,{...bA,...n}).searchIn(e)},zD.parseQuery=Mvt,nwe(Dvo),nwe(Lvo),zD.use=function(...t){t.forEach(e=>nwe(e))};var Kvo=zD;const Uvo="https://kicad-mod-cache.tscircuit.com";let awe=null,_O=null,cwe=null;const Yvo=async()=>awe||_O||(_O=fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then(t=>t.json()).then(t=>(awe=t,_O=null,t)),_O),Vvo=async(t,e=20)=>{const n=await Yvo();return cwe||(cwe=new Kvo(n)),cwe.search(t).slice(0,e).map(o=>o.item)},zvo=t=>{const e=t.replace(".pretty/","/").replace(".kicad_mod",""),n=`kicad:${e}`;return{path:t,qualifiedName:n,description:e}},Jvo=t=>t.replace(/^\/+/,"").split("/").map(e=>encodeURIComponent(e)).join("/"),qvo=async t=>{const e=await fetch(`${Uvo}/${Jvo(t)}`);if(!e.ok)throw new Error(`KiCad footprint fetch failed: ${e.status}`);const n=await e.text(),{KicadFootprintToCircuitJsonConverter:o}=await FB("kicad-to-circuit-json"),i=new o;return i.addFile(t.split("/").pop()??"selected-footprint.kicad_mod",n),i.runUntilFinished(),i.getOutput()},Nvt=t=>t?.source==="jlcpcb"||t?.source==="kicad",Wvo=async(t,e)=>{if(t.source==="jlcpcb")return ovo(t.component.partNumber,e?.jlcpcb);if(t.source==="kicad")return qvo(t.footprint.path);throw new Error("Footprint preview is not available for this source")},jvo=({query:t,placeholder:e,isSearching:n,onQueryChange:o,onSubmit:i})=>{const r=j.useCallback(A=>{A.key==="Enter"&&(A.preventDefault(),i())},[i]);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mt-4",children:[V.jsxs("div",{className:"rf-relative rf-flex-grow",children:[V.jsx(X4e,{className:"rf-absolute rf-left-2 rf-top-2.5 rf-h-4 rf-w-4 rf-text-muted-foreground"}),V.jsx(dDe,{placeholder:e,className:"rf-pl-8",spellCheck:!1,autoComplete:"off",value:t,onChange:A=>o(A.target.value),onKeyDown:r})]}),V.jsx(Vs,{onClick:i,disabled:n||t.trim().length<1,className:"sm:rf-px-4 rf-px-3",children:n?V.jsx(RB,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):V.jsxs(V.Fragment,{children:[V.jsx(X4e,{className:"rf-h-4 rf-w-4 sm:rf-hidden"}),V.jsx("span",{className:"rf-hidden sm:rf-inline",children:"Search"})]})})]})},Xvo=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),$vo=t=>Xvo.format(t),Rvt=t=>{switch(t.source){case"tscircuit.com":{const e=t.package;return`tscircuit-${e.package_id??`${e.org_owner_tscircuit_handle??"unknown"}-${e.unscoped_name??e.name??"package"}`}`}case"jlcpcb":return`jlc-${t.component.lcscId}`;case"kicad":return`kicad-${t.footprint.path}`;default:return"unknown"}},Zvo=t=>{switch(t.source){case"tscircuit.com":return t.package.unscoped_name;case"jlcpcb":return t.component.manufacturer;case"kicad":return t.footprint.qualifiedName}},e6o=t=>{switch(t.source){case"tscircuit.com":return t.package.description||(t.package.org_owner_tscircuit_handle?`Component by ${t.package.org_owner_tscircuit_handle}`:void 0);case"jlcpcb":return t.component.description;case"kicad":return t.footprint.description}},t6o=t=>{switch(t.source){case"tscircuit.com":return t.package.name;case"jlcpcb":return t.component.partNumber;case"kicad":return}},n6o=({results:t,selected:e,onSelect:n,onShowDetails:o})=>{const i=e?Rvt(e):null;return V.jsx("div",{className:"rf-divide-y rf-w-full rf-overflow-hidden",children:t.map(r=>{const A=Rvt(r),s=i===A,a=Zvo(r),c=e6o(r),l=t6o(r),g=r.source==="jlcpcb"?r.component.stock:null,u=r.source==="jlcpcb"?r.component.price:null,d=r.source==="jlcpcb"?r.component.isBasic:null;return V.jsxs("div",{className:`rf-p-3 rf-flex rf-flex-col sm:rf-grid sm:rf-grid-cols-[minmax(0,1fr)_auto] rf-items-start sm:rf-items-center rf-cursor-pointer hover:rf-bg-zinc-100 rf-gap-2 rf-overflow-hidden ${s?"rf-bg-zinc-100":""}`,onClick:()=>n(r),children:[V.jsxs("div",{className:"rf-min-w-0 rf-overflow-hidden rf-w-full",children:[V.jsxs("div",{className:"rf-flex rf-items-start rf-gap-2 rf-min-w-0",children:[V.jsxs("div",{className:"rf-font-medium rf-text-sm rf-truncate rf-flex-1 rf-min-w-0 rf-flex rf-items-center rf-gap-1.5",children:[a,r.source==="jlcpcb"&&d!=null&&V.jsx("span",{className:`rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 ${d?"rf-bg-green-100 rf-text-green-700":"rf-bg-orange-100 rf-text-orange-700"}`,children:d?"Basic":"Extended"}),r.source==="tscircuit.com"&&r.package.is_private&&V.jsx(WIo,{className:"rf-ml-1 rf-h-3 rf-w-3 rf-text-zinc-400 rf-flex-shrink-0"})]}),r.source==="jlcpcb"&&g!=null?V.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 sm:rf-hidden",children:[g.toLocaleString()," in stock"]}):null]}),V.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-truncate rf-w-full",children:[l?V.jsx("span",{className:"rf-mr-2",children:l}):null,c]})]}),V.jsxs("div",{children:[r.source==="tscircuit.com"&&o?V.jsx("div",{className:"rf-flex-shrink-0 rf-w-full sm:rf-w-auto",children:V.jsx(Vs,{variant:"outline",size:"sm",className:"rf-text-xs rf-w-full sm:rf-w-auto",onClick:h=>{h.stopPropagation(),o(r)},children:"See Details"})}):r.source==="jlcpcb"&&g!=null?V.jsxs("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0",children:[g.toLocaleString()," in stock"]}):null,u!=null&&V.jsx("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 rf-text-right",children:$vo(u)})]})]},A)})})},o6o=({circuitJson:t,error:e,isLoading:n,height:o})=>V.jsx("section",{className:"rf-flex rf-min-w-0 rf-items-center rf-justify-center",style:{height:o},children:n?V.jsxs("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-gap-2 rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:[V.jsx(RB,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Loading preview..."]}):e?V.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-p-4",style:{height:o},children:V.jsxs("div",{className:"rf-flex rf-max-w-[320px] rf-items-start rf-gap-2 rf-text-sm rf-text-zinc-300",children:[V.jsx(QQt,{className:"rf-mt-0.5 rf-h-4 rf-w-4 rf-flex-shrink-0"}),V.jsx("span",{children:e})]})}):t?V.jsx("div",{className:"rf-w-full rf-min-w-0 rf-overflow-hidden",children:V.jsx(B3t,{circuitJson:t,height:o,allowEditing:!1,clickToInteractEnabled:!1,focusOnHover:!1,disablePcbGroups:!0})}):V.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:"No preview"})}),Tvt={importComponentDialog:101,importComponentDetailsDialog:102},i6o=({packageResult:t,isOpen:e,onOpenChange:n,isLoading:o,details:i,previewTab:r,onPreviewTabChange:A,isSubmitting:s,onImport:a})=>{const c=t?.package??null,l=c?.latest_pcb_preview_image_url,g=c?.latest_sch_preview_image_url,u=c?.latest_cad_preview_image_url,d=c?.unscoped_name?.split("/").pop()??c?.unscoped_name,h=c?.org_owner_tscircuit_handle??void 0,_=h?`https://tscircuit.com/${h}`:void 0,p=h&&d?`https://tscircuit.com/${h}/${d}`:void 0;return V.jsx(PN,{open:e,onOpenChange:n,children:V.jsxs(f3,{showOverlay:!1,style:{width:"calc(100vw - 2rem)",zIndex:Tvt.importComponentDetailsDialog},className:"rf-max-w-5xl no-scrollbar !rf-overflow-y-auto rf-max-h-[90vh] rf-overflow-hidden rf-flex rf-flex-col rf-rounded-sm",children:[V.jsx(y3,{className:"rf-pb-4 rf-border-b",children:V.jsx("div",{className:"rf-flex rf-items-start rf-justify-between rf-gap-4",children:V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx(E3,{className:"rf-text-xl rf-font-semibold rf-truncate",children:d}),V.jsx(vN,{children:c?.description})]})})}),V.jsxs("div",{className:"rf-flex-1 rf-overflow-y-auto rf-py-4 rf-space-y-6",children:[h?V.jsxs("div",{children:[V.jsx("span",{className:"rf-text-xs rf-font-medium rf-text-gray-500 rf-uppercase rf-tracking-wide",children:"Created by"}),V.jsx("div",{className:"rf-mt-1 rf-text-sm rf-font-medium",children:_?V.jsx("a",{href:_,target:"_blank",rel:"noopener noreferrer",className:"rf-text-black hover:rf-underline",children:h}):h})]}):null,(u||l||g)&&V.jsx(V.Fragment,{children:V.jsxs("div",{children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Preview"}),V.jsxs(TIe,{value:r,onValueChange:m=>A(m),children:[V.jsxs(xX,{className:"rf-inline-flex rf-h-9 rf-items-center rf-justify-center rf-rounded-lg rf-bg-zinc-100 rf-p-1 rf-text-zinc-500 dark:rf-bg-zinc-800 dark:rf-text-zinc-400",children:[l&&V.jsx(Zx,{value:"pcb",children:"PCB"}),g&&V.jsx(Zx,{value:"schematic",children:"Schematic"}),u&&V.jsx(Zx,{value:"3d",children:"3D"})]}),V.jsxs("div",{className:"rf-mt-4",children:[V.jsx(OI,{value:"pcb",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:l?V.jsx("img",{src:l,alt:`${d??"package"} PCB preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),V.jsx(OI,{value:"schematic",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:g?V.jsx("img",{src:g,alt:`${d??"package"} schematic preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),V.jsx(OI,{value:"3d",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:u?V.jsx("img",{src:u,alt:`${d??"package"} 3D preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null})]})]})]})}),i?.ai_description?V.jsxs("section",{children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"AI Description"}),V.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed",children:i.ai_description})})]}):null,i?.ai_usage_instructions?V.jsxs("section",{children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"Usage Instructions"}),V.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed rf-whitespace-pre-wrap",children:i.ai_usage_instructions})})]}):null,o?V.jsxs("div",{className:"rf-flex rf-justify-center rf-items-center rf-gap-2 rf-text-gray-500",children:[V.jsx(RB,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),V.jsx("span",{className:"rf-text-sm",children:"Loading package details..."})]}):null]}),V.jsxs(hO,{className:"rf-pt-4 rf-border-t rf-flex rf-flex-col sm:rf-flex-row rf-justify-between rf-gap-2",children:[V.jsx("div",{className:"rf-flex-1",children:p?V.jsxs(Vs,{variant:"outline",size:"sm",className:"rf-gap-2 rf-w-full sm:rf-w-auto",onClick:()=>window.open(p,"_blank"),children:[V.jsx(KIo,{className:"rf-h-4 rf-w-4"}),"View on tscircuit.com"]}):null}),V.jsxs("div",{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[V.jsx(Vs,{variant:"outline",onClick:()=>n(!1),className:"rf-order-2 sm:rf-order-1",children:"Close"}),V.jsx(Vs,{onClick:a,disabled:s,className:"rf-bg-blue-600 hover:rf-bg-blue-700",children:s?V.jsx(RB,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import Component"})]})]})]})})},r6o=()=>{const[t,e]=j.useState(null),[n,o]=j.useState(!1),i=j.useCallback(async(A,s)=>{o(!0);try{const a=await fetch(`https://api.tscircuit.com/packages/get?name=${encodeURIComponent(`${A}/${s}`)}`);if(!a.ok)throw new Error(`Failed to load package details: ${a.status}`);const c=await a.json();e(c.package??null)}catch(a){console.error("Failed to fetch package details",a),e(null)}finally{o(!1)}},[]),r=j.useCallback(()=>{e(null),o(!1)},[]);return{details:t,isLoading:n,fetchDetails:i,reset:r}},A6o=(t,e)=>{const[n,o]=j.useState({circuitJson:null,error:null,isLoading:!1});return j.useEffect(()=>{if(!t||!Nvt(t)){o({circuitJson:null,error:null,isLoading:!1});return}let i=!1;return o({circuitJson:null,error:null,isLoading:!0}),Wvo(t,e).then(r=>{i||o({circuitJson:r,error:null,isLoading:!1})}).catch(r=>{i||o({circuitJson:null,error:r instanceof Error?r.message:"Failed to load footprint preview",isLoading:!1})}),()=>{i=!0}},[t,e]),n},s6o=async(t,e)=>{const n={"Content-Type":"application/json"};e&&(n.Authorization=`Bearer ${e}`);const o=await fetch("https://registry-api.tscircuit.com/packages/search",{method:"POST",headers:n,body:JSON.stringify({query:t})});if(!o.ok)throw new Error(`tscircuit registry error: ${o.status}`);return(await o.json()).packages??[]},a6o=({sessionToken:t})=>{const[e,n]=j.useState([]),[o,i]=j.useState(!1),[r,A]=j.useState(null),[s,a]=j.useState(!1),c=j.useCallback(async g=>{const u=g.trim();if(!u)return[];i(!0),A(null);try{const h=(await s6o(u,t)).map(_=>({source:"tscircuit.com",package:_}));return n(h),h}catch(d){return console.error("Error searching tscircuit packages",d),n([]),A(d instanceof Error?d.message:"Failed to search tscircuit packages"),[]}finally{i(!1),a(!0)}},[t]),l=j.useCallback(()=>{n([]),i(!1),A(null),a(!1)},[]);return{results:e,isSearching:o,error:r,hasSearched:s,search:c,reset:l}},c6o=t=>{const e=t.trim();return/^C\d+/i.test(e)?e.replace(/^C/i,""):e},l6o=()=>{const[t,e]=j.useState([]),[n,o]=j.useState(!1),[i,r]=j.useState(null),[A,s]=j.useState(!1),a=j.useCallback(async l=>{const g=c6o(l);if(!g)return[];o(!0),r(null);try{const d=(await evo(g,10)).map(h=>({source:"jlcpcb",component:tvo(h)}));return e(d),d}catch(u){return console.error("Error searching JLCPCB components",u),e([]),r(u instanceof Error?u.message:"Failed to search JLCPCB components"),[]}finally{o(!1),s(!0)}},[]),c=j.useCallback(()=>{e([]),o(!1),r(null),s(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:A,search:a,reset:c}},g6o=()=>{const[t,e]=j.useState([]),[n,o]=j.useState(!1),[i,r]=j.useState(null),[A,s]=j.useState(!1),a=j.useCallback(async l=>{const g=l.trim();if(!g)return[];o(!0),r(null);try{const d=(await Vvo(g,20)).map(h=>({source:"kicad",footprint:zvo(h)}));return e(d),d}catch(u){return console.error("Error searching KiCad footprints",u),e([]),r(u instanceof Error?u.message:"Failed to search KiCad footprints"),[]}finally{o(!1),s(!0)}},[]),c=j.useCallback(()=>{e([]),o(!1),r(null),s(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:A,search:a,reset:c}},u6o=({onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:e,onKicadStringSelected:n})=>{const o=[];return t&&o.push("tscircuit.com"),e&&o.push("jlcpcb"),n&&o.push("kicad"),o},h6o=({isOpen:t,onClose:e,jlcpcbProxyRequestHeaders:n,onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r,jlcpcbProxyApiBase:A,tscircuitSessionToken:s})=>{Zte();const a=j.useMemo(()=>u6o({onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r}),[o,i,r]),c=a.length>0,l=a.length===1,[g,u]=j.useState(a[0]??"tscircuit.com"),[d,h]=j.useState(""),[_,p]=j.useState(null),{results:m,isSearching:I,error:C,hasSearched:f,search:y,reset:B}=a6o({sessionToken:s}),{results:x,isSearching:S,error:M,hasSearched:w,search:k,reset:N}=l6o(),{results:G,isSearching:H,error:U,hasSearched:J,search:W,reset:X}=g6o(),{details:oe,isLoading:ce,fetchDetails:te,reset:ie}=r6o(),[ae,re]=j.useState(null),[le,ye]=j.useState(!1),[xe,be]=j.useState("pcb"),[he,Se]=j.useState(null),[Ie,He]=j.useState(!1),Je=j.useMemo(()=>({jlcpcb:{headers:n,apiBase:A}}),[A,n]),{circuitJson:et,error:pe,isLoading:$e}=A6o(_,Je),Ge=Nvt(_);j.useEffect(()=>{Se(null)},[_]);const Pe=j.useCallback(()=>{B(),N(),X(),p(null)},[N,X,B]);j.useEffect(()=>{t||(Pe(),h(""),ye(!1),re(null),Se(null))},[t,Pe]),j.useEffect(()=>{h(""),p(null),g==="tscircuit.com"?B():g==="jlcpcb"?N():g==="kicad"&&X()},[g,N,X,B]);const Ue=lt=>{p(lt),re(lt),be("pcb"),ye(!0),ie();const Ct=lt.package.org_owner_tscircuit_handle,Dt=lt.package.unscoped_name;if(Ct&&Dt){const It=Dt.split("/").pop()??Dt;te(Ct,It)}},Ne=async()=>{d.trim()&&(p(null),g==="tscircuit.com"?await y(d):g==="jlcpcb"?await k(d):g==="kicad"&&await W(d))},Ee=async lt=>{try{if(Se(null),He(!0),lt.source==="kicad"){if(!o)throw new Error("KiCad handler not provided");await o({result:lt,footprint:lt.footprint.qualifiedName})}else if(lt.source==="jlcpcb"){if(!r)throw new Error("JLCPCB handler not provided");const Ct=await nvo(lt.component.partNumber,{headers:n,apiBase:A});await r({result:lt,tsx:Ct})}else if(lt.source==="tscircuit.com"){if(!i)throw new Error("tscircuit package handler not provided");const Ct=lt.package.org_owner_tscircuit_handle,Dt=lt.package.unscoped_name;if(!Ct||!Dt)throw new Error("Missing package metadata");const It=Dt.split("/").pop()??Dt,Nt=`@tsci/${Ct}.${It}`;await i({result:lt,fullPackageName:Nt})}return!0}catch(Ct){return console.error("Failed to import component",Ct),Se(Ct instanceof Error?Ct.message:"Failed to import component"),!1}finally{He(!1)}};let Oe=[],Me=!1,ze=null,je=!1;g==="tscircuit.com"?(Oe=m,Me=I,ze=C,je=f):g==="jlcpcb"?(Oe=x,Me=S,ze=M,je=w):g==="kicad"&&(Oe=G,Me=H,ze=U,je=J);const st=async()=>{if(!_)return;await Ee(_)&&(e(),Pe(),h(""))},ct=lt=>{lt||e()},ut=lt=>{ye(lt),lt||re(null)};return V.jsxs(PN,{open:t,onOpenChange:ct,children:[V.jsxs(f3,{style:{width:"calc(100vw - 2rem)",maxWidth:Ge?"min(1120px, calc(100vw - 2rem))":"min(672px, calc(100vw - 2rem))",zIndex:Tvt.importComponentDialog},className:"rf-rounded-sm rf-max-h-[90vh] rf-overflow-y-auto rf-overflow-x-hidden rf-flex rf-flex-col",children:[V.jsxs(y3,{children:[V.jsxs(E3,{className:"rf-text-lg sm:rf-text-xl",children:["Import ",l?ane[g].label:""," ","Component"]}),V.jsx(vN,{className:"rf-text-sm",children:c?"Search for components from available sources.":"Import options are disabled because no handlers were provided."})]}),c?V.jsxs(TIe,{value:g,onValueChange:lt=>u(lt),className:"rf-min-w-0 rf-w-full",children:[!l&&V.jsx(xX,{className:"rf-flex rf-w-full rf-gap-2",children:a.map(lt=>V.jsx(Zx,{value:lt,className:"rf-flex-1 rf-text-xs sm:rf-text-sm",children:ane[lt].label},lt))}),V.jsxs("div",{className:"rf-min-w-0",style:Ge?{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(360px, 0.95fr)",gap:"1.5rem",alignItems:"start"}:void 0,children:[V.jsxs("div",{className:"rf-min-w-0",children:[V.jsx(jvo,{query:d,placeholder:ane[g].placeholder,isSearching:Me,onQueryChange:h,onSubmit:Ne}),V.jsx("div",{className:"no-scrollbar rf-mt-4 rf-flex-1 rf-min-h-[200px] !rf-max-h-[40vh] !rf-overflow-y-auto rf-overflow-x-hidden rf-border rf-rounded-md rf-min-w-0",children:Me?V.jsxs("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:[V.jsx(RB,{className:"rf-h-8 rf-w-8 rf-animate-spin rf-mx-auto rf-mb-2"}),V.jsx("p",{children:"Searching..."})]}):Oe.length>0?V.jsx(n6o,{results:Oe,selected:_,onSelect:p,onShowDetails:g==="tscircuit.com"?Ue:void 0}):V.jsx("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:ze?`Error: ${ze}`:je?ane[g].emptyMessage:"Enter a search term to find components"})})]}),Ge?V.jsx("div",{className:"rf-mt-4",children:V.jsx(o6o,{circuitJson:et,error:pe,isLoading:$e,height:325})}):null]})]}):null,he?V.jsx("div",{className:"rf-text-sm rf-text-red-600 rf-mt-2",children:he}):null,V.jsxs(hO,{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[V.jsx(Vs,{variant:"outline",onClick:e,className:"rf-order-2 sm:rf-order-1",children:"Cancel"}),V.jsx(Vs,{onClick:st,disabled:!_||Ie,className:"rf-order-1 sm:rf-order-2",children:Ie?V.jsx(RB,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import"})]})]}),V.jsx(i6o,{packageResult:ae,isOpen:le,onOpenChange:ut,isLoading:ce,details:oe,previewTab:xe,onPreviewTabChange:lt=>be(lt),isSubmitting:Ie,onImport:()=>{ae&&Ee(ae).then(lt=>{lt&&(ye(!1),e(),Pe(),h(""))})}})]})},d6o=t=>{const e=t.match(/export const (\w+) =/);if(!e)throw new Error("Could not determine component name from TSX contents");return e[1]},kvt=t=>{const e=M0(A=>A.pushEvent),n=M0(A=>A.upsertFile),o=async({result:A,fullPackageName:s})=>{const c=A.package.unscoped_name??A.package.name;await GA.promise(e({event_type:"INSTALL_PACKAGE",full_package_name:s}),{loading:`Requesting install for "${c}"`,success:`Install requested for "${c}"`,error:l=>`Failed to request install: ${l instanceof Error?l.message:String(l)}`})},i=async({footprint:A})=>{await GA.promise(navigator.clipboard.writeText(A),{loading:`Copying "${A}"`,success:`Copied "${A}" to clipboard`,error:s=>`Failed to copy footprint: ${s instanceof Error?s.message:String(s)}`})},r=async({result:A,tsx:s})=>{const c=`imports/${d6o(s)}.tsx`;await GA.promise(n(c,s),{loading:`Importing ${A.component.partNumber}`,success:`Imported to "${c}"`,error:l=>`Failed to import component: ${l instanceof Error?l.message:String(l)}`})};return V.jsx(h6o,{...t,onTscircuitPackageSelected:o,onKicadStringSelected:i,onJlcpcbComponentTsxLoaded:r})};kvt.displayName="ImportComponentDialogForCli";var lwe={exports:{}},Fvt;function _6o(){return Fvt||(Fvt=1,(function(t,e){var n={env:{},version:""};(function(o){t.exports=o()})(function(){return(function o(i,r,A){function s(l,g){if(!r[l]){if(!i[l]){var u=typeof y4=="function"&&y4;if(!g&&u)return u(l,!0);if(a)return a(l,!0);var d=new Error("Cannot find module '"+l+"'");throw d.code="MODULE_NOT_FOUND",d}var h=r[l]={exports:{}};i[l][0].call(h.exports,function(_){var p=i[l][1][_];return s(p||_)},h,h.exports,o,i,r,A)}return r[l].exports}for(var a=typeof y4=="function"&&y4,c=0;c<A.length;c++)s(A[c]);return s})({1:[function(o,i,r){var A=o("./utils"),s=o("./support"),a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.encode=function(c){for(var l,g,u,d,h,_,p,m=[],I=0,C=c.length,f=C,y=A.getTypeOf(c)!=="string";I<c.length;)f=C-I,u=y?(l=c[I++],g=I<C?c[I++]:0,I<C?c[I++]:0):(l=c.charCodeAt(I++),g=I<C?c.charCodeAt(I++):0,I<C?c.charCodeAt(I++):0),d=l>>2,h=(3&l)<<4|g>>4,_=1<f?(15&g)<<2|u>>6:64,p=2<f?63&u:64,m.push(a.charAt(d)+a.charAt(h)+a.charAt(_)+a.charAt(p));return m.join("")},r.decode=function(c){var l,g,u,d,h,_,p=0,m=0,I="data:";if(c.substr(0,I.length)===I)throw new Error("Invalid base64 input, it looks like a data url.");var C,f=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===a.charAt(64)&&f--,c.charAt(c.length-2)===a.charAt(64)&&f--,f%1!=0)throw new Error("Invalid base64 input, bad content length.");for(C=s.uint8array?new Uint8Array(0|f):new Array(0|f);p<c.length;)l=a.indexOf(c.charAt(p++))<<2|(d=a.indexOf(c.charAt(p++)))>>4,g=(15&d)<<4|(h=a.indexOf(c.charAt(p++)))>>2,u=(3&h)<<6|(_=a.indexOf(c.charAt(p++))),C[m++]=l,h!==64&&(C[m++]=g),_!==64&&(C[m++]=u);return C}},{"./support":30,"./utils":32}],2:[function(o,i,r){var A=o("./external"),s=o("./stream/DataWorker"),a=o("./stream/Crc32Probe"),c=o("./stream/DataLengthProbe");function l(g,u,d,h,_){this.compressedSize=g,this.uncompressedSize=u,this.crc32=d,this.compression=h,this.compressedContent=_}l.prototype={getContentWorker:function(){var g=new s(A.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),u=this;return g.on("end",function(){if(this.streamInfo.data_length!==u.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),g},getCompressedWorker:function(){return new s(A.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},l.createWorkerFrom=function(g,u,d){return g.pipe(new a).pipe(new c("uncompressedSize")).pipe(u.compressWorker(d)).pipe(new c("compressedSize")).withStreamInfo("compression",u)},i.exports=l},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(o,i,r){var A=o("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new A("STORE compression")},uncompressWorker:function(){return new A("STORE decompression")}},r.DEFLATE=o("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(o,i,r){var A=o("./utils"),s=(function(){for(var a,c=[],l=0;l<256;l++){a=l;for(var g=0;g<8;g++)a=1&a?3988292384^a>>>1:a>>>1;c[l]=a}return c})();i.exports=function(a,c){return a!==void 0&&a.length?A.getTypeOf(a)!=="string"?(function(l,g,u,d){var h=s,_=d+u;l^=-1;for(var p=d;p<_;p++)l=l>>>8^h[255&(l^g[p])];return-1^l})(0|c,a,a.length,0):(function(l,g,u,d){var h=s,_=d+u;l^=-1;for(var p=d;p<_;p++)l=l>>>8^h[255&(l^g.charCodeAt(p))];return-1^l})(0|c,a,a.length,0):0}},{"./utils":32}],5:[function(o,i,r){r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(o,i,r){var A=null;A=typeof Promise<"u"?Promise:o("lie"),i.exports={Promise:A}},{lie:37}],7:[function(o,i,r){var A=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",s=o("pako"),a=o("./utils"),c=o("./stream/GenericWorker"),l=A?"uint8array":"array";function g(u,d){c.call(this,"FlateWorker/"+u),this._pako=null,this._pakoAction=u,this._pakoOptions=d,this.meta={}}r.magic="\b\0",a.inherits(g,c),g.prototype.processChunk=function(u){this.meta=u.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(l,u.data),!1)},g.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},g.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},g.prototype._createPako=function(){this._pako=new s[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var u=this;this._pako.onData=function(d){u.push({data:d,meta:u.meta})}},r.compressWorker=function(u){return new g("Deflate",u)},r.uncompressWorker=function(){return new g("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(o,i,r){function A(h,_){var p,m="";for(p=0;p<_;p++)m+=String.fromCharCode(255&h),h>>>=8;return m}function s(h,_,p,m,I,C){var f,y,B=h.file,x=h.compression,S=C!==l.utf8encode,M=a.transformTo("string",C(B.name)),w=a.transformTo("string",l.utf8encode(B.name)),k=B.comment,N=a.transformTo("string",C(k)),G=a.transformTo("string",l.utf8encode(k)),H=w.length!==B.name.length,U=G.length!==k.length,J="",W="",X="",oe=B.dir,ce=B.date,te={crc32:0,compressedSize:0,uncompressedSize:0};_&&!p||(te.crc32=h.crc32,te.compressedSize=h.compressedSize,te.uncompressedSize=h.uncompressedSize);var ie=0;_&&(ie|=8),S||!H&&!U||(ie|=2048);var ae=0,re=0;oe&&(ae|=16),I==="UNIX"?(re=798,ae|=(function(ye,xe){var be=ye;return ye||(be=xe?16893:33204),(65535&be)<<16})(B.unixPermissions,oe)):(re=20,ae|=(function(ye){return 63&(ye||0)})(B.dosPermissions)),f=ce.getUTCHours(),f<<=6,f|=ce.getUTCMinutes(),f<<=5,f|=ce.getUTCSeconds()/2,y=ce.getUTCFullYear()-1980,y<<=4,y|=ce.getUTCMonth()+1,y<<=5,y|=ce.getUTCDate(),H&&(W=A(1,1)+A(g(M),4)+w,J+="up"+A(W.length,2)+W),U&&(X=A(1,1)+A(g(N),4)+G,J+="uc"+A(X.length,2)+X);var le="";return le+=`
|
|
5786
|
+
`,g=new Blob([l],{type:"text/plain"}),u=URL.createObjectURL(g),d=document.createElement("a");d.href=u,d.download=`${c}.test.ts`,d.click(),URL.revokeObjectURL(u)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}o(!1)};return V.jsxs("div",{className:`relative ${e}`,ref:i,children:[V.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>o(!n),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),n&&V.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download JSON"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:A,children:"Download page.tsx"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download test.ts"})]})]})},S3t=t=>t.activeSubSolver?[t,...S3t(t.activeSubSolver)]:[t],t3o=({solver:t})=>{const e=S3t(t);return V.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:e.map((n,o)=>V.jsxs("div",{className:"flex items-center",children:[o>0&&V.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),V.jsx(e3o,{solver:n})]},n.constructor.name))})},n3o=({solver:t,triggerRender:e,animationSpeed:n=25,onSolverStarted:o,onSolverCompleted:i})=>{const[r,A]=j.useReducer(_=>!_,!1),s=j.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),e())},c=()=>{!t.solved&&!t.failed&&(o&&o(t),t.solve(),e(),i&&i(t))},l=()=>{r?(s.current&&(clearInterval(s.current),s.current=void 0),A()):(A(),s.current=setInterval(()=>{if(t.solved||t.failed){s.current&&(clearInterval(s.current),s.current=void 0),A(),e(),i&&t.solved&&i(t);return}t.step(),e()},n))},g=()=>{const _=t;if(_.getCurrentPhase&&!t.solved&&!t.failed){const p=_.getCurrentPhase();for(;_.getCurrentPhase()===p&&!t.solved&&!t.failed;)t.step();e()}},u=()=>{if(t.solved||t.failed||r)return;const _=window.prompt("Step until which iteration?",`${t.iterations}`);if(_===null)return;const p=Number(_);if(!Number.isFinite(p)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<p&&!t.solved&&!t.failed;)t.step();e(),t.solved&&i&&i(t)};j.useEffect(()=>()=>{s.current&&clearInterval(s.current)},[]),j.useEffect(()=>{(t.solved||t.failed)&&r&&(s.current&&(clearInterval(s.current),s.current=void 0),A())},[t.solved,t.failed,r]);const d=t.getCurrentPhase!==void 0,h=d?t.getCurrentPhase():null;return V.jsxs("div",{className:"space-y-2 p-2 border-b",children:[V.jsx("div",{className:"flex items-center",children:V.jsx(t3o,{solver:t})}),V.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[V.jsx("button",{onClick:a,disabled:t.solved||t.failed||r,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),V.jsx("button",{onClick:c,disabled:t.solved||t.failed||r,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),V.jsx("button",{onClick:l,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${r?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:r?"Stop":"Animate"}),V.jsx("button",{onClick:u,disabled:t.solved||t.failed||r,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),d&&V.jsx("button",{onClick:g,disabled:t.solved||t.failed||r,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),V.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),h&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",V.jsx("span",{className:"font-medium",children:h})]}),t.solved&&V.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&V.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&V.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},o3o=(t,e,n)=>{const o=t.currentPipelineStepIndex;return e<o?"Completed":e===o&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},i3o=(t,e)=>{const o=t.pipelineDef[e].solverName,i=o3o(t,e),r=t[o],A=t.firstIterationOfPhase?.[o]??null,s=t.iterations;let a=0;if(i==="Completed"){const u=t.pipelineDef[e+1],d=u?t.firstIterationOfPhase?.[u.solverName]:void 0;d!==void 0&&A!==null?a=d-A:A!==null&&(a=s-A)}else i==="In Progress"&&A!==null&&(a=s-A);const c=t.timeSpentOnPhase?.[o]??0;let l=0;i==="Completed"?l=1:i==="In Progress"&&r&&(l=r.progress??0);const g=r?.stats??null;return{index:e,name:o,status:i,firstIteration:A,iterations:a,progress:l,timeSpent:c,stats:g&&Object.keys(g).length>0?g:null,solverInstance:r??null}},r3o=({status:t})=>{const e={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return V.jsx("span",{className:`font-medium ${e[t]}`,children:t})},A3o=({progress:t})=>{if(t===0)return null;const e=Math.round(t*100);return V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:V.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${e}%`}})}),V.jsxs("span",{className:"text-xs text-gray-500",children:[e,"%"]})]})},s3o=t=>Object.entries(t).map(([e,n])=>`${e}: ${n}`).join(", "),a3o=({stats:t})=>{if(!t||Object.keys(t).length===0)return V.jsx("span",{children:"-"});const e=Object.entries(t),n=s3o(t);return V.jsxs("details",{className:"cursor-pointer",children:[V.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:n}),V.jsx("div",{className:"mt-1 text-xs",children:e.map(([o,i])=>V.jsxs("div",{children:[o,": ",String(i)]},o))})]})},TMe=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(TMe);const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||(e[n]=TMe(o));return e},c3o=(t,e)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${e}`);return}const n=TMe(t.getConstructorParams()),o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),i=URL.createObjectURL(o),r=document.createElement("a");r.href=i,r.download=`${e}_input.json`,r.click(),URL.revokeObjectURL(i)}catch(n){alert(`Error downloading input for ${e}: ${n instanceof Error?n.message:String(n)}`)}},l3o=({solver:t,onStepUntilPhase:e,onDownloadInput:n})=>{const o=t.pipelineDef.map((s,a)=>i3o(t,a)),i=s=>{e?.(s)},r=s=>{s.solverInstance&&(n?n(s.solverInstance,s.name):c3o(s.solverInstance,s.name))},A=s=>`${(s/1e3).toFixed(2)}s`;return V.jsxs("div",{className:"border-t border-gray-200",children:[V.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:V.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),V.jsx("div",{className:"overflow-x-auto",children:V.jsxs("table",{className:"w-full text-sm",children:[V.jsx("thead",{children:V.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),V.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",V.jsx("sub",{children:"0"})]}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),V.jsx("tbody",{children:o.map(s=>V.jsxs("tr",{className:`border-b border-gray-100 ${s.status==="In Progress"?"bg-yellow-50":""}`,children:[V.jsx("td",{className:"px-4 py-2",children:V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("span",{className:"text-gray-400 w-6",children:String(s.index+1).padStart(2,"0")}),V.jsx("button",{onClick:()=>i(s.name),disabled:s.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${s.name} completes`,children:V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),V.jsx("span",{className:"font-medium text-gray-900",children:s.name})]})}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(r3o,{status:s.status})}),V.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:s.firstIteration!==null?s.firstIteration:""}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:s.iterations}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(A3o,{progress:s.progress})}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:A(s.timeSpent)}),V.jsx("td",{className:"px-4 py-2 text-gray-500",children:V.jsx(a3o,{stats:s.stats})}),V.jsx("td",{className:"px-4 py-2",children:s.solverInstance?V.jsxs("button",{onClick:()=>r(s),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${s.name}`,children:[V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),V.jsx("span",{children:"Input"})]}):null})]},s.name))})]})})]})},g3o=class extends Jr.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function u3o({graphics:t}){const e=t.points??[],n=t.lines??[],o=t.rects??[],i=t.circles??[],r=t.texts??[];let A=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY;const l=(p,m)=>{typeof p=="number"&&(p<A&&(A=p),p>a&&(a=p)),typeof m=="number"&&(m<s&&(s=m),m>c&&(c=m))};for(const p of e)l(p.x,p.y);for(const p of n){const m=p.points??[];for(const I of m)l(I.x,I.y)}for(const p of o){const m=p.x??0,I=p.y??0,C=p.width??0,f=p.height??0;l(m,I),l(m+C,I+f)}for(const p of i){const m=p.x??0,I=p.y??0,C=p.radius??1;l(m-C,I-C),l(m+C,I+C)}for(const p of r)l(p.x,p.y);(!isFinite(A)||!isFinite(s)||!isFinite(a)||!isFinite(c))&&(A=-20,s=-20,a=20,c=20);const g=10,u=A-g,d=s-g,h=Math.max(1,a-A+2*g),_=Math.max(1,c-s+2*g);return V.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${u} ${d} ${h} ${_}`,role:"img","aria-label":"Graphics fallback",children:[o.map((p,m)=>V.jsx("rect",{x:p.x??0,y:p.y??0,width:p.width??0,height:p.height??0,fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1},`rect-${m}`)),n.map((p,m)=>V.jsx("polyline",{fill:"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1,points:(p.points??[]).map(I=>`${I.x??0},${I.y??0}`).join(" ")},`line-${m}`)),i.map((p,m)=>V.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.fillColor??"none",stroke:p.strokeColor??"black",strokeWidth:p.strokeWidth??1},`circle-${m}`)),e.map((p,m)=>V.jsx("circle",{cx:p.x??0,cy:p.y??0,r:p.radius??1.5,fill:p.color??"black"},`point-${m}`)),r.map((p,m)=>V.jsx("text",{x:p.x??0,y:p.y??0,fontSize:p.fontSize??10,fill:p.color??"black",children:p.text??""},`text-${m}`))]})}var h3o=({solver:t,animationSpeed:e=25,onSolverStarted:n,onSolverCompleted:o})=>{const[i,r]=j.useReducer(l=>l+1,0),A=j.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(l){return console.error("Visualization error:",l),{points:[],lines:[],rects:[],circles:[]}}},[t,i]),s=j.useMemo(()=>(A.rects?.length||0)===0&&(A.lines?.length||0)===0&&(A.points?.length||0)===0&&(A.circles?.length||0)===0,[A]);j.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const l=document.createElement("script");l.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(l)}},[]);const a=t.pipelineDef!==void 0,c=l=>{const g=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&g.currentPipelineStepIndex<=g.pipelineDef.findIndex(u=>u.solverName===l);)t.step();r()}};return V.jsxs("div",{children:[V.jsx(n3o,{solver:t,triggerRender:r,animationSpeed:e,onSolverStarted:n,onSolverCompleted:o}),s?V.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):V.jsx(g3o,{fallback:V.jsx(u3o,{graphics:A}),children:V.jsx(ZPo,{graphics:A})}),a&&V.jsx(l3o,{solver:t,onStepUntilPhase:c})]})};const d3o=()=>{j.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const e=document.createElement("div");e.className="hidden",document.body.appendChild(e);const n=window.getComputedStyle(e).display==="none";if(document.body.removeChild(e),n)return;const o=document.createElement("script");o.id=t,o.src="https://cdn.tailwindcss.com",document.head.appendChild(o)},[])},_3o=1e3,MQ=(t,e)=>{const{fileName:n,mimeType:o="text/plain"}=e,i=t instanceof Blob?t:new Blob([t],{type:o}),r=URL.createObjectURL(i),A=document.createElement("a");A.href=r,A.download=n,A.target="_blank",A.rel="noopener noreferrer",A.style.display="none",document.body.appendChild(A),A.click(),document.body.removeChild(A),setTimeout(()=>{URL.revokeObjectURL(r)},_3o)},b3t=t=>{let e=t.trim().replace(/[\\/:*?"<>|]/g,"_").replace(/[\x00-\x1f]/g,"").replace(/^\.+/,"").replace(/\.+$/,"").replace(/\s+/g," ").replace(/_+/g,"_");return/^(con|prn|aux|nul|com[0-9]|lpt[0-9])$/i.test(e)&&(e=`_${e}`),e=e.slice(0,200),e||"untitled"},wQ="https://github.com/tscircuit/tscircuit-autorouter/issues/new",D3t="https://github.com/tscircuit/copper-pour-solver/issues/new",M3t="https://github.com/tscircuit/calculate-packing/issues/new",w3t="https://github.com/tscircuit/schematic-trace-solver/issues/new?template=json-bug-report.yml",m3o={PackSolver2:M3t,AutoroutingPipelineSolver:wQ,AssignableAutoroutingPipeline2:wQ,AssignableAutoroutingPipeline3:wQ,AutoroutingPipeline1_OriginalUnravel:wQ,AutoroutingPipelineSolver3_HgPortPointPathing:wQ,AutoroutingPipelineSolver4:wQ,AutoroutingPipelineSolver5:wQ,AutoroutingPipelineSolver7_MultiGraph:wQ,AutoroutingPipelineSolver8:wQ,CopperPourPipelineSolver:D3t,SchematicTracePipelineSolver:w3t},p3o=t=>t.toLowerCase().includes("pack")?JIo:t.toLowerCase().includes("rout")?ZIo:RIo,P3t=t=>{const e=m3o[t];if(e)return e;const n=t.toLowerCase();return n.includes("autorout")?wQ:n.includes("schematic")&&n.includes("trace")?w3t:n.includes("copperpour")?D3t:n.includes("pack")?M3t:null},I3o=t=>`${b3t(`${t.componentName}-${t.solverName}`)}-solver-input.json`,v3t=t=>{MQ(JSON.stringify(t.solverParams,null,2),{fileName:I3o(t),mimeType:"application/json"})},C3o=({solverEvent:t})=>{const e=P3t(t.solverName);return V.jsxs("div",{className:"rf-flex rf-items-center rf-justify-end rf-gap-2 rf-border-b rf-border-gray-200 rf-bg-gray-50 rf-px-4 rf-py-2",children:[V.jsxs(Vs,{type:"button",variant:"outline",size:"sm",onClick:()=>v3t(t),children:[V.jsx(j4e,{className:"rf-w-4 rf-h-4"}),"Download"]}),e?V.jsx(Vs,{asChild:!0,variant:"outline",size:"sm",children:V.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[V.jsx(pee,{className:"rf-w-4 rf-h-4"}),"Report"]})}):V.jsxs(Vs,{type:"button",variant:"outline",size:"sm",disabled:!0,title:"No report link configured for this solver",children:[V.jsx(pee,{className:"rf-w-4 rf-h-4"}),"Report"]})]})},f3o=({solverEvent:t})=>{const e=P3t(t.solverName);return e?V.jsx(Vs,{asChild:!0,variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",children:V.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:"Report solver bug","aria-label":"Report solver bug",children:V.jsx(pee,{className:"rf-w-4 rf-h-4"})})}):V.jsx(Vs,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8",disabled:!0,title:"No report link configured for this solver","aria-label":"Report solver bug",children:V.jsx(pee,{className:"rf-w-4 rf-h-4"})})},y3o=({solverEvents:t=[]})=>{const[e,n]=j.useState(null);d3o();const o=j.useMemo(()=>{const s=new Map;for(const a of t){const c=`${a.componentName}-${a.solverName}`;s.set(c,a)}return s},[t]),i=j.useMemo(()=>Array.from(o.keys()),[o]),r=e?o.get(e):null,A=j.useMemo(()=>{if(!r)return{instance:null,error:null,classFound:!1};const s=_me[r.solverName];if(!s)return{instance:null,error:`Solver class "${r.solverName}" not found in SOLVERS registry. Available: ${Object.keys(_me).join(", ")}`,classFound:!1};try{const a=r.solverParams,c=a?.input!==void 0?a.input:a;return{instance:new s(c),error:null,classFound:!0}}catch(a){const c=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${c}`,classFound:!0}}},[r]);return t.length===0?V.jsx("div",{className:"rf-p-4",children:V.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:V.jsxs("div",{className:"rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),V.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):V.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[V.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[V.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[i.length," ",i.length===1?"Solver":"Solvers"]}),i.map(s=>{const a=o.get(s),c=e===s;return V.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${c?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>n(s),children:(()=>{const l=p3o(a.solverName);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[V.jsx(l,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),V.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},s)})]}),V.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:r?A.instance?V.jsxs("div",{className:"rf-flex rf-h-full rf-flex-col rf-overflow-y-auto",children:[V.jsx(C3o,{solverEvent:r}),V.jsx("div",{className:"rf-min-h-0 rf-flex-1",children:V.jsx(y2,{fallback:V.jsx("div",{className:"rf-p-4",children:V.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),V.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",r.solverName]})]})}),children:V.jsx(h3o,{solver:A.instance})})})]}):V.jsxs("div",{className:"rf-p-4",children:[V.jsxs("div",{className:"rf-mb-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:r.solverName}),V.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",r.componentName]})]}),A.error&&V.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${A.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:V.jsx("p",{className:`rf-text-sm ${A.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:A.error})}),V.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[V.jsxs("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50 rf-flex rf-items-center rf-justify-between rf-gap-2",children:[V.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"}),V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-1",children:[V.jsx(f3o,{solverEvent:r}),V.jsx(Vs,{type:"button",variant:"ghost",size:"icon",className:"rf-h-8 rf-w-8","aria-label":"Download solver input JSON",title:"Download solver input JSON",onClick:()=>v3t(r),children:V.jsx(j4e,{className:"rf-w-4 rf-h-4"})})]})]}),V.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:V.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(r.solverParams,null,2)})})]})]}):V.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},N3t=({errorMessage:t,errorStack:e,circuitJsonErrors:n})=>{j.useEffect(()=>{if(t){const o=new Error(t);e&&(o.stack=e);try{b9.captureException(o)}catch{}}},[t,e]),j.useEffect(()=>{if(n&&n.length>0)for(const o of n){const i=new Error(o.message||"Circuit JSON Error");o.stack&&(i.stack=o.stack);try{b9.captureException(i,{error_type:o.type})}catch{}}},[n])},R3t=t=>{j.useEffect(()=>{try{Rkn(t)}catch{}},[t.source,t.component,t.isWebEmbedded,t.activeTab])},T3t="0.0.2214",E3o={version:T3t},ene=sAt()(aAt(t=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{t({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),B3o=t=>{const[e,n]=j.useState([]),[o,i]=j.useState(null),[r,A]=j.useState(""),[s,a]=r9("eval-version-selection",null),c=ene(d=>d.setLastRunEvalVersion),l=ene(d=>d.lastRunEvalVersion);return j.useEffect(()=>{t&&fetch("https://data.jsdelivr.com/v1/package/npm/@tscircuit/eval").then(d=>d.json()).then(d=>{if(Array.isArray(d?.versions)){let h=[...d.versions];d.tags?.latest&&(i(d.tags.latest),h=h.filter(_=>_!==d.tags.latest)),n(h)}}).catch(()=>{})},[t]),j.useEffect(()=>{t&&(s?(window.TSCIRCUIT_LATEST_EVAL_VERSION=s,c(s)):o&&(window.TSCIRCUIT_LATEST_EVAL_VERSION=o,c(o)))},[t,s,o]),{versions:j.useMemo(()=>e.filter(d=>d.includes(r)).slice(0,50),[e,r]),latestVersion:o,lastRunEvalVersion:l,search:r,setSearch:A,selectVersion:d=>{a(d),A("")}}},x3o=({snippetNames:t,onSelect:e,onCancel:n,isOpen:o})=>{const[i,r]=j.useState(""),[A,s]=j.useState("");if(!o)return null;const a=t.filter(g=>g.toLowerCase().includes(A.toLowerCase())),c=A&&!t.includes(A),l=g=>{g.key==="Enter"&&(a.length===1?r(a[0]):c&&r(A))};return V.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-items-center rf-justify-center rf-z-[100]",children:V.jsxs("div",{className:"rf-bg-white rf-rounded-lg rf-p-6 rf-w-96",children:[V.jsx("h2",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Select Snippet"}),V.jsx("input",{type:"text",className:"rf-w-full rf-px-4 rf-py-2 rf-border rf-rounded rf-mb-4",placeholder:"Search snippets or new snippet name...",value:A,onChange:g=>s(g.target.value),onKeyDown:l}),V.jsxs("div",{className:"rf-h-60 rf-overflow-y-auto",children:[a.map(g=>V.jsx("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 ${i===g?"bg-blue-50":""}`,onClick:()=>r(g),children:g},g)),c&&V.jsxs("button",{type:"button",className:`w-full text-left px-4 py-2 rounded hover:bg-gray-100 text-blue-500 ${i===A?"bg-blue-50":""}`,onClick:()=>r(A),children:['Create new "',A,'"']})]}),V.jsxs("div",{className:"rf-mt-4 rf-flex rf-justify-end rf-gap-2",children:[V.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-text-gray-600 rf-hover:text-gray-800",onClick:n,children:"Cancel"}),V.jsx("button",{type:"button",className:"rf-px-4 rf-py-2 rf-bg-blue-500 rf-text-white rf-rounded rf-hover:bg-blue-600 rf-disabled:opacity-50",onClick:()=>i&&e(i),disabled:!i,children:i===A?`Create "${i}"`:`Save to ${i}`})]})]})})},Q3o=t=>{const e=j.useRef(null),n=M0(o=>o.recentEvents);j.useEffect(()=>{if(n.length===0)return;const o=n[0];o.event_id!==e.current&&(t(o),e.current=o.event_id)},[n,t])};var tne="Dialog",[k3t,F3t]=_B(tne),[S3o,OB]=k3t(tne),nne=t=>{const{__scopeDialog:e,children:n,open:o,defaultOpen:i,onOpenChange:r,modal:A=!0}=t,s=j.useRef(null),a=j.useRef(null),[c,l]=Lb({prop:o,defaultProp:i??!1,onChange:r,caller:tne});return V.jsx(S3o,{scope:e,triggerRef:s,contentRef:a,contentId:bp(),titleId:bp(),descriptionId:bp(),open:c,onOpenChange:l,onOpenToggle:j.useCallback(()=>l(g=>!g),[l]),modal:A,children:n})};nne.displayName=tne;var L3t="DialogTrigger",H3t=j.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=OB(L3t,n),r=mg(e,i.triggerRef);return V.jsx(Us.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":LMe(i.open),...o,ref:r,onClick:wr(t.onClick,i.onOpenToggle)})});H3t.displayName=L3t;var kMe="DialogPortal",[b3o,G3t]=k3t(kMe,{forceMount:void 0}),one=t=>{const{__scopeDialog:e,forceMount:n,children:o,container:i}=t,r=OB(kMe,e);return V.jsx(b3o,{scope:e,forceMount:n,children:j.Children.map(o,A=>V.jsx(Ry,{present:n||r.open,children:V.jsx(Nee,{asChild:!0,container:i,children:A})}))})};one.displayName=kMe;var ine="DialogOverlay",lO=j.forwardRef((t,e)=>{const n=G3t(ine,t.__scopeDialog),{forceMount:o=n.forceMount,...i}=t,r=OB(ine,t.__scopeDialog);return r.modal?V.jsx(Ry,{present:o||r.open,children:V.jsx(M3o,{...i,ref:e})}):null});lO.displayName=ine;var D3o=iP("DialogOverlay.RemoveScroll"),M3o=j.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=OB(ine,n),r=dCo(),A=mg(e,r);return V.jsx(Oee,{as:D3o,allowPinchZoom:!0,shards:[i.contentRef],children:V.jsx(Us.div,{"data-state":LMe(i.open),...o,ref:A,style:{pointerEvents:"auto",...o.style}})})}),wN="DialogContent",gO=j.forwardRef((t,e)=>{const n=G3t(wN,t.__scopeDialog),{forceMount:o=n.forceMount,...i}=t,r=OB(wN,t.__scopeDialog);return V.jsx(Ry,{present:o||r.open,children:r.modal?V.jsx(w3o,{...i,ref:e}):V.jsx(P3o,{...i,ref:e})})});gO.displayName=wN;var w3o=j.forwardRef((t,e)=>{const n=OB(wN,t.__scopeDialog),o=j.useRef(null),i=mg(e,n.contentRef,o);return j.useEffect(()=>{const r=o.current;if(r)return fbe(r)},[]),V.jsx(O3t,{...t,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:wr(t.onCloseAutoFocus,r=>{r.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:wr(t.onPointerDownOutside,r=>{const A=r.detail.originalEvent,s=A.button===0&&A.ctrlKey===!0;(A.button===2||s)&&r.preventDefault()}),onFocusOutside:wr(t.onFocusOutside,r=>r.preventDefault())})}),P3o=j.forwardRef((t,e)=>{const n=OB(wN,t.__scopeDialog),o=j.useRef(!1),i=j.useRef(!1);return V.jsx(O3t,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:r=>{t.onCloseAutoFocus?.(r),r.defaultPrevented||(o.current||n.triggerRef.current?.focus(),r.preventDefault()),o.current=!1,i.current=!1},onInteractOutside:r=>{t.onInteractOutside?.(r),r.defaultPrevented||(o.current=!0,r.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const A=r.target;n.triggerRef.current?.contains(A)&&r.preventDefault(),r.detail.originalEvent.type==="focusin"&&i.current&&r.preventDefault()}})}),O3t=j.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:o,onOpenAutoFocus:i,onCloseAutoFocus:r,...A}=t,s=OB(wN,n);return ebe(),V.jsx(V.Fragment,{children:V.jsx(Cee,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:i,onUnmountAutoFocus:r,children:V.jsx(IG,{role:"dialog",id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":LMe(s.open),...A,ref:e,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})}),K3t="DialogTitle",rne=j.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=OB(K3t,n);return V.jsx(Us.h2,{id:i.titleId,...o,ref:e})});rne.displayName=K3t;var U3t="DialogDescription",Ane=j.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=OB(U3t,n);return V.jsx(Us.p,{id:i.descriptionId,...o,ref:e})});Ane.displayName=U3t;var Y3t="DialogClose",FMe=j.forwardRef((t,e)=>{const{__scopeDialog:n,...o}=t,i=OB(Y3t,n);return V.jsx(Us.button,{type:"button",...o,ref:e,onClick:wr(t.onClick,()=>i.onOpenChange(!1))})});FMe.displayName=Y3t;function LMe(t){return t?"open":"closed"}var V3t="AlertDialog",[v3o]=_B(V3t,[F3t]),B5=F3t(),z3t=t=>{const{__scopeAlertDialog:e,...n}=t,o=B5(e);return V.jsx(nne,{...o,...n,modal:!0})};z3t.displayName=V3t;var N3o="AlertDialogTrigger",R3o=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=B5(n);return V.jsx(H3t,{...i,...o,ref:e})});R3o.displayName=N3o;var T3o="AlertDialogPortal",J3t=t=>{const{__scopeAlertDialog:e,...n}=t,o=B5(e);return V.jsx(one,{...o,...n})};J3t.displayName=T3o;var k3o="AlertDialogOverlay",q3t=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=B5(n);return V.jsx(lO,{...i,...o,ref:e})});q3t.displayName=k3o;var W3t="AlertDialogContent",[F3o,L3o]=v3o(W3t),j3t=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,children:o,...i}=t,r=B5(n),A=j.useRef(null),s=mg(e,A),a=j.useRef(null);return V.jsx(F3o,{scope:n,cancelRef:a,children:V.jsx(gO,{role:"alertdialog",...r,...i,ref:s,onOpenAutoFocus:wr(i.onOpenAutoFocus,c=>{c.preventDefault(),a.current?.focus({preventScroll:!0})}),onPointerDownOutside:c=>c.preventDefault(),onInteractOutside:c=>c.preventDefault(),children:o})})});j3t.displayName=W3t;var H3o="AlertDialogTitle",X3t=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=B5(n);return V.jsx(rne,{...i,...o,ref:e})});X3t.displayName=H3o;var G3o="AlertDialogDescription",$3t=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=B5(n);return V.jsx(Ane,{...i,...o,ref:e})});$3t.displayName=G3o;var O3o="AlertDialogAction",Z3t=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,i=B5(n);return V.jsx(FMe,{...i,...o,ref:e})});Z3t.displayName=O3o;var evt="AlertDialogCancel",tvt=j.forwardRef((t,e)=>{const{__scopeAlertDialog:n,...o}=t,{cancelRef:i}=L3o(evt,n),r=B5(n),A=mg(e,i);return V.jsx(FMe,{...r,...o,ref:A})});tvt.displayName=evt;var K3o=z3t,U3o=J3t,nvt=q3t,ovt=j3t,ivt=Z3t,rvt=tvt,Avt=X3t,svt=$3t;const avt=K3o,Y3o=U3o,cvt=j.forwardRef(({className:t,...e},n)=>V.jsx(nvt,{className:Ui("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",t),...e,ref:n}));cvt.displayName=nvt.displayName;const HMe=j.forwardRef(({className:t,...e},n)=>V.jsxs(Y3o,{children:[V.jsx(cvt,{}),V.jsx(ovt,{ref:n,className:Ui("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",t),...e})]}));HMe.displayName=ovt.displayName;const GMe=({className:t,...e})=>V.jsx("div",{className:Ui("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});GMe.displayName="AlertDialogHeader";const OMe=({className:t,...e})=>V.jsx("div",{className:Ui("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});OMe.displayName="AlertDialogFooter";const KMe=j.forwardRef(({className:t,...e},n)=>V.jsx(Avt,{ref:n,className:Ui("rf-text-lg rf-font-semibold",t),...e}));KMe.displayName=Avt.displayName;const UMe=j.forwardRef(({className:t,...e},n)=>V.jsx(svt,{ref:n,className:Ui("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));UMe.displayName=svt.displayName;const V3o=j.forwardRef(({className:t,...e},n)=>V.jsx(ivt,{ref:n,className:Ui($7(),t),...e}));V3o.displayName=ivt.displayName;const YMe=j.forwardRef(({className:t,...e},n)=>V.jsx(rvt,{ref:n,className:Ui($7({variant:"outline"}),"rf-mt-2 sm:rf-mt-0",t),...e}));YMe.displayName=rvt.displayName;function z3o(t){const e=j.useRef({value:t,previous:t});return j.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var sne="Checkbox",[J3o]=_B(sne),[q3o,VMe]=J3o(sne);function W3o(t){const{__scopeCheckbox:e,checked:n,children:o,defaultChecked:i,disabled:r,form:A,name:s,onCheckedChange:a,required:c,value:l="on",internal_do_not_use_render:g}=t,[u,d]=Lb({prop:n,defaultProp:i??!1,onChange:a,caller:sne}),[h,_]=j.useState(null),[p,m]=j.useState(null),I=j.useRef(!1),C=h?!!A||!!h.closest("form"):!0,f={checked:u,disabled:r,setChecked:d,control:h,setControl:_,name:s,form:A,value:l,hasConsumerStoppedPropagationRef:I,required:c,defaultChecked:YD(i)?!1:i,isFormControl:C,bubbleInput:p,setBubbleInput:m};return V.jsx(q3o,{scope:e,...f,children:j3o(g)?g(f):o})}var lvt="CheckboxTrigger",gvt=j.forwardRef(({__scopeCheckbox:t,onKeyDown:e,onClick:n,...o},i)=>{const{control:r,value:A,disabled:s,checked:a,required:c,setControl:l,setChecked:g,hasConsumerStoppedPropagationRef:u,isFormControl:d,bubbleInput:h}=VMe(lvt,t),_=mg(i,l),p=j.useRef(a);return j.useEffect(()=>{const m=r?.form;if(m){const I=()=>g(p.current);return m.addEventListener("reset",I),()=>m.removeEventListener("reset",I)}},[r,g]),V.jsx(Us.button,{type:"button",role:"checkbox","aria-checked":YD(a)?"mixed":a,"aria-required":c,"data-state":mvt(a),"data-disabled":s?"":void 0,disabled:s,value:A,...o,ref:_,onKeyDown:wr(e,m=>{m.key==="Enter"&&m.preventDefault()}),onClick:wr(n,m=>{g(I=>YD(I)?!0:!I),h&&d&&(u.current=m.isPropagationStopped(),u.current||m.stopPropagation())})})});gvt.displayName=lvt;var zMe=j.forwardRef((t,e)=>{const{__scopeCheckbox:n,name:o,checked:i,defaultChecked:r,required:A,disabled:s,value:a,onCheckedChange:c,form:l,...g}=t;return V.jsx(W3o,{__scopeCheckbox:n,checked:i,defaultChecked:r,disabled:s,required:A,onCheckedChange:c,name:o,form:l,value:a,internal_do_not_use_render:({isFormControl:u})=>V.jsxs(V.Fragment,{children:[V.jsx(gvt,{...g,ref:e,__scopeCheckbox:n}),u&&V.jsx(_vt,{__scopeCheckbox:n})]})})});zMe.displayName=sne;var uvt="CheckboxIndicator",hvt=j.forwardRef((t,e)=>{const{__scopeCheckbox:n,forceMount:o,...i}=t,r=VMe(uvt,n);return V.jsx(Ry,{present:o||YD(r.checked)||r.checked===!0,children:V.jsx(Us.span,{"data-state":mvt(r.checked),"data-disabled":r.disabled?"":void 0,...i,ref:e,style:{pointerEvents:"none",...t.style}})})});hvt.displayName=uvt;var dvt="CheckboxBubbleInput",_vt=j.forwardRef(({__scopeCheckbox:t,...e},n)=>{const{control:o,hasConsumerStoppedPropagationRef:i,checked:r,defaultChecked:A,required:s,disabled:a,name:c,value:l,form:g,bubbleInput:u,setBubbleInput:d}=VMe(dvt,t),h=mg(n,d),_=z3o(r),p=rSt(o);j.useEffect(()=>{const I=u;if(!I)return;const C=window.HTMLInputElement.prototype,y=Object.getOwnPropertyDescriptor(C,"checked").set,B=!i.current;if(_!==r&&y){const x=new Event("click",{bubbles:B});I.indeterminate=YD(r),y.call(I,YD(r)?!1:r),I.dispatchEvent(x)}},[u,_,r,i]);const m=j.useRef(YD(r)?!1:r);return V.jsx(Us.input,{type:"checkbox","aria-hidden":!0,defaultChecked:A??m.current,required:s,disabled:a,name:c,value:l,form:g,...e,tabIndex:-1,ref:h,style:{...e.style,...p,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});_vt.displayName=dvt;function j3o(t){return typeof t=="function"}function YD(t){return t==="indeterminate"}function mvt(t){return YD(t)?"indeterminate":t?"checked":"unchecked"}const uO=j.forwardRef(({className:t,...e},n)=>V.jsx(zMe,{ref:n,className:Ui("rf-peer rf-h-4 rf-w-4 rf-shrink-0 rf-rounded-sm rf-border rf-border-zinc-200 rf-border-zinc-900 rf-shadow focus-visible:rf-outline-none focus-visible:rf-ring-1 focus-visible:rf-ring-zinc-950 disabled:rf-cursor-not-allowed disabled:rf-opacity-50 data-[state=checked]:rf-bg-zinc-900 data-[state=checked]:rf-text-zinc-50 dark:rf-border-zinc-800 dark:rf-border-zinc-50 dark:focus-visible:rf-ring-zinc-300 dark:data-[state=checked]:rf-bg-zinc-50 dark:data-[state=checked]:rf-text-zinc-900",t),...e,children:V.jsx(hvt,{className:Ui("rf-flex rf-items-center rf-justify-center rf-text-current"),children:V.jsx(r3,{className:"rf-h-4 rf-w-4"})})}));uO.displayName=zMe.displayName;const PN=nne,X3o=one,pvt=j.forwardRef(({className:t,...e},n)=>V.jsx(lO,{className:Ui("rf-fixed rf-inset-0 rf-z-50 rf-bg-black/80 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0",t),...e,ref:n}));pvt.displayName=lO.displayName;const f3=j.forwardRef(({className:t,children:e,showOverlay:n=!0,...o},i)=>V.jsxs(X3o,{children:[V.jsx(pvt,{className:Ui(n?"":"rf-hidden")}),V.jsx(gO,{ref:i,className:Ui("rf-fixed rf-left-[50%] rf-top-[50%] rf-z-50 rf-grid rf-w-full rf-max-w-lg rf-translate-x-[-50%] rf-translate-y-[-50%] rf-gap-4 rf-border rf-border-zinc-200 rf-bg-white rf-p-6 rf-shadow-lg rf-duration-200 data-[state=open]:rf-animate-in data-[state=closed]:rf-animate-out data-[state=closed]:rf-fade-out-0 data-[state=open]:rf-fade-in-0 data-[state=closed]:rf-zoom-out-95 data-[state=open]:rf-zoom-in-95 data-[state=closed]:rf-slide-out-to-left-1/2 data-[state=closed]:rf-slide-out-to-top-[48%] data-[state=open]:rf-slide-in-from-left-1/2 data-[state=open]:rf-slide-in-from-top-[48%] sm:rf-rounded-lg dark:rf-border-zinc-800 dark:rf-bg-zinc-950",t),...o,children:e})]}));f3.displayName=gO.displayName;const y3=({className:t,...e})=>V.jsx("div",{className:Ui("rf-flex rf-flex-col rf-space-y-2 rf-text-center sm:rf-text-left",t),...e});y3.displayName="DialogHeader";const hO=({className:t,...e})=>V.jsx("div",{className:Ui("rf-flex rf-flex-col-reverse sm:rf-flex-row sm:rf-justify-end sm:rf-space-x-2",t),...e});hO.displayName="DialogFooter";const E3=j.forwardRef(({className:t,...e},n)=>V.jsx(rne,{ref:n,className:Ui("rf-text-lg rf-font-semibold",t),...e}));E3.displayName=rne.displayName;const vN=j.forwardRef(({className:t,...e},n)=>V.jsx(Ane,{ref:n,className:Ui("rf-text-sm rf-text-zinc-500 dark:rf-text-zinc-400",t),...e}));vN.displayName=Ane.displayName;const ane={"tscircuit.com":{label:"tscircuit.com",placeholder:"Search tscircuit packages...",emptyMessage:"No packages found"},jlcpcb:{label:"JLCPCB Parts",placeholder:"Search JLCPCB parts (e.g. C14663)...",emptyMessage:"No parts found"},kicad:{label:"KiCad Footprints",placeholder:"Search KiCad footprints...",emptyMessage:"No footprints found"}},$3o="https://cdn.jsdelivr.net/npm/easyeda@latest/dist/browser/index.js";let JMe=null;const qMe=async()=>(JMe||(JMe=import($3o)),JMe),Z3o=t=>(e,n)=>{const o=new Headers(n?.headers),i={};return o.forEach((r,A)=>{i[A]=r}),fetch(`${t?.apiBase??zC}/proxy`,{...n,headers:{...i,"X-Target-Url":e.toString(),"X-Sender-Origin":i.origin??"","X-Sender-Host":i.host??"https://easyeda.com","X-Sender-Referer":i.referer??"","X-Sender-User-Agent":i["user-agent"]??"","X-Sender-Cookie":i.cookie??"",authority:i.authority??"","content-type":i["content-type"]??"",...t?.headers}})},evo=async(t,e=10)=>{const n=encodeURIComponent(t),o=await fetch(`https://jlcsearch.tscircuit.com/api/search?limit=${e}&q=${n}`);if(!o.ok)throw new Error(`JLCPCB API error: ${o.status}`);return(await o.json()).components??[]},tvo=t=>({lcscId:t.lcsc,manufacturer:t.mfr,description:t.description,partNumber:`C${t.lcsc}`,package:t.package,price:t.price,stock:t.stock,isBasic:t.is_basic}),Ivt=async(t,e)=>{const{fetchEasyEDAComponent:n}=await qMe();return n(t,{fetch:Z3o(e),includeModelMetadata:e?.includeModelMetadata})},nvo=async(t,e)=>{const{convertRawEasyToTsx:n}=await qMe(),o=await Ivt(t,e);return n({rawEasy:o})},ovo=async(t,e)=>{const{EasyEdaJsonSchema:n,convertEasyEdaJsonToCircuitJson:o}=await qMe(),i=await Ivt(t,{...e,includeModelMetadata:!1}),r=n.parse(i);return o(r,{shouldRecenter:!0,showDesignator:!0,useModelCdn:!1})};function VD(t){return Array.isArray?Array.isArray(t):fvt(t)==="[object Array]"}function ivo(t){if(typeof t=="string")return t;if(typeof t=="bigint")return t.toString();const e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function WMe(t){return t==null?"":ivo(t)}function ZI(t){return typeof t=="string"}function cne(t){return typeof t=="number"}function rvo(t){return t===!0||t===!1||Avo(t)&&fvt(t)=="[object Boolean]"}function Cvt(t){return typeof t=="object"}function Avo(t){return Cvt(t)&&t!==null}function eE(t){return t!=null}function lne(t){return!t.trim().length}function fvt(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const svo="Incorrect 'index' type",jMe="Invalid doc index: must be a non-negative integer within the bounds of the docs array",avo=t=>`Invalid value for key ${t}`,cvo=t=>`Pattern length exceeds max of ${t}.`,lvo=t=>`Missing ${t} property in key`,gvo=t=>`Property 'weight' in key '${t}' must be a positive integer`,uvo="Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.",yvt=Object.prototype.hasOwnProperty;var hvo=class{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(n=>{const o=Evt(n);this._keys.push(o),this._keyMap[o.id]=o,e+=o.weight}),this._keys.forEach(n=>{n.weight/=e})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};function Evt(t){let e=null,n=null,o=null,i=1,r=null;if(ZI(t)||VD(t))o=t,e=Bvt(t),n=gne(t);else{if(!yvt.call(t,"name"))throw new Error(lvo("name"));const A=t.name;if(o=A,yvt.call(t,"weight")&&t.weight!==void 0&&(i=t.weight,i<=0))throw new Error(gvo(gne(A)));e=Bvt(A),n=gne(A),r=t.getFn??null}return{path:e,id:n,weight:i,src:o,getFn:r}}function Bvt(t){return VD(t)?t:t.split(".")}function gne(t){return VD(t)?t.join("."):t}function dvo(t,e){const n=[];let o=!1;const i=(r,A,s,a)=>{if(eE(r))if(!A[s])n.push(a!==void 0?{v:r,i:a}:r);else{const c=r[A[s]];if(!eE(c))return;if(s===A.length-1&&(ZI(c)||cne(c)||rvo(c)||typeof c=="bigint"))n.push(a!==void 0?{v:WMe(c),i:a}:WMe(c));else if(VD(c)){o=!0;for(let l=0,g=c.length;l<g;l+=1)i(c[l],A,s+1,l)}else A.length&&i(c,A,s+1,a)}};return i(t,ZI(e)?e.split("."):e,0),o?n:n[0]}const bA=Object.freeze({...{isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1},...{includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},...{location:0,threshold:.6,distance:100},...{useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:dvo,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1}});function _vo(t){return t>=9&&t<=13||t===32||t===160}function mvo(t=1,e=3){const n=new Map,o=Math.pow(10,e);return{get(i){let r=0,A=!1;for(let a=0;a<i.length;a++)_vo(i.charCodeAt(a))?A=!1:A||(r++,A=!0);if(r===0&&(r=1),n.has(r))return n.get(r);const s=Math.round(o/Math.pow(r,.5*t))/o;return n.set(r,s),s},clear(){n.clear()}}}var XMe=class{constructor({getFn:t=bA.getFn,fieldNormWeight:e=bA.fieldNormWeight}={}){this.norm=mvo(e,3),this.getFn=t,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((e,n)=>{this._keysMap[e.id]=n})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;const t=this.docs.length;this.records=new Array(t);let e=0;if(ZI(this.docs[0]))for(let n=0;n<t;n++){const o=this._createStringRecord(this.docs[n],n);o&&(this.records[e++]=o)}else for(let n=0;n<t;n++)this.records[e++]=this._createObjectRecord(this.docs[n],n);this.records.length=e,this.norm.clear()}add(t,e){if(!Number.isInteger(e)||e<0)throw new Error(jMe);if(ZI(t)){const o=this._createStringRecord(t,e);return o&&this.records.push(o),o}const n=this._createObjectRecord(t,e);return this.records.push(n),n}removeAt(t){if(!Number.isInteger(t)||t<0)throw new Error(jMe);for(let e=0,n=this.records.length;e<n;e+=1)if(this.records[e].i===t){this.records.splice(e,1);break}for(let e=0,n=this.records.length;e<n;e+=1)this.records[e].i>t&&(this.records[e].i-=1)}removeAll(t){const e=new Set;for(const o of t)Number.isInteger(o)&&o>=0&&e.add(o);if(e.size===0)return;this.records=this.records.filter(o=>!e.has(o.i));const n=Array.from(e).sort((o,i)=>o-i);for(const o of this.records){let i=0,r=n.length;for(;i<r;){const A=i+r>>>1;n[A]<o.i?i=A+1:r=A}o.i-=i}}getValueForItemAtKeyId(t,e){return t[this._keysMap[e]]}size(){return this.records.length}_createStringRecord(t,e){return!eE(t)||lne(t)?null:{v:t,i:e,n:this.norm.get(t)}}_createObjectRecord(t,e){const n={i:e,$:{}};for(let o=0,i=this.keys.length;o<i;o++){const r=this.keys[o],A=r.getFn?r.getFn(t):this.getFn(t,r.path);if(eE(A)){if(VD(A)){const s=[];for(let a=0,c=A.length;a<c;a+=1){const l=A[a];if(eE(l)){if(ZI(l)){if(!lne(l)){const g={v:l,i:a,n:this.norm.get(l)};s.push(g)}}else if(eE(l.v)){const g=ZI(l.v)?l.v:WMe(l.v);if(!lne(g)){const u={v:g,i:l.i,n:this.norm.get(g)};s.push(u)}}}}n.$[o]=s}else if(ZI(A)&&!lne(A)){const s={v:A,n:this.norm.get(A)};n.$[o]=s}}}return n}toJSON(){return{keys:this.keys.map(({getFn:t,...e})=>e),records:this.records}}};function xvt(t,e,{getFn:n=bA.getFn,fieldNormWeight:o=bA.fieldNormWeight}={}){const i=new XMe({getFn:n,fieldNormWeight:o});return i.setKeys(t.map(Evt)),i.setSources(e),i.create(),i}function pvo(t,{getFn:e=bA.getFn,fieldNormWeight:n=bA.fieldNormWeight}={}){const{keys:o,records:i}=t,r=new XMe({getFn:e,fieldNormWeight:n});return r.setKeys(o),r.setIndexRecords(i),r}function Ivo(t=[],e=bA.minMatchCharLength){const n=[];let o=-1,i=-1,r=0;for(let A=t.length;r<A;r+=1){const s=t[r];s&&o===-1?o=r:!s&&o!==-1&&(i=r-1,i-o+1>=e&&n.push([o,i]),o=-1)}return t[r-1]&&r-o>=e&&n.push([o,r-1]),n}function Cvo(t,e,n,{location:o=bA.location,distance:i=bA.distance,threshold:r=bA.threshold,findAllMatches:A=bA.findAllMatches,minMatchCharLength:s=bA.minMatchCharLength,includeMatches:a=bA.includeMatches,ignoreLocation:c=bA.ignoreLocation}={}){if(e.length>32)throw new Error(cvo(32));const l=e.length,g=t.length,u=Math.max(0,Math.min(o,g));let d=r,h=u;const _=(M,w)=>{const k=M/l;if(c)return k;const N=Math.abs(u-w);return i?k+N/i:N?1:k},p=s>1||a,m=p?Array(g):[];let I;for(;(I=t.indexOf(e,h))>-1;){const M=_(0,I);if(d=Math.min(M,d),h=I+l,p){let w=0;for(;w<l;)m[I+w]=1,w+=1}}h=-1;let C=[],f=1,y=0,B=l+g;const x=1<<l-1;for(let M=0;M<l;M+=1){let w=0,k=B;for(;w<k;)_(M,u+k)<=d?w=k:B=k,k=Math.floor((B-w)/2+w);B=k;let N=Math.max(1,u-k+1);const G=A?g:Math.min(u+k,g)+l,H=Array(G+2);H[G+1]=(1<<M)-1;for(let U=G;U>=N;U-=1){const J=U-1,W=n[t[J]];if(H[U]=(H[U+1]<<1|1)&W,M&&(H[U]|=(C[U+1]|C[U])<<1|1|C[U+1]),H[U]&x&&(f=_(M,J),f<=d)){if(d=f,h=J,y=M,h<=u)break;N=Math.max(1,2*u-h)}}if(_(M+1,u)>d)break;C=H}if(p&&h>=0){const M=Math.min(g-1,h+l-1+y);for(let w=h;w<=M;w+=1)n[t[w]]&&(m[w]=1)}const S={isMatch:h>=0,score:Math.max(.001,f)};if(p){const M=Ivo(m,s);M.length?a&&(S.indices=M):S.isMatch=!1}return S}function fvo(t){const e={};for(let n=0,o=t.length;n<o;n+=1){const i=t.charAt(n);e[i]=(e[i]||0)|1<<o-n-1}return e}function $Me(t){if(t.length<=1)return t;t.sort((n,o)=>n[0]-o[0]||n[1]-o[1]);const e=[t[0]];for(let n=1,o=t.length;n<o;n+=1){const i=e[e.length-1],r=t[n];r[0]<=i[1]+1?i[1]=Math.max(i[1],r[1]):e.push(r)}return e}const Qvt={ł:"l",Ł:"L",đ:"d",Đ:"D",ø:"o",Ø:"O",ħ:"h",Ħ:"H",ŧ:"t",Ŧ:"T",ı:"i",ß:"ss"},yvo=new RegExp("["+Object.keys(Qvt).join("")+"]","g"),dO=typeof String.prototype.normalize=="function"?t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"").replace(yvo,e=>Qvt[e]):t=>t;var ZMe=class{constructor(t,{location:e=bA.location,threshold:n=bA.threshold,distance:o=bA.distance,includeMatches:i=bA.includeMatches,findAllMatches:r=bA.findAllMatches,minMatchCharLength:A=bA.minMatchCharLength,isCaseSensitive:s=bA.isCaseSensitive,ignoreDiacritics:a=bA.ignoreDiacritics,ignoreLocation:c=bA.ignoreLocation}={}){if(this.options={location:e,threshold:n,distance:o,includeMatches:i,findAllMatches:r,minMatchCharLength:A,isCaseSensitive:s,ignoreDiacritics:a,ignoreLocation:c},t=s?t:t.toLowerCase(),t=a?dO(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const l=(u,d)=>{this.chunks.push({pattern:u,alphabet:fvo(u),startIndex:d})},g=this.pattern.length;if(g>32){let u=0;const d=g%32,h=g-d;for(;u<h;)l(this.pattern.substr(u,32),u),u+=32;if(d){const _=g-32;l(this.pattern.substr(_),_)}}else l(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o}=this.options;if(t=e?t:t.toLowerCase(),t=n?dO(t):t,this.pattern===t){if(t.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};const h={isMatch:!0,score:0};return o&&(h.indices=[[0,t.length-1]]),h}const{location:i,distance:r,threshold:A,findAllMatches:s,minMatchCharLength:a,ignoreLocation:c}=this.options,l=[];let g=0,u=!1;this.chunks.forEach(({pattern:h,alphabet:_,startIndex:p})=>{const{isMatch:m,score:I,indices:C}=Cvo(t,h,_,{location:i+p,distance:r,threshold:A,findAllMatches:s,minMatchCharLength:a,includeMatches:o,ignoreLocation:c});m&&(u=!0),g+=I,m&&C&&l.push(...C)});const d={isMatch:u,score:u?g/this.chunks.length:1};return u&&o&&(d.indices=$Me(l)),d}};const Evo=new Set(["fuzzy","include"]);function Bvo(t){return t.startsWith("inverse")}const ewe=[{type:"exact",multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:t=>({type:"exact",search(e){const n=e===t;return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"include",multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:t=>({type:"include",search(e){let n=0,o;const i=[],r=t.length;for(;(o=e.indexOf(t,n))>-1;)n=o+r,i.push([o,n-1]);const A=!!i.length;return{isMatch:A,score:A?0:1,indices:i}}})},{type:"prefix-exact",multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:t=>({type:"prefix-exact",search(e){const n=e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}})},{type:"inverse-prefix-exact",multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:t=>({type:"inverse-prefix-exact",search(e){const n=!e.startsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"inverse-suffix-exact",multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:t=>({type:"inverse-suffix-exact",search(e){const n=!e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"suffix-exact",multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:t=>({type:"suffix-exact",search(e){const n=e.endsWith(t);return{isMatch:n,score:n?0:1,indices:[e.length-t.length,e.length-1]}}})},{type:"inverse-exact",multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:t=>({type:"inverse-exact",search(e){const n=e.indexOf(t)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}})},{type:"fuzzy",multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(t,e={})=>{const n=new ZMe(t,{location:e.location??bA.location,threshold:e.threshold??bA.threshold,distance:e.distance??bA.distance,includeMatches:e.includeMatches??bA.includeMatches,findAllMatches:e.findAllMatches??bA.findAllMatches,minMatchCharLength:e.minMatchCharLength??bA.minMatchCharLength,isCaseSensitive:e.isCaseSensitive??bA.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics??bA.ignoreDiacritics,ignoreLocation:e.ignoreLocation??bA.ignoreLocation});return{type:"fuzzy",search(o){return n.searchIn(o)}}}}],Svt=ewe.length,xvo="\0",Qvo="|";function Svo(t){const e=[],n=t.length;let o=0;for(;o<n;){for(;o<n&&t[o]===" ";)o++;if(o>=n)break;let i=o;for(;i<n&&t[i]!==" "&&t[i]!=='"';)i++;if(i<n&&t[i]==='"'){for(i++;i<n;){if(t[i]==='"'){const r=i+1;if(r>=n||t[r]===" "){i++;break}if(t[r]==="$"&&(r+1>=n||t[r+1]===" ")){i+=2;break}}i++}e.push(t.substring(o,i)),o=i}else{for(;i<n&&t[i]!==" ";)i++;e.push(t.substring(o,i)),o=i}}return e}function bvt(t,e){const n=t.match(e);return n?n[1]:null}function bvo(t,e={}){return t.replace(/\\\|/g,xvo).split(Qvo).map(n=>{const o=Svo(n.replace(/\u0000/g,"|").trim()).filter(r=>r&&!!r.trim()),i=[];for(let r=0,A=o.length;r<A;r+=1){const s=o[r];let a=!1,c=-1;for(;!a&&++c<Svt;){const l=ewe[c],g=bvt(s,l.multiRegex);g&&(i.push(l.create(g,e)),a=!0)}if(!a)for(c=-1;++c<Svt;){const l=ewe[c],g=bvt(s,l.singleRegex);if(g){i.push(l.create(g,e));break}}}return i})}var Dvo=class{constructor(t,{isCaseSensitive:e=bA.isCaseSensitive,ignoreDiacritics:n=bA.ignoreDiacritics,includeMatches:o=bA.includeMatches,minMatchCharLength:i=bA.minMatchCharLength,ignoreLocation:r=bA.ignoreLocation,findAllMatches:A=bA.findAllMatches,location:s=bA.location,threshold:a=bA.threshold,distance:c=bA.distance}={}){this.query=null,this.options={isCaseSensitive:e,ignoreDiacritics:n,includeMatches:o,minMatchCharLength:i,findAllMatches:A,ignoreLocation:r,location:s,threshold:a,distance:c},t=e?t:t.toLowerCase(),t=n?dO(t):t,this.pattern=t,this.query=bvo(this.pattern,this.options)}static condition(t,e){return e.useExtendedSearch}searchIn(t){const e=this.query;if(!e)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:o,ignoreDiacritics:i}=this.options;t=o?t:t.toLowerCase(),t=i?dO(t):t;let r=0;const A=[];let s=0,a=!1;for(let c=0,l=e.length;c<l;c+=1){const g=e[c];A.length=0,r=0,a=!1;for(let u=0,d=g.length;u<d;u+=1){const h=g[u],{isMatch:_,indices:p,score:m}=h.search(t);if(_)r+=1,s+=m,Bvo(h.type)&&(a=!0),n&&(Evo.has(h.type)?A.push(...p):A.push(p));else{s=0,r=0,A.length=0,a=!1;break}}if(r){const u={isMatch:!0,score:s/r};return a&&(u.hasInverse=!0),n&&(u.indices=$Me(A)),u}}return{isMatch:!1,score:1}}};const twe=[];function nwe(...t){twe.push(...t)}function une(t,e){for(let n=0,o=twe.length;n<o;n+=1){const i=twe[n];if(i.condition(t,e))return new i(t,e)}return new ZMe(t,e)}const hne={AND:"$and",OR:"$or"},owe={PATH:"$path",PATTERN:"$val"},iwe=t=>!!(t[hne.AND]||t[hne.OR]),Mvo=t=>!!t[owe.PATH],wvo=t=>!VD(t)&&Cvt(t)&&!iwe(t),Dvt=t=>({[hne.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function Mvt(t,e,{auto:n=!0}={}){const o=i=>{if(ZI(i)){const a={keyId:null,pattern:i};return n&&(a.searcher=une(i,e)),a}const r=Object.keys(i),A=Mvo(i);if(!A&&r.length>1&&!iwe(i))return o(Dvt(i));if(wvo(i)){const a=A?i[owe.PATH]:r[0],c=A?i[owe.PATTERN]:i[a];if(!ZI(c))throw new Error(avo(a));const l={keyId:gne(a),pattern:c};return n&&(l.searcher=une(c,e)),l}const s={children:[],operator:r[0]};return r.forEach(a=>{const c=i[a];VD(c)&&c.forEach(l=>{s.children.push(o(l))})}),s};return iwe(t)||(t=Dvt(t)),o(t)}function rwe(t,{ignoreFieldNorm:e=bA.ignoreFieldNorm}){let n=1;return t.forEach(({key:o,norm:i,score:r})=>{const A=o?o.weight:null;n*=Math.pow(r===0&&A?Number.EPSILON:r,(A||1)*(e?1:i))}),n}function Pvo(t,{ignoreFieldNorm:e=bA.ignoreFieldNorm}){t.forEach(n=>{n.score=rwe(n.matches,{ignoreFieldNorm:e})})}var vvo=class{constructor(t,e){this.limit=t,this.heap=[],this.comparator=e}get size(){return this.heap.length}insert(t){this.size<this.limit?(this.heap.push(t),this._bubbleUp(this.size-1)):this.comparator(t,this.heap[0])<0&&(this.heap[0]=t,this._sinkDown(0))}extractSorted(){return this.heap.sort(this.comparator)}_bubbleUp(t){const e=this.heap;for(;t>0;){const n=t-1>>1;if(this.comparator(e[t],e[n])<=0)break;const o=e[t];e[t]=e[n],e[n]=o,t=n}}_sinkDown(t){const e=this.heap,n=e.length;let o=t;do{t=o;const i=2*t+1,r=2*t+2;if(i<n&&this.comparator(e[i],e[o])>0&&(o=i),r<n&&this.comparator(e[r],e[o])>0&&(o=r),o!==t){const A=e[t];e[t]=e[o],e[o]=A}}while(o!==t)}};function Nvo(t){const e=[];return t.matches.forEach(n=>{if(!eE(n.indices)||!n.indices.length)return;const o={indices:n.indices,value:n.value};n.key&&(o.key=n.key.id),n.idx>-1&&(o.refIndex=n.idx),e.push(o)}),e}function Rvo(t,e,{includeMatches:n=bA.includeMatches,includeScore:o=bA.includeScore}={}){return t.map(i=>{const{idx:r}=i,A={item:e[r],refIndex:r};return n&&(A.matches=Nvo(i)),o&&(A.score=i.score),A})}const Tvo=/[\p{L}\p{M}\p{N}_]+/gu,wvt=new WeakSet;function kvo(t){wvt.has(t)||(wvt.add(t),console.warn(`[Fuse] tokenize regex ${t} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`))}function Fvo(t){if(typeof t=="function"){let e=!1;return n=>{const o=t(n);if(!e&&(e=!0,!Array.isArray(o)||o.some(i=>typeof i!="string")))throw new Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(o)?"array containing non-strings":typeof o}.`);return o}}return t instanceof RegExp?(t.global||kvo(t),e=>e.match(t)||[]):e=>e.match(Tvo)||[]}function Awe({isCaseSensitive:t=!1,ignoreDiacritics:e=!1,tokenize:n}={}){const o=Fvo(n);return{tokenize(i){return t||(i=i.toLowerCase()),e&&(i=dO(i)),o(i)}}}var Lvo=class{static condition(t,e){return e.useTokenSearch}constructor(t,e){this.options=e,this.analyzer=Awe({isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,tokenize:e.tokenize});const n=this.analyzer.tokenize(t),{df:o,fieldCount:i}=e._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(const r of n){this.termSearchers.push(new ZMe(r,{location:e.location,threshold:e.threshold,distance:e.distance,includeMatches:e.includeMatches,findAllMatches:e.findAllMatches,minMatchCharLength:e.minMatchCharLength,isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,ignoreLocation:!0}));const A=o.get(r)||0,s=Math.log(1+(i-A+.5)/(A+.5));this.idfWeights.push(s)}this.combineAll=e.tokenMatch==="all",this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(t){if(!this.termSearchers.length)return{isMatch:!1,score:1};const e=[];let n=0,o=0,i=0,r=0;const A=this.combineAll&&!this.useMask?new Set:null;for(let c=0;c<this.termSearchers.length;c++){const l=this.termSearchers[c].searchIn(t),g=this.idfWeights[c];o+=g,l.isMatch&&(i++,n+=g*(1-l.score),l.indices&&e.push(...l.indices),this.combineAll&&(this.useMask?r|=1<<c:A.add(c)))}if(i===0)return{isMatch:!1,score:1};const s=o>0?1-n/o:0,a={isMatch:!0,score:Math.max(.001,s)};return this.options.includeMatches&&e.length&&(a.indices=$Me(e)),this.combineAll&&(this.useMask?a.matchedMask=r:a.matchedTerms=A,a.termCount=this.numTerms),a}};function swe(t,e,n,o){const i=o.tokenize(e);if(!i.length)return;t.fieldCount++,t.docFieldCount.set(n,(t.docFieldCount.get(n)||0)+1);const r=new Set(i);let A=t.docTermFieldHits.get(n);A||(A=new Map,t.docTermFieldHits.set(n,A));for(const s of r)A.set(s,(A.get(s)||0)+1),t.df.set(s,(t.df.get(s)||0)+1)}function Pvt(t,e,n,o){const{i,v:r,$:A}=e;if(r!==void 0){swe(t,r,i,o);return}if(A)for(let s=0;s<n;s++){const a=A[s];if(a)if(Array.isArray(a))for(const c of a)swe(t,c.v,i,o);else swe(t,a.v,i,o)}}function Hvo(t,e,n){const o={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(const i of t)Pvt(o,i,e,n);return o}function Gvo(t,e,n,o){Pvt(t,e,n,o)}function Ovo(t,e){const n=t.docFieldCount.get(e);if(n===void 0)return;t.fieldCount-=n,t.docFieldCount.delete(e);const o=t.docTermFieldHits.get(e);if(o){for(const[i,r]of o){const A=(t.df.get(i)||0)-r;A<=0?t.df.delete(i):t.df.set(i,A)}t.docTermFieldHits.delete(e)}}function vvt(t,e){if(e.length===0)return;const n=Array.from(new Set(e)).sort((s,a)=>s-a);for(const s of n)Ovo(t,s);const o=s=>{let a=0,c=n.length;for(;a<c;){const l=a+c>>>1;n[l]<s?a=l+1:c=l}return s-a},i=n[0],r=new Map;for(const[s,a]of t.docFieldCount)r.set(s>i?o(s):s,a);t.docFieldCount=r;const A=new Map;for(const[s,a]of t.docTermFieldHits)A.set(s>i?o(s):s,a);t.docTermFieldHits=A}var zD=class{constructor(t,e,n){this.options={...bA,...e},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new hvo(this.options.keys),this._docs=t,this._myIndex=null,this._invertedIndex=null,this.setCollection(t,n),this._lastQuery=null,this._lastSearcher=null}_getSearcher(t){if(this._lastQuery===t)return this._lastSearcher;const e=une(t,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=t,this._lastSearcher=e,e}setCollection(t,e){if(this._docs=t,e&&!(e instanceof XMe))throw new Error(svo);if(this._myIndex=e||xvt(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){const n=Awe({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=Hvo(this._myIndex.records,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}add(t){if(!eE(t))return;this._docs.push(t);const e=this._myIndex.add(t,this._docs.length-1);if(this._invertedIndex&&e){const n=Awe({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});Gvo(this._invertedIndex,e,this._myIndex.keys.length,n)}this._invalidateSearcherCache()}remove(t=()=>!1){const e=[],n=[];for(let o=0,i=this._docs.length;o<i;o+=1)t(this._docs[o],o)&&(e.push(this._docs[o]),n.push(o));if(n.length){this._invertedIndex&&vvt(this._invertedIndex,n);const o=new Set(n);this._docs=this._docs.filter((i,r)=>!o.has(r)),this._myIndex.removeAll(n),this._invalidateSearcherCache()}return e}removeAt(t){if(!Number.isInteger(t)||t<0||t>=this._docs.length)throw new Error(jMe);this._invertedIndex&&vvt(this._invertedIndex,[t]);const e=this._docs.splice(t,1)[0];return this._myIndex.removeAt(t),this._invalidateSearcherCache(),e}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}_normalizedKeys(){return this._myIndex.keys.map(t=>this._keyStore.get(t.id)||t)}search(t,e){const{limit:n=-1}=e||{},{includeMatches:o,includeScore:i,shouldSort:r,sortFn:A,ignoreFieldNorm:s}=this.options;if(ZI(t)&&!t.trim()){let u=this._docs.map((d,h)=>({item:d,refIndex:h}));return cne(n)&&n>-1&&(u=u.slice(0,n)),u}const a=r&&cne(n)&&n>0&&ZI(t),c=A,l=(u,d)=>c(u,d)||u.idx-d.idx;let g;if(a){const u=new vvo(n,l);ZI(this._docs[0])?this._searchStringList(t,{heap:u,ignoreFieldNorm:s}):this._searchObjectList(t,{heap:u,ignoreFieldNorm:s}),g=u.extractSorted()}else g=ZI(t)?ZI(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t),Pvo(g,{ignoreFieldNorm:s}),r&&g.sort(ZI(t)?l:c),cne(n)&&n>-1&&(g=g.slice(0,n));return Rvo(g,this._docs,{includeMatches:o,includeScore:i})}_searchStringList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:r}=this._myIndex,A=e?null:[];return r.forEach(({v:s,i:a,n:c})=>{if(!eE(s))return;const l=o.searchIn(s);if(l.isMatch){const g={score:l.score,value:s,norm:c,indices:l.indices};i&&(g.matchedMask=l.matchedMask,g.matchedTerms=l.matchedTerms,g.termCount=l.termCount);const u=[g];if(!i||this._coversAllTokens(u)){const d={item:s,idx:a,matches:u};e?(d.score=rwe(d.matches,{ignoreFieldNorm:n}),e.insert(d)):A.push(d)}}}),A}_searchLogical(t){const e=Mvt(t,this.options),n=this._normalizedKeys(),o=(s,a,c)=>{if(!("children"in s)){const{keyId:d,searcher:h}=s;let _;return d===null?(_=[],n.forEach((p,m)=>{_.push(...this._findMatches({key:p,value:a[m],searcher:h}))})):_=this._findMatches({key:this._keyStore.get(d),value:this._myIndex.getValueForItemAtKeyId(a,d),searcher:h}),_&&_.length?[{idx:c,item:a,matches:_}]:[]}const{children:l,operator:g}=s,u=[];for(let d=0,h=l.length;d<h;d+=1){const _=l[d],p=o(_,a,c);if(p.length)u.push(...p);else if(g===hne.AND)return[]}return u},i=this._myIndex.records,r=new Map,A=[];return i.forEach(({$:s,i:a})=>{if(eE(s)){const c=o(e,s,a);c.length&&(r.has(a)||(r.set(a,{idx:a,item:s,matches:[]}),A.push(r.get(a))),c.forEach(({matches:l})=>{r.get(a).matches.push(...l)}))}}),A}_searchObjectList(t,{heap:e,ignoreFieldNorm:n}={}){const o=this._getSearcher(t),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:r}=this._myIndex,A=this._normalizedKeys(),s=e?null:[];return r.forEach(({$:a,i:c})=>{if(!eE(a))return;const l=[];let g=!1,u=!1;if(A.forEach((d,h)=>{const _=this._findMatches({key:d,value:a[h],searcher:o});_.length?(l.push(..._),_[0].hasInverse&&(u=!0)):g=!0}),!(u&&g)&&l.length&&(!i||this._coversAllTokens(l))){const d={idx:c,item:a,matches:l};e?(d.score=rwe(d.matches,{ignoreFieldNorm:n}),e.insert(d)):s.push(d)}}),s}_findMatches({key:t,value:e,searcher:n}){if(!eE(e))return[];const o=[];if(VD(e))e.forEach(({v:i,i:r,n:A})=>{if(!eE(i))return;const s=n.searchIn(i);if(s.isMatch){const a={score:s.score,key:t,value:i,idx:r,norm:A,indices:s.indices,hasInverse:s.hasInverse};s.termCount!==void 0&&(a.matchedMask=s.matchedMask,a.matchedTerms=s.matchedTerms,a.termCount=s.termCount),o.push(a)}});else{const{v:i,n:r}=e,A=n.searchIn(i);if(A.isMatch){const s={score:A.score,key:t,value:i,norm:r,indices:A.indices,hasInverse:A.hasInverse};A.termCount!==void 0&&(s.matchedMask=A.matchedMask,s.matchedTerms=A.matchedTerms,s.termCount=A.termCount),o.push(s)}}return o}_coversAllTokens(t){const e=t.length?t[0].termCount:void 0;if(e===void 0)return!0;if(e<=31){let o=0;for(let i=0;i<t.length;i++)o|=t[i].matchedMask||0;return o===2**e-1}const n=new Set;for(let o=0;o<t.length;o++){const i=t[o].matchedTerms;if(i)for(const r of i)n.add(r)}return n.size===e}};zD.version="7.5.0",zD.createIndex=xvt,zD.parseIndex=pvo,zD.config=bA,zD.match=function(t,e,n){if(n&&n.useTokenSearch)throw new Error(uvo);return une(t,{...bA,...n}).searchIn(e)},zD.parseQuery=Mvt,nwe(Dvo),nwe(Lvo),zD.use=function(...t){t.forEach(e=>nwe(e))};var Kvo=zD;const Uvo="https://kicad-mod-cache.tscircuit.com";let awe=null,_O=null,cwe=null;const Yvo=async()=>awe||_O||(_O=fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then(t=>t.json()).then(t=>(awe=t,_O=null,t)),_O),Vvo=async(t,e=20)=>{const n=await Yvo();return cwe||(cwe=new Kvo(n)),cwe.search(t).slice(0,e).map(o=>o.item)},zvo=t=>{const e=t.replace(".pretty/","/").replace(".kicad_mod",""),n=`kicad:${e}`;return{path:t,qualifiedName:n,description:e}},Jvo=t=>t.replace(/^\/+/,"").split("/").map(e=>encodeURIComponent(e)).join("/"),qvo=async t=>{const e=await fetch(`${Uvo}/${Jvo(t)}`);if(!e.ok)throw new Error(`KiCad footprint fetch failed: ${e.status}`);const n=await e.text(),{KicadFootprintToCircuitJsonConverter:o}=await FB("kicad-to-circuit-json"),i=new o;return i.addFile(t.split("/").pop()??"selected-footprint.kicad_mod",n),i.runUntilFinished(),i.getOutput()},Nvt=t=>t?.source==="jlcpcb"||t?.source==="kicad",Wvo=async(t,e)=>{if(t.source==="jlcpcb")return ovo(t.component.partNumber,e?.jlcpcb);if(t.source==="kicad")return qvo(t.footprint.path);throw new Error("Footprint preview is not available for this source")},jvo=({query:t,placeholder:e,isSearching:n,onQueryChange:o,onSubmit:i})=>{const r=j.useCallback(A=>{A.key==="Enter"&&(A.preventDefault(),i())},[i]);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mt-4",children:[V.jsxs("div",{className:"rf-relative rf-flex-grow",children:[V.jsx(X4e,{className:"rf-absolute rf-left-2 rf-top-2.5 rf-h-4 rf-w-4 rf-text-muted-foreground"}),V.jsx(dDe,{placeholder:e,className:"rf-pl-8",spellCheck:!1,autoComplete:"off",value:t,onChange:A=>o(A.target.value),onKeyDown:r})]}),V.jsx(Vs,{onClick:i,disabled:n||t.trim().length<1,className:"sm:rf-px-4 rf-px-3",children:n?V.jsx(RB,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):V.jsxs(V.Fragment,{children:[V.jsx(X4e,{className:"rf-h-4 rf-w-4 sm:rf-hidden"}),V.jsx("span",{className:"rf-hidden sm:rf-inline",children:"Search"})]})})]})},Xvo=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}),$vo=t=>Xvo.format(t),Rvt=t=>{switch(t.source){case"tscircuit.com":{const e=t.package;return`tscircuit-${e.package_id??`${e.org_owner_tscircuit_handle??"unknown"}-${e.unscoped_name??e.name??"package"}`}`}case"jlcpcb":return`jlc-${t.component.lcscId}`;case"kicad":return`kicad-${t.footprint.path}`;default:return"unknown"}},Zvo=t=>{switch(t.source){case"tscircuit.com":return t.package.unscoped_name;case"jlcpcb":return t.component.manufacturer;case"kicad":return t.footprint.qualifiedName}},e6o=t=>{switch(t.source){case"tscircuit.com":return t.package.description||(t.package.org_owner_tscircuit_handle?`Component by ${t.package.org_owner_tscircuit_handle}`:void 0);case"jlcpcb":return t.component.description;case"kicad":return t.footprint.description}},t6o=t=>{switch(t.source){case"tscircuit.com":return t.package.name;case"jlcpcb":return t.component.partNumber;case"kicad":return}},n6o=({results:t,selected:e,onSelect:n,onShowDetails:o})=>{const i=e?Rvt(e):null;return V.jsx("div",{className:"rf-divide-y rf-w-full rf-overflow-hidden",children:t.map(r=>{const A=Rvt(r),s=i===A,a=Zvo(r),c=e6o(r),l=t6o(r),g=r.source==="jlcpcb"?r.component.stock:null,u=r.source==="jlcpcb"?r.component.price:null,d=r.source==="jlcpcb"?r.component.isBasic:null;return V.jsxs("div",{className:`rf-p-3 rf-flex rf-flex-col sm:rf-grid sm:rf-grid-cols-[minmax(0,1fr)_auto] rf-items-start sm:rf-items-center rf-cursor-pointer hover:rf-bg-zinc-100 rf-gap-2 rf-overflow-hidden ${s?"rf-bg-zinc-100":""}`,onClick:()=>n(r),children:[V.jsxs("div",{className:"rf-min-w-0 rf-overflow-hidden rf-w-full",children:[V.jsxs("div",{className:"rf-flex rf-items-start rf-gap-2 rf-min-w-0",children:[V.jsxs("div",{className:"rf-font-medium rf-text-sm rf-truncate rf-flex-1 rf-min-w-0 rf-flex rf-items-center rf-gap-1.5",children:[a,r.source==="jlcpcb"&&d!=null&&V.jsx("span",{className:`rf-text-xs rf-px-1.5 rf-py-0.5 rf-rounded rf-font-medium rf-flex-shrink-0 ${d?"rf-bg-green-100 rf-text-green-700":"rf-bg-orange-100 rf-text-orange-700"}`,children:d?"Basic":"Extended"}),r.source==="tscircuit.com"&&r.package.is_private&&V.jsx(WIo,{className:"rf-ml-1 rf-h-3 rf-w-3 rf-text-zinc-400 rf-flex-shrink-0"})]}),r.source==="jlcpcb"&&g!=null?V.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 sm:rf-hidden",children:[g.toLocaleString()," in stock"]}):null]}),V.jsxs("div",{className:"rf-text-xs rf-text-zinc-500 rf-truncate rf-w-full",children:[l?V.jsx("span",{className:"rf-mr-2",children:l}):null,c]})]}),V.jsxs("div",{children:[r.source==="tscircuit.com"&&o?V.jsx("div",{className:"rf-flex-shrink-0 rf-w-full sm:rf-w-auto",children:V.jsx(Vs,{variant:"outline",size:"sm",className:"rf-text-xs rf-w-full sm:rf-w-auto",onClick:h=>{h.stopPropagation(),o(r)},children:"See Details"})}):r.source==="jlcpcb"&&g!=null?V.jsxs("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0",children:[g.toLocaleString()," in stock"]}):null,u!=null&&V.jsx("div",{className:"rf-hidden sm:rf-block rf-text-xs rf-text-zinc-500 rf-font-medium rf-whitespace-nowrap rf-flex-shrink-0 rf-text-right",children:$vo(u)})]})]},A)})})},o6o=({circuitJson:t,error:e,isLoading:n,height:o})=>V.jsx("section",{className:"rf-flex rf-min-w-0 rf-items-center rf-justify-center",style:{height:o},children:n?V.jsxs("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-gap-2 rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:[V.jsx(RB,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),"Loading preview..."]}):e?V.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-p-4",style:{height:o},children:V.jsxs("div",{className:"rf-flex rf-max-w-[320px] rf-items-start rf-gap-2 rf-text-sm rf-text-zinc-300",children:[V.jsx(QQt,{className:"rf-mt-0.5 rf-h-4 rf-w-4 rf-flex-shrink-0"}),V.jsx("span",{children:e})]})}):t?V.jsx("div",{className:"rf-w-full rf-min-w-0 rf-overflow-hidden",children:V.jsx(B3t,{circuitJson:t,height:o,allowEditing:!1,clickToInteractEnabled:!1,focusOnHover:!1,disablePcbGroups:!0})}):V.jsx("div",{className:"rf-flex rf-w-full rf-items-center rf-justify-center rf-bg-zinc-950 rf-text-sm rf-text-zinc-300",style:{height:o},children:"No preview"})}),Tvt={importComponentDialog:101,importComponentDetailsDialog:102},i6o=({packageResult:t,isOpen:e,onOpenChange:n,isLoading:o,details:i,previewTab:r,onPreviewTabChange:A,isSubmitting:s,onImport:a})=>{const c=t?.package??null,l=c?.latest_pcb_preview_image_url,g=c?.latest_sch_preview_image_url,u=c?.latest_cad_preview_image_url,d=c?.unscoped_name?.split("/").pop()??c?.unscoped_name,h=c?.org_owner_tscircuit_handle??void 0,_=h?`https://tscircuit.com/${h}`:void 0,p=h&&d?`https://tscircuit.com/${h}/${d}`:void 0;return V.jsx(PN,{open:e,onOpenChange:n,children:V.jsxs(f3,{showOverlay:!1,style:{width:"calc(100vw - 2rem)",zIndex:Tvt.importComponentDetailsDialog},className:"rf-max-w-5xl no-scrollbar !rf-overflow-y-auto rf-max-h-[90vh] rf-overflow-hidden rf-flex rf-flex-col rf-rounded-sm",children:[V.jsx(y3,{className:"rf-pb-4 rf-border-b",children:V.jsx("div",{className:"rf-flex rf-items-start rf-justify-between rf-gap-4",children:V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx(E3,{className:"rf-text-xl rf-font-semibold rf-truncate",children:d}),V.jsx(vN,{children:c?.description})]})})}),V.jsxs("div",{className:"rf-flex-1 rf-overflow-y-auto rf-py-4 rf-space-y-6",children:[h?V.jsxs("div",{children:[V.jsx("span",{className:"rf-text-xs rf-font-medium rf-text-gray-500 rf-uppercase rf-tracking-wide",children:"Created by"}),V.jsx("div",{className:"rf-mt-1 rf-text-sm rf-font-medium",children:_?V.jsx("a",{href:_,target:"_blank",rel:"noopener noreferrer",className:"rf-text-black hover:rf-underline",children:h}):h})]}):null,(u||l||g)&&V.jsx(V.Fragment,{children:V.jsxs("div",{children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-4",children:"Preview"}),V.jsxs(TIe,{value:r,onValueChange:m=>A(m),children:[V.jsxs(xX,{className:"rf-inline-flex rf-h-9 rf-items-center rf-justify-center rf-rounded-lg rf-bg-zinc-100 rf-p-1 rf-text-zinc-500 dark:rf-bg-zinc-800 dark:rf-text-zinc-400",children:[l&&V.jsx(Zx,{value:"pcb",children:"PCB"}),g&&V.jsx(Zx,{value:"schematic",children:"Schematic"}),u&&V.jsx(Zx,{value:"3d",children:"3D"})]}),V.jsxs("div",{className:"rf-mt-4",children:[V.jsx(OI,{value:"pcb",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:l?V.jsx("img",{src:l,alt:`${d??"package"} PCB preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),V.jsx(OI,{value:"schematic",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:g?V.jsx("img",{src:g,alt:`${d??"package"} schematic preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null}),V.jsx(OI,{value:"3d",className:"rf-border rf-rounded-lg rf-overflow-hidden rf-bg-gray-50",children:u?V.jsx("img",{src:u,alt:`${d??"package"} 3D preview`,className:"rf-w-full rf-h-full rf-object-contain rf-bg-white rf-p-4"}):null})]})]})]})}),i?.ai_description?V.jsxs("section",{children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"AI Description"}),V.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed",children:i.ai_description})})]}):null,i?.ai_usage_instructions?V.jsxs("section",{children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-mb-3",children:"Usage Instructions"}),V.jsx("div",{className:"rf-bg-gray-50 rf-border rf-border-gray-200 rf-rounded-lg rf-p-4",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-700 rf-leading-relaxed rf-whitespace-pre-wrap",children:i.ai_usage_instructions})})]}):null,o?V.jsxs("div",{className:"rf-flex rf-justify-center rf-items-center rf-gap-2 rf-text-gray-500",children:[V.jsx(RB,{className:"rf-h-4 rf-w-4 rf-animate-spin"}),V.jsx("span",{className:"rf-text-sm",children:"Loading package details..."})]}):null]}),V.jsxs(hO,{className:"rf-pt-4 rf-border-t rf-flex rf-flex-col sm:rf-flex-row rf-justify-between rf-gap-2",children:[V.jsx("div",{className:"rf-flex-1",children:p?V.jsxs(Vs,{variant:"outline",size:"sm",className:"rf-gap-2 rf-w-full sm:rf-w-auto",onClick:()=>window.open(p,"_blank"),children:[V.jsx(KIo,{className:"rf-h-4 rf-w-4"}),"View on tscircuit.com"]}):null}),V.jsxs("div",{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[V.jsx(Vs,{variant:"outline",onClick:()=>n(!1),className:"rf-order-2 sm:rf-order-1",children:"Close"}),V.jsx(Vs,{onClick:a,disabled:s,className:"rf-bg-blue-600 hover:rf-bg-blue-700",children:s?V.jsx(RB,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import Component"})]})]})]})})},r6o=()=>{const[t,e]=j.useState(null),[n,o]=j.useState(!1),i=j.useCallback(async(A,s)=>{o(!0);try{const a=await fetch(`https://api.tscircuit.com/packages/get?name=${encodeURIComponent(`${A}/${s}`)}`);if(!a.ok)throw new Error(`Failed to load package details: ${a.status}`);const c=await a.json();e(c.package??null)}catch(a){console.error("Failed to fetch package details",a),e(null)}finally{o(!1)}},[]),r=j.useCallback(()=>{e(null),o(!1)},[]);return{details:t,isLoading:n,fetchDetails:i,reset:r}},A6o=(t,e)=>{const[n,o]=j.useState({circuitJson:null,error:null,isLoading:!1});return j.useEffect(()=>{if(!t||!Nvt(t)){o({circuitJson:null,error:null,isLoading:!1});return}let i=!1;return o({circuitJson:null,error:null,isLoading:!0}),Wvo(t,e).then(r=>{i||o({circuitJson:r,error:null,isLoading:!1})}).catch(r=>{i||o({circuitJson:null,error:r instanceof Error?r.message:"Failed to load footprint preview",isLoading:!1})}),()=>{i=!0}},[t,e]),n},s6o=async(t,e)=>{const n={"Content-Type":"application/json"};e&&(n.Authorization=`Bearer ${e}`);const o=await fetch("https://registry-api.tscircuit.com/packages/search",{method:"POST",headers:n,body:JSON.stringify({query:t})});if(!o.ok)throw new Error(`tscircuit registry error: ${o.status}`);return(await o.json()).packages??[]},a6o=({sessionToken:t})=>{const[e,n]=j.useState([]),[o,i]=j.useState(!1),[r,A]=j.useState(null),[s,a]=j.useState(!1),c=j.useCallback(async g=>{const u=g.trim();if(!u)return[];i(!0),A(null);try{const h=(await s6o(u,t)).map(_=>({source:"tscircuit.com",package:_}));return n(h),h}catch(d){return console.error("Error searching tscircuit packages",d),n([]),A(d instanceof Error?d.message:"Failed to search tscircuit packages"),[]}finally{i(!1),a(!0)}},[t]),l=j.useCallback(()=>{n([]),i(!1),A(null),a(!1)},[]);return{results:e,isSearching:o,error:r,hasSearched:s,search:c,reset:l}},c6o=t=>{const e=t.trim();return/^C\d+/i.test(e)?e.replace(/^C/i,""):e},l6o=()=>{const[t,e]=j.useState([]),[n,o]=j.useState(!1),[i,r]=j.useState(null),[A,s]=j.useState(!1),a=j.useCallback(async l=>{const g=c6o(l);if(!g)return[];o(!0),r(null);try{const d=(await evo(g,10)).map(h=>({source:"jlcpcb",component:tvo(h)}));return e(d),d}catch(u){return console.error("Error searching JLCPCB components",u),e([]),r(u instanceof Error?u.message:"Failed to search JLCPCB components"),[]}finally{o(!1),s(!0)}},[]),c=j.useCallback(()=>{e([]),o(!1),r(null),s(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:A,search:a,reset:c}},g6o=()=>{const[t,e]=j.useState([]),[n,o]=j.useState(!1),[i,r]=j.useState(null),[A,s]=j.useState(!1),a=j.useCallback(async l=>{const g=l.trim();if(!g)return[];o(!0),r(null);try{const d=(await Vvo(g,20)).map(h=>({source:"kicad",footprint:zvo(h)}));return e(d),d}catch(u){return console.error("Error searching KiCad footprints",u),e([]),r(u instanceof Error?u.message:"Failed to search KiCad footprints"),[]}finally{o(!1),s(!0)}},[]),c=j.useCallback(()=>{e([]),o(!1),r(null),s(!1)},[]);return{results:t,isSearching:n,error:i,hasSearched:A,search:a,reset:c}},u6o=({onTscircuitPackageSelected:t,onJlcpcbComponentTsxLoaded:e,onKicadStringSelected:n})=>{const o=[];return t&&o.push("tscircuit.com"),e&&o.push("jlcpcb"),n&&o.push("kicad"),o},h6o=({isOpen:t,onClose:e,jlcpcbProxyRequestHeaders:n,onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r,jlcpcbProxyApiBase:A,tscircuitSessionToken:s})=>{Zte();const a=j.useMemo(()=>u6o({onKicadStringSelected:o,onTscircuitPackageSelected:i,onJlcpcbComponentTsxLoaded:r}),[o,i,r]),c=a.length>0,l=a.length===1,[g,u]=j.useState(a[0]??"tscircuit.com"),[d,h]=j.useState(""),[_,p]=j.useState(null),{results:m,isSearching:I,error:C,hasSearched:f,search:y,reset:B}=a6o({sessionToken:s}),{results:x,isSearching:S,error:M,hasSearched:w,search:k,reset:N}=l6o(),{results:G,isSearching:H,error:U,hasSearched:J,search:W,reset:X}=g6o(),{details:oe,isLoading:ce,fetchDetails:te,reset:ie}=r6o(),[ae,re]=j.useState(null),[le,ye]=j.useState(!1),[xe,be]=j.useState("pcb"),[he,Se]=j.useState(null),[Ie,He]=j.useState(!1),Je=j.useMemo(()=>({jlcpcb:{headers:n,apiBase:A}}),[A,n]),{circuitJson:et,error:pe,isLoading:$e}=A6o(_,Je),Ge=Nvt(_);j.useEffect(()=>{Se(null)},[_]);const Pe=j.useCallback(()=>{B(),N(),X(),p(null)},[N,X,B]);j.useEffect(()=>{t||(Pe(),h(""),ye(!1),re(null),Se(null))},[t,Pe]),j.useEffect(()=>{h(""),p(null),g==="tscircuit.com"?B():g==="jlcpcb"?N():g==="kicad"&&X()},[g,N,X,B]);const Ue=lt=>{p(lt),re(lt),be("pcb"),ye(!0),ie();const Ct=lt.package.org_owner_tscircuit_handle,Dt=lt.package.unscoped_name;if(Ct&&Dt){const It=Dt.split("/").pop()??Dt;te(Ct,It)}},Ne=async()=>{d.trim()&&(p(null),g==="tscircuit.com"?await y(d):g==="jlcpcb"?await k(d):g==="kicad"&&await W(d))},Ee=async lt=>{try{if(Se(null),He(!0),lt.source==="kicad"){if(!o)throw new Error("KiCad handler not provided");await o({result:lt,footprint:lt.footprint.qualifiedName})}else if(lt.source==="jlcpcb"){if(!r)throw new Error("JLCPCB handler not provided");const Ct=await nvo(lt.component.partNumber,{headers:n,apiBase:A});await r({result:lt,tsx:Ct})}else if(lt.source==="tscircuit.com"){if(!i)throw new Error("tscircuit package handler not provided");const Ct=lt.package.org_owner_tscircuit_handle,Dt=lt.package.unscoped_name;if(!Ct||!Dt)throw new Error("Missing package metadata");const It=Dt.split("/").pop()??Dt,Nt=`@tsci/${Ct}.${It}`;await i({result:lt,fullPackageName:Nt})}return!0}catch(Ct){return console.error("Failed to import component",Ct),Se(Ct instanceof Error?Ct.message:"Failed to import component"),!1}finally{He(!1)}};let Oe=[],Me=!1,ze=null,je=!1;g==="tscircuit.com"?(Oe=m,Me=I,ze=C,je=f):g==="jlcpcb"?(Oe=x,Me=S,ze=M,je=w):g==="kicad"&&(Oe=G,Me=H,ze=U,je=J);const st=async()=>{if(!_)return;await Ee(_)&&(e(),Pe(),h(""))},ct=lt=>{lt||e()},ut=lt=>{ye(lt),lt||re(null)};return V.jsxs(PN,{open:t,onOpenChange:ct,children:[V.jsxs(f3,{style:{width:"calc(100vw - 2rem)",maxWidth:Ge?"min(1120px, calc(100vw - 2rem))":"min(672px, calc(100vw - 2rem))",zIndex:Tvt.importComponentDialog},className:"rf-rounded-sm rf-max-h-[90vh] rf-overflow-y-auto rf-overflow-x-hidden rf-flex rf-flex-col",children:[V.jsxs(y3,{children:[V.jsxs(E3,{className:"rf-text-lg sm:rf-text-xl",children:["Import ",l?ane[g].label:""," ","Component"]}),V.jsx(vN,{className:"rf-text-sm",children:c?"Search for components from available sources.":"Import options are disabled because no handlers were provided."})]}),c?V.jsxs(TIe,{value:g,onValueChange:lt=>u(lt),className:"rf-min-w-0 rf-w-full",children:[!l&&V.jsx(xX,{className:"rf-flex rf-w-full rf-gap-2",children:a.map(lt=>V.jsx(Zx,{value:lt,className:"rf-flex-1 rf-text-xs sm:rf-text-sm",children:ane[lt].label},lt))}),V.jsxs("div",{className:"rf-min-w-0",style:Ge?{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(360px, 0.95fr)",gap:"1.5rem",alignItems:"start"}:void 0,children:[V.jsxs("div",{className:"rf-min-w-0",children:[V.jsx(jvo,{query:d,placeholder:ane[g].placeholder,isSearching:Me,onQueryChange:h,onSubmit:Ne}),V.jsx("div",{className:"no-scrollbar rf-mt-4 rf-flex-1 rf-min-h-[200px] !rf-max-h-[40vh] !rf-overflow-y-auto rf-overflow-x-hidden rf-border rf-rounded-md rf-min-w-0",children:Me?V.jsxs("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:[V.jsx(RB,{className:"rf-h-8 rf-w-8 rf-animate-spin rf-mx-auto rf-mb-2"}),V.jsx("p",{children:"Searching..."})]}):Oe.length>0?V.jsx(n6o,{results:Oe,selected:_,onSelect:p,onShowDetails:g==="tscircuit.com"?Ue:void 0}):V.jsx("div",{className:"rf-p-8 rf-text-center rf-text-zinc-500",children:ze?`Error: ${ze}`:je?ane[g].emptyMessage:"Enter a search term to find components"})})]}),Ge?V.jsx("div",{className:"rf-mt-4",children:V.jsx(o6o,{circuitJson:et,error:pe,isLoading:$e,height:325})}):null]})]}):null,he?V.jsx("div",{className:"rf-text-sm rf-text-red-600 rf-mt-2",children:he}):null,V.jsxs(hO,{className:"rf-flex rf-flex-col sm:rf-flex-row rf-gap-2",children:[V.jsx(Vs,{variant:"outline",onClick:e,className:"rf-order-2 sm:rf-order-1",children:"Cancel"}),V.jsx(Vs,{onClick:st,disabled:!_||Ie,className:"rf-order-1 sm:rf-order-2",children:Ie?V.jsx(RB,{className:"rf-h-4 rf-w-4 rf-animate-spin"}):"Import"})]})]}),V.jsx(i6o,{packageResult:ae,isOpen:le,onOpenChange:ut,isLoading:ce,details:oe,previewTab:xe,onPreviewTabChange:lt=>be(lt),isSubmitting:Ie,onImport:()=>{ae&&Ee(ae).then(lt=>{lt&&(ye(!1),e(),Pe(),h(""))})}})]})},d6o=t=>{const e=t.match(/export const (\w+) =/);if(!e)throw new Error("Could not determine component name from TSX contents");return e[1]},kvt=t=>{const e=M0(A=>A.pushEvent),n=M0(A=>A.upsertFile),o=async({result:A,fullPackageName:s})=>{const c=A.package.unscoped_name??A.package.name;await GA.promise(e({event_type:"INSTALL_PACKAGE",full_package_name:s}),{loading:`Requesting install for "${c}"`,success:`Install requested for "${c}"`,error:l=>`Failed to request install: ${l instanceof Error?l.message:String(l)}`})},i=async({footprint:A})=>{await GA.promise(navigator.clipboard.writeText(A),{loading:`Copying "${A}"`,success:`Copied "${A}" to clipboard`,error:s=>`Failed to copy footprint: ${s instanceof Error?s.message:String(s)}`})},r=async({result:A,tsx:s})=>{const c=`imports/${d6o(s)}.tsx`;await GA.promise(n(c,s),{loading:`Importing ${A.component.partNumber}`,success:`Imported to "${c}"`,error:l=>`Failed to import component: ${l instanceof Error?l.message:String(l)}`})};return V.jsx(h6o,{...t,onTscircuitPackageSelected:o,onKicadStringSelected:i,onJlcpcbComponentTsxLoaded:r})};kvt.displayName="ImportComponentDialogForCli";var lwe={exports:{}},Fvt;function _6o(){return Fvt||(Fvt=1,(function(t,e){var n={env:{},version:""};(function(o){t.exports=o()})(function(){return(function o(i,r,A){function s(l,g){if(!r[l]){if(!i[l]){var u=typeof y4=="function"&&y4;if(!g&&u)return u(l,!0);if(a)return a(l,!0);var d=new Error("Cannot find module '"+l+"'");throw d.code="MODULE_NOT_FOUND",d}var h=r[l]={exports:{}};i[l][0].call(h.exports,function(_){var p=i[l][1][_];return s(p||_)},h,h.exports,o,i,r,A)}return r[l].exports}for(var a=typeof y4=="function"&&y4,c=0;c<A.length;c++)s(A[c]);return s})({1:[function(o,i,r){var A=o("./utils"),s=o("./support"),a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.encode=function(c){for(var l,g,u,d,h,_,p,m=[],I=0,C=c.length,f=C,y=A.getTypeOf(c)!=="string";I<c.length;)f=C-I,u=y?(l=c[I++],g=I<C?c[I++]:0,I<C?c[I++]:0):(l=c.charCodeAt(I++),g=I<C?c.charCodeAt(I++):0,I<C?c.charCodeAt(I++):0),d=l>>2,h=(3&l)<<4|g>>4,_=1<f?(15&g)<<2|u>>6:64,p=2<f?63&u:64,m.push(a.charAt(d)+a.charAt(h)+a.charAt(_)+a.charAt(p));return m.join("")},r.decode=function(c){var l,g,u,d,h,_,p=0,m=0,I="data:";if(c.substr(0,I.length)===I)throw new Error("Invalid base64 input, it looks like a data url.");var C,f=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===a.charAt(64)&&f--,c.charAt(c.length-2)===a.charAt(64)&&f--,f%1!=0)throw new Error("Invalid base64 input, bad content length.");for(C=s.uint8array?new Uint8Array(0|f):new Array(0|f);p<c.length;)l=a.indexOf(c.charAt(p++))<<2|(d=a.indexOf(c.charAt(p++)))>>4,g=(15&d)<<4|(h=a.indexOf(c.charAt(p++)))>>2,u=(3&h)<<6|(_=a.indexOf(c.charAt(p++))),C[m++]=l,h!==64&&(C[m++]=g),_!==64&&(C[m++]=u);return C}},{"./support":30,"./utils":32}],2:[function(o,i,r){var A=o("./external"),s=o("./stream/DataWorker"),a=o("./stream/Crc32Probe"),c=o("./stream/DataLengthProbe");function l(g,u,d,h,_){this.compressedSize=g,this.uncompressedSize=u,this.crc32=d,this.compression=h,this.compressedContent=_}l.prototype={getContentWorker:function(){var g=new s(A.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),u=this;return g.on("end",function(){if(this.streamInfo.data_length!==u.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),g},getCompressedWorker:function(){return new s(A.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},l.createWorkerFrom=function(g,u,d){return g.pipe(new a).pipe(new c("uncompressedSize")).pipe(u.compressWorker(d)).pipe(new c("compressedSize")).withStreamInfo("compression",u)},i.exports=l},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(o,i,r){var A=o("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new A("STORE compression")},uncompressWorker:function(){return new A("STORE decompression")}},r.DEFLATE=o("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(o,i,r){var A=o("./utils"),s=(function(){for(var a,c=[],l=0;l<256;l++){a=l;for(var g=0;g<8;g++)a=1&a?3988292384^a>>>1:a>>>1;c[l]=a}return c})();i.exports=function(a,c){return a!==void 0&&a.length?A.getTypeOf(a)!=="string"?(function(l,g,u,d){var h=s,_=d+u;l^=-1;for(var p=d;p<_;p++)l=l>>>8^h[255&(l^g[p])];return-1^l})(0|c,a,a.length,0):(function(l,g,u,d){var h=s,_=d+u;l^=-1;for(var p=d;p<_;p++)l=l>>>8^h[255&(l^g.charCodeAt(p))];return-1^l})(0|c,a,a.length,0):0}},{"./utils":32}],5:[function(o,i,r){r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(o,i,r){var A=null;A=typeof Promise<"u"?Promise:o("lie"),i.exports={Promise:A}},{lie:37}],7:[function(o,i,r){var A=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",s=o("pako"),a=o("./utils"),c=o("./stream/GenericWorker"),l=A?"uint8array":"array";function g(u,d){c.call(this,"FlateWorker/"+u),this._pako=null,this._pakoAction=u,this._pakoOptions=d,this.meta={}}r.magic="\b\0",a.inherits(g,c),g.prototype.processChunk=function(u){this.meta=u.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(l,u.data),!1)},g.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},g.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},g.prototype._createPako=function(){this._pako=new s[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var u=this;this._pako.onData=function(d){u.push({data:d,meta:u.meta})}},r.compressWorker=function(u){return new g("Deflate",u)},r.uncompressWorker=function(){return new g("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(o,i,r){function A(h,_){var p,m="";for(p=0;p<_;p++)m+=String.fromCharCode(255&h),h>>>=8;return m}function s(h,_,p,m,I,C){var f,y,B=h.file,x=h.compression,S=C!==l.utf8encode,M=a.transformTo("string",C(B.name)),w=a.transformTo("string",l.utf8encode(B.name)),k=B.comment,N=a.transformTo("string",C(k)),G=a.transformTo("string",l.utf8encode(k)),H=w.length!==B.name.length,U=G.length!==k.length,J="",W="",X="",oe=B.dir,ce=B.date,te={crc32:0,compressedSize:0,uncompressedSize:0};_&&!p||(te.crc32=h.crc32,te.compressedSize=h.compressedSize,te.uncompressedSize=h.uncompressedSize);var ie=0;_&&(ie|=8),S||!H&&!U||(ie|=2048);var ae=0,re=0;oe&&(ae|=16),I==="UNIX"?(re=798,ae|=(function(ye,xe){var be=ye;return ye||(be=xe?16893:33204),(65535&be)<<16})(B.unixPermissions,oe)):(re=20,ae|=(function(ye){return 63&(ye||0)})(B.dosPermissions)),f=ce.getUTCHours(),f<<=6,f|=ce.getUTCMinutes(),f<<=5,f|=ce.getUTCSeconds()/2,y=ce.getUTCFullYear()-1980,y<<=4,y|=ce.getUTCMonth()+1,y<<=5,y|=ce.getUTCDate(),H&&(W=A(1,1)+A(g(M),4)+w,J+="up"+A(W.length,2)+W),U&&(X=A(1,1)+A(g(N),4)+G,J+="uc"+A(X.length,2)+X);var le="";return le+=`
|
|
5787
5787
|
\0`,le+=A(ie,2),le+=x.magic,le+=A(f,2),le+=A(y,2),le+=A(te.crc32,4),le+=A(te.compressedSize,4),le+=A(te.uncompressedSize,4),le+=A(M.length,2),le+=A(J.length,2),{fileRecord:u.LOCAL_FILE_HEADER+le+M+J,dirRecord:u.CENTRAL_FILE_HEADER+A(re,2)+le+A(N.length,2)+"\0\0\0\0"+A(ae,4)+A(m,4)+M+J+N}}var a=o("../utils"),c=o("../stream/GenericWorker"),l=o("../utf8"),g=o("../crc32"),u=o("../signature");function d(h,_,p,m){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=_,this.zipPlatform=p,this.encodeFileName=m,this.streamFiles=h,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(d,c),d.prototype.push=function(h){var _=h.meta.percent||0,p=this.entriesCount,m=this._sources.length;this.accumulate?this.contentBuffer.push(h):(this.bytesWritten+=h.data.length,c.prototype.push.call(this,{data:h.data,meta:{currentFile:this.currentFile,percent:p?(_+100*(p-m-1))/p:100}}))},d.prototype.openedSource=function(h){this.currentSourceOffset=this.bytesWritten,this.currentFile=h.file.name;var _=this.streamFiles&&!h.file.dir;if(_){var p=s(h,_,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:p.fileRecord,meta:{percent:0}})}else this.accumulate=!0},d.prototype.closedSource=function(h){this.accumulate=!1;var _=this.streamFiles&&!h.file.dir,p=s(h,_,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(p.dirRecord),_)this.push({data:(function(m){return u.DATA_DESCRIPTOR+A(m.crc32,4)+A(m.compressedSize,4)+A(m.uncompressedSize,4)})(h),meta:{percent:100}});else for(this.push({data:p.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},d.prototype.flush=function(){for(var h=this.bytesWritten,_=0;_<this.dirRecords.length;_++)this.push({data:this.dirRecords[_],meta:{percent:100}});var p=this.bytesWritten-h,m=(function(I,C,f,y,B){var x=a.transformTo("string",B(y));return u.CENTRAL_DIRECTORY_END+"\0\0\0\0"+A(I,2)+A(I,2)+A(C,4)+A(f,4)+A(x.length,2)+x})(this.dirRecords.length,p,h,this.zipComment,this.encodeFileName);this.push({data:m,meta:{percent:100}})},d.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},d.prototype.registerPrevious=function(h){this._sources.push(h);var _=this;return h.on("data",function(p){_.processChunk(p)}),h.on("end",function(){_.closedSource(_.previous.streamInfo),_._sources.length?_.prepareNextSource():_.end()}),h.on("error",function(p){_.error(p)}),this},d.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},d.prototype.error=function(h){var _=this._sources;if(!c.prototype.error.call(this,h))return!1;for(var p=0;p<_.length;p++)try{_[p].error(h)}catch{}return!0},d.prototype.lock=function(){c.prototype.lock.call(this);for(var h=this._sources,_=0;_<h.length;_++)h[_].lock()},i.exports=d},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(o,i,r){var A=o("../compressions"),s=o("./ZipFileWorker");r.generateWorker=function(a,c,l){var g=new s(c.streamFiles,l,c.platform,c.encodeFileName),u=0;try{a.forEach(function(d,h){u++;var _=(function(C,f){var y=C||f,B=A[y];if(!B)throw new Error(y+" is not a valid compression method !");return B})(h.options.compression,c.compression),p=h.options.compressionOptions||c.compressionOptions||{},m=h.dir,I=h.date;h._compressWorker(_,p).withStreamInfo("file",{name:d,dir:m,date:I,comment:h.comment||"",unixPermissions:h.unixPermissions,dosPermissions:h.dosPermissions}).pipe(g)}),g.entriesCount=u}catch(d){g.error(d)}return g}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(o,i,r){function A(){if(!(this instanceof A))return new A;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var s=new A;for(var a in this)typeof this[a]!="function"&&(s[a]=this[a]);return s}}(A.prototype=o("./object")).loadAsync=o("./load"),A.support=o("./support"),A.defaults=o("./defaults"),A.version="3.10.1",A.loadAsync=function(s,a){return new A().loadAsync(s,a)},A.external=o("./external"),i.exports=A},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(o,i,r){var A=o("./utils"),s=o("./external"),a=o("./utf8"),c=o("./zipEntries"),l=o("./stream/Crc32Probe"),g=o("./nodejsUtils");function u(d){return new s.Promise(function(h,_){var p=d.decompressed.getContentWorker().pipe(new l);p.on("error",function(m){_(m)}).on("end",function(){p.streamInfo.crc32!==d.decompressed.crc32?_(new Error("Corrupted zip : CRC32 mismatch")):h()}).resume()})}i.exports=function(d,h){var _=this;return h=A.extend(h||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),g.isNode&&g.isStream(d)?s.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):A.prepareContent("the loaded zip file",d,!0,h.optimizedBinaryString,h.base64).then(function(p){var m=new c(h);return m.load(p),m}).then(function(p){var m=[s.Promise.resolve(p)],I=p.files;if(h.checkCRC32)for(var C=0;C<I.length;C++)m.push(u(I[C]));return s.Promise.all(m)}).then(function(p){for(var m=p.shift(),I=m.files,C=0;C<I.length;C++){var f=I[C],y=f.fileNameStr,B=A.resolve(f.fileNameStr);_.file(B,f.decompressed,{binary:!0,optimizedBinaryString:!0,date:f.date,dir:f.dir,comment:f.fileCommentStr.length?f.fileCommentStr:null,unixPermissions:f.unixPermissions,dosPermissions:f.dosPermissions,createFolders:h.createFolders}),f.dir||(_.file(B).unsafeOriginalName=y)}return m.zipComment.length&&(_.comment=m.zipComment),_})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(o,i,r){var A=o("../utils"),s=o("../stream/GenericWorker");function a(c,l){s.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(l)}A.inherits(a,s),a.prototype._bindStream=function(c){var l=this;(this._stream=c).pause(),c.on("data",function(g){l.push({data:g,meta:{percent:0}})}).on("error",function(g){l.isPaused?this.generatedError=g:l.error(g)}).on("end",function(){l.isPaused?l._upstreamEnded=!0:l.end()})},a.prototype.pause=function(){return!!s.prototype.pause.call(this)&&(this._stream.pause(),!0)},a.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},i.exports=a},{"../stream/GenericWorker":28,"../utils":32}],13:[function(o,i,r){var A=o("readable-stream").Readable;function s(a,c,l){A.call(this,c),this._helper=a;var g=this;a.on("data",function(u,d){g.push(u)||g._helper.pause(),l&&l(d)}).on("error",function(u){g.emit("error",u)}).on("end",function(){g.push(null)})}o("../utils").inherits(s,A),s.prototype._read=function(){this._helper.resume()},i.exports=s},{"../utils":32,"readable-stream":16}],14:[function(o,i,r){i.exports={isNode:typeof Buffer<"u",newBufferFrom:function(A,s){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(A,s);if(typeof A=="number")throw new Error('The "data" argument must not be a number');return new Buffer(A,s)},allocBuffer:function(A){if(Buffer.alloc)return Buffer.alloc(A);var s=new Buffer(A);return s.fill(0),s},isBuffer:function(A){return Buffer.isBuffer(A)},isStream:function(A){return A&&typeof A.on=="function"&&typeof A.pause=="function"&&typeof A.resume=="function"}}},{}],15:[function(o,i,r){function A(B,x,S){var M,w=a.getTypeOf(x),k=a.extend(S||{},g);k.date=k.date||new Date,k.compression!==null&&(k.compression=k.compression.toUpperCase()),typeof k.unixPermissions=="string"&&(k.unixPermissions=parseInt(k.unixPermissions,8)),k.unixPermissions&&16384&k.unixPermissions&&(k.dir=!0),k.dosPermissions&&16&k.dosPermissions&&(k.dir=!0),k.dir&&(B=I(B)),k.createFolders&&(M=m(B))&&C.call(this,M,!0);var N=w==="string"&&k.binary===!1&&k.base64===!1;S&&S.binary!==void 0||(k.binary=!N),(x instanceof u&&x.uncompressedSize===0||k.dir||!x||x.length===0)&&(k.base64=!1,k.binary=!0,x="",k.compression="STORE",w="string");var G=null;G=x instanceof u||x instanceof c?x:_.isNode&&_.isStream(x)?new p(B,x):a.prepareContent(B,x,k.binary,k.optimizedBinaryString,k.base64);var H=new d(B,G,k);this.files[B]=H}var s=o("./utf8"),a=o("./utils"),c=o("./stream/GenericWorker"),l=o("./stream/StreamHelper"),g=o("./defaults"),u=o("./compressedObject"),d=o("./zipObject"),h=o("./generate"),_=o("./nodejsUtils"),p=o("./nodejs/NodejsStreamInputAdapter"),m=function(B){B.slice(-1)==="/"&&(B=B.substring(0,B.length-1));var x=B.lastIndexOf("/");return 0<x?B.substring(0,x):""},I=function(B){return B.slice(-1)!=="/"&&(B+="/"),B},C=function(B,x){return x=x!==void 0?x:g.createFolders,B=I(B),this.files[B]||A.call(this,B,null,{dir:!0,createFolders:x}),this.files[B]};function f(B){return Object.prototype.toString.call(B)==="[object RegExp]"}var y={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(B){var x,S,M;for(x in this.files)M=this.files[x],(S=x.slice(this.root.length,x.length))&&x.slice(0,this.root.length)===this.root&&B(S,M)},filter:function(B){var x=[];return this.forEach(function(S,M){B(S,M)&&x.push(M)}),x},file:function(B,x,S){if(arguments.length!==1)return B=this.root+B,A.call(this,B,x,S),this;if(f(B)){var M=B;return this.filter(function(k,N){return!N.dir&&M.test(k)})}var w=this.files[this.root+B];return w&&!w.dir?w:null},folder:function(B){if(!B)return this;if(f(B))return this.filter(function(w,k){return k.dir&&B.test(w)});var x=this.root+B,S=C.call(this,x),M=this.clone();return M.root=S.name,M},remove:function(B){B=this.root+B;var x=this.files[B];if(x||(B.slice(-1)!=="/"&&(B+="/"),x=this.files[B]),x&&!x.dir)delete this.files[B];else for(var S=this.filter(function(w,k){return k.name.slice(0,B.length)===B}),M=0;M<S.length;M++)delete this.files[S[M].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(B){var x,S={};try{if((S=a.extend(B||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:s.utf8encode})).type=S.type.toLowerCase(),S.compression=S.compression.toUpperCase(),S.type==="binarystring"&&(S.type="string"),!S.type)throw new Error("No output type specified.");a.checkSupport(S.type),S.platform!=="darwin"&&S.platform!=="freebsd"&&S.platform!=="linux"&&S.platform!=="sunos"||(S.platform="UNIX"),S.platform==="win32"&&(S.platform="DOS");var M=S.comment||this.comment||"";x=h.generateWorker(this,S,M)}catch(w){(x=new c("error")).error(w)}return new l(x,S.type||"string",S.mimeType)},generateAsync:function(B,x){return this.generateInternalStream(B).accumulate(x)},generateNodeStream:function(B,x){return(B=B||{}).type||(B.type="nodebuffer"),this.generateInternalStream(B).toNodejsStream(x)}};i.exports=y},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(o,i,r){i.exports=o("stream")},{stream:void 0}],17:[function(o,i,r){var A=o("./DataReader");function s(a){A.call(this,a);for(var c=0;c<this.data.length;c++)a[c]=255&a[c]}o("../utils").inherits(s,A),s.prototype.byteAt=function(a){return this.data[this.zero+a]},s.prototype.lastIndexOfSignature=function(a){for(var c=a.charCodeAt(0),l=a.charCodeAt(1),g=a.charCodeAt(2),u=a.charCodeAt(3),d=this.length-4;0<=d;--d)if(this.data[d]===c&&this.data[d+1]===l&&this.data[d+2]===g&&this.data[d+3]===u)return d-this.zero;return-1},s.prototype.readAndCheckSignature=function(a){var c=a.charCodeAt(0),l=a.charCodeAt(1),g=a.charCodeAt(2),u=a.charCodeAt(3),d=this.readData(4);return c===d[0]&&l===d[1]&&g===d[2]&&u===d[3]},s.prototype.readData=function(a){if(this.checkOffset(a),a===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,c},i.exports=s},{"../utils":32,"./DataReader":18}],18:[function(o,i,r){var A=o("../utils");function s(a){this.data=a,this.length=a.length,this.index=0,this.zero=0}s.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.length<this.zero+a||a<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var c,l=0;for(this.checkOffset(a),c=this.index+a-1;c>=this.index;c--)l=(l<<8)+this.byteAt(c);return this.index+=a,l},readString:function(a){return A.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},i.exports=s},{"../utils":32}],19:[function(o,i,r){var A=o("./Uint8ArrayReader");function s(a){A.call(this,a)}o("../utils").inherits(s,A),s.prototype.readData=function(a){this.checkOffset(a);var c=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,c},i.exports=s},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(o,i,r){var A=o("./DataReader");function s(a){A.call(this,a)}o("../utils").inherits(s,A),s.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},s.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},s.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},s.prototype.readData=function(a){this.checkOffset(a);var c=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,c},i.exports=s},{"../utils":32,"./DataReader":18}],21:[function(o,i,r){var A=o("./ArrayReader");function s(a){A.call(this,a)}o("../utils").inherits(s,A),s.prototype.readData=function(a){if(this.checkOffset(a),a===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,c},i.exports=s},{"../utils":32,"./ArrayReader":17}],22:[function(o,i,r){var A=o("../utils"),s=o("../support"),a=o("./ArrayReader"),c=o("./StringReader"),l=o("./NodeBufferReader"),g=o("./Uint8ArrayReader");i.exports=function(u){var d=A.getTypeOf(u);return A.checkSupport(d),d!=="string"||s.uint8array?d==="nodebuffer"?new l(u):s.uint8array?new g(A.transformTo("uint8array",u)):new a(A.transformTo("array",u)):new c(u)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(o,i,r){r.LOCAL_FILE_HEADER="PK",r.CENTRAL_FILE_HEADER="PK",r.CENTRAL_DIRECTORY_END="PK",r.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",r.ZIP64_CENTRAL_DIRECTORY_END="PK",r.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(o,i,r){var A=o("./GenericWorker"),s=o("../utils");function a(c){A.call(this,"ConvertWorker to "+c),this.destType=c}s.inherits(a,A),a.prototype.processChunk=function(c){this.push({data:s.transformTo(this.destType,c.data),meta:c.meta})},i.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(o,i,r){var A=o("./GenericWorker"),s=o("../crc32");function a(){A.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}o("../utils").inherits(a,A),a.prototype.processChunk=function(c){this.streamInfo.crc32=s(c.data,this.streamInfo.crc32||0),this.push(c)},i.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(o,i,r){var A=o("../utils"),s=o("./GenericWorker");function a(c){s.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}A.inherits(a,s),a.prototype.processChunk=function(c){if(c){var l=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=l+c.data.length}s.prototype.processChunk.call(this,c)},i.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(o,i,r){var A=o("../utils"),s=o("./GenericWorker");function a(c){s.call(this,"DataWorker");var l=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(g){l.dataIsReady=!0,l.data=g,l.max=g&&g.length||0,l.type=A.getTypeOf(g),l.isPaused||l._tickAndRepeat()},function(g){l.error(g)})}A.inherits(a,s),a.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,A.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(A.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,l=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,l);break;case"uint8array":c=this.data.subarray(this.index,l);break;case"array":case"nodebuffer":c=this.data.slice(this.index,l)}return this.index=l,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},i.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(o,i,r){function A(s){this.name=s||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}A.prototype={push:function(s){this.emit("data",s)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(s){this.emit("error",s)}return!0},error:function(s){return!this.isFinished&&(this.isPaused?this.generatedError=s:(this.isFinished=!0,this.emit("error",s),this.previous&&this.previous.error(s),this.cleanUp()),!0)},on:function(s,a){return this._listeners[s].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(s,a){if(this._listeners[s])for(var c=0;c<this._listeners[s].length;c++)this._listeners[s][c].call(this,a)},pipe:function(s){return s.registerPrevious(this)},registerPrevious:function(s){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=s.streamInfo,this.mergeStreamInfo(),this.previous=s;var a=this;return s.on("data",function(c){a.processChunk(c)}),s.on("end",function(){a.end()}),s.on("error",function(c){a.error(c)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var s=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),s=!0),this.previous&&this.previous.resume(),!s},flush:function(){},processChunk:function(s){this.push(s)},withStreamInfo:function(s,a){return this.extraStreamInfo[s]=a,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var s in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,s)&&(this.streamInfo[s]=this.extraStreamInfo[s])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var s="Worker "+this.name;return this.previous?this.previous+" -> "+s:s}},i.exports=A},{}],29:[function(o,i,r){var A=o("../utils"),s=o("./ConvertWorker"),a=o("./GenericWorker"),c=o("../base64"),l=o("../support"),g=o("../external"),u=null;if(l.nodestream)try{u=o("../nodejs/NodejsStreamOutputAdapter")}catch{}function d(_,p){return new g.Promise(function(m,I){var C=[],f=_._internalType,y=_._outputType,B=_._mimeType;_.on("data",function(x,S){C.push(x),p&&p(S)}).on("error",function(x){C=[],I(x)}).on("end",function(){try{var x=(function(S,M,w){switch(S){case"blob":return A.newBlob(A.transformTo("arraybuffer",M),w);case"base64":return c.encode(M);default:return A.transformTo(S,M)}})(y,(function(S,M){var w,k=0,N=null,G=0;for(w=0;w<M.length;w++)G+=M[w].length;switch(S){case"string":return M.join("");case"array":return Array.prototype.concat.apply([],M);case"uint8array":for(N=new Uint8Array(G),w=0;w<M.length;w++)N.set(M[w],k),k+=M[w].length;return N;case"nodebuffer":return Buffer.concat(M);default:throw new Error("concat : unsupported type '"+S+"'")}})(f,C),B);m(x)}catch(S){I(S)}C=[]}).resume()})}function h(_,p,m){var I=p;switch(p){case"blob":case"arraybuffer":I="uint8array";break;case"base64":I="string"}try{this._internalType=I,this._outputType=p,this._mimeType=m,A.checkSupport(I),this._worker=_.pipe(new s(I)),_.lock()}catch(C){this._worker=new a("error"),this._worker.error(C)}}h.prototype={accumulate:function(_){return d(this,_)},on:function(_,p){var m=this;return _==="data"?this._worker.on(_,function(I){p.call(m,I.data,I.meta)}):this._worker.on(_,function(){A.delay(p,arguments,m)}),this},resume:function(){return A.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(_){if(A.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new u(this,{objectMode:this._outputType!=="nodebuffer"},_)}},i.exports=h},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(o,i,r){if(r.base64=!0,r.array=!0,r.string=!0,r.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",r.nodebuffer=typeof Buffer<"u",r.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")r.blob=!1;else{var A=new ArrayBuffer(0);try{r.blob=new Blob([A],{type:"application/zip"}).size===0}catch{try{var s=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);s.append(A),r.blob=s.getBlob("application/zip").size===0}catch{r.blob=!1}}}try{r.nodestream=!!o("readable-stream").Readable}catch{r.nodestream=!1}},{"readable-stream":16}],31:[function(o,i,r){for(var A=o("./utils"),s=o("./support"),a=o("./nodejsUtils"),c=o("./stream/GenericWorker"),l=new Array(256),g=0;g<256;g++)l[g]=252<=g?6:248<=g?5:240<=g?4:224<=g?3:192<=g?2:1;l[254]=l[254]=1;function u(){c.call(this,"utf-8 decode"),this.leftOver=null}function d(){c.call(this,"utf-8 encode")}r.utf8encode=function(h){return s.nodebuffer?a.newBufferFrom(h,"utf-8"):(function(_){var p,m,I,C,f,y=_.length,B=0;for(C=0;C<y;C++)(64512&(m=_.charCodeAt(C)))==55296&&C+1<y&&(64512&(I=_.charCodeAt(C+1)))==56320&&(m=65536+(m-55296<<10)+(I-56320),C++),B+=m<128?1:m<2048?2:m<65536?3:4;for(p=s.uint8array?new Uint8Array(B):new Array(B),C=f=0;f<B;C++)(64512&(m=_.charCodeAt(C)))==55296&&C+1<y&&(64512&(I=_.charCodeAt(C+1)))==56320&&(m=65536+(m-55296<<10)+(I-56320),C++),m<128?p[f++]=m:(m<2048?p[f++]=192|m>>>6:(m<65536?p[f++]=224|m>>>12:(p[f++]=240|m>>>18,p[f++]=128|m>>>12&63),p[f++]=128|m>>>6&63),p[f++]=128|63&m);return p})(h)},r.utf8decode=function(h){return s.nodebuffer?A.transformTo("nodebuffer",h).toString("utf-8"):(function(_){var p,m,I,C,f=_.length,y=new Array(2*f);for(p=m=0;p<f;)if((I=_[p++])<128)y[m++]=I;else if(4<(C=l[I]))y[m++]=65533,p+=C-1;else{for(I&=C===2?31:C===3?15:7;1<C&&p<f;)I=I<<6|63&_[p++],C--;1<C?y[m++]=65533:I<65536?y[m++]=I:(I-=65536,y[m++]=55296|I>>10&1023,y[m++]=56320|1023&I)}return y.length!==m&&(y.subarray?y=y.subarray(0,m):y.length=m),A.applyFromCharCode(y)})(h=A.transformTo(s.uint8array?"uint8array":"array",h))},A.inherits(u,c),u.prototype.processChunk=function(h){var _=A.transformTo(s.uint8array?"uint8array":"array",h.data);if(this.leftOver&&this.leftOver.length){if(s.uint8array){var p=_;(_=new Uint8Array(p.length+this.leftOver.length)).set(this.leftOver,0),_.set(p,this.leftOver.length)}else _=this.leftOver.concat(_);this.leftOver=null}var m=(function(C,f){var y;for((f=f||C.length)>C.length&&(f=C.length),y=f-1;0<=y&&(192&C[y])==128;)y--;return y<0||y===0?f:y+l[C[y]]>f?y:f})(_),I=_;m!==_.length&&(s.uint8array?(I=_.subarray(0,m),this.leftOver=_.subarray(m,_.length)):(I=_.slice(0,m),this.leftOver=_.slice(m,_.length))),this.push({data:r.utf8decode(I),meta:h.meta})},u.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:r.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},r.Utf8DecodeWorker=u,A.inherits(d,c),d.prototype.processChunk=function(h){this.push({data:r.utf8encode(h.data),meta:h.meta})},r.Utf8EncodeWorker=d},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(o,i,r){var A=o("./support"),s=o("./base64"),a=o("./nodejsUtils"),c=o("./external");function l(p){return p}function g(p,m){for(var I=0;I<p.length;++I)m[I]=255&p.charCodeAt(I);return m}o("setimmediate"),r.newBlob=function(p,m){r.checkSupport("blob");try{return new Blob([p],{type:m})}catch{try{var I=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return I.append(p),I.getBlob(m)}catch{throw new Error("Bug : can't construct the Blob.")}}};var u={stringifyByChunk:function(p,m,I){var C=[],f=0,y=p.length;if(y<=I)return String.fromCharCode.apply(null,p);for(;f<y;)m==="array"||m==="nodebuffer"?C.push(String.fromCharCode.apply(null,p.slice(f,Math.min(f+I,y)))):C.push(String.fromCharCode.apply(null,p.subarray(f,Math.min(f+I,y)))),f+=I;return C.join("")},stringifyByChar:function(p){for(var m="",I=0;I<p.length;I++)m+=String.fromCharCode(p[I]);return m},applyCanBeUsed:{uint8array:(function(){try{return A.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return A.nodebuffer&&String.fromCharCode.apply(null,a.allocBuffer(1)).length===1}catch{return!1}})()}};function d(p){var m=65536,I=r.getTypeOf(p),C=!0;if(I==="uint8array"?C=u.applyCanBeUsed.uint8array:I==="nodebuffer"&&(C=u.applyCanBeUsed.nodebuffer),C)for(;1<m;)try{return u.stringifyByChunk(p,I,m)}catch{m=Math.floor(m/2)}return u.stringifyByChar(p)}function h(p,m){for(var I=0;I<p.length;I++)m[I]=p[I];return m}r.applyFromCharCode=d;var _={};_.string={string:l,array:function(p){return g(p,new Array(p.length))},arraybuffer:function(p){return _.string.uint8array(p).buffer},uint8array:function(p){return g(p,new Uint8Array(p.length))},nodebuffer:function(p){return g(p,a.allocBuffer(p.length))}},_.array={string:d,array:l,arraybuffer:function(p){return new Uint8Array(p).buffer},uint8array:function(p){return new Uint8Array(p)},nodebuffer:function(p){return a.newBufferFrom(p)}},_.arraybuffer={string:function(p){return d(new Uint8Array(p))},array:function(p){return h(new Uint8Array(p),new Array(p.byteLength))},arraybuffer:l,uint8array:function(p){return new Uint8Array(p)},nodebuffer:function(p){return a.newBufferFrom(new Uint8Array(p))}},_.uint8array={string:d,array:function(p){return h(p,new Array(p.length))},arraybuffer:function(p){return p.buffer},uint8array:l,nodebuffer:function(p){return a.newBufferFrom(p)}},_.nodebuffer={string:d,array:function(p){return h(p,new Array(p.length))},arraybuffer:function(p){return _.nodebuffer.uint8array(p).buffer},uint8array:function(p){return h(p,new Uint8Array(p.length))},nodebuffer:l},r.transformTo=function(p,m){if(m=m||"",!p)return m;r.checkSupport(p);var I=r.getTypeOf(m);return _[I][p](m)},r.resolve=function(p){for(var m=p.split("/"),I=[],C=0;C<m.length;C++){var f=m[C];f==="."||f===""&&C!==0&&C!==m.length-1||(f===".."?I.pop():I.push(f))}return I.join("/")},r.getTypeOf=function(p){return typeof p=="string"?"string":Object.prototype.toString.call(p)==="[object Array]"?"array":A.nodebuffer&&a.isBuffer(p)?"nodebuffer":A.uint8array&&p instanceof Uint8Array?"uint8array":A.arraybuffer&&p instanceof ArrayBuffer?"arraybuffer":void 0},r.checkSupport=function(p){if(!A[p.toLowerCase()])throw new Error(p+" is not supported by this platform")},r.MAX_VALUE_16BITS=65535,r.MAX_VALUE_32BITS=-1,r.pretty=function(p){var m,I,C="";for(I=0;I<(p||"").length;I++)C+="\\x"+((m=p.charCodeAt(I))<16?"0":"")+m.toString(16).toUpperCase();return C},r.delay=function(p,m,I){setImmediate(function(){p.apply(I||null,m||[])})},r.inherits=function(p,m){function I(){}I.prototype=m.prototype,p.prototype=new I},r.extend=function(){var p,m,I={};for(p=0;p<arguments.length;p++)for(m in arguments[p])Object.prototype.hasOwnProperty.call(arguments[p],m)&&I[m]===void 0&&(I[m]=arguments[p][m]);return I},r.prepareContent=function(p,m,I,C,f){return c.Promise.resolve(m).then(function(y){return A.blob&&(y instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(y))!==-1)&&typeof FileReader<"u"?new c.Promise(function(B,x){var S=new FileReader;S.onload=function(M){B(M.target.result)},S.onerror=function(M){x(M.target.error)},S.readAsArrayBuffer(y)}):y}).then(function(y){var B=r.getTypeOf(y);return B?(B==="arraybuffer"?y=r.transformTo("uint8array",y):B==="string"&&(f?y=s.decode(y):I&&C!==!0&&(y=(function(x){return g(x,A.uint8array?new Uint8Array(x.length):new Array(x.length))})(y))),y):c.Promise.reject(new Error("Can't read the data of '"+p+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(o,i,r){var A=o("./reader/readerFor"),s=o("./utils"),a=o("./signature"),c=o("./zipEntry"),l=o("./support");function g(u){this.files=[],this.loadOptions=u}g.prototype={checkSignature:function(u){if(!this.reader.readAndCheckSignature(u)){this.reader.index-=4;var d=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+s.pretty(d)+", expected "+s.pretty(u)+")")}},isSignature:function(u,d){var h=this.reader.index;this.reader.setIndex(u);var _=this.reader.readString(4)===d;return this.reader.setIndex(h),_},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var u=this.reader.readData(this.zipCommentLength),d=l.uint8array?"uint8array":"array",h=s.transformTo(d,u);this.zipComment=this.loadOptions.decodeFileName(h)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var u,d,h,_=this.zip64EndOfCentralSize-44;0<_;)u=this.reader.readInt(2),d=this.reader.readInt(4),h=this.reader.readData(d),this.zip64ExtensibleData[u]={id:u,length:d,value:h}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var u,d;for(u=0;u<this.files.length;u++)d=this.files[u],this.reader.setIndex(d.localHeaderOffset),this.checkSignature(a.LOCAL_FILE_HEADER),d.readLocalPart(this.reader),d.handleUTF8(),d.processAttributes()},readCentralDir:function(){var u;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER);)(u=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(u);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var u=this.reader.lastIndexOfSignature(a.CENTRAL_DIRECTORY_END);if(u<0)throw this.isSignature(0,a.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(u);var d=u;if(this.checkSignature(a.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===s.MAX_VALUE_16BITS||this.diskWithCentralDirStart===s.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===s.MAX_VALUE_16BITS||this.centralDirRecords===s.MAX_VALUE_16BITS||this.centralDirSize===s.MAX_VALUE_32BITS||this.centralDirOffset===s.MAX_VALUE_32BITS){if(this.zip64=!0,(u=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(u),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,a.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var h=this.centralDirOffset+this.centralDirSize;this.zip64&&(h+=20,h+=12+this.zip64EndOfCentralSize);var _=d-h;if(0<_)this.isSignature(d,a.CENTRAL_FILE_HEADER)||(this.reader.zero=_);else if(_<0)throw new Error("Corrupted zip: missing "+Math.abs(_)+" bytes.")},prepareReader:function(u){this.reader=A(u)},load:function(u){this.prepareReader(u),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},i.exports=g},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(o,i,r){var A=o("./reader/readerFor"),s=o("./utils"),a=o("./compressedObject"),c=o("./crc32"),l=o("./utf8"),g=o("./compressions"),u=o("./support");function d(h,_){this.options=h,this.loadOptions=_}d.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(h){var _,p;if(h.skip(22),this.fileNameLength=h.readInt(2),p=h.readInt(2),this.fileName=h.readData(this.fileNameLength),h.skip(p),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((_=(function(m){for(var I in g)if(Object.prototype.hasOwnProperty.call(g,I)&&g[I].magic===m)return g[I];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+s.pretty(this.compressionMethod)+" unknown (inner file : "+s.transformTo("string",this.fileName)+")");this.decompressed=new a(this.compressedSize,this.uncompressedSize,this.crc32,_,h.readData(this.compressedSize))},readCentralPart:function(h){this.versionMadeBy=h.readInt(2),h.skip(2),this.bitFlag=h.readInt(2),this.compressionMethod=h.readString(2),this.date=h.readDate(),this.crc32=h.readInt(4),this.compressedSize=h.readInt(4),this.uncompressedSize=h.readInt(4);var _=h.readInt(2);if(this.extraFieldsLength=h.readInt(2),this.fileCommentLength=h.readInt(2),this.diskNumberStart=h.readInt(2),this.internalFileAttributes=h.readInt(2),this.externalFileAttributes=h.readInt(4),this.localHeaderOffset=h.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");h.skip(_),this.readExtraFields(h),this.parseZIP64ExtraField(h),this.fileComment=h.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var h=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),h==0&&(this.dosPermissions=63&this.externalFileAttributes),h==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var h=A(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=h.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=h.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=h.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=h.readInt(4))}},readExtraFields:function(h){var _,p,m,I=h.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});h.index+4<I;)_=h.readInt(2),p=h.readInt(2),m=h.readData(p),this.extraFields[_]={id:_,length:p,value:m};h.setIndex(I)},handleUTF8:function(){var h=u.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=l.utf8decode(this.fileName),this.fileCommentStr=l.utf8decode(this.fileComment);else{var _=this.findExtraFieldUnicodePath();if(_!==null)this.fileNameStr=_;else{var p=s.transformTo(h,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(p)}var m=this.findExtraFieldUnicodeComment();if(m!==null)this.fileCommentStr=m;else{var I=s.transformTo(h,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(I)}}},findExtraFieldUnicodePath:function(){var h=this.extraFields[28789];if(h){var _=A(h.value);return _.readInt(1)!==1||c(this.fileName)!==_.readInt(4)?null:l.utf8decode(_.readData(h.length-5))}return null},findExtraFieldUnicodeComment:function(){var h=this.extraFields[25461];if(h){var _=A(h.value);return _.readInt(1)!==1||c(this.fileComment)!==_.readInt(4)?null:l.utf8decode(_.readData(h.length-5))}return null}},i.exports=d},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(o,i,r){function A(_,p,m){this.name=_,this.dir=m.dir,this.date=m.date,this.comment=m.comment,this.unixPermissions=m.unixPermissions,this.dosPermissions=m.dosPermissions,this._data=p,this._dataBinary=m.binary,this.options={compression:m.compression,compressionOptions:m.compressionOptions}}var s=o("./stream/StreamHelper"),a=o("./stream/DataWorker"),c=o("./utf8"),l=o("./compressedObject"),g=o("./stream/GenericWorker");A.prototype={internalStream:function(_){var p=null,m="string";try{if(!_)throw new Error("No output type specified.");var I=(m=_.toLowerCase())==="string"||m==="text";m!=="binarystring"&&m!=="text"||(m="string"),p=this._decompressWorker();var C=!this._dataBinary;C&&!I&&(p=p.pipe(new c.Utf8EncodeWorker)),!C&&I&&(p=p.pipe(new c.Utf8DecodeWorker))}catch(f){(p=new g("error")).error(f)}return new s(p,m,"")},async:function(_,p){return this.internalStream(_).accumulate(p)},nodeStream:function(_,p){return this.internalStream(_||"nodebuffer").toNodejsStream(p)},_compressWorker:function(_,p){if(this._data instanceof l&&this._data.compression.magic===_.magic)return this._data.getCompressedWorker();var m=this._decompressWorker();return this._dataBinary||(m=m.pipe(new c.Utf8EncodeWorker)),l.createWorkerFrom(m,_,p)},_decompressWorker:function(){return this._data instanceof l?this._data.getContentWorker():this._data instanceof g?this._data:new a(this._data)}};for(var u=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],d=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},h=0;h<u.length;h++)A.prototype[u[h]]=d;i.exports=A},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(o,i,r){(function(A){var s,a,c=A.MutationObserver||A.WebKitMutationObserver;if(c){var l=0,g=new c(_),u=A.document.createTextNode("");g.observe(u,{characterData:!0}),s=function(){u.data=l=++l%2}}else if(A.setImmediate||A.MessageChannel===void 0)s="document"in A&&"onreadystatechange"in A.document.createElement("script")?function(){var p=A.document.createElement("script");p.onreadystatechange=function(){_(),p.onreadystatechange=null,p.parentNode.removeChild(p),p=null},A.document.documentElement.appendChild(p)}:function(){setTimeout(_,0)};else{var d=new A.MessageChannel;d.port1.onmessage=_,s=function(){d.port2.postMessage(0)}}var h=[];function _(){var p,m;a=!0;for(var I=h.length;I;){for(m=h,h=[],p=-1;++p<I;)m[p]();I=h.length}a=!1}i.exports=function(p){h.push(p)!==1||a||s()}}).call(this,typeof yK<"u"?yK:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(o,i,r){var A=o("immediate");function s(){}var a={},c=["REJECTED"],l=["FULFILLED"],g=["PENDING"];function u(I){if(typeof I!="function")throw new TypeError("resolver must be a function");this.state=g,this.queue=[],this.outcome=void 0,I!==s&&p(this,I)}function d(I,C,f){this.promise=I,typeof C=="function"&&(this.onFulfilled=C,this.callFulfilled=this.otherCallFulfilled),typeof f=="function"&&(this.onRejected=f,this.callRejected=this.otherCallRejected)}function h(I,C,f){A(function(){var y;try{y=C(f)}catch(B){return a.reject(I,B)}y===I?a.reject(I,new TypeError("Cannot resolve promise with itself")):a.resolve(I,y)})}function _(I){var C=I&&I.then;if(I&&(typeof I=="object"||typeof I=="function")&&typeof C=="function")return function(){C.apply(I,arguments)}}function p(I,C){var f=!1;function y(S){f||(f=!0,a.reject(I,S))}function B(S){f||(f=!0,a.resolve(I,S))}var x=m(function(){C(B,y)});x.status==="error"&&y(x.value)}function m(I,C){var f={};try{f.value=I(C),f.status="success"}catch(y){f.status="error",f.value=y}return f}(i.exports=u).prototype.finally=function(I){if(typeof I!="function")return this;var C=this.constructor;return this.then(function(f){return C.resolve(I()).then(function(){return f})},function(f){return C.resolve(I()).then(function(){throw f})})},u.prototype.catch=function(I){return this.then(null,I)},u.prototype.then=function(I,C){if(typeof I!="function"&&this.state===l||typeof C!="function"&&this.state===c)return this;var f=new this.constructor(s);return this.state!==g?h(f,this.state===l?I:C,this.outcome):this.queue.push(new d(f,I,C)),f},d.prototype.callFulfilled=function(I){a.resolve(this.promise,I)},d.prototype.otherCallFulfilled=function(I){h(this.promise,this.onFulfilled,I)},d.prototype.callRejected=function(I){a.reject(this.promise,I)},d.prototype.otherCallRejected=function(I){h(this.promise,this.onRejected,I)},a.resolve=function(I,C){var f=m(_,C);if(f.status==="error")return a.reject(I,f.value);var y=f.value;if(y)p(I,y);else{I.state=l,I.outcome=C;for(var B=-1,x=I.queue.length;++B<x;)I.queue[B].callFulfilled(C)}return I},a.reject=function(I,C){I.state=c,I.outcome=C;for(var f=-1,y=I.queue.length;++f<y;)I.queue[f].callRejected(C);return I},u.resolve=function(I){return I instanceof this?I:a.resolve(new this(s),I)},u.reject=function(I){var C=new this(s);return a.reject(C,I)},u.all=function(I){var C=this;if(Object.prototype.toString.call(I)!=="[object Array]")return this.reject(new TypeError("must be an array"));var f=I.length,y=!1;if(!f)return this.resolve([]);for(var B=new Array(f),x=0,S=-1,M=new this(s);++S<f;)w(I[S],S);return M;function w(k,N){C.resolve(k).then(function(G){B[N]=G,++x!==f||y||(y=!0,a.resolve(M,B))},function(G){y||(y=!0,a.reject(M,G))})}},u.race=function(I){var C=this;if(Object.prototype.toString.call(I)!=="[object Array]")return this.reject(new TypeError("must be an array"));var f=I.length,y=!1;if(!f)return this.resolve([]);for(var B=-1,x=new this(s);++B<f;)S=I[B],C.resolve(S).then(function(M){y||(y=!0,a.resolve(x,M))},function(M){y||(y=!0,a.reject(x,M))});var S;return x}},{immediate:36}],38:[function(o,i,r){var A={};(0,o("./lib/utils/common").assign)(A,o("./lib/deflate"),o("./lib/inflate"),o("./lib/zlib/constants")),i.exports=A},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(o,i,r){var A=o("./zlib/deflate"),s=o("./utils/common"),a=o("./utils/strings"),c=o("./zlib/messages"),l=o("./zlib/zstream"),g=Object.prototype.toString,u=0,d=-1,h=0,_=8;function p(I){if(!(this instanceof p))return new p(I);this.options=s.assign({level:d,method:_,chunkSize:16384,windowBits:15,memLevel:8,strategy:h,to:""},I||{});var C=this.options;C.raw&&0<C.windowBits?C.windowBits=-C.windowBits:C.gzip&&0<C.windowBits&&C.windowBits<16&&(C.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new l,this.strm.avail_out=0;var f=A.deflateInit2(this.strm,C.level,C.method,C.windowBits,C.memLevel,C.strategy);if(f!==u)throw new Error(c[f]);if(C.header&&A.deflateSetHeader(this.strm,C.header),C.dictionary){var y;if(y=typeof C.dictionary=="string"?a.string2buf(C.dictionary):g.call(C.dictionary)==="[object ArrayBuffer]"?new Uint8Array(C.dictionary):C.dictionary,(f=A.deflateSetDictionary(this.strm,y))!==u)throw new Error(c[f]);this._dict_set=!0}}function m(I,C){var f=new p(C);if(f.push(I,!0),f.err)throw f.msg||c[f.err];return f.result}p.prototype.push=function(I,C){var f,y,B=this.strm,x=this.options.chunkSize;if(this.ended)return!1;y=C===~~C?C:C===!0?4:0,typeof I=="string"?B.input=a.string2buf(I):g.call(I)==="[object ArrayBuffer]"?B.input=new Uint8Array(I):B.input=I,B.next_in=0,B.avail_in=B.input.length;do{if(B.avail_out===0&&(B.output=new s.Buf8(x),B.next_out=0,B.avail_out=x),(f=A.deflate(B,y))!==1&&f!==u)return this.onEnd(f),!(this.ended=!0);B.avail_out!==0&&(B.avail_in!==0||y!==4&&y!==2)||(this.options.to==="string"?this.onData(a.buf2binstring(s.shrinkBuf(B.output,B.next_out))):this.onData(s.shrinkBuf(B.output,B.next_out)))}while((0<B.avail_in||B.avail_out===0)&&f!==1);return y===4?(f=A.deflateEnd(this.strm),this.onEnd(f),this.ended=!0,f===u):y!==2||(this.onEnd(u),!(B.avail_out=0))},p.prototype.onData=function(I){this.chunks.push(I)},p.prototype.onEnd=function(I){I===u&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=I,this.msg=this.strm.msg},r.Deflate=p,r.deflate=m,r.deflateRaw=function(I,C){return(C=C||{}).raw=!0,m(I,C)},r.gzip=function(I,C){return(C=C||{}).gzip=!0,m(I,C)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(o,i,r){var A=o("./zlib/inflate"),s=o("./utils/common"),a=o("./utils/strings"),c=o("./zlib/constants"),l=o("./zlib/messages"),g=o("./zlib/zstream"),u=o("./zlib/gzheader"),d=Object.prototype.toString;function h(p){if(!(this instanceof h))return new h(p);this.options=s.assign({chunkSize:16384,windowBits:0,to:""},p||{});var m=this.options;m.raw&&0<=m.windowBits&&m.windowBits<16&&(m.windowBits=-m.windowBits,m.windowBits===0&&(m.windowBits=-15)),!(0<=m.windowBits&&m.windowBits<16)||p&&p.windowBits||(m.windowBits+=32),15<m.windowBits&&m.windowBits<48&&(15&m.windowBits)==0&&(m.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new g,this.strm.avail_out=0;var I=A.inflateInit2(this.strm,m.windowBits);if(I!==c.Z_OK)throw new Error(l[I]);this.header=new u,A.inflateGetHeader(this.strm,this.header)}function _(p,m){var I=new h(m);if(I.push(p,!0),I.err)throw I.msg||l[I.err];return I.result}h.prototype.push=function(p,m){var I,C,f,y,B,x,S=this.strm,M=this.options.chunkSize,w=this.options.dictionary,k=!1;if(this.ended)return!1;C=m===~~m?m:m===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof p=="string"?S.input=a.binstring2buf(p):d.call(p)==="[object ArrayBuffer]"?S.input=new Uint8Array(p):S.input=p,S.next_in=0,S.avail_in=S.input.length;do{if(S.avail_out===0&&(S.output=new s.Buf8(M),S.next_out=0,S.avail_out=M),(I=A.inflate(S,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&w&&(x=typeof w=="string"?a.string2buf(w):d.call(w)==="[object ArrayBuffer]"?new Uint8Array(w):w,I=A.inflateSetDictionary(this.strm,x)),I===c.Z_BUF_ERROR&&k===!0&&(I=c.Z_OK,k=!1),I!==c.Z_STREAM_END&&I!==c.Z_OK)return this.onEnd(I),!(this.ended=!0);S.next_out&&(S.avail_out!==0&&I!==c.Z_STREAM_END&&(S.avail_in!==0||C!==c.Z_FINISH&&C!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(f=a.utf8border(S.output,S.next_out),y=S.next_out-f,B=a.buf2string(S.output,f),S.next_out=y,S.avail_out=M-y,y&&s.arraySet(S.output,S.output,f,y,0),this.onData(B)):this.onData(s.shrinkBuf(S.output,S.next_out)))),S.avail_in===0&&S.avail_out===0&&(k=!0)}while((0<S.avail_in||S.avail_out===0)&&I!==c.Z_STREAM_END);return I===c.Z_STREAM_END&&(C=c.Z_FINISH),C===c.Z_FINISH?(I=A.inflateEnd(this.strm),this.onEnd(I),this.ended=!0,I===c.Z_OK):C!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(S.avail_out=0))},h.prototype.onData=function(p){this.chunks.push(p)},h.prototype.onEnd=function(p){p===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=p,this.msg=this.strm.msg},r.Inflate=h,r.inflate=_,r.inflateRaw=function(p,m){return(m=m||{}).raw=!0,_(p,m)},r.ungzip=_},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(o,i,r){var A=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";r.assign=function(c){for(var l=Array.prototype.slice.call(arguments,1);l.length;){var g=l.shift();if(g){if(typeof g!="object")throw new TypeError(g+"must be non-object");for(var u in g)g.hasOwnProperty(u)&&(c[u]=g[u])}}return c},r.shrinkBuf=function(c,l){return c.length===l?c:c.subarray?c.subarray(0,l):(c.length=l,c)};var s={arraySet:function(c,l,g,u,d){if(l.subarray&&c.subarray)c.set(l.subarray(g,g+u),d);else for(var h=0;h<u;h++)c[d+h]=l[g+h]},flattenChunks:function(c){var l,g,u,d,h,_;for(l=u=0,g=c.length;l<g;l++)u+=c[l].length;for(_=new Uint8Array(u),l=d=0,g=c.length;l<g;l++)h=c[l],_.set(h,d),d+=h.length;return _}},a={arraySet:function(c,l,g,u,d){for(var h=0;h<u;h++)c[d+h]=l[g+h]},flattenChunks:function(c){return[].concat.apply([],c)}};r.setTyped=function(c){c?(r.Buf8=Uint8Array,r.Buf16=Uint16Array,r.Buf32=Int32Array,r.assign(r,s)):(r.Buf8=Array,r.Buf16=Array,r.Buf32=Array,r.assign(r,a))},r.setTyped(A)},{}],42:[function(o,i,r){var A=o("./common"),s=!0,a=!0;try{String.fromCharCode.apply(null,[0])}catch{s=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{a=!1}for(var c=new A.Buf8(256),l=0;l<256;l++)c[l]=252<=l?6:248<=l?5:240<=l?4:224<=l?3:192<=l?2:1;function g(u,d){if(d<65537&&(u.subarray&&a||!u.subarray&&s))return String.fromCharCode.apply(null,A.shrinkBuf(u,d));for(var h="",_=0;_<d;_++)h+=String.fromCharCode(u[_]);return h}c[254]=c[254]=1,r.string2buf=function(u){var d,h,_,p,m,I=u.length,C=0;for(p=0;p<I;p++)(64512&(h=u.charCodeAt(p)))==55296&&p+1<I&&(64512&(_=u.charCodeAt(p+1)))==56320&&(h=65536+(h-55296<<10)+(_-56320),p++),C+=h<128?1:h<2048?2:h<65536?3:4;for(d=new A.Buf8(C),p=m=0;m<C;p++)(64512&(h=u.charCodeAt(p)))==55296&&p+1<I&&(64512&(_=u.charCodeAt(p+1)))==56320&&(h=65536+(h-55296<<10)+(_-56320),p++),h<128?d[m++]=h:(h<2048?d[m++]=192|h>>>6:(h<65536?d[m++]=224|h>>>12:(d[m++]=240|h>>>18,d[m++]=128|h>>>12&63),d[m++]=128|h>>>6&63),d[m++]=128|63&h);return d},r.buf2binstring=function(u){return g(u,u.length)},r.binstring2buf=function(u){for(var d=new A.Buf8(u.length),h=0,_=d.length;h<_;h++)d[h]=u.charCodeAt(h);return d},r.buf2string=function(u,d){var h,_,p,m,I=d||u.length,C=new Array(2*I);for(h=_=0;h<I;)if((p=u[h++])<128)C[_++]=p;else if(4<(m=c[p]))C[_++]=65533,h+=m-1;else{for(p&=m===2?31:m===3?15:7;1<m&&h<I;)p=p<<6|63&u[h++],m--;1<m?C[_++]=65533:p<65536?C[_++]=p:(p-=65536,C[_++]=55296|p>>10&1023,C[_++]=56320|1023&p)}return g(C,_)},r.utf8border=function(u,d){var h;for((d=d||u.length)>u.length&&(d=u.length),h=d-1;0<=h&&(192&u[h])==128;)h--;return h<0||h===0?d:h+c[u[h]]>d?h:d}},{"./common":41}],43:[function(o,i,r){i.exports=function(A,s,a,c){for(var l=65535&A|0,g=A>>>16&65535|0,u=0;a!==0;){for(a-=u=2e3<a?2e3:a;g=g+(l=l+s[c++]|0)|0,--u;);l%=65521,g%=65521}return l|g<<16|0}},{}],44:[function(o,i,r){i.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(o,i,r){var A=(function(){for(var s,a=[],c=0;c<256;c++){s=c;for(var l=0;l<8;l++)s=1&s?3988292384^s>>>1:s>>>1;a[c]=s}return a})();i.exports=function(s,a,c,l){var g=A,u=l+c;s^=-1;for(var d=l;d<u;d++)s=s>>>8^g[255&(s^a[d])];return-1^s}},{}],46:[function(o,i,r){var A,s=o("../utils/common"),a=o("./trees"),c=o("./adler32"),l=o("./crc32"),g=o("./messages"),u=0,d=4,h=0,_=-2,p=-1,m=4,I=2,C=8,f=9,y=286,B=30,x=19,S=2*y+1,M=15,w=3,k=258,N=k+w+1,G=42,H=113,U=1,J=2,W=3,X=4;function oe(pe,$e){return pe.msg=g[$e],$e}function ce(pe){return(pe<<1)-(4<pe?9:0)}function te(pe){for(var $e=pe.length;0<=--$e;)pe[$e]=0}function ie(pe){var $e=pe.state,Ge=$e.pending;Ge>pe.avail_out&&(Ge=pe.avail_out),Ge!==0&&(s.arraySet(pe.output,$e.pending_buf,$e.pending_out,Ge,pe.next_out),pe.next_out+=Ge,$e.pending_out+=Ge,pe.total_out+=Ge,pe.avail_out-=Ge,$e.pending-=Ge,$e.pending===0&&($e.pending_out=0))}function ae(pe,$e){a._tr_flush_block(pe,0<=pe.block_start?pe.block_start:-1,pe.strstart-pe.block_start,$e),pe.block_start=pe.strstart,ie(pe.strm)}function re(pe,$e){pe.pending_buf[pe.pending++]=$e}function le(pe,$e){pe.pending_buf[pe.pending++]=$e>>>8&255,pe.pending_buf[pe.pending++]=255&$e}function ye(pe,$e){var Ge,Pe,Ue=pe.max_chain_length,Ne=pe.strstart,Ee=pe.prev_length,Oe=pe.nice_match,Me=pe.strstart>pe.w_size-N?pe.strstart-(pe.w_size-N):0,ze=pe.window,je=pe.w_mask,st=pe.prev,ct=pe.strstart+k,ut=ze[Ne+Ee-1],lt=ze[Ne+Ee];pe.prev_length>=pe.good_match&&(Ue>>=2),Oe>pe.lookahead&&(Oe=pe.lookahead);do if(ze[(Ge=$e)+Ee]===lt&&ze[Ge+Ee-1]===ut&&ze[Ge]===ze[Ne]&&ze[++Ge]===ze[Ne+1]){Ne+=2,Ge++;do;while(ze[++Ne]===ze[++Ge]&&ze[++Ne]===ze[++Ge]&&ze[++Ne]===ze[++Ge]&&ze[++Ne]===ze[++Ge]&&ze[++Ne]===ze[++Ge]&&ze[++Ne]===ze[++Ge]&&ze[++Ne]===ze[++Ge]&&ze[++Ne]===ze[++Ge]&&Ne<ct);if(Pe=k-(ct-Ne),Ne=ct-k,Ee<Pe){if(pe.match_start=$e,Oe<=(Ee=Pe))break;ut=ze[Ne+Ee-1],lt=ze[Ne+Ee]}}while(($e=st[$e&je])>Me&&--Ue!=0);return Ee<=pe.lookahead?Ee:pe.lookahead}function xe(pe){var $e,Ge,Pe,Ue,Ne,Ee,Oe,Me,ze,je,st=pe.w_size;do{if(Ue=pe.window_size-pe.lookahead-pe.strstart,pe.strstart>=st+(st-N)){for(s.arraySet(pe.window,pe.window,st,st,0),pe.match_start-=st,pe.strstart-=st,pe.block_start-=st,$e=Ge=pe.hash_size;Pe=pe.head[--$e],pe.head[$e]=st<=Pe?Pe-st:0,--Ge;);for($e=Ge=st;Pe=pe.prev[--$e],pe.prev[$e]=st<=Pe?Pe-st:0,--Ge;);Ue+=st}if(pe.strm.avail_in===0)break;if(Ee=pe.strm,Oe=pe.window,Me=pe.strstart+pe.lookahead,ze=Ue,je=void 0,je=Ee.avail_in,ze<je&&(je=ze),Ge=je===0?0:(Ee.avail_in-=je,s.arraySet(Oe,Ee.input,Ee.next_in,je,Me),Ee.state.wrap===1?Ee.adler=c(Ee.adler,Oe,je,Me):Ee.state.wrap===2&&(Ee.adler=l(Ee.adler,Oe,je,Me)),Ee.next_in+=je,Ee.total_in+=je,je),pe.lookahead+=Ge,pe.lookahead+pe.insert>=w)for(Ne=pe.strstart-pe.insert,pe.ins_h=pe.window[Ne],pe.ins_h=(pe.ins_h<<pe.hash_shift^pe.window[Ne+1])&pe.hash_mask;pe.insert&&(pe.ins_h=(pe.ins_h<<pe.hash_shift^pe.window[Ne+w-1])&pe.hash_mask,pe.prev[Ne&pe.w_mask]=pe.head[pe.ins_h],pe.head[pe.ins_h]=Ne,Ne++,pe.insert--,!(pe.lookahead+pe.insert<w)););}while(pe.lookahead<N&&pe.strm.avail_in!==0)}function be(pe,$e){for(var Ge,Pe;;){if(pe.lookahead<N){if(xe(pe),pe.lookahead<N&&$e===u)return U;if(pe.lookahead===0)break}if(Ge=0,pe.lookahead>=w&&(pe.ins_h=(pe.ins_h<<pe.hash_shift^pe.window[pe.strstart+w-1])&pe.hash_mask,Ge=pe.prev[pe.strstart&pe.w_mask]=pe.head[pe.ins_h],pe.head[pe.ins_h]=pe.strstart),Ge!==0&&pe.strstart-Ge<=pe.w_size-N&&(pe.match_length=ye(pe,Ge)),pe.match_length>=w)if(Pe=a._tr_tally(pe,pe.strstart-pe.match_start,pe.match_length-w),pe.lookahead-=pe.match_length,pe.match_length<=pe.max_lazy_match&&pe.lookahead>=w){for(pe.match_length--;pe.strstart++,pe.ins_h=(pe.ins_h<<pe.hash_shift^pe.window[pe.strstart+w-1])&pe.hash_mask,Ge=pe.prev[pe.strstart&pe.w_mask]=pe.head[pe.ins_h],pe.head[pe.ins_h]=pe.strstart,--pe.match_length!=0;);pe.strstart++}else pe.strstart+=pe.match_length,pe.match_length=0,pe.ins_h=pe.window[pe.strstart],pe.ins_h=(pe.ins_h<<pe.hash_shift^pe.window[pe.strstart+1])&pe.hash_mask;else Pe=a._tr_tally(pe,0,pe.window[pe.strstart]),pe.lookahead--,pe.strstart++;if(Pe&&(ae(pe,!1),pe.strm.avail_out===0))return U}return pe.insert=pe.strstart<w-1?pe.strstart:w-1,$e===d?(ae(pe,!0),pe.strm.avail_out===0?W:X):pe.last_lit&&(ae(pe,!1),pe.strm.avail_out===0)?U:J}function he(pe,$e){for(var Ge,Pe,Ue;;){if(pe.lookahead<N){if(xe(pe),pe.lookahead<N&&$e===u)return U;if(pe.lookahead===0)break}if(Ge=0,pe.lookahead>=w&&(pe.ins_h=(pe.ins_h<<pe.hash_shift^pe.window[pe.strstart+w-1])&pe.hash_mask,Ge=pe.prev[pe.strstart&pe.w_mask]=pe.head[pe.ins_h],pe.head[pe.ins_h]=pe.strstart),pe.prev_length=pe.match_length,pe.prev_match=pe.match_start,pe.match_length=w-1,Ge!==0&&pe.prev_length<pe.max_lazy_match&&pe.strstart-Ge<=pe.w_size-N&&(pe.match_length=ye(pe,Ge),pe.match_length<=5&&(pe.strategy===1||pe.match_length===w&&4096<pe.strstart-pe.match_start)&&(pe.match_length=w-1)),pe.prev_length>=w&&pe.match_length<=pe.prev_length){for(Ue=pe.strstart+pe.lookahead-w,Pe=a._tr_tally(pe,pe.strstart-1-pe.prev_match,pe.prev_length-w),pe.lookahead-=pe.prev_length-1,pe.prev_length-=2;++pe.strstart<=Ue&&(pe.ins_h=(pe.ins_h<<pe.hash_shift^pe.window[pe.strstart+w-1])&pe.hash_mask,Ge=pe.prev[pe.strstart&pe.w_mask]=pe.head[pe.ins_h],pe.head[pe.ins_h]=pe.strstart),--pe.prev_length!=0;);if(pe.match_available=0,pe.match_length=w-1,pe.strstart++,Pe&&(ae(pe,!1),pe.strm.avail_out===0))return U}else if(pe.match_available){if((Pe=a._tr_tally(pe,0,pe.window[pe.strstart-1]))&&ae(pe,!1),pe.strstart++,pe.lookahead--,pe.strm.avail_out===0)return U}else pe.match_available=1,pe.strstart++,pe.lookahead--}return pe.match_available&&(Pe=a._tr_tally(pe,0,pe.window[pe.strstart-1]),pe.match_available=0),pe.insert=pe.strstart<w-1?pe.strstart:w-1,$e===d?(ae(pe,!0),pe.strm.avail_out===0?W:X):pe.last_lit&&(ae(pe,!1),pe.strm.avail_out===0)?U:J}function Se(pe,$e,Ge,Pe,Ue){this.good_length=pe,this.max_lazy=$e,this.nice_length=Ge,this.max_chain=Pe,this.func=Ue}function Ie(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=C,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new s.Buf16(2*S),this.dyn_dtree=new s.Buf16(2*(2*B+1)),this.bl_tree=new s.Buf16(2*(2*x+1)),te(this.dyn_ltree),te(this.dyn_dtree),te(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new s.Buf16(M+1),this.heap=new s.Buf16(2*y+1),te(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new s.Buf16(2*y+1),te(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function He(pe){var $e;return pe&&pe.state?(pe.total_in=pe.total_out=0,pe.data_type=I,($e=pe.state).pending=0,$e.pending_out=0,$e.wrap<0&&($e.wrap=-$e.wrap),$e.status=$e.wrap?G:H,pe.adler=$e.wrap===2?0:1,$e.last_flush=u,a._tr_init($e),h):oe(pe,_)}function Je(pe){var $e=He(pe);return $e===h&&(function(Ge){Ge.window_size=2*Ge.w_size,te(Ge.head),Ge.max_lazy_match=A[Ge.level].max_lazy,Ge.good_match=A[Ge.level].good_length,Ge.nice_match=A[Ge.level].nice_length,Ge.max_chain_length=A[Ge.level].max_chain,Ge.strstart=0,Ge.block_start=0,Ge.lookahead=0,Ge.insert=0,Ge.match_length=Ge.prev_length=w-1,Ge.match_available=0,Ge.ins_h=0})(pe.state),$e}function et(pe,$e,Ge,Pe,Ue,Ne){if(!pe)return _;var Ee=1;if($e===p&&($e=6),Pe<0?(Ee=0,Pe=-Pe):15<Pe&&(Ee=2,Pe-=16),Ue<1||f<Ue||Ge!==C||Pe<8||15<Pe||$e<0||9<$e||Ne<0||m<Ne)return oe(pe,_);Pe===8&&(Pe=9);var Oe=new Ie;return(pe.state=Oe).strm=pe,Oe.wrap=Ee,Oe.gzhead=null,Oe.w_bits=Pe,Oe.w_size=1<<Oe.w_bits,Oe.w_mask=Oe.w_size-1,Oe.hash_bits=Ue+7,Oe.hash_size=1<<Oe.hash_bits,Oe.hash_mask=Oe.hash_size-1,Oe.hash_shift=~~((Oe.hash_bits+w-1)/w),Oe.window=new s.Buf8(2*Oe.w_size),Oe.head=new s.Buf16(Oe.hash_size),Oe.prev=new s.Buf16(Oe.w_size),Oe.lit_bufsize=1<<Ue+6,Oe.pending_buf_size=4*Oe.lit_bufsize,Oe.pending_buf=new s.Buf8(Oe.pending_buf_size),Oe.d_buf=1*Oe.lit_bufsize,Oe.l_buf=3*Oe.lit_bufsize,Oe.level=$e,Oe.strategy=Ne,Oe.method=Ge,Je(pe)}A=[new Se(0,0,0,0,function(pe,$e){var Ge=65535;for(Ge>pe.pending_buf_size-5&&(Ge=pe.pending_buf_size-5);;){if(pe.lookahead<=1){if(xe(pe),pe.lookahead===0&&$e===u)return U;if(pe.lookahead===0)break}pe.strstart+=pe.lookahead,pe.lookahead=0;var Pe=pe.block_start+Ge;if((pe.strstart===0||pe.strstart>=Pe)&&(pe.lookahead=pe.strstart-Pe,pe.strstart=Pe,ae(pe,!1),pe.strm.avail_out===0)||pe.strstart-pe.block_start>=pe.w_size-N&&(ae(pe,!1),pe.strm.avail_out===0))return U}return pe.insert=0,$e===d?(ae(pe,!0),pe.strm.avail_out===0?W:X):(pe.strstart>pe.block_start&&(ae(pe,!1),pe.strm.avail_out),U)}),new Se(4,4,8,4,be),new Se(4,5,16,8,be),new Se(4,6,32,32,be),new Se(4,4,16,16,he),new Se(8,16,32,32,he),new Se(8,16,128,128,he),new Se(8,32,128,256,he),new Se(32,128,258,1024,he),new Se(32,258,258,4096,he)],r.deflateInit=function(pe,$e){return et(pe,$e,C,15,8,0)},r.deflateInit2=et,r.deflateReset=Je,r.deflateResetKeep=He,r.deflateSetHeader=function(pe,$e){return pe&&pe.state?pe.state.wrap!==2?_:(pe.state.gzhead=$e,h):_},r.deflate=function(pe,$e){var Ge,Pe,Ue,Ne;if(!pe||!pe.state||5<$e||$e<0)return pe?oe(pe,_):_;if(Pe=pe.state,!pe.output||!pe.input&&pe.avail_in!==0||Pe.status===666&&$e!==d)return oe(pe,pe.avail_out===0?-5:_);if(Pe.strm=pe,Ge=Pe.last_flush,Pe.last_flush=$e,Pe.status===G)if(Pe.wrap===2)pe.adler=0,re(Pe,31),re(Pe,139),re(Pe,8),Pe.gzhead?(re(Pe,(Pe.gzhead.text?1:0)+(Pe.gzhead.hcrc?2:0)+(Pe.gzhead.extra?4:0)+(Pe.gzhead.name?8:0)+(Pe.gzhead.comment?16:0)),re(Pe,255&Pe.gzhead.time),re(Pe,Pe.gzhead.time>>8&255),re(Pe,Pe.gzhead.time>>16&255),re(Pe,Pe.gzhead.time>>24&255),re(Pe,Pe.level===9?2:2<=Pe.strategy||Pe.level<2?4:0),re(Pe,255&Pe.gzhead.os),Pe.gzhead.extra&&Pe.gzhead.extra.length&&(re(Pe,255&Pe.gzhead.extra.length),re(Pe,Pe.gzhead.extra.length>>8&255)),Pe.gzhead.hcrc&&(pe.adler=l(pe.adler,Pe.pending_buf,Pe.pending,0)),Pe.gzindex=0,Pe.status=69):(re(Pe,0),re(Pe,0),re(Pe,0),re(Pe,0),re(Pe,0),re(Pe,Pe.level===9?2:2<=Pe.strategy||Pe.level<2?4:0),re(Pe,3),Pe.status=H);else{var Ee=C+(Pe.w_bits-8<<4)<<8;Ee|=(2<=Pe.strategy||Pe.level<2?0:Pe.level<6?1:Pe.level===6?2:3)<<6,Pe.strstart!==0&&(Ee|=32),Ee+=31-Ee%31,Pe.status=H,le(Pe,Ee),Pe.strstart!==0&&(le(Pe,pe.adler>>>16),le(Pe,65535&pe.adler)),pe.adler=1}if(Pe.status===69)if(Pe.gzhead.extra){for(Ue=Pe.pending;Pe.gzindex<(65535&Pe.gzhead.extra.length)&&(Pe.pending!==Pe.pending_buf_size||(Pe.gzhead.hcrc&&Pe.pending>Ue&&(pe.adler=l(pe.adler,Pe.pending_buf,Pe.pending-Ue,Ue)),ie(pe),Ue=Pe.pending,Pe.pending!==Pe.pending_buf_size));)re(Pe,255&Pe.gzhead.extra[Pe.gzindex]),Pe.gzindex++;Pe.gzhead.hcrc&&Pe.pending>Ue&&(pe.adler=l(pe.adler,Pe.pending_buf,Pe.pending-Ue,Ue)),Pe.gzindex===Pe.gzhead.extra.length&&(Pe.gzindex=0,Pe.status=73)}else Pe.status=73;if(Pe.status===73)if(Pe.gzhead.name){Ue=Pe.pending;do{if(Pe.pending===Pe.pending_buf_size&&(Pe.gzhead.hcrc&&Pe.pending>Ue&&(pe.adler=l(pe.adler,Pe.pending_buf,Pe.pending-Ue,Ue)),ie(pe),Ue=Pe.pending,Pe.pending===Pe.pending_buf_size)){Ne=1;break}Ne=Pe.gzindex<Pe.gzhead.name.length?255&Pe.gzhead.name.charCodeAt(Pe.gzindex++):0,re(Pe,Ne)}while(Ne!==0);Pe.gzhead.hcrc&&Pe.pending>Ue&&(pe.adler=l(pe.adler,Pe.pending_buf,Pe.pending-Ue,Ue)),Ne===0&&(Pe.gzindex=0,Pe.status=91)}else Pe.status=91;if(Pe.status===91)if(Pe.gzhead.comment){Ue=Pe.pending;do{if(Pe.pending===Pe.pending_buf_size&&(Pe.gzhead.hcrc&&Pe.pending>Ue&&(pe.adler=l(pe.adler,Pe.pending_buf,Pe.pending-Ue,Ue)),ie(pe),Ue=Pe.pending,Pe.pending===Pe.pending_buf_size)){Ne=1;break}Ne=Pe.gzindex<Pe.gzhead.comment.length?255&Pe.gzhead.comment.charCodeAt(Pe.gzindex++):0,re(Pe,Ne)}while(Ne!==0);Pe.gzhead.hcrc&&Pe.pending>Ue&&(pe.adler=l(pe.adler,Pe.pending_buf,Pe.pending-Ue,Ue)),Ne===0&&(Pe.status=103)}else Pe.status=103;if(Pe.status===103&&(Pe.gzhead.hcrc?(Pe.pending+2>Pe.pending_buf_size&&ie(pe),Pe.pending+2<=Pe.pending_buf_size&&(re(Pe,255&pe.adler),re(Pe,pe.adler>>8&255),pe.adler=0,Pe.status=H)):Pe.status=H),Pe.pending!==0){if(ie(pe),pe.avail_out===0)return Pe.last_flush=-1,h}else if(pe.avail_in===0&&ce($e)<=ce(Ge)&&$e!==d)return oe(pe,-5);if(Pe.status===666&&pe.avail_in!==0)return oe(pe,-5);if(pe.avail_in!==0||Pe.lookahead!==0||$e!==u&&Pe.status!==666){var Oe=Pe.strategy===2?(function(Me,ze){for(var je;;){if(Me.lookahead===0&&(xe(Me),Me.lookahead===0)){if(ze===u)return U;break}if(Me.match_length=0,je=a._tr_tally(Me,0,Me.window[Me.strstart]),Me.lookahead--,Me.strstart++,je&&(ae(Me,!1),Me.strm.avail_out===0))return U}return Me.insert=0,ze===d?(ae(Me,!0),Me.strm.avail_out===0?W:X):Me.last_lit&&(ae(Me,!1),Me.strm.avail_out===0)?U:J})(Pe,$e):Pe.strategy===3?(function(Me,ze){for(var je,st,ct,ut,lt=Me.window;;){if(Me.lookahead<=k){if(xe(Me),Me.lookahead<=k&&ze===u)return U;if(Me.lookahead===0)break}if(Me.match_length=0,Me.lookahead>=w&&0<Me.strstart&&(st=lt[ct=Me.strstart-1])===lt[++ct]&&st===lt[++ct]&&st===lt[++ct]){ut=Me.strstart+k;do;while(st===lt[++ct]&&st===lt[++ct]&&st===lt[++ct]&&st===lt[++ct]&&st===lt[++ct]&&st===lt[++ct]&&st===lt[++ct]&&st===lt[++ct]&&ct<ut);Me.match_length=k-(ut-ct),Me.match_length>Me.lookahead&&(Me.match_length=Me.lookahead)}if(Me.match_length>=w?(je=a._tr_tally(Me,1,Me.match_length-w),Me.lookahead-=Me.match_length,Me.strstart+=Me.match_length,Me.match_length=0):(je=a._tr_tally(Me,0,Me.window[Me.strstart]),Me.lookahead--,Me.strstart++),je&&(ae(Me,!1),Me.strm.avail_out===0))return U}return Me.insert=0,ze===d?(ae(Me,!0),Me.strm.avail_out===0?W:X):Me.last_lit&&(ae(Me,!1),Me.strm.avail_out===0)?U:J})(Pe,$e):A[Pe.level].func(Pe,$e);if(Oe!==W&&Oe!==X||(Pe.status=666),Oe===U||Oe===W)return pe.avail_out===0&&(Pe.last_flush=-1),h;if(Oe===J&&($e===1?a._tr_align(Pe):$e!==5&&(a._tr_stored_block(Pe,0,0,!1),$e===3&&(te(Pe.head),Pe.lookahead===0&&(Pe.strstart=0,Pe.block_start=0,Pe.insert=0))),ie(pe),pe.avail_out===0))return Pe.last_flush=-1,h}return $e!==d?h:Pe.wrap<=0?1:(Pe.wrap===2?(re(Pe,255&pe.adler),re(Pe,pe.adler>>8&255),re(Pe,pe.adler>>16&255),re(Pe,pe.adler>>24&255),re(Pe,255&pe.total_in),re(Pe,pe.total_in>>8&255),re(Pe,pe.total_in>>16&255),re(Pe,pe.total_in>>24&255)):(le(Pe,pe.adler>>>16),le(Pe,65535&pe.adler)),ie(pe),0<Pe.wrap&&(Pe.wrap=-Pe.wrap),Pe.pending!==0?h:1)},r.deflateEnd=function(pe){var $e;return pe&&pe.state?($e=pe.state.status)!==G&&$e!==69&&$e!==73&&$e!==91&&$e!==103&&$e!==H&&$e!==666?oe(pe,_):(pe.state=null,$e===H?oe(pe,-3):h):_},r.deflateSetDictionary=function(pe,$e){var Ge,Pe,Ue,Ne,Ee,Oe,Me,ze,je=$e.length;if(!pe||!pe.state||(Ne=(Ge=pe.state).wrap)===2||Ne===1&&Ge.status!==G||Ge.lookahead)return _;for(Ne===1&&(pe.adler=c(pe.adler,$e,je,0)),Ge.wrap=0,je>=Ge.w_size&&(Ne===0&&(te(Ge.head),Ge.strstart=0,Ge.block_start=0,Ge.insert=0),ze=new s.Buf8(Ge.w_size),s.arraySet(ze,$e,je-Ge.w_size,Ge.w_size,0),$e=ze,je=Ge.w_size),Ee=pe.avail_in,Oe=pe.next_in,Me=pe.input,pe.avail_in=je,pe.next_in=0,pe.input=$e,xe(Ge);Ge.lookahead>=w;){for(Pe=Ge.strstart,Ue=Ge.lookahead-(w-1);Ge.ins_h=(Ge.ins_h<<Ge.hash_shift^Ge.window[Pe+w-1])&Ge.hash_mask,Ge.prev[Pe&Ge.w_mask]=Ge.head[Ge.ins_h],Ge.head[Ge.ins_h]=Pe,Pe++,--Ue;);Ge.strstart=Pe,Ge.lookahead=w-1,xe(Ge)}return Ge.strstart+=Ge.lookahead,Ge.block_start=Ge.strstart,Ge.insert=Ge.lookahead,Ge.lookahead=0,Ge.match_length=Ge.prev_length=w-1,Ge.match_available=0,pe.next_in=Oe,pe.input=Me,pe.avail_in=Ee,Ge.wrap=Ne,h},r.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(o,i,r){i.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(o,i,r){i.exports=function(A,s){var a,c,l,g,u,d,h,_,p,m,I,C,f,y,B,x,S,M,w,k,N,G,H,U,J;a=A.state,c=A.next_in,U=A.input,l=c+(A.avail_in-5),g=A.next_out,J=A.output,u=g-(s-A.avail_out),d=g+(A.avail_out-257),h=a.dmax,_=a.wsize,p=a.whave,m=a.wnext,I=a.window,C=a.hold,f=a.bits,y=a.lencode,B=a.distcode,x=(1<<a.lenbits)-1,S=(1<<a.distbits)-1;e:do{f<15&&(C+=U[c++]<<f,f+=8,C+=U[c++]<<f,f+=8),M=y[C&x];t:for(;;){if(C>>>=w=M>>>24,f-=w,(w=M>>>16&255)===0)J[g++]=65535&M;else{if(!(16&w)){if((64&w)==0){M=y[(65535&M)+(C&(1<<w)-1)];continue t}if(32&w){a.mode=12;break e}A.msg="invalid literal/length code",a.mode=30;break e}k=65535&M,(w&=15)&&(f<w&&(C+=U[c++]<<f,f+=8),k+=C&(1<<w)-1,C>>>=w,f-=w),f<15&&(C+=U[c++]<<f,f+=8,C+=U[c++]<<f,f+=8),M=B[C&S];n:for(;;){if(C>>>=w=M>>>24,f-=w,!(16&(w=M>>>16&255))){if((64&w)==0){M=B[(65535&M)+(C&(1<<w)-1)];continue n}A.msg="invalid distance code",a.mode=30;break e}if(N=65535&M,f<(w&=15)&&(C+=U[c++]<<f,(f+=8)<w&&(C+=U[c++]<<f,f+=8)),h<(N+=C&(1<<w)-1)){A.msg="invalid distance too far back",a.mode=30;break e}if(C>>>=w,f-=w,(w=g-u)<N){if(p<(w=N-w)&&a.sane){A.msg="invalid distance too far back",a.mode=30;break e}if(H=I,(G=0)===m){if(G+=_-w,w<k){for(k-=w;J[g++]=I[G++],--w;);G=g-N,H=J}}else if(m<w){if(G+=_+m-w,(w-=m)<k){for(k-=w;J[g++]=I[G++],--w;);if(G=0,m<k){for(k-=w=m;J[g++]=I[G++],--w;);G=g-N,H=J}}}else if(G+=m-w,w<k){for(k-=w;J[g++]=I[G++],--w;);G=g-N,H=J}for(;2<k;)J[g++]=H[G++],J[g++]=H[G++],J[g++]=H[G++],k-=3;k&&(J[g++]=H[G++],1<k&&(J[g++]=H[G++]))}else{for(G=g-N;J[g++]=J[G++],J[g++]=J[G++],J[g++]=J[G++],2<(k-=3););k&&(J[g++]=J[G++],1<k&&(J[g++]=J[G++]))}break}}break}}while(c<l&&g<d);c-=k=f>>3,C&=(1<<(f-=k<<3))-1,A.next_in=c,A.next_out=g,A.avail_in=c<l?l-c+5:5-(c-l),A.avail_out=g<d?d-g+257:257-(g-d),a.hold=C,a.bits=f}},{}],49:[function(o,i,r){var A=o("../utils/common"),s=o("./adler32"),a=o("./crc32"),c=o("./inffast"),l=o("./inftrees"),g=1,u=2,d=0,h=-2,_=1,p=852,m=592;function I(G){return(G>>>24&255)+(G>>>8&65280)+((65280&G)<<8)+((255&G)<<24)}function C(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new A.Buf16(320),this.work=new A.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function f(G){var H;return G&&G.state?(H=G.state,G.total_in=G.total_out=H.total=0,G.msg="",H.wrap&&(G.adler=1&H.wrap),H.mode=_,H.last=0,H.havedict=0,H.dmax=32768,H.head=null,H.hold=0,H.bits=0,H.lencode=H.lendyn=new A.Buf32(p),H.distcode=H.distdyn=new A.Buf32(m),H.sane=1,H.back=-1,d):h}function y(G){var H;return G&&G.state?((H=G.state).wsize=0,H.whave=0,H.wnext=0,f(G)):h}function B(G,H){var U,J;return G&&G.state?(J=G.state,H<0?(U=0,H=-H):(U=1+(H>>4),H<48&&(H&=15)),H&&(H<8||15<H)?h:(J.window!==null&&J.wbits!==H&&(J.window=null),J.wrap=U,J.wbits=H,y(G))):h}function x(G,H){var U,J;return G?(J=new C,(G.state=J).window=null,(U=B(G,H))!==d&&(G.state=null),U):h}var S,M,w=!0;function k(G){if(w){var H;for(S=new A.Buf32(512),M=new A.Buf32(32),H=0;H<144;)G.lens[H++]=8;for(;H<256;)G.lens[H++]=9;for(;H<280;)G.lens[H++]=7;for(;H<288;)G.lens[H++]=8;for(l(g,G.lens,0,288,S,0,G.work,{bits:9}),H=0;H<32;)G.lens[H++]=5;l(u,G.lens,0,32,M,0,G.work,{bits:5}),w=!1}G.lencode=S,G.lenbits=9,G.distcode=M,G.distbits=5}function N(G,H,U,J){var W,X=G.state;return X.window===null&&(X.wsize=1<<X.wbits,X.wnext=0,X.whave=0,X.window=new A.Buf8(X.wsize)),J>=X.wsize?(A.arraySet(X.window,H,U-X.wsize,X.wsize,0),X.wnext=0,X.whave=X.wsize):(J<(W=X.wsize-X.wnext)&&(W=J),A.arraySet(X.window,H,U-J,W,X.wnext),(J-=W)?(A.arraySet(X.window,H,U-J,J,0),X.wnext=J,X.whave=X.wsize):(X.wnext+=W,X.wnext===X.wsize&&(X.wnext=0),X.whave<X.wsize&&(X.whave+=W))),0}r.inflateReset=y,r.inflateReset2=B,r.inflateResetKeep=f,r.inflateInit=function(G){return x(G,15)},r.inflateInit2=x,r.inflate=function(G,H){var U,J,W,X,oe,ce,te,ie,ae,re,le,ye,xe,be,he,Se,Ie,He,Je,et,pe,$e,Ge,Pe,Ue=0,Ne=new A.Buf8(4),Ee=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!G||!G.state||!G.output||!G.input&&G.avail_in!==0)return h;(U=G.state).mode===12&&(U.mode=13),oe=G.next_out,W=G.output,te=G.avail_out,X=G.next_in,J=G.input,ce=G.avail_in,ie=U.hold,ae=U.bits,re=ce,le=te,$e=d;e:for(;;)switch(U.mode){case _:if(U.wrap===0){U.mode=13;break}for(;ae<16;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}if(2&U.wrap&&ie===35615){Ne[U.check=0]=255&ie,Ne[1]=ie>>>8&255,U.check=a(U.check,Ne,2,0),ae=ie=0,U.mode=2;break}if(U.flags=0,U.head&&(U.head.done=!1),!(1&U.wrap)||(((255&ie)<<8)+(ie>>8))%31){G.msg="incorrect header check",U.mode=30;break}if((15&ie)!=8){G.msg="unknown compression method",U.mode=30;break}if(ae-=4,pe=8+(15&(ie>>>=4)),U.wbits===0)U.wbits=pe;else if(pe>U.wbits){G.msg="invalid window size",U.mode=30;break}U.dmax=1<<pe,G.adler=U.check=1,U.mode=512&ie?10:12,ae=ie=0;break;case 2:for(;ae<16;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}if(U.flags=ie,(255&U.flags)!=8){G.msg="unknown compression method",U.mode=30;break}if(57344&U.flags){G.msg="unknown header flags set",U.mode=30;break}U.head&&(U.head.text=ie>>8&1),512&U.flags&&(Ne[0]=255&ie,Ne[1]=ie>>>8&255,U.check=a(U.check,Ne,2,0)),ae=ie=0,U.mode=3;case 3:for(;ae<32;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}U.head&&(U.head.time=ie),512&U.flags&&(Ne[0]=255&ie,Ne[1]=ie>>>8&255,Ne[2]=ie>>>16&255,Ne[3]=ie>>>24&255,U.check=a(U.check,Ne,4,0)),ae=ie=0,U.mode=4;case 4:for(;ae<16;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}U.head&&(U.head.xflags=255&ie,U.head.os=ie>>8),512&U.flags&&(Ne[0]=255&ie,Ne[1]=ie>>>8&255,U.check=a(U.check,Ne,2,0)),ae=ie=0,U.mode=5;case 5:if(1024&U.flags){for(;ae<16;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}U.length=ie,U.head&&(U.head.extra_len=ie),512&U.flags&&(Ne[0]=255&ie,Ne[1]=ie>>>8&255,U.check=a(U.check,Ne,2,0)),ae=ie=0}else U.head&&(U.head.extra=null);U.mode=6;case 6:if(1024&U.flags&&(ce<(ye=U.length)&&(ye=ce),ye&&(U.head&&(pe=U.head.extra_len-U.length,U.head.extra||(U.head.extra=new Array(U.head.extra_len)),A.arraySet(U.head.extra,J,X,ye,pe)),512&U.flags&&(U.check=a(U.check,J,ye,X)),ce-=ye,X+=ye,U.length-=ye),U.length))break e;U.length=0,U.mode=7;case 7:if(2048&U.flags){if(ce===0)break e;for(ye=0;pe=J[X+ye++],U.head&&pe&&U.length<65536&&(U.head.name+=String.fromCharCode(pe)),pe&&ye<ce;);if(512&U.flags&&(U.check=a(U.check,J,ye,X)),ce-=ye,X+=ye,pe)break e}else U.head&&(U.head.name=null);U.length=0,U.mode=8;case 8:if(4096&U.flags){if(ce===0)break e;for(ye=0;pe=J[X+ye++],U.head&&pe&&U.length<65536&&(U.head.comment+=String.fromCharCode(pe)),pe&&ye<ce;);if(512&U.flags&&(U.check=a(U.check,J,ye,X)),ce-=ye,X+=ye,pe)break e}else U.head&&(U.head.comment=null);U.mode=9;case 9:if(512&U.flags){for(;ae<16;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}if(ie!==(65535&U.check)){G.msg="header crc mismatch",U.mode=30;break}ae=ie=0}U.head&&(U.head.hcrc=U.flags>>9&1,U.head.done=!0),G.adler=U.check=0,U.mode=12;break;case 10:for(;ae<32;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}G.adler=U.check=I(ie),ae=ie=0,U.mode=11;case 11:if(U.havedict===0)return G.next_out=oe,G.avail_out=te,G.next_in=X,G.avail_in=ce,U.hold=ie,U.bits=ae,2;G.adler=U.check=1,U.mode=12;case 12:if(H===5||H===6)break e;case 13:if(U.last){ie>>>=7&ae,ae-=7&ae,U.mode=27;break}for(;ae<3;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}switch(U.last=1&ie,ae-=1,3&(ie>>>=1)){case 0:U.mode=14;break;case 1:if(k(U),U.mode=20,H!==6)break;ie>>>=2,ae-=2;break e;case 2:U.mode=17;break;case 3:G.msg="invalid block type",U.mode=30}ie>>>=2,ae-=2;break;case 14:for(ie>>>=7&ae,ae-=7&ae;ae<32;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}if((65535&ie)!=(ie>>>16^65535)){G.msg="invalid stored block lengths",U.mode=30;break}if(U.length=65535&ie,ae=ie=0,U.mode=15,H===6)break e;case 15:U.mode=16;case 16:if(ye=U.length){if(ce<ye&&(ye=ce),te<ye&&(ye=te),ye===0)break e;A.arraySet(W,J,X,ye,oe),ce-=ye,X+=ye,te-=ye,oe+=ye,U.length-=ye;break}U.mode=12;break;case 17:for(;ae<14;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}if(U.nlen=257+(31&ie),ie>>>=5,ae-=5,U.ndist=1+(31&ie),ie>>>=5,ae-=5,U.ncode=4+(15&ie),ie>>>=4,ae-=4,286<U.nlen||30<U.ndist){G.msg="too many length or distance symbols",U.mode=30;break}U.have=0,U.mode=18;case 18:for(;U.have<U.ncode;){for(;ae<3;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}U.lens[Ee[U.have++]]=7&ie,ie>>>=3,ae-=3}for(;U.have<19;)U.lens[Ee[U.have++]]=0;if(U.lencode=U.lendyn,U.lenbits=7,Ge={bits:U.lenbits},$e=l(0,U.lens,0,19,U.lencode,0,U.work,Ge),U.lenbits=Ge.bits,$e){G.msg="invalid code lengths set",U.mode=30;break}U.have=0,U.mode=19;case 19:for(;U.have<U.nlen+U.ndist;){for(;Se=(Ue=U.lencode[ie&(1<<U.lenbits)-1])>>>16&255,Ie=65535&Ue,!((he=Ue>>>24)<=ae);){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}if(Ie<16)ie>>>=he,ae-=he,U.lens[U.have++]=Ie;else{if(Ie===16){for(Pe=he+2;ae<Pe;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}if(ie>>>=he,ae-=he,U.have===0){G.msg="invalid bit length repeat",U.mode=30;break}pe=U.lens[U.have-1],ye=3+(3&ie),ie>>>=2,ae-=2}else if(Ie===17){for(Pe=he+3;ae<Pe;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}ae-=he,pe=0,ye=3+(7&(ie>>>=he)),ie>>>=3,ae-=3}else{for(Pe=he+7;ae<Pe;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}ae-=he,pe=0,ye=11+(127&(ie>>>=he)),ie>>>=7,ae-=7}if(U.have+ye>U.nlen+U.ndist){G.msg="invalid bit length repeat",U.mode=30;break}for(;ye--;)U.lens[U.have++]=pe}}if(U.mode===30)break;if(U.lens[256]===0){G.msg="invalid code -- missing end-of-block",U.mode=30;break}if(U.lenbits=9,Ge={bits:U.lenbits},$e=l(g,U.lens,0,U.nlen,U.lencode,0,U.work,Ge),U.lenbits=Ge.bits,$e){G.msg="invalid literal/lengths set",U.mode=30;break}if(U.distbits=6,U.distcode=U.distdyn,Ge={bits:U.distbits},$e=l(u,U.lens,U.nlen,U.ndist,U.distcode,0,U.work,Ge),U.distbits=Ge.bits,$e){G.msg="invalid distances set",U.mode=30;break}if(U.mode=20,H===6)break e;case 20:U.mode=21;case 21:if(6<=ce&&258<=te){G.next_out=oe,G.avail_out=te,G.next_in=X,G.avail_in=ce,U.hold=ie,U.bits=ae,c(G,le),oe=G.next_out,W=G.output,te=G.avail_out,X=G.next_in,J=G.input,ce=G.avail_in,ie=U.hold,ae=U.bits,U.mode===12&&(U.back=-1);break}for(U.back=0;Se=(Ue=U.lencode[ie&(1<<U.lenbits)-1])>>>16&255,Ie=65535&Ue,!((he=Ue>>>24)<=ae);){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}if(Se&&(240&Se)==0){for(He=he,Je=Se,et=Ie;Se=(Ue=U.lencode[et+((ie&(1<<He+Je)-1)>>He)])>>>16&255,Ie=65535&Ue,!(He+(he=Ue>>>24)<=ae);){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}ie>>>=He,ae-=He,U.back+=He}if(ie>>>=he,ae-=he,U.back+=he,U.length=Ie,Se===0){U.mode=26;break}if(32&Se){U.back=-1,U.mode=12;break}if(64&Se){G.msg="invalid literal/length code",U.mode=30;break}U.extra=15&Se,U.mode=22;case 22:if(U.extra){for(Pe=U.extra;ae<Pe;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}U.length+=ie&(1<<U.extra)-1,ie>>>=U.extra,ae-=U.extra,U.back+=U.extra}U.was=U.length,U.mode=23;case 23:for(;Se=(Ue=U.distcode[ie&(1<<U.distbits)-1])>>>16&255,Ie=65535&Ue,!((he=Ue>>>24)<=ae);){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}if((240&Se)==0){for(He=he,Je=Se,et=Ie;Se=(Ue=U.distcode[et+((ie&(1<<He+Je)-1)>>He)])>>>16&255,Ie=65535&Ue,!(He+(he=Ue>>>24)<=ae);){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}ie>>>=He,ae-=He,U.back+=He}if(ie>>>=he,ae-=he,U.back+=he,64&Se){G.msg="invalid distance code",U.mode=30;break}U.offset=Ie,U.extra=15&Se,U.mode=24;case 24:if(U.extra){for(Pe=U.extra;ae<Pe;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}U.offset+=ie&(1<<U.extra)-1,ie>>>=U.extra,ae-=U.extra,U.back+=U.extra}if(U.offset>U.dmax){G.msg="invalid distance too far back",U.mode=30;break}U.mode=25;case 25:if(te===0)break e;if(ye=le-te,U.offset>ye){if((ye=U.offset-ye)>U.whave&&U.sane){G.msg="invalid distance too far back",U.mode=30;break}xe=ye>U.wnext?(ye-=U.wnext,U.wsize-ye):U.wnext-ye,ye>U.length&&(ye=U.length),be=U.window}else be=W,xe=oe-U.offset,ye=U.length;for(te<ye&&(ye=te),te-=ye,U.length-=ye;W[oe++]=be[xe++],--ye;);U.length===0&&(U.mode=21);break;case 26:if(te===0)break e;W[oe++]=U.length,te--,U.mode=21;break;case 27:if(U.wrap){for(;ae<32;){if(ce===0)break e;ce--,ie|=J[X++]<<ae,ae+=8}if(le-=te,G.total_out+=le,U.total+=le,le&&(G.adler=U.check=U.flags?a(U.check,W,le,oe-le):s(U.check,W,le,oe-le)),le=te,(U.flags?ie:I(ie))!==U.check){G.msg="incorrect data check",U.mode=30;break}ae=ie=0}U.mode=28;case 28:if(U.wrap&&U.flags){for(;ae<32;){if(ce===0)break e;ce--,ie+=J[X++]<<ae,ae+=8}if(ie!==(4294967295&U.total)){G.msg="incorrect length check",U.mode=30;break}ae=ie=0}U.mode=29;case 29:$e=1;break e;case 30:$e=-3;break e;case 31:return-4;default:return h}return G.next_out=oe,G.avail_out=te,G.next_in=X,G.avail_in=ce,U.hold=ie,U.bits=ae,(U.wsize||le!==G.avail_out&&U.mode<30&&(U.mode<27||H!==4))&&N(G,G.output,G.next_out,le-G.avail_out)?(U.mode=31,-4):(re-=G.avail_in,le-=G.avail_out,G.total_in+=re,G.total_out+=le,U.total+=le,U.wrap&&le&&(G.adler=U.check=U.flags?a(U.check,W,le,G.next_out-le):s(U.check,W,le,G.next_out-le)),G.data_type=U.bits+(U.last?64:0)+(U.mode===12?128:0)+(U.mode===20||U.mode===15?256:0),(re==0&&le===0||H===4)&&$e===d&&($e=-5),$e)},r.inflateEnd=function(G){if(!G||!G.state)return h;var H=G.state;return H.window&&(H.window=null),G.state=null,d},r.inflateGetHeader=function(G,H){var U;return G&&G.state?(2&(U=G.state).wrap)==0?h:((U.head=H).done=!1,d):h},r.inflateSetDictionary=function(G,H){var U,J=H.length;return G&&G.state?(U=G.state).wrap!==0&&U.mode!==11?h:U.mode===11&&s(1,H,J,0)!==U.check?-3:N(G,H,J,J)?(U.mode=31,-4):(U.havedict=1,d):h},r.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(o,i,r){var A=o("../utils/common"),s=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],a=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],l=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];i.exports=function(g,u,d,h,_,p,m,I){var C,f,y,B,x,S,M,w,k,N=I.bits,G=0,H=0,U=0,J=0,W=0,X=0,oe=0,ce=0,te=0,ie=0,ae=null,re=0,le=new A.Buf16(16),ye=new A.Buf16(16),xe=null,be=0;for(G=0;G<=15;G++)le[G]=0;for(H=0;H<h;H++)le[u[d+H]]++;for(W=N,J=15;1<=J&&le[J]===0;J--);if(J<W&&(W=J),J===0)return _[p++]=20971520,_[p++]=20971520,I.bits=1,0;for(U=1;U<J&&le[U]===0;U++);for(W<U&&(W=U),G=ce=1;G<=15;G++)if(ce<<=1,(ce-=le[G])<0)return-1;if(0<ce&&(g===0||J!==1))return-1;for(ye[1]=0,G=1;G<15;G++)ye[G+1]=ye[G]+le[G];for(H=0;H<h;H++)u[d+H]!==0&&(m[ye[u[d+H]]++]=H);if(S=g===0?(ae=xe=m,19):g===1?(ae=s,re-=257,xe=a,be-=257,256):(ae=c,xe=l,-1),G=U,x=p,oe=H=ie=0,y=-1,B=(te=1<<(X=W))-1,g===1&&852<te||g===2&&592<te)return 1;for(;;){for(M=G-oe,k=m[H]<S?(w=0,m[H]):m[H]>S?(w=xe[be+m[H]],ae[re+m[H]]):(w=96,0),C=1<<G-oe,U=f=1<<X;_[x+(ie>>oe)+(f-=C)]=M<<24|w<<16|k|0,f!==0;);for(C=1<<G-1;ie&C;)C>>=1;if(C!==0?(ie&=C-1,ie+=C):ie=0,H++,--le[G]==0){if(G===J)break;G=u[d+m[H]]}if(W<G&&(ie&B)!==y){for(oe===0&&(oe=W),x+=U,ce=1<<(X=G-oe);X+oe<J&&!((ce-=le[X+oe])<=0);)X++,ce<<=1;if(te+=1<<X,g===1&&852<te||g===2&&592<te)return 1;_[y=ie&B]=W<<24|X<<16|x-p|0}}return ie!==0&&(_[x+ie]=G-oe<<24|64<<16|0),I.bits=W,0}},{"../utils/common":41}],51:[function(o,i,r){i.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(o,i,r){var A=o("../utils/common"),s=0,a=1;function c(Ue){for(var Ne=Ue.length;0<=--Ne;)Ue[Ne]=0}var l=0,g=29,u=256,d=u+1+g,h=30,_=19,p=2*d+1,m=15,I=16,C=7,f=256,y=16,B=17,x=18,S=[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],M=[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],w=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],k=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],N=new Array(2*(d+2));c(N);var G=new Array(2*h);c(G);var H=new Array(512);c(H);var U=new Array(256);c(U);var J=new Array(g);c(J);var W,X,oe,ce=new Array(h);function te(Ue,Ne,Ee,Oe,Me){this.static_tree=Ue,this.extra_bits=Ne,this.extra_base=Ee,this.elems=Oe,this.max_length=Me,this.has_stree=Ue&&Ue.length}function ie(Ue,Ne){this.dyn_tree=Ue,this.max_code=0,this.stat_desc=Ne}function ae(Ue){return Ue<256?H[Ue]:H[256+(Ue>>>7)]}function re(Ue,Ne){Ue.pending_buf[Ue.pending++]=255&Ne,Ue.pending_buf[Ue.pending++]=Ne>>>8&255}function le(Ue,Ne,Ee){Ue.bi_valid>I-Ee?(Ue.bi_buf|=Ne<<Ue.bi_valid&65535,re(Ue,Ue.bi_buf),Ue.bi_buf=Ne>>I-Ue.bi_valid,Ue.bi_valid+=Ee-I):(Ue.bi_buf|=Ne<<Ue.bi_valid&65535,Ue.bi_valid+=Ee)}function ye(Ue,Ne,Ee){le(Ue,Ee[2*Ne],Ee[2*Ne+1])}function xe(Ue,Ne){for(var Ee=0;Ee|=1&Ue,Ue>>>=1,Ee<<=1,0<--Ne;);return Ee>>>1}function be(Ue,Ne,Ee){var Oe,Me,ze=new Array(m+1),je=0;for(Oe=1;Oe<=m;Oe++)ze[Oe]=je=je+Ee[Oe-1]<<1;for(Me=0;Me<=Ne;Me++){var st=Ue[2*Me+1];st!==0&&(Ue[2*Me]=xe(ze[st]++,st))}}function he(Ue){var Ne;for(Ne=0;Ne<d;Ne++)Ue.dyn_ltree[2*Ne]=0;for(Ne=0;Ne<h;Ne++)Ue.dyn_dtree[2*Ne]=0;for(Ne=0;Ne<_;Ne++)Ue.bl_tree[2*Ne]=0;Ue.dyn_ltree[2*f]=1,Ue.opt_len=Ue.static_len=0,Ue.last_lit=Ue.matches=0}function Se(Ue){8<Ue.bi_valid?re(Ue,Ue.bi_buf):0<Ue.bi_valid&&(Ue.pending_buf[Ue.pending++]=Ue.bi_buf),Ue.bi_buf=0,Ue.bi_valid=0}function Ie(Ue,Ne,Ee,Oe){var Me=2*Ne,ze=2*Ee;return Ue[Me]<Ue[ze]||Ue[Me]===Ue[ze]&&Oe[Ne]<=Oe[Ee]}function He(Ue,Ne,Ee){for(var Oe=Ue.heap[Ee],Me=Ee<<1;Me<=Ue.heap_len&&(Me<Ue.heap_len&&Ie(Ne,Ue.heap[Me+1],Ue.heap[Me],Ue.depth)&&Me++,!Ie(Ne,Oe,Ue.heap[Me],Ue.depth));)Ue.heap[Ee]=Ue.heap[Me],Ee=Me,Me<<=1;Ue.heap[Ee]=Oe}function Je(Ue,Ne,Ee){var Oe,Me,ze,je,st=0;if(Ue.last_lit!==0)for(;Oe=Ue.pending_buf[Ue.d_buf+2*st]<<8|Ue.pending_buf[Ue.d_buf+2*st+1],Me=Ue.pending_buf[Ue.l_buf+st],st++,Oe===0?ye(Ue,Me,Ne):(ye(Ue,(ze=U[Me])+u+1,Ne),(je=S[ze])!==0&&le(Ue,Me-=J[ze],je),ye(Ue,ze=ae(--Oe),Ee),(je=M[ze])!==0&&le(Ue,Oe-=ce[ze],je)),st<Ue.last_lit;);ye(Ue,f,Ne)}function et(Ue,Ne){var Ee,Oe,Me,ze=Ne.dyn_tree,je=Ne.stat_desc.static_tree,st=Ne.stat_desc.has_stree,ct=Ne.stat_desc.elems,ut=-1;for(Ue.heap_len=0,Ue.heap_max=p,Ee=0;Ee<ct;Ee++)ze[2*Ee]!==0?(Ue.heap[++Ue.heap_len]=ut=Ee,Ue.depth[Ee]=0):ze[2*Ee+1]=0;for(;Ue.heap_len<2;)ze[2*(Me=Ue.heap[++Ue.heap_len]=ut<2?++ut:0)]=1,Ue.depth[Me]=0,Ue.opt_len--,st&&(Ue.static_len-=je[2*Me+1]);for(Ne.max_code=ut,Ee=Ue.heap_len>>1;1<=Ee;Ee--)He(Ue,ze,Ee);for(Me=ct;Ee=Ue.heap[1],Ue.heap[1]=Ue.heap[Ue.heap_len--],He(Ue,ze,1),Oe=Ue.heap[1],Ue.heap[--Ue.heap_max]=Ee,Ue.heap[--Ue.heap_max]=Oe,ze[2*Me]=ze[2*Ee]+ze[2*Oe],Ue.depth[Me]=(Ue.depth[Ee]>=Ue.depth[Oe]?Ue.depth[Ee]:Ue.depth[Oe])+1,ze[2*Ee+1]=ze[2*Oe+1]=Me,Ue.heap[1]=Me++,He(Ue,ze,1),2<=Ue.heap_len;);Ue.heap[--Ue.heap_max]=Ue.heap[1],(function(lt,Ct){var Dt,It,Nt,Lt,gn,un,Vt=Ct.dyn_tree,Ce=Ct.max_code,rt=Ct.stat_desc.static_tree,At=Ct.stat_desc.has_stree,Et=Ct.stat_desc.extra_bits,Ft=Ct.stat_desc.extra_base,Kt=Ct.stat_desc.max_length,ln=0;for(Lt=0;Lt<=m;Lt++)lt.bl_count[Lt]=0;for(Vt[2*lt.heap[lt.heap_max]+1]=0,Dt=lt.heap_max+1;Dt<p;Dt++)Kt<(Lt=Vt[2*Vt[2*(It=lt.heap[Dt])+1]+1]+1)&&(Lt=Kt,ln++),Vt[2*It+1]=Lt,Ce<It||(lt.bl_count[Lt]++,gn=0,Ft<=It&&(gn=Et[It-Ft]),un=Vt[2*It],lt.opt_len+=un*(Lt+gn),At&&(lt.static_len+=un*(rt[2*It+1]+gn)));if(ln!==0){do{for(Lt=Kt-1;lt.bl_count[Lt]===0;)Lt--;lt.bl_count[Lt]--,lt.bl_count[Lt+1]+=2,lt.bl_count[Kt]--,ln-=2}while(0<ln);for(Lt=Kt;Lt!==0;Lt--)for(It=lt.bl_count[Lt];It!==0;)Ce<(Nt=lt.heap[--Dt])||(Vt[2*Nt+1]!==Lt&&(lt.opt_len+=(Lt-Vt[2*Nt+1])*Vt[2*Nt],Vt[2*Nt+1]=Lt),It--)}})(Ue,Ne),be(ze,ut,Ue.bl_count)}function pe(Ue,Ne,Ee){var Oe,Me,ze=-1,je=Ne[1],st=0,ct=7,ut=4;for(je===0&&(ct=138,ut=3),Ne[2*(Ee+1)+1]=65535,Oe=0;Oe<=Ee;Oe++)Me=je,je=Ne[2*(Oe+1)+1],++st<ct&&Me===je||(st<ut?Ue.bl_tree[2*Me]+=st:Me!==0?(Me!==ze&&Ue.bl_tree[2*Me]++,Ue.bl_tree[2*y]++):st<=10?Ue.bl_tree[2*B]++:Ue.bl_tree[2*x]++,ze=Me,ut=(st=0)===je?(ct=138,3):Me===je?(ct=6,3):(ct=7,4))}function $e(Ue,Ne,Ee){var Oe,Me,ze=-1,je=Ne[1],st=0,ct=7,ut=4;for(je===0&&(ct=138,ut=3),Oe=0;Oe<=Ee;Oe++)if(Me=je,je=Ne[2*(Oe+1)+1],!(++st<ct&&Me===je)){if(st<ut)for(;ye(Ue,Me,Ue.bl_tree),--st!=0;);else Me!==0?(Me!==ze&&(ye(Ue,Me,Ue.bl_tree),st--),ye(Ue,y,Ue.bl_tree),le(Ue,st-3,2)):st<=10?(ye(Ue,B,Ue.bl_tree),le(Ue,st-3,3)):(ye(Ue,x,Ue.bl_tree),le(Ue,st-11,7));ze=Me,ut=(st=0)===je?(ct=138,3):Me===je?(ct=6,3):(ct=7,4)}}c(ce);var Ge=!1;function Pe(Ue,Ne,Ee,Oe){le(Ue,(l<<1)+(Oe?1:0),3),(function(Me,ze,je,st){Se(Me),re(Me,je),re(Me,~je),A.arraySet(Me.pending_buf,Me.window,ze,je,Me.pending),Me.pending+=je})(Ue,Ne,Ee)}r._tr_init=function(Ue){Ge||((function(){var Ne,Ee,Oe,Me,ze,je=new Array(m+1);for(Me=Oe=0;Me<g-1;Me++)for(J[Me]=Oe,Ne=0;Ne<1<<S[Me];Ne++)U[Oe++]=Me;for(U[Oe-1]=Me,Me=ze=0;Me<16;Me++)for(ce[Me]=ze,Ne=0;Ne<1<<M[Me];Ne++)H[ze++]=Me;for(ze>>=7;Me<h;Me++)for(ce[Me]=ze<<7,Ne=0;Ne<1<<M[Me]-7;Ne++)H[256+ze++]=Me;for(Ee=0;Ee<=m;Ee++)je[Ee]=0;for(Ne=0;Ne<=143;)N[2*Ne+1]=8,Ne++,je[8]++;for(;Ne<=255;)N[2*Ne+1]=9,Ne++,je[9]++;for(;Ne<=279;)N[2*Ne+1]=7,Ne++,je[7]++;for(;Ne<=287;)N[2*Ne+1]=8,Ne++,je[8]++;for(be(N,d+1,je),Ne=0;Ne<h;Ne++)G[2*Ne+1]=5,G[2*Ne]=xe(Ne,5);W=new te(N,S,u+1,d,m),X=new te(G,M,0,h,m),oe=new te(new Array(0),w,0,_,C)})(),Ge=!0),Ue.l_desc=new ie(Ue.dyn_ltree,W),Ue.d_desc=new ie(Ue.dyn_dtree,X),Ue.bl_desc=new ie(Ue.bl_tree,oe),Ue.bi_buf=0,Ue.bi_valid=0,he(Ue)},r._tr_stored_block=Pe,r._tr_flush_block=function(Ue,Ne,Ee,Oe){var Me,ze,je=0;0<Ue.level?(Ue.strm.data_type===2&&(Ue.strm.data_type=(function(st){var ct,ut=4093624447;for(ct=0;ct<=31;ct++,ut>>>=1)if(1&ut&&st.dyn_ltree[2*ct]!==0)return s;if(st.dyn_ltree[18]!==0||st.dyn_ltree[20]!==0||st.dyn_ltree[26]!==0)return a;for(ct=32;ct<u;ct++)if(st.dyn_ltree[2*ct]!==0)return a;return s})(Ue)),et(Ue,Ue.l_desc),et(Ue,Ue.d_desc),je=(function(st){var ct;for(pe(st,st.dyn_ltree,st.l_desc.max_code),pe(st,st.dyn_dtree,st.d_desc.max_code),et(st,st.bl_desc),ct=_-1;3<=ct&&st.bl_tree[2*k[ct]+1]===0;ct--);return st.opt_len+=3*(ct+1)+5+5+4,ct})(Ue),Me=Ue.opt_len+3+7>>>3,(ze=Ue.static_len+3+7>>>3)<=Me&&(Me=ze)):Me=ze=Ee+5,Ee+4<=Me&&Ne!==-1?Pe(Ue,Ne,Ee,Oe):Ue.strategy===4||ze===Me?(le(Ue,2+(Oe?1:0),3),Je(Ue,N,G)):(le(Ue,4+(Oe?1:0),3),(function(st,ct,ut,lt){var Ct;for(le(st,ct-257,5),le(st,ut-1,5),le(st,lt-4,4),Ct=0;Ct<lt;Ct++)le(st,st.bl_tree[2*k[Ct]+1],3);$e(st,st.dyn_ltree,ct-1),$e(st,st.dyn_dtree,ut-1)})(Ue,Ue.l_desc.max_code+1,Ue.d_desc.max_code+1,je+1),Je(Ue,Ue.dyn_ltree,Ue.dyn_dtree)),he(Ue),Oe&&Se(Ue)},r._tr_tally=function(Ue,Ne,Ee){return Ue.pending_buf[Ue.d_buf+2*Ue.last_lit]=Ne>>>8&255,Ue.pending_buf[Ue.d_buf+2*Ue.last_lit+1]=255&Ne,Ue.pending_buf[Ue.l_buf+Ue.last_lit]=255&Ee,Ue.last_lit++,Ne===0?Ue.dyn_ltree[2*Ee]++:(Ue.matches++,Ne--,Ue.dyn_ltree[2*(U[Ee]+u+1)]++,Ue.dyn_dtree[2*ae(Ne)]++),Ue.last_lit===Ue.lit_bufsize-1},r._tr_align=function(Ue){le(Ue,2,3),ye(Ue,f,N),(function(Ne){Ne.bi_valid===16?(re(Ne,Ne.bi_buf),Ne.bi_buf=0,Ne.bi_valid=0):8<=Ne.bi_valid&&(Ne.pending_buf[Ne.pending++]=255&Ne.bi_buf,Ne.bi_buf>>=8,Ne.bi_valid-=8)})(Ue)}},{"../utils/common":41}],53:[function(o,i,r){i.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(o,i,r){(function(A){(function(s,a){if(!s.setImmediate){var c,l,g,u,d=1,h={},_=!1,p=s.document,m=Object.getPrototypeOf&&Object.getPrototypeOf(s);m=m&&m.setTimeout?m:s,c={}.toString.call(s.process)==="[object process]"?function(y){n.nextTick(function(){C(y)})}:(function(){if(s.postMessage&&!s.importScripts){var y=!0,B=s.onmessage;return s.onmessage=function(){y=!1},s.postMessage("","*"),s.onmessage=B,y}})()?(u="setImmediate$"+Math.random()+"$",s.addEventListener?s.addEventListener("message",f,!1):s.attachEvent("onmessage",f),function(y){s.postMessage(u+y,"*")}):s.MessageChannel?((g=new MessageChannel).port1.onmessage=function(y){C(y.data)},function(y){g.port2.postMessage(y)}):p&&"onreadystatechange"in p.createElement("script")?(l=p.documentElement,function(y){var B=p.createElement("script");B.onreadystatechange=function(){C(y),B.onreadystatechange=null,l.removeChild(B),B=null},l.appendChild(B)}):function(y){setTimeout(C,0,y)},m.setImmediate=function(y){typeof y!="function"&&(y=new Function(""+y));for(var B=new Array(arguments.length-1),x=0;x<B.length;x++)B[x]=arguments[x+1];var S={callback:y,args:B};return h[d]=S,c(d),d++},m.clearImmediate=I}function I(y){delete h[y]}function C(y){if(_)setTimeout(C,0,y);else{var B=h[y];if(B){_=!0;try{(function(x){var S=x.callback,M=x.args;switch(M.length){case 0:S();break;case 1:S(M[0]);break;case 2:S(M[0],M[1]);break;case 3:S(M[0],M[1],M[2]);break;default:S.apply(a,M)}})(B)}finally{I(y),_=!1}}}}function f(y){y.source===s&&typeof y.data=="string"&&y.data.indexOf(u)===0&&C(+y.data.slice(u.length))}})(typeof self>"u"?A===void 0?this:A:self)}).call(this,typeof yK<"u"?yK:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(lwe)),lwe.exports}var m6o=_6o();const gwe=V2(m6o),p6o=async({circuitJson:t,projectName:e})=>{await GA.promise((async()=>{const n=new gwe,[{stringifyGerberCommandLayers:o,convertSoupToGerberCommands:i,convertSoupToExcellonDrillCommands:r,stringifyExcellonDrill:A},{convertCircuitJsonToBomRows:s,convertBomRowsToCsv:a},{convertCircuitJsonToPickAndPlaceCsv:c}]=await Promise.all([FB("circuit-json-to-gerber"),FB("circuit-json-to-bom-csv"),FB("circuit-json-to-pnp-csv")]),l=t.filter(C=>!("error_type"in C)&&!("warning_type"in C)),g=i(l,{flip_y_axis:!1}),u=o(g);for(const[C,f]of Object.entries(u))n.file(`gerber/${C}.gbr`,f);const d=r({circuitJson:l,is_plated:!0,flip_y_axis:!1}),h=A(d);n.file("gerber/drill.drl",h);const _=await s({circuitJson:t}),p=await a(_);n.file("bom.csv",p);const m=await c(t);n.file("pick_and_place.csv",m);const I=await n.generateAsync({type:"blob"});MQ(I,{fileName:`${e}_fabrication_files.zip`})})(),{loading:"Generating fabrication files...",success:"Fabrication ZIP ready",error:n=>`Failed to generate fabrication files: ${n instanceof Error?n.message:String(n)}`})},I6o=async({circuitJson:t,projectName:e})=>{let n;try{const{convertCircuitJsonToGltf:o}=await FB("circuit-json-to-gltf");console.log("convertCircuitJsonToGltf",o);const i=await o(t,{format:"glb",boardTextureResolution:1024});if(!i||!(i instanceof ArrayBuffer))throw new Error("Invalid GLB data returned from converter");n=new Blob([i],{type:"model/gltf-binary"})}catch(o){console.error("GLB Export Error:",o);return}MQ(n,{fileName:`${e}.glb`})},C6o=async({circuitJson:t,libraryName:e})=>{const{CircuitJsonToKicadLibraryConverter:n}=await FB("circuit-json-to-kicad"),o=new n(t,{libraryName:e,footprintLibraryName:e});o.runUntilFinished();const i=o.getOutput(),r=new gwe;r.file(`${e}.kicad_sym`,i.kicadSymString);for(const A of i.footprints){const s=r.folder(`${e}.pretty`);s&&s.file(`${A.footprintName}.kicad_mod`,`${A.kicadModString}
|
|
5788
5788
|
`)}if(i.model3dSourcePaths.length>0){const A=r.folder(`${e}.3dshapes`);if(A)for(const s of i.model3dSourcePaths)try{const a=s.split("/").pop()||s,c=await fetch(s);if(c.ok){const l=await c.arrayBuffer();A.file(a,l)}}catch{}}return r.file("fp-lib-table",i.fpLibTableString),r.file("sym-lib-table",i.symLibTableString),r},f6o=async({circuitJson:t,projectName:e})=>{await GA.promise((async()=>{const o=await(await C6o({circuitJson:t,libraryName:e})).generateAsync({type:"blob"});MQ(o,{fileName:`${e}_kicad_library.zip`})})(),{loading:"Generating KiCad library...",success:"KiCad library ZIP ready",error:n=>`Failed to generate KiCad library: ${n instanceof Error?n.message:String(n)}`})},y6o=async({circuitJson:t,projectName:e})=>{const{CircuitJsonToKicadPcbConverter:n,CircuitJsonToKicadSchConverter:o,CircuitJsonToKicadProConverter:i,resolveAndLoadKicad3dModelFiles:r}=await FB("circuit-json-to-kicad"),A=new o(t);A.runUntilFinished();const s=A.getOutputString(),a=new n(t,{includeBuiltin3dModels:!0,projectName:e});a.runUntilFinished();const c=a.getOutputString(),l=new i(t,{projectName:e,schematicFilename:`${e}.kicad_sch`,pcbFilename:`${e}.kicad_pcb`});l.runUntilFinished();const g=l.getOutputString(),u=new gwe;return u.file(`${e}.kicad_sch`,s),u.file(`${e}.kicad_pcb`,c),u.file(`${e}.kicad_pro`,g),await r({projectName:e,model3dSourcePaths:a.getModel3dSourcePaths(),fetch,onModelFile:({outputPath:d,content:h})=>{u.file(d,h)},onError:({sourcePath:d})=>{console.warn(`Failed to load 3D model from ${d}`)}}),u},E6o=async({circuitJson:t,projectName:e})=>{await GA.promise((async()=>{const o=await(await y6o({circuitJson:t,projectName:e})).generateAsync({type:"blob"});MQ(o,{fileName:`${e}_kicad_project.zip`})})(),{loading:"Generating KiCad project...",success:"KiCad project ZIP ready",error:n=>`Failed to generate KiCad project: ${n instanceof Error?n.message:String(n)}`})},Lvt=async({circuitJson:t,projectName:e,options:n={}})=>{try{const{convertCircuitJsonToLbrn:o}=await FB("circuit-json-to-lbrn"),r=(await o(t,{includeSilkscreen:n.includeSilkscreen??!1,includeOxidationCleaningLayer:n.includeOxidationCleaningLayer??!0})).toXml(),A=new Blob([r],{type:"application/lbrn"});MQ(A,{fileName:`${e}.lbrn2`})}catch(o){const i=o instanceof Error?o.message:"Unknown error";GA.error(`Failed to export to LBRN format: ${i}`)}},B6o=async({circuitJson:t,projectName:e})=>{const{convertCircuitJsonToPinoutSvg:n}=await FB("circuit-to-svg"),o=n(t);MQ(o,{fileName:`${e}-pinout.svg`,mimeType:"image/svg+xml"})},x6o=async({circuitJson:t,projectName:e})=>{const{circuitJsonToStep:n}=await FB("circuit-json-to-step"),o=t.find(c=>c.type==="pcb_board"),i=o&&"width"in o?o.width:void 0,r=o&&"height"in o?o.height:void 0,A=o&&"thickness"in o?o.thickness:void 0;if(i===void 0||r===void 0||A===void 0){GA.error("Board dimensions not found. Please add a pcb_board with width, height, and thickness to your circuit.");return}let s;try{s=await n(t,{boardWidth:i,boardHeight:r,boardThickness:A,productName:e,includeComponents:!0,includeExternalMeshes:!0})}catch(c){const l=c instanceof Error?c.message:"Unknown error";GA.error(`Failed to convert circuit to STEP format: ${l}`);return}const a=new Blob([s],{type:"application/step"});try{MQ(a,{fileName:`${e}.step`})}catch(c){const l=c instanceof Error?c.message:"Unknown error";GA.error(`Failed to download STEP file: ${l}`)}},Q6o=[{extension:"json",name:"Circuit JSON"},{extension:"json",name:"Simple Route JSON"},{extension:"zip",name:"Fabrication Files"},{extension:"zip",name:"KiCad Project"},{extension:"zip",name:"KiCad Library"},{extension:"glb",name:"GLB (Binary GLTF)"},{extension:"svg",name:"Pinout SVG"},{extension:"step",name:"STEP"},{extension:"lbrn2",name:"LightBurn"}],S6o=async({exportName:t,circuitJson:e,simpleRouteJson:n,projectName:o})=>{const i=b3t(o);if(t==="Fabrication Files"){await p6o({circuitJson:e,projectName:i});return}if(t==="KiCad Project"){await E6o({circuitJson:e,projectName:i});return}if(t==="KiCad Library"){await f6o({circuitJson:e,projectName:i});return}if(t==="Circuit JSON"){MQ(JSON.stringify(e,null,2),{fileName:`${i}.circuit.json`,mimeType:"application/json"});return}if(t==="Simple Route JSON"){if(!n)throw new Error("No Simple Route JSON available to export");MQ(JSON.stringify(n,null,2),{fileName:`${i}.simple-route.json`,mimeType:"application/json"});return}if(t==="GLB (Binary GLTF)"){await I6o({circuitJson:e,projectName:i});return}if(t==="Pinout SVG"){B6o({circuitJson:e,projectName:i});return}if(t==="STEP"){await x6o({circuitJson:e,projectName:i});return}if(t==="LightBurn"){await Lvt({circuitJson:e,projectName:i});return}throw new Error(`Unsupported export type: "${t}"`)},b6o=({packageName:t,onSelectReview:e})=>{const n=M0(g=>g.fsMap),o=M0(g=>g.circuitJson),[i,r]=j.useState([]),[A,s]=j.useState(!1),[a,c]=j.useState(!1);j.useEffect(()=>{!t||!BX()||(s(!0),vL.get("ai_reviews/list",{searchParams:{package_name:t}}).json().then(g=>r(g.ai_reviews)).catch(g=>{console.error("Failed to load AI reviews",g),GA.error("Failed to load AI reviews")}).finally(()=>s(!1)))},[t]);const l=async()=>{if(!o){GA.error("Need Circuit JSON to Request AI Review");return}if(!BX()){GA.error("Missing registry token");return}c(!0);try{const{ai_review:g}=await vL.post("ai_reviews/create",{json:{package_name:t??"unknown",fs_map:Object.fromEntries(n),circuit_json:o}}).json();r(u=>[g,...u]),e(g),GA.success("AI review requested")}catch(g){console.error("Failed to create AI review",g),GA.error("Failed to request AI review")}finally{c(!1)}};return V.jsxs(V.Fragment,{children:[V.jsxs(y3,{children:[V.jsx(E3,{children:"AI Review"}),V.jsx(vN,{children:"Select an AI review or request a new one."})]}),V.jsx("div",{className:"rf-flex rf-gap-4 rf-mt-4",children:V.jsx("div",{className:"rf-w-48 rf-h-64 rf-overflow-y-auto rf-border rf-rounded rf-p-2 rf-flex-shrink-0",children:A?V.jsx("div",{className:"rf-text-sm",children:"Loading..."}):i.length>0?i.map(g=>V.jsx("div",{className:"rf-text-sm rf-p-2 rf-cursor-pointer rf-rounded hover:rf-bg-zinc-100",onClick:()=>e(g),children:new Date(g.created_at||"").toLocaleString()},g.ai_review_id)):V.jsx("div",{className:"rf-text-sm rf-text-muted-foreground",children:"No AI reviews found."})})}),V.jsx(hO,{className:"rf-mt-4",children:V.jsx(Vs,{onClick:l,disabled:a,children:a?"Requesting...":"Review my Board"})})]})};function uwe(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var B3=uwe();function Hvt(t){B3=t}var mO={exec:()=>null};function ol(t,e=""){let n=typeof t=="string"?t:t.source;const o={replace:(i,r)=>{let A=typeof r=="string"?r:r.source;return A=A.replace(af.caret,"$1"),n=n.replace(i,A),o},getRegex:()=>new RegExp(n,e)};return o}var af={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i")},D6o=/^(?:[ \t]*(?:\n|$))+/,M6o=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,w6o=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,pO=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,P6o=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hwe=/(?:[*+-]|\d{1,9}[.)])/,Gvt=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Ovt=ol(Gvt).replace(/bull/g,hwe).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),v6o=ol(Gvt).replace(/bull/g,hwe).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),dwe=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,N6o=/^[^\n]+/,_we=/(?!\s*\])(?:\\.|[^\[\]\\])+/,R6o=ol(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",_we).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),T6o=ol(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,hwe).getRegex(),dne="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",mwe=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,k6o=ol("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",mwe).replace("tag",dne).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Kvt=ol(dwe).replace("hr",pO).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",dne).getRegex(),F6o=ol(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Kvt).getRegex(),pwe={blockquote:F6o,code:M6o,def:R6o,fences:w6o,heading:P6o,hr:pO,html:k6o,lheading:Ovt,list:T6o,newline:D6o,paragraph:Kvt,table:mO,text:N6o},Uvt=ol("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",pO).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",dne).getRegex(),L6o={...pwe,lheading:v6o,table:Uvt,paragraph:ol(dwe).replace("hr",pO).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Uvt).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",dne).getRegex()},H6o={...pwe,html:ol(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",mwe).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:mO,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ol(dwe).replace("hr",pO).replace("heading",` *#{1,6} *[^
|
|
5789
5789
|
]`).replace("lheading",Ovt).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},G6o=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,O6o=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Yvt=/^( {2,}|\\)\n(?!\s*$)/,K6o=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,_ne=/[\p{P}\p{S}]/u,Iwe=/[\s\p{P}\p{S}]/u,Vvt=/[^\s\p{P}\p{S}]/u,U6o=ol(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Iwe).getRegex(),zvt=/(?!~)[\p{P}\p{S}]/u,Y6o=/(?!~)[\s\p{P}\p{S}]/u,V6o=/(?:[^\s\p{P}\p{S}]|~)/u,z6o=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,Jvt=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,J6o=ol(Jvt,"u").replace(/punct/g,_ne).getRegex(),q6o=ol(Jvt,"u").replace(/punct/g,zvt).getRegex(),qvt="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",W6o=ol(qvt,"gu").replace(/notPunctSpace/g,Vvt).replace(/punctSpace/g,Iwe).replace(/punct/g,_ne).getRegex(),j6o=ol(qvt,"gu").replace(/notPunctSpace/g,V6o).replace(/punctSpace/g,Y6o).replace(/punct/g,zvt).getRegex(),X6o=ol("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Vvt).replace(/punctSpace/g,Iwe).replace(/punct/g,_ne).getRegex(),$6o=ol(/\\(punct)/,"gu").replace(/punct/g,_ne).getRegex(),Z6o=ol(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),e8o=ol(mwe).replace("(?:-->|$)","-->").getRegex(),t8o=ol("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",e8o).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),mne=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,n8o=ol(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",mne).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Wvt=ol(/^!?\[(label)\]\[(ref)\]/).replace("label",mne).replace("ref",_we).getRegex(),jvt=ol(/^!?\[(ref)\](?:\[\])?/).replace("ref",_we).getRegex(),o8o=ol("reflink|nolink(?!\\()","g").replace("reflink",Wvt).replace("nolink",jvt).getRegex(),Cwe={_backpedal:mO,anyPunctuation:$6o,autolink:Z6o,blockSkip:z6o,br:Yvt,code:O6o,del:mO,emStrongLDelim:J6o,emStrongRDelimAst:W6o,emStrongRDelimUnd:X6o,escape:G6o,link:n8o,nolink:jvt,punctuation:U6o,reflink:Wvt,reflinkSearch:o8o,tag:t8o,text:K6o,url:mO},i8o={...Cwe,link:ol(/^!?\[(label)\]\((.*?)\)/).replace("label",mne).getRegex(),reflink:ol(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",mne).getRegex()},fwe={...Cwe,emStrongRDelimAst:j6o,emStrongLDelim:q6o,url:ol(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},r8o={...fwe,br:ol(Yvt).replace("{2,}","*").getRegex(),text:ol(fwe.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},pne={normal:pwe,gfm:L6o,pedantic:H6o},IO={normal:Cwe,gfm:fwe,breaks:r8o,pedantic:i8o},A8o={"&":"&","<":"<",">":">",'"':""","'":"'"},Xvt=t=>A8o[t];function PQ(t,e){if(e){if(af.escapeTest.test(t))return t.replace(af.escapeReplace,Xvt)}else if(af.escapeTestNoEncode.test(t))return t.replace(af.escapeReplaceNoEncode,Xvt);return t}function $vt(t){try{t=encodeURI(t).replace(af.percentDecode,"%")}catch{return null}return t}function Zvt(t,e){const n=t.replace(af.findPipe,(r,A,s)=>{let a=!1,c=A;for(;--c>=0&&s[c]==="\\";)a=!a;return a?"|":" |"}),o=n.split(af.splitPipe);let i=0;if(o[0].trim()||o.shift(),o.length>0&&!o.at(-1)?.trim()&&o.pop(),e)if(o.length>e)o.splice(e);else for(;o.length<e;)o.push("");for(;i<o.length;i++)o[i]=o[i].trim().replace(af.slashPipe,"|");return o}function CO(t,e,n){const o=t.length;if(o===0)return"";let i=0;for(;i<o&&t.charAt(o-i-1)===e;)i++;return t.slice(0,o-i)}function s8o(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let o=0;o<t.length;o++)if(t[o]==="\\")o++;else if(t[o]===e[0])n++;else if(t[o]===e[1]&&(n--,n<0))return o;return n>0?-2:-1}function e6t(t,e,n,o,i){const r=e.href,A=e.title||null,s=t[1].replace(i.other.outputLinkReplace,"$1");o.state.inLink=!0;const a={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:r,title:A,text:s,tokens:o.inlineTokens(s)};return o.state.inLink=!1,a}function a8o(t,e,n){const o=t.match(n.other.indentCodeCompensation);if(o===null)return e;const i=o[1];return e.split(`
|