@tscircuit/runframe 0.0.724 → 0.0.726
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.
|
@@ -241,7 +241,7 @@ Check the render method of %s.`,_s(sc)||"Unknown"));var Jt=i1(Le,it);Jt.payload=
|
|
|
241
241
|
You might need to use a local HTTP server (instead of file://): https://reactjs.org/link/react-devtools-faq`:""),"font-weight:bold")}Kx.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=zAe,Kx.createPortal=jtn,Kx.createRoot=Wtn,Kx.findDOMNode=ztn,Kx.flushSync=Ztn,Kx.hydrate=Htn,Kx.hydrateRoot=qtn,Kx.render=Ytn,Kx.unmountComponentAtNode=Ktn,Kx.unstable_batchedUpdates=yAe,Kx.unstable_renderSubtreeIntoContainer=Jtn,Kx.version=PAe,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}(),Kx}var gde;function mde(){if(gde)return X4.exports;gde=1;function r(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function")){if(process.env.NODE_ENV!=="production")throw new Error("^_^");try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(r)}catch(e){console.error(e)}}}return process.env.NODE_ENV==="production"?(r(),X4.exports=_Ke()):X4.exports=xKe(),X4.exports}var yde;function BKe(){if(yde)return hM;yde=1;var r=mde();if(process.env.NODE_ENV==="production")hM.createRoot=r.createRoot,hM.hydrateRoot=r.hydrateRoot;else{var e=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;hM.createRoot=function(t,n){e.usingClientEntryPoint=!0;try{return r.createRoot(t,n)}finally{e.usingClientEntryPoint=!1}},hM.hydrateRoot=function(t,n,i){e.usingClientEntryPoint=!0;try{return r.hydrateRoot(t,n,i)}finally{e.usingClientEntryPoint=!1}}}return hM}var vde=BKe(),pt=ZE();const Jh=qE(pt),Ide=Wb({__proto__:null,default:Jh},[pt]);function Jg(r,e,{checkForDefaultPrevented:t=!0}={}){return function(i){if(r==null||r(i),t===!1||!i.defaultPrevented)return e==null?void 0:e(i)}}function gM(r,e=[]){let t=[];function n(o,a){const s=pt.createContext(a),l=t.length;t=[...t,a];const c=A=>{var _;const{scope:d,children:f,...m}=A,C=((_=d==null?void 0:d[r])==null?void 0:_[l])||s,E=pt.useMemo(()=>m,Object.values(m));return ut.jsx(C.Provider,{value:E,children:f})};c.displayName=o+"Provider";function u(A,d){var C;const f=((C=d==null?void 0:d[r])==null?void 0:C[l])||s,m=pt.useContext(f);if(m)return m;if(a!==void 0)return a;throw new Error(`\`${A}\` must be used within \`${o}\``)}return[c,u]}const i=()=>{const o=t.map(a=>pt.createContext(a));return function(s){const l=(s==null?void 0:s[r])||o;return pt.useMemo(()=>({[`__scope${r}`]:{...s,[r]:l}}),[s,l])}};return i.scopeName=r,[n,bKe(i,...e)]}function bKe(...r){const e=r[0];if(r.length===1)return e;const t=()=>{const n=r.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(o){const a=n.reduce((s,{useScope:l,scopeName:c})=>{const A=l(o)[`__scope${c}`];return{...s,...A}},{});return pt.useMemo(()=>({[`__scope${e.scopeName}`]:a}),[a])}};return t.scopeName=e.scopeName,t}function Cde(r,e){if(typeof r=="function")return r(e);r!=null&&(r.current=e)}function eP(...r){return e=>{let t=!1;const n=r.map(i=>{const o=Cde(i,e);return!t&&typeof o=="function"&&(t=!0),o});if(t)return()=>{for(let i=0;i<n.length;i++){const o=n[i];typeof o=="function"?o():Cde(r[i],null)}}}}function jx(...r){return pt.useCallback(eP(...r),r)}function h3(r){const e=wKe(r),t=pt.forwardRef((n,i)=>{const{children:o,...a}=n,s=pt.Children.toArray(o),l=s.find(MKe);if(l){const c=l.props.children,u=s.map(A=>A===l?pt.Children.count(c)>1?pt.Children.only(null):pt.isValidElement(c)?c.props.children:null:A);return ut.jsx(e,{...a,ref:i,children:pt.isValidElement(c)?pt.cloneElement(c,void 0,u):null})}return ut.jsx(e,{...a,ref:i,children:o})});return t.displayName=`${r}.Slot`,t}var SKe=h3("Slot");function wKe(r){const e=pt.forwardRef((t,n)=>{const{children:i,...o}=t;if(pt.isValidElement(i)){const a=RKe(i),s=DKe(o,i.props);return i.type!==pt.Fragment&&(s.ref=n?eP(n,a):a),pt.cloneElement(i,s)}return pt.Children.count(i)>1?pt.Children.only(null):null});return e.displayName=`${r}.SlotClone`,e}var QKe=Symbol("radix.slottable");function MKe(r){return pt.isValidElement(r)&&typeof r.type=="function"&&"__radixId"in r.type&&r.type.__radixId===QKe}function DKe(r,e){const t={...e};for(const n in e){const i=r[n],o=e[n];/^on[A-Z]/.test(n)?i&&o?t[n]=(...s)=>{const l=o(...s);return i(...s),l}:i&&(t[n]=i):n==="style"?t[n]={...i,...o}:n==="className"&&(t[n]=[i,o].filter(Boolean).join(" "))}return{...r,...t}}function RKe(r){var n,i;let e=(n=Object.getOwnPropertyDescriptor(r.props,"ref"))==null?void 0:n.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?r.ref:(e=(i=Object.getOwnPropertyDescriptor(r,"ref"))==null?void 0:i.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?r.props.ref:r.props.ref||r.ref)}function Ede(r){const e=r+"CollectionProvider",[t,n]=gM(e),[i,o]=t(e,{collectionRef:{current:null},itemMap:new Map}),a=C=>{const{scope:E,children:_}=C,x=Jh.useRef(null),w=Jh.useRef(new Map).current;return ut.jsx(i,{scope:E,itemMap:w,collectionRef:x,children:_})};a.displayName=e;const s=r+"CollectionSlot",l=h3(s),c=Jh.forwardRef((C,E)=>{const{scope:_,children:x}=C,w=o(s,_),P=jx(E,w.collectionRef);return ut.jsx(l,{ref:P,children:x})});c.displayName=s;const u=r+"CollectionItemSlot",A="data-radix-collection-item",d=h3(u),f=Jh.forwardRef((C,E)=>{const{scope:_,children:x,...w}=C,P=Jh.useRef(null),L=jx(E,P),O=o(u,_);return Jh.useEffect(()=>(O.itemMap.set(P,{ref:P,...w}),()=>void O.itemMap.delete(P))),ut.jsx(d,{[A]:"",ref:L,children:x})});f.displayName=u;function m(C){const E=o(r+"CollectionConsumer",C);return Jh.useCallback(()=>{const x=E.collectionRef.current;if(!x)return[];const w=Array.from(x.querySelectorAll(`[${A}]`));return Array.from(E.itemMap.values()).sort((O,H)=>w.indexOf(O.ref.current)-w.indexOf(H.ref.current))},[E.collectionRef,E.itemMap])}return[{Provider:a,Slot:c,ItemSlot:f},m,n]}var eQ=globalThis!=null&&globalThis.document?pt.useLayoutEffect:()=>{},NKe=Ide[" useId ".trim().toString()]||(()=>{}),TKe=0;function tP(r){const[e,t]=pt.useState(NKe());return eQ(()=>{t(n=>n??String(TKe++))},[r]),e?`radix-${e}`:""}var Az=mde();const PKe=qE(Az);var kKe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],nE=kKe.reduce((r,e)=>{const t=h3(`Primitive.${e}`),n=pt.forwardRef((i,o)=>{const{asChild:a,...s}=i,l=a?t:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),ut.jsx(l,{...s,ref:o})});return n.displayName=`Primitive.${e}`,{...r,[e]:n}},{});function _de(r,e){r&&Az.flushSync(()=>r.dispatchEvent(e))}function WS(r){const e=pt.useRef(r);return pt.useEffect(()=>{e.current=r}),pt.useMemo(()=>(...t)=>{var n;return(n=e.current)==null?void 0:n.call(e,...t)},[])}var UKe=Ide[" useInsertionEffect ".trim().toString()]||eQ;function dz({prop:r,defaultProp:e,onChange:t=()=>{},caller:n}){const[i,o,a]=FKe({defaultProp:e,onChange:t}),s=r!==void 0,l=s?r:i;{const u=pt.useRef(r!==void 0);pt.useEffect(()=>{const A=u.current;A!==s&&console.warn(`${n} is changing from ${A?"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.`),u.current=s},[s,n])}const c=pt.useCallback(u=>{var A;if(s){const d=LKe(u)?u(r):u;d!==r&&((A=a.current)==null||A.call(a,d))}else o(u)},[s,r,o,a]);return[l,c]}function FKe({defaultProp:r,onChange:e}){const[t,n]=pt.useState(r),i=pt.useRef(t),o=pt.useRef(e);return UKe(()=>{o.current=e},[e]),pt.useEffect(()=>{var a;i.current!==t&&((a=o.current)==null||a.call(o,t),i.current=t)},[t,i]),[t,n,o]}function LKe(r){return typeof r=="function"}var GKe=pt.createContext(void 0);function fz(r){const e=pt.useContext(GKe);return r||e||"ltr"}var hz="rovingFocusGroup.onEntryFocus",OKe={bubbles:!1,cancelable:!0},p3="RovingFocusGroup",[pz,xde,zKe]=Ede(p3),[HKe,nP]=gM(p3,[zKe]),[YKe,VKe]=HKe(p3),Bde=pt.forwardRef((r,e)=>ut.jsx(pz.Provider,{scope:r.__scopeRovingFocusGroup,children:ut.jsx(pz.Slot,{scope:r.__scopeRovingFocusGroup,children:ut.jsx(KKe,{...r,ref:e})})}));Bde.displayName=p3;var KKe=pt.forwardRef((r,e)=>{const{__scopeRovingFocusGroup:t,orientation:n,loop:i=!1,dir:o,currentTabStopId:a,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:u=!1,...A}=r,d=pt.useRef(null),f=jx(e,d),m=fz(o),[C,E]=dz({prop:a,defaultProp:s??null,onChange:l,caller:p3}),[_,x]=pt.useState(!1),w=WS(c),P=xde(t),L=pt.useRef(!1),[O,H]=pt.useState(0);return pt.useEffect(()=>{const K=d.current;if(K)return K.addEventListener(hz,w),()=>K.removeEventListener(hz,w)},[w]),ut.jsx(YKe,{scope:t,orientation:n,dir:m,loop:i,currentTabStopId:C,onItemFocus:pt.useCallback(K=>E(K),[E]),onItemShiftTab:pt.useCallback(()=>x(!0),[]),onFocusableItemAdd:pt.useCallback(()=>H(K=>K+1),[]),onFocusableItemRemove:pt.useCallback(()=>H(K=>K-1),[]),children:ut.jsx(nE.div,{tabIndex:_||O===0?-1:0,"data-orientation":n,...A,ref:f,style:{outline:"none",...r.style},onMouseDown:Jg(r.onMouseDown,()=>{L.current=!0}),onFocus:Jg(r.onFocus,K=>{const q=!L.current;if(K.target===K.currentTarget&&q&&!_){const Y=new CustomEvent(hz,OKe);if(K.currentTarget.dispatchEvent(Y),!Y.defaultPrevented){const se=P().filter(fe=>fe.focusable),ie=se.find(fe=>fe.active),de=se.find(fe=>fe.id===C),xe=[ie,de,...se].filter(Boolean).map(fe=>fe.ref.current);wde(xe,u)}}L.current=!1}),onBlur:Jg(r.onBlur,()=>x(!1))})})}),bde="RovingFocusGroupItem",Sde=pt.forwardRef((r,e)=>{const{__scopeRovingFocusGroup:t,focusable:n=!0,active:i=!1,tabStopId:o,children:a,...s}=r,l=tP(),c=o||l,u=VKe(bde,t),A=u.currentTabStopId===c,d=xde(t),{onFocusableItemAdd:f,onFocusableItemRemove:m,currentTabStopId:C}=u;return pt.useEffect(()=>{if(n)return f(),()=>m()},[n,f,m]),ut.jsx(pz.ItemSlot,{scope:t,id:c,focusable:n,active:i,children:ut.jsx(nE.span,{tabIndex:A?0:-1,"data-orientation":u.orientation,...s,ref:e,onMouseDown:Jg(r.onMouseDown,E=>{n?u.onItemFocus(c):E.preventDefault()}),onFocus:Jg(r.onFocus,()=>u.onItemFocus(c)),onKeyDown:Jg(r.onKeyDown,E=>{if(E.key==="Tab"&&E.shiftKey){u.onItemShiftTab();return}if(E.target!==E.currentTarget)return;const _=WKe(E,u.orientation,u.dir);if(_!==void 0){if(E.metaKey||E.ctrlKey||E.altKey||E.shiftKey)return;E.preventDefault();let w=d().filter(P=>P.focusable).map(P=>P.ref.current);if(_==="last")w.reverse();else if(_==="prev"||_==="next"){_==="prev"&&w.reverse();const P=w.indexOf(E.currentTarget);w=u.loop?qKe(w,P+1):w.slice(P+1)}setTimeout(()=>wde(w))}}),children:typeof a=="function"?a({isCurrentTabStop:A,hasTabStop:C!=null}):a})})});Sde.displayName=bde;var jKe={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function JKe(r,e){return e!=="rtl"?r:r==="ArrowLeft"?"ArrowRight":r==="ArrowRight"?"ArrowLeft":r}function WKe(r,e,t){const n=JKe(r.key,t);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return jKe[n]}function wde(r,e=!1){const t=document.activeElement;for(const n of r)if(n===t||(n.focus({preventScroll:e}),document.activeElement!==t))return}function qKe(r,e){return r.map((t,n)=>r[(e+n)%r.length])}var Qde=Bde,Mde=Sde;function ZKe(r,e){return pt.useReducer((t,n)=>e[t][n]??t,r)}var mM=r=>{const{present:e,children:t}=r,n=XKe(e),i=typeof t=="function"?t({present:n.isPresent}):pt.Children.only(t),o=jx(n.ref,$Ke(i));return typeof t=="function"||n.isPresent?pt.cloneElement(i,{ref:o}):null};mM.displayName="Presence";function XKe(r){const[e,t]=pt.useState(),n=pt.useRef(null),i=pt.useRef(r),o=pt.useRef("none"),a=r?"mounted":"unmounted",[s,l]=ZKe(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return pt.useEffect(()=>{const c=rP(n.current);o.current=s==="mounted"?c:"none"},[s]),eQ(()=>{const c=n.current,u=i.current;if(u!==r){const d=o.current,f=rP(c);r?l("MOUNT"):f==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(u&&d!==f?"ANIMATION_OUT":"UNMOUNT"),i.current=r}},[r,l]),eQ(()=>{if(e){let c;const u=e.ownerDocument.defaultView??window,A=f=>{const C=rP(n.current).includes(f.animationName);if(f.target===e&&C&&(l("ANIMATION_END"),!i.current)){const E=e.style.animationFillMode;e.style.animationFillMode="forwards",c=u.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=E)})}},d=f=>{f.target===e&&(o.current=rP(n.current))};return e.addEventListener("animationstart",d),e.addEventListener("animationcancel",A),e.addEventListener("animationend",A),()=>{u.clearTimeout(c),e.removeEventListener("animationstart",d),e.removeEventListener("animationcancel",A),e.removeEventListener("animationend",A)}}else l("ANIMATION_END")},[e,l]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:pt.useCallback(c=>{n.current=c?getComputedStyle(c):null,t(c)},[])}}function rP(r){return(r==null?void 0:r.animationName)||"none"}function $Ke(r){var n,i;let e=(n=Object.getOwnPropertyDescriptor(r.props,"ref"))==null?void 0:n.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?r.ref:(e=(i=Object.getOwnPropertyDescriptor(r,"ref"))==null?void 0:i.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?r.props.ref:r.props.ref||r.ref)}var iP="Tabs",[eje,rnn]=gM(iP,[nP]),Dde=nP(),[tje,gz]=eje(iP),Rde=pt.forwardRef((r,e)=>{const{__scopeTabs:t,value:n,onValueChange:i,defaultValue:o,orientation:a="horizontal",dir:s,activationMode:l="automatic",...c}=r,u=fz(s),[A,d]=dz({prop:n,onChange:i,defaultProp:o??"",caller:iP});return ut.jsx(tje,{scope:t,baseId:tP(),value:A,onValueChange:d,orientation:a,dir:u,activationMode:l,children:ut.jsx(nE.div,{dir:u,"data-orientation":a,...c,ref:e})})});Rde.displayName=iP;var Nde="TabsList",Tde=pt.forwardRef((r,e)=>{const{__scopeTabs:t,loop:n=!0,...i}=r,o=gz(Nde,t),a=Dde(t);return ut.jsx(Qde,{asChild:!0,...a,orientation:o.orientation,dir:o.dir,loop:n,children:ut.jsx(nE.div,{role:"tablist","aria-orientation":o.orientation,...i,ref:e})})});Tde.displayName=Nde;var Pde="TabsTrigger",kde=pt.forwardRef((r,e)=>{const{__scopeTabs:t,value:n,disabled:i=!1,...o}=r,a=gz(Pde,t),s=Dde(t),l=Lde(a.baseId,n),c=Gde(a.baseId,n),u=n===a.value;return ut.jsx(Mde,{asChild:!0,...s,focusable:!i,active:u,children:ut.jsx(nE.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":c,"data-state":u?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:l,...o,ref:e,onMouseDown:Jg(r.onMouseDown,A=>{!i&&A.button===0&&A.ctrlKey===!1?a.onValueChange(n):A.preventDefault()}),onKeyDown:Jg(r.onKeyDown,A=>{[" ","Enter"].includes(A.key)&&a.onValueChange(n)}),onFocus:Jg(r.onFocus,()=>{const A=a.activationMode!=="manual";!u&&!i&&A&&a.onValueChange(n)})})})});kde.displayName=Pde;var Ude="TabsContent",Fde=pt.forwardRef((r,e)=>{const{__scopeTabs:t,value:n,forceMount:i,children:o,...a}=r,s=gz(Ude,t),l=Lde(s.baseId,n),c=Gde(s.baseId,n),u=n===s.value,A=pt.useRef(u);return pt.useEffect(()=>{const d=requestAnimationFrame(()=>A.current=!1);return()=>cancelAnimationFrame(d)},[]),ut.jsx(mM,{present:i||u,children:({present:d})=>ut.jsx(nE.div,{"data-state":u?"active":"inactive","data-orientation":s.orientation,role:"tabpanel","aria-labelledby":l,hidden:!d,id:c,tabIndex:0,...a,ref:e,style:{...r.style,animationDuration:A.current?"0s":void 0},children:d&&o})})});Fde.displayName=Ude;function Lde(r,e){return`${r}-trigger-${e}`}function Gde(r,e){return`${r}-content-${e}`}var nje=Rde,Ode=Tde,zde=kde,Hde=Fde;function Yde(r){var e,t,n="";if(typeof r=="string"||typeof r=="number")n+=r;else if(typeof r=="object")if(Array.isArray(r)){var i=r.length;for(e=0;e<i;e++)r[e]&&(t=Yde(r[e]))&&(n&&(n+=" "),n+=t)}else for(t in r)r[t]&&(n&&(n+=" "),n+=t);return n}function qb(){for(var r,e,t=0,n="",i=arguments.length;t<i;t++)(r=arguments[t])&&(e=Yde(r))&&(n&&(n+=" "),n+=e);return n}const mz="-",rje=r=>{const e=oje(r),{conflictingClassGroups:t,conflictingClassGroupModifiers:n}=r;return{getClassGroupId:a=>{const s=a.split(mz);return s[0]===""&&s.length!==1&&s.shift(),Vde(s,e)||ije(a)},getConflictingClassGroupIds:(a,s)=>{const l=t[a]||[];return s&&n[a]?[...l,...n[a]]:l}}},Vde=(r,e)=>{var a;if(r.length===0)return e.classGroupId;const t=r[0],n=e.nextPart.get(t),i=n?Vde(r.slice(1),n):void 0;if(i)return i;if(e.validators.length===0)return;const o=r.join(mz);return(a=e.validators.find(({validator:s})=>s(o)))==null?void 0:a.classGroupId},Kde=/^\[(.+)\]$/,ije=r=>{if(Kde.test(r)){const e=Kde.exec(r)[1],t=e==null?void 0:e.substring(0,e.indexOf(":"));if(t)return"arbitrary.."+t}},oje=r=>{const{theme:e,prefix:t}=r,n={nextPart:new Map,validators:[]};return sje(Object.entries(r.classGroups),t).forEach(([o,a])=>{yz(a,n,o,e)}),n},yz=(r,e,t,n)=>{r.forEach(i=>{if(typeof i=="string"){const o=i===""?e:jde(e,i);o.classGroupId=t;return}if(typeof i=="function"){if(aje(i)){yz(i(n),e,t,n);return}e.validators.push({validator:i,classGroupId:t});return}Object.entries(i).forEach(([o,a])=>{yz(a,jde(e,o),t,n)})})},jde=(r,e)=>{let t=r;return e.split(mz).forEach(n=>{t.nextPart.has(n)||t.nextPart.set(n,{nextPart:new Map,validators:[]}),t=t.nextPart.get(n)}),t},aje=r=>r.isThemeGetter,sje=(r,e)=>e?r.map(([t,n])=>{const i=n.map(o=>typeof o=="string"?e+o:typeof o=="object"?Object.fromEntries(Object.entries(o).map(([a,s])=>[e+a,s])):o);return[t,i]}):r,lje=r=>{if(r<1)return{get:()=>{},set:()=>{}};let e=0,t=new Map,n=new Map;const i=(o,a)=>{t.set(o,a),e++,e>r&&(e=0,n=t,t=new Map)};return{get(o){let a=t.get(o);if(a!==void 0)return a;if((a=n.get(o))!==void 0)return i(o,a),a},set(o,a){t.has(o)?t.set(o,a):i(o,a)}}},Jde="!",cje=r=>{const{separator:e,experimentalParseClassName:t}=r,n=e.length===1,i=e[0],o=e.length,a=s=>{const l=[];let c=0,u=0,A;for(let E=0;E<s.length;E++){let _=s[E];if(c===0){if(_===i&&(n||s.slice(E,E+o)===e)){l.push(s.slice(u,E)),u=E+o;continue}if(_==="/"){A=E;continue}}_==="["?c++:_==="]"&&c--}const d=l.length===0?s:s.substring(u),f=d.startsWith(Jde),m=f?d.substring(1):d,C=A&&A>u?A-u:void 0;return{modifiers:l,hasImportantModifier:f,baseClassName:m,maybePostfixModifierPosition:C}};return t?s=>t({className:s,parseClassName:a}):a},uje=r=>{if(r.length<=1)return r;const e=[];let t=[];return r.forEach(n=>{n[0]==="["?(e.push(...t.sort(),n),t=[]):t.push(n)}),e.push(...t.sort()),e},Aje=r=>({cache:lje(r.cacheSize),parseClassName:cje(r),...rje(r)}),dje=/\s+/,fje=(r,e)=>{const{parseClassName:t,getClassGroupId:n,getConflictingClassGroupIds:i}=e,o=[],a=r.trim().split(dje);let s="";for(let l=a.length-1;l>=0;l-=1){const c=a[l],{modifiers:u,hasImportantModifier:A,baseClassName:d,maybePostfixModifierPosition:f}=t(c);let m=!!f,C=n(m?d.substring(0,f):d);if(!C){if(!m){s=c+(s.length>0?" "+s:s);continue}if(C=n(d),!C){s=c+(s.length>0?" "+s:s);continue}m=!1}const E=uje(u).join(":"),_=A?E+Jde:E,x=_+C;if(o.includes(x))continue;o.push(x);const w=i(C,m);for(let P=0;P<w.length;++P){const L=w[P];o.push(_+L)}s=c+(s.length>0?" "+s:s)}return s};function hje(){let r=0,e,t,n="";for(;r<arguments.length;)(e=arguments[r++])&&(t=Wde(e))&&(n&&(n+=" "),n+=t);return n}const Wde=r=>{if(typeof r=="string")return r;let e,t="";for(let n=0;n<r.length;n++)r[n]&&(e=Wde(r[n]))&&(t&&(t+=" "),t+=e);return t};function pje(r,...e){let t,n,i,o=a;function a(l){const c=e.reduce((u,A)=>A(u),r());return t=Aje(c),n=t.cache.get,i=t.cache.set,o=s,s(l)}function s(l){const c=n(l);if(c)return c;const u=fje(l,t);return i(l,u),u}return function(){return o(hje.apply(null,arguments))}}const _I=r=>{const e=t=>t[r]||[];return e.isThemeGetter=!0,e},qde=/^\[(?:([a-z-]+):)?(.+)\]$/i,gje=/^\d+\/\d+$/,mje=new Set(["px","full","screen"]),yje=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,vje=/\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$/,Ije=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,Cje=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Eje=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,qS=r=>yM(r)||mje.has(r)||gje.test(r),tQ=r=>vM(r,"length",Mje),yM=r=>!!r&&!Number.isNaN(Number(r)),vz=r=>vM(r,"number",yM),g3=r=>!!r&&Number.isInteger(Number(r)),_je=r=>r.endsWith("%")&&yM(r.slice(0,-1)),qp=r=>qde.test(r),nQ=r=>yje.test(r),xje=new Set(["length","size","percentage"]),Bje=r=>vM(r,xje,Zde),bje=r=>vM(r,"position",Zde),Sje=new Set(["image","url"]),wje=r=>vM(r,Sje,Rje),Qje=r=>vM(r,"",Dje),m3=()=>!0,vM=(r,e,t)=>{const n=qde.exec(r);return n?n[1]?typeof e=="string"?n[1]===e:e.has(n[1]):t(n[2]):!1},Mje=r=>vje.test(r)&&!Ije.test(r),Zde=()=>!1,Dje=r=>Cje.test(r),Rje=r=>Eje.test(r),Nje=pje(()=>{const r=_I("colors"),e=_I("spacing"),t=_I("blur"),n=_I("brightness"),i=_I("borderColor"),o=_I("borderRadius"),a=_I("borderSpacing"),s=_I("borderWidth"),l=_I("contrast"),c=_I("grayscale"),u=_I("hueRotate"),A=_I("invert"),d=_I("gap"),f=_I("gradientColorStops"),m=_I("gradientColorStopPositions"),C=_I("inset"),E=_I("margin"),_=_I("opacity"),x=_I("padding"),w=_I("saturate"),P=_I("scale"),L=_I("sepia"),O=_I("skew"),H=_I("space"),K=_I("translate"),q=()=>["auto","contain","none"],Y=()=>["auto","hidden","clip","visible","scroll"],se=()=>["auto",qp,e],ie=()=>[qp,e],de=()=>["",qS,tQ],Ce=()=>["auto",yM,qp],xe=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],fe=()=>["solid","dashed","dotted","double","none"],Ie=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ve=()=>["start","end","center","between","around","evenly","stretch"],Qe=()=>["","0",qp],De=()=>["auto","avoid","all","avoid-page","page","left","right","column"],Fe=()=>[yM,qp];return{cacheSize:500,separator:":",theme:{colors:[m3],spacing:[qS,tQ],blur:["none","",nQ,qp],brightness:Fe(),borderColor:[r],borderRadius:["none","","full",nQ,qp],borderSpacing:ie(),borderWidth:de(),contrast:Fe(),grayscale:Qe(),hueRotate:Fe(),invert:Qe(),gap:ie(),gradientColorStops:[r],gradientColorStopPositions:[_je,tQ],inset:se(),margin:se(),opacity:Fe(),padding:ie(),saturate:Fe(),scale:Fe(),sepia:Qe(),skew:Fe(),space:ie(),translate:ie()},classGroups:{aspect:[{aspect:["auto","square","video",qp]}],container:["container"],columns:[{columns:[nQ]}],"break-after":[{"break-after":De()}],"break-before":[{"break-before":De()}],"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:[...xe(),qp]}],overflow:[{overflow:Y()}],"overflow-x":[{"overflow-x":Y()}],"overflow-y":[{"overflow-y":Y()}],overscroll:[{overscroll:q()}],"overscroll-x":[{"overscroll-x":q()}],"overscroll-y":[{"overscroll-y":q()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[C]}],"inset-x":[{"inset-x":[C]}],"inset-y":[{"inset-y":[C]}],start:[{start:[C]}],end:[{end:[C]}],top:[{top:[C]}],right:[{right:[C]}],bottom:[{bottom:[C]}],left:[{left:[C]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",g3,qp]}],basis:[{basis:se()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",qp]}],grow:[{grow:Qe()}],shrink:[{shrink:Qe()}],order:[{order:["first","last","none",g3,qp]}],"grid-cols":[{"grid-cols":[m3]}],"col-start-end":[{col:["auto",{span:["full",g3,qp]},qp]}],"col-start":[{"col-start":Ce()}],"col-end":[{"col-end":Ce()}],"grid-rows":[{"grid-rows":[m3]}],"row-start-end":[{row:["auto",{span:[g3,qp]},qp]}],"row-start":[{"row-start":Ce()}],"row-end":[{"row-end":Ce()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",qp]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",qp]}],gap:[{gap:[d]}],"gap-x":[{"gap-x":[d]}],"gap-y":[{"gap-y":[d]}],"justify-content":[{justify:["normal",...ve()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...ve(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...ve(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[x]}],px:[{px:[x]}],py:[{py:[x]}],ps:[{ps:[x]}],pe:[{pe:[x]}],pt:[{pt:[x]}],pr:[{pr:[x]}],pb:[{pb:[x]}],pl:[{pl:[x]}],m:[{m:[E]}],mx:[{mx:[E]}],my:[{my:[E]}],ms:[{ms:[E]}],me:[{me:[E]}],mt:[{mt:[E]}],mr:[{mr:[E]}],mb:[{mb:[E]}],ml:[{ml:[E]}],"space-x":[{"space-x":[H]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[H]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",qp,e]}],"min-w":[{"min-w":[qp,e,"min","max","fit"]}],"max-w":[{"max-w":[qp,e,"none","full","min","max","fit","prose",{screen:[nQ]},nQ]}],h:[{h:[qp,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[qp,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[qp,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[qp,e,"auto","min","max","fit"]}],"font-size":[{text:["base",nQ,tQ]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",vz]}],"font-family":[{font:[m3]}],"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",qp]}],"line-clamp":[{"line-clamp":["none",yM,vz]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",qS,qp]}],"list-image":[{"list-image":["none",qp]}],"list-style-type":[{list:["none","disc","decimal",qp]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[r]}],"placeholder-opacity":[{"placeholder-opacity":[_]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[r]}],"text-opacity":[{"text-opacity":[_]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...fe(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",qS,tQ]}],"underline-offset":[{"underline-offset":["auto",qS,qp]}],"text-decoration-color":[{decoration:[r]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:ie()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",qp]}],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",qp]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[_]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...xe(),bje]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",Bje]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},wje]}],"bg-color":[{bg:[r]}],"gradient-from-pos":[{from:[m]}],"gradient-via-pos":[{via:[m]}],"gradient-to-pos":[{to:[m]}],"gradient-from":[{from:[f]}],"gradient-via":[{via:[f]}],"gradient-to":[{to:[f]}],rounded:[{rounded:[o]}],"rounded-s":[{"rounded-s":[o]}],"rounded-e":[{"rounded-e":[o]}],"rounded-t":[{"rounded-t":[o]}],"rounded-r":[{"rounded-r":[o]}],"rounded-b":[{"rounded-b":[o]}],"rounded-l":[{"rounded-l":[o]}],"rounded-ss":[{"rounded-ss":[o]}],"rounded-se":[{"rounded-se":[o]}],"rounded-ee":[{"rounded-ee":[o]}],"rounded-es":[{"rounded-es":[o]}],"rounded-tl":[{"rounded-tl":[o]}],"rounded-tr":[{"rounded-tr":[o]}],"rounded-br":[{"rounded-br":[o]}],"rounded-bl":[{"rounded-bl":[o]}],"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":[_]}],"border-style":[{border:[...fe(),"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":[_]}],"divide-style":[{divide:fe()}],"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:["",...fe()]}],"outline-offset":[{"outline-offset":[qS,qp]}],"outline-w":[{outline:[qS,tQ]}],"outline-color":[{outline:[r]}],"ring-w":[{ring:de()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[r]}],"ring-opacity":[{"ring-opacity":[_]}],"ring-offset-w":[{"ring-offset":[qS,tQ]}],"ring-offset-color":[{"ring-offset":[r]}],shadow:[{shadow:["","inner","none",nQ,Qje]}],"shadow-color":[{shadow:[m3]}],opacity:[{opacity:[_]}],"mix-blend":[{"mix-blend":[...Ie(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":Ie()}],filter:[{filter:["","none"]}],blur:[{blur:[t]}],brightness:[{brightness:[n]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",nQ,qp]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[A]}],saturate:[{saturate:[w]}],sepia:[{sepia:[L]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[t]}],"backdrop-brightness":[{"backdrop-brightness":[n]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[A]}],"backdrop-opacity":[{"backdrop-opacity":[_]}],"backdrop-saturate":[{"backdrop-saturate":[w]}],"backdrop-sepia":[{"backdrop-sepia":[L]}],"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",qp]}],duration:[{duration:Fe()}],ease:[{ease:["linear","in","out","in-out",qp]}],delay:[{delay:Fe()}],animate:[{animate:["none","spin","ping","pulse","bounce",qp]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[P]}],"scale-x":[{"scale-x":[P]}],"scale-y":[{"scale-y":[P]}],rotate:[{rotate:[g3,qp]}],"translate-x":[{"translate-x":[K]}],"translate-y":[{"translate-y":[K]}],"skew-x":[{"skew-x":[O]}],"skew-y":[{"skew-y":[O]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",qp]}],accent:[{accent:["auto",r]}],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",qp]}],"caret-color":[{caret:[r]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":ie()}],"scroll-mx":[{"scroll-mx":ie()}],"scroll-my":[{"scroll-my":ie()}],"scroll-ms":[{"scroll-ms":ie()}],"scroll-me":[{"scroll-me":ie()}],"scroll-mt":[{"scroll-mt":ie()}],"scroll-mr":[{"scroll-mr":ie()}],"scroll-mb":[{"scroll-mb":ie()}],"scroll-ml":[{"scroll-ml":ie()}],"scroll-p":[{"scroll-p":ie()}],"scroll-px":[{"scroll-px":ie()}],"scroll-py":[{"scroll-py":ie()}],"scroll-ps":[{"scroll-ps":ie()}],"scroll-pe":[{"scroll-pe":ie()}],"scroll-pt":[{"scroll-pt":ie()}],"scroll-pr":[{"scroll-pr":ie()}],"scroll-pb":[{"scroll-pb":ie()}],"scroll-pl":[{"scroll-pl":ie()}],"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",qp]}],fill:[{fill:[r,"none"]}],"stroke-w":[{stroke:[qS,tQ,vz]}],stroke:[{stroke:[r,"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 xo=typeof window<"u"?window:void 0,Jx=typeof globalThis<"u"?globalThis:xo,Xde=Array.prototype,$de=Xde.forEach,efe=Xde.indexOf,_B=Jx==null?void 0:Jx.navigator,Au=Jx==null?void 0:Jx.document,Wx=Jx==null?void 0:Jx.location,Iz=Jx==null?void 0:Jx.fetch,Cz=Jx!=null&&Jx.XMLHttpRequest&&"withCredentials"in new Jx.XMLHttpRequest?Jx.XMLHttpRequest:void 0,tfe=Jx==null?void 0:Jx.AbortController,qx=_B==null?void 0:_B.userAgent,wh=xo??{},ZS={DEBUG:!1,LIB_VERSION:"1.257.2"},Ez="$copy_autocapture",Tje=["$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"],XS=function(r){return r.GZipJS="gzip-js",r.Base64="base64",r}({}),Pje=["fatal","error","warning","log","info","debug"];function Wg(r,e){return r.indexOf(e)!==-1}var oP=function(r){return r.trim()},_z=function(r){return r.replace(/^\$/,"")},kje=Array.isArray,nfe=Object.prototype,rfe=nfe.hasOwnProperty,aP=nfe.toString,OI=kje||function(r){return aP.call(r)==="[object Array]"},jB=r=>typeof r=="function",TC=r=>r===Object(r)&&!OI(r),IM=r=>{if(TC(r)){for(var e in r)if(rfe.call(r,e))return!1;return!0}return!1},dc=r=>r===void 0,PC=r=>aP.call(r)=="[object String]",xz=r=>PC(r)&&r.trim().length===0,rQ=r=>r===null,Um=r=>dc(r)||rQ(r),q_=r=>aP.call(r)=="[object Number]",Zb=r=>aP.call(r)==="[object Boolean]",Uje=r=>r instanceof FormData,Fje=r=>Wg(Tje,r),ife=r=>{var e={t:function(t){if(xo&&(ZS.DEBUG||wh.POSTHOG_DEBUG)&&!dc(xo.console)&&xo.console){for(var n=("__rrweb_original__"in xo.console[t])?xo.console[t].__rrweb_original__:xo.console[t],i=arguments.length,o=new Array(i>1?i-1:0),a=1;a<i;a++)o[a-1]=arguments[a];n(r,...o)}},info:function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];e.t("log",...n)},warn:function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];e.t("warn",...n)},error:function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];e.t("error",...n)},critical:function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];console.error(r,...n)},uninitializedWarning:t=>{e.error("You must initialize PostHog before calling "+t)},createLogger:t=>ife(r+" "+t)};return e},bu=ife("[PostHog.js]"),XE=bu.createLogger,Lje=XE("[ExternalScriptsLoader]"),ofe=(r,e,t)=>{if(r.config.disable_external_dependency_loading)return Lje.warn(e+" was requested but loading of external scripts is disabled."),t("Loading of external scripts is disabled");var n=Au==null?void 0:Au.querySelectorAll("script");if(n){for(var i=0;i<n.length;i++)if(n[i].src===e)return t()}var o=()=>{if(!Au)return t("document not found");var a=Au.createElement("script");if(a.type="text/javascript",a.crossOrigin="anonymous",a.src=e,a.onload=c=>t(void 0,c),a.onerror=c=>t(c),r.config.prepare_external_dependency_script&&(a=r.config.prepare_external_dependency_script(a)),!a)return t("prepare_external_dependency_script returned null");var s,l=Au.querySelectorAll("body > script");l.length>0?(s=l[0].parentNode)==null||s.insertBefore(a,l[0]):Au.body.appendChild(a)};Au!=null&&Au.body?o():Au==null||Au.addEventListener("DOMContentLoaded",o)};function Wc(){return Wc=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},Wc.apply(null,arguments)}function afe(r,e){if(r==null)return{};var t={};for(var n in r)if({}.hasOwnProperty.call(r,n)){if(e.indexOf(n)!==-1)continue;t[n]=r[n]}return t}wh.__PosthogExtensions__=wh.__PosthogExtensions__||{},wh.__PosthogExtensions__.loadExternalDependency=(r,e,t)=>{var n="/static/"+e+".js?v="+r.version;if(e==="remote-config"&&(n="/array/"+r.config.token+"/config.js"),e==="toolbar"){var i=3e5;n=n+"&t="+Math.floor(Date.now()/i)*i}var o=r.requestRouter.endpointFor("assets",n);ofe(r,o,t)},wh.__PosthogExtensions__.loadSiteApp=(r,e,t)=>{var n=r.requestRouter.endpointFor("api",e);ofe(r,n,t)};var sP={};function iQ(r,e,t){if(OI(r)){if($de&&r.forEach===$de)r.forEach(e,t);else if("length"in r&&r.length===+r.length){for(var n=0,i=r.length;n<i;n++)if(n in r&&e.call(t,r[n],n)===sP)return}}}function av(r,e,t){if(!Um(r)){if(OI(r))return iQ(r,e,t);if(Uje(r)){for(var n of r.entries())if(e.call(t,n[1],n[0])===sP)return}else for(var i in r)if(rfe.call(r,i)&&e.call(t,r[i],i)===sP)return}}var u1=function(r){for(var e=arguments.length,t=new Array(e>1?e-1:0),n=1;n<e;n++)t[n-1]=arguments[n];return iQ(t,function(i){for(var o in i)i[o]!==void 0&&(r[o]=i[o])}),r},lP=function(r){for(var e=arguments.length,t=new Array(e>1?e-1:0),n=1;n<e;n++)t[n-1]=arguments[n];return iQ(t,function(i){iQ(i,function(o){r.push(o)})}),r};function cP(r){for(var e=Object.keys(r),t=e.length,n=new Array(t);t--;)n[t]=[e[t],r[e[t]]];return n}var sfe=function(r){try{return r()}catch{return}},Gje=function(r){return function(){try{for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r.apply(this,t)}catch(i){bu.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),bu.critical(i)}}},Bz=function(r){var e={};return av(r,function(t,n){(PC(t)&&t.length>0||q_(t))&&(e[n]=t)}),e};function Oje(r,e){return t=r,n=o=>PC(o)&&!rQ(e)?o.slice(0,e):o,i=new Set,function o(a,s){return a!==Object(a)?n?n(a,s):a:i.has(a)?void 0:(i.add(a),OI(a)?(l=[],iQ(a,c=>{l.push(o(c))})):(l={},av(a,(c,u)=>{i.has(c)||(l[u]=o(c,u))})),l);var l}(t);var t,n,i}var zje=["herokuapp.com","vercel.app","netlify.app"];function Hje(r){var e=r==null?void 0:r.hostname;if(!PC(e))return!1;var t=e.split(".").slice(-2).join(".");for(var n of zje)if(t===n)return!1;return!0}function lfe(r,e){for(var t=0;t<r.length;t++)if(e(r[t]))return r[t]}function oC(r,e,t,n){var{capture:i=!1,passive:o=!0}=n??{};r==null||r.addEventListener(e,t,{capture:i,passive:o})}var cfe="$people_distinct_id",y3="__alias",v3="__timers",ufe="$autocapture_disabled_server_side",bz="$heatmaps_enabled_server_side",Afe="$exception_capture_enabled_server_side",Sz="$error_tracking_suppression_rules",dfe="$web_vitals_enabled_server_side",ffe="$dead_clicks_enabled_server_side",hfe="$web_vitals_allowed_metrics",wz="$session_recording_enabled_server_side",pfe="$console_log_recording_enabled_server_side",gfe="$session_recording_network_payload_capture",mfe="$session_recording_masking",yfe="$session_recording_canvas_recording",vfe="$replay_sample_rate",Ife="$replay_minimum_duration",Cfe="$replay_script_config",uP="$sesid",I3="$session_is_sampled",Qz="$session_recording_url_trigger_activated_session",Mz="$session_recording_event_trigger_activated_session",CM="$enabled_feature_flags",AP="$early_access_features",Dz="$feature_flag_details",C3="$stored_person_properties",h2="$stored_group_properties",Rz="$surveys",dP="$surveys_activated",fP="$flag_call_reported",$S="$user_state",Nz="$client_session_props",Tz="$capture_rate_limit",Pz="$initial_campaign_params",kz="$initial_referrer_info",hP="$initial_person_info",pP="$epp",Efe="__POSTHOG_TOOLBAR__",gP="$posthog_cookieless",Yje=[cfe,y3,"__cmpns",v3,wz,bz,uP,CM,Sz,$S,AP,Dz,h2,C3,Rz,fP,Nz,Tz,Pz,kz,pP,hP];function _fe(r){return r instanceof Element&&(r.id===Efe||!(r.closest==null||!r.closest(".toolbar-global-fade-container")))}function mP(r){return!!r&&r.nodeType===1}function oQ(r,e){return!!r&&!!r.tagName&&r.tagName.toLowerCase()===e.toLowerCase()}function xfe(r){return!!r&&r.nodeType===3}function Bfe(r){return!!r&&r.nodeType===11}function Uz(r){return r?oP(r).split(/\s+/):[]}function bfe(r){var e=xo==null?void 0:xo.location.href;return!!(e&&r&&r.some(t=>e.match(t)))}function yP(r){var e="";switch(typeof r.className){case"string":e=r.className;break;case"object":e=(r.className&&"baseVal"in r.className?r.className.baseVal:null)||r.getAttribute("class")||"";break;default:e=""}return Uz(e)}function Sfe(r){return Um(r)?null:oP(r).split(/(\s+)/).filter(e=>EM(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function vP(r){var e="";return Lz(r)&&!Mfe(r)&&r.childNodes&&r.childNodes.length&&av(r.childNodes,function(t){var n;xfe(t)&&t.textContent&&(e+=(n=Sfe(t.textContent))!==null&&n!==void 0?n:"")}),oP(e)}function wfe(r){return dc(r.target)?r.srcElement||null:(e=r.target)!=null&&e.shadowRoot?r.composedPath()[0]||null:r.target||null;var e}var Fz=["a","button","form","input","select","textarea","label"];function Qfe(r){var e=r.parentNode;return!(!e||!mP(e))&&e}function Vje(r,e,t,n,i){var o,a,s;if(t===void 0&&(t=void 0),!xo||!r||oQ(r,"html")||!mP(r)||(o=t)!=null&&o.url_allowlist&&!bfe(t.url_allowlist)||(a=t)!=null&&a.url_ignorelist&&bfe(t.url_ignorelist))return!1;if((s=t)!=null&&s.dom_event_allowlist){var l=t.dom_event_allowlist;if(l&&!l.some(E=>e.type===E))return!1}for(var c=!1,u=[r],A=!0,d=r;d.parentNode&&!oQ(d,"body");)if(Bfe(d.parentNode))u.push(d.parentNode.host),d=d.parentNode.host;else{if(!(A=Qfe(d)))break;if(n||Fz.indexOf(A.tagName.toLowerCase())>-1)c=!0;else{var f=xo.getComputedStyle(A);f&&f.getPropertyValue("cursor")==="pointer"&&(c=!0)}u.push(A),d=A}if(!function(E,_){var x=_==null?void 0:_.element_allowlist;if(dc(x))return!0;var w,P=function(O){if(x.some(H=>O.tagName.toLowerCase()===H))return{v:!0}};for(var L of E)if(w=P(L))return w.v;return!1}(u,t)||!function(E,_){var x=_==null?void 0:_.css_selector_allowlist;if(dc(x))return!0;var w,P=function(O){if(x.some(H=>O.matches(H)))return{v:!0}};for(var L of E)if(w=P(L))return w.v;return!1}(u,t))return!1;var m=xo.getComputedStyle(r);if(m&&m.getPropertyValue("cursor")==="pointer"&&e.type==="click")return!0;var C=r.tagName.toLowerCase();switch(C){case"html":return!1;case"form":return(i||["submit"]).indexOf(e.type)>=0;case"input":case"select":case"textarea":return(i||["change","click"]).indexOf(e.type)>=0;default:return c?(i||["click"]).indexOf(e.type)>=0:(i||["click"]).indexOf(e.type)>=0&&(Fz.indexOf(C)>-1||r.getAttribute("contenteditable")==="true")}}function Lz(r){for(var e=r;e.parentNode&&!oQ(e,"body");e=e.parentNode){var t=yP(e);if(Wg(t,"ph-sensitive")||Wg(t,"ph-no-capture"))return!1}if(Wg(yP(r),"ph-include"))return!0;var n=r.type||"";if(PC(n))switch(n.toLowerCase()){case"hidden":case"password":return!1}var i=r.name||r.id||"";return!(PC(i)&&/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(i.replace(/[^a-zA-Z0-9]/g,"")))}function Mfe(r){return!!(oQ(r,"input")&&!["button","checkbox","submit","reset"].includes(r.type)||oQ(r,"select")||oQ(r,"textarea")||r.getAttribute("contenteditable")==="true")}var Dfe="(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})",Kje=new RegExp("^(?:"+Dfe+")$"),jje=new RegExp(Dfe),Rfe="\\d{3}-?\\d{2}-?\\d{4}",Jje=new RegExp("^("+Rfe+")$"),Wje=new RegExp("("+Rfe+")");function EM(r,e){return e===void 0&&(e=!0),!(Um(r)||PC(r)&&(r=oP(r),(e?Kje:jje).test((r||"").replace(/[- ]/g,""))||(e?Jje:Wje).test(r)))}function Nfe(r){var e=vP(r);return EM(e=(e+" "+Tfe(r)).trim())?e:""}function Tfe(r){var e="";return r&&r.childNodes&&r.childNodes.length&&av(r.childNodes,function(t){var n;if(t&&((n=t.tagName)==null?void 0:n.toLowerCase())==="span")try{var i=vP(t);e=(e+" "+i).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+Tfe(t)).trim())}catch(o){bu.error("[AutoCapture]",o)}}),e}function qje(r){return function(e){var t=e.map(n=>{var i,o,a="";if(n.tag_name&&(a+=n.tag_name),n.attr_class)for(var s of(n.attr_class.sort(),n.attr_class))a+="."+s.replace(/"/g,"");var l=Wc({},n.text?{text:n.text}:{},{"nth-child":(i=n.nth_child)!==null&&i!==void 0?i:0,"nth-of-type":(o=n.nth_of_type)!==null&&o!==void 0?o:0},n.href?{href:n.href}:{},n.attr_id?{attr_id:n.attr_id}:{},n.attributes),c={};return cP(l).sort((u,A)=>{var[d]=u,[f]=A;return d.localeCompare(f)}).forEach(u=>{var[A,d]=u;return c[Pfe(A.toString())]=Pfe(d.toString())}),a+=":",a+=cP(c).map(u=>{var[A,d]=u;return A+'="'+d+'"'}).join("")});return t.join(";")}(function(e){return e.map(t=>{var n,i,o={text:(n=t.$el_text)==null?void 0:n.slice(0,400),tag_name:t.tag_name,href:(i=t.attr__href)==null?void 0:i.slice(0,2048),attr_class:Zje(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return cP(t).filter(a=>{var[s]=a;return s.indexOf("attr__")===0}).forEach(a=>{var[s,l]=a;return o.attributes[s]=l}),o})}(r))}function Pfe(r){return r.replace(/"|\\"/g,'\\"')}function Zje(r){var e=r.attr__class;return e?OI(e)?e:Uz(e):void 0}class kfe{constructor(){this.clicks=[]}isRageClick(e,t,n){var i=this.clicks[this.clicks.length-1];if(i&&Math.abs(e-i.x)+Math.abs(t-i.y)<30&&n-i.timestamp<1e3){if(this.clicks.push({x:e,y:t,timestamp:n}),this.clicks.length===3)return!0}else this.clicks=[{x:e,y:t,timestamp:n}];return!1}}var Xje=["localhost","127.0.0.1"],_M=r=>{var e=Au==null?void 0:Au.createElement("a");return dc(e)?null:(e.href=r,e)},$je=function(r,e){var t,n;e===void 0&&(e="&");var i=[];return av(r,function(o,a){dc(o)||dc(a)||a==="undefined"||(t=encodeURIComponent((s=>s instanceof File)(o)?o.name:o.toString()),n=encodeURIComponent(a),i[i.length]=n+"="+t)}),i.join(e)},IP=function(r,e){for(var t,n=((r.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),i=0;i<n.length;i++){var o=n[i].split("=");if(o[0]===e){t=o;break}}if(!OI(t)||t.length<2)return"";var a=t[1];try{a=decodeURIComponent(a)}catch{bu.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},Gz=function(r,e,t){if(!r||!e||!e.length)return r;for(var n=r.split("#"),i=n[0]||"",o=n[1],a=i.split("?"),s=a[1],l=a[0],c=(s||"").split("&"),u=[],A=0;A<c.length;A++){var d=c[A].split("=");OI(d)&&(e.includes(d[0])?u.push(d[0]+"="+t):u.push(c[A]))}var f=l;return s!=null&&(f+="?"+u.join("&")),o!=null&&(f+="#"+o),f},CP=function(r,e){var t=r.match(new RegExp(e+"=([^&]*)"));return t?t[1]:null},Ufe=XE("[AutoCapture]");function Oz(r,e){return e.length>r?e.slice(0,r)+"...":e}function eJe(r){if(r.previousElementSibling)return r.previousElementSibling;var e=r;do e=e.previousSibling;while(e&&!mP(e));return e}function tJe(r,e,t,n){var i=r.tagName.toLowerCase(),o={tag_name:i};Fz.indexOf(i)>-1&&!t&&(i.toLowerCase()==="a"||i.toLowerCase()==="button"?o.$el_text=Oz(1024,Nfe(r)):o.$el_text=Oz(1024,vP(r)));var a=yP(r);a.length>0&&(o.classes=a.filter(function(u){return u!==""})),av(r.attributes,function(u){var A;if((!Mfe(r)||["name","id","class","aria-label"].indexOf(u.name)!==-1)&&(n==null||!n.includes(u.name))&&!e&&EM(u.value)&&(A=u.name,!PC(A)||A.substring(0,10)!=="_ngcontent"&&A.substring(0,7)!=="_nghost")){var d=u.value;u.name==="class"&&(d=Uz(d).join(" ")),o["attr__"+u.name]=Oz(1024,d)}});for(var s=1,l=1,c=r;c=eJe(c);)s++,c.tagName===r.tagName&&l++;return o.nth_child=s,o.nth_of_type=l,o}function nJe(r,e){for(var t,n,{e:i,maskAllElementAttributes:o,maskAllText:a,elementAttributeIgnoreList:s,elementsChainAsString:l}=e,c=[r],u=r;u.parentNode&&!oQ(u,"body");)Bfe(u.parentNode)?(c.push(u.parentNode.host),u=u.parentNode.host):(c.push(u.parentNode),u=u.parentNode);var A,d=[],f={},m=!1,C=!1;if(av(c,P=>{var L=Lz(P);P.tagName.toLowerCase()==="a"&&(m=P.getAttribute("href"),m=L&&m&&EM(m)&&m),Wg(yP(P),"ph-no-capture")&&(C=!0),d.push(tJe(P,o,a,s));var O=function(H){if(!Lz(H))return{};var K={};return av(H.attributes,function(q){if(q.name&&q.name.indexOf("data-ph-capture-attribute")===0){var Y=q.name.replace("data-ph-capture-attribute-",""),se=q.value;Y&&se&&EM(se)&&(K[Y]=se)}}),K}(P);u1(f,O)}),C)return{props:{},explicitNoCapture:C};if(a||(r.tagName.toLowerCase()==="a"||r.tagName.toLowerCase()==="button"?d[0].$el_text=Nfe(r):d[0].$el_text=vP(r)),m){var E,_;d[0].attr__href=m;var x=(E=_M(m))==null?void 0:E.host,w=xo==null||(_=xo.location)==null?void 0:_.host;x&&w&&x!==w&&(A=m)}return{props:u1({$event_type:i.type,$ce_version:1},l?{}:{$elements:d},{$elements_chain:qje(d)},(t=d[0])!=null&&t.$el_text?{$el_text:(n=d[0])==null?void 0:n.$el_text}:{},A&&i.type==="click"?{$external_click_url:A}:{},f)}}class rJe{constructor(e){this.i=!1,this.o=null,this.rageclicks=new kfe,this.h=!1,this.instance=e,this.m=null}get S(){var e,t,n=TC(this.instance.config.autocapture)?this.instance.config.autocapture:{};return n.url_allowlist=(e=n.url_allowlist)==null?void 0:e.map(i=>new RegExp(i)),n.url_ignorelist=(t=n.url_ignorelist)==null?void 0:t.map(i=>new RegExp(i)),n}$(){if(this.isBrowserSupported()){if(xo&&Au){var e=n=>{n=n||(xo==null?void 0:xo.event);try{this.k(n)}catch(i){Ufe.error("Failed to capture event",i)}};if(oC(Au,"submit",e,{capture:!0}),oC(Au,"change",e,{capture:!0}),oC(Au,"click",e,{capture:!0}),this.S.capture_copied_text){var t=n=>{n=n||(xo==null?void 0:xo.event),this.k(n,Ez)};oC(Au,"copy",t,{capture:!0}),oC(Au,"cut",t,{capture:!0})}}}else Ufe.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.i&&(this.$(),this.i=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this.h=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[ufe]:!!e.autocapture_opt_out}),this.o=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this.m=e}getElementSelectors(e){var t,n=[];return(t=this.m)==null||t.forEach(i=>{var o=Au==null?void 0:Au.querySelectorAll(i);o==null||o.forEach(a=>{e===a&&n.push(i)})}),n}get isEnabled(){var e,t,n=(e=this.instance.persistence)==null?void 0:e.props[ufe],i=this.o;if(rQ(i)&&!Zb(n)&&!this.instance.I())return!1;var o=(t=this.o)!==null&&t!==void 0?t:!!n;return!!this.instance.config.autocapture&&!o}k(e,t){if(t===void 0&&(t="$autocapture"),this.isEnabled){var n,i=wfe(e);xfe(i)&&(i=i.parentNode||null),t==="$autocapture"&&e.type==="click"&&e instanceof MouseEvent&&this.instance.config.rageclick&&(n=this.rageclicks)!=null&&n.isRageClick(e.clientX,e.clientY,new Date().getTime())&&this.k(e,"$rageclick");var o=t===Ez;if(i&&Vje(i,e,this.S,o,o?["copy","cut"]:void 0)){var{props:a,explicitNoCapture:s}=nJe(i,{e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.S.element_attribute_ignorelist,elementsChainAsString:this.h});if(s)return!1;var l=this.getElementSelectors(i);if(l&&l.length>0&&(a.$element_selectors=l),t===Ez){var c,u=Sfe(xo==null||(c=xo.getSelection())==null?void 0:c.toString()),A=e.type||"clipboard";if(!u)return!1;a.$selected_content=u,a.$copy_type=A}return this.instance.capture(t,a),!0}}}isBrowserSupported(){return jB(Au==null?void 0:Au.querySelectorAll)}}Math.trunc||(Math.trunc=function(r){return r<0?Math.ceil(r):Math.floor(r)}),Number.isInteger||(Number.isInteger=function(r){return q_(r)&&isFinite(r)&&Math.floor(r)===r});var Ffe="0123456789abcdef";class EP{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,n,i){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(n)||!Number.isInteger(i)||e<0||t<0||n<0||i<0||e>0xffffffffffff||t>4095||n>1073741823||i>4294967295)throw new RangeError("invalid field value");var o=new Uint8Array(16);return o[0]=e/Math.pow(2,40),o[1]=e/Math.pow(2,32),o[2]=e/Math.pow(2,24),o[3]=e/Math.pow(2,16),o[4]=e/Math.pow(2,8),o[5]=e,o[6]=112|t>>>8,o[7]=t,o[8]=128|n>>>24,o[9]=n>>>16,o[10]=n>>>8,o[11]=n,o[12]=i>>>24,o[13]=i>>>16,o[14]=i>>>8,o[15]=i,new EP(o)}toString(){for(var e="",t=0;t<this.bytes.length;t++)e=e+Ffe.charAt(this.bytes[t]>>>4)+Ffe.charAt(15&this.bytes[t]),t!==3&&t!==5&&t!==7&&t!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new EP(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var t=0;t<16;t++){var n=this.bytes[t]-e.bytes[t];if(n!==0)return Math.sign(n)}return 0}}class iJe{constructor(){this.P=0,this.R=0,this.T=new oJe}generate(){var e=this.generateOrAbort();if(dc(e)){this.P=0;var t=this.generateOrAbort();if(dc(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();if(e>this.P)this.P=e,this.M();else{if(!(e+1e4>this.P))return;this.R++,this.R>4398046511103&&(this.P++,this.M())}return EP.fromFieldsV7(this.P,Math.trunc(this.R/Math.pow(2,30)),this.R&Math.pow(2,30)-1,this.T.nextUint32())}M(){this.R=1024*this.T.nextUint32()+(1023&this.T.nextUint32())}}var Lfe,Gfe=r=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;e<r.length;e++)r[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return r};xo&&!dc(xo.crypto)&&crypto.getRandomValues&&(Gfe=r=>crypto.getRandomValues(r));class oJe{constructor(){this.C=new Uint32Array(8),this.F=1/0}nextUint32(){return this.F>=this.C.length&&(Gfe(this.C),this.F=0),this.C[this.F++]}}var aQ=()=>aJe().toString(),aJe=()=>(Lfe||(Lfe=new iJe)).generate(),E3="",sJe=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function lJe(r,e){if(e){var t=function(i,o){if(o===void 0&&(o=Au),E3)return E3;if(!o||["localhost","127.0.0.1"].includes(i))return"";for(var a=i.split("."),s=Math.min(a.length,8),l="dmn_chk_"+aQ();!E3&&s--;){var c=a.slice(s).join("."),u=l+"=1;domain=."+c+";path=/";o.cookie=u+";max-age=3",o.cookie.includes(l)&&(o.cookie=u+";max-age=0",E3=c)}return E3}(r);if(!t){var n=(i=>{var o=i.match(sJe);return o?o[0]:""})(r);n!==t&&bu.info("Warning: cookie subdomain discovery mismatch",n,t),t=n}return t?"; domain=."+t:""}return""}var Xb={O:()=>!!Au,A:function(r){bu.error("cookieStore error: "+r)},D:function(r){if(Au){try{for(var e=r+"=",t=Au.cookie.split(";").filter(o=>o.length),n=0;n<t.length;n++){for(var i=t[n];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}},L:function(r){var e;try{e=JSON.parse(Xb.D(r))||{}}catch{}return e},j:function(r,e,t,n,i){if(Au)try{var o="",a="",s=lJe(Au.location.hostname,n);if(t){var l=new Date;l.setTime(l.getTime()+24*t*60*60*1e3),o="; expires="+l.toUTCString()}i&&(a="; secure");var c=r+"="+encodeURIComponent(JSON.stringify(e))+o+"; SameSite=Lax; path=/"+s+a;return c.length>3686.4&&bu.warn("cookieStore warning: large cookie, len="+c.length),Au.cookie=c,c}catch{return}},N:function(r,e){try{Xb.j(r,"",-1,e)}catch{return}}},zz=null,rE={O:function(){if(!rQ(zz))return zz;var r=!0;if(dc(xo))r=!1;else try{var e="__mplssupport__";rE.j(e,"xyz"),rE.D(e)!=='"xyz"'&&(r=!1),rE.N(e)}catch{r=!1}return r||bu.error("localStorage unsupported; falling back to cookie store"),zz=r,r},A:function(r){bu.error("localStorage error: "+r)},D:function(r){try{return xo==null?void 0:xo.localStorage.getItem(r)}catch(e){rE.A(e)}return null},L:function(r){try{return JSON.parse(rE.D(r))||{}}catch{}return null},j:function(r,e){try{xo==null||xo.localStorage.setItem(r,JSON.stringify(e))}catch(t){rE.A(t)}},N:function(r){try{xo==null||xo.localStorage.removeItem(r)}catch(e){rE.A(e)}}},cJe=["distinct_id",uP,I3,pP,hP],_P=Wc({},rE,{L:function(r){try{var e={};try{e=Xb.L(r)||{}}catch{}var t=u1(e,JSON.parse(rE.D(r)||"{}"));return rE.j(r,t),t}catch{}return null},j:function(r,e,t,n,i,o){try{rE.j(r,e,void 0,void 0,o);var a={};cJe.forEach(s=>{e[s]&&(a[s]=e[s])}),Object.keys(a).length&&Xb.j(r,a,t,n,i,o)}catch(s){rE.A(s)}},N:function(r,e){try{xo==null||xo.localStorage.removeItem(r),Xb.N(r,e)}catch(t){rE.A(t)}}}),xP={},uJe={O:function(){return!0},A:function(r){bu.error("memoryStorage error: "+r)},D:function(r){return xP[r]||null},L:function(r){return xP[r]||null},j:function(r,e){xP[r]=e},N:function(r){delete xP[r]}},p2=null,v_={O:function(){if(!rQ(p2))return p2;if(p2=!0,dc(xo))p2=!1;else try{var r="__support__";v_.j(r,"xyz"),v_.D(r)!=='"xyz"'&&(p2=!1),v_.N(r)}catch{p2=!1}return p2},A:function(r){bu.error("sessionStorage error: ",r)},D:function(r){try{return xo==null?void 0:xo.sessionStorage.getItem(r)}catch(e){v_.A(e)}return null},L:function(r){try{return JSON.parse(v_.D(r))||null}catch{}return null},j:function(r,e){try{xo==null||xo.sessionStorage.setItem(r,JSON.stringify(e))}catch(t){v_.A(t)}},N:function(r){try{xo==null||xo.sessionStorage.removeItem(r)}catch(e){v_.A(e)}}},xM=function(r){return r[r.PENDING=-1]="PENDING",r[r.DENIED=0]="DENIED",r[r.GRANTED=1]="GRANTED",r}({});class AJe{constructor(e){this._instance=e}get S(){return this._instance.config}get consent(){return this.U()?xM.DENIED:this.q}isOptedOut(){return this.consent===xM.DENIED||this.consent===xM.PENDING&&this.S.opt_out_capturing_by_default}isOptedIn(){return!this.isOptedOut()}optInOut(e){this.B.j(this.H,e?1:0,this.S.cookie_expiration,this.S.cross_subdomain_cookie,this.S.secure_cookie)}reset(){this.B.N(this.H,this.S.cross_subdomain_cookie)}get H(){var{token:e,opt_out_capturing_cookie_prefix:t}=this._instance.config;return(t||"__ph_opt_in_out_")+e}get q(){var e=this.B.D(this.H);return e==="1"?xM.GRANTED:e==="0"?xM.DENIED:xM.PENDING}get B(){if(!this.W){var e=this.S.opt_out_capturing_persistence_type;this.W=e==="localStorage"?rE:Xb;var t=e==="localStorage"?Xb:rE;t.D(this.H)&&(this.W.D(this.H)||this.optInOut(t.D(this.H)==="1"),t.N(this.H,this.S.cross_subdomain_cookie))}return this.W}U(){return!!this.S.respect_dnt&&!!lfe([_B==null?void 0:_B.doNotTrack,_B==null?void 0:_B.msDoNotTrack,wh.doNotTrack],e=>Wg([!0,1,"1","yes"],e))}}var BP=XE("[Dead Clicks]"),dJe=()=>!0,fJe=r=>{var e,t=!((e=r.instance.persistence)==null||!e.get_property(ffe)),n=r.instance.config.capture_dead_clicks;return Zb(n)?n:t};class Ofe{get lazyLoadedDeadClicksAutocapture(){return this.G}constructor(e,t,n){this.instance=e,this.isEnabled=t,this.onCapture=n,this.startIfEnabled()}onRemoteConfig(e){this.instance.persistence&&this.instance.persistence.register({[ffe]:e==null?void 0:e.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.J(()=>{this.V()})}J(e){var t,n;(t=wh.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture&&e(),(n=wh.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this.instance,"dead-clicks-autocapture",i=>{i?BP.error("failed to load script",i):e()})}V(){var e;if(Au){if(!this.G&&(e=wh.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var t=TC(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this.G=wh.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.G.start(Au),BP.info("starting...")}}else BP.error("`document` not found. Cannot start.")}stop(){this.G&&(this.G.stop(),this.G=void 0,BP.info("stopping..."))}}function xB(r,e,t,n,i){return e>t&&(bu.warn("min cannot be greater than max."),e=t),q_(r)?r>t?(n&&bu.warn(n+" cannot be greater than max: "+t+". Using max value instead."),t):r<e?(n&&bu.warn(n+" cannot be less than min: "+e+". Using min value instead."),e):r:(n&&bu.warn(n+" must be a number. using max or fallback. max: "+t+", fallback: "+i),xB(i||t,e,t,n))}class zfe{constructor(e){this.K={},this.Y=()=>{Object.keys(this.K).forEach(t=>{var n=this.X(t)+this.Z;n>=this.tt?delete this.K[t]:this.it(t,n)})},this.X=t=>this.K[String(t)],this.it=(t,n)=>{this.K[String(t)]=n},this.consumeRateLimit=t=>{var n,i=(n=this.X(t))!==null&&n!==void 0?n:this.tt;if((i=Math.max(i-1,0))===0)return!0;this.it(t,i);var o,a=i===0;return a&&((o=this.et)==null||o.call(this,t)),a},this.rt=e,this.et=this.rt.et,this.tt=xB(this.rt.bucketSize,0,100,"rate limiter bucket size"),this.Z=xB(this.rt.refillRate,0,this.tt,"rate limiter refill rate"),this.st=xB(this.rt.refillInterval,0,864e5,"rate limiter refill interval"),setInterval(()=>{this.Y()},this.st)}}var bP=XE("[ExceptionAutocapture]");class hJe{constructor(e){var t,n,i;this.nt=()=>{var o;if(xo&&this.isEnabled&&(o=wh.__PosthogExtensions__)!=null&&o.errorWrappingFunctions){var a=wh.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,s=wh.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,l=wh.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.ot&&this.S.capture_unhandled_errors&&(this.ot=a(this.captureException.bind(this))),!this.lt&&this.S.capture_unhandled_rejections&&(this.lt=s(this.captureException.bind(this))),!this.ut&&this.S.capture_console_errors&&(this.ut=l(this.captureException.bind(this)))}catch(c){bP.error("failed to start",c),this.ht()}}},this._instance=e,this.dt=!((t=this._instance.persistence)==null||!t.props[Afe]),this.S=this.vt(),this.ct=new zfe({refillRate:(n=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)!==null&&n!==void 0?n:1,bucketSize:(i=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)!==null&&i!==void 0?i:10,refillInterval:1e4}),this.startIfEnabled()}vt(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return TC(e)?t=Wc({},t,e):(dc(e)?this.dt:e)&&(t=Wc({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.S.capture_console_errors||this.S.capture_unhandled_errors||this.S.capture_unhandled_rejections}startIfEnabled(){this.isEnabled&&(bP.info("enabled"),this.J(this.nt))}J(e){var t,n;(t=wh.__PosthogExtensions__)!=null&&t.errorWrappingFunctions&&e(),(n=wh.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"exception-autocapture",i=>{if(i)return bP.error("failed to load script",i);e()})}ht(){var e,t,n;(e=this.ot)==null||e.call(this),this.ot=void 0,(t=this.lt)==null||t.call(this),this.lt=void 0,(n=this.ut)==null||n.call(this),this.ut=void 0}onRemoteConfig(e){var t=e.autocaptureExceptions;this.dt=!!t||!1,this.S=this.vt(),this._instance.persistence&&this._instance.persistence.register({[Afe]:this.dt}),this.startIfEnabled()}captureException(e){var t,n=this._instance.requestRouter.endpointFor("ui");e.$exception_personURL=n+"/project/"+this._instance.config.token+"/person/"+this._instance.get_distinct_id();var i=(t=e.$exception_list[0].type)!==null&&t!==void 0?t:"Exception";this.ct.consumeRateLimit(i)?bP.info("Skipping exception capture because of client rate limiting.",{exception:e.$exception_list[0].type}):this._instance.exceptions.sendExceptionEvent(e)}}function Hfe(r){return!dc(Event)&&Yfe(r,Event)}function Yfe(r,e){try{return r instanceof e}catch{return!1}}function Vfe(r){switch(Object.prototype.toString.call(r)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":return!0;default:return Yfe(r,Error)}}function SP(r,e){return Object.prototype.toString.call(r)==="[object "+e+"]"}function Hz(r){return SP(r,"DOMError")}var Kfe=/\(error: (.*)\)/,jfe=50,BM="?";function Yz(r,e,t,n){var i={platform:"web:javascript",filename:r,function:e==="<anonymous>"?BM:e,in_app:!0};return dc(t)||(i.lineno=t),dc(n)||(i.colno=n),i}var pJe=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,gJe=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,mJe=/\((\S*)(?::(\d+))(?::(\d+))\)/,yJe=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,vJe=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,IJe=function(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];var n=e.sort((i,o)=>i[0]-o[0]).map(i=>i[1]);return function(i,o){o===void 0&&(o=0);for(var a=[],s=i.split(`
|
|
242
242
|
`),l=o;l<s.length;l++){var c=s[l];if(!(c.length>1024)){var u=Kfe.test(c)?c.replace(Kfe,"$1"):c;if(!u.match(/\S*Error: /)){for(var A of n){var d=A(u);if(d){a.push(d);break}}if(a.length>=jfe)break}}}return function(f){if(!f.length)return[];var m=Array.from(f);return m.reverse(),m.slice(0,jfe).map(C=>Wc({},C,{filename:C.filename||CJe(m).filename,function:C.function||BM}))}(a)}}([30,r=>{var e=pJe.exec(r);if(e){var[,t,n,i]=e;return Yz(t,BM,+n,+i)}var o=gJe.exec(r);if(o){if(o[2]&&o[2].indexOf("eval")===0){var a=mJe.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[s,l]=Wfe(o[1]||BM,o[2]);return Yz(l,s,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}}],[50,r=>{var e=yJe.exec(r);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){var t=vJe.exec(e[3]);t&&(e[1]=e[1]||"eval",e[3]=t[1],e[4]=t[2],e[5]="")}var n=e[3],i=e[1]||BM;return[i,n]=Wfe(i,n),Yz(n,i,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}}]);function CJe(r){return r[r.length-1]||{}}var wP,Jfe,Vz,Wfe=(r,e)=>{var t=r.indexOf("safari-extension")!==-1,n=r.indexOf("safari-web-extension")!==-1;return t||n?[r.indexOf("@")!==-1?r.split("@")[0]:BM,t?"safari-extension:"+e:"safari-web-extension:"+e]:[r,e]},EJe=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;function Kz(r,e){e===void 0&&(e=0);var t=r.stacktrace||r.stack||"",n=function(a){return a&&_Je.test(a.message)?1:0}(r);try{var i=IJe,o=function(a,s){var l=function(c){var u=globalThis._posthogChunkIds;if(!u)return{};var A=Object.keys(u);return Vz&&A.length===Jfe||(Jfe=A.length,Vz=A.reduce((d,f)=>{wP||(wP={});var m=wP[f];if(m)d[m[0]]=m[1];else for(var C=c(f),E=C.length-1;E>=0;E--){var _=C[E],x=_==null?void 0:_.filename,w=u[f];if(x&&w){d[x]=w,wP[f]=[x,w];break}}return d},{})),Vz}(s);return a.forEach(c=>{c.filename&&(c.chunk_id=l[c.filename])}),a}(i(t,n),i);return o.slice(0,o.length-e)}catch{}return[]}var _Je=/Minified React error #\d+;/i;function xJe(r,e){var t,n,i=Kz(r),o=(t=e==null?void 0:e.handled)===null||t===void 0||t,a=(n=e==null?void 0:e.synthetic)!==null&&n!==void 0&&n;return{type:e!=null&&e.overrideExceptionType?e.overrideExceptionType:r.name,value:function(s){var l=s.message;return l.error&&typeof l.error.message=="string"?String(l.error.message):String(l)}(r),stacktrace:{frames:i,type:"raw"},mechanism:{handled:o,synthetic:a}}}function qfe(r,e){var t=xJe(r,e);return r.cause&&Vfe(r.cause)&&r.cause!==r?[t,...qfe(r.cause,{handled:e==null?void 0:e.handled,synthetic:e==null?void 0:e.synthetic})]:[t]}function jz(r,e){return{$exception_list:qfe(r,e),$exception_level:"error"}}function Jz(r,e){var t,n,i,o=(t=e==null?void 0:e.handled)===null||t===void 0||t,a=(n=e==null?void 0:e.synthetic)===null||n===void 0||n,s={type:e!=null&&e.overrideExceptionType?e.overrideExceptionType:(i=e==null?void 0:e.defaultExceptionType)!==null&&i!==void 0?i:"Error",value:r||(e==null?void 0:e.defaultExceptionMessage),mechanism:{handled:o,synthetic:a}};if(e!=null&&e.syntheticException){var l=Kz(e.syntheticException,1);l.length&&(s.stacktrace={frames:l,type:"raw"})}return{$exception_list:[s],$exception_level:"error"}}function BJe(r){return PC(r)&&!xz(r)&&Pje.indexOf(r)>=0}function bJe(r,e){var t,n,i=(t=e==null?void 0:e.handled)===null||t===void 0||t,o=(n=e==null?void 0:e.synthetic)===null||n===void 0||n,a=e!=null&&e.overrideExceptionType?e.overrideExceptionType:Hfe(r)?r.constructor.name:"Error",s="Non-Error 'exception' captured with keys: "+function(u,A){A===void 0&&(A=40);var d=Object.keys(u);if(d.sort(),!d.length)return"[object has no keys]";for(var f=d.length;f>0;f--){var m=d.slice(0,f).join(", ");if(!(m.length>A))return f===d.length||m.length<=A?m:m.slice(0,A)+"..."}return""}(r),l={type:a,value:s,mechanism:{handled:i,synthetic:o}};if(e!=null&&e.syntheticException){var c=Kz(e==null?void 0:e.syntheticException,1);c.length&&(l.stacktrace={frames:c,type:"raw"})}return{$exception_list:[l],$exception_level:BJe(r.level)?r.level:"error"}}function SJe(r,e){var{error:t,event:n}=r,i={$exception_list:[]},o=t||n;if(Hz(o)||function(d){return SP(d,"DOMException")}(o)){var a=o;if(function(d){return"stack"in d}(o))i=jz(o,e);else{var s=a.name||(Hz(a)?"DOMError":"DOMException"),l=a.message?s+": "+a.message:s;i=Jz(l,Wc({},e,{overrideExceptionType:Hz(a)?"DOMError":"DOMException",defaultExceptionMessage:l}))}return"code"in a&&(i.$exception_DOMException_code=""+a.code),i}if(function(d){return SP(d,"ErrorEvent")}(o)&&o.error)return jz(o.error,e);if(Vfe(o))return jz(o,e);if(function(d){return SP(d,"Object")}(o)||Hfe(o))return bJe(o,e);if(dc(t)&&PC(n)){var c="Error",u=n,A=n.match(EJe);return A&&(c=A[1],u=A[2]),Jz(u,Wc({},e,{overrideExceptionType:c,defaultExceptionMessage:u}))}return Jz(o,e)}function Zfe(r,e,t){try{if(!(e in r))return()=>{};var n=r[e],i=t(n);return jB(i)&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__posthog_wrapped__:{enumerable:!1,value:!0}})),r[e]=i,()=>{r[e]=n}}catch{return()=>{}}}class wJe{constructor(e){var t;this._instance=e,this.ft=(xo==null||(t=xo.location)==null?void 0:t.pathname)||""}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(bu.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.gt&&this.gt(),this.gt=void 0,bu.info("History API monitoring stopped")}monitorHistoryChanges(){var e,t;if(xo&&xo.history){var n=this;(e=xo.history.pushState)!=null&&e.__posthog_wrapped__||Zfe(xo.history,"pushState",i=>function(o,a,s){i.call(this,o,a,s),n._t("pushState")}),(t=xo.history.replaceState)!=null&&t.__posthog_wrapped__||Zfe(xo.history,"replaceState",i=>function(o,a,s){i.call(this,o,a,s),n._t("replaceState")}),this.bt()}}_t(e){try{var t,n=xo==null||(t=xo.location)==null?void 0:t.pathname;if(!n)return;n!==this.ft&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:e}),this.ft=n}catch(i){bu.error("Error capturing "+e+" pageview",i)}}bt(){if(!this.gt){var e=()=>{this._t("popstate")};oC(xo,"popstate",e),this.gt=()=>{xo&&xo.removeEventListener("popstate",e)}}}}function QP(r){var e,t;return((e=JSON.stringify(r,(t=[],function(n,i){if(TC(i)){for(;t.length>0&&t[t.length-1]!==this;)t.pop();return t.includes(i)?"[Circular]":(t.push(i),i)}return i})))==null?void 0:e.length)||0}function Wz(r,e){if(e===void 0&&(e=66060288e-1),r.size>=e&&r.data.length>1){var t=Math.floor(r.data.length/2),n=r.data.slice(0,t),i=r.data.slice(t);return[Wz({size:QP(n),data:n,sessionId:r.sessionId,windowId:r.windowId}),Wz({size:QP(i),data:i,sessionId:r.sessionId,windowId:r.windowId})].flatMap(o=>o)}return[r]}var ew=(r=>(r[r.DomContentLoaded=0]="DomContentLoaded",r[r.Load=1]="Load",r[r.FullSnapshot=2]="FullSnapshot",r[r.IncrementalSnapshot=3]="IncrementalSnapshot",r[r.Meta=4]="Meta",r[r.Custom=5]="Custom",r[r.Plugin=6]="Plugin",r))(ew||{}),Cb=(r=>(r[r.Mutation=0]="Mutation",r[r.MouseMove=1]="MouseMove",r[r.MouseInteraction=2]="MouseInteraction",r[r.Scroll=3]="Scroll",r[r.ViewportResize=4]="ViewportResize",r[r.Input=5]="Input",r[r.TouchMove=6]="TouchMove",r[r.MediaInteraction=7]="MediaInteraction",r[r.StyleSheetRule=8]="StyleSheetRule",r[r.CanvasMutation=9]="CanvasMutation",r[r.Font=10]="Font",r[r.Log=11]="Log",r[r.Drag=12]="Drag",r[r.StyleDeclaration=13]="StyleDeclaration",r[r.Selection=14]="Selection",r[r.AdoptedStyleSheet=15]="AdoptedStyleSheet",r[r.CustomElement=16]="CustomElement",r))(Cb||{}),qz="[SessionRecording]",Zz="redacted",MP={initiatorTypes:["audio","beacon","body","css","early-hint","embed","fetch","frame","iframe","icon","image","img","input","link","navigation","object","ping","script","track","video","xmlhttprequest"],maskRequestFn:r=>r,recordHeaders:!1,recordBody:!1,recordInitialRequests:!1,recordPerformance:!1,performanceEntryTypeToObserve:["first-input","navigation","paint","resource"],payloadSizeLimitBytes:1e6,payloadHostDenyList:[".lr-ingest.io",".ingest.sentry.io",".clarity.ms","analytics.google.com","bam.nr-data.net"]},QJe=["authorization","x-forwarded-for","authorization","cookie","set-cookie","x-api-key","x-real-ip","remote-addr","forwarded","proxy-authorization","x-csrf-token","x-csrftoken","x-xsrf-token"],MJe=["password","secret","passwd","api_key","apikey","auth","credentials","mysql_pwd","privatekey","private_key","token"],DJe=["/s/","/e/","/i/"];function Xfe(r,e,t,n){if(Um(r))return r;var i=(e==null?void 0:e["content-length"])||function(o){return new Blob([o]).size}(r);return PC(i)&&(i=parseInt(i)),i>t?qz+" "+n+" body too large to record ("+i+" bytes)":r}function $fe(r,e){if(Um(r))return r;var t=r;return EM(t,!1)||(t=qz+" "+e+" body "+Zz),av(MJe,n=>{var i,o;(i=t)!=null&&i.length&&((o=t)==null?void 0:o.indexOf(n))!==-1&&(t=qz+" "+e+" body "+Zz+" as might contain: "+n)}),t}var RJe=(r,e)=>{var t,n,i,o={payloadSizeLimitBytes:MP.payloadSizeLimitBytes,performanceEntryTypeToObserve:[...MP.performanceEntryTypeToObserve],payloadHostDenyList:[...e.payloadHostDenyList||[],...MP.payloadHostDenyList]},a=r.session_recording.recordHeaders!==!1&&e.recordHeaders,s=r.session_recording.recordBody!==!1&&e.recordBody,l=r.capture_performance!==!1&&e.recordPerformance,c=(t=o,i=Math.min(1e6,(n=t.payloadSizeLimitBytes)!==null&&n!==void 0?n:1e6),d=>(d!=null&&d.requestBody&&(d.requestBody=Xfe(d.requestBody,d.requestHeaders,i,"Request")),d!=null&&d.responseBody&&(d.responseBody=Xfe(d.responseBody,d.responseHeaders,i,"Response")),d)),u=d=>{return c(((C,E)=>{var _,x=_M(C.name),w=E.indexOf("http")===0?(_=_M(E))==null?void 0:_.pathname:E;w==="/"&&(w="");var P=x==null?void 0:x.pathname.replace(w||"","");if(!(x&&P&&DJe.some(L=>P.indexOf(L)===0)))return C})((m=(f=d).requestHeaders,Um(m)||av(Object.keys(m??{}),C=>{QJe.includes(C.toLowerCase())&&(m[C]=Zz)}),f),r.api_host));var f,m},A=jB(r.session_recording.maskNetworkRequestFn);return A&&jB(r.session_recording.maskCapturedNetworkRequestFn)&&bu.warn("Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored."),A&&(r.session_recording.maskCapturedNetworkRequestFn=d=>{var f=r.session_recording.maskNetworkRequestFn({url:d.name});return Wc({},d,{name:f==null?void 0:f.url})}),o.maskRequestFn=jB(r.session_recording.maskCapturedNetworkRequestFn)?d=>{var f,m=u(d);return m&&(f=r.session_recording.maskCapturedNetworkRequestFn==null?void 0:r.session_recording.maskCapturedNetworkRequestFn(m))!==null&&f!==void 0?f:void 0}:d=>function(f){if(!dc(f))return f.requestBody=$fe(f.requestBody,"Request"),f.responseBody=$fe(f.responseBody,"Response"),f}(u(d)),Wc({},MP,o,{recordHeaders:a,recordBody:s,recordPerformance:l,recordInitialRequests:l})};class NJe{constructor(e,t){var n,i;t===void 0&&(t={}),this.yt={},this.wt=o=>{if(!this.yt[o]){var a,s;this.yt[o]=!0;var l=this.St(o);(a=(s=this.rt).onBlockedNode)==null||a.call(s,o,l)}},this.$t=o=>{var a=this.St(o);if((a==null?void 0:a.nodeName)!=="svg"&&a instanceof Element){var s=a.closest("svg");if(s)return[this._rrweb.mirror.getId(s),s]}return[o,a]},this.St=o=>this._rrweb.mirror.getNode(o),this.kt=o=>{var a,s,l,c,u,A,d,f;return((a=(s=o.removes)==null?void 0:s.length)!==null&&a!==void 0?a:0)+((l=(c=o.attributes)==null?void 0:c.length)!==null&&l!==void 0?l:0)+((u=(A=o.texts)==null?void 0:A.length)!==null&&u!==void 0?u:0)+((d=(f=o.adds)==null?void 0:f.length)!==null&&d!==void 0?d:0)},this.throttleMutations=o=>{if(o.type!==3||o.data.source!==0)return o;var a=o.data,s=this.kt(a);a.attributes&&(a.attributes=a.attributes.filter(c=>{var[u]=this.$t(c.id);return!this.ct.consumeRateLimit(u)&&c}));var l=this.kt(a);return l!==0||s===l?o:void 0},this._rrweb=e,this.rt=t,this.ct=new zfe({bucketSize:(n=this.rt.bucketSize)!==null&&n!==void 0?n:100,refillRate:(i=this.rt.refillRate)!==null&&i!==void 0?i:10,refillInterval:1e3,et:this.wt})}}var JB=Uint8Array,Zx=Uint16Array,bM=Uint32Array,Xz=new JB([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]),$z=new JB([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]),ehe=new JB([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),the=function(r,e){for(var t=new Zx(31),n=0;n<31;++n)t[n]=e+=1<<r[n-1];var i=new bM(t[30]);for(n=1;n<30;++n)for(var o=t[n];o<t[n+1];++o)i[o]=o-t[n]<<5|n;return[t,i]},nhe=the(Xz,2),TJe=nhe[0],eH=nhe[1];TJe[28]=258,eH[258]=28;for(var rhe=the($z,0)[1],ihe=new Zx(32768),xI=0;xI<32768;++xI){var g2=(43690&xI)>>>1|(21845&xI)<<1;g2=(61680&(g2=(52428&g2)>>>2|(13107&g2)<<2))>>>4|(3855&g2)<<4,ihe[xI]=((65280&g2)>>>8|(255&g2)<<8)>>>1}var _3=function(r,e,t){for(var n=r.length,i=0,o=new Zx(e);i<n;++i)++o[r[i]-1];var a,s=new Zx(e);for(i=0;i<e;++i)s[i]=s[i-1]+o[i-1]<<1;for(a=new Zx(n),i=0;i<n;++i)a[i]=ihe[s[r[i]-1]++]>>>15-r[i];return a},m2=new JB(288);for(xI=0;xI<144;++xI)m2[xI]=8;for(xI=144;xI<256;++xI)m2[xI]=9;for(xI=256;xI<280;++xI)m2[xI]=7;for(xI=280;xI<288;++xI)m2[xI]=8;var DP=new JB(32);for(xI=0;xI<32;++xI)DP[xI]=5;var PJe=_3(m2,9),kJe=_3(DP,5),ohe=function(r){return(r/8>>0)+(7&r&&1)},ahe=function(r,e,t){(t==null||t>r.length)&&(t=r.length);var n=new(r instanceof Zx?Zx:r instanceof bM?bM:JB)(t-e);return n.set(r.subarray(e,t)),n},tw=function(r,e,t){t<<=7&e;var n=e/8>>0;r[n]|=t,r[n+1]|=t>>>8},x3=function(r,e,t){t<<=7&e;var n=e/8>>0;r[n]|=t,r[n+1]|=t>>>8,r[n+2]|=t>>>16},tH=function(r,e){for(var t=[],n=0;n<r.length;++n)r[n]&&t.push({s:n,f:r[n]});var i=t.length,o=t.slice();if(!i)return[new JB(0),0];if(i==1){var a=new JB(t[0].s+1);return a[t[0].s]=1,[a,1]}t.sort(function(L,O){return L.f-O.f}),t.push({s:-1,f:25001});var s=t[0],l=t[1],c=0,u=1,A=2;for(t[0]={s:-1,f:s.f+l.f,l:s,r:l};u!=i-1;)s=t[t[c].f<t[A].f?c++:A++],l=t[c!=u&&t[c].f<t[A].f?c++:A++],t[u++]={s:-1,f:s.f+l.f,l:s,r:l};var d=o[0].s;for(n=1;n<i;++n)o[n].s>d&&(d=o[n].s);var f=new Zx(d+1),m=nH(t[u-1],f,0);if(m>e){n=0;var C=0,E=m-e,_=1<<E;for(o.sort(function(L,O){return f[O.s]-f[L.s]||L.f-O.f});n<i;++n){var x=o[n].s;if(!(f[x]>e))break;C+=_-(1<<m-f[x]),f[x]=e}for(C>>>=E;C>0;){var w=o[n].s;f[w]<e?C-=1<<e-f[w]++-1:++n}for(;n>=0&&C;--n){var P=o[n].s;f[P]==e&&(--f[P],++C)}m=e}return[new JB(f),m]},nH=function(r,e,t){return r.s==-1?Math.max(nH(r.l,e,t+1),nH(r.r,e,t+1)):e[r.s]=t},she=function(r){for(var e=r.length;e&&!r[--e];);for(var t=new Zx(++e),n=0,i=r[0],o=1,a=function(l){t[n++]=l},s=1;s<=e;++s)if(r[s]==i&&s!=e)++o;else{if(!i&&o>2){for(;o>138;o-=138)a(32754);o>2&&(a(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(a(i),--o;o>6;o-=6)a(8304);o>2&&(a(o-3<<5|8208),o=0)}for(;o--;)a(i);o=1,i=r[s]}return[t.subarray(0,n),e]},B3=function(r,e){for(var t=0,n=0;n<e.length;++n)t+=r[n]*e[n];return t},rH=function(r,e,t){var n=t.length,i=ohe(e+2);r[i]=255&n,r[i+1]=n>>>8,r[i+2]=255^r[i],r[i+3]=255^r[i+1];for(var o=0;o<n;++o)r[i+o+4]=t[o];return 8*(i+4+n)},lhe=function(r,e,t,n,i,o,a,s,l,c,u){tw(e,u++,t),++i[256];for(var A=tH(i,15),d=A[0],f=A[1],m=tH(o,15),C=m[0],E=m[1],_=she(d),x=_[0],w=_[1],P=she(C),L=P[0],O=P[1],H=new Zx(19),K=0;K<x.length;++K)H[31&x[K]]++;for(K=0;K<L.length;++K)H[31&L[K]]++;for(var q=tH(H,7),Y=q[0],se=q[1],ie=19;ie>4&&!Y[ehe[ie-1]];--ie);var de,Ce,xe,fe,Ie=c+5<<3,ve=B3(i,m2)+B3(o,DP)+a,Qe=B3(i,d)+B3(o,C)+a+14+3*ie+B3(H,Y)+(2*H[16]+3*H[17]+7*H[18]);if(Ie<=ve&&Ie<=Qe)return rH(e,u,r.subarray(l,l+c));if(tw(e,u,1+(Qe<ve)),u+=2,Qe<ve){de=_3(d,f),Ce=d,xe=_3(C,E),fe=C;var De=_3(Y,se);for(tw(e,u,w-257),tw(e,u+5,O-1),tw(e,u+10,ie-4),u+=14,K=0;K<ie;++K)tw(e,u+3*K,Y[ehe[K]]);u+=3*ie;for(var Fe=[x,L],Ne=0;Ne<2;++Ne){var rt=Fe[Ne];for(K=0;K<rt.length;++K){var et=31&rt[K];tw(e,u,De[et]),u+=Y[et],et>15&&(tw(e,u,rt[K]>>>5&127),u+=rt[K]>>>12)}}}else de=PJe,Ce=m2,xe=kJe,fe=DP;for(K=0;K<s;++K)if(n[K]>255){et=n[K]>>>18&31,x3(e,u,de[et+257]),u+=Ce[et+257],et>7&&(tw(e,u,n[K]>>>23&31),u+=Xz[et]);var ft=31&n[K];x3(e,u,xe[ft]),u+=fe[ft],ft>3&&(x3(e,u,n[K]>>>5&8191),u+=$z[ft])}else x3(e,u,de[n[K]]),u+=Ce[n[K]];return x3(e,u,de[256]),u+Ce[256]},UJe=new bM([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),FJe=function(){for(var r=new bM(256),e=0;e<256;++e){for(var t=e,n=9;--n;)t=(1&t&&3988292384)^t>>>1;r[e]=t}return r}(),LJe=function(){var r=4294967295;return{p:function(e){for(var t=r,n=0;n<e.length;++n)t=FJe[255&t^e[n]]^t>>>8;r=t},d:function(){return 4294967295^r}}},GJe=function(r,e,t,n,i){return function(o,a,s,l,c,u){var A=o.length,d=new JB(l+A+5*(1+Math.floor(A/7e3))+c),f=d.subarray(l,d.length-c),m=0;if(!a||A<8)for(var C=0;C<=A;C+=65535){var E=C+65535;E<A?m=rH(f,m,o.subarray(C,E)):(f[C]=u,m=rH(f,m,o.subarray(C,A)))}else{for(var _=UJe[a-1],x=_>>>13,w=8191&_,P=(1<<s)-1,L=new Zx(32768),O=new Zx(P+1),H=Math.ceil(s/3),K=2*H,q=function(Wt){return(o[Wt]^o[Wt+1]<<H^o[Wt+2]<<K)&P},Y=new bM(25e3),se=new Zx(288),ie=new Zx(32),de=0,Ce=0,xe=(C=0,0),fe=0,Ie=0;C<A;++C){var ve=q(C),Qe=32767&C,De=O[ve];if(L[Qe]=De,O[ve]=Qe,fe<=C){var Fe=A-C;if((de>7e3||xe>24576)&&Fe>423){m=lhe(o,f,0,Y,se,ie,Ce,xe,Ie,C-Ie,m),xe=de=Ce=0,Ie=C;for(var Ne=0;Ne<286;++Ne)se[Ne]=0;for(Ne=0;Ne<30;++Ne)ie[Ne]=0}var rt=2,et=0,ft=w,_t=Qe-De&32767;if(Fe>2&&ve==q(C-_t))for(var Ft=Math.min(x,Fe)-1,Lt=Math.min(32767,C),tt=Math.min(258,Fe);_t<=Lt&&--ft&&Qe!=De;){if(o[C+rt]==o[C+rt-_t]){for(var xt=0;xt<tt&&o[C+xt]==o[C+xt-_t];++xt);if(xt>rt){if(rt=xt,et=_t,xt>Ft)break;var vt=Math.min(_t,xt-2),Ht=0;for(Ne=0;Ne<vt;++Ne){var en=C-_t+Ne+32768&32767,kt=en-L[en]+32768&32767;kt>Ht&&(Ht=kt,De=en)}}}_t+=(Qe=De)-(De=L[Qe])+32768&32767}if(et){Y[xe++]=268435456|eH[rt]<<18|rhe[et];var qn=31&eH[rt],cn=31&rhe[et];Ce+=Xz[qn]+$z[cn],++se[257+qn],++ie[cn],fe=C+rt,++de}else Y[xe++]=o[C],++se[o[C]]}}m=lhe(o,f,u,Y,se,ie,Ce,xe,Ie,C-Ie,m)}return ahe(d,0,l+ohe(m)+c)}(r,e.level==null?6:e.level,e.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(r.length)))):12+e.mem,t,n,!0)},iH=function(r,e,t){for(;t;++e)r[e]=t,t>>>=8},OJe=function(r,e){var t=e.filename;if(r[0]=31,r[1]=139,r[2]=8,r[8]=e.level<2?4:e.level==9?2:0,r[9]=3,e.mtime!=0&&iH(r,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),t){r[3]=8;for(var n=0;n<=t.length;++n)r[n+10]=t.charCodeAt(n)}},zJe=function(r){return 10+(r.filename&&r.filename.length+1||0)};function che(r,e){e===void 0&&(e={});var t=LJe(),n=r.length;t.p(r);var i=GJe(r,e,zJe(e),8),o=i.length;return OJe(i,e),iH(i,o-8,t.d()),iH(i,o-4,n),i}function uhe(r,e){var t=r.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(r);for(var n=new JB(r.length+(r.length>>>1)),i=0,o=function(c){n[i++]=c},a=0;a<t;++a){if(i+5>n.length){var s=new JB(i+8+(t-a<<1));s.set(n),n=s}var l=r.charCodeAt(a);l<128||e?o(l):l<2048?(o(192|l>>>6),o(128|63&l)):l>55295&&l<57344?(o(240|(l=65536+(1047552&l)|1023&r.charCodeAt(++a))>>>18),o(128|l>>>12&63),o(128|l>>>6&63),o(128|63&l)):(o(224|l>>>12),o(128|l>>>6&63),o(128|63&l))}return ahe(n,0,i)}function HJe(r,e){return function(t){for(var n=0,i=0;i<t.length;i++)n=(n<<5)-n+t.charCodeAt(i),n|=0;return Math.abs(n)}(r)%100<xB(100*e,0,100)}var sQ="disabled",oH="sampled",RP="active",y2="buffering",aH="paused",sH="trigger",$b=sH+"_activated",Z_=sH+"_pending",eS=sH+"_"+sQ;function Ahe(r,e){return e.some(t=>t.matching==="regex"&&new RegExp(t.url).test(r))}class dhe{constructor(e){this.xt=e}triggerStatus(e){var t=this.xt.map(n=>n.triggerStatus(e));return t.includes($b)?$b:t.includes(Z_)?Z_:eS}stop(){this.xt.forEach(e=>e.stop())}}class fhe{constructor(e){this.xt=e}triggerStatus(e){var t=new Set;for(var n of this.xt)t.add(n.triggerStatus(e));switch(t.delete(eS),t.size){case 0:return eS;case 1:return Array.from(t)[0];default:return Z_}}stop(){this.xt.forEach(e=>e.stop())}}class YJe{triggerStatus(){return Z_}stop(){}}class VJe{constructor(e){this.Et=[],this.It=[],this.urlBlocked=!1,this._instance=e}onRemoteConfig(e){var t,n;this.Et=((t=e.sessionRecording)==null?void 0:t.urlTriggers)||[],this.It=((n=e.sessionRecording)==null?void 0:n.urlBlocklist)||[]}Pt(e){var t;return this.Et.length===0?eS:((t=this._instance)==null?void 0:t.get_property(Qz))===e?$b:Z_}triggerStatus(e){var t=this.Pt(e),n=t===$b?$b:t===Z_?Z_:eS;return this._instance.register_for_session({$sdk_debug_replay_url_trigger_status:n}),n}checkUrlTriggerConditions(e,t,n){if(xo!==void 0&&xo.location.href){var i=xo.location.href,o=this.urlBlocked,a=Ahe(i,this.It);o&&a||(a&&!o?e():!a&&o&&t(),Ahe(i,this.Et)&&n("url"))}}stop(){}}class KJe{constructor(e){this.linkedFlag=null,this.linkedFlagSeen=!1,this.Rt=()=>{},this._instance=e}triggerStatus(){var e=Z_;return Um(this.linkedFlag)&&(e=eS),this.linkedFlagSeen&&(e=$b),this._instance.register_for_session({$sdk_debug_replay_linked_flag_trigger_status:e}),e}onRemoteConfig(e,t){var n;if(this.linkedFlag=((n=e.sessionRecording)==null?void 0:n.linkedFlag)||null,!Um(this.linkedFlag)&&!this.linkedFlagSeen){var i=PC(this.linkedFlag)?this.linkedFlag:this.linkedFlag.flag,o=PC(this.linkedFlag)?null:this.linkedFlag.variant;this.Rt=this._instance.onFeatureFlags((a,s)=>{var l=!1;if(TC(s)&&i in s){var c=s[i];l=Zb(c)?c===!0:o?c===o:!!c}this.linkedFlagSeen=l,l&&t(i,o)})}}stop(){this.Rt()}}class jJe{constructor(e){this.Tt=[],this._instance=e}onRemoteConfig(e){var t;this.Tt=((t=e.sessionRecording)==null?void 0:t.eventTriggers)||[]}Mt(e){var t;return this.Tt.length===0?eS:((t=this._instance)==null?void 0:t.get_property(Mz))===e?$b:Z_}triggerStatus(e){var t=this.Mt(e),n=t===$b?$b:t===Z_?Z_:eS;return this._instance.register_for_session({$sdk_debug_replay_event_trigger_status:n}),n}stop(){}}function JJe(r){return r.isRecordingEnabled?y2:sQ}function WJe(r){if(!r.receivedFlags)return y2;if(!r.isRecordingEnabled)return sQ;if(r.urlTriggerMatching.urlBlocked)return aH;var e=r.isSampled===!0,t=new dhe([r.eventTriggerMatching,r.urlTriggerMatching,r.linkedFlagMatching]).triggerStatus(r.sessionId);return e?oH:t===$b?RP:t===Z_?y2:r.isSampled===!1?sQ:RP}function qJe(r){if(!r.receivedFlags)return y2;if(!r.isRecordingEnabled)return sQ;if(r.urlTriggerMatching.urlBlocked)return aH;var e=new fhe([r.eventTriggerMatching,r.urlTriggerMatching,r.linkedFlagMatching]).triggerStatus(r.sessionId),t=e!==eS,n=Zb(r.isSampled);return t&&e===Z_?y2:t&&e===eS||n&&!r.isSampled?sQ:r.isSampled===!0?oH:RP}var b3="[SessionRecording]",X_=XE(b3);function NP(){var r;return wh==null||(r=wh.__PosthogExtensions__)==null||(r=r.rrweb)==null?void 0:r.record}var ZJe=3e5,XJe=[Cb.MouseMove,Cb.MouseInteraction,Cb.Scroll,Cb.ViewportResize,Cb.Input,Cb.TouchMove,Cb.MediaInteraction,Cb.Drag],hhe=r=>({rrwebMethod:r,enqueuedAt:Date.now(),attempt:1});function v2(r){return function(e,t){for(var n="",i=0;i<e.length;){var o=e[i++];n+=String.fromCharCode(o)}return n}(che(uhe(JSON.stringify(r))))}function phe(r){return r.type===ew.Custom&&r.data.tag==="sessionIdle"}class $Je{get sessionId(){return this.Ct}get Ft(){return this._instance.config.session_recording.session_idle_threshold_ms||3e5}get started(){return this.Ot}get At(){if(!this._instance.sessionManager)throw new Error(b3+" must be started with a valid sessionManager.");return this._instance.sessionManager}get Dt(){var e,t;return this.Lt.triggerStatus(this.sessionId)===Z_?6e4:(e=(t=this._instance.config.session_recording)==null?void 0:t.full_snapshot_interval_millis)!==null&&e!==void 0?e:ZJe}get jt(){var e=this._instance.get_property(I3);return Zb(e)?e:null}get Nt(){var e,t,n=(e=this.C)==null?void 0:e.data[((t=this.C)==null?void 0:t.data.length)-1],{sessionStartTimestamp:i}=this.At.checkAndGetSessionAndWindowId(!0);return n?n.timestamp-i:null}get zt(){var e=!!this._instance.get_property(wz),t=!this._instance.config.disable_session_recording;return xo&&e&&t}get Ut(){var e=!!this._instance.get_property(pfe),t=this._instance.config.enable_recording_console_log;return t??e}get qt(){var e,t,n,i,o,a,s=this._instance.config.session_recording.captureCanvas,l=this._instance.get_property(yfe),c=(e=(t=s==null?void 0:s.recordCanvas)!==null&&t!==void 0?t:l==null?void 0:l.enabled)!==null&&e!==void 0&&e,u=(n=(i=s==null?void 0:s.canvasFps)!==null&&i!==void 0?i:l==null?void 0:l.fps)!==null&&n!==void 0?n:4,A=(o=(a=s==null?void 0:s.canvasQuality)!==null&&a!==void 0?a:l==null?void 0:l.quality)!==null&&o!==void 0?o:.4;if(typeof A=="string"){var d=parseFloat(A);A=isNaN(d)?.4:d}return{enabled:c,fps:xB(u,0,12,"canvas recording fps",4),quality:xB(A,0,1,"canvas recording quality",.4)}}get Bt(){var e,t,n=this._instance.get_property(gfe),i={recordHeaders:(e=this._instance.config.session_recording)==null?void 0:e.recordHeaders,recordBody:(t=this._instance.config.session_recording)==null?void 0:t.recordBody},o=(i==null?void 0:i.recordHeaders)||(n==null?void 0:n.recordHeaders),a=(i==null?void 0:i.recordBody)||(n==null?void 0:n.recordBody),s=TC(this._instance.config.capture_performance)?this._instance.config.capture_performance.network_timing:this._instance.config.capture_performance,l=!!(Zb(s)?s:n!=null&&n.capturePerformance);return o||a||l?{recordHeaders:o,recordBody:a,recordPerformance:l}:void 0}get Ht(){var e,t,n,i,o,a,s=this._instance.get_property(mfe),l={maskAllInputs:(e=this._instance.config.session_recording)==null?void 0:e.maskAllInputs,maskTextSelector:(t=this._instance.config.session_recording)==null?void 0:t.maskTextSelector,blockSelector:(n=this._instance.config.session_recording)==null?void 0:n.blockSelector},c=(i=l==null?void 0:l.maskAllInputs)!==null&&i!==void 0?i:s==null?void 0:s.maskAllInputs,u=(o=l==null?void 0:l.maskTextSelector)!==null&&o!==void 0?o:s==null?void 0:s.maskTextSelector,A=(a=l==null?void 0:l.blockSelector)!==null&&a!==void 0?a:s==null?void 0:s.blockSelector;return dc(c)&&dc(u)&&dc(A)?void 0:{maskAllInputs:c==null||c,maskTextSelector:u,blockSelector:A}}get Wt(){var e=this._instance.get_property(vfe);return q_(e)?e:null}get Gt(){var e=this._instance.get_property(Ife);return q_(e)?e:null}get status(){return this.Jt?this.Vt({receivedFlags:this.Jt,isRecordingEnabled:this.zt,isSampled:this.jt,urlTriggerMatching:this.Kt,eventTriggerMatching:this.Yt,linkedFlagMatching:this.Xt,sessionId:this.sessionId}):y2}constructor(e){if(this.Vt=JJe,this.Jt=!1,this.Qt=[],this.Zt="unknown",this.ti=Date.now(),this.Lt=new YJe,this.ii=void 0,this.ei=void 0,this.ri=void 0,this.si=void 0,this.ni=void 0,this._forceAllowLocalhostNetworkCapture=!1,this.oi=()=>{this.ai()},this.li=()=>{this.ui("browser offline",{})},this.hi=()=>{this.ui("browser online",{})},this.di=()=>{if(Au!=null&&Au.visibilityState){var i="window "+Au.visibilityState;this.ui(i,{})}},this._instance=e,this.Ot=!1,this.vi="/s/",this.ci=void 0,this.Jt=!1,!this._instance.sessionManager)throw X_.error("started without valid sessionManager"),new Error(b3+" started without valid sessionManager. This is a bug.");if(this._instance.config.__preview_experimental_cookieless_mode)throw new Error(b3+" cannot be used with __preview_experimental_cookieless_mode.");this.Xt=new KJe(this._instance),this.Kt=new VJe(this._instance),this.Yt=new jJe(this._instance);var{sessionId:t,windowId:n}=this.At.checkAndGetSessionAndWindowId();this.Ct=t,this.fi=n,this.C=this.pi(),this.Ft>=this.At.sessionTimeoutMs&&X_.warn("session_idle_threshold_ms ("+this.Ft+") is greater than the session timeout ("+this.At.sessionTimeoutMs+"). Session will never be detected as idle")}startIfEnabledOrStop(e){this.zt?(this.gi(e),oC(xo,"beforeunload",this.oi),oC(xo,"offline",this.li),oC(xo,"online",this.hi),oC(xo,"visibilitychange",this.di),this.mi(),this.bi(),Um(this.ii)&&(this.ii=this._instance.on("eventCaptured",t=>{try{if(t.event==="$pageview"){var n=t!=null&&t.properties.$current_url?this.yi(t==null?void 0:t.properties.$current_url):"";if(!n)return;this.ui("$pageview",{href:n})}}catch(i){X_.error("Could not add $pageview to rrweb session",i)}})),this.ei||(this.ei=this.At.onSessionId((t,n,i)=>{var o,a;i&&(this.ui("$session_id_change",{sessionId:t,windowId:n,changeReason:i}),(o=this._instance)==null||(o=o.persistence)==null||o.unregister(Mz),(a=this._instance)==null||(a=a.persistence)==null||a.unregister(Qz))}))):this.stopRecording()}stopRecording(){var e,t,n,i;this.Ot&&this.ci&&(this.ci(),this.ci=void 0,this.Ot=!1,xo==null||xo.removeEventListener("beforeunload",this.oi),xo==null||xo.removeEventListener("offline",this.li),xo==null||xo.removeEventListener("online",this.hi),xo==null||xo.removeEventListener("visibilitychange",this.di),this.pi(),clearInterval(this.wi),(e=this.ii)==null||e.call(this),this.ii=void 0,(t=this.ni)==null||t.call(this),this.ni=void 0,(n=this.ei)==null||n.call(this),this.ei=void 0,(i=this.si)==null||i.call(this),this.si=void 0,this.Yt.stop(),this.Kt.stop(),this.Xt.stop(),X_.info("stopped"))}Si(){var e;(e=this._instance.persistence)==null||e.unregister(I3)}$i(e){var t,n=this.Ct!==e,i=this.Wt;if(q_(i)){var o=this.jt,a=n||!Zb(o),s=a?HJe(e,i):o;a&&(s?this.ki(oH):X_.warn("Sample rate ("+i+") has determined that this sessionId ("+e+") will not be sent to the server."),this.ui("samplingDecisionMade",{sampleRate:i,isSampled:s})),(t=this._instance.persistence)==null||t.register({[I3]:s})}else this.Si()}onRemoteConfig(e){var t,n,i,o;this.ui("$remote_config_received",e),this.xi(e),(t=e.sessionRecording)!=null&&t.endpoint&&(this.vi=(o=e.sessionRecording)==null?void 0:o.endpoint),this.mi(),((n=e.sessionRecording)==null?void 0:n.triggerMatchType)==="any"?(this.Vt=WJe,this.Lt=new dhe([this.Yt,this.Kt])):(this.Vt=qJe,this.Lt=new fhe([this.Yt,this.Kt])),this._instance.register_for_session({$sdk_debug_replay_remote_trigger_matching_config:(i=e.sessionRecording)==null?void 0:i.triggerMatchType}),this.Kt.onRemoteConfig(e),this.Yt.onRemoteConfig(e),this.Xt.onRemoteConfig(e,(a,s)=>{this.ki("linked_flag_matched",{flag:a,variant:s})}),this.Jt=!0,this.startIfEnabledOrStop()}mi(){q_(this.Wt)&&Um(this.si)&&(this.si=this.At.onSessionId(e=>{this.$i(e)}))}xi(e){if(this._instance.persistence){var t,n=this._instance.persistence,i=()=>{var o,a,s,l,c,u,A,d,f,m=(o=e.sessionRecording)==null?void 0:o.sampleRate,C=Um(m)?null:parseFloat(m);Um(C)&&this.Si();var E=(a=e.sessionRecording)==null?void 0:a.minimumDurationMilliseconds;n.register({[wz]:!!e.sessionRecording,[pfe]:(s=e.sessionRecording)==null?void 0:s.consoleLogRecordingEnabled,[gfe]:Wc({capturePerformance:e.capturePerformance},(l=e.sessionRecording)==null?void 0:l.networkPayloadCapture),[mfe]:(c=e.sessionRecording)==null?void 0:c.masking,[yfe]:{enabled:(u=e.sessionRecording)==null?void 0:u.recordCanvas,fps:(A=e.sessionRecording)==null?void 0:A.canvasFps,quality:(d=e.sessionRecording)==null?void 0:d.canvasQuality},[vfe]:C,[Ife]:dc(E)?null:E,[Cfe]:(f=e.sessionRecording)==null?void 0:f.scriptConfig})};i(),(t=this.ri)==null||t.call(this),this.ri=this.At.onSessionId(i)}}log(e,t){var n;t===void 0&&(t="log"),(n=this._instance.sessionRecording)==null||n.onRRwebEmit({type:6,data:{plugin:"rrweb/console@1",payload:{level:t,trace:[],payload:[JSON.stringify(e)]}},timestamp:Date.now()})}gi(e){if(!dc(Object.assign)&&!dc(Array.from)&&!(this.Ot||this._instance.config.disable_session_recording||this._instance.consent.isOptedOut())){var t;this.Ot=!0,this.At.checkAndGetSessionAndWindowId(),NP()?this.Ei():(t=wh.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,this.Ii,n=>{if(n)return X_.error("could not load recorder",n);this.Ei()}),X_.info("starting"),this.status===RP&&this.ki(e||"recording_initialized")}}get Ii(){var e;return((e=this._instance)==null||(e=e.persistence)==null||(e=e.get_property(Cfe))==null?void 0:e.script)||"recorder"}Pi(e){var t;return e.type===3&&XJe.indexOf((t=e.data)==null?void 0:t.source)!==-1}Ri(e){var t=this.Pi(e);t||this.Zt||e.timestamp-this.ti>this.Ft&&(this.Zt=!0,clearInterval(this.wi),this.ui("sessionIdle",{eventTimestamp:e.timestamp,lastActivityTimestamp:this.ti,threshold:this.Ft,bufferLength:this.C.data.length,bufferSize:this.C.size}),this.ai());var n=!1;if(t&&(this.ti=e.timestamp,this.Zt)){var i=this.Zt==="unknown";this.Zt=!1,i||(this.ui("sessionNoLongerIdle",{reason:"user activity",type:e.type}),n=!0)}if(!this.Zt){var{windowId:o,sessionId:a}=this.At.checkAndGetSessionAndWindowId(!t,e.timestamp),s=this.Ct!==a,l=this.fi!==o;this.fi=o,this.Ct=a,s||l?(this.stopRecording(),this.startIfEnabledOrStop("session_id_changed")):n&&this.Ti()}}Mi(e){try{return e.rrwebMethod(),!0}catch(t){return this.Qt.length<10?this.Qt.push({enqueuedAt:e.enqueuedAt||Date.now(),attempt:e.attempt++,rrwebMethod:e.rrwebMethod}):X_.warn("could not emit queued rrweb event.",t,e),!1}}ui(e,t){return this.Mi(hhe(()=>NP().addCustomEvent(e,t)))}Ci(){return this.Mi(hhe(()=>NP().takeFullSnapshot()))}Ei(){var e,t,n,i,o={blockClass:"ph-no-capture",blockSelector:void 0,ignoreClass:"ph-ignore-input",maskTextClass:"ph-mask",maskTextSelector:void 0,maskTextFn:void 0,maskAllInputs:!0,maskInputOptions:{password:!0},maskInputFn:void 0,slimDOMOptions:{},collectFonts:!1,inlineStylesheet:!0,recordCrossOriginIframes:!1},a=this._instance.config.session_recording;for(var[s,l]of Object.entries(a||{}))s in o&&(s==="maskInputOptions"?o.maskInputOptions=Wc({password:!0},l):o[s]=l);this.qt&&this.qt.enabled&&(o.recordCanvas=!0,o.sampling={canvas:this.qt.fps},o.dataURLOptions={type:"image/webp",quality:this.qt.quality}),this.Ht&&(o.maskAllInputs=(t=this.Ht.maskAllInputs)===null||t===void 0||t,o.maskTextSelector=(n=this.Ht.maskTextSelector)!==null&&n!==void 0?n:void 0,o.blockSelector=(i=this.Ht.blockSelector)!==null&&i!==void 0?i:void 0);var c=NP();if(c){this.Fi=(e=this.Fi)!==null&&e!==void 0?e:new NJe(c,{refillRate:this._instance.config.session_recording.__mutationThrottlerRefillRate,bucketSize:this._instance.config.session_recording.__mutationThrottlerBucketSize,onBlockedNode:(A,d)=>{var f="Too many mutations on node '"+A+"'. Rate limiting. This could be due to SVG animations or something similar";X_.info(f,{node:d}),this.log(b3+" "+f,"warn")}});var u=this.Oi();this.ci=c(Wc({emit:A=>{this.onRRwebEmit(A)},plugins:u},o)),this.ti=Date.now(),this.Zt=Zb(this.Zt)?this.Zt:"unknown",this.ui("$session_options",{sessionRecordingOptions:o,activePlugins:u.map(A=>A==null?void 0:A.name)}),this.ui("$posthog_config",{config:this._instance.config})}else X_.error("onScriptLoaded was called but rrwebRecord is not available. This indicates something has gone wrong.")}Ti(){if(this.wi&&clearInterval(this.wi),this.Zt!==!0){var e=this.Dt;e&&(this.wi=setInterval(()=>{this.Ci()},e))}}Oi(){var e,t,n=[],i=(e=wh.__PosthogExtensions__)==null||(e=e.rrwebPlugins)==null?void 0:e.getRecordConsolePlugin;i&&this.Ut&&n.push(i());var o=(t=wh.__PosthogExtensions__)==null||(t=t.rrwebPlugins)==null?void 0:t.getRecordNetworkPlugin;return this.Bt&&jB(o)&&(!Xje.includes(location.hostname)||this._forceAllowLocalhostNetworkCapture?n.push(o(RJe(this._instance.config,this.Bt))):X_.info("NetworkCapture not started because we are on localhost.")),n}onRRwebEmit(e){var t;if(this.Ai(),e&&TC(e)){if(e.type===ew.Meta){var n=this.yi(e.data.href);if(this.Di=n,!n)return;e.data.href=n}else this.Li();if(this.Kt.checkUrlTriggerConditions(()=>this.ji(),()=>this.Ni(),d=>this.zi(d)),!this.Kt.urlBlocked||(i=e).type===ew.Custom&&i.data.tag==="recording paused"){var i;e.type===ew.FullSnapshot&&this.Ti(),e.type===ew.FullSnapshot&&this.Jt&&this.Lt.triggerStatus(this.sessionId)===Z_&&this.pi();var o=this.Fi?this.Fi.throttleMutations(e):e;if(o){var a=function(d){var f=d;if(f&&TC(f)&&f.type===6&&TC(f.data)&&f.data.plugin==="rrweb/console@1"){f.data.payload.payload.length>10&&(f.data.payload.payload=f.data.payload.payload.slice(0,10),f.data.payload.payload.push("...[truncated]"));for(var m=[],C=0;C<f.data.payload.payload.length;C++)f.data.payload.payload[C]&&f.data.payload.payload[C].length>2e3?m.push(f.data.payload.payload[C].slice(0,2e3)+"...[truncated]"):m.push(f.data.payload.payload[C]);return f.data.payload.payload=m,d}return d}(o);if(this.Ri(a),this.Zt!==!0||phe(a)){if(phe(a)){var s=a.data.payload;if(s){var l=s.lastActivityTimestamp,c=s.threshold;a.timestamp=l+c}}var u=(t=this._instance.config.session_recording.compress_events)===null||t===void 0||t?function(d){if(QP(d)<1024)return d;try{if(d.type===ew.FullSnapshot)return Wc({},d,{data:v2(d.data),cv:"2024-10"});if(d.type===ew.IncrementalSnapshot&&d.data.source===Cb.Mutation)return Wc({},d,{cv:"2024-10",data:Wc({},d.data,{texts:v2(d.data.texts),attributes:v2(d.data.attributes),removes:v2(d.data.removes),adds:v2(d.data.adds)})});if(d.type===ew.IncrementalSnapshot&&d.data.source===Cb.StyleSheetRule)return Wc({},d,{cv:"2024-10",data:Wc({},d.data,{adds:d.data.adds?v2(d.data.adds):void 0,removes:d.data.removes?v2(d.data.removes):void 0})})}catch(f){X_.error("could not compress event - will use uncompressed event",f)}return d}(a):a,A={$snapshot_bytes:QP(u),$snapshot_data:u,$session_id:this.Ct,$window_id:this.fi};this.status!==sQ?this.Ui(A):this.pi()}}}}}Li(){if(!this._instance.config.capture_pageview&&xo){var e=this.yi(xo.location.href);this.Di!==e&&(this.ui("$url_changed",{href:e}),this.Di=e)}}Ai(){if(this.Qt.length){var e=[...this.Qt];this.Qt=[],e.forEach(t=>{Date.now()-t.enqueuedAt<=2e3&&this.Mi(t)})}}yi(e){var t=this._instance.config.session_recording;if(t.maskNetworkRequestFn){var n,i={url:e};return(n=i=t.maskNetworkRequestFn(i))==null?void 0:n.url}return e}pi(){return this.C={size:0,data:[],sessionId:this.Ct,windowId:this.fi},this.C}ai(){this.qi&&(clearTimeout(this.qi),this.qi=void 0);var e=this.Gt,t=this.Nt,n=q_(t)&&t>=0,i=q_(e)&&n&&t<e;return this.status===y2||this.status===aH||this.status===sQ||i?(this.qi=setTimeout(()=>{this.ai()},2e3),this.C):(this.C.data.length>0&&Wz(this.C).forEach(o=>{this.Bi({$snapshot_bytes:o.size,$snapshot_data:o.data,$session_id:o.sessionId,$window_id:o.windowId,$lib:"web",$lib_version:ZS.LIB_VERSION})}),this.pi())}Ui(e){var t,n=2+(((t=this.C)==null?void 0:t.data.length)||0);!this.Zt&&(this.C.size+e.$snapshot_bytes+n>943718.4||this.C.sessionId!==this.Ct)&&(this.C=this.ai()),this.C.size+=e.$snapshot_bytes,this.C.data.push(e.$snapshot_data),this.qi||this.Zt||(this.qi=setTimeout(()=>{this.ai()},2e3))}Bi(e){this._instance.capture("$snapshot",e,{_url:this._instance.requestRouter.endpointFor("api",this.vi),_noTruncate:!0,_batchKey:"recordings",skip_client_rate_limiting:!0})}zi(e){var t;this.Lt.triggerStatus(this.sessionId)===Z_&&((t=this._instance)==null||(t=t.persistence)==null||t.register({[e==="url"?Qz:Mz]:this.Ct}),this.ai(),this.ki(e+"_trigger_matched"))}ji(){this.Kt.urlBlocked||(this.Kt.urlBlocked=!0,clearInterval(this.wi),X_.info("recording paused due to URL blocker"),this.ui("recording paused",{reason:"url blocker"}))}Ni(){this.Kt.urlBlocked&&(this.Kt.urlBlocked=!1,this.Ci(),this.Ti(),this.ui("recording resumed",{reason:"left blocked url"}),X_.info("recording resumed"))}bi(){this.Yt.Tt.length!==0&&Um(this.ni)&&(this.ni=this._instance.on("eventCaptured",e=>{try{this.Yt.Tt.includes(e.event)&&this.zi("event")}catch(t){X_.error("Could not activate event trigger",t)}}))}overrideLinkedFlag(){this.Xt.linkedFlagSeen=!0,this.Ci(),this.ki("linked_flag_overridden")}overrideSampling(){var e;(e=this._instance.persistence)==null||e.register({[I3]:!0}),this.Ci(),this.ki("sampling_overridden")}overrideTrigger(e){this.zi(e)}ki(e,t){this._instance.register_for_session({$session_recording_start_reason:e}),X_.info(e.replace("_"," "),t),Wg(["recording_initialized","session_id_changed"],e)||this.ui(e,t)}get sdkDebugProperties(){var{sessionStartTimestamp:e}=this.At.checkAndGetSessionAndWindowId(!0);return{$recording_status:this.status,$sdk_debug_replay_internal_buffer_length:this.C.data.length,$sdk_debug_replay_internal_buffer_size:this.C.size,$sdk_debug_current_session_duration:this.Nt,$sdk_debug_session_start:e}}}var lH=XE("[SegmentIntegration]");function eWe(r,e){var t=r.config.segment;if(!t)return e();(function(n,i){var o=n.config.segment;if(!o)return i();var a=l=>{var c=()=>l.anonymousId()||aQ();n.config.get_device_id=c,l.id()&&(n.register({distinct_id:l.id(),$device_id:c()}),n.persistence.set_property($S,"identified")),i()},s=o.user();"then"in s&&jB(s.then)?s.then(l=>a(l)):a(s)})(r,()=>{t.register((n=>{Promise&&Promise.resolve||lH.warn("This browser does not have Promise support, and can not use the segment integration");var i=(o,a)=>{if(!a)return o;o.event.userId||o.event.anonymousId===n.get_distinct_id()||(lH.info("No userId set, resetting PostHog"),n.reset()),o.event.userId&&o.event.userId!==n.get_distinct_id()&&(lH.info("UserId set, identifying with PostHog"),n.identify(o.event.userId));var s=n.calculateEventProperties(a,o.event.properties);return o.event.properties=Object.assign({},s,o.event.properties),o};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:o=>i(o,o.event.event),page:o=>i(o,"$pageview"),identify:o=>i(o,"$identify"),screen:o=>i(o,"$screen")}})(r)).then(()=>{e()})})}var ghe="posthog-js";function mhe(r,e){var{organization:t,projectId:n,prefix:i,severityAllowList:o=["error"]}=e===void 0?{}:e;return a=>{var s,l,c,u,A;if(!(o==="*"||o.includes(a.level))||!r.__loaded)return a;a.tags||(a.tags={});var d=r.requestRouter.endpointFor("ui","/project/"+r.config.token+"/person/"+r.get_distinct_id());a.tags["PostHog Person URL"]=d,r.sessionRecordingStarted()&&(a.tags["PostHog Recording URL"]=r.get_session_replay_url({withTimestamp:!0}));var f=((s=a.exception)==null?void 0:s.values)||[],m=f.map(E=>Wc({},E,{stacktrace:E.stacktrace?Wc({},E.stacktrace,{type:"raw",frames:(E.stacktrace.frames||[]).map(_=>Wc({},_,{platform:"web:javascript"}))}):void 0})),C={$exception_message:((l=f[0])==null?void 0:l.value)||a.message,$exception_type:(c=f[0])==null?void 0:c.type,$exception_personURL:d,$exception_level:a.level,$exception_list:m,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:((u=f[0])==null?void 0:u.value)||a.message,$sentry_exception_type:(A=f[0])==null?void 0:A.type,$sentry_tags:a.tags};return t&&n&&(C.$sentry_url=(i||"https://sentry.io/organizations/")+t+"/issues/?project="+n+"&query="+a.event_id),r.exceptions.sendExceptionEvent(C),a}}class tWe{constructor(e,t,n,i,o){this.name=ghe,this.setupOnce=function(a){a(mhe(e,{organization:t,projectId:n,prefix:i,severityAllowList:o}))}}}var nWe=xo!=null&&xo.location?CP(xo.location.hash,"__posthog")||CP(location.hash,"state"):null,yhe="_postHogToolbarParams",vhe=XE("[Toolbar]"),lQ=function(r){return r[r.UNINITIALIZED=0]="UNINITIALIZED",r[r.LOADING=1]="LOADING",r[r.LOADED=2]="LOADED",r}(lQ||{});class rWe{constructor(e){this.instance=e}Hi(e){wh.ph_toolbar_state=e}Wi(){var e;return(e=wh.ph_toolbar_state)!==null&&e!==void 0?e:lQ.UNINITIALIZED}maybeLoadToolbar(e,t,n){if(e===void 0&&(e=void 0),t===void 0&&(t=void 0),n===void 0&&(n=void 0),!xo||!Au)return!1;e=e??xo.location,n=n??xo.history;try{if(!t){try{xo.localStorage.setItem("test","test"),xo.localStorage.removeItem("test")}catch{return!1}t=xo==null?void 0:xo.localStorage}var i,o=nWe||CP(e.hash,"__posthog")||CP(e.hash,"state"),a=o?sfe(()=>JSON.parse(atob(decodeURIComponent(o))))||sfe(()=>JSON.parse(decodeURIComponent(o))):null;return a&&a.action==="ph_authorize"?((i=a).source="url",i&&Object.keys(i).length>0&&(a.desiredHash?e.hash=a.desiredHash:n?n.replaceState(n.state,"",e.pathname+e.search):e.hash="")):((i=JSON.parse(t.getItem(yhe)||"{}")).source="localstorage",delete i.userIntent),!(!i.token||this.instance.config.token!==i.token)&&(this.loadToolbar(i),!0)}catch{return!1}}Gi(e){var t=wh.ph_load_toolbar||wh.ph_load_editor;!Um(t)&&jB(t)?t(e,this.instance):vhe.warn("No toolbar load function found")}loadToolbar(e){var t=!(Au==null||!Au.getElementById(Efe));if(!xo||t)return!1;var n=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,i=Wc({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},n?{instrument:!1}:{});if(xo.localStorage.setItem(yhe,JSON.stringify(Wc({},i,{source:void 0}))),this.Wi()===lQ.LOADED)this.Gi(i);else if(this.Wi()===lQ.UNINITIALIZED){var o;this.Hi(lQ.LOADING),(o=wh.__PosthogExtensions__)==null||o.loadExternalDependency==null||o.loadExternalDependency(this.instance,"toolbar",a=>{if(a)return vhe.error("[Toolbar] Failed to load",a),void this.Hi(lQ.UNINITIALIZED);this.Hi(lQ.LOADED),this.Gi(i)}),oC(xo,"turbolinks:load",()=>{this.Hi(lQ.UNINITIALIZED),this.loadToolbar(i)})}return!0}Ji(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,n){return e===void 0&&(e=void 0),t===void 0&&(t=void 0),n===void 0&&(n=void 0),this.maybeLoadToolbar(e,t,n)}}var iWe=XE("[TracingHeaders]");class oWe{constructor(e){this.Vi=void 0,this.Ki=void 0,this.nt=()=>{var t,n;dc(this.Vi)&&((t=wh.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null||t._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),dc(this.Ki)&&((n=wh.__PosthogExtensions__)==null||(n=n.tracingHeadersPatchFns)==null||n._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=e}J(e){var t,n;(t=wh.__PosthogExtensions__)!=null&&t.tracingHeadersPatchFns&&e(),(n=wh.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"tracing-headers",i=>{if(i)return iWe.error("failed to load script",i);e()})}startIfEnabledOrStop(){var e,t;this._instance.config.__add_tracing_headers?this.J(this.nt):((e=this.Vi)==null||e.call(this),(t=this.Ki)==null||t.call(this),this.Vi=void 0,this.Ki=void 0)}}var cQ=XE("[Web Vitals]"),Ihe=9e5;class aWe{constructor(e){var t;this.Yi=!1,this.i=!1,this.C={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Xi=()=>{clearTimeout(this.Qi),this.C.metrics.length!==0&&(this._instance.capture("$web_vitals",this.C.metrics.reduce((n,i)=>Wc({},n,{["$web_vitals_"+i.name+"_event"]:Wc({},i),["$web_vitals_"+i.name+"_value"]:i.value}),{})),this.C={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Zi=n=>{var i,o=(i=this._instance.sessionManager)==null?void 0:i.checkAndGetSessionAndWindowId(!0);if(dc(o))cQ.error("Could not read session ID. Dropping metrics!");else{this.C=this.C||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var a=this.te();dc(a)||(Um(n==null?void 0:n.name)||Um(n==null?void 0:n.value)?cQ.error("Invalid metric received",n):this.ie&&n.value>=this.ie?cQ.error("Ignoring metric with value >= "+this.ie,n):(this.C.url!==a&&(this.Xi(),this.Qi=setTimeout(this.Xi,this.flushToCaptureTimeoutMs)),dc(this.C.url)&&(this.C.url=a),this.C.firstMetricTimestamp=dc(this.C.firstMetricTimestamp)?Date.now():this.C.firstMetricTimestamp,n.attribution&&n.attribution.interactionTargetElement&&(n.attribution.interactionTargetElement=void 0),this.C.metrics.push(Wc({},n,{$current_url:a,$session_id:o.sessionId,$window_id:o.windowId,timestamp:Date.now()})),this.C.metrics.length===this.allowedMetrics.length&&this.Xi()))}},this.nt=()=>{var n,i,o,a,s=wh.__PosthogExtensions__;dc(s)||dc(s.postHogWebVitalsCallbacks)||({onLCP:n,onCLS:i,onFCP:o,onINP:a}=s.postHogWebVitalsCallbacks),n&&i&&o&&a?(this.allowedMetrics.indexOf("LCP")>-1&&n(this.Zi.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&i(this.Zi.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&o(this.Zi.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&a(this.Zi.bind(this)),this.i=!0):cQ.error("web vitals callbacks not loaded - not starting")},this._instance=e,this.Yi=!((t=this._instance.persistence)==null||!t.props[dfe]),this.startIfEnabled()}get allowedMetrics(){var e,t,n=TC(this._instance.config.capture_performance)?(e=this._instance.config.capture_performance)==null?void 0:e.web_vitals_allowed_metrics:void 0;return dc(n)?((t=this._instance.persistence)==null?void 0:t.props[hfe])||["CLS","FCP","INP","LCP"]:n}get flushToCaptureTimeoutMs(){return(TC(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get ie(){var e=TC(this._instance.config.capture_performance)&&q_(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:Ihe;return 0<e&&e<=6e4?Ihe:e}get isEnabled(){var e=Wx==null?void 0:Wx.protocol;if(e!=="http:"&&e!=="https:")return cQ.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=TC(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals:Zb(this._instance.config.capture_performance)?this._instance.config.capture_performance:void 0;return Zb(t)?t:this.Yi}startIfEnabled(){this.isEnabled&&!this.i&&(cQ.info("enabled, starting..."),this.J(this.nt))}onRemoteConfig(e){var t=TC(e.capturePerformance)&&!!e.capturePerformance.web_vitals,n=TC(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[dfe]:t}),this._instance.persistence.register({[hfe]:n})),this.Yi=t,this.startIfEnabled()}J(e){var t,n;(t=wh.__PosthogExtensions__)!=null&&t.postHogWebVitalsCallbacks&&e(),(n=wh.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"web-vitals",i=>{i?cQ.error("failed to load script",i):e()})}te(){var e=xo?xo.location.href:void 0;return e||cQ.error("Could not determine current URL"),e}}var sWe=XE("[Heatmaps]");function Che(r){return TC(r)&&"clientX"in r&&"clientY"in r&&q_(r.clientX)&&q_(r.clientY)}class lWe{constructor(e){var t;this.rageclicks=new kfe,this.Yi=!1,this.i=!1,this.ee=null,this.instance=e,this.Yi=!((t=this.instance.persistence)==null||!t.props[bz])}get flushIntervalMilliseconds(){var e=5e3;return TC(this.instance.config.capture_heatmaps)&&this.instance.config.capture_heatmaps.flush_interval_milliseconds&&(e=this.instance.config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return dc(this.instance.config.capture_heatmaps)?dc(this.instance.config.enable_heatmaps)?this.Yi:this.instance.config.enable_heatmaps:this.instance.config.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.i)return;sWe.info("starting..."),this.re(),this.ee=setInterval(this.se.bind(this),this.flushIntervalMilliseconds)}else{var e,t;clearInterval((e=this.ee)!==null&&e!==void 0?e:void 0),(t=this.ne)==null||t.stop(),this.getAndClearBuffer()}}onRemoteConfig(e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[bz]:t}),this.Yi=t,this.startIfEnabled()}getAndClearBuffer(){var e=this.C;return this.C=void 0,e}oe(e){this.ae(e.originalEvent,"deadclick")}re(){xo&&Au&&(oC(xo,"beforeunload",this.se.bind(this)),oC(Au,"click",e=>this.ae(e||(xo==null?void 0:xo.event)),{capture:!0}),oC(Au,"mousemove",e=>this.le(e||(xo==null?void 0:xo.event)),{capture:!0}),this.ne=new Ofe(this.instance,dJe,this.oe.bind(this)),this.ne.startIfEnabled(),this.i=!0)}ue(e,t){var n=this.instance.scrollManager.scrollY(),i=this.instance.scrollManager.scrollX(),o=this.instance.scrollManager.scrollElement(),a=function(s,l,c){for(var u=s;u&&mP(u)&&!oQ(u,"body");){if(u===c)return!1;if(Wg(l,xo==null?void 0:xo.getComputedStyle(u).position))return!0;u=Qfe(u)}return!1}(wfe(e),["fixed","sticky"],o);return{x:e.clientX+(a?0:i),y:e.clientY+(a?0:n),target_fixed:a,type:t}}ae(e,t){var n;if(t===void 0&&(t="click"),!_fe(e.target)&&Che(e)){var i=this.ue(e,t);(n=this.rageclicks)!=null&&n.isRageClick(e.clientX,e.clientY,new Date().getTime())&&this.he(Wc({},i,{type:"rageclick"})),this.he(i)}}le(e){!_fe(e.target)&&Che(e)&&(clearTimeout(this.de),this.de=setTimeout(()=>{this.he(this.ue(e,"mousemove"))},500))}he(e){if(xo){var t=xo.location.href;this.C=this.C||{},this.C[t]||(this.C[t]=[]),this.C[t].push(e)}}se(){this.C&&!IM(this.C)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class cWe{constructor(e){this._instance=e}doPageView(e,t){var n,i=this.ve(e,t);return this.ce={pathname:(n=xo==null?void 0:xo.location.pathname)!==null&&n!==void 0?n:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),i}doPageLeave(e){var t;return this.ve(e,(t=this.ce)==null?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.ce)==null?void 0:e.pageViewId}}ve(e,t){var n=this.ce;if(!n)return{$pageview_id:t};var i={$pageview_id:t,$prev_pageview_id:n.pageViewId},o=this._instance.scrollManager.getContext();if(o&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:a,lastScrollY:s,maxScrollY:l,maxContentHeight:c,lastContentY:u,maxContentY:A}=o;if(!(dc(a)||dc(s)||dc(l)||dc(c)||dc(u)||dc(A))){a=Math.ceil(a),s=Math.ceil(s),l=Math.ceil(l),c=Math.ceil(c),u=Math.ceil(u),A=Math.ceil(A);var d=a<=1?1:xB(s/a,0,1),f=a<=1?1:xB(l/a,0,1),m=c<=1?1:xB(u/c,0,1),C=c<=1?1:xB(A/c,0,1);i=u1(i,{$prev_pageview_last_scroll:s,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:l,$prev_pageview_max_scroll_percentage:f,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:m,$prev_pageview_max_content:A,$prev_pageview_max_content_percentage:C})}}return n.pathname&&(i.$prev_pageview_pathname=n.pathname),n.timestamp&&(i.$prev_pageview_duration=(e.getTime()-n.timestamp.getTime())/1e3),i}}var uWe=function(r){var e,t,n,i,o="";for(e=t=0,n=(r=(r+"").replace(/\r\n/g,`
|
|
243
243
|
`).replace(/\r/g,`
|
|
244
|
-
`)).length,i=0;i<n;i++){var a=r.charCodeAt(i),s=null;a<128?t++:s=a>127&&a<2048?String.fromCharCode(a>>6|192,63&a|128):String.fromCharCode(a>>12|224,a>>6&63|128,63&a|128),rQ(s)||(t>e&&(o+=r.substring(e,t)),o+=s,e=t=i+1)}return t>e&&(o+=r.substring(e,r.length)),o},AWe=!!Cz||!!Iz,Ehe="text/plain",TP=(r,e)=>{var[t,n]=r.split("?"),i=Wc({},e);n==null||n.split("&").forEach(a=>{var[s]=a.split("=");delete i[s]});var o=$je(i);return t+"?"+(o=o?(n?n+"&":"")+o:n)},S3=(r,e)=>JSON.stringify(r,(t,n)=>typeof n=="bigint"?n.toString():n,e),cH=r=>{var{data:e,compression:t}=r;if(e){if(t===XS.GZipJS){var n=che(uhe(S3(e)),{mtime:0}),i=new Blob([n],{type:Ehe});return{contentType:Ehe,body:i,estimatedSize:i.size}}if(t===XS.Base64){var o=function(l){var c,u,A,d,f,m="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",C=0,E=0,_="",x=[];if(!l)return l;l=uWe(l);do c=(f=l.charCodeAt(C++)<<16|l.charCodeAt(C++)<<8|l.charCodeAt(C++))>>18&63,u=f>>12&63,A=f>>6&63,d=63&f,x[E++]=m.charAt(c)+m.charAt(u)+m.charAt(A)+m.charAt(d);while(C<l.length);switch(_=x.join(""),l.length%3){case 1:_=_.slice(0,-2)+"==";break;case 2:_=_.slice(0,-1)+"="}return _}(S3(e)),a=(l=>"data="+encodeURIComponent(typeof l=="string"?l:S3(l)))(o);return{contentType:"application/x-www-form-urlencoded",body:a,estimatedSize:new Blob([a]).size}}var s=S3(e);return{contentType:"application/json",body:s,estimatedSize:new Blob([s]).size}}},w3=[];Iz&&w3.push({transport:"fetch",method:r=>{var e,t,{contentType:n,body:i,estimatedSize:o}=(e=cH(r))!==null&&e!==void 0?e:{},a=new Headers;av(r.headers,function(u,A){a.append(A,u)}),n&&a.append("Content-Type",n);var s=r.url,l=null;if(tfe){var c=new tfe;l={signal:c.signal,timeout:setTimeout(()=>c.abort(),r.timeout)}}Iz(s,Wc({method:(r==null?void 0:r.method)||"GET",headers:a,keepalive:r.method==="POST"&&(o||0)<52428.8,body:i,signal:(t=l)==null?void 0:t.signal},r.fetchOptions)).then(u=>u.text().then(A=>{var d={statusCode:u.status,text:A};if(u.status===200)try{d.json=JSON.parse(A)}catch(f){bu.error(f)}r.callback==null||r.callback(d)})).catch(u=>{bu.error(u),r.callback==null||r.callback({statusCode:0,text:u})}).finally(()=>l?clearTimeout(l.timeout):null)}}),Cz&&w3.push({transport:"XHR",method:r=>{var e,t=new Cz;t.open(r.method||"GET",r.url,!0);var{contentType:n,body:i}=(e=cH(r))!==null&&e!==void 0?e:{};av(r.headers,function(o,a){t.setRequestHeader(a,o)}),n&&t.setRequestHeader("Content-Type",n),r.timeout&&(t.timeout=r.timeout),t.withCredentials=!0,t.onreadystatechange=()=>{if(t.readyState===4){var o={statusCode:t.status,text:t.responseText};if(t.status===200)try{o.json=JSON.parse(t.responseText)}catch{}r.callback==null||r.callback(o)}},t.send(i)}}),_B!=null&&_B.sendBeacon&&w3.push({transport:"sendBeacon",method:r=>{var e=TP(r.url,{beacon:"1"});try{var t,{contentType:n,body:i}=(t=cH(r))!==null&&t!==void 0?t:{},o=typeof i=="string"?new Blob([i],{type:n}):i;_B.sendBeacon(e,o)}catch{}}});var SM=function(r,e){if(!function(t){try{new RegExp(t)}catch{return!1}return!0}(e))return!1;try{return new RegExp(e).test(r)}catch{return!1}};function _he(r,e,t){return S3({distinct_id:r,userPropertiesToSet:e,userPropertiesToSetOnce:t})}var dWe={exact:(r,e)=>e.some(t=>r.some(n=>t===n)),is_not:(r,e)=>e.every(t=>r.every(n=>t!==n)),regex:(r,e)=>e.some(t=>r.some(n=>SM(t,n))),not_regex:(r,e)=>e.every(t=>r.every(n=>!SM(t,n))),icontains:(r,e)=>e.map(PP).some(t=>r.map(PP).some(n=>t.includes(n))),not_icontains:(r,e)=>e.map(PP).every(t=>r.map(PP).every(n=>!t.includes(n)))},PP=r=>r.toLowerCase(),fWe=XE("[Error tracking]");class hWe{constructor(e){var t,n;this.fe=[],this._instance=e,this.fe=(t=(n=this._instance.persistence)==null?void 0:n.get_property(Sz))!==null&&t!==void 0?t:[]}onRemoteConfig(e){var t,n,i=(t=(n=e.errorTracking)==null?void 0:n.suppressionRules)!==null&&t!==void 0?t:[];this.fe=i,this._instance.persistence&&this._instance.persistence.register({[Sz]:this.fe})}sendExceptionEvent(e){if(!this.pe(e))return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"});fWe.info("Skipping exception capture because a suppression rule matched")}pe(e){var t=e.$exception_list;if(!t||!OI(t)||t.length===0)return!1;var n=t.reduce((i,o)=>{var{type:a,value:s}=o;return PC(a)&&a.length>0&&i.$exception_types.push(a),PC(s)&&s.length>0&&i.$exception_values.push(s),i},{$exception_types:[],$exception_values:[]});return this.fe.some(i=>{var o=i.values.map(a=>{var s,l=dWe[a.operator],c=OI(a.value)?a.value:[a.value],u=(s=n[a.key])!==null&&s!==void 0?s:[];return c.length>0&&l(c,u)});return i.type==="OR"?o.some(Boolean):o.every(Boolean)})}}var WB="Mobile",kP="iOS",tS="Android",Q3="Tablet",xhe=tS+" "+Q3,Bhe="iPad",bhe="Apple",She=bhe+" Watch",M3="Safari",wM="BlackBerry",whe="Samsung",Qhe=whe+"Browser",Mhe=whe+" Internet",I2="Chrome",pWe=I2+" OS",Dhe=I2+" "+kP,uH="Internet Explorer",Rhe=uH+" "+WB,AH="Opera",gWe=AH+" Mini",dH="Edge",Nhe="Microsoft "+dH,QM="Firefox",The=QM+" "+kP,D3="Nintendo",R3="PlayStation",MM="Xbox",Phe=tS+" "+WB,khe=WB+" "+M3,N3="Windows",fH=N3+" Phone",Uhe="Nokia",hH="Ouya",Fhe="Generic",mWe=Fhe+" "+WB.toLowerCase(),Lhe=Fhe+" "+Q3.toLowerCase(),pH="Konqueror",Ex="(\\d+(\\.\\d+)?)",gH=new RegExp("Version/"+Ex),yWe=new RegExp(MM,"i"),vWe=new RegExp(R3+" \\w+","i"),IWe=new RegExp(D3+" \\w+","i"),mH=new RegExp(wM+"|PlayBook|BB10","i"),CWe={"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"},EWe=(r,e)=>e&&Wg(e,bhe)||function(t){return Wg(t,M3)&&!Wg(t,I2)&&!Wg(t,tS)}(r),Ghe=function(r,e){return e=e||"",Wg(r," OPR/")&&Wg(r,"Mini")?gWe:Wg(r," OPR/")?AH:mH.test(r)?wM:Wg(r,"IE"+WB)||Wg(r,"WPDesktop")?Rhe:Wg(r,Qhe)?Mhe:Wg(r,dH)||Wg(r,"Edg/")?Nhe:Wg(r,"FBIOS")?"Facebook "+WB:Wg(r,"UCWEB")||Wg(r,"UCBrowser")?"UC Browser":Wg(r,"CriOS")?Dhe:Wg(r,"CrMo")||Wg(r,I2)?I2:Wg(r,tS)&&Wg(r,M3)?Phe:Wg(r,"FxiOS")?The:Wg(r.toLowerCase(),pH.toLowerCase())?pH:EWe(r,e)?Wg(r,WB)?khe:M3:Wg(r,QM)?QM:Wg(r,"MSIE")||Wg(r,"Trident/")?uH:Wg(r,"Gecko")?QM:""},_We={[Rhe]:[new RegExp("rv:"+Ex)],[Nhe]:[new RegExp(dH+"?\\/"+Ex)],[I2]:[new RegExp("("+I2+"|CrMo)\\/"+Ex)],[Dhe]:[new RegExp("CriOS\\/"+Ex)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Ex)],[M3]:[gH],[khe]:[gH],[AH]:[new RegExp("(Opera|OPR)\\/"+Ex)],[QM]:[new RegExp(QM+"\\/"+Ex)],[The]:[new RegExp("FxiOS\\/"+Ex)],[pH]:[new RegExp("Konqueror[:/]?"+Ex,"i")],[wM]:[new RegExp(wM+" "+Ex),gH],[Phe]:[new RegExp("android\\s"+Ex,"i")],[Mhe]:[new RegExp(Qhe+"\\/"+Ex)],[uH]:[new RegExp("(rv:|MSIE )"+Ex)],Mozilla:[new RegExp("rv:"+Ex)]},xWe=function(r,e){var t=Ghe(r,e),n=_We[t];if(dc(n))return null;for(var i=0;i<n.length;i++){var o=n[i],a=r.match(o);if(a)return parseFloat(a[a.length-2])}return null},Ohe=[[new RegExp(MM+"; "+MM+" (.*?)[);]","i"),r=>[MM,r&&r[1]||""]],[new RegExp(D3,"i"),[D3,""]],[new RegExp(R3,"i"),[R3,""]],[mH,[wM,""]],[new RegExp(N3,"i"),(r,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[fH,""];if(new RegExp(WB).test(e)&&!/IEMobile\b/.test(e))return[N3+" "+WB,""];var t=/Windows NT ([0-9.]+)/i.exec(e);if(t&&t[1]){var n=t[1],i=CWe[n]||"";return/arm/i.test(e)&&(i="RT"),[N3,i]}return[N3,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,r=>{if(r&&r[3]){var e=[r[3],r[4],r[5]||"0"];return[kP,e.join(".")]}return[kP,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,r=>{var e="";return r&&r.length>=3&&(e=dc(r[2])?r[3]:r[2]),["watchOS",e]}],[new RegExp("("+tS+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+tS+")","i"),r=>{if(r&&r[2]){var e=[r[2],r[3],r[4]||"0"];return[tS,e.join(".")]}return[tS,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,r=>{var e=["Mac OS X",""];if(r&&r[1]){var t=[r[1],r[2],r[3]||"0"];e[1]=t.join(".")}return e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[pWe,""]],[/Linux|debian/i,["Linux",""]]],zhe=function(r){return IWe.test(r)?D3:vWe.test(r)?R3:yWe.test(r)?MM:new RegExp(hH,"i").test(r)?hH:new RegExp("("+fH+"|WPDesktop)","i").test(r)?fH:/iPad/.test(r)?Bhe:/iPod/.test(r)?"iPod Touch":/iPhone/.test(r)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(r)?She:mH.test(r)?wM:/(kobo)\s(ereader|touch)/i.test(r)?"Kobo":new RegExp(Uhe,"i").test(r)?Uhe:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(r)||/(kf[a-z]+)( bui|\)).+silk\//i.test(r)?"Kindle Fire":/(Android|ZTE)/i.test(r)?!new RegExp(WB).test(r)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(r)?/pixel[\daxl ]{1,6}/i.test(r)&&!/pixel c/i.test(r)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(r)||/lmy47v/i.test(r)&&!/QTAQZ3/i.test(r)?tS:xhe:tS:new RegExp("(pda|"+WB+")","i").test(r)?mWe:new RegExp(Q3,"i").test(r)&&!new RegExp(Q3+" pc","i").test(r)?Lhe:""},UP="https?://(.*)",FP=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],BWe=lP(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],FP),yH="<masked>",bWe=["li_fat_id"];function Hhe(r,e,t){if(!Au)return{};var n,i=e?lP([],FP,t||[]):[],o=Yhe(Gz(Au.URL,i,yH),r),a=(n={},av(bWe,function(s){var l=Xb.D(s);n[s]=l||null}),n);return u1(a,o)}function Yhe(r,e){var t=BWe.concat(e||[]),n={};return av(t,function(i){var o=IP(r,i);n[i]=o||null}),n}function Vhe(r){var e=function(o){return o?o.search(UP+"google.([^/?]*)")===0?"google":o.search(UP+"bing.com")===0?"bing":o.search(UP+"yahoo.com")===0?"yahoo":o.search(UP+"duckduckgo.com")===0?"duckduckgo":null:null}(r),t=e!="yahoo"?"q":"p",n={};if(!rQ(e)){n.$search_engine=e;var i=Au?IP(Au.referrer,t):"";i.length&&(n.ph_keyword=i)}return n}function Khe(){return navigator.language||navigator.userLanguage}function jhe(){return(Au==null?void 0:Au.referrer)||"$direct"}function Jhe(r,e){var t=r?lP([],FP,e||[]):[],n=Wx==null?void 0:Wx.href.substring(0,1e3);return{r:jhe().substring(0,1e3),u:n?Gz(n,t,yH):void 0}}function Whe(r){var e,{r:t,u:n}=r,i={$referrer:t,$referring_domain:t==null?void 0:t=="$direct"?"$direct":(e=_M(t))==null?void 0:e.host};if(n){i.$current_url=n;var o=_M(n);i.$host=o==null?void 0:o.host,i.$pathname=o==null?void 0:o.pathname;var a=Yhe(n);u1(i,a)}if(t){var s=Vhe(t);u1(i,s)}return i}function qhe(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function SWe(){try{return new Date().getTimezoneOffset()}catch{return}}function wWe(r,e){if(!qx)return{};var t,n,i,o=r?lP([],FP,e||[]):[],[a,s]=function(l){for(var c=0;c<Ohe.length;c++){var[u,A]=Ohe[c],d=u.exec(l),f=d&&(jB(A)?A(d,l):A);if(f)return f}return["",""]}(qx);return u1(Bz({$os:a,$os_version:s,$browser:Ghe(qx,navigator.vendor),$device:zhe(qx),$device_type:(n=qx,i=zhe(n),i===Bhe||i===xhe||i==="Kobo"||i==="Kindle Fire"||i===Lhe?Q3:i===D3||i===MM||i===R3||i===hH?"Console":i===She?"Wearable":i?WB:"Desktop"),$timezone:qhe(),$timezone_offset:SWe()}),{$current_url:Gz(Wx==null?void 0:Wx.href,o,yH),$host:Wx==null?void 0:Wx.host,$pathname:Wx==null?void 0:Wx.pathname,$raw_user_agent:qx.length>1e3?qx.substring(0,997)+"...":qx,$browser_version:xWe(qx,navigator.vendor),$browser_language:Khe(),$browser_language_prefix:(t=Khe(),typeof t=="string"?t.split("-")[0]:void 0),$screen_height:xo==null?void 0:xo.screen.height,$screen_width:xo==null?void 0:xo.screen.width,$viewport_height:xo==null?void 0:xo.innerHeight,$viewport_width:xo==null?void 0:xo.innerWidth,$lib:"web",$lib_version:ZS.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}var nS=XE("[FeatureFlags]"),vH="$active_feature_flags",DM="$override_feature_flags",Zhe="$feature_flag_payloads",T3="$override_feature_flag_payloads",Xhe="$feature_flag_request_id",$he=r=>{var e={};for(var[t,n]of cP(r||{}))n&&(e[t]=n);return e},QWe=r=>{var e=r.flags;return e?(r.featureFlags=Object.fromEntries(Object.keys(e).map(t=>{var n;return[t,(n=e[t].variant)!==null&&n!==void 0?n:e[t].enabled]})),r.featureFlagPayloads=Object.fromEntries(Object.keys(e).filter(t=>e[t].enabled).filter(t=>{var n;return(n=e[t].metadata)==null?void 0:n.payload}).map(t=>{var n;return[t,(n=e[t].metadata)==null?void 0:n.payload]}))):nS.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),r},MWe=function(r){return r.FeatureFlags="feature_flags",r.Recordings="recordings",r}({});class DWe{constructor(e){this.ge=!1,this._e=!1,this.me=!1,this.be=!1,this.ye=!1,this.we=!1,this.Se=!1,this._instance=e,this.featureFlagEventHandlers=[]}flags(){if(this._instance.config.__preview_remote_config)this.we=!0;else{var e=!this.$e&&(this._instance.config.advanced_disable_feature_flags||this._instance.config.advanced_disable_feature_flags_on_first_load);this.ke({disableFlags:e})}}get hasLoadedFlags(){return this._e}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(Dz),t=this._instance.get_property(DM),n=this._instance.get_property(T3);if(!n&&!t)return e||{};var i=u1({},e||{}),o=[...new Set([...Object.keys(n||{}),...Object.keys(t||{})])];for(var a of o){var s,l,c=i[a],u=t==null?void 0:t[a],A=dc(u)?(s=c==null?void 0:c.enabled)!==null&&s!==void 0&&s:!!u,d=dc(u)?c.variant:typeof u=="string"?u:void 0,f=n==null?void 0:n[a],m=Wc({},c,{enabled:A,variant:A?d??(c==null?void 0:c.variant):void 0});A!==(c==null?void 0:c.enabled)&&(m.original_enabled=c==null?void 0:c.enabled),d!==(c==null?void 0:c.variant)&&(m.original_variant=c==null?void 0:c.variant),f&&(m.metadata=Wc({},c==null?void 0:c.metadata,{payload:f,original_payload:c==null||(l=c.metadata)==null?void 0:l.payload})),i[a]=m}return this.ge||(nS.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:n,finalDetails:i}),this.ge=!0),i}getFlagVariants(){var e=this._instance.get_property(CM),t=this._instance.get_property(DM);if(!t)return e||{};for(var n=u1({},e),i=Object.keys(t),o=0;o<i.length;o++)n[i[o]]=t[i[o]];return this.ge||(nS.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:n}),this.ge=!0),n}getFlagPayloads(){var e=this._instance.get_property(Zhe),t=this._instance.get_property(T3);if(!t)return e||{};for(var n=u1({},e||{}),i=Object.keys(t),o=0;o<i.length;o++)n[i[o]]=t[i[o]];return this.ge||(nS.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:n}),this.ge=!0),n}reloadFeatureFlags(){this.be||this._instance.config.advanced_disable_feature_flags||this.$e||(this.$e=setTimeout(()=>{this.ke()},5))}xe(){clearTimeout(this.$e),this.$e=void 0}ensureFlagsLoaded(){this._e||this.me||this.$e||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.be=e}ke(e){var t;if(this.xe(),!this._instance.I())if(this.me)this.ye=!0;else{var n={token:this._instance.config.token,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:Wc({},((t=this._instance.persistence)==null?void 0:t.get_initial_props())||{},this._instance.get_property(C3)||{}),group_properties:this._instance.get_property(h2)};(e!=null&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(n.disable_flags=!0);var i=this._instance.config.__preview_remote_config,o=i?"/flags/?v=2":"/flags/?v=2&config=true",a=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",s=this._instance.requestRouter.endpointFor("api",o+a);i&&(n.timezone=qhe()),this.me=!0,this._instance.Ee({method:"POST",url:s,data:n,compression:this._instance.config.disable_compression?void 0:XS.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:l=>{var c,u,A=!0;if(l.statusCode===200&&(this.ye||(this.$anon_distinct_id=void 0),A=!1),this.me=!1,this.we||(this.we=!0,this._instance.Ie((u=l.json)!==null&&u!==void 0?u:{})),!n.disable_flags||this.ye)if(this.Se=!A,l.json&&(c=l.json.quotaLimited)!=null&&c.includes(MWe.FeatureFlags))nS.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.");else{var d;n.disable_flags||this.receivedFeatureFlags((d=l.json)!==null&&d!==void 0?d:{},A),this.ye&&(this.ye=!1,this.ke())}}})}}getFeatureFlag(e,t){if(t===void 0&&(t={}),this._e||this.getFlags()&&this.getFlags().length>0){var n=this.getFlagVariants()[e],i=""+n,o=this._instance.get_property(Xhe)||void 0,a=this._instance.get_property(fP)||{};if((t.send_event||!("send_event"in t))&&(!(e in a)||!a[e].includes(i))){var s,l,c,u,A,d,f,m,C;OI(a[e])?a[e].push(i):a[e]=[i],(s=this._instance.persistence)==null||s.register({[fP]:a});var E=this.getFeatureFlagDetails(e),_={$feature_flag:e,$feature_flag_response:n,$feature_flag_payload:this.getFeatureFlagPayload(e)||null,$feature_flag_request_id:o,$feature_flag_bootstrapped_response:((l=this._instance.config.bootstrap)==null||(l=l.featureFlags)==null?void 0:l[e])||null,$feature_flag_bootstrapped_payload:((c=this._instance.config.bootstrap)==null||(c=c.featureFlagPayloads)==null?void 0:c[e])||null,$used_bootstrap_value:!this.Se};dc(E==null||(u=E.metadata)==null?void 0:u.version)||(_.$feature_flag_version=E.metadata.version);var x,w=(A=E==null||(d=E.reason)==null?void 0:d.description)!==null&&A!==void 0?A:E==null||(f=E.reason)==null?void 0:f.code;w&&(_.$feature_flag_reason=w),E!=null&&(m=E.metadata)!=null&&m.id&&(_.$feature_flag_id=E.metadata.id),dc(E==null?void 0:E.original_variant)&&dc(E==null?void 0:E.original_enabled)||(_.$feature_flag_original_response=dc(E.original_variant)?E.original_enabled:E.original_variant),E!=null&&(C=E.metadata)!=null&&C.original_payload&&(_.$feature_flag_original_payload=E==null||(x=E.metadata)==null?void 0:x.original_payload),this._instance.capture("$feature_flag_called",_)}return n}nS.warn('getFeatureFlag for key "'+e+`" failed. Feature flags didn't load in time.`)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){return this.getFlagPayloads()[e]}getRemoteConfigPayload(e,t){var n=this._instance.config.token;this._instance.Ee({method:"POST",url:this._instance.requestRouter.endpointFor("api","/flags/?v=2&config=true"),data:{distinct_id:this._instance.get_distinct_id(),token:n},compression:this._instance.config.disable_compression?void 0:XS.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:i=>{var o,a=(o=i.json)==null?void 0:o.featureFlagPayloads;t((a==null?void 0:a[e])||void 0)}})}isFeatureEnabled(e,t){if(t===void 0&&(t={}),this._e||this.getFlags()&&this.getFlags().length>0)return!!this.getFeatureFlag(e,t);nS.warn('isFeatureEnabled for key "'+e+`" failed. Feature flags didn't load in time.`)}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(t=>t!==e)}receivedFeatureFlags(e,t){if(this._instance.persistence){this._e=!0;var n=this.getFlagVariants(),i=this.getFlagPayloads(),o=this.getFlagsWithDetails();(function(a,s,l,c,u){l===void 0&&(l={}),c===void 0&&(c={}),u===void 0&&(u={});var A=QWe(a),d=A.flags,f=A.featureFlags,m=A.featureFlagPayloads;if(f){var C=a.requestId;if(OI(f)){nS.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var E={};if(f)for(var _=0;_<f.length;_++)E[f[_]]=!0;s&&s.register({[vH]:f,[CM]:E})}else{var x=f,w=m,P=d;a.errorsWhileComputingFlags&&(x=Wc({},l,x),w=Wc({},c,w),P=Wc({},u,P)),s&&s.register(Wc({[vH]:Object.keys($he(x)),[CM]:x||{},[Zhe]:w||{},[Dz]:P||{}},C?{[Xhe]:C}:{}))}}})(e,this._instance.persistence,n,i,o),this.Pe(t)}}override(e,t){t===void 0&&(t=!1),nS.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return nS.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(e===!1)return this._instance.persistence.unregister(DM),this._instance.persistence.unregister(T3),void this.Pe();if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var t,n=e;if(this.ge=!!((t=n.suppressWarning)!==null&&t!==void 0&&t),"flags"in n){if(n.flags===!1)this._instance.persistence.unregister(DM);else if(n.flags)if(OI(n.flags)){for(var i={},o=0;o<n.flags.length;o++)i[n.flags[o]]=!0;this._instance.persistence.register({[DM]:i})}else this._instance.persistence.register({[DM]:n.flags})}return"payloads"in n&&(n.payloads===!1?this._instance.persistence.unregister(T3):n.payloads&&this._instance.persistence.register({[T3]:n.payloads})),void this.Pe()}this.Pe()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this._e){var{flags:t,flagVariants:n}=this.Re();e(t,n)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t){var n,i=(this._instance.get_property(AP)||[]).find(l=>l.flagKey===e),o={["$feature_enrollment/"+e]:t},a={$feature_flag:e,$feature_enrollment:t,$set:o};i&&(a.$early_access_feature_name=i.name),this._instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(o,!1);var s=Wc({},this.getFlagVariants(),{[e]:t});(n=this._instance.persistence)==null||n.register({[vH]:Object.keys($he(s)),[CM]:s}),this.Pe()}getEarlyAccessFeatures(e,t,n){t===void 0&&(t=!1);var i=this._instance.get_property(AP),o=n?"&"+n.map(a=>"stage="+a).join("&"):"";if(i&&!t)return e(i);this._instance.Ee({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._instance.config.token+o),method:"GET",callback:a=>{var s;if(a.json){var l=a.json.earlyAccessFeatures;return(s=this._instance.persistence)==null||s.register({[AP]:l}),e(l)}}})}Re(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter(n=>t[n]),flagVariants:Object.keys(t).filter(n=>t[n]).reduce((n,i)=>(n[i]=t[i],n),{})}}Pe(e){var{flags:t,flagVariants:n}=this.Re();this.featureFlagEventHandlers.forEach(i=>i(t,n,{errorsLoading:e}))}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=this._instance.get_property(C3)||{};this._instance.register({[C3]:Wc({},n,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(C3)}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=this._instance.get_property(h2)||{};Object.keys(n).length!==0&&Object.keys(n).forEach(i=>{n[i]=Wc({},n[i],e[i]),delete e[i]}),this._instance.register({[h2]:Wc({},n,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(h2)||{};this._instance.register({[h2]:Wc({},t,{[e]:{}})})}else this._instance.unregister(h2)}reset(){this._e=!1,this.me=!1,this.be=!1,this.ye=!1,this.we=!1,this.Se=!1,this.$anon_distinct_id=void 0,this.xe(),this.ge=!1}}var RWe=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class IH{constructor(e,t){this.S=e,this.props={},this.Te=!1,this.Me=(n=>{var i="";return n.token&&(i=n.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),n.persistence_name?"ph_"+n.persistence_name:"ph_"+i+"_posthog"})(e),this.B=this.Ce(e),this.load(),e.debug&&bu.info("Persistence loaded",e.persistence,Wc({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.Fe}Ce(e){RWe.indexOf(e.persistence.toLowerCase())===-1&&(bu.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=e.persistence.toLowerCase();return t==="localstorage"&&rE.O()?rE:t==="localstorage+cookie"&&_P.O()?_P:t==="sessionstorage"&&v_.O()?v_:t==="memory"?uJe:t==="cookie"?Xb:_P.O()?_P:Xb}properties(){var e={};return av(this.props,function(t,n){if(n===CM&&TC(t))for(var i=Object.keys(t),o=0;o<i.length;o++)e["$feature/"+i[o]]=t[i[o]];else s=n,l=!1,(rQ(a=Yje)?l:efe&&a.indexOf===efe?a.indexOf(s)!=-1:(av(a,function(c){if(l||(l=c===s))return sP}),l))||(e[n]=t);var a,s,l}),e}load(){if(!this.Fe){var e=this.B.L(this.Me);e&&(this.props=u1({},e))}}save(){this.Fe||this.B.j(this.Me,this.props,this.Oe,this.Ae,this.De,this.S.debug)}remove(){this.B.N(this.Me,!1),this.B.N(this.Me,!0)}clear(){this.remove(),this.props={}}register_once(e,t,n){if(TC(e)){dc(t)&&(t="None"),this.Oe=dc(n)?this.Le:n;var i=!1;if(av(e,(o,a)=>{this.props.hasOwnProperty(a)&&this.props[a]!==t||(this.props[a]=o,i=!0)}),i)return this.save(),!0}return!1}register(e,t){if(TC(e)){this.Oe=dc(t)?this.Le:t;var n=!1;if(av(e,(i,o)=>{e.hasOwnProperty(o)&&this.props[o]!==i&&(this.props[o]=i,n=!0)}),n)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.Te){var e=Hhe(this.S.custom_campaign_params,this.S.mask_personal_data_properties,this.S.custom_personal_data_properties);IM(Bz(e))||this.register(e),this.Te=!0}}update_search_keyword(){var e;this.register((e=Au==null?void 0:Au.referrer)?Vhe(e):{})}update_referrer_info(){var e;this.register_once({$referrer:jhe(),$referring_domain:Au!=null&&Au.referrer&&((e=_M(Au.referrer))==null?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[Pz]||this.props[kz]||this.register_once({[hP]:Jhe(this.S.mask_personal_data_properties,this.S.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};av([kz,Pz],a=>{var s=this.props[a];s&&av(s,function(l,c){e["$initial_"+_z(c)]=l})});var t,n,i=this.props[hP];if(i){var o=(t=Whe(i),n={},av(t,function(a,s){n["$initial_"+_z(s)]=a}),n);u1(e,o)}return e}safe_merge(e){return av(this.props,function(t,n){n in e||(e[n]=t)}),e}update_config(e,t,n){if(this.Le=this.Oe=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!n),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence){var i=this.Ce(e),o=this.props;this.clear(),this.B=i,this.props=o,this.save()}}set_disabled(e){this.Fe=e,this.Fe?this.remove():this.save()}set_cross_subdomain(e){e!==this.Ae&&(this.Ae=e,this.remove(),this.save())}set_secure(e){e!==this.De&&(this.De=e,this.remove(),this.save())}set_event_timer(e,t){var n=this.props[v3]||{};n[e]=t,this.props[v3]=n,this.save()}remove_event_timer(e){var t=(this.props[v3]||{})[e];return dc(t)||(delete this.props[v3][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}}class epe{constructor(){this.je={},this.je={}}on(e,t){return this.je[e]||(this.je[e]=[]),this.je[e].push(t),()=>{this.je[e]=this.je[e].filter(n=>n!==t)}}emit(e,t){for(var n of this.je[e]||[])n(t);for(var i of this.je["*"]||[])i(e,t)}}class C2{constructor(e){this.Ne=new epe,this.ze=(t,n)=>this.Ue(t,n)&&this.qe(t,n)&&this.Be(t,n),this.Ue=(t,n)=>n==null||!n.event||(t==null?void 0:t.event)===(n==null?void 0:n.event),this._instance=e,this.He=new Set,this.We=new Set}init(){var e;if(!dc((e=this._instance)==null?void 0:e.Ge)){var t;(t=this._instance)==null||t.Ge((n,i)=>{this.on(n,i)})}}register(e){var t,n;if(!dc((t=this._instance)==null?void 0:t.Ge)&&(e.forEach(a=>{var s,l;(s=this.We)==null||s.add(a),(l=a.steps)==null||l.forEach(c=>{var u;(u=this.He)==null||u.add((c==null?void 0:c.event)||"")})}),(n=this._instance)!=null&&n.autocapture)){var i,o=new Set;e.forEach(a=>{var s;(s=a.steps)==null||s.forEach(l=>{l!=null&&l.selector&&o.add(l==null?void 0:l.selector)})}),(i=this._instance)==null||i.autocapture.setElementSelectors(o)}}on(e,t){var n;t!=null&&e.length!=0&&(this.He.has(e)||this.He.has(t==null?void 0:t.event))&&this.We&&((n=this.We)==null?void 0:n.size)>0&&this.We.forEach(i=>{this.Je(t,i)&&this.Ne.emit("actionCaptured",i.name)})}Ve(e){this.onAction("actionCaptured",t=>e(t))}Je(e,t){if((t==null?void 0:t.steps)==null)return!1;for(var n of t.steps)if(this.ze(e,n))return!0;return!1}onAction(e,t){return this.Ne.on(e,t)}qe(e,t){if(t!=null&&t.url){var n,i=e==null||(n=e.properties)==null?void 0:n.$current_url;if(!i||typeof i!="string"||!C2.Ke(i,t==null?void 0:t.url,(t==null?void 0:t.url_matching)||"contains"))return!1}return!0}static Ke(e,t,n){switch(n){case"regex":return!!xo&&SM(e,t);case"exact":return t===e;case"contains":var i=C2.Ye(t).replace(/_/g,".").replace(/%/g,".*");return SM(e,i);default:return!1}}static Ye(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}Be(e,t){if((t!=null&&t.href||t!=null&&t.tag_name||t!=null&&t.text)&&!this.Xe(e).some(o=>!(t!=null&&t.href&&!C2.Ke(o.href||"",t==null?void 0:t.href,(t==null?void 0:t.href_matching)||"exact"))&&(t==null||!t.tag_name||o.tag_name===(t==null?void 0:t.tag_name))&&!(t!=null&&t.text&&!C2.Ke(o.text||"",t==null?void 0:t.text,(t==null?void 0:t.text_matching)||"exact")&&!C2.Ke(o.$el_text||"",t==null?void 0:t.text,(t==null?void 0:t.text_matching)||"exact"))))return!1;if(t!=null&&t.selector){var n,i=e==null||(n=e.properties)==null?void 0:n.$element_selectors;if(!i||!i.includes(t==null?void 0:t.selector))return!1}return!0}Xe(e){return(e==null?void 0:e.properties.$elements)==null?[]:e==null?void 0:e.properties.$elements}}var $E=XE("[Surveys]"),CH="seenSurvey_",NWe=(r,e)=>{var t="$survey_"+e+"/"+r.id;return r.current_iteration&&r.current_iteration>0&&(t="$survey_"+e+"/"+r.id+"/"+r.current_iteration),t};class TWe{constructor(e){this._instance=e,this.Qe=new Map,this.Ze=new Map}register(e){var t;dc((t=this._instance)==null?void 0:t.Ge)||(this.tr(e),this.ir(e))}ir(e){var t=e.filter(n=>{var i,o;return((i=n.conditions)==null?void 0:i.actions)&&((o=n.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length)>0});t.length!==0&&(this.er==null&&(this.er=new C2(this._instance),this.er.init(),this.er.Ve(n=>{this.onAction(n)})),t.forEach(n=>{var i,o,a,s,l;n.conditions&&(i=n.conditions)!=null&&i.actions&&(o=n.conditions)!=null&&(o=o.actions)!=null&&o.values&&((a=n.conditions)==null||(a=a.actions)==null||(a=a.values)==null?void 0:a.length)>0&&((s=this.er)==null||s.register(n.conditions.actions.values),(l=n.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach(c=>{if(c&&c.name){var u=this.Ze.get(c.name);u&&u.push(n.id),this.Ze.set(c.name,u||[n.id])}}))}))}tr(e){var t;e.filter(n=>{var i,o;return((i=n.conditions)==null?void 0:i.events)&&((o=n.conditions)==null||(o=o.events)==null||(o=o.values)==null?void 0:o.length)>0}).length!==0&&((t=this._instance)==null||t.Ge((n,i)=>{this.onEvent(n,i)}),e.forEach(n=>{var i;(i=n.conditions)==null||(i=i.events)==null||(i=i.values)==null||i.forEach(o=>{if(o&&o.name){var a=this.Qe.get(o.name);a&&a.push(n.id),this.Qe.set(o.name,a||[n.id])}})}))}onEvent(e,t){var n,i=((n=this._instance)==null||(n=n.persistence)==null?void 0:n.props[dP])||[];if(e==="survey shown"&&t&&i.length>0){var o;$E.info("survey event matched, removing survey from activated surveys",{event:e,eventPayload:t,existingActivatedSurveys:i});var a=t==null||(o=t.properties)==null?void 0:o.$survey_id;if(a){var s=i.indexOf(a);s>=0&&(i.splice(s,1),this.rr(i))}}else this.Qe.has(e)&&($E.info("survey event matched, updating activated surveys",{event:e,surveys:this.Qe.get(e)}),this.rr(i.concat(this.Qe.get(e)||[])))}onAction(e){var t,n=((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[dP])||[];this.Ze.has(e)&&this.rr(n.concat(this.Ze.get(e)||[]))}rr(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({[dP]:[...new Set(e)]})}getSurveys(){var e,t=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[dP];return t||[]}getEventToSurveys(){return this.Qe}sr(){return this.er}}class PWe{constructor(e){this.nr=void 0,this.ar=null,this.lr=!1,this.ur=!1,this.hr=[],this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){var t=e.surveys;if(Um(t))return $E.warn("Flags not loaded yet. Not loading surveys.");var n=OI(t);this.nr=n?t.length>0:t,$E.info("flags response received, isSurveysEnabled: "+this.nr),this.loadIfEnabled()}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var e=[],t=0;t<localStorage.length;t++){var n=localStorage.key(t);(n!=null&&n.startsWith(CH)||n!=null&&n.startsWith("inProgressSurvey_"))&&e.push(n)}e.forEach(i=>localStorage.removeItem(i))}loadIfEnabled(){if(!this.ar)if(this.ur)$E.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)$E.info("Disabled. Not loading surveys.");else{var e=wh==null?void 0:wh.__PosthogExtensions__;if(e){var t=this.nr;if(!dc(t)){this.ur=!0;try{var n=e.generateSurveys;if(n)return void this.dr(n,t);var i=e.loadExternalDependency;if(!i)return void this.vr("PostHog loadExternalDependency extension not found.");i(this._instance,"surveys",o=>{o||!e.generateSurveys?this.vr("Could not load surveys script",o):this.dr(e.generateSurveys,t)})}catch(o){throw this.vr("Error initializing surveys",o),o}finally{this.ur=!1}}}else $E.error("PostHog Extensions not found.")}}dr(e,t){this.ar=e(this._instance,t),this._surveyEventReceiver=new TWe(this._instance),$E.info("Surveys loaded successfully"),this.cr({isLoaded:!0})}vr(e,t){$E.error(e,t),this.cr({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.hr.push(e),this.ar&&this.cr({isLoaded:!0}),()=>{this.hr=this.hr.filter(t=>t!==e)}}getSurveys(e,t){if(t===void 0&&(t=!1),this._instance.config.disable_surveys)return $E.info("Disabled. Not loading surveys."),e([]);var n=this._instance.get_property(Rz);if(n&&!t)return e(n,{isLoaded:!0});if(this.lr)return e([],{isLoaded:!1,error:"Surveys are already being loaded"});try{this.lr=!0,this._instance.Ee({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this._instance.config.token),method:"GET",timeout:this._instance.config.surveys_request_timeout_ms,callback:i=>{var o;this.lr=!1;var a=i.statusCode;if(a!==200||!i.json){var s="Surveys API could not be loaded, status: "+a;return $E.error(s),e([],{isLoaded:!1,error:s})}var l,c=i.json.surveys||[],u=c.filter(A=>function(d){return!(!d.start_date||d.end_date)}(A)&&(function(d){var f;return!((f=d.conditions)==null||(f=f.events)==null||(f=f.values)==null||!f.length)}(A)||function(d){var f;return!((f=d.conditions)==null||(f=f.actions)==null||(f=f.values)==null||!f.length)}(A)));return u.length>0&&((l=this._surveyEventReceiver)==null||l.register(u)),(o=this._instance.persistence)==null||o.register({[Rz]:c}),e(c,{isLoaded:!0})}})}catch(i){throw this.lr=!1,i}}cr(e){for(var t of this.hr)try{e.isLoaded?this.getSurveys(t):t([],e)}catch(n){$E.error("Error in survey callback",n)}}getActiveMatchingSurveys(e,t){if(t===void 0&&(t=!1),!Um(this.ar))return this.ar.getActiveMatchingSurveys(e,t);$E.warn("init was not called")}pr(e){var t=null;return this.getSurveys(n=>{var i;t=(i=n.find(o=>o.id===e))!==null&&i!==void 0?i:null}),t}gr(e){if(Um(this.ar))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var t=typeof e=="string"?this.pr(e):e;return t?this.ar.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(Um(this.ar))return $E.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var t=this.gr(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return Um(this.ar)?($E.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"})):new Promise(n=>{this.getSurveys(i=>{var o,a=(o=i.find(l=>l.id===e))!==null&&o!==void 0?o:null;if(a){var s=this.gr(a);n({visible:s.eligible,disabledReason:s.reason})}else n({visible:!1,disabledReason:"Survey not found"})},t)})}renderSurvey(e,t){if(Um(this.ar))$E.warn("init was not called");else{var n=this.pr(e),i=Au==null?void 0:Au.querySelector(t);n?i?this.ar.renderSurvey(n,i):$E.warn("Survey element not found"):$E.warn("Survey not found")}}}(function(r){return r.Button="button",r.Tab="tab",r.Selector="selector",r})({}),function(r){return r.TopLeft="top_left",r.TopRight="top_right",r.TopCenter="top_center",r.MiddleLeft="middle_left",r.MiddleRight="middle_right",r.MiddleCenter="middle_center",r.Left="left",r.Center="center",r.Right="right",r.NextToTrigger="next_to_trigger",r}({}),function(r){return r.Popover="popover",r.API="api",r.Widget="widget",r}({}),function(r){return r.Open="open",r.MultipleChoice="multiple_choice",r.SingleChoice="single_choice",r.Rating="rating",r.Link="link",r}({}),function(r){return r.NextQuestion="next_question",r.End="end",r.ResponseBased="response_based",r.SpecificQuestion="specific_question",r}({}),function(r){return r.Once="once",r.Recurring="recurring",r.Always="always",r}({});var EH=function(r){return r.SHOWN="survey shown",r.DISMISSED="survey dismissed",r.SENT="survey sent",r}({}),tpe=function(r){return r.SURVEY_ID="$survey_id",r.SURVEY_NAME="$survey_name",r.SURVEY_RESPONSE="$survey_response",r.SURVEY_ITERATION="$survey_iteration",r.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",r.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",r.SURVEY_SUBMISSION_ID="$survey_submission_id",r.SURVEY_QUESTIONS="$survey_questions",r.SURVEY_COMPLETED="$survey_completed",r}({}),npe=XE("[RateLimiter]");class kWe{constructor(e){var t,n;this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=i=>{var o=i.text;if(o&&o.length)try{(JSON.parse(o).quota_limited||[]).forEach(a=>{npe.info((a||"events")+" is quota limited."),this.serverLimits[a]=new Date().getTime()+6e4})}catch(a){return void npe.warn('could not rate limit - continuing. Error: "'+(a==null?void 0:a.message)+'"',{text:o})}},this.instance=e,this.captureEventsPerSecond=((t=e.config.rate_limiting)==null?void 0:t.events_per_second)||10,this.captureEventsBurstLimit=Math.max(((n=e.config.rate_limiting)==null?void 0:n.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond),this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}clientRateLimitContext(e){var t,n,i;e===void 0&&(e=!1);var o=new Date().getTime(),a=(t=(n=this.instance.persistence)==null?void 0:n.get_property(Tz))!==null&&t!==void 0?t:{tokens:this.captureEventsBurstLimit,last:o};a.tokens+=(o-a.last)/1e3*this.captureEventsPerSecond,a.last=o,a.tokens>this.captureEventsBurstLimit&&(a.tokens=this.captureEventsBurstLimit);var s=a.tokens<1;return s||e||(a.tokens=Math.max(0,a.tokens-1)),!s||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+this.captureEventsPerSecond+" events per second and "+this.captureEventsBurstLimit+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=s,(i=this.instance.persistence)==null||i.set_property(Tz,a),{isRateLimited:s,remainingTokens:a.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}}var E2=XE("[RemoteConfig]");class UWe{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=wh._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}_r(e){var t,n;(t=wh.__PosthogExtensions__)!=null&&t.loadExternalDependency?(n=wh.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"remote-config",()=>e(this.remoteConfig)):(E2.error("PostHog Extensions not found. Cannot load remote config."),e())}mr(e){this._instance.Ee({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t=>{e(t.json)}})}load(){try{if(this.remoteConfig)return E2.info("Using preloaded remote config",this.remoteConfig),void this.Ie(this.remoteConfig);if(this._instance.I())return void E2.warn("Remote config is disabled. Falling back to local config.");this._r(e=>{if(!e)return E2.info("No config found after loading remote JS config. Falling back to JSON."),void this.mr(t=>{this.Ie(t)});this.Ie(e)})}catch(e){E2.error("Error loading remote config",e)}}Ie(e){e?this._instance.config.__preview_remote_config?(this._instance.Ie(e),e.hasFeatureFlags!==!1&&this._instance.featureFlags.ensureFlagsLoaded()):E2.info("__preview_remote_config is disabled. Logging config instead",e):E2.error("Failed to fetch remote config from PostHog.")}}var _H=3e3;class FWe{constructor(e,t){this.br=!0,this.yr=[],this.wr=xB((t==null?void 0:t.flush_interval_ms)||_H,250,5e3,"flush interval",_H),this.Sr=e}enqueue(e){this.yr.push(e),this.$r||this.kr()}unload(){this.Er();var e=this.yr.length>0?this.Ir():{},t=Object.values(e);[...t.filter(n=>n.url.indexOf("/e")===0),...t.filter(n=>n.url.indexOf("/e")!==0)].map(n=>{this.Sr(Wc({},n,{transport:"sendBeacon"}))})}enable(){this.br=!1,this.kr()}kr(){var e=this;this.br||(this.$r=setTimeout(()=>{if(this.Er(),this.yr.length>0){var t=this.Ir(),n=function(){var o=t[i],a=new Date().getTime();o.data&&OI(o.data)&&av(o.data,s=>{s.offset=Math.abs(s.timestamp-a),delete s.timestamp}),e.Sr(o)};for(var i in t)n()}},this.wr))}Er(){clearTimeout(this.$r),this.$r=void 0}Ir(){var e={};return av(this.yr,t=>{var n,i=t,o=(i?i.batchKey:null)||i.url;dc(e[o])&&(e[o]=Wc({},i,{data:[]})),(n=e[o].data)==null||n.push(i.data)}),this.yr=[],e}}var LWe=["retriesPerformedSoFar"];class GWe{constructor(e){this.Pr=!1,this.Rr=3e3,this.yr=[],this._instance=e,this.yr=[],this.Tr=!0,!dc(xo)&&"onLine"in xo.navigator&&(this.Tr=xo.navigator.onLine,oC(xo,"online",()=>{this.Tr=!0,this.se()}),oC(xo,"offline",()=>{this.Tr=!1}))}get length(){return this.yr.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,n=afe(e,LWe);q_(t)&&t>0&&(n.url=TP(n.url,{retry_count:t})),this._instance.Ee(Wc({},n,{callback:i=>{i.statusCode!==200&&(i.statusCode<400||i.statusCode>=500)&&(t??0)<10?this.Mr(Wc({retriesPerformedSoFar:t},n)):n.callback==null||n.callback(i)}}))}Mr(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var n=function(a){var s=3e3*Math.pow(2,a),l=s/2,c=Math.min(18e5,s),u=(Math.random()-.5)*(c-l);return Math.ceil(c+u)}(t),i=Date.now()+n;this.yr.push({retryAt:i,requestOptions:e});var o="Enqueued failed request for retry in "+n;navigator.onLine||(o+=" (Browser is offline)"),bu.warn(o),this.Pr||(this.Pr=!0,this.Cr())}Cr(){this.Fr&&clearTimeout(this.Fr),this.Fr=setTimeout(()=>{this.Tr&&this.yr.length>0&&this.se(),this.Cr()},this.Rr)}se(){var e=Date.now(),t=[],n=this.yr.filter(o=>o.retryAt<e||(t.push(o),!1));if(this.yr=t,n.length>0)for(var{requestOptions:i}of n)this.retriableRequest(i)}unload(){for(var{requestOptions:e}of(this.Fr&&(clearTimeout(this.Fr),this.Fr=void 0),this.yr))try{this._instance.Ee(Wc({},e,{transport:"sendBeacon"}))}catch(t){bu.error(t)}this.yr=[]}}class OWe{constructor(e){this.Or=()=>{var t,n,i,o;this.Ar||(this.Ar={});var a=this.scrollElement(),s=this.scrollY(),l=a?Math.max(0,a.scrollHeight-a.clientHeight):0,c=s+((a==null?void 0:a.clientHeight)||0),u=(a==null?void 0:a.scrollHeight)||0;this.Ar.lastScrollY=Math.ceil(s),this.Ar.maxScrollY=Math.max(s,(t=this.Ar.maxScrollY)!==null&&t!==void 0?t:0),this.Ar.maxScrollHeight=Math.max(l,(n=this.Ar.maxScrollHeight)!==null&&n!==void 0?n:0),this.Ar.lastContentY=c,this.Ar.maxContentY=Math.max(c,(i=this.Ar.maxContentY)!==null&&i!==void 0?i:0),this.Ar.maxContentHeight=Math.max(u,(o=this.Ar.maxContentHeight)!==null&&o!==void 0?o:0)},this._instance=e}getContext(){return this.Ar}resetContext(){var e=this.Ar;return setTimeout(this.Or,0),e}startMeasuringScrollPosition(){oC(xo,"scroll",this.Or,{capture:!0}),oC(xo,"scrollend",this.Or,{capture:!0}),oC(xo,"resize",this.Or)}scrollElement(){if(!this._instance.config.scroll_root_selector)return xo==null?void 0:xo.document.documentElement;var e=OI(this._instance.config.scroll_root_selector)?this._instance.config.scroll_root_selector:[this._instance.config.scroll_root_selector];for(var t of e){var n=xo==null?void 0:xo.document.querySelector(t);if(n)return n}}scrollY(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return xo&&(xo.scrollY||xo.pageYOffset||xo.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return xo&&(xo.scrollX||xo.pageXOffset||xo.document.documentElement.scrollLeft)||0}}var zWe=r=>Jhe(r==null?void 0:r.config.mask_personal_data_properties,r==null?void 0:r.config.custom_personal_data_properties);class HWe{constructor(e,t,n,i){this.Dr=o=>{var a=this.Lr();if(!a||a.sessionId!==o){var s={sessionId:o,props:this.jr(this._instance)};this.Nr.register({[Nz]:s})}},this._instance=e,this.zr=t,this.Nr=n,this.jr=i||zWe,this.zr.onSessionId(this.Dr)}Lr(){return this.Nr.props[Nz]}getSetOnceProps(){var e,t=(e=this.Lr())==null?void 0:e.props;return t?"r"in t?Whe(t):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){var e={};return av(Bz(this.getSetOnceProps()),(t,n)=>{n==="$current_url"&&(n="url"),e["$session_entry_"+_z(n)]=t}),e}}var rpe=XE("[SessionId]");class YWe{constructor(e,t,n){var i;if(this.Ur=[],!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.__preview_experimental_cookieless_mode)throw new Error("SessionIdManager cannot be used with __preview_experimental_cookieless_mode");this.S=e.config,this.Nr=e.persistence,this.fi=void 0,this.Ct=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.qr=t||aQ,this.Br=n||aQ;var o=this.S.persistence_name||this.S.token,a=this.S.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*xB(a,60,36e3,"session_idle_timeout_seconds",1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.Hr(),this.Wr="ph_"+o+"_window_id",this.Gr="ph_"+o+"_primary_window_exists",this.Jr()){var s=v_.L(this.Wr),l=v_.L(this.Gr);s&&!l?this.fi=s:v_.N(this.Wr),v_.j(this.Gr,!0)}if((i=this.S.bootstrap)!=null&&i.sessionID)try{var c=(u=>{var A=u.replace(/-/g,"");if(A.length!==32)throw new Error("Not a valid UUID");if(A[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(A.substring(0,12),16)})(this.S.bootstrap.sessionID);this.Vr(this.S.bootstrap.sessionID,new Date().getTime(),c)}catch(u){rpe.error("Invalid sessionID in bootstrap",u)}this.Kr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return dc(this.Ur)&&(this.Ur=[]),this.Ur.push(e),this.Ct&&e(this.Ct,this.fi),()=>{this.Ur=this.Ur.filter(t=>t!==e)}}Jr(){return this.S.persistence!=="memory"&&!this.Nr.Fe&&v_.O()}Yr(e){e!==this.fi&&(this.fi=e,this.Jr()&&v_.j(this.Wr,e))}Xr(){return this.fi?this.fi:this.Jr()?v_.L(this.Wr):null}Vr(e,t,n){e===this.Ct&&t===this._sessionActivityTimestamp&&n===this._sessionStartTimestamp||(this._sessionStartTimestamp=n,this._sessionActivityTimestamp=t,this.Ct=e,this.Nr.register({[uP]:[t,e,n]}))}Qr(){if(this.Ct&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this.Ct,this._sessionStartTimestamp];var e=this.Nr.props[uP];return OI(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.Vr(null,null,null)}Kr(){oC(xo,"beforeunload",()=>{this.Jr()&&v_.N(this.Gr)},{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(e===void 0&&(e=!1),t===void 0&&(t=null),this.S.__preview_experimental_cookieless_mode)throw new Error("checkAndGetSessionAndWindowId should not be called in __preview_experimental_cookieless_mode");var n=t||new Date().getTime(),[i,o,a]=this.Qr(),s=this.Xr(),l=q_(a)&&a>0&&Math.abs(n-a)>864e5,c=!1,u=!o,A=!e&&Math.abs(n-i)>this.sessionTimeoutMs;u||A||l?(o=this.qr(),s=this.Br(),rpe.info("new session ID generated",{sessionId:o,windowId:s,changeReason:{noSessionId:u,activityTimeout:A,sessionPastMaximumLength:l}}),a=n,c=!0):s||(s=this.Br(),c=!0);var d=i===0||!e||l?n:i,f=a===0?new Date().getTime():a;return this.Yr(s),this.Vr(o,d,f),e||this.Hr(),c&&this.Ur.forEach(m=>m(o,s,c?{noSessionId:u,activityTimeout:A,sessionPastMaximumLength:l}:void 0)),{sessionId:o,windowId:s,sessionStartTimestamp:f,changeReason:c?{noSessionId:u,activityTimeout:A,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:i}}Hr(){clearTimeout(this.Zr),this.Zr=setTimeout(()=>{this.resetSessionId()},1.1*this.sessionTimeoutMs)}}var VWe=["$set_once","$set"],uQ=XE("[SiteApps]");class KWe{constructor(e){this._instance=e,this.ts=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}es(e,t){if(t){var n=this.globalsForEvent(t);this.ts.push(n),this.ts.length>1e3&&(this.ts=this.ts.slice(10))}}get siteAppLoaders(){var e;return(e=wh._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}init(){if(this.isEnabled){var e=this._instance.Ge(this.es.bind(this));this.rs=()=>{e(),this.ts=[],this.rs=void 0}}}globalsForEvent(e){var t,n,i,o,a,s,l;if(!e)throw new Error("Event payload is required");var c={},u=this._instance.get_property("$groups")||[],A=this._instance.get_property("$stored_group_properties")||{};for(var[d,f]of Object.entries(A))c[d]={id:u[d],type:d,properties:f};var{$set_once:m,$set:C}=e;return{event:Wc({},afe(e,VWe),{properties:Wc({},e.properties,C?{$set:Wc({},(t=(n=e.properties)==null?void 0:n.$set)!==null&&t!==void 0?t:{},C)}:{},m?{$set_once:Wc({},(i=(o=e.properties)==null?void 0:o.$set_once)!==null&&i!==void 0?i:{},m)}:{}),elements_chain:(a=(s=e.properties)==null?void 0:s.$elements_chain)!==null&&a!==void 0?a:"",distinct_id:(l=e.properties)==null?void 0:l.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:c}}setupSiteApp(e){var t=this.apps[e.id],n=()=>{var s;!t.errored&&this.ts.length&&(uQ.info("Processing "+this.ts.length+" events for site app with id "+e.id),this.ts.forEach(l=>t.processEvent==null?void 0:t.processEvent(l)),t.processedBuffer=!0),Object.values(this.apps).every(l=>l.processedBuffer||l.errored)&&((s=this.rs)==null||s.call(this))},i=!1,o=s=>{t.errored=!s,t.loaded=!0,uQ.info("Site app with id "+e.id+" "+(s?"loaded":"errored")),i&&n()};try{var{processEvent:a}=e.init({posthog:this._instance,callback:s=>{o(s)}});a&&(t.processEvent=a),i=!0}catch(s){uQ.error("Error while initializing PostHog app with config id "+e.id,s),o(!1)}if(i&&t.loaded)try{n()}catch(s){uQ.error("Error while processing buffered events PostHog app with config id "+e.id,s),t.errored=!0}}ss(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var n of e)this.setupSiteApp(n)}ns(e){if(Object.keys(this.apps).length!==0){var t=this.globalsForEvent(e);for(var n of Object.values(this.apps))try{n.processEvent==null||n.processEvent(t)}catch(i){uQ.error("Error while processing event "+e.event+" for site app "+n.id,i)}}}onRemoteConfig(e){var t,n,i,o=this;if((t=this.siteAppLoaders)!=null&&t.length)return this.isEnabled?(this.ss(),void this._instance.on("eventCaptured",c=>this.ns(c))):void uQ.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((n=this.rs)==null||n.call(this),(i=e.siteApps)!=null&&i.length)if(this.isEnabled){var a=function(c){var u;wh["__$$ph_site_app_"+c]=o._instance,(u=wh.__PosthogExtensions__)==null||u.loadSiteApp==null||u.loadSiteApp(o._instance,l,A=>{if(A)return uQ.error("Error while initializing PostHog app with config id "+c,A)})};for(var{id:s,url:l}of e.siteApps)a(s)}else uQ.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var jWe=["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","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"],ipe=function(r,e){if(!r)return!1;var t=r.toLowerCase();return jWe.concat(e||[]).some(n=>{var i=n.toLowerCase();return t.indexOf(i)!==-1})},ope=function(r,e){if(!r)return!1;var t=r.userAgent;if(t&&ipe(t,e))return!0;try{var n=r==null?void 0:r.userAgentData;if(n!=null&&n.brands&&n.brands.some(i=>ipe(i==null?void 0:i.brand,e)))return!0}catch{}return!!r.webdriver},P3=function(r){return r.US="us",r.EU="eu",r.CUSTOM="custom",r}({}),ape="i.posthog.com";class JWe{constructor(e){this.os={},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 uiHost(){var e,t=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+ape,".posthog.com")),t==="https://app.posthog.com"?"https://us.posthog.com":t}get region(){return this.os[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.os[this.apiHost]=P3.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.os[this.apiHost]=P3.EU:this.os[this.apiHost]=P3.CUSTOM),this.os[this.apiHost]}endpointFor(e,t){if(t===void 0&&(t=""),t&&(t=t[0]==="/"?t:"/"+t),e==="ui")return this.uiHost+t;if(this.region===P3.CUSTOM)return this.apiHost+t;var n=ape+t;switch(e){case"assets":return"https://"+this.region+"-assets."+n;case"api":return"https://"+this.region+"."+n}}}var WWe={icontains:(r,e)=>!!xo&&e.href.toLowerCase().indexOf(r.toLowerCase())>-1,not_icontains:(r,e)=>!!xo&&e.href.toLowerCase().indexOf(r.toLowerCase())===-1,regex:(r,e)=>!!xo&&SM(e.href,r),not_regex:(r,e)=>!!xo&&!SM(e.href,r),exact:(r,e)=>e.href===r,is_not:(r,e)=>e.href!==r};class $_{constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(n){n===void 0&&(n=!1),t.getWebExperiments(i=>{$_.ls("retrieved web experiments from the server"),t.us=new Map,i.forEach(o=>{if(o.feature_flag_key){var a;t.us&&($_.ls("setting flag key ",o.feature_flag_key," to web experiment ",o),(a=t.us)==null||a.set(o.feature_flag_key,o));var s=t._instance.getFeatureFlag(o.feature_flag_key);PC(s)&&o.variants[s]&&t.hs(o.name,s,o.variants[s].transforms)}else if(o.variants)for(var l in o.variants){var c=o.variants[l];$_.ds(c)&&t.hs(o.name,l,c.transforms)}})},n)},this._instance=e,this._instance.onFeatureFlags(n=>{this.onFeatureFlags(n)})}onFeatureFlags(e){if(this._is_bot())$_.ls("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(Um(this.us))return this.us=new Map,this.loadIfEnabled(),void this.previewWebExperiment();$_.ls("applying feature flags",e),e.forEach(t=>{var n;if(this.us&&(n=this.us)!=null&&n.has(t)){var i,o=this._instance.getFeatureFlag(t),a=(i=this.us)==null?void 0:i.get(t);o&&a!=null&&a.variants[o]&&this.hs(a.name,o,a.variants[o].transforms)}})}}previewWebExperiment(){var e=$_.getWindowLocation();if(e!=null&&e.search){var t=IP(e==null?void 0:e.search,"__experiment_id"),n=IP(e==null?void 0:e.search,"__experiment_variant");t&&n&&($_.ls("previewing web experiments "+t+" && "+n),this.getWebExperiments(i=>{this.vs(parseInt(t),n,i)},!1,!0))}}loadIfEnabled(){this._instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,n){if(this._instance.config.disable_web_experiments&&!n)return e([]);var i=this._instance.get_property("$web_experiments");if(i&&!t)return e(i);this._instance.Ee({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._instance.config.token),method:"GET",callback:o=>{if(o.statusCode!==200||!o.json)return e([]);var a=o.json.experiments||[];return e(a)}})}vs(e,t,n){var i=n.filter(o=>o.id===e);i&&i.length>0&&($_.ls("Previewing web experiment ["+i[0].name+"] with variant ["+t+"]"),this.hs(i[0].name,t,i[0].variants[t].transforms))}static ds(e){return!Um(e.conditions)&&$_.cs(e)&&$_.fs(e)}static cs(e){var t;if(Um(e.conditions)||Um((t=e.conditions)==null?void 0:t.url))return!0;var n,i,o,a=$_.getWindowLocation();return!!a&&((n=e.conditions)==null||!n.url||WWe[(i=(o=e.conditions)==null?void 0:o.urlMatchType)!==null&&i!==void 0?i:"icontains"](e.conditions.url,a))}static getWindowLocation(){return xo==null?void 0:xo.location}static fs(e){var t;if(Um(e.conditions)||Um((t=e.conditions)==null?void 0:t.utm))return!0;var n=Hhe();if(n.utm_source){var i,o,a,s,l,c,u,A,d=(i=e.conditions)==null||(i=i.utm)==null||!i.utm_campaign||((o=e.conditions)==null||(o=o.utm)==null?void 0:o.utm_campaign)==n.utm_campaign,f=(a=e.conditions)==null||(a=a.utm)==null||!a.utm_source||((s=e.conditions)==null||(s=s.utm)==null?void 0:s.utm_source)==n.utm_source,m=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((c=e.conditions)==null||(c=c.utm)==null?void 0:c.utm_medium)==n.utm_medium,C=(u=e.conditions)==null||(u=u.utm)==null||!u.utm_term||((A=e.conditions)==null||(A=A.utm)==null?void 0:A.utm_term)==n.utm_term;return d&&m&&C&&f}return!1}static ls(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];bu.info("[WebExperiments] "+e,n)}hs(e,t,n){this._is_bot()?$_.ls("Refusing to render web experiment since the viewer is a likely bot"):t!=="control"?n.forEach(i=>{if(i.selector){var o;$_.ls("applying transform of variant "+t+" for experiment "+e+" ",i);var a=(o=document)==null?void 0:o.querySelectorAll(i.selector);a==null||a.forEach(s=>{var l=s;i.html&&(l.innerHTML=i.html),i.css&&l.setAttribute("style",i.css)})}}):$_.ls("Control variants leave the page unmodified.")}_is_bot(){return _B&&this._instance?ope(_B,this._instance.config.custom_blocked_useragents):void 0}}var qWe=XE("[PostHog ExternalIntegrations]"),ZWe={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class XWe{constructor(e){this._instance=e}J(e,t){var n;(n=wh.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,e,i=>{if(i)return qWe.error("failed to load script",i);t()})}startIfEnabledOrStop(){var e=this,t=function(a){var s,l,c;!i||(s=wh.__PosthogExtensions__)!=null&&(s=s.integrations)!=null&&s[a]||e.J(ZWe[a],()=>{var u;(u=wh.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[a])==null||u.start(e._instance)}),!i&&(l=wh.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[a]&&((c=wh.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[a])==null||c.stop())};for(var[n,i]of Object.entries((o=this._instance.config.integrations)!==null&&o!==void 0?o:{})){var o;t(n)}}}var k3={},xH=()=>{},RM="posthog",spe=!AWe&&(qx==null?void 0:qx.indexOf("MSIE"))===-1&&(qx==null?void 0:qx.indexOf("Mozilla"))===-1,lpe=r=>{var e;return{api_host:"https://us.i.posthog.com",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:Hje(Au==null?void 0:Au.location),persistence:"localStorage+cookie",persistence_name:"",loaded:xH,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageview:r!=="2025-05-24"||"history_change",capture_pageleave:"if_capture_pageview",defaults:r??"unset",debug:Wx&&PC(Wx==null?void 0:Wx.search)&&Wx.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_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(xo==null||(e=xo.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",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,session_recording:{},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_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error:t=>{var n="Bad HTTP status: "+t.statusCode+" "+t.text;bu.error(n)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",before_send:void 0,request_queue_config:{flush_interval_ms:_H},error_tracking:{},_onCapture:xH}},cpe=r=>{var e={};dc(r.process_person)||(e.person_profiles=r.process_person),dc(r.xhr_headers)||(e.request_headers=r.xhr_headers),dc(r.cookie_name)||(e.persistence_name=r.cookie_name),dc(r.disable_cookie)||(e.disable_persistence=r.disable_cookie),dc(r.store_google)||(e.save_campaign_params=r.store_google),dc(r.verbose)||(e.debug=r.verbose);var t=u1({},e,r);return OI(r.property_blacklist)&&(dc(r.property_denylist)?t.property_denylist=r.property_blacklist:OI(r.property_denylist)?t.property_denylist=[...r.property_blacklist,...r.property_denylist]:bu.error("Invalid value for property_denylist config: "+r.property_denylist)),t};class $We{constructor(){this.__forceAllowLocalhost=!1}get ps(){return this.__forceAllowLocalhost}set ps(e){bu.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class LP{get decideEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){this.webPerformance=new $We,this.gs=!1,this.version=ZS.LIB_VERSION,this._s=new epe,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=lpe(),this.SentryIntegration=tWe,this.sentryIntegration=e=>function(t,n){var i=mhe(t,n);return{name:ghe,processEvent:o=>i(o)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.bs=!1,this.ys=null,this.ws=null,this.Ss=null,this.featureFlags=new DWe(this),this.toolbar=new rWe(this),this.scrollManager=new OWe(this),this.pageViewManager=new cWe(this),this.surveys=new PWe(this),this.experiments=new $_(this),this.exceptions=new hWe(this),this.rateLimiter=new kWe(this),this.requestRouter=new JWe(this),this.consent=new AJe(this),this.externalIntegrations=new XWe(this),this.people={set:(e,t,n)=>{var i=PC(e)?{[e]:t}:e;this.setPersonProperties(i),n==null||n({})},set_once:(e,t,n)=>{var i=PC(e)?{[e]:t}:e;this.setPersonProperties(void 0,i),n==null||n({})}},this.on("eventCaptured",e=>bu.info('send "'+(e==null?void 0:e.event)+'"',e))}init(e,t,n){if(n&&n!==RM){var i,o=(i=k3[n])!==null&&i!==void 0?i:new LP;return o._init(e,t,n),k3[n]=o,k3[RM][n]=o,o}return this._init(e,t,n)}_init(e,t,n){var i,o;if(t===void 0&&(t={}),dc(e)||xz(e))return bu.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 bu.warn("You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},this.$s=t,this.ks=[],t.person_profiles&&(this.ws=t.person_profiles),this.set_config(u1({},lpe(t.defaults),cpe(t),{name:n,token:e})),this.config.on_xhr_error&&bu.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:XS.GZipJS;var a=this.xs();this.persistence=new IH(this.config,a),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new IH(Wc({},this.config,{persistence:"sessionStorage"}),a);var s=Wc({},this.persistence.props),l=Wc({},this.sessionPersistence.props);if(this.register({$initialization_time:new Date().toISOString()}),this.Es=new FWe(x=>this.Is(x),this.config.request_queue_config),this.Ps=new GWe(this),this.__request_queue=[],this.config.__preview_experimental_cookieless_mode||(this.sessionManager=new YWe(this),this.sessionPropsManager=new HWe(this,this.sessionManager,this.persistence)),new oWe(this).startIfEnabledOrStop(),this.siteApps=new KWe(this),(i=this.siteApps)==null||i.init(),this.config.__preview_experimental_cookieless_mode||(this.sessionRecording=new $Je(this),this.sessionRecording.startIfEnabledOrStop()),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),this.autocapture=new rJe(this),this.autocapture.startIfEnabled(),this.surveys.loadIfEnabled(),this.heatmaps=new lWe(this),this.heatmaps.startIfEnabled(),this.webVitalsAutocapture=new aWe(this),this.exceptionObserver=new hJe(this),this.exceptionObserver.startIfEnabled(),this.deadClicksAutocapture=new Ofe(this,fJe),this.deadClicksAutocapture.startIfEnabled(),this.historyAutocapture=new wJe(this),this.historyAutocapture.startIfEnabled(),ZS.DEBUG=ZS.DEBUG||this.config.debug,ZS.DEBUG&&bu.info("Starting in debug mode",{this:this,config:t,thisC:Wc({},this.config),p:s,s:l}),((o=t.bootstrap)==null?void 0:o.distinctID)!==void 0){var c,u,A=this.config.get_device_id(aQ()),d=(c=t.bootstrap)!=null&&c.isIdentifiedID?A:t.bootstrap.distinctID;this.persistence.set_property($S,(u=t.bootstrap)!=null&&u.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:t.bootstrap.distinctID,$device_id:d})}if(this.Rs()){var f,m,C=Object.keys(((f=t.bootstrap)==null?void 0:f.featureFlags)||{}).filter(x=>{var w;return!((w=t.bootstrap)==null||(w=w.featureFlags)==null||!w[x])}).reduce((x,w)=>{var P;return x[w]=((P=t.bootstrap)==null||(P=P.featureFlags)==null?void 0:P[w])||!1,x},{}),E=Object.keys(((m=t.bootstrap)==null?void 0:m.featureFlagPayloads)||{}).filter(x=>C[x]).reduce((x,w)=>{var P,L;return(P=t.bootstrap)!=null&&(P=P.featureFlagPayloads)!=null&&P[w]&&(x[w]=(L=t.bootstrap)==null||(L=L.featureFlagPayloads)==null?void 0:L[w]),x},{});this.featureFlags.receivedFeatureFlags({featureFlags:C,featureFlagPayloads:E})}if(this.config.__preview_experimental_cookieless_mode)this.register_once({distinct_id:gP,$device_id:null},"");else if(!this.get_distinct_id()){var _=this.config.get_device_id(aQ());this.register_once({distinct_id:_,$device_id:_},""),this.persistence.set_property($S,"anonymous")}return oC(xo,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?eWe(this,()=>this.Ts()):this.Ts(),jB(this.config._onCapture)&&this.config._onCapture!==xH&&(bu.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",x=>this.config._onCapture(x.event,x))),this.config.ip&&bu.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}Ie(e){var t,n,i,o,a,s,l,c;if(!Au||!Au.body)return bu.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.Ie(e)},500);this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=Wg(e.supportedCompression,XS.GZipJS)?XS.GZipJS:Wg(e.supportedCompression,XS.Base64)?XS.Base64:void 0),(t=e.analytics)!=null&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.ws?this.ws:"identified_only"}),(n=this.siteApps)==null||n.onRemoteConfig(e),(i=this.sessionRecording)==null||i.onRemoteConfig(e),(o=this.autocapture)==null||o.onRemoteConfig(e),(a=this.heatmaps)==null||a.onRemoteConfig(e),this.surveys.onRemoteConfig(e),(s=this.webVitalsAutocapture)==null||s.onRemoteConfig(e),(l=this.exceptionObserver)==null||l.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),(c=this.deadClicksAutocapture)==null||c.onRemoteConfig(e)}Ts(){try{this.config.loaded(this)}catch(e){bu.critical("`loaded` function failed",e)}this.Ms(),this.config.capture_pageview&&setTimeout(()=>{this.consent.isOptedIn()&&this.Cs()},1),new UWe(this).load(),this.featureFlags.flags()}Ms(){var e;this.has_opted_out_capturing()||this.config.request_batching&&((e=this.Es)==null||e.enable())}_dom_loaded(){this.has_opted_out_capturing()||iQ(this.__request_queue,e=>this.Is(e)),this.__request_queue=[],this.Ms()}_handle_unload(){var e,t;this.config.request_batching?(this.Fs()&&this.capture("$pageleave"),(e=this.Es)==null||e.unload(),(t=this.Ps)==null||t.unload()):this.Fs()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}Ee(e){this.__loaded&&(spe?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=TP(e.url,{ip:this.config.ip?1:0}),e.headers=Wc({},this.config.request_headers),e.compression=e.compression==="best-available"?this.compression:e.compression,e.fetchOptions=e.fetchOptions||this.config.fetch_options,(t=>{var n,i,o,a=Wc({},t);a.timeout=a.timeout||6e4,a.url=TP(a.url,{_:new Date().getTime().toString(),ver:ZS.LIB_VERSION,compression:a.compression});var s=(n=a.transport)!==null&&n!==void 0?n:"fetch",l=(i=(o=lfe(w3,c=>c.transport===s))==null?void 0:o.method)!==null&&i!==void 0?i:w3[0].method;if(!l)throw new Error("No available transport method");l(a)})(Wc({},e,{callback:t=>{var n,i;this.rateLimiter.checkForLimiting(t),t.statusCode>=400&&((n=(i=this.config).on_request_error)==null||n.call(i,t)),e.callback==null||e.callback(t)}}))))}Is(e){this.Ps?this.Ps.retriableRequest(e):this.Ee(e)}_execute_array(e){var t,n=[],i=[],o=[];iQ(e,s=>{s&&(t=s[0],OI(t)?o.push(s):jB(s)?s.call(this):OI(s)&&t==="alias"?n.push(s):OI(s)&&t.indexOf("capture")!==-1&&jB(this[t])?o.push(s):i.push(s))});var a=function(s,l){iQ(s,function(c){if(OI(c[0])){var u=l;av(c,function(A){u=u[A[0]].apply(u,A.slice(1))})}else this[c[0]].apply(this,c.slice(1))},l)};a(n,this),a(i,this),a(o,this)}Rs(){var e,t;return((e=this.config.bootstrap)==null?void 0:e.featureFlags)&&Object.keys((t=this.config.bootstrap)==null?void 0:t.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,t,n){var i;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Es){if(!this.consent.isOptedOut())if(!dc(e)&&PC(e)){if(this.config.opt_out_useragent_filter||!this._is_bot()){var o=n!=null&&n.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(o==null||!o.isRateLimited){t!=null&&t.$current_url&&!PC(t==null?void 0:t.$current_url)&&(bu.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),t==null||delete t.$current_url),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 a=new Date,s=(n==null?void 0:n.timestamp)||a,l=aQ(),c={uuid:l,event:e,properties:this.calculateEventProperties(e,t||{},s,l)};o&&(c.properties.$lib_rate_limit_remaining_tokens=o.remainingTokens),n!=null&&n.$set&&(c.$set=n==null?void 0:n.$set);var u,A,d=this.Os(n==null?void 0:n.$set_once);if(d&&(c.$set_once=d),(c=Oje(c,n!=null&&n._noTruncate?null:this.config.properties_string_max_length)).timestamp=s,dc(n==null?void 0:n.timestamp)||(c.properties.$event_time_override_provided=!0,c.properties.$event_time_override_system_time=a),e===EH.DISMISSED||e===EH.SENT){var f=t==null?void 0:t[tpe.SURVEY_ID],m=t==null?void 0:t[tpe.SURVEY_ITERATION];localStorage.setItem((A=""+CH+(u={id:f,current_iteration:m}).id,u.current_iteration&&u.current_iteration>0&&(A=""+CH+u.id+"_"+u.current_iteration),A),"true"),c.$set=Wc({},c.$set,{[NWe({id:f,current_iteration:m},e===EH.SENT?"responded":"dismissed")]:!0})}var C=Wc({},c.properties.$set,c.$set);if(IM(C)||this.setPersonPropertiesForFlags(C),!Um(this.config.before_send)){var E=this.As(c);if(!E)return;c=E}this._s.emit("eventCaptured",c);var _={method:"POST",url:(i=n==null?void 0:n._url)!==null&&i!==void 0?i:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:c,compression:"best-available",batchKey:n==null?void 0:n._batchKey};return!this.config.request_batching||n&&(n==null||!n._batchKey)||n!=null&&n.send_instantly?this.Is(_):this.Es.enqueue(_),c}bu.critical("This capture call is ignored due to client rate limiting.")}}else bu.error("No event name provided to posthog.capture")}else bu.uninitializedWarning("posthog.capture")}Ge(e){return this.on("eventCaptured",t=>e(t.event,t))}calculateEventProperties(e,t,n,i,o){if(n=n||new Date,!this.persistence||!this.sessionPersistence)return t;var a=o?void 0:this.persistence.remove_event_timer(e),s=Wc({},t);if(s.token=this.config.token,s.$config_defaults=this.config.defaults,this.config.__preview_experimental_cookieless_mode&&(s.$cookieless_mode=!0),e==="$snapshot"){var l=Wc({},this.persistence.properties(),this.sessionPersistence.properties());return s.distinct_id=l.distinct_id,(!PC(s.distinct_id)&&!q_(s.distinct_id)||xz(s.distinct_id))&&bu.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),s}var c,u=wWe(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:A,windowId:d}=this.sessionManager.checkAndGetSessionAndWindowId(o,n.getTime());s.$session_id=A,s.$window_id=d}this.sessionPropsManager&&u1(s,this.sessionPropsManager.getSessionProps());try{var f;this.sessionRecording&&u1(s,this.sessionRecording.sdkDebugProperties),s.$sdk_debug_retry_queue_size=(f=this.Ps)==null?void 0:f.length}catch(_){s.$sdk_debug_error_capturing_properties=String(_)}if(this.requestRouter.region===P3.CUSTOM&&(s.$lib_custom_api_host=this.config.api_host),c=e!=="$pageview"||o?e!=="$pageleave"||o?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(n):this.pageViewManager.doPageView(n,i),s=u1(s,c),e==="$pageview"&&Au&&(s.title=Au.title),!dc(a)){var m=n.getTime()-a;s.$duration=parseFloat((m/1e3).toFixed(3))}qx&&this.config.opt_out_useragent_filter&&(s.$browser_type=this._is_bot()?"bot":"browser"),(s=u1({},u,this.persistence.properties(),this.sessionPersistence.properties(),s)).$is_identified=this._isIdentified(),OI(this.config.property_denylist)?av(this.config.property_denylist,function(_){delete s[_]}):bu.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var C=this.config.sanitize_properties;C&&(bu.error("sanitize_properties is deprecated. Use before_send instead"),s=C(s,e));var E=this.Ds();return s.$process_person_profile=E,E&&!o&&this.Ls("_calculate_event_properties"),s}Os(e){var t;if(!this.persistence||!this.Ds()||this.gs)return e;var n=this.persistence.get_initial_props(),i=(t=this.sessionPropsManager)==null?void 0:t.getSetOnceProps(),o=u1({},n,i||{},e||{}),a=this.config.sanitize_properties;return a&&(bu.error("sanitize_properties is deprecated. Use before_send instead"),o=a(o,"$set_once")),this.gs=!0,IM(o)?void 0:o}register(e,t){var n;(n=this.persistence)==null||n.register(e,t)}register_once(e,t,n){var i;(i=this.persistence)==null||i.register_once(e,t,n)}register_for_session(e){var t;(t=this.sessionPersistence)==null||t.register(e)}unregister(e){var t;(t=this.persistence)==null||t.unregister(e)}unregister_for_session(e){var t;(t=this.sessionPersistence)==null||t.unregister(e)}js(e,t){this.register({[e]:t})}getFeatureFlag(e,t){return this.featureFlags.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t=this.featureFlags.getFeatureFlagPayload(e);try{return JSON.parse(t)}catch{return t}}isFeatureEnabled(e,t){return this.featureFlags.isFeatureEnabled(e,t)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateEarlyAccessFeatureEnrollment(e,t){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t)}getEarlyAccessFeatures(e,t,n){return t===void 0&&(t=!1),this.featureFlags.getEarlyAccessFeatures(e,t,n)}on(e,t){return this._s.on(e,t)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSurveysLoaded(e){return this.surveys.onSurveysLoaded(e)}onSessionId(e){var t,n;return(t=(n=this.sessionManager)==null?void 0:n.onSessionId(e))!==null&&t!==void 0?t:()=>{}}getSurveys(e,t){t===void 0&&(t=!1),this.surveys.getSurveys(e,t)}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys.getActiveMatchingSurveys(e,t)}renderSurvey(e,t){this.surveys.renderSurvey(e,t)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,t){return t===void 0&&(t=!1),this.surveys.canRenderSurveyAsync(e,t)}identify(e,t,n){if(!this.__loaded||!this.persistence)return bu.uninitializedWarning("posthog.identify");if(q_(e)&&(e=e.toString(),bu.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),e)if(["distinct_id","distinctid"].includes(e.toLowerCase()))bu.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.');else if(e!==gP){if(this.Ls("posthog.identify")){var i=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var o=i;this.register_once({$had_persisted_distinct_id:!0,$device_id:o},"")}e!==i&&e!==this.get_property(y3)&&(this.unregister(y3),this.register({distinct_id:e}));var a=(this.persistence.get_property($S)||"anonymous")==="anonymous";e!==i&&a?(this.persistence.set_property($S,"identified"),this.setPersonPropertiesForFlags(Wc({},n||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:i},{$set:t||{},$set_once:n||{}}),this.Ss=_he(e,t,n),this.featureFlags.setAnonymousDistinctId(i)):(t||n)&&this.setPersonProperties(t,n),e!==i&&(this.reloadFeatureFlags(),this.unregister(fP))}}else bu.critical('The string "'+gP+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else bu.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,t){if((e||t)&&this.Ls("posthog.setPersonProperties")){var n=_he(this.get_distinct_id(),e,t);this.Ss!==n?(this.setPersonPropertiesForFlags(Wc({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.Ss=n):bu.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,n){if(e&&t){if(this.Ls("posthog.group")){var i=this.getGroups();i[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:Wc({},i,{[e]:t})}),n&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:n}),this.setGroupPropertiesForFlags({[e]:n})),i[e]===t||n||this.reloadFeatureFlags()}}else bu.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0),this.featureFlags.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0),this.Ls("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,t)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var t,n,i,o;if(bu.info("reset"),!this.__loaded)return bu.uninitializedWarning("posthog.reset");var a=this.get_property("$device_id");if(this.consent.reset(),(t=this.persistence)==null||t.clear(),(n=this.sessionPersistence)==null||n.clear(),this.surveys.reset(),this.featureFlags.reset(),(i=this.persistence)==null||i.set_property($S,"anonymous"),(o=this.sessionManager)==null||o.resetSessionId(),this.Ss=null,this.config.__preview_experimental_cookieless_mode)this.register_once({distinct_id:gP,$device_id:null},"");else{var s=this.config.get_device_id(aQ());this.register_once({distinct_id:s,$device_id:e?s:a},"")}this.register({$last_posthog_reset:new Date().toISOString()},1)}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return(e=(t=this.sessionManager)==null?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:t,sessionStartTimestamp:n}=this.sessionManager.checkAndGetSessionAndWindowId(!0),i=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);if(e!=null&&e.withTimestamp&&n){var o,a=(o=e.timestampLookBack)!==null&&o!==void 0?o:10;if(!n)return i;i+="?t="+Math.max(Math.floor((new Date().getTime()-n)/1e3)-a,0)}return i}alias(e,t){return e===this.get_property(cfe)?(bu.critical("Attempting to create alias for existing People user - aborting."),-2):this.Ls("posthog.alias")?(dc(t)&&(t=this.get_distinct_id()),e!==t?(this.js(y3,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(bu.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=Wc({},this.config);if(TC(e)){var n,i,o,a,s;u1(this.config,cpe(e));var l=this.xs();(n=this.persistence)==null||n.update_config(this.config,t,l),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new IH(Wc({},this.config,{persistence:"sessionStorage"}),l),rE.O()&&rE.D("ph_debug")==="true"&&(this.config.debug=!0),this.config.debug&&(ZS.DEBUG=!0,bu.info("set_config",{config:e,oldConfig:t,newConfig:Wc({},this.config)})),(i=this.sessionRecording)==null||i.startIfEnabledOrStop(),(o=this.autocapture)==null||o.startIfEnabled(),(a=this.heatmaps)==null||a.startIfEnabled(),this.surveys.loadIfEnabled(),this.Ns(),(s=this.externalIntegrations)==null||s.startIfEnabledOrStop()}}startSessionRecording(e){var t=e===!0,n={sampling:t||!(e==null||!e.sampling),linked_flag:t||!(e==null||!e.linked_flag),url_trigger:t||!(e==null||!e.url_trigger),event_trigger:t||!(e==null||!e.event_trigger)};if(Object.values(n).some(Boolean)){var i,o,a,s,l;(i=this.sessionManager)==null||i.checkAndGetSessionAndWindowId(),n.sampling&&((o=this.sessionRecording)==null||o.overrideSampling()),n.linked_flag&&((a=this.sessionRecording)==null||a.overrideLinkedFlag()),n.url_trigger&&((s=this.sessionRecording)==null||s.overrideTrigger("url")),n.event_trigger&&((l=this.sessionRecording)==null||l.overrideTrigger("event"))}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,t){var n=new Error("PostHog syntheticException");return this.exceptions.sendExceptionEvent(Wc({},SJe((i=>i instanceof Error)(e)?{error:e,event:e.message}:{event:e},{syntheticException:n}),t))}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var t;return(t=this.persistence)==null?void 0:t.props[e]}getSessionProperty(e){var t;return(t=this.sessionPersistence)==null?void 0:t.props[e]}toString(){var e,t=(e=this.config.name)!==null&&e!==void 0?e:RM;return t!==RM&&(t=RM+"."+t),t}_isIdentified(){var e,t;return((e=this.persistence)==null?void 0:e.get_property($S))==="identified"||((t=this.sessionPersistence)==null?void 0:t.get_property($S))==="identified"}Ds(){var e,t;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&IM(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[y3])&&((t=this.persistence)==null||(t=t.props)==null||!t[pP]))}Fs(){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.Ds()||this.Ls("posthog.createPersonProfile")&&this.setPersonProperties({},{})}Ls(e){return this.config.person_profiles==="never"?(bu.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.js(pP,!0),!0)}xs(){var e=this.consent.isOptedOut(),t=this.config.opt_out_persistence_by_default;return this.config.disable_persistence||e&&!!t}Ns(){var e,t,n,i,o=this.xs();return((e=this.persistence)==null?void 0:e.Fe)!==o&&((n=this.persistence)==null||n.set_disabled(o)),((t=this.sessionPersistence)==null?void 0:t.Fe)!==o&&((i=this.sessionPersistence)==null||i.set_disabled(o)),o}opt_in_capturing(e){var t;this.consent.optInOut(!0),this.Ns(),(dc(e==null?void 0:e.captureEventName)||e!=null&&e.captureEventName)&&this.capture((t=e==null?void 0:e.captureEventName)!==null&&t!==void 0?t:"$opt_in",e==null?void 0:e.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Cs()}opt_out_capturing(){this.consent.optInOut(!1),this.Ns()}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}clear_opt_in_out_capturing(){this.consent.reset(),this.Ns()}_is_bot(){return _B?ope(_B,this.config.custom_blocked_useragents):void 0}Cs(){Au&&(Au.visibilityState==="visible"?this.bs||(this.bs=!0,this.capture("$pageview",{title:Au.title},{send_instantly:!0}),this.ys&&(Au.removeEventListener("visibilitychange",this.ys),this.ys=null)):this.ys||(this.ys=this.Cs.bind(this),oC(Au,"visibilitychange",this.ys)))}debug(e){e===!1?(xo==null||xo.console.log("You've disabled debug mode."),localStorage&&localStorage.removeItem("ph_debug"),this.set_config({debug:!1})):(xo==null||xo.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)`."),localStorage&&localStorage.setItem("ph_debug","true"),this.set_config({debug:!0}))}I(){var e,t,n,i,o,a,s,l=this.$s||{};return"advanced_disable_flags"in l?!!l.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(bu.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(n="advanced_disable_decide",i=!1,o=bu,a=(t="advanced_disable_flags")in(e=l)&&!dc(e[t]),s=n in e&&!dc(e[n]),a?e[t]:s?(o&&o.warn("Config field '"+n+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[n]):i)}As(e){if(Um(this.config.before_send))return e;var t=OI(this.config.before_send)?this.config.before_send:[this.config.before_send],n=e;for(var i of t){if(n=i(n),Um(n)){var o="Event '"+e.event+"' was rejected in beforeSend function";return Fje(e.event)?bu.warn(o+". This can cause unexpected behavior."):bu.info(o),null}n.properties&&!IM(n.properties)||bu.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return n}getPageViewId(){var e;return(e=this.pageViewManager.ce)==null?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,n){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(n)})}}(function(r,e){for(var t=0;t<e.length;t++)r.prototype[e[t]]=Gje(r.prototype[e[t]])})(LP,["identify"]);var upe,GP=(upe=k3[RM]=new LP,function(){function r(){r.done||(r.done=!0,spe=!1,av(k3,function(e){e._dom_loaded()}))}Au!=null&&Au.addEventListener?Au.readyState==="complete"?r():oC(Au,"DOMContentLoaded",r,{capture:!1}):xo&&bu.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),upe);!window.location.hostname.includes("localhost")&&!window.location.hostname.includes("127.0.0.1")&&(GP.__loaded||GP.init("phc_htd8AQjSfVEsFCLQMAiUooG4Q0DKBCjqYuQglc9V3Wo",{api_host:"https://postpig.tscircuit.com",person_profiles:"always"}));function eqe(r){let e="";const t=r.byteLength;for(let n=0;n<t;n++)e+=String.fromCharCode(r[n]);return btoa(e)}var BB=Uint8Array,bB=Uint16Array,BH=Int32Array,bH=new BB([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]),SH=new BB([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]),Ape=new BB([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),dpe=function(r,e){for(var t=new bB(31),n=0;n<31;++n)t[n]=e+=1<<r[n-1];for(var i=new BH(t[30]),n=1;n<30;++n)for(var o=t[n];o<t[n+1];++o)i[o]=o-t[n]<<5|n;return{b:t,r:i}},fpe=dpe(bH,2),tqe=fpe.b,wH=fpe.r;tqe[28]=258,wH[258]=28;for(var nqe=dpe(SH,0),hpe=nqe.r,QH=new bB(32768),BI=0;BI<32768;++BI){var AQ=(BI&43690)>>1|(BI&21845)<<1;AQ=(AQ&52428)>>2|(AQ&13107)<<2,AQ=(AQ&61680)>>4|(AQ&3855)<<4,QH[BI]=((AQ&65280)>>8|(AQ&255)<<8)>>1}for(var U3=function(r,e,t){for(var n=r.length,i=0,o=new bB(e);i<n;++i)r[i]&&++o[r[i]-1];var a=new bB(e);for(i=1;i<e;++i)a[i]=a[i-1]+o[i-1]<<1;var s;if(t){s=new bB(1<<e);var l=15-e;for(i=0;i<n;++i)if(r[i])for(var c=i<<4|r[i],u=e-r[i],A=a[r[i]-1]++<<u,d=A|(1<<u)-1;A<=d;++A)s[QH[A]>>l]=c}else for(s=new bB(n),i=0;i<n;++i)r[i]&&(s[i]=QH[a[r[i]-1]++]>>15-r[i]);return s},_2=new BB(288),BI=0;BI<144;++BI)_2[BI]=8;for(var BI=144;BI<256;++BI)_2[BI]=9;for(var BI=256;BI<280;++BI)_2[BI]=7;for(var BI=280;BI<288;++BI)_2[BI]=8;for(var OP=new BB(32),BI=0;BI<32;++BI)OP[BI]=5;var rqe=U3(_2,9,0),iqe=U3(OP,5,0),ppe=function(r){return(r+7)/8|0},gpe=function(r,e,t){return(t==null||t>r.length)&&(t=r.length),new BB(r.subarray(e,t))},nw=function(r,e,t){t<<=e&7;var n=e/8|0;r[n]|=t,r[n+1]|=t>>8},F3=function(r,e,t){t<<=e&7;var n=e/8|0;r[n]|=t,r[n+1]|=t>>8,r[n+2]|=t>>16},MH=function(r,e){for(var t=[],n=0;n<r.length;++n)r[n]&&t.push({s:n,f:r[n]});var i=t.length,o=t.slice();if(!i)return{t:Ipe,l:0};if(i==1){var a=new BB(t[0].s+1);return a[t[0].s]=1,{t:a,l:1}}t.sort(function(L,O){return L.f-O.f}),t.push({s:-1,f:25001});var s=t[0],l=t[1],c=0,u=1,A=2;for(t[0]={s:-1,f:s.f+l.f,l:s,r:l};u!=i-1;)s=t[t[c].f<t[A].f?c++:A++],l=t[c!=u&&t[c].f<t[A].f?c++:A++],t[u++]={s:-1,f:s.f+l.f,l:s,r:l};for(var d=o[0].s,n=1;n<i;++n)o[n].s>d&&(d=o[n].s);var f=new bB(d+1),m=DH(t[u-1],f,0);if(m>e){var n=0,C=0,E=m-e,_=1<<E;for(o.sort(function(O,H){return f[H.s]-f[O.s]||O.f-H.f});n<i;++n){var x=o[n].s;if(f[x]>e)C+=_-(1<<m-f[x]),f[x]=e;else break}for(C>>=E;C>0;){var w=o[n].s;f[w]<e?C-=1<<e-f[w]++-1:++n}for(;n>=0&&C;--n){var P=o[n].s;f[P]==e&&(--f[P],++C)}m=e}return{t:new BB(f),l:m}},DH=function(r,e,t){return r.s==-1?Math.max(DH(r.l,e,t+1),DH(r.r,e,t+1)):e[r.s]=t},mpe=function(r){for(var e=r.length;e&&!r[--e];);for(var t=new bB(++e),n=0,i=r[0],o=1,a=function(l){t[n++]=l},s=1;s<=e;++s)if(r[s]==i&&s!=e)++o;else{if(!i&&o>2){for(;o>138;o-=138)a(32754);o>2&&(a(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(a(i),--o;o>6;o-=6)a(8304);o>2&&(a(o-3<<5|8208),o=0)}for(;o--;)a(i);o=1,i=r[s]}return{c:t.subarray(0,n),n:e}},L3=function(r,e){for(var t=0,n=0;n<e.length;++n)t+=r[n]*e[n];return t},ype=function(r,e,t){var n=t.length,i=ppe(e+2);r[i]=n&255,r[i+1]=n>>8,r[i+2]=r[i]^255,r[i+3]=r[i+1]^255;for(var o=0;o<n;++o)r[i+o+4]=t[o];return(i+4+n)*8},vpe=function(r,e,t,n,i,o,a,s,l,c,u){nw(e,u++,t),++i[256];for(var A=MH(i,15),d=A.t,f=A.l,m=MH(o,15),C=m.t,E=m.l,_=mpe(d),x=_.c,w=_.n,P=mpe(C),L=P.c,O=P.n,H=new bB(19),K=0;K<x.length;++K)++H[x[K]&31];for(var K=0;K<L.length;++K)++H[L[K]&31];for(var q=MH(H,7),Y=q.t,se=q.l,ie=19;ie>4&&!Y[Ape[ie-1]];--ie);var de=c+5<<3,Ce=L3(i,_2)+L3(o,OP)+a,xe=L3(i,d)+L3(o,C)+a+14+3*ie+L3(H,Y)+2*H[16]+3*H[17]+7*H[18];if(l>=0&&de<=Ce&&de<=xe)return ype(e,u,r.subarray(l,l+c));var fe,Ie,ve,Qe;if(nw(e,u,1+(xe<Ce)),u+=2,xe<Ce){fe=U3(d,f,0),Ie=d,ve=U3(C,E,0),Qe=C;var De=U3(Y,se,0);nw(e,u,w-257),nw(e,u+5,O-1),nw(e,u+10,ie-4),u+=14;for(var K=0;K<ie;++K)nw(e,u+3*K,Y[Ape[K]]);u+=3*ie;for(var Fe=[x,L],Ne=0;Ne<2;++Ne)for(var rt=Fe[Ne],K=0;K<rt.length;++K){var et=rt[K]&31;nw(e,u,De[et]),u+=Y[et],et>15&&(nw(e,u,rt[K]>>5&127),u+=rt[K]>>12)}}else fe=rqe,Ie=_2,ve=iqe,Qe=OP;for(var K=0;K<s;++K){var ft=n[K];if(ft>255){var et=ft>>18&31;F3(e,u,fe[et+257]),u+=Ie[et+257],et>7&&(nw(e,u,ft>>23&31),u+=bH[et]);var _t=ft&31;F3(e,u,ve[_t]),u+=Qe[_t],_t>3&&(F3(e,u,ft>>5&8191),u+=SH[_t])}else F3(e,u,fe[ft]),u+=Ie[ft]}return F3(e,u,fe[256]),u+Ie[256]},oqe=new BH([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ipe=new BB(0),aqe=function(r,e,t,n,i,o){var a=o.z||r.length,s=new BB(n+a+5*(1+Math.ceil(a/7e3))+i),l=s.subarray(n,s.length-i),c=o.l,u=(o.r||0)&7;if(e){u&&(l[0]=o.r>>3);for(var A=oqe[e-1],d=A>>13,f=A&8191,m=(1<<t)-1,C=o.p||new bB(32768),E=o.h||new bB(m+1),_=Math.ceil(t/3),x=2*_,w=function(kt){return(r[kt]^r[kt+1]<<_^r[kt+2]<<x)&m},P=new BH(25e3),L=new bB(288),O=new bB(32),H=0,K=0,q=o.i||0,Y=0,se=o.w||0,ie=0;q+2<a;++q){var de=w(q),Ce=q&32767,xe=E[de];if(C[Ce]=xe,E[de]=Ce,se<=q){var fe=a-q;if((H>7e3||Y>24576)&&(fe>423||!c)){u=vpe(r,l,0,P,L,O,K,Y,ie,q-ie,u),Y=H=K=0,ie=q;for(var Ie=0;Ie<286;++Ie)L[Ie]=0;for(var Ie=0;Ie<30;++Ie)O[Ie]=0}var ve=2,Qe=0,De=f,Fe=Ce-xe&32767;if(fe>2&&de==w(q-Fe))for(var Ne=Math.min(d,fe)-1,rt=Math.min(32767,q),et=Math.min(258,fe);Fe<=rt&&--De&&Ce!=xe;){if(r[q+ve]==r[q+ve-Fe]){for(var ft=0;ft<et&&r[q+ft]==r[q+ft-Fe];++ft);if(ft>ve){if(ve=ft,Qe=Fe,ft>Ne)break;for(var _t=Math.min(Fe,ft-2),Ft=0,Ie=0;Ie<_t;++Ie){var Lt=q-Fe+Ie&32767,tt=C[Lt],xt=Lt-tt&32767;xt>Ft&&(Ft=xt,xe=Lt)}}}Ce=xe,xe=C[Ce],Fe+=Ce-xe&32767}if(Qe){P[Y++]=268435456|wH[ve]<<18|hpe[Qe];var vt=wH[ve]&31,Ht=hpe[Qe]&31;K+=bH[vt]+SH[Ht],++L[257+vt],++O[Ht],se=q+ve,++H}else P[Y++]=r[q],++L[r[q]]}}for(q=Math.max(q,se);q<a;++q)P[Y++]=r[q],++L[r[q]];u=vpe(r,l,c,P,L,O,K,Y,ie,q-ie,u),c||(o.r=u&7|l[u/8|0]<<3,u-=7,o.h=E,o.p=C,o.i=q,o.w=se)}else{for(var q=o.w||0;q<a+c;q+=65535){var en=q+65535;en>=a&&(l[u/8|0]=c,en=a),u=ype(l,u+1,r.subarray(q,en))}o.i=a}return gpe(s,0,n+ppe(u)+i)},sqe=function(){for(var r=new Int32Array(256),e=0;e<256;++e){for(var t=e,n=9;--n;)t=(t&1&&-306674912)^t>>>1;r[e]=t}return r}(),lqe=function(){var r=-1;return{p:function(e){for(var t=r,n=0;n<e.length;++n)t=sqe[t&255^e[n]]^t>>>8;r=t},d:function(){return~r}}},cqe=function(r,e,t,n,i){if(!i&&(i={l:1},e.dictionary)){var o=e.dictionary.subarray(-32768),a=new BB(o.length+r.length);a.set(o),a.set(r,o.length),r=a,i.w=o.length}return aqe(r,e.level==null?6:e.level,e.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(r.length)))*1.5):20:12+e.mem,t,n,i)},RH=function(r,e,t){for(;t;++e)r[e]=t,t>>>=8},uqe=function(r,e){var t=e.filename;if(r[0]=31,r[1]=139,r[2]=8,r[8]=e.level<2?4:e.level==9?2:0,r[9]=3,e.mtime!=0&&RH(r,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),t){r[3]=8;for(var n=0;n<=t.length;++n)r[n+10]=t.charCodeAt(n)}},Aqe=function(r){return 10+(r.filename?r.filename.length+1:0)};function Cpe(r,e){e||(e={});var t=lqe(),n=r.length;t.p(r);var i=cqe(r,e,Aqe(e),8),o=i.length;return uqe(i,e),RH(i,o-8,t.d()),RH(i,o-4,n),i}var Epe=typeof TextEncoder<"u"&&new TextEncoder,dqe=typeof TextDecoder<"u"&&new TextDecoder,fqe=0;try{dqe.decode(Ipe,{stream:!0}),fqe=1}catch{}function _pe(r,e){var t;if(Epe)return Epe.encode(r);for(var n=r.length,i=new BB(r.length+(r.length>>1)),o=0,a=function(c){i[o++]=c},t=0;t<n;++t){if(o+5>i.length){var s=new BB(o+8+(n-t<<1));s.set(i),i=s}var l=r.charCodeAt(t);l<128||e?a(l):l<2048?(a(192|l>>6),a(128|l&63)):l>55295&&l<57344?(l=65536+(l&1047552)|r.charCodeAt(++t)&1023,a(240|l>>18),a(128|l>>12&63),a(128|l>>6&63),a(128|l&63)):(a(224|l>>12),a(128|l>>6&63),a(128|l&63))}return gpe(i,0,o)}function hqe(r,e){const t=JSON.stringify(r),n=Cpe(_pe(t)),i=eqe(n);return`${window.location.origin}/editor?#data:application/gzip;base64,${i}`}function nI(...r){return Nje(qb(r))}const xpe=r=>r.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()),pqe=nje,Bpe=pt.forwardRef(({className:r,...e},t)=>ut.jsx(Ode,{ref:t,className:nI("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",r),...e}));Bpe.displayName=Ode.displayName;const NM=pt.forwardRef(({className:r,...e},t)=>ut.jsx(zde,{ref:t,className:nI("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",r),...e}));NM.displayName=zde.displayName;const rS=pt.forwardRef(({className:r,...e},t)=>ut.jsx(Hde,{ref:t,className:nI("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",r),...e}));rS.displayName=Hde.displayName;var Am;(function(r){r.assertEqual=i=>{};function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{const o={};for(const a of i)o[a]=a;return o},r.getValidEnumValues=i=>{const o=r.objectKeys(i).filter(s=>typeof i[i[s]]!="number"),a={};for(const s of o)a[s]=i[s];return r.objectValues(a)},r.objectValues=i=>r.objectKeys(i).map(function(o){return i[o]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const o=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&o.push(a);return o},r.find=(i,o)=>{for(const a of i)if(o(a))return a},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function n(i,o=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(o)}r.joinValues=n,r.jsonStringifyReplacer=(i,o)=>typeof o=="bigint"?o.toString():o})(Am||(Am={}));var bpe;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(bpe||(bpe={}));const du=Am.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),dQ=r=>{switch(typeof r){case"undefined":return du.undefined;case"string":return du.string;case"number":return Number.isNaN(r)?du.nan:du.number;case"boolean":return du.boolean;case"function":return du.function;case"bigint":return du.bigint;case"symbol":return du.symbol;case"object":return Array.isArray(r)?du.array:r===null?du.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?du.promise:typeof Map<"u"&&r instanceof Map?du.map:typeof Set<"u"&&r instanceof Set?du.set:typeof Date<"u"&&r instanceof Date?du.date:du.object;default:return du.unknown}},Is=Am.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);let iS=class AVe extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(o){return o.message},n={_errors:[]},i=o=>{for(const a of o.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else{let s=n,l=0;for(;l<a.path.length;){const c=a.path[l];l===a.path.length-1?(s[c]=s[c]||{_errors:[]},s[c]._errors.push(t(a))):s[c]=s[c]||{_errors:[]},s=s[c],l++}}};return i(this),n}static assert(e){if(!(e instanceof AVe))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Am.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const i of this.issues)if(i.path.length>0){const o=i.path[0];t[o]=t[o]||[],t[o].push(e(i))}else n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};iS.create=r=>new iS(r);const G3=(r,e)=>{let t;switch(r.code){case Is.invalid_type:r.received===du.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case Is.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Am.jsonStringifyReplacer)}`;break;case Is.unrecognized_keys:t=`Unrecognized key(s) in object: ${Am.joinValues(r.keys,", ")}`;break;case Is.invalid_union:t="Invalid input";break;case Is.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Am.joinValues(r.options)}`;break;case Is.invalid_enum_value:t=`Invalid enum value. Expected ${Am.joinValues(r.options)}, received '${r.received}'`;break;case Is.invalid_arguments:t="Invalid function arguments";break;case Is.invalid_return_type:t="Invalid function return type";break;case Is.invalid_date:t="Invalid date";break;case Is.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:Am.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case Is.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="bigint"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case Is.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case Is.custom:t="Invalid input";break;case Is.invalid_intersection_types:t="Intersection results could not be merged";break;case Is.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case Is.not_finite:t="Number must be finite";break;default:t=e.defaultError,Am.assertNever(r)}return{message:t}};let gqe=G3;function NH(){return gqe}const TH=r=>{const{data:e,path:t,errorMaps:n,issueData:i}=r,o=[...t,...i.path||[]],a={...i,path:o};if(i.message!==void 0)return{...i,path:o,message:i.message};let s="";const l=n.filter(c=>!!c).slice().reverse();for(const c of l)s=c(a,{data:e,defaultError:s}).message;return{...i,path:o,message:s}};function Mc(r,e){const t=NH(),n=TH({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===G3?void 0:G3].filter(i=>!!i)});r.common.issues.push(n)}let SB=class dVe{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const i of t){if(i.status==="aborted")return Nf;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const i of t){const o=await i.key,a=await i.value;n.push({key:o,value:a})}return dVe.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:o,value:a}=i;if(o.status==="aborted"||a.status==="aborted")return Nf;o.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),o.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(n[o.value]=a.value)}return{status:e.value,value:n}}};const Nf=Object.freeze({status:"aborted"}),O3=r=>({status:"dirty",value:r}),Xx=r=>({status:"valid",value:r}),Spe=r=>r.status==="aborted",wpe=r=>r.status==="dirty",TM=r=>r.status==="valid",zP=r=>typeof Promise<"u"&&r instanceof Promise;var MA;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(MA||(MA={}));let oS=class{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};const Qpe=(r,e)=>{if(TM(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new iS(r.common.issues);return this._error=t,this._error}}};function Tp(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(a,s)=>{const{message:l}=r;return a.code==="invalid_enum_value"?{message:l??s.defaultError}:typeof s.data>"u"?{message:l??n??s.defaultError}:a.code!=="invalid_type"?{message:s.defaultError}:{message:l??t??s.defaultError}},description:i}}let qg=class{get description(){return this._def.description}_getType(e){return dQ(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:dQ(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new SB,ctx:{common:e.parent.common,data:e.data,parsedType:dQ(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(zP(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){const n={common:{issues:[],async:(t==null?void 0:t.async)??!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:dQ(e)},i=this._parseSync({data:e,path:n.path,parent:n});return Qpe(n,i)}"~validate"(e){var n,i;const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:dQ(e)};if(!this["~standard"].async)try{const o=this._parseSync({data:e,path:[],parent:t});return TM(o)?{value:o.value}:{issues:t.common.issues}}catch(o){(i=(n=o==null?void 0:o.message)==null?void 0:n.toLowerCase())!=null&&i.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(o=>TM(o)?{value:o.value}:{issues:t.common.issues})}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:dQ(e)},i=this._parse({data:e,path:n.path,parent:n}),o=await(zP(i)?i:Promise.resolve(i));return Qpe(n,o)}refine(e,t){const n=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,o)=>{const a=e(i),s=()=>o.addIssue({code:Is.custom,...n(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(l=>l?!0:(s(),!1)):a?!0:(s(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new B2({schema:this,typeName:Kf.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return ow.create(this,this._def)}nullable(){return b2.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return kM.create(this)}promise(){return H3.create(this,this._def)}or(e){return VP.create([this,e],this._def)}and(e){return KP.create(this,e,this._def)}transform(e){return new B2({...Tp(this._def),schema:this,typeName:Kf.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new WP({...Tp(this._def),innerType:this,defaultValue:t,typeName:Kf.ZodDefault})}brand(){return new Gpe({typeName:Kf.ZodBranded,type:this,...Tp(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new qP({...Tp(this._def),innerType:this,catchValue:t,typeName:Kf.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return zqe.create(this,e)}readonly(){return ZP.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const mqe=/^c[^\s-]{8,}$/i,yqe=/^[0-9a-z]+$/,vqe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Iqe=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Cqe=/^[a-z0-9_-]{21}$/i,Eqe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,_qe=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,xqe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Bqe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let PH;const bqe=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Sqe=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,wqe=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Qqe=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Mqe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Dqe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Mpe="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Rqe=new RegExp(`^${Mpe}$`);function Dpe(r){let e="[0-5]\\d";r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`);const t=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function Nqe(r){return new RegExp(`^${Dpe(r)}$`)}function Tqe(r){let e=`${Mpe}T${Dpe(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Pqe(r,e){return!!((e==="v4"||!e)&&bqe.test(r)||(e==="v6"||!e)&&wqe.test(r))}function kqe(r,e){if(!Eqe.test(r))return!1;try{const[t]=r.split(".");if(!t)return!1;const n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),i=JSON.parse(atob(n));return!(typeof i!="object"||i===null||"typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||e&&i.alg!==e)}catch{return!1}}function Uqe(r,e){return!!((e==="v4"||!e)&&Sqe.test(r)||(e==="v6"||!e)&&Qqe.test(r))}let HP=class J4 extends qg{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==du.string){const o=this._getOrReturnCtx(e);return Mc(o,{code:Is.invalid_type,expected:du.string,received:o.parsedType}),Nf}const n=new SB;let i;for(const o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(i=this._getOrReturnCtx(e,i),Mc(i,{code:Is.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="max")e.data.length>o.value&&(i=this._getOrReturnCtx(e,i),Mc(i,{code:Is.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="length"){const a=e.data.length>o.value,s=e.data.length<o.value;(a||s)&&(i=this._getOrReturnCtx(e,i),a?Mc(i,{code:Is.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):s&&Mc(i,{code:Is.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),n.dirty())}else if(o.kind==="email")xqe.test(e.data)||(i=this._getOrReturnCtx(e,i),Mc(i,{validation:"email",code:Is.invalid_string,message:o.message}),n.dirty());else if(o.kind==="emoji")PH||(PH=new RegExp(Bqe,"u")),PH.test(e.data)||(i=this._getOrReturnCtx(e,i),Mc(i,{validation:"emoji",code:Is.invalid_string,message:o.message}),n.dirty());else if(o.kind==="uuid")Iqe.test(e.data)||(i=this._getOrReturnCtx(e,i),Mc(i,{validation:"uuid",code:Is.invalid_string,message:o.message}),n.dirty());else if(o.kind==="nanoid")Cqe.test(e.data)||(i=this._getOrReturnCtx(e,i),Mc(i,{validation:"nanoid",code:Is.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid")mqe.test(e.data)||(i=this._getOrReturnCtx(e,i),Mc(i,{validation:"cuid",code:Is.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid2")yqe.test(e.data)||(i=this._getOrReturnCtx(e,i),Mc(i,{validation:"cuid2",code:Is.invalid_string,message:o.message}),n.dirty());else if(o.kind==="ulid")vqe.test(e.data)||(i=this._getOrReturnCtx(e,i),Mc(i,{validation:"ulid",code:Is.invalid_string,message:o.message}),n.dirty());else if(o.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),Mc(i,{validation:"url",code:Is.invalid_string,message:o.message}),n.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),Mc(i,{validation:"regex",code:Is.invalid_string,message:o.message}),n.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(i=this._getOrReturnCtx(e,i),Mc(i,{code:Is.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),n.dirty()):o.kind==="toLowerCase"?e.data=e.data.toLowerCase():o.kind==="toUpperCase"?e.data=e.data.toUpperCase():o.kind==="startsWith"?e.data.startsWith(o.value)||(i=this._getOrReturnCtx(e,i),Mc(i,{code:Is.invalid_string,validation:{startsWith:o.value},message:o.message}),n.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(i=this._getOrReturnCtx(e,i),Mc(i,{code:Is.invalid_string,validation:{endsWith:o.value},message:o.message}),n.dirty()):o.kind==="datetime"?Tqe(o).test(e.data)||(i=this._getOrReturnCtx(e,i),Mc(i,{code:Is.invalid_string,validation:"datetime",message:o.message}),n.dirty()):o.kind==="date"?Rqe.test(e.data)||(i=this._getOrReturnCtx(e,i),Mc(i,{code:Is.invalid_string,validation:"date",message:o.message}),n.dirty()):o.kind==="time"?Nqe(o).test(e.data)||(i=this._getOrReturnCtx(e,i),Mc(i,{code:Is.invalid_string,validation:"time",message:o.message}),n.dirty()):o.kind==="duration"?_qe.test(e.data)||(i=this._getOrReturnCtx(e,i),Mc(i,{validation:"duration",code:Is.invalid_string,message:o.message}),n.dirty()):o.kind==="ip"?Pqe(e.data,o.version)||(i=this._getOrReturnCtx(e,i),Mc(i,{validation:"ip",code:Is.invalid_string,message:o.message}),n.dirty()):o.kind==="jwt"?kqe(e.data,o.alg)||(i=this._getOrReturnCtx(e,i),Mc(i,{validation:"jwt",code:Is.invalid_string,message:o.message}),n.dirty()):o.kind==="cidr"?Uqe(e.data,o.version)||(i=this._getOrReturnCtx(e,i),Mc(i,{validation:"cidr",code:Is.invalid_string,message:o.message}),n.dirty()):o.kind==="base64"?Mqe.test(e.data)||(i=this._getOrReturnCtx(e,i),Mc(i,{validation:"base64",code:Is.invalid_string,message:o.message}),n.dirty()):o.kind==="base64url"?Dqe.test(e.data)||(i=this._getOrReturnCtx(e,i),Mc(i,{validation:"base64url",code:Is.invalid_string,message:o.message}),n.dirty()):Am.assertNever(o);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:Is.invalid_string,...MA.errToObj(n)})}_addCheck(e){return new J4({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...MA.errToObj(e)})}url(e){return this._addCheck({kind:"url",...MA.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...MA.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...MA.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...MA.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...MA.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...MA.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...MA.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...MA.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...MA.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...MA.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...MA.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...MA.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...MA.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...MA.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...MA.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...MA.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...MA.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...MA.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...MA.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...MA.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...MA.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...MA.errToObj(t)})}nonempty(e){return this.min(1,MA.errToObj(e))}trim(){return new J4({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new J4({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new J4({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};HP.create=r=>new HP({checks:[],typeName:Kf.ZodString,coerce:(r==null?void 0:r.coerce)??!1,...Tp(r)});function Fqe(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,o=Number.parseInt(r.toFixed(i).replace(".","")),a=Number.parseInt(e.toFixed(i).replace(".",""));return o%a/10**i}let kH=class HAe extends qg{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==du.number){const o=this._getOrReturnCtx(e);return Mc(o,{code:Is.invalid_type,expected:du.number,received:o.parsedType}),Nf}let n;const i=new SB;for(const o of this._def.checks)o.kind==="int"?Am.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),Mc(n,{code:Is.invalid_type,expected:"integer",received:"float",message:o.message}),i.dirty()):o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),Mc(n,{code:Is.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),Mc(n,{code:Is.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="multipleOf"?Fqe(e.data,o.value)!==0&&(n=this._getOrReturnCtx(e,n),Mc(n,{code:Is.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),Mc(n,{code:Is.not_finite,message:o.message}),i.dirty()):Am.assertNever(o);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,MA.toString(t))}gt(e,t){return this.setLimit("min",e,!1,MA.toString(t))}lte(e,t){return this.setLimit("max",e,!0,MA.toString(t))}lt(e,t){return this.setLimit("max",e,!1,MA.toString(t))}setLimit(e,t,n,i){return new HAe({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:MA.toString(i)}]})}_addCheck(e){return new HAe({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:MA.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:MA.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:MA.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:MA.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:MA.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:MA.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:MA.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:MA.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:MA.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Am.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}};kH.create=r=>new kH({checks:[],typeName:Kf.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...Tp(r)});let Rpe=class YAe extends qg{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==du.bigint)return this._getInvalidInput(e);let n;const i=new SB;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),Mc(n,{code:Is.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),Mc(n,{code:Is.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),Mc(n,{code:Is.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):Am.assertNever(o);return{status:i.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return Mc(t,{code:Is.invalid_type,expected:du.bigint,received:t.parsedType}),Nf}gte(e,t){return this.setLimit("min",e,!0,MA.toString(t))}gt(e,t){return this.setLimit("min",e,!1,MA.toString(t))}lte(e,t){return this.setLimit("max",e,!0,MA.toString(t))}lt(e,t){return this.setLimit("max",e,!1,MA.toString(t))}setLimit(e,t,n,i){return new YAe({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:MA.toString(i)}]})}_addCheck(e){return new YAe({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:MA.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:MA.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:MA.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:MA.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:MA.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};Rpe.create=r=>new Rpe({checks:[],typeName:Kf.ZodBigInt,coerce:(r==null?void 0:r.coerce)??!1,...Tp(r)});let UH=class extends qg{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==du.boolean){const n=this._getOrReturnCtx(e);return Mc(n,{code:Is.invalid_type,expected:du.boolean,received:n.parsedType}),Nf}return Xx(e.data)}};UH.create=r=>new UH({typeName:Kf.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...Tp(r)});let Npe=class fVe extends qg{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==du.date){const o=this._getOrReturnCtx(e);return Mc(o,{code:Is.invalid_type,expected:du.date,received:o.parsedType}),Nf}if(Number.isNaN(e.data.getTime())){const o=this._getOrReturnCtx(e);return Mc(o,{code:Is.invalid_date}),Nf}const n=new SB;let i;for(const o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(i=this._getOrReturnCtx(e,i),Mc(i,{code:Is.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),n.dirty()):o.kind==="max"?e.data.getTime()>o.value&&(i=this._getOrReturnCtx(e,i),Mc(i,{code:Is.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):Am.assertNever(o);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new fVe({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:MA.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:MA.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};Npe.create=r=>new Npe({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:Kf.ZodDate,...Tp(r)});let Tpe=class extends qg{_parse(e){if(this._getType(e)!==du.symbol){const n=this._getOrReturnCtx(e);return Mc(n,{code:Is.invalid_type,expected:du.symbol,received:n.parsedType}),Nf}return Xx(e.data)}};Tpe.create=r=>new Tpe({typeName:Kf.ZodSymbol,...Tp(r)});let FH=class extends qg{_parse(e){if(this._getType(e)!==du.undefined){const n=this._getOrReturnCtx(e);return Mc(n,{code:Is.invalid_type,expected:du.undefined,received:n.parsedType}),Nf}return Xx(e.data)}};FH.create=r=>new FH({typeName:Kf.ZodUndefined,...Tp(r)});let YP=class extends qg{_parse(e){if(this._getType(e)!==du.null){const n=this._getOrReturnCtx(e);return Mc(n,{code:Is.invalid_type,expected:du.null,received:n.parsedType}),Nf}return Xx(e.data)}};YP.create=r=>new YP({typeName:Kf.ZodNull,...Tp(r)});let z3=class extends qg{constructor(){super(...arguments),this._any=!0}_parse(e){return Xx(e.data)}};z3.create=r=>new z3({typeName:Kf.ZodAny,...Tp(r)});let PM=class extends qg{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Xx(e.data)}};PM.create=r=>new PM({typeName:Kf.ZodUnknown,...Tp(r)});let fQ=class extends qg{_parse(e){const t=this._getOrReturnCtx(e);return Mc(t,{code:Is.invalid_type,expected:du.never,received:t.parsedType}),Nf}};fQ.create=r=>new fQ({typeName:Kf.ZodNever,...Tp(r)});let Ppe=class extends qg{_parse(e){if(this._getType(e)!==du.undefined){const n=this._getOrReturnCtx(e);return Mc(n,{code:Is.invalid_type,expected:du.void,received:n.parsedType}),Nf}return Xx(e.data)}};Ppe.create=r=>new Ppe({typeName:Kf.ZodVoid,...Tp(r)});let kM=class $O extends qg{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==du.array)return Mc(t,{code:Is.invalid_type,expected:du.array,received:t.parsedType}),Nf;if(i.exactLength!==null){const a=t.data.length>i.exactLength.value,s=t.data.length<i.exactLength.value;(a||s)&&(Mc(t,{code:a?Is.too_big:Is.too_small,minimum:s?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(Mc(t,{code:Is.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(Mc(t,{code:Is.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,s)=>i.type._parseAsync(new oS(t,a,t.path,s)))).then(a=>SB.mergeArray(n,a));const o=[...t.data].map((a,s)=>i.type._parseSync(new oS(t,a,t.path,s)));return SB.mergeArray(n,o)}get element(){return this._def.type}min(e,t){return new $O({...this._def,minLength:{value:e,message:MA.toString(t)}})}max(e,t){return new $O({...this._def,maxLength:{value:e,message:MA.toString(t)}})}length(e,t){return new $O({...this._def,exactLength:{value:e,message:MA.toString(t)}})}nonempty(e){return this.min(1,e)}};kM.create=(r,e)=>new kM({type:r,minLength:null,maxLength:null,exactLength:null,typeName:Kf.ZodArray,...Tp(e)});function UM(r){if(r instanceof rw){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=ow.create(UM(n))}return new rw({...r._def,shape:()=>e})}else return r instanceof kM?new kM({...r._def,type:UM(r.element)}):r instanceof ow?ow.create(UM(r.unwrap())):r instanceof b2?b2.create(UM(r.unwrap())):r instanceof x2?x2.create(r.items.map(e=>UM(e))):r}let rw=class jb extends qg{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=Am.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==du.object){const c=this._getOrReturnCtx(e);return Mc(c,{code:Is.invalid_type,expected:du.object,received:c.parsedType}),Nf}const{status:n,ctx:i}=this._processInputParams(e),{shape:o,keys:a}=this._getCached(),s=[];if(!(this._def.catchall instanceof fQ&&this._def.unknownKeys==="strip"))for(const c in i.data)a.includes(c)||s.push(c);const l=[];for(const c of a){const u=o[c],A=i.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new oS(i,A,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof fQ){const c=this._def.unknownKeys;if(c==="passthrough")for(const u of s)l.push({key:{status:"valid",value:u},value:{status:"valid",value:i.data[u]}});else if(c==="strict")s.length>0&&(Mc(i,{code:Is.unrecognized_keys,keys:s}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of s){const A=i.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new oS(i,A,i.path,u)),alwaysSet:u in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of l){const A=await u.key,d=await u.value;c.push({key:A,value:d,alwaysSet:u.alwaysSet})}return c}).then(c=>SB.mergeObjectSync(n,c)):SB.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(e){return MA.errToObj,new jb({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var o,a;const i=((a=(o=this._def).errorMap)==null?void 0:a.call(o,t,n).message)??n.defaultError;return t.code==="unrecognized_keys"?{message:MA.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new jb({...this._def,unknownKeys:"strip"})}passthrough(){return new jb({...this._def,unknownKeys:"passthrough"})}extend(e){return new jb({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new jb({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Kf.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new jb({...this._def,catchall:e})}pick(e){const t={};for(const n of Am.objectKeys(e))e[n]&&this.shape[n]&&(t[n]=this.shape[n]);return new jb({...this._def,shape:()=>t})}omit(e){const t={};for(const n of Am.objectKeys(this.shape))e[n]||(t[n]=this.shape[n]);return new jb({...this._def,shape:()=>t})}deepPartial(){return UM(this)}partial(e){const t={};for(const n of Am.objectKeys(this.shape)){const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}return new jb({...this._def,shape:()=>t})}required(e){const t={};for(const n of Am.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof ow;)o=o._def.innerType;t[n]=o}return new jb({...this._def,shape:()=>t})}keyof(){return Fpe(Am.objectKeys(this.shape))}};rw.create=(r,e)=>new rw({shape:()=>r,unknownKeys:"strip",catchall:fQ.create(),typeName:Kf.ZodObject,...Tp(e)}),rw.strictCreate=(r,e)=>new rw({shape:()=>r,unknownKeys:"strict",catchall:fQ.create(),typeName:Kf.ZodObject,...Tp(e)}),rw.lazycreate=(r,e)=>new rw({shape:r,unknownKeys:"strip",catchall:fQ.create(),typeName:Kf.ZodObject,...Tp(e)});let VP=class extends qg{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function i(o){for(const s of o)if(s.result.status==="valid")return s.result;for(const s of o)if(s.result.status==="dirty")return t.common.issues.push(...s.ctx.common.issues),s.result;const a=o.map(s=>new iS(s.ctx.common.issues));return Mc(t,{code:Is.invalid_union,unionErrors:a}),Nf}if(t.common.async)return Promise.all(n.map(async o=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await o._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(i);{let o;const a=[];for(const l of n){const c={...t,common:{...t.common,issues:[]},parent:null},u=l._parseSync({data:t.data,path:t.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!o&&(o={result:u,ctx:c}),c.common.issues.length&&a.push(c.common.issues)}if(o)return t.common.issues.push(...o.ctx.common.issues),o.result;const s=a.map(l=>new iS(l));return Mc(t,{code:Is.invalid_union,unionErrors:s}),Nf}}get options(){return this._def.options}};VP.create=(r,e)=>new VP({options:r,typeName:Kf.ZodUnion,...Tp(e)});const iw=r=>r instanceof GH?iw(r.schema):r instanceof B2?iw(r.innerType()):r instanceof jP?[r.value]:r instanceof JP?r.options:r instanceof OH?Am.objectValues(r.enum):r instanceof WP?iw(r._def.innerType):r instanceof FH?[void 0]:r instanceof YP?[null]:r instanceof ow?[void 0,...iw(r.unwrap())]:r instanceof b2?[null,...iw(r.unwrap())]:r instanceof Gpe||r instanceof ZP?iw(r.unwrap()):r instanceof qP?iw(r._def.innerType):[];let Lqe=class hVe extends qg{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==du.object)return Mc(t,{code:Is.invalid_type,expected:du.object,received:t.parsedType}),Nf;const n=this.discriminator,i=t.data[n],o=this.optionsMap.get(i);return o?t.common.async?o._parseAsync({data:t.data,path:t.path,parent:t}):o._parseSync({data:t.data,path:t.path,parent:t}):(Mc(t,{code:Is.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Nf)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const i=new Map;for(const o of t){const a=iw(o.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const s of a){if(i.has(s))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);i.set(s,o)}}return new hVe({typeName:Kf.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...Tp(n)})}};function LH(r,e){const t=dQ(r),n=dQ(e);if(r===e)return{valid:!0,data:r};if(t===du.object&&n===du.object){const i=Am.objectKeys(e),o=Am.objectKeys(r).filter(s=>i.indexOf(s)!==-1),a={...r,...e};for(const s of o){const l=LH(r[s],e[s]);if(!l.valid)return{valid:!1};a[s]=l.data}return{valid:!0,data:a}}else if(t===du.array&&n===du.array){if(r.length!==e.length)return{valid:!1};const i=[];for(let o=0;o<r.length;o++){const a=r[o],s=e[o],l=LH(a,s);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return t===du.date&&n===du.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}let KP=class extends qg{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(o,a)=>{if(Spe(o)||Spe(a))return Nf;const s=LH(o.value,a.value);return s.valid?((wpe(o)||wpe(a))&&t.dirty(),{status:t.value,value:s.data}):(Mc(n,{code:Is.invalid_intersection_types}),Nf)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([o,a])=>i(o,a)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};KP.create=(r,e,t)=>new KP({left:r,right:e,typeName:Kf.ZodIntersection,...Tp(t)});let x2=class pVe extends qg{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==du.array)return Mc(n,{code:Is.invalid_type,expected:du.array,received:n.parsedType}),Nf;if(n.data.length<this._def.items.length)return Mc(n,{code:Is.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Nf;!this._def.rest&&n.data.length>this._def.items.length&&(Mc(n,{code:Is.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const o=[...n.data].map((a,s)=>{const l=this._def.items[s]||this._def.rest;return l?l._parse(new oS(n,a,n.path,s)):null}).filter(a=>!!a);return n.common.async?Promise.all(o).then(a=>SB.mergeArray(t,a)):SB.mergeArray(t,o)}get items(){return this._def.items}rest(e){return new pVe({...this._def,rest:e})}};x2.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new x2({items:r,typeName:Kf.ZodTuple,rest:null,...Tp(e)})};let Gqe=class VAe extends qg{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==du.object)return Mc(n,{code:Is.invalid_type,expected:du.object,received:n.parsedType}),Nf;const i=[],o=this._def.keyType,a=this._def.valueType;for(const s in n.data)i.push({key:o._parse(new oS(n,s,n.path,s)),value:a._parse(new oS(n,n.data[s],n.path,s)),alwaysSet:s in n.data});return n.common.async?SB.mergeObjectAsync(t,i):SB.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof qg?new VAe({keyType:e,valueType:t,typeName:Kf.ZodRecord,...Tp(n)}):new VAe({keyType:HP.create(),valueType:e,typeName:Kf.ZodRecord,...Tp(t)})}},kpe=class extends qg{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==du.map)return Mc(n,{code:Is.invalid_type,expected:du.map,received:n.parsedType}),Nf;const i=this._def.keyType,o=this._def.valueType,a=[...n.data.entries()].map(([s,l],c)=>({key:i._parse(new oS(n,s,n.path,[c,"key"])),value:o._parse(new oS(n,l,n.path,[c,"value"]))}));if(n.common.async){const s=new Map;return Promise.resolve().then(async()=>{for(const l of a){const c=await l.key,u=await l.value;if(c.status==="aborted"||u.status==="aborted")return Nf;(c.status==="dirty"||u.status==="dirty")&&t.dirty(),s.set(c.value,u.value)}return{status:t.value,value:s}})}else{const s=new Map;for(const l of a){const c=l.key,u=l.value;if(c.status==="aborted"||u.status==="aborted")return Nf;(c.status==="dirty"||u.status==="dirty")&&t.dirty(),s.set(c.value,u.value)}return{status:t.value,value:s}}}};kpe.create=(r,e,t)=>new kpe({valueType:e,keyType:r,typeName:Kf.ZodMap,...Tp(t)});let Upe=class KAe extends qg{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==du.set)return Mc(n,{code:Is.invalid_type,expected:du.set,received:n.parsedType}),Nf;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(Mc(n,{code:Is.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(Mc(n,{code:Is.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const o=this._def.valueType;function a(l){const c=new Set;for(const u of l){if(u.status==="aborted")return Nf;u.status==="dirty"&&t.dirty(),c.add(u.value)}return{status:t.value,value:c}}const s=[...n.data.values()].map((l,c)=>o._parse(new oS(n,l,n.path,c)));return n.common.async?Promise.all(s).then(l=>a(l)):a(s)}min(e,t){return new KAe({...this._def,minSize:{value:e,message:MA.toString(t)}})}max(e,t){return new KAe({...this._def,maxSize:{value:e,message:MA.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Upe.create=(r,e)=>new Upe({valueType:r,minSize:null,maxSize:null,typeName:Kf.ZodSet,...Tp(e)});let Oqe=class ez extends qg{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==du.function)return Mc(t,{code:Is.invalid_type,expected:du.function,received:t.parsedType}),Nf;function n(s,l){return TH({data:s,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,NH(),G3].filter(c=>!!c),issueData:{code:Is.invalid_arguments,argumentsError:l}})}function i(s,l){return TH({data:s,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,NH(),G3].filter(c=>!!c),issueData:{code:Is.invalid_return_type,returnTypeError:l}})}const o={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof H3){const s=this;return Xx(async function(...l){const c=new iS([]),u=await s._def.args.parseAsync(l,o).catch(f=>{throw c.addIssue(n(l,f)),c}),A=await Reflect.apply(a,this,u);return await s._def.returns._def.type.parseAsync(A,o).catch(f=>{throw c.addIssue(i(A,f)),c})})}else{const s=this;return Xx(function(...l){const c=s._def.args.safeParse(l,o);if(!c.success)throw new iS([n(l,c.error)]);const u=Reflect.apply(a,this,c.data),A=s._def.returns.safeParse(u,o);if(!A.success)throw new iS([i(u,A.error)]);return A.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ez({...this._def,args:x2.create(e).rest(PM.create())})}returns(e){return new ez({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new ez({args:e||x2.create([]).rest(PM.create()),returns:t||PM.create(),typeName:Kf.ZodFunction,...Tp(n)})}},GH=class extends qg{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};GH.create=(r,e)=>new GH({getter:r,typeName:Kf.ZodLazy,...Tp(e)});let jP=class extends qg{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return Mc(t,{received:t.data,code:Is.invalid_literal,expected:this._def.value}),Nf}return{status:"valid",value:e.data}}get value(){return this._def.value}};jP.create=(r,e)=>new jP({value:r,typeName:Kf.ZodLiteral,...Tp(e)});function Fpe(r,e){return new JP({values:r,typeName:Kf.ZodEnum,...Tp(e)})}let JP=class jAe extends qg{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return Mc(t,{expected:Am.joinValues(n),received:t.parsedType,code:Is.invalid_type}),Nf}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return Mc(t,{received:t.data,code:Is.invalid_enum_value,options:n}),Nf}return Xx(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return jAe.create(e,{...this._def,...t})}exclude(e,t=this._def){return jAe.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};JP.create=Fpe;let OH=class extends qg{_parse(e){const t=Am.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==du.string&&n.parsedType!==du.number){const i=Am.objectValues(t);return Mc(n,{expected:Am.joinValues(i),received:n.parsedType,code:Is.invalid_type}),Nf}if(this._cache||(this._cache=new Set(Am.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const i=Am.objectValues(t);return Mc(n,{received:n.data,code:Is.invalid_enum_value,options:i}),Nf}return Xx(e.data)}get enum(){return this._def.values}};OH.create=(r,e)=>new OH({values:r,typeName:Kf.ZodNativeEnum,...Tp(e)});let H3=class extends qg{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==du.promise&&t.common.async===!1)return Mc(t,{code:Is.invalid_type,expected:du.promise,received:t.parsedType}),Nf;const n=t.parsedType===du.promise?t.data:Promise.resolve(t.data);return Xx(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}};H3.create=(r,e)=>new H3({type:r,typeName:Kf.ZodPromise,...Tp(e)});let B2=class extends qg{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Kf.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,o={addIssue:a=>{Mc(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),i.type==="preprocess"){const a=i.transform(n.data,o);if(n.common.async)return Promise.resolve(a).then(async s=>{if(t.value==="aborted")return Nf;const l=await this._def.schema._parseAsync({data:s,path:n.path,parent:n});return l.status==="aborted"?Nf:l.status==="dirty"||t.value==="dirty"?O3(l.value):l});{if(t.value==="aborted")return Nf;const s=this._def.schema._parseSync({data:a,path:n.path,parent:n});return s.status==="aborted"?Nf:s.status==="dirty"||t.value==="dirty"?O3(s.value):s}}if(i.type==="refinement"){const a=s=>{const l=i.refinement(s,o);if(n.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(n.common.async===!1){const s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?Nf:(s.status==="dirty"&&t.dirty(),a(s.value),{status:t.value,value:s.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>s.status==="aborted"?Nf:(s.status==="dirty"&&t.dirty(),a(s.value).then(()=>({status:t.value,value:s.value}))))}if(i.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!TM(a))return Nf;const s=i.transform(a.value,o);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:s}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>TM(a)?Promise.resolve(i.transform(a.value,o)).then(s=>({status:t.value,value:s})):Nf);Am.assertNever(i)}};B2.create=(r,e,t)=>new B2({schema:r,typeName:Kf.ZodEffects,effect:e,...Tp(t)}),B2.createWithPreprocess=(r,e,t)=>new B2({schema:e,effect:{type:"preprocess",transform:r},typeName:Kf.ZodEffects,...Tp(t)});let ow=class extends qg{_parse(e){return this._getType(e)===du.undefined?Xx(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ow.create=(r,e)=>new ow({innerType:r,typeName:Kf.ZodOptional,...Tp(e)});let b2=class extends qg{_parse(e){return this._getType(e)===du.null?Xx(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};b2.create=(r,e)=>new b2({innerType:r,typeName:Kf.ZodNullable,...Tp(e)});let WP=class extends qg{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===du.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};WP.create=(r,e)=>new WP({innerType:r,typeName:Kf.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Tp(e)});let qP=class extends qg{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return zP(i)?i.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new iS(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new iS(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};qP.create=(r,e)=>new qP({innerType:r,typeName:Kf.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Tp(e)});let Lpe=class extends qg{_parse(e){if(this._getType(e)!==du.nan){const n=this._getOrReturnCtx(e);return Mc(n,{code:Is.invalid_type,expected:du.nan,received:n.parsedType}),Nf}return{status:"valid",value:e.data}}};Lpe.create=r=>new Lpe({typeName:Kf.ZodNaN,...Tp(r)});let Gpe=class extends qg{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},zqe=class gVe extends qg{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const o=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?Nf:o.status==="dirty"?(t.dirty(),O3(o.value)):this._def.out._parseAsync({data:o.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?Nf:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new gVe({in:e,out:t,typeName:Kf.ZodPipeline})}},ZP=class extends qg{_parse(e){const t=this._def.innerType._parse(e),n=i=>(TM(i)&&(i.value=Object.freeze(i.value)),i);return zP(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}};ZP.create=(r,e)=>new ZP({innerType:r,typeName:Kf.ZodReadonly,...Tp(e)});function Ope(r,e){const t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function aS(r,e={},t){return r?z3.create().superRefine((n,i)=>{const o=r(n);if(o instanceof Promise)return o.then(a=>{if(!a){const s=Ope(e,n),l=s.fatal??t??!0;i.addIssue({code:"custom",...s,fatal:l})}});if(!o){const a=Ope(e,n),s=a.fatal??t??!0;i.addIssue({code:"custom",...a,fatal:s})}}):z3.create()}var Kf;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(Kf||(Kf={}));const Pe=HP.create,Nr=kH.create,Oo=UH.create,Hqe=YP.create,_x=z3.create;PM.create,fQ.create;const lo=kM.create,Pn=rw.create,Nd=VP.create,hQ=Lqe.create;KP.create,x2.create;const bI=Gqe.create,Yqe=Oqe.create,Qn=jP.create,Ks=JP.create,Vqe=H3.create;ow.create,b2.create;const Kqe="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let zH=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)e+=Kqe[t[r]&63];return e};var zpe={Hz:{baseUnit:"Hz",variants:{MHz:1e6,kHz:1e3,Hz:1}},g:{baseUnit:"g",variants:{kg:1e3,g:1}},Ω:{baseUnit:"Ω",variants:{mΩ:.001,Ω:1,kΩ:1e3,KΩ:1e3,kohm:1e3,MΩ:1e6,GΩ:1e9,TΩ:1e12}},V:{baseUnit:"V",variants:{mV:.001,V:1,kV:1e3,KV:1e3,MV:1e6,GV:1e9,TV:1e12}},A:{baseUnit:"A",variants:{µA:1e-6,mA:.001,ma:.001,A:1,kA:1e3,MA:1e6}},F:{baseUnit:"F",variants:{pF:1e-12,nF:1e-9,µF:1e-6,uF:1e-6,mF:.001,F:1}},ml:{baseUnit:"ml",variants:{ml:1,mL:1,l:1e3,L:1e3}},deg:{baseUnit:"deg",variants:{rad:180/Math.PI}},ms:{baseUnit:"ms",variants:{s:1e3}},mm:{baseUnit:"mm",variants:{nm:1e-6,µm:.001,um:.001,mm:1,cm:10,dm:100,m:1e3,km:1e6,in:25.4,ft:304.8,IN:25.4,FT:304.8,yd:914.4,mi:1609344,mil:.0254}}},HH=new Set;for(const[r,e]of Object.entries(zpe)){HH.add(r);for(const t of Object.keys(e.variants))HH.add(t)}function jqe(r){for(const[e,t]of Object.entries(zpe))if(r in t.variants)return{baseUnit:t.baseUnit,conversionFactor:t.variants[r]};return{baseUnit:r,conversionFactor:1}}var Hpe={tera:1e12,T:1e12,giga:1e9,G:1e9,mega:1e6,M:1e6,kilo:1e3,k:1e3,deci:.1,d:.1,centi:.01,c:.01,milli:.001,m:.001,micro:1e-6,u:1e-6,µ:1e-6,nano:1e-9,n:1e-9,pico:1e-12,p:1e-12},Eb=r=>{var s;if(typeof r>"u")return{parsedUnit:null,unitOfValue:null,value:null};if(typeof r=="string"&&r.match(/^-?[\d\.]+$/))return{value:Number.parseFloat(r),parsedUnit:null,unitOfValue:null};if(typeof r=="number")return{value:r,parsedUnit:null,unitOfValue:null};if(typeof r=="object"&&"x"in r&&"y"in r){const{parsedUnit:l,unitOfValue:c}=Eb(r.x);return{parsedUnit:l,unitOfValue:c,value:{x:Eb(r.x).value,y:Eb(r.y).value}}}const t=(s=r.toString().split("").reverse().join("").match(/[^\d\s]+/))==null?void 0:s[0];if(!t)throw new Error(`Could not determine unit: "${r}"`);const n=t.split("").reverse().join(""),i=r.slice(0,-n.length);if(n in Hpe&&!HH.has(n)){const l=Hpe[n];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(i)*l}}const{baseUnit:o,conversionFactor:a}=jqe(n);return{parsedUnit:n,unitOfValue:o,value:a*Number.parseFloat(i)}},FM=Pe().or(Nr()).transform(r=>Eb(r).value),LM=Pe().or(Nr()).transform(r=>Eb(r).value).transform(r=>Number.parseFloat(r.toPrecision(12))),YH=Pe().or(Nr()).transform(r=>Eb(r).value),GM=Pe().or(Nr()).transform(r=>Eb(r).value),nn=Pe().or(Nr()).transform(r=>Eb(r).value),XP=Pe().or(Nr()).transform(r=>Eb(r).value),Dr=nn,Jqe=Pe().or(Nr()).transform(r=>Eb(r).value),Wqe=Pe().or(Nr()).transform(r=>Eb(r).value),ex=Pe().or(Nr()).transform(r=>typeof r=="number"?r:r.endsWith("deg")?Number.parseFloat(r.split("deg")[0]):r.endsWith("rad")?Number.parseFloat(r.split("rad")[0])*180/Math.PI:Number.parseFloat(r)),Ype=Nr().or(Pe().endsWith("mAh")).transform(r=>{if(typeof r=="string"){const e=r.replace("mAh",""),t=Number.parseFloat(e);if(Number.isNaN(t))throw new Error("Invalid capacity");return t}return r}).describe("Battery capacity in mAh"),Ng=Pn({x:Dr,y:Dr}),qqe=Ng,S2=Pn({x:Dr,y:Dr,z:Dr}),Zqe=S2,VH=Pn({width:Nr(),height:Nr()}),Yd=r=>Pe().optional().default(()=>`${r}_${zH(10)}`),$P=Ks(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]),e8=Ks(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),iE=Pn({type:Qn("source_component"),ftype:Pe().optional(),source_component_id:Pe(),name:Pe(),manufacturer_part_number:Pe().optional(),supplier_part_numbers:bI(e8,lo(Pe())).optional(),display_value:Pe().optional(),are_pins_interchangeable:Oo().optional(),internally_connected_source_port_ids:lo(lo(Pe())).optional(),source_group_id:Pe().optional(),subcircuit_id:Pe().optional()}),KH=iE.extend({ftype:Qn("simple_capacitor"),capacitance:LM,max_voltage_rating:GM.optional(),display_capacitance:Pe().optional(),max_decoupling_trace_length:Dr.optional()}),jH=iE.extend({ftype:Qn("simple_resistor"),resistance:FM,display_resistance:Pe().optional()}),t8=iE.extend({ftype:Qn("simple_diode")}),JH=t8.extend({ftype:Qn("simple_led"),color:Pe().optional(),wavelength:Pe().optional()}),Vpe=iE.extend({ftype:Qn("simple_ground")}),WH=iE.extend({ftype:Qn("simple_chip")}),qH=iE.extend({ftype:Qn("simple_power_source"),voltage:GM}),Xqe=iE.extend({ftype:Qn("simple_fuse"),current_rating_amps:Nr().describe("Nominal current in amps the fuse is rated for"),voltage_rating_volts:Nr().describe("Voltage rating in volts, e.g. ±5V would be 5")}),ZH=iE.extend({ftype:Qn("simple_battery"),capacity:Ype}),XH=iE.extend({ftype:Qn("simple_inductor"),inductance:YH,max_current_rating:Nr().optional()}),$H=iE.extend({ftype:Qn("simple_push_button")}),eY=iE.extend({ftype:Qn("simple_potentiometer"),max_resistance:FM}),Kpe=iE.extend({ftype:Qn("simple_crystal"),frequency:Nr().describe("Frequency in Hz"),load_capacitance:Nr().optional().describe("Load capacitance in pF")}),tY=iE.extend({ftype:Qn("simple_pin_header"),pin_count:Nr(),gender:Ks(["male","female"]).optional().default("male")}),nY=iE.extend({ftype:Qn("simple_resonator"),load_capacitance:LM,equivalent_series_resistance:FM.optional(),frequency:XP}),rY=iE.extend({ftype:Qn("simple_transistor"),transistor_type:Ks(["npn","pnp"])}),iY=iE.extend({ftype:Qn("simple_test_point"),footprint_variant:Ks(["pad","through_hole"]).optional(),pad_shape:Ks(["rect","circle"]).optional(),pad_diameter:Nd([Nr(),Pe()]).optional(),hole_diameter:Nd([Nr(),Pe()]).optional(),width:Nd([Nr(),Pe()]).optional(),height:Nd([Nr(),Pe()]).optional()}),oY=iE.extend({ftype:Qn("simple_mosfet"),channel_type:Ks(["n","p"]),mosfet_mode:Ks(["enhancement","depletion"])}),aY=iE.extend({ftype:Qn("simple_switch")}),sY=Pn({type:Qn("source_project_metadata"),name:Pe().optional(),software_used_string:Pe().optional(),project_url:Pe().optional(),created_at:Pe().datetime().optional()}),jpe=Pn({type:Qn("source_missing_property_error"),source_missing_property_error_id:Yd("source_missing_property_error"),source_component_id:Pe(),property_name:Pe(),subcircuit_id:Pe().optional(),error_type:Qn("source_missing_property_error").default("source_missing_property_error"),message:Pe()}).describe("The source code is missing a property"),Jpe=Pn({type:Qn("source_failed_to_create_component_error"),source_failed_to_create_component_error_id:Yd("source_failed_to_create_component_error"),error_type:Qn("source_failed_to_create_component_error").default("source_failed_to_create_component_error"),component_name:Pe().optional(),subcircuit_id:Pe().optional(),parent_source_component_id:Pe().optional(),message:Pe(),pcb_center:Pn({x:Nr().optional(),y:Nr().optional()}).optional(),schematic_center:Pn({x:Nr().optional(),y:Nr().optional()}).optional()}).describe("Error emitted when a component fails to be constructed"),Wpe=Nd([jH,KH,t8,JH,Vpe,WH,qH,ZH,XH,$H,eY,Kpe,tY,nY,aY,rY,iY,oY,Xqe,sY,jpe,Jpe]),qpe=Pn({type:Qn("source_port"),pin_number:Nr().optional(),port_hints:lo(Pe()).optional(),name:Pe(),source_port_id:Pe(),source_component_id:Pe(),subcircuit_id:Pe().optional(),subcircuit_connectivity_map_key:Pe().optional()}),Zpe=Pn({type:Qn("source_trace"),source_trace_id:Pe(),connected_source_port_ids:lo(Pe()),connected_source_net_ids:lo(Pe()),subcircuit_id:Pe().optional(),subcircuit_connectivity_map_key:Pe().optional(),max_length:Nr().optional(),min_trace_thickness:Nr().optional(),display_name:Pe().optional()}),Xpe=Pn({type:Qn("source_group"),source_group_id:Pe(),subcircuit_id:Pe().optional(),parent_subcircuit_id:Pe().optional(),is_subcircuit:Oo().optional(),name:Pe().optional()}),$pe=Pn({type:Qn("source_net"),source_net_id:Pe(),name:Pe(),member_source_group_ids:lo(Pe()),is_power:Oo().optional(),is_ground:Oo().optional(),is_digital_signal:Oo().optional(),is_analog_signal:Oo().optional(),trace_width:Nr().optional(),subcircuit_id:Pe().optional(),subcircuit_connectivity_map_key:Pe().optional()}),ege=Pn({type:Qn("source_pcb_ground_plane"),source_pcb_ground_plane_id:Pe(),source_group_id:Pe(),source_net_id:Pe(),subcircuit_id:Pe().optional()}).describe("Defines a ground plane in the source domain"),tge=Pn({type:Qn("schematic_box"),schematic_component_id:Pe().optional(),width:Dr,height:Dr,is_dashed:Oo().default(!1),x:Dr,y:Dr,subcircuit_id:Pe().optional()}).describe("Draws a box on the schematic"),nge=Pn({type:Qn("schematic_path"),schematic_component_id:Pe(),fill_color:Ks(["red","blue"]).optional(),is_filled:Oo().optional(),points:lo(Ng),subcircuit_id:Pe().optional()}),rge=bI(Pn({left_margin:nn.optional(),right_margin:nn.optional(),top_margin:nn.optional(),bottom_margin:nn.optional()})),ige=Pn({left_size:Nr(),right_size:Nr(),top_size:Nr().optional(),bottom_size:Nr().optional()}),oge=Pn({left_side:Pn({pins:lo(Nr()),direction:Ks(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:Pn({pins:lo(Nr()),direction:Ks(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:Pn({pins:lo(Nr()),direction:Ks(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:Pn({pins:lo(Nr()),direction:Ks(["left-to-right","right-to-left"]).optional()}).optional()}),age=Nd([ige,oge]),sge=Pn({type:Qn("schematic_component"),size:VH,center:Ng,source_component_id:Pe(),schematic_component_id:Pe(),pin_spacing:nn.optional(),pin_styles:rge.optional(),box_width:nn.optional(),symbol_name:Pe().optional(),port_arrangement:age.optional(),port_labels:bI(Pe()).optional(),symbol_display_value:Pe().optional(),subcircuit_id:Pe().optional(),schematic_group_id:Pe().optional()}),lge=Pn({type:Qn("schematic_line"),schematic_component_id:Pe(),x1:Dr,x2:Dr,y1:Dr,y2:Dr,subcircuit_id:Pe().optional()}),cge=Pn({type:Qn("schematic_trace"),schematic_trace_id:Pe(),source_trace_id:Pe(),junctions:lo(Pn({x:Nr(),y:Nr()})),edges:lo(Pn({from:Pn({x:Nr(),y:Nr()}),to:Pn({x:Nr(),y:Nr()}),is_crossing:Oo().optional(),from_schematic_port_id:Pe().optional(),to_schematic_port_id:Pe().optional()})),subcircuit_id:Pe().optional()}),$qe=Ks(["center","left","right","top","bottom"]),uge=Pn({type:Qn("schematic_text"),schematic_component_id:Pe().optional(),schematic_text_id:Pe(),text:Pe(),font_size:Nr().default(.18),position:Pn({x:Dr,y:Dr}),rotation:Nr().default(0),anchor:Nd([$qe.describe("legacy"),$P]).default("center"),color:Pe().default("#000000"),subcircuit_id:Pe().optional()}),Age=Pn({type:Qn("schematic_port"),schematic_port_id:Pe(),source_port_id:Pe(),schematic_component_id:Pe().optional(),center:Ng,facing_direction:Ks(["up","down","left","right"]).optional(),distance_from_component_edge:Nr().optional(),side_of_component:Ks(["top","bottom","left","right"]).optional(),true_ccw_index:Nr().optional(),pin_number:Nr().optional(),display_pin_label:Pe().optional(),subcircuit_id:Pe().optional(),is_connected:Oo().optional()}).describe("Defines a port on a schematic component"),dge=Pn({type:Qn("schematic_net_label"),schematic_net_label_id:Yd("schematic_net_label"),schematic_trace_id:Pe().optional(),source_trace_id:Pe().optional(),source_net_id:Pe(),center:Ng,anchor_position:Ng.optional(),anchor_side:Ks(["top","bottom","left","right"]),text:Pe(),symbol_name:Pe().optional(),is_movable:Oo().optional(),subcircuit_id:Pe().optional()}),fge=Pn({type:Qn("schematic_error"),schematic_error_id:Pe(),error_type:Qn("schematic_port_not_found").default("schematic_port_not_found"),message:Pe(),subcircuit_id:Pe().optional()}).describe("Defines a schematic error on the schematic"),hge=Pn({type:Qn("schematic_layout_error"),schematic_layout_error_id:Yd("schematic_layout_error"),error_type:Qn("schematic_layout_error").default("schematic_layout_error"),message:Pe(),source_group_id:Pe(),schematic_group_id:Pe(),subcircuit_id:Pe().optional()}).describe("Error emitted when schematic layout fails for a group"),n8=Pn({type:Qn("schematic_debug_object"),label:Pe().optional(),subcircuit_id:Pe().optional()}),pge=n8.extend({shape:Qn("rect"),center:Ng,size:VH}),gge=n8.extend({shape:Qn("line"),start:Ng,end:Ng}),mge=n8.extend({shape:Qn("point"),center:Ng}),yge=hQ("shape",[pge,gge,mge]),vge=Pn({type:Qn("schematic_voltage_probe"),schematic_voltage_probe_id:Pe(),position:Ng,schematic_trace_id:Pe(),voltage:GM.optional(),subcircuit_id:Pe().optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),r8=Pn({type:Qn("schematic_manual_edit_conflict_warning"),schematic_manual_edit_conflict_warning_id:Yd("schematic_manual_edit_conflict_warning"),warning_type:Qn("schematic_manual_edit_conflict_warning").default("schematic_manual_edit_conflict_warning"),message:Pe(),schematic_component_id:Pe(),schematic_group_id:Pe().optional(),subcircuit_id:Pe().optional(),source_component_id:Pe()}).describe("Warning emitted when a component has both manual placement and explicit schX/schY coordinates"),Ige=Pn({type:Qn("schematic_group"),schematic_group_id:Yd("schematic_group"),source_group_id:Pe(),is_subcircuit:Oo().optional(),subcircuit_id:Pe().optional(),width:nn,height:nn,center:Ng,schematic_component_ids:lo(Pe()),name:Pe().optional(),description:Pe().optional()}).describe("Defines a group of components on the schematic"),Cge=Pn({type:Qn("schematic_table"),schematic_table_id:Yd("schematic_table"),anchor_position:Ng,column_widths:lo(Dr),row_heights:lo(Dr),cell_padding:Dr.optional(),border_width:Dr.optional(),subcircuit_id:Pe().optional(),schematic_component_id:Pe().optional(),anchor:$P.optional()}).describe("Defines a table on the schematic"),Ege=Pn({type:Qn("schematic_table_cell"),schematic_table_cell_id:Yd("schematic_table_cell"),schematic_table_id:Pe(),start_row_index:Nr(),end_row_index:Nr(),start_column_index:Nr(),end_column_index:Nr(),text:Pe().optional(),center:Ng,width:Dr,height:Dr,horizontal_align:Ks(["left","center","right"]).optional(),vertical_align:Ks(["top","middle","bottom"]).optional(),font_size:Dr.optional(),subcircuit_id:Pe().optional()}).describe("Defines a cell within a schematic_table"),Y3=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],lY=Ks(Y3),C0=lY.or(Pn({name:lY})).transform(r=>typeof r=="string"?r:r.name),OM=Ks(["top","bottom"]),_ge=Pn({x:Dr,y:Dr,via:Oo().optional(),via_to_layer:C0.optional()}),eZe=lo(_ge),aw=Pn({x:Dr,y:Dr,via:Oo().optional(),to_layer:C0.optional(),trace_width:Dr.optional()}),xge=Pn({type:Qn("pcb_component"),pcb_component_id:Yd("pcb_component"),source_component_id:Pe(),center:Ng,layer:C0,rotation:ex,width:nn,height:nn,subcircuit_id:Pe().optional(),pcb_group_id:Pe().optional()}).describe("Defines a component on the PCB"),Bge=Pn({type:Qn("pcb_hole"),pcb_hole_id:Yd("pcb_hole"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),hole_shape:Ks(["circle","square"]),hole_diameter:Nr(),x:Dr,y:Dr}),tZe=Bge.describe("Defines a circular or square hole on the PCB"),bge=Pn({type:Qn("pcb_hole"),pcb_hole_id:Yd("pcb_hole"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),hole_shape:Qn("oval"),hole_width:Nr(),hole_height:Nr(),x:Dr,y:Dr}),nZe=bge.describe("Defines an oval hole on the PCB"),Sge=Bge.or(bge),rZe=Pn({type:Qn("pcb_plated_hole"),shape:Qn("circle"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),outer_diameter:Nr(),hole_diameter:Nr(),x:Dr,y:Dr,layers:lo(C0),port_hints:lo(Pe()).optional(),pcb_component_id:Pe().optional(),pcb_port_id:Pe().optional(),pcb_plated_hole_id:Yd("pcb_plated_hole")}),iZe=Pn({type:Qn("pcb_plated_hole"),shape:Ks(["oval","pill"]),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),outer_width:Nr(),outer_height:Nr(),hole_width:Nr(),hole_height:Nr(),x:Dr,y:Dr,layers:lo(C0),port_hints:lo(Pe()).optional(),pcb_component_id:Pe().optional(),pcb_port_id:Pe().optional(),pcb_plated_hole_id:Yd("pcb_plated_hole")}),oZe=Pn({type:Qn("pcb_plated_hole"),shape:Qn("circular_hole_with_rect_pad"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),hole_shape:Qn("circle"),pad_shape:Qn("rect"),hole_diameter:Nr(),rect_pad_width:Nr(),rect_pad_height:Nr(),x:Dr,y:Dr,layers:lo(C0),port_hints:lo(Pe()).optional(),pcb_component_id:Pe().optional(),pcb_port_id:Pe().optional(),pcb_plated_hole_id:Yd("pcb_plated_hole")}),aZe=Pn({type:Qn("pcb_plated_hole"),shape:Qn("pill_hole_with_rect_pad"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),hole_shape:Qn("pill"),pad_shape:Qn("rect"),hole_width:Nr(),hole_height:Nr(),rect_pad_width:Nr(),rect_pad_height:Nr(),x:Dr,y:Dr,layers:lo(C0),port_hints:lo(Pe()).optional(),pcb_component_id:Pe().optional(),pcb_port_id:Pe().optional(),pcb_plated_hole_id:Yd("pcb_plated_hole")}),wge=Nd([rZe,iZe,oZe,aZe]),Qge=Pn({type:Qn("pcb_port"),pcb_port_id:Yd("pcb_port"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),source_port_id:Pe(),pcb_component_id:Pe(),x:Dr,y:Dr,layers:lo(C0)}).describe("Defines a port on the PCB"),sZe=Pn({type:Qn("pcb_smtpad"),shape:Qn("circle"),pcb_smtpad_id:Yd("pcb_smtpad"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),x:Dr,y:Dr,radius:Nr(),layer:C0,port_hints:lo(Pe()).optional(),pcb_component_id:Pe().optional(),pcb_port_id:Pe().optional()}),lZe=Pn({type:Qn("pcb_smtpad"),shape:Qn("rect"),pcb_smtpad_id:Yd("pcb_smtpad"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),x:Dr,y:Dr,width:Nr(),height:Nr(),layer:C0,port_hints:lo(Pe()).optional(),pcb_component_id:Pe().optional(),pcb_port_id:Pe().optional()}),cZe=Pn({type:Qn("pcb_smtpad"),shape:Qn("rotated_rect"),pcb_smtpad_id:Yd("pcb_smtpad"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),x:Dr,y:Dr,width:Nr(),height:Nr(),ccw_rotation:ex,layer:C0,port_hints:lo(Pe()).optional(),pcb_component_id:Pe().optional(),pcb_port_id:Pe().optional()}),Mge=Pn({type:Qn("pcb_smtpad"),shape:Qn("pill"),pcb_smtpad_id:Yd("pcb_smtpad"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),x:Dr,y:Dr,width:Nr(),height:Nr(),radius:Nr(),layer:C0,port_hints:lo(Pe()).optional(),pcb_component_id:Pe().optional(),pcb_port_id:Pe().optional()}),uZe=Pn({type:Qn("pcb_smtpad"),shape:Qn("polygon"),pcb_smtpad_id:Yd("pcb_smtpad"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),points:lo(Ng),layer:C0,port_hints:lo(Pe()).optional(),pcb_component_id:Pe().optional(),pcb_port_id:Pe().optional()}),Dge=hQ("shape",[sZe,lZe,cZe,Mge,uZe]).describe("Defines an SMT pad on the PCB"),AZe=Pn({type:Qn("pcb_solder_paste"),shape:Qn("circle"),pcb_solder_paste_id:Yd("pcb_solder_paste"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),x:Dr,y:Dr,radius:Nr(),layer:C0,pcb_component_id:Pe().optional(),pcb_smtpad_id:Pe().optional()}),dZe=Pn({type:Qn("pcb_solder_paste"),shape:Qn("rect"),pcb_solder_paste_id:Yd("pcb_solder_paste"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),x:Dr,y:Dr,width:Nr(),height:Nr(),layer:C0,pcb_component_id:Pe().optional(),pcb_smtpad_id:Pe().optional()}),fZe=Pn({type:Qn("pcb_solder_paste"),shape:Qn("pill"),pcb_solder_paste_id:Yd("pcb_solder_paste"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),x:Dr,y:Dr,width:Nr(),height:Nr(),radius:Nr(),layer:C0,pcb_component_id:Pe().optional(),pcb_smtpad_id:Pe().optional()}),hZe=Pn({type:Qn("pcb_solder_paste"),shape:Qn("rotated_rect"),pcb_solder_paste_id:Yd("pcb_solder_paste"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),x:Dr,y:Dr,width:Nr(),height:Nr(),ccw_rotation:Dr,layer:C0,pcb_component_id:Pe().optional(),pcb_smtpad_id:Pe().optional()}),pZe=Pn({type:Qn("pcb_solder_paste"),shape:Qn("oval"),pcb_solder_paste_id:Yd("pcb_solder_paste"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),x:Dr,y:Dr,width:Nr(),height:Nr(),layer:C0,pcb_component_id:Pe().optional(),pcb_smtpad_id:Pe().optional()}),Rge=Nd([AZe,dZe,fZe,hZe,pZe]).describe("Defines solderpaste on the PCB"),Nge=Pn({type:Qn("pcb_text"),pcb_text_id:Yd("pcb_text"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),text:Pe(),center:Ng,layer:C0,width:nn,height:nn,lines:Nr(),align:Ks(["bottom-left"])}).describe("Defines text on the PCB"),Tge=Pn({route_type:Qn("wire"),x:Dr,y:Dr,width:Dr,start_pcb_port_id:Pe().optional(),end_pcb_port_id:Pe().optional(),layer:C0}),Pge=Pn({route_type:Qn("via"),x:Dr,y:Dr,hole_diameter:Dr.optional(),outer_diameter:Dr.optional(),from_layer:Pe(),to_layer:Pe()}),i8=Nd([Tge,Pge]),kge=Pn({type:Qn("pcb_trace"),source_trace_id:Pe().optional(),pcb_component_id:Pe().optional(),pcb_trace_id:Yd("pcb_trace"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),route_thickness_mode:Ks(["constant","interpolated"]).default("constant").optional(),route_order_index:Nr().optional(),should_round_corners:Oo().optional(),trace_length:Nr().optional(),route:lo(i8)}).describe("Defines a trace on the PCB"),Uge=Pn({type:Qn("pcb_trace_error"),pcb_trace_error_id:Yd("pcb_trace_error"),error_type:Qn("pcb_trace_error").default("pcb_trace_error"),message:Pe(),center:Ng.optional(),pcb_trace_id:Pe(),source_trace_id:Pe(),pcb_component_ids:lo(Pe()),pcb_port_ids:lo(Pe()),subcircuit_id:Pe().optional()}).describe("Defines a trace error on the PCB"),Fge=Pn({type:Qn("pcb_port_not_matched_error"),pcb_error_id:Yd("pcb_error"),error_type:Qn("pcb_port_not_matched_error").default("pcb_port_not_matched_error"),message:Pe(),pcb_component_ids:lo(Pe()),subcircuit_id:Pe().optional()}).describe("Defines a trace error on the PCB where a port is not matched"),Lge=Pn({type:Qn("pcb_via"),pcb_via_id:Yd("pcb_via"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),x:Dr,y:Dr,outer_diameter:Dr.default("0.6mm"),hole_diameter:Dr.default("0.25mm"),from_layer:C0.optional(),to_layer:C0.optional(),layers:lo(C0),pcb_trace_id:Pe().optional()}).describe("Defines a via on the PCB"),Gge=Pn({type:Qn("pcb_board"),pcb_board_id:Yd("pcb_board"),is_subcircuit:Oo().optional(),subcircuit_id:Pe().optional(),width:nn,height:nn,center:Ng,thickness:nn.optional().default(1.4),num_layers:Nr().optional().default(4),outline:lo(Ng).optional(),material:Ks(["fr4","fr1"]).default("fr4")}).describe("Defines the board outline of the PCB"),Oge=Pn({type:Qn("pcb_placement_error"),pcb_placement_error_id:Yd("pcb_placement_error"),error_type:Qn("pcb_placement_error").default("pcb_placement_error"),message:Pe(),subcircuit_id:Pe().optional()}).describe("Defines a placement error on the PCB"),zge=Pn({type:Qn("pcb_trace_hint"),pcb_trace_hint_id:Yd("pcb_trace_hint"),pcb_port_id:Pe(),pcb_component_id:Pe(),route:lo(aw),subcircuit_id:Pe().optional()}).describe("A hint that can be used during generation of a PCB trace"),Hge=Pn({type:Qn("pcb_silkscreen_line"),pcb_silkscreen_line_id:Yd("pcb_silkscreen_line"),pcb_component_id:Pe(),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),stroke_width:Dr.default("0.1mm"),x1:Dr,y1:Dr,x2:Dr,y2:Dr,layer:OM}).describe("Defines a silkscreen line on the PCB"),Yge=Pn({type:Qn("pcb_silkscreen_path"),pcb_silkscreen_path_id:Yd("pcb_silkscreen_path"),pcb_component_id:Pe(),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),layer:OM,route:lo(Ng),stroke_width:nn}).describe("Defines a silkscreen path on the PCB"),Vge=Pn({type:Qn("pcb_silkscreen_text"),pcb_silkscreen_text_id:Yd("pcb_silkscreen_text"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),font:Qn("tscircuit2024").default("tscircuit2024"),font_size:Dr.default("0.2mm"),pcb_component_id:Pe(),text:Pe(),ccw_rotation:Nr().optional(),layer:C0,is_mirrored:Oo().default(!1).optional(),anchor_position:Ng.default({x:0,y:0}),anchor_alignment:$P.default("center")}).describe("Defines silkscreen text on the PCB"),Kge=Pn({type:Qn("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:Yd("pcb_silkscreen_rect"),pcb_component_id:Pe(),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),center:Ng,width:nn,height:nn,layer:C0,stroke_width:nn.default("1mm"),is_filled:Oo().default(!0).optional(),has_stroke:Oo().optional(),is_stroke_dashed:Oo().optional()}).describe("Defines a silkscreen rect on the PCB"),jge=Pn({type:Qn("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:Yd("pcb_silkscreen_circle"),pcb_component_id:Pe(),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),center:Ng,radius:nn,layer:OM,stroke_width:nn.default("1mm")}).describe("Defines a silkscreen circle on the PCB"),Jge=Pn({type:Qn("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:Yd("pcb_silkscreen_oval"),pcb_component_id:Pe(),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),center:Ng,radius_x:Dr,radius_y:Dr,layer:OM}).describe("Defines a silkscreen oval on the PCB"),Wge=Pn({type:Qn("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:Yd("pcb_fabrication_note_text"),subcircuit_id:Pe().optional(),pcb_group_id:Pe().optional(),font:Qn("tscircuit2024").default("tscircuit2024"),font_size:Dr.default("1mm"),pcb_component_id:Pe(),text:Pe(),layer:OM,anchor_position:Ng.default({x:0,y:0}),anchor_alignment:Ks(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:Pe().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),qge=Pn({type:Qn("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:Yd("pcb_fabrication_note_path"),pcb_component_id:Pe(),subcircuit_id:Pe().optional(),layer:C0,route:lo(Ng),stroke_width:nn,color:Pe().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),Zge=Pn({type:Qn("pcb_footprint_overlap_error"),pcb_error_id:Yd("pcb_error"),error_type:Qn("pcb_footprint_overlap_error").default("pcb_footprint_overlap_error"),message:Pe(),pcb_smtpad_ids:lo(Pe()).optional(),pcb_plated_hole_ids:lo(Pe()).optional(),pcb_hole_ids:lo(Pe()).optional(),pcb_keepout_ids:lo(Pe()).optional()}).describe("Error emitted when a pcb footprint overlaps with another element"),Xge=Pn({type:Qn("pcb_keepout"),shape:Qn("rect"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),center:Ng,width:Dr,height:Dr,pcb_keepout_id:Pe(),layers:lo(Pe()),description:Pe().optional()}).or(Pn({type:Qn("pcb_keepout"),shape:Qn("circle"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),center:Ng,radius:Dr,pcb_keepout_id:Pe(),layers:lo(Pe()),description:Pe().optional()})),cY=Pn({type:Qn("pcb_cutout"),pcb_cutout_id:Yd("pcb_cutout"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional()}),$ge=cY.extend({shape:Qn("rect"),center:Ng,width:nn,height:nn,rotation:ex.optional()}),e0e=cY.extend({shape:Qn("circle"),center:Ng,radius:nn}),t0e=cY.extend({shape:Qn("polygon"),points:lo(Ng)}),n0e=hQ("shape",[$ge,e0e,t0e]).describe("Defines a cutout on the PCB, removing board material."),r0e=Pn({type:Qn("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:Yd("pcb_missing_footprint_error"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),error_type:Qn("pcb_missing_footprint_error").default("pcb_missing_footprint_error"),source_component_id:Pe(),message:Pe()}).describe("Defines a missing footprint error on the PCB"),i0e=Pn({type:Qn("pcb_group"),pcb_group_id:Yd("pcb_group"),source_group_id:Pe(),is_subcircuit:Oo().optional(),subcircuit_id:Pe().optional(),width:nn,height:nn,center:Ng,pcb_component_ids:lo(Pe()),name:Pe().optional(),description:Pe().optional(),autorouter_configuration:Pn({trace_clearance:nn}).optional(),autorouter_used_string:Pe().optional()}).describe("Defines a group of components on the PCB"),o0e=Pn({type:Qn("pcb_autorouting_error"),pcb_error_id:Yd("pcb_autorouting_error"),error_type:Qn("pcb_autorouting_error").default("pcb_autorouting_error"),message:Pe(),subcircuit_id:Pe().optional()}).describe("The autorouting has failed to route a portion of the board"),o8=Pn({type:Qn("pcb_manual_edit_conflict_warning"),pcb_manual_edit_conflict_warning_id:Yd("pcb_manual_edit_conflict_warning"),warning_type:Qn("pcb_manual_edit_conflict_warning").default("pcb_manual_edit_conflict_warning"),message:Pe(),pcb_component_id:Pe(),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),source_component_id:Pe()}).describe("Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),a0e=Pn({type:Qn("pcb_breakout_point"),pcb_breakout_point_id:Yd("pcb_breakout_point"),pcb_group_id:Pe(),subcircuit_id:Pe().optional(),source_trace_id:Pe().optional(),source_port_id:Pe().optional(),source_net_id:Pe().optional(),x:Dr,y:Dr}).describe("Defines a routing target within a pcb_group for a source_trace or source_net"),s0e=Pn({type:Qn("pcb_ground_plane"),pcb_ground_plane_id:Yd("pcb_ground_plane"),source_pcb_ground_plane_id:Pe(),source_net_id:Pe(),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional()}).describe("Defines a ground plane on the PCB"),l0e=Pn({type:Qn("pcb_ground_plane_region"),pcb_ground_plane_region_id:Yd("pcb_ground_plane_region"),pcb_ground_plane_id:Pe(),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),layer:C0,points:lo(Ng)}).describe("Defines a polygon region of a ground plane"),c0e=Pn({type:Qn("pcb_thermal_spoke"),pcb_thermal_spoke_id:Yd("pcb_thermal_spoke"),pcb_ground_plane_id:Pe(),shape:Pe(),spoke_count:Nr(),spoke_thickness:Dr,spoke_inner_diameter:Dr,spoke_outer_diameter:Dr,pcb_plated_hole_id:Pe().optional(),subcircuit_id:Pe().optional()}).describe("Pattern for connecting a ground plane to a plated hole"),u0e=Pn({type:Qn("cad_component"),cad_component_id:Pe(),pcb_component_id:Pe(),source_component_id:Pe(),position:S2,rotation:S2.optional(),size:S2.optional(),layer:C0.optional(),subcircuit_id:Pe().optional(),footprinter_string:Pe().optional(),model_obj_url:Pe().optional(),model_stl_url:Pe().optional(),model_3mf_url:Pe().optional(),model_jscad:_x().optional()}).describe("Defines a component on the PCB"),A0e=Nd([Zpe,qpe,Wpe,$pe,Xpe,WH,KH,t8,JH,jH,qH,ZH,XH,tY,nY,aY,rY,iY,oY,eY,$H,ege,sY,xge,Sge,r0e,o8,wge,Xge,Qge,Nge,kge,Lge,Dge,Rge,Gge,i0e,zge,Hge,Yge,Vge,Kge,jge,Jge,Uge,Oge,Fge,qge,Wge,o0e,Zge,a0e,n0e,s0e,l0e,c0e,tge,uge,lge,sge,Age,cge,nge,fge,hge,dge,yge,vge,r8,Ige,Cge,Ege,u0e]),V3=A0e;const a8=Object.freeze(Object.defineProperty({__proto__:null,all_layers:Y3,any_circuit_element:A0e,any_soup_element:V3,any_source_component:Wpe,battery_capacity:Ype,cad_component:u0e,capacitance:LM,current:Jqe,distance:Dr,frequency:XP,getZodPrefixedIdWithDefault:Yd,inductance:YH,layer_ref:C0,layer_string:lY,length:nn,ninePointAnchor:$P,pcb_autorouting_error:o0e,pcb_board:Gge,pcb_breakout_point:a0e,pcb_component:xge,pcb_cutout:n0e,pcb_cutout_circle:e0e,pcb_cutout_polygon:t0e,pcb_cutout_rect:$ge,pcb_fabrication_note_path:qge,pcb_fabrication_note_text:Wge,pcb_footprint_overlap_error:Zge,pcb_ground_plane:s0e,pcb_ground_plane_region:l0e,pcb_group:i0e,pcb_hole:Sge,pcb_hole_circle_or_square_shape:tZe,pcb_hole_oval_shape:nZe,pcb_keepout:Xge,pcb_manual_edit_conflict_warning:o8,pcb_missing_footprint_error:r0e,pcb_placement_error:Oge,pcb_plated_hole:wge,pcb_port:Qge,pcb_port_not_matched_error:Fge,pcb_route_hint:_ge,pcb_route_hints:eZe,pcb_silkscreen_circle:jge,pcb_silkscreen_line:Hge,pcb_silkscreen_oval:Jge,pcb_silkscreen_path:Yge,pcb_silkscreen_rect:Kge,pcb_silkscreen_text:Vge,pcb_smtpad:Dge,pcb_smtpad_pill:Mge,pcb_solder_paste:Rge,pcb_text:Nge,pcb_thermal_spoke:c0e,pcb_trace:kge,pcb_trace_error:Uge,pcb_trace_hint:zge,pcb_trace_route_point:i8,pcb_trace_route_point_via:Pge,pcb_trace_route_point_wire:Tge,pcb_via:Lge,point:Ng,point3:S2,port_arrangement:age,position:qqe,position3:Zqe,resistance:FM,rotation:ex,route_hint_point:aw,schematic_box:tge,schematic_component:sge,schematic_component_port_arrangement_by_sides:oge,schematic_component_port_arrangement_by_size:ige,schematic_debug_line:gge,schematic_debug_object:yge,schematic_debug_object_base:n8,schematic_debug_point:mge,schematic_debug_rect:pge,schematic_error:fge,schematic_group:Ige,schematic_layout_error:hge,schematic_line:lge,schematic_manual_edit_conflict_warning:r8,schematic_net_label:dge,schematic_path:nge,schematic_pin_styles:rge,schematic_port:Age,schematic_table:Cge,schematic_table_cell:Ege,schematic_text:uge,schematic_trace:cge,schematic_voltage_probe:vge,size:VH,source_component_base:iE,source_failed_to_create_component_error:Jpe,source_group:Xpe,source_missing_property_error:jpe,source_net:$pe,source_pcb_ground_plane:ege,source_port:qpe,source_project_metadata:sY,source_simple_battery:ZH,source_simple_capacitor:KH,source_simple_chip:WH,source_simple_crystal:Kpe,source_simple_diode:t8,source_simple_ground:Vpe,source_simple_inductor:XH,source_simple_led:JH,source_simple_mosfet:oY,source_simple_pin_header:tY,source_simple_potentiometer:eY,source_simple_power_source:qH,source_simple_push_button:$H,source_simple_resistor:jH,source_simple_resonator:nY,source_simple_switch:aY,source_simple_test_point:iY,source_simple_transistor:rY,source_trace:Zpe,supplier_name:e8,time:Wqe,visible_layer:OM,voltage:GM},Symbol.toStringTag,{value:"Module"}));function Xr(r,e){return Array.isArray(e)?[r.a*e[0]+r.c*e[1]+r.e,r.b*e[0]+r.d*e[1]+r.f]:{x:r.a*e.x+r.c*e.y+r.e,y:r.b*e.x+r.d*e.y+r.f}}function gZe(r,e){return e.map(t=>Xr(r,t))}function d0e(r){return{a:parseFloat(r.a),b:parseFloat(r.b),c:parseFloat(r.c),d:parseFloat(r.d),e:parseFloat(r.e),f:parseFloat(r.f)}}const mZe=/^matrix\(\s*([0-9_+-.e]+)\s*,\s*([0-9_+-.e]+)\s*,\s*([0-9_+-.e]+)\s*,\s*([0-9_+-.e]+)\s*,\s*([0-9_+-.e]+)\s*,\s*([0-9_+-.e]+)\s*\)$/i;function uY(r){const e=r.match(mZe);if(e===null||e.length<7)throw new Error(`'${r}' is not a matrix`);return{a:parseFloat(e[1]),b:parseFloat(e[2]),c:parseFloat(e[3]),d:parseFloat(e[4]),e:parseFloat(e[5]),f:parseFloat(e[6])}}function Ny(){return{a:1,c:0,e:0,b:0,d:1,f:0}}function sS(r){const{a:e,b:t,c:n,d:i,e:o,f:a}=r,s=e*i-t*n;return{a:i/s,b:t/-s,c:n/-s,d:e/s,e:(i*o-n*a)/-s,f:(t*o-e*a)/s}}function K3(r){return typeof r>"u"}function zM(r){return typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r)}function yZe(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}function vZe(r){return yZe(r)&&"a"in r&&zM(r.a)&&"b"in r&&zM(r.b)&&"c"in r&&zM(r.c)&&"d"in r&&zM(r.d)&&"e"in r&&zM(r.e)&&"f"in r&&zM(r.f)}function $d(r,e=0){return{a:1,c:0,e:r,b:0,d:1,f:e}}function pQ(...r){r=Array.isArray(r[0])?r[0]:r;const e=(t,n)=>({a:t.a*n.a+t.c*n.b,c:t.a*n.c+t.c*n.d,e:t.a*n.e+t.c*n.f+t.e,b:t.b*n.a+t.d*n.b,d:t.b*n.c+t.d*n.d,f:t.b*n.e+t.d*n.f+t.f});switch(r.length){case 0:throw new Error("no matrices provided");case 1:return r[0];case 2:return e(r[0],r[1]);default:{const[t,n,...i]=r,o=e(t,n);return pQ(o,...i)}}}function Ku(...r){return pQ(...r)}const{cos:IZe,sin:CZe,PI:EZe}=Math;function $x(r,e,t){const n=IZe(r),i=CZe(r),o={a:n,c:-i,e:0,b:i,d:n,f:0};return K3(e)||K3(t)?o:pQ([$d(e,t),o,$d(-e,-t)])}function AY(r,e=void 0,t=void 0){return $x(r*EZe/180,e,t)}function oE(r,e=void 0,t=void 0,n=void 0){K3(e)&&(e=r);const i={a:r,c:0,e:0,b:0,d:e,f:0};return K3(t)||K3(n)?i:pQ([$d(t,n),i,$d(-t,-n)])}function f0e(r,e){return{a:1,c:r,e:0,b:e,d:1,f:0}}const{tan:h0e}=Math;function p0e(r,e){return{a:1,c:h0e(r),e:0,b:h0e(e),d:1,f:0}}function dY(r,e){return p0e(r*Math.PI/180,e*Math.PI/180)}function _Ze(r){return gQ(r)}function g0e(r){return gQ(r)}function gQ(r){return`matrix(${r.a},${r.b},${r.c},${r.d},${r.e},${r.f})`}function m0e(r,e=1e10){return{a:Math.round(r.a*e)/e,b:Math.round(r.b*e)/e,c:Math.round(r.c*e)/e,d:Math.round(r.d*e)/e,e:Math.round(r.e*e)/e,f:Math.round(r.f*e)/e}}function y0e(r,e){const t=r[0].x!=null?r[0].x:r[0][0],n=r[0].y!=null?r[0].y:r[0][1],i=e[0].x!=null?e[0].x:e[0][0],o=e[0].y!=null?e[0].y:e[0][1],a=r[1].x!=null?r[1].x:r[1][0],s=r[1].y!=null?r[1].y:r[1][1],l=e[1].x!=null?e[1].x:e[1][0],c=e[1].y!=null?e[1].y:e[1][1],u=r[2].x!=null?r[2].x:r[2][0],A=r[2].y!=null?r[2].y:r[2][1],d=e[2].x!=null?e[2].x:e[2][0],f=e[2].y!=null?e[2].y:e[2][1],m={a:t-u,b:n-A,c:a-u,d:s-A,e:u,f:A},C={a:i-d,b:o-f,c:l-d,d:c-f,e:d,f},E=sS(m),_=pQ([C,E]);return m0e(_)}function xZe(r){return Array.isArray(r)?r.map(e):e(r);function e(t){switch(t.type){case"matrix":if("a"in t&&"b"in t&&"c"in t&&"d"in t&&"e"in t&&"f"in t)return d0e(t);throw new Error("MISSING_MANDATORY_PARAM");case"translate":if(!("tx"in t))throw new Error("MISSING_MANDATORY_PARAM");return"ty"in t?$d(t.tx,t.ty):$d(t.tx);case"scale":if(!("sx"in t))throw new Error("MISSING_MANDATORY_PARAM");return"sy"in t?oE(t.sx,t.sy):oE(t.sx);case"rotate":if(!("angle"in t))throw new Error("MISSING_MANDATORY_PARAM");return"cx"in t&&"cy"in t?AY(t.angle,t.cx,t.cy):AY(t.angle);case"skewX":if(!("angle"in t))throw new Error("MISSING_MANDATORY_PARAM");return dY(t.angle,0);case"skewY":if(!("angle"in t))throw new Error("MISSING_MANDATORY_PARAM");return dY(0,t.angle);case"shear":if(!("shx"in t&&"shy"in t))throw new Error("MISSING_MANDATORY_PARAM");return f0e(t.shx,t.shy);default:throw new Error("UNSUPPORTED_DESCRIPTOR")}}}function BZe(r,e){function t(){this.constructor=r}t.prototype=e.prototype,r.prototype=new t}function HM(r,e,t,n){var i=Error.call(this,r);return Object.setPrototypeOf&&Object.setPrototypeOf(i,HM.prototype),i.expected=e,i.found=t,i.location=n,i.name="SyntaxError",i}BZe(HM,Error);function fY(r,e,t){return t=t||" ",r.length>e?r:(e-=r.length,t+=t.repeat(e),r+t.slice(0,e))}HM.prototype.format=function(r){var e="Error: "+this.message;if(this.location){var t=null,n;for(n=0;n<r.length;n++)if(r[n].source===this.location.source){t=r[n].text.split(/\r\n|\n|\r/g);break}var i=this.location.start,o=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(i):i,a=this.location.source+":"+o.line+":"+o.column;if(t){var s=this.location.end,l=fY("",o.line.toString().length," "),c=t[i.line-1],u=i.line===s.line?s.column:c.length+1,A=u-i.column||1;e+=`
|
|
244
|
+
`)).length,i=0;i<n;i++){var a=r.charCodeAt(i),s=null;a<128?t++:s=a>127&&a<2048?String.fromCharCode(a>>6|192,63&a|128):String.fromCharCode(a>>12|224,a>>6&63|128,63&a|128),rQ(s)||(t>e&&(o+=r.substring(e,t)),o+=s,e=t=i+1)}return t>e&&(o+=r.substring(e,r.length)),o},AWe=!!Cz||!!Iz,Ehe="text/plain",TP=(r,e)=>{var[t,n]=r.split("?"),i=Wc({},e);n==null||n.split("&").forEach(a=>{var[s]=a.split("=");delete i[s]});var o=$je(i);return t+"?"+(o=o?(n?n+"&":"")+o:n)},S3=(r,e)=>JSON.stringify(r,(t,n)=>typeof n=="bigint"?n.toString():n,e),cH=r=>{var{data:e,compression:t}=r;if(e){if(t===XS.GZipJS){var n=che(uhe(S3(e)),{mtime:0}),i=new Blob([n],{type:Ehe});return{contentType:Ehe,body:i,estimatedSize:i.size}}if(t===XS.Base64){var o=function(l){var c,u,A,d,f,m="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",C=0,E=0,_="",x=[];if(!l)return l;l=uWe(l);do c=(f=l.charCodeAt(C++)<<16|l.charCodeAt(C++)<<8|l.charCodeAt(C++))>>18&63,u=f>>12&63,A=f>>6&63,d=63&f,x[E++]=m.charAt(c)+m.charAt(u)+m.charAt(A)+m.charAt(d);while(C<l.length);switch(_=x.join(""),l.length%3){case 1:_=_.slice(0,-2)+"==";break;case 2:_=_.slice(0,-1)+"="}return _}(S3(e)),a=(l=>"data="+encodeURIComponent(typeof l=="string"?l:S3(l)))(o);return{contentType:"application/x-www-form-urlencoded",body:a,estimatedSize:new Blob([a]).size}}var s=S3(e);return{contentType:"application/json",body:s,estimatedSize:new Blob([s]).size}}},w3=[];Iz&&w3.push({transport:"fetch",method:r=>{var e,t,{contentType:n,body:i,estimatedSize:o}=(e=cH(r))!==null&&e!==void 0?e:{},a=new Headers;av(r.headers,function(u,A){a.append(A,u)}),n&&a.append("Content-Type",n);var s=r.url,l=null;if(tfe){var c=new tfe;l={signal:c.signal,timeout:setTimeout(()=>c.abort(),r.timeout)}}Iz(s,Wc({method:(r==null?void 0:r.method)||"GET",headers:a,keepalive:r.method==="POST"&&(o||0)<52428.8,body:i,signal:(t=l)==null?void 0:t.signal},r.fetchOptions)).then(u=>u.text().then(A=>{var d={statusCode:u.status,text:A};if(u.status===200)try{d.json=JSON.parse(A)}catch(f){bu.error(f)}r.callback==null||r.callback(d)})).catch(u=>{bu.error(u),r.callback==null||r.callback({statusCode:0,text:u})}).finally(()=>l?clearTimeout(l.timeout):null)}}),Cz&&w3.push({transport:"XHR",method:r=>{var e,t=new Cz;t.open(r.method||"GET",r.url,!0);var{contentType:n,body:i}=(e=cH(r))!==null&&e!==void 0?e:{};av(r.headers,function(o,a){t.setRequestHeader(a,o)}),n&&t.setRequestHeader("Content-Type",n),r.timeout&&(t.timeout=r.timeout),t.withCredentials=!0,t.onreadystatechange=()=>{if(t.readyState===4){var o={statusCode:t.status,text:t.responseText};if(t.status===200)try{o.json=JSON.parse(t.responseText)}catch{}r.callback==null||r.callback(o)}},t.send(i)}}),_B!=null&&_B.sendBeacon&&w3.push({transport:"sendBeacon",method:r=>{var e=TP(r.url,{beacon:"1"});try{var t,{contentType:n,body:i}=(t=cH(r))!==null&&t!==void 0?t:{},o=typeof i=="string"?new Blob([i],{type:n}):i;_B.sendBeacon(e,o)}catch{}}});var SM=function(r,e){if(!function(t){try{new RegExp(t)}catch{return!1}return!0}(e))return!1;try{return new RegExp(e).test(r)}catch{return!1}};function _he(r,e,t){return S3({distinct_id:r,userPropertiesToSet:e,userPropertiesToSetOnce:t})}var dWe={exact:(r,e)=>e.some(t=>r.some(n=>t===n)),is_not:(r,e)=>e.every(t=>r.every(n=>t!==n)),regex:(r,e)=>e.some(t=>r.some(n=>SM(t,n))),not_regex:(r,e)=>e.every(t=>r.every(n=>!SM(t,n))),icontains:(r,e)=>e.map(PP).some(t=>r.map(PP).some(n=>t.includes(n))),not_icontains:(r,e)=>e.map(PP).every(t=>r.map(PP).every(n=>!t.includes(n)))},PP=r=>r.toLowerCase(),fWe=XE("[Error tracking]");class hWe{constructor(e){var t,n;this.fe=[],this._instance=e,this.fe=(t=(n=this._instance.persistence)==null?void 0:n.get_property(Sz))!==null&&t!==void 0?t:[]}onRemoteConfig(e){var t,n,i=(t=(n=e.errorTracking)==null?void 0:n.suppressionRules)!==null&&t!==void 0?t:[];this.fe=i,this._instance.persistence&&this._instance.persistence.register({[Sz]:this.fe})}sendExceptionEvent(e){if(!this.pe(e))return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"});fWe.info("Skipping exception capture because a suppression rule matched")}pe(e){var t=e.$exception_list;if(!t||!OI(t)||t.length===0)return!1;var n=t.reduce((i,o)=>{var{type:a,value:s}=o;return PC(a)&&a.length>0&&i.$exception_types.push(a),PC(s)&&s.length>0&&i.$exception_values.push(s),i},{$exception_types:[],$exception_values:[]});return this.fe.some(i=>{var o=i.values.map(a=>{var s,l=dWe[a.operator],c=OI(a.value)?a.value:[a.value],u=(s=n[a.key])!==null&&s!==void 0?s:[];return c.length>0&&l(c,u)});return i.type==="OR"?o.some(Boolean):o.every(Boolean)})}}var WB="Mobile",kP="iOS",tS="Android",Q3="Tablet",xhe=tS+" "+Q3,Bhe="iPad",bhe="Apple",She=bhe+" Watch",M3="Safari",wM="BlackBerry",whe="Samsung",Qhe=whe+"Browser",Mhe=whe+" Internet",I2="Chrome",pWe=I2+" OS",Dhe=I2+" "+kP,uH="Internet Explorer",Rhe=uH+" "+WB,AH="Opera",gWe=AH+" Mini",dH="Edge",Nhe="Microsoft "+dH,QM="Firefox",The=QM+" "+kP,D3="Nintendo",R3="PlayStation",MM="Xbox",Phe=tS+" "+WB,khe=WB+" "+M3,N3="Windows",fH=N3+" Phone",Uhe="Nokia",hH="Ouya",Fhe="Generic",mWe=Fhe+" "+WB.toLowerCase(),Lhe=Fhe+" "+Q3.toLowerCase(),pH="Konqueror",Ex="(\\d+(\\.\\d+)?)",gH=new RegExp("Version/"+Ex),yWe=new RegExp(MM,"i"),vWe=new RegExp(R3+" \\w+","i"),IWe=new RegExp(D3+" \\w+","i"),mH=new RegExp(wM+"|PlayBook|BB10","i"),CWe={"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"},EWe=(r,e)=>e&&Wg(e,bhe)||function(t){return Wg(t,M3)&&!Wg(t,I2)&&!Wg(t,tS)}(r),Ghe=function(r,e){return e=e||"",Wg(r," OPR/")&&Wg(r,"Mini")?gWe:Wg(r," OPR/")?AH:mH.test(r)?wM:Wg(r,"IE"+WB)||Wg(r,"WPDesktop")?Rhe:Wg(r,Qhe)?Mhe:Wg(r,dH)||Wg(r,"Edg/")?Nhe:Wg(r,"FBIOS")?"Facebook "+WB:Wg(r,"UCWEB")||Wg(r,"UCBrowser")?"UC Browser":Wg(r,"CriOS")?Dhe:Wg(r,"CrMo")||Wg(r,I2)?I2:Wg(r,tS)&&Wg(r,M3)?Phe:Wg(r,"FxiOS")?The:Wg(r.toLowerCase(),pH.toLowerCase())?pH:EWe(r,e)?Wg(r,WB)?khe:M3:Wg(r,QM)?QM:Wg(r,"MSIE")||Wg(r,"Trident/")?uH:Wg(r,"Gecko")?QM:""},_We={[Rhe]:[new RegExp("rv:"+Ex)],[Nhe]:[new RegExp(dH+"?\\/"+Ex)],[I2]:[new RegExp("("+I2+"|CrMo)\\/"+Ex)],[Dhe]:[new RegExp("CriOS\\/"+Ex)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Ex)],[M3]:[gH],[khe]:[gH],[AH]:[new RegExp("(Opera|OPR)\\/"+Ex)],[QM]:[new RegExp(QM+"\\/"+Ex)],[The]:[new RegExp("FxiOS\\/"+Ex)],[pH]:[new RegExp("Konqueror[:/]?"+Ex,"i")],[wM]:[new RegExp(wM+" "+Ex),gH],[Phe]:[new RegExp("android\\s"+Ex,"i")],[Mhe]:[new RegExp(Qhe+"\\/"+Ex)],[uH]:[new RegExp("(rv:|MSIE )"+Ex)],Mozilla:[new RegExp("rv:"+Ex)]},xWe=function(r,e){var t=Ghe(r,e),n=_We[t];if(dc(n))return null;for(var i=0;i<n.length;i++){var o=n[i],a=r.match(o);if(a)return parseFloat(a[a.length-2])}return null},Ohe=[[new RegExp(MM+"; "+MM+" (.*?)[);]","i"),r=>[MM,r&&r[1]||""]],[new RegExp(D3,"i"),[D3,""]],[new RegExp(R3,"i"),[R3,""]],[mH,[wM,""]],[new RegExp(N3,"i"),(r,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[fH,""];if(new RegExp(WB).test(e)&&!/IEMobile\b/.test(e))return[N3+" "+WB,""];var t=/Windows NT ([0-9.]+)/i.exec(e);if(t&&t[1]){var n=t[1],i=CWe[n]||"";return/arm/i.test(e)&&(i="RT"),[N3,i]}return[N3,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,r=>{if(r&&r[3]){var e=[r[3],r[4],r[5]||"0"];return[kP,e.join(".")]}return[kP,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,r=>{var e="";return r&&r.length>=3&&(e=dc(r[2])?r[3]:r[2]),["watchOS",e]}],[new RegExp("("+tS+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+tS+")","i"),r=>{if(r&&r[2]){var e=[r[2],r[3],r[4]||"0"];return[tS,e.join(".")]}return[tS,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,r=>{var e=["Mac OS X",""];if(r&&r[1]){var t=[r[1],r[2],r[3]||"0"];e[1]=t.join(".")}return e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[pWe,""]],[/Linux|debian/i,["Linux",""]]],zhe=function(r){return IWe.test(r)?D3:vWe.test(r)?R3:yWe.test(r)?MM:new RegExp(hH,"i").test(r)?hH:new RegExp("("+fH+"|WPDesktop)","i").test(r)?fH:/iPad/.test(r)?Bhe:/iPod/.test(r)?"iPod Touch":/iPhone/.test(r)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(r)?She:mH.test(r)?wM:/(kobo)\s(ereader|touch)/i.test(r)?"Kobo":new RegExp(Uhe,"i").test(r)?Uhe:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(r)||/(kf[a-z]+)( bui|\)).+silk\//i.test(r)?"Kindle Fire":/(Android|ZTE)/i.test(r)?!new RegExp(WB).test(r)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(r)?/pixel[\daxl ]{1,6}/i.test(r)&&!/pixel c/i.test(r)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(r)||/lmy47v/i.test(r)&&!/QTAQZ3/i.test(r)?tS:xhe:tS:new RegExp("(pda|"+WB+")","i").test(r)?mWe:new RegExp(Q3,"i").test(r)&&!new RegExp(Q3+" pc","i").test(r)?Lhe:""},UP="https?://(.*)",FP=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],BWe=lP(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],FP),yH="<masked>",bWe=["li_fat_id"];function Hhe(r,e,t){if(!Au)return{};var n,i=e?lP([],FP,t||[]):[],o=Yhe(Gz(Au.URL,i,yH),r),a=(n={},av(bWe,function(s){var l=Xb.D(s);n[s]=l||null}),n);return u1(a,o)}function Yhe(r,e){var t=BWe.concat(e||[]),n={};return av(t,function(i){var o=IP(r,i);n[i]=o||null}),n}function Vhe(r){var e=function(o){return o?o.search(UP+"google.([^/?]*)")===0?"google":o.search(UP+"bing.com")===0?"bing":o.search(UP+"yahoo.com")===0?"yahoo":o.search(UP+"duckduckgo.com")===0?"duckduckgo":null:null}(r),t=e!="yahoo"?"q":"p",n={};if(!rQ(e)){n.$search_engine=e;var i=Au?IP(Au.referrer,t):"";i.length&&(n.ph_keyword=i)}return n}function Khe(){return navigator.language||navigator.userLanguage}function jhe(){return(Au==null?void 0:Au.referrer)||"$direct"}function Jhe(r,e){var t=r?lP([],FP,e||[]):[],n=Wx==null?void 0:Wx.href.substring(0,1e3);return{r:jhe().substring(0,1e3),u:n?Gz(n,t,yH):void 0}}function Whe(r){var e,{r:t,u:n}=r,i={$referrer:t,$referring_domain:t==null?void 0:t=="$direct"?"$direct":(e=_M(t))==null?void 0:e.host};if(n){i.$current_url=n;var o=_M(n);i.$host=o==null?void 0:o.host,i.$pathname=o==null?void 0:o.pathname;var a=Yhe(n);u1(i,a)}if(t){var s=Vhe(t);u1(i,s)}return i}function qhe(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function SWe(){try{return new Date().getTimezoneOffset()}catch{return}}function wWe(r,e){if(!qx)return{};var t,n,i,o=r?lP([],FP,e||[]):[],[a,s]=function(l){for(var c=0;c<Ohe.length;c++){var[u,A]=Ohe[c],d=u.exec(l),f=d&&(jB(A)?A(d,l):A);if(f)return f}return["",""]}(qx);return u1(Bz({$os:a,$os_version:s,$browser:Ghe(qx,navigator.vendor),$device:zhe(qx),$device_type:(n=qx,i=zhe(n),i===Bhe||i===xhe||i==="Kobo"||i==="Kindle Fire"||i===Lhe?Q3:i===D3||i===MM||i===R3||i===hH?"Console":i===She?"Wearable":i?WB:"Desktop"),$timezone:qhe(),$timezone_offset:SWe()}),{$current_url:Gz(Wx==null?void 0:Wx.href,o,yH),$host:Wx==null?void 0:Wx.host,$pathname:Wx==null?void 0:Wx.pathname,$raw_user_agent:qx.length>1e3?qx.substring(0,997)+"...":qx,$browser_version:xWe(qx,navigator.vendor),$browser_language:Khe(),$browser_language_prefix:(t=Khe(),typeof t=="string"?t.split("-")[0]:void 0),$screen_height:xo==null?void 0:xo.screen.height,$screen_width:xo==null?void 0:xo.screen.width,$viewport_height:xo==null?void 0:xo.innerHeight,$viewport_width:xo==null?void 0:xo.innerWidth,$lib:"web",$lib_version:ZS.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}var nS=XE("[FeatureFlags]"),vH="$active_feature_flags",DM="$override_feature_flags",Zhe="$feature_flag_payloads",T3="$override_feature_flag_payloads",Xhe="$feature_flag_request_id",$he=r=>{var e={};for(var[t,n]of cP(r||{}))n&&(e[t]=n);return e},QWe=r=>{var e=r.flags;return e?(r.featureFlags=Object.fromEntries(Object.keys(e).map(t=>{var n;return[t,(n=e[t].variant)!==null&&n!==void 0?n:e[t].enabled]})),r.featureFlagPayloads=Object.fromEntries(Object.keys(e).filter(t=>e[t].enabled).filter(t=>{var n;return(n=e[t].metadata)==null?void 0:n.payload}).map(t=>{var n;return[t,(n=e[t].metadata)==null?void 0:n.payload]}))):nS.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),r},MWe=function(r){return r.FeatureFlags="feature_flags",r.Recordings="recordings",r}({});class DWe{constructor(e){this.ge=!1,this._e=!1,this.me=!1,this.be=!1,this.ye=!1,this.we=!1,this.Se=!1,this._instance=e,this.featureFlagEventHandlers=[]}flags(){if(this._instance.config.__preview_remote_config)this.we=!0;else{var e=!this.$e&&(this._instance.config.advanced_disable_feature_flags||this._instance.config.advanced_disable_feature_flags_on_first_load);this.ke({disableFlags:e})}}get hasLoadedFlags(){return this._e}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(Dz),t=this._instance.get_property(DM),n=this._instance.get_property(T3);if(!n&&!t)return e||{};var i=u1({},e||{}),o=[...new Set([...Object.keys(n||{}),...Object.keys(t||{})])];for(var a of o){var s,l,c=i[a],u=t==null?void 0:t[a],A=dc(u)?(s=c==null?void 0:c.enabled)!==null&&s!==void 0&&s:!!u,d=dc(u)?c.variant:typeof u=="string"?u:void 0,f=n==null?void 0:n[a],m=Wc({},c,{enabled:A,variant:A?d??(c==null?void 0:c.variant):void 0});A!==(c==null?void 0:c.enabled)&&(m.original_enabled=c==null?void 0:c.enabled),d!==(c==null?void 0:c.variant)&&(m.original_variant=c==null?void 0:c.variant),f&&(m.metadata=Wc({},c==null?void 0:c.metadata,{payload:f,original_payload:c==null||(l=c.metadata)==null?void 0:l.payload})),i[a]=m}return this.ge||(nS.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:n,finalDetails:i}),this.ge=!0),i}getFlagVariants(){var e=this._instance.get_property(CM),t=this._instance.get_property(DM);if(!t)return e||{};for(var n=u1({},e),i=Object.keys(t),o=0;o<i.length;o++)n[i[o]]=t[i[o]];return this.ge||(nS.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:n}),this.ge=!0),n}getFlagPayloads(){var e=this._instance.get_property(Zhe),t=this._instance.get_property(T3);if(!t)return e||{};for(var n=u1({},e||{}),i=Object.keys(t),o=0;o<i.length;o++)n[i[o]]=t[i[o]];return this.ge||(nS.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:n}),this.ge=!0),n}reloadFeatureFlags(){this.be||this._instance.config.advanced_disable_feature_flags||this.$e||(this.$e=setTimeout(()=>{this.ke()},5))}xe(){clearTimeout(this.$e),this.$e=void 0}ensureFlagsLoaded(){this._e||this.me||this.$e||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.be=e}ke(e){var t;if(this.xe(),!this._instance.I())if(this.me)this.ye=!0;else{var n={token:this._instance.config.token,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:Wc({},((t=this._instance.persistence)==null?void 0:t.get_initial_props())||{},this._instance.get_property(C3)||{}),group_properties:this._instance.get_property(h2)};(e!=null&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(n.disable_flags=!0);var i=this._instance.config.__preview_remote_config,o=i?"/flags/?v=2":"/flags/?v=2&config=true",a=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",s=this._instance.requestRouter.endpointFor("api",o+a);i&&(n.timezone=qhe()),this.me=!0,this._instance.Ee({method:"POST",url:s,data:n,compression:this._instance.config.disable_compression?void 0:XS.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:l=>{var c,u,A=!0;if(l.statusCode===200&&(this.ye||(this.$anon_distinct_id=void 0),A=!1),this.me=!1,this.we||(this.we=!0,this._instance.Ie((u=l.json)!==null&&u!==void 0?u:{})),!n.disable_flags||this.ye)if(this.Se=!A,l.json&&(c=l.json.quotaLimited)!=null&&c.includes(MWe.FeatureFlags))nS.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.");else{var d;n.disable_flags||this.receivedFeatureFlags((d=l.json)!==null&&d!==void 0?d:{},A),this.ye&&(this.ye=!1,this.ke())}}})}}getFeatureFlag(e,t){if(t===void 0&&(t={}),this._e||this.getFlags()&&this.getFlags().length>0){var n=this.getFlagVariants()[e],i=""+n,o=this._instance.get_property(Xhe)||void 0,a=this._instance.get_property(fP)||{};if((t.send_event||!("send_event"in t))&&(!(e in a)||!a[e].includes(i))){var s,l,c,u,A,d,f,m,C;OI(a[e])?a[e].push(i):a[e]=[i],(s=this._instance.persistence)==null||s.register({[fP]:a});var E=this.getFeatureFlagDetails(e),_={$feature_flag:e,$feature_flag_response:n,$feature_flag_payload:this.getFeatureFlagPayload(e)||null,$feature_flag_request_id:o,$feature_flag_bootstrapped_response:((l=this._instance.config.bootstrap)==null||(l=l.featureFlags)==null?void 0:l[e])||null,$feature_flag_bootstrapped_payload:((c=this._instance.config.bootstrap)==null||(c=c.featureFlagPayloads)==null?void 0:c[e])||null,$used_bootstrap_value:!this.Se};dc(E==null||(u=E.metadata)==null?void 0:u.version)||(_.$feature_flag_version=E.metadata.version);var x,w=(A=E==null||(d=E.reason)==null?void 0:d.description)!==null&&A!==void 0?A:E==null||(f=E.reason)==null?void 0:f.code;w&&(_.$feature_flag_reason=w),E!=null&&(m=E.metadata)!=null&&m.id&&(_.$feature_flag_id=E.metadata.id),dc(E==null?void 0:E.original_variant)&&dc(E==null?void 0:E.original_enabled)||(_.$feature_flag_original_response=dc(E.original_variant)?E.original_enabled:E.original_variant),E!=null&&(C=E.metadata)!=null&&C.original_payload&&(_.$feature_flag_original_payload=E==null||(x=E.metadata)==null?void 0:x.original_payload),this._instance.capture("$feature_flag_called",_)}return n}nS.warn('getFeatureFlag for key "'+e+`" failed. Feature flags didn't load in time.`)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){return this.getFlagPayloads()[e]}getRemoteConfigPayload(e,t){var n=this._instance.config.token;this._instance.Ee({method:"POST",url:this._instance.requestRouter.endpointFor("api","/flags/?v=2&config=true"),data:{distinct_id:this._instance.get_distinct_id(),token:n},compression:this._instance.config.disable_compression?void 0:XS.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:i=>{var o,a=(o=i.json)==null?void 0:o.featureFlagPayloads;t((a==null?void 0:a[e])||void 0)}})}isFeatureEnabled(e,t){if(t===void 0&&(t={}),this._e||this.getFlags()&&this.getFlags().length>0)return!!this.getFeatureFlag(e,t);nS.warn('isFeatureEnabled for key "'+e+`" failed. Feature flags didn't load in time.`)}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(t=>t!==e)}receivedFeatureFlags(e,t){if(this._instance.persistence){this._e=!0;var n=this.getFlagVariants(),i=this.getFlagPayloads(),o=this.getFlagsWithDetails();(function(a,s,l,c,u){l===void 0&&(l={}),c===void 0&&(c={}),u===void 0&&(u={});var A=QWe(a),d=A.flags,f=A.featureFlags,m=A.featureFlagPayloads;if(f){var C=a.requestId;if(OI(f)){nS.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var E={};if(f)for(var _=0;_<f.length;_++)E[f[_]]=!0;s&&s.register({[vH]:f,[CM]:E})}else{var x=f,w=m,P=d;a.errorsWhileComputingFlags&&(x=Wc({},l,x),w=Wc({},c,w),P=Wc({},u,P)),s&&s.register(Wc({[vH]:Object.keys($he(x)),[CM]:x||{},[Zhe]:w||{},[Dz]:P||{}},C?{[Xhe]:C}:{}))}}})(e,this._instance.persistence,n,i,o),this.Pe(t)}}override(e,t){t===void 0&&(t=!1),nS.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return nS.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(e===!1)return this._instance.persistence.unregister(DM),this._instance.persistence.unregister(T3),void this.Pe();if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var t,n=e;if(this.ge=!!((t=n.suppressWarning)!==null&&t!==void 0&&t),"flags"in n){if(n.flags===!1)this._instance.persistence.unregister(DM);else if(n.flags)if(OI(n.flags)){for(var i={},o=0;o<n.flags.length;o++)i[n.flags[o]]=!0;this._instance.persistence.register({[DM]:i})}else this._instance.persistence.register({[DM]:n.flags})}return"payloads"in n&&(n.payloads===!1?this._instance.persistence.unregister(T3):n.payloads&&this._instance.persistence.register({[T3]:n.payloads})),void this.Pe()}this.Pe()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this._e){var{flags:t,flagVariants:n}=this.Re();e(t,n)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t){var n,i=(this._instance.get_property(AP)||[]).find(l=>l.flagKey===e),o={["$feature_enrollment/"+e]:t},a={$feature_flag:e,$feature_enrollment:t,$set:o};i&&(a.$early_access_feature_name=i.name),this._instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(o,!1);var s=Wc({},this.getFlagVariants(),{[e]:t});(n=this._instance.persistence)==null||n.register({[vH]:Object.keys($he(s)),[CM]:s}),this.Pe()}getEarlyAccessFeatures(e,t,n){t===void 0&&(t=!1);var i=this._instance.get_property(AP),o=n?"&"+n.map(a=>"stage="+a).join("&"):"";if(i&&!t)return e(i);this._instance.Ee({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._instance.config.token+o),method:"GET",callback:a=>{var s;if(a.json){var l=a.json.earlyAccessFeatures;return(s=this._instance.persistence)==null||s.register({[AP]:l}),e(l)}}})}Re(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter(n=>t[n]),flagVariants:Object.keys(t).filter(n=>t[n]).reduce((n,i)=>(n[i]=t[i],n),{})}}Pe(e){var{flags:t,flagVariants:n}=this.Re();this.featureFlagEventHandlers.forEach(i=>i(t,n,{errorsLoading:e}))}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=this._instance.get_property(C3)||{};this._instance.register({[C3]:Wc({},n,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(C3)}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=this._instance.get_property(h2)||{};Object.keys(n).length!==0&&Object.keys(n).forEach(i=>{n[i]=Wc({},n[i],e[i]),delete e[i]}),this._instance.register({[h2]:Wc({},n,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(h2)||{};this._instance.register({[h2]:Wc({},t,{[e]:{}})})}else this._instance.unregister(h2)}reset(){this._e=!1,this.me=!1,this.be=!1,this.ye=!1,this.we=!1,this.Se=!1,this.$anon_distinct_id=void 0,this.xe(),this.ge=!1}}var RWe=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class IH{constructor(e,t){this.S=e,this.props={},this.Te=!1,this.Me=(n=>{var i="";return n.token&&(i=n.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),n.persistence_name?"ph_"+n.persistence_name:"ph_"+i+"_posthog"})(e),this.B=this.Ce(e),this.load(),e.debug&&bu.info("Persistence loaded",e.persistence,Wc({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.Fe}Ce(e){RWe.indexOf(e.persistence.toLowerCase())===-1&&(bu.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=e.persistence.toLowerCase();return t==="localstorage"&&rE.O()?rE:t==="localstorage+cookie"&&_P.O()?_P:t==="sessionstorage"&&v_.O()?v_:t==="memory"?uJe:t==="cookie"?Xb:_P.O()?_P:Xb}properties(){var e={};return av(this.props,function(t,n){if(n===CM&&TC(t))for(var i=Object.keys(t),o=0;o<i.length;o++)e["$feature/"+i[o]]=t[i[o]];else s=n,l=!1,(rQ(a=Yje)?l:efe&&a.indexOf===efe?a.indexOf(s)!=-1:(av(a,function(c){if(l||(l=c===s))return sP}),l))||(e[n]=t);var a,s,l}),e}load(){if(!this.Fe){var e=this.B.L(this.Me);e&&(this.props=u1({},e))}}save(){this.Fe||this.B.j(this.Me,this.props,this.Oe,this.Ae,this.De,this.S.debug)}remove(){this.B.N(this.Me,!1),this.B.N(this.Me,!0)}clear(){this.remove(),this.props={}}register_once(e,t,n){if(TC(e)){dc(t)&&(t="None"),this.Oe=dc(n)?this.Le:n;var i=!1;if(av(e,(o,a)=>{this.props.hasOwnProperty(a)&&this.props[a]!==t||(this.props[a]=o,i=!0)}),i)return this.save(),!0}return!1}register(e,t){if(TC(e)){this.Oe=dc(t)?this.Le:t;var n=!1;if(av(e,(i,o)=>{e.hasOwnProperty(o)&&this.props[o]!==i&&(this.props[o]=i,n=!0)}),n)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.Te){var e=Hhe(this.S.custom_campaign_params,this.S.mask_personal_data_properties,this.S.custom_personal_data_properties);IM(Bz(e))||this.register(e),this.Te=!0}}update_search_keyword(){var e;this.register((e=Au==null?void 0:Au.referrer)?Vhe(e):{})}update_referrer_info(){var e;this.register_once({$referrer:jhe(),$referring_domain:Au!=null&&Au.referrer&&((e=_M(Au.referrer))==null?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[Pz]||this.props[kz]||this.register_once({[hP]:Jhe(this.S.mask_personal_data_properties,this.S.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};av([kz,Pz],a=>{var s=this.props[a];s&&av(s,function(l,c){e["$initial_"+_z(c)]=l})});var t,n,i=this.props[hP];if(i){var o=(t=Whe(i),n={},av(t,function(a,s){n["$initial_"+_z(s)]=a}),n);u1(e,o)}return e}safe_merge(e){return av(this.props,function(t,n){n in e||(e[n]=t)}),e}update_config(e,t,n){if(this.Le=this.Oe=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!n),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence){var i=this.Ce(e),o=this.props;this.clear(),this.B=i,this.props=o,this.save()}}set_disabled(e){this.Fe=e,this.Fe?this.remove():this.save()}set_cross_subdomain(e){e!==this.Ae&&(this.Ae=e,this.remove(),this.save())}set_secure(e){e!==this.De&&(this.De=e,this.remove(),this.save())}set_event_timer(e,t){var n=this.props[v3]||{};n[e]=t,this.props[v3]=n,this.save()}remove_event_timer(e){var t=(this.props[v3]||{})[e];return dc(t)||(delete this.props[v3][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}}class epe{constructor(){this.je={},this.je={}}on(e,t){return this.je[e]||(this.je[e]=[]),this.je[e].push(t),()=>{this.je[e]=this.je[e].filter(n=>n!==t)}}emit(e,t){for(var n of this.je[e]||[])n(t);for(var i of this.je["*"]||[])i(e,t)}}class C2{constructor(e){this.Ne=new epe,this.ze=(t,n)=>this.Ue(t,n)&&this.qe(t,n)&&this.Be(t,n),this.Ue=(t,n)=>n==null||!n.event||(t==null?void 0:t.event)===(n==null?void 0:n.event),this._instance=e,this.He=new Set,this.We=new Set}init(){var e;if(!dc((e=this._instance)==null?void 0:e.Ge)){var t;(t=this._instance)==null||t.Ge((n,i)=>{this.on(n,i)})}}register(e){var t,n;if(!dc((t=this._instance)==null?void 0:t.Ge)&&(e.forEach(a=>{var s,l;(s=this.We)==null||s.add(a),(l=a.steps)==null||l.forEach(c=>{var u;(u=this.He)==null||u.add((c==null?void 0:c.event)||"")})}),(n=this._instance)!=null&&n.autocapture)){var i,o=new Set;e.forEach(a=>{var s;(s=a.steps)==null||s.forEach(l=>{l!=null&&l.selector&&o.add(l==null?void 0:l.selector)})}),(i=this._instance)==null||i.autocapture.setElementSelectors(o)}}on(e,t){var n;t!=null&&e.length!=0&&(this.He.has(e)||this.He.has(t==null?void 0:t.event))&&this.We&&((n=this.We)==null?void 0:n.size)>0&&this.We.forEach(i=>{this.Je(t,i)&&this.Ne.emit("actionCaptured",i.name)})}Ve(e){this.onAction("actionCaptured",t=>e(t))}Je(e,t){if((t==null?void 0:t.steps)==null)return!1;for(var n of t.steps)if(this.ze(e,n))return!0;return!1}onAction(e,t){return this.Ne.on(e,t)}qe(e,t){if(t!=null&&t.url){var n,i=e==null||(n=e.properties)==null?void 0:n.$current_url;if(!i||typeof i!="string"||!C2.Ke(i,t==null?void 0:t.url,(t==null?void 0:t.url_matching)||"contains"))return!1}return!0}static Ke(e,t,n){switch(n){case"regex":return!!xo&&SM(e,t);case"exact":return t===e;case"contains":var i=C2.Ye(t).replace(/_/g,".").replace(/%/g,".*");return SM(e,i);default:return!1}}static Ye(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}Be(e,t){if((t!=null&&t.href||t!=null&&t.tag_name||t!=null&&t.text)&&!this.Xe(e).some(o=>!(t!=null&&t.href&&!C2.Ke(o.href||"",t==null?void 0:t.href,(t==null?void 0:t.href_matching)||"exact"))&&(t==null||!t.tag_name||o.tag_name===(t==null?void 0:t.tag_name))&&!(t!=null&&t.text&&!C2.Ke(o.text||"",t==null?void 0:t.text,(t==null?void 0:t.text_matching)||"exact")&&!C2.Ke(o.$el_text||"",t==null?void 0:t.text,(t==null?void 0:t.text_matching)||"exact"))))return!1;if(t!=null&&t.selector){var n,i=e==null||(n=e.properties)==null?void 0:n.$element_selectors;if(!i||!i.includes(t==null?void 0:t.selector))return!1}return!0}Xe(e){return(e==null?void 0:e.properties.$elements)==null?[]:e==null?void 0:e.properties.$elements}}var $E=XE("[Surveys]"),CH="seenSurvey_",NWe=(r,e)=>{var t="$survey_"+e+"/"+r.id;return r.current_iteration&&r.current_iteration>0&&(t="$survey_"+e+"/"+r.id+"/"+r.current_iteration),t};class TWe{constructor(e){this._instance=e,this.Qe=new Map,this.Ze=new Map}register(e){var t;dc((t=this._instance)==null?void 0:t.Ge)||(this.tr(e),this.ir(e))}ir(e){var t=e.filter(n=>{var i,o;return((i=n.conditions)==null?void 0:i.actions)&&((o=n.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length)>0});t.length!==0&&(this.er==null&&(this.er=new C2(this._instance),this.er.init(),this.er.Ve(n=>{this.onAction(n)})),t.forEach(n=>{var i,o,a,s,l;n.conditions&&(i=n.conditions)!=null&&i.actions&&(o=n.conditions)!=null&&(o=o.actions)!=null&&o.values&&((a=n.conditions)==null||(a=a.actions)==null||(a=a.values)==null?void 0:a.length)>0&&((s=this.er)==null||s.register(n.conditions.actions.values),(l=n.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach(c=>{if(c&&c.name){var u=this.Ze.get(c.name);u&&u.push(n.id),this.Ze.set(c.name,u||[n.id])}}))}))}tr(e){var t;e.filter(n=>{var i,o;return((i=n.conditions)==null?void 0:i.events)&&((o=n.conditions)==null||(o=o.events)==null||(o=o.values)==null?void 0:o.length)>0}).length!==0&&((t=this._instance)==null||t.Ge((n,i)=>{this.onEvent(n,i)}),e.forEach(n=>{var i;(i=n.conditions)==null||(i=i.events)==null||(i=i.values)==null||i.forEach(o=>{if(o&&o.name){var a=this.Qe.get(o.name);a&&a.push(n.id),this.Qe.set(o.name,a||[n.id])}})}))}onEvent(e,t){var n,i=((n=this._instance)==null||(n=n.persistence)==null?void 0:n.props[dP])||[];if(e==="survey shown"&&t&&i.length>0){var o;$E.info("survey event matched, removing survey from activated surveys",{event:e,eventPayload:t,existingActivatedSurveys:i});var a=t==null||(o=t.properties)==null?void 0:o.$survey_id;if(a){var s=i.indexOf(a);s>=0&&(i.splice(s,1),this.rr(i))}}else this.Qe.has(e)&&($E.info("survey event matched, updating activated surveys",{event:e,surveys:this.Qe.get(e)}),this.rr(i.concat(this.Qe.get(e)||[])))}onAction(e){var t,n=((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[dP])||[];this.Ze.has(e)&&this.rr(n.concat(this.Ze.get(e)||[]))}rr(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({[dP]:[...new Set(e)]})}getSurveys(){var e,t=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[dP];return t||[]}getEventToSurveys(){return this.Qe}sr(){return this.er}}class PWe{constructor(e){this.nr=void 0,this.ar=null,this.lr=!1,this.ur=!1,this.hr=[],this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){var t=e.surveys;if(Um(t))return $E.warn("Flags not loaded yet. Not loading surveys.");var n=OI(t);this.nr=n?t.length>0:t,$E.info("flags response received, isSurveysEnabled: "+this.nr),this.loadIfEnabled()}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var e=[],t=0;t<localStorage.length;t++){var n=localStorage.key(t);(n!=null&&n.startsWith(CH)||n!=null&&n.startsWith("inProgressSurvey_"))&&e.push(n)}e.forEach(i=>localStorage.removeItem(i))}loadIfEnabled(){if(!this.ar)if(this.ur)$E.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)$E.info("Disabled. Not loading surveys.");else{var e=wh==null?void 0:wh.__PosthogExtensions__;if(e){var t=this.nr;if(!dc(t)){this.ur=!0;try{var n=e.generateSurveys;if(n)return void this.dr(n,t);var i=e.loadExternalDependency;if(!i)return void this.vr("PostHog loadExternalDependency extension not found.");i(this._instance,"surveys",o=>{o||!e.generateSurveys?this.vr("Could not load surveys script",o):this.dr(e.generateSurveys,t)})}catch(o){throw this.vr("Error initializing surveys",o),o}finally{this.ur=!1}}}else $E.error("PostHog Extensions not found.")}}dr(e,t){this.ar=e(this._instance,t),this._surveyEventReceiver=new TWe(this._instance),$E.info("Surveys loaded successfully"),this.cr({isLoaded:!0})}vr(e,t){$E.error(e,t),this.cr({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.hr.push(e),this.ar&&this.cr({isLoaded:!0}),()=>{this.hr=this.hr.filter(t=>t!==e)}}getSurveys(e,t){if(t===void 0&&(t=!1),this._instance.config.disable_surveys)return $E.info("Disabled. Not loading surveys."),e([]);var n=this._instance.get_property(Rz);if(n&&!t)return e(n,{isLoaded:!0});if(this.lr)return e([],{isLoaded:!1,error:"Surveys are already being loaded"});try{this.lr=!0,this._instance.Ee({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this._instance.config.token),method:"GET",timeout:this._instance.config.surveys_request_timeout_ms,callback:i=>{var o;this.lr=!1;var a=i.statusCode;if(a!==200||!i.json){var s="Surveys API could not be loaded, status: "+a;return $E.error(s),e([],{isLoaded:!1,error:s})}var l,c=i.json.surveys||[],u=c.filter(A=>function(d){return!(!d.start_date||d.end_date)}(A)&&(function(d){var f;return!((f=d.conditions)==null||(f=f.events)==null||(f=f.values)==null||!f.length)}(A)||function(d){var f;return!((f=d.conditions)==null||(f=f.actions)==null||(f=f.values)==null||!f.length)}(A)));return u.length>0&&((l=this._surveyEventReceiver)==null||l.register(u)),(o=this._instance.persistence)==null||o.register({[Rz]:c}),e(c,{isLoaded:!0})}})}catch(i){throw this.lr=!1,i}}cr(e){for(var t of this.hr)try{e.isLoaded?this.getSurveys(t):t([],e)}catch(n){$E.error("Error in survey callback",n)}}getActiveMatchingSurveys(e,t){if(t===void 0&&(t=!1),!Um(this.ar))return this.ar.getActiveMatchingSurveys(e,t);$E.warn("init was not called")}pr(e){var t=null;return this.getSurveys(n=>{var i;t=(i=n.find(o=>o.id===e))!==null&&i!==void 0?i:null}),t}gr(e){if(Um(this.ar))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var t=typeof e=="string"?this.pr(e):e;return t?this.ar.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(Um(this.ar))return $E.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var t=this.gr(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return Um(this.ar)?($E.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"})):new Promise(n=>{this.getSurveys(i=>{var o,a=(o=i.find(l=>l.id===e))!==null&&o!==void 0?o:null;if(a){var s=this.gr(a);n({visible:s.eligible,disabledReason:s.reason})}else n({visible:!1,disabledReason:"Survey not found"})},t)})}renderSurvey(e,t){if(Um(this.ar))$E.warn("init was not called");else{var n=this.pr(e),i=Au==null?void 0:Au.querySelector(t);n?i?this.ar.renderSurvey(n,i):$E.warn("Survey element not found"):$E.warn("Survey not found")}}}(function(r){return r.Button="button",r.Tab="tab",r.Selector="selector",r})({}),function(r){return r.TopLeft="top_left",r.TopRight="top_right",r.TopCenter="top_center",r.MiddleLeft="middle_left",r.MiddleRight="middle_right",r.MiddleCenter="middle_center",r.Left="left",r.Center="center",r.Right="right",r.NextToTrigger="next_to_trigger",r}({}),function(r){return r.Popover="popover",r.API="api",r.Widget="widget",r}({}),function(r){return r.Open="open",r.MultipleChoice="multiple_choice",r.SingleChoice="single_choice",r.Rating="rating",r.Link="link",r}({}),function(r){return r.NextQuestion="next_question",r.End="end",r.ResponseBased="response_based",r.SpecificQuestion="specific_question",r}({}),function(r){return r.Once="once",r.Recurring="recurring",r.Always="always",r}({});var EH=function(r){return r.SHOWN="survey shown",r.DISMISSED="survey dismissed",r.SENT="survey sent",r}({}),tpe=function(r){return r.SURVEY_ID="$survey_id",r.SURVEY_NAME="$survey_name",r.SURVEY_RESPONSE="$survey_response",r.SURVEY_ITERATION="$survey_iteration",r.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",r.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",r.SURVEY_SUBMISSION_ID="$survey_submission_id",r.SURVEY_QUESTIONS="$survey_questions",r.SURVEY_COMPLETED="$survey_completed",r}({}),npe=XE("[RateLimiter]");class kWe{constructor(e){var t,n;this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=i=>{var o=i.text;if(o&&o.length)try{(JSON.parse(o).quota_limited||[]).forEach(a=>{npe.info((a||"events")+" is quota limited."),this.serverLimits[a]=new Date().getTime()+6e4})}catch(a){return void npe.warn('could not rate limit - continuing. Error: "'+(a==null?void 0:a.message)+'"',{text:o})}},this.instance=e,this.captureEventsPerSecond=((t=e.config.rate_limiting)==null?void 0:t.events_per_second)||10,this.captureEventsBurstLimit=Math.max(((n=e.config.rate_limiting)==null?void 0:n.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond),this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}clientRateLimitContext(e){var t,n,i;e===void 0&&(e=!1);var o=new Date().getTime(),a=(t=(n=this.instance.persistence)==null?void 0:n.get_property(Tz))!==null&&t!==void 0?t:{tokens:this.captureEventsBurstLimit,last:o};a.tokens+=(o-a.last)/1e3*this.captureEventsPerSecond,a.last=o,a.tokens>this.captureEventsBurstLimit&&(a.tokens=this.captureEventsBurstLimit);var s=a.tokens<1;return s||e||(a.tokens=Math.max(0,a.tokens-1)),!s||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+this.captureEventsPerSecond+" events per second and "+this.captureEventsBurstLimit+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=s,(i=this.instance.persistence)==null||i.set_property(Tz,a),{isRateLimited:s,remainingTokens:a.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}}var E2=XE("[RemoteConfig]");class UWe{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=wh._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}_r(e){var t,n;(t=wh.__PosthogExtensions__)!=null&&t.loadExternalDependency?(n=wh.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,"remote-config",()=>e(this.remoteConfig)):(E2.error("PostHog Extensions not found. Cannot load remote config."),e())}mr(e){this._instance.Ee({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t=>{e(t.json)}})}load(){try{if(this.remoteConfig)return E2.info("Using preloaded remote config",this.remoteConfig),void this.Ie(this.remoteConfig);if(this._instance.I())return void E2.warn("Remote config is disabled. Falling back to local config.");this._r(e=>{if(!e)return E2.info("No config found after loading remote JS config. Falling back to JSON."),void this.mr(t=>{this.Ie(t)});this.Ie(e)})}catch(e){E2.error("Error loading remote config",e)}}Ie(e){e?this._instance.config.__preview_remote_config?(this._instance.Ie(e),e.hasFeatureFlags!==!1&&this._instance.featureFlags.ensureFlagsLoaded()):E2.info("__preview_remote_config is disabled. Logging config instead",e):E2.error("Failed to fetch remote config from PostHog.")}}var _H=3e3;class FWe{constructor(e,t){this.br=!0,this.yr=[],this.wr=xB((t==null?void 0:t.flush_interval_ms)||_H,250,5e3,"flush interval",_H),this.Sr=e}enqueue(e){this.yr.push(e),this.$r||this.kr()}unload(){this.Er();var e=this.yr.length>0?this.Ir():{},t=Object.values(e);[...t.filter(n=>n.url.indexOf("/e")===0),...t.filter(n=>n.url.indexOf("/e")!==0)].map(n=>{this.Sr(Wc({},n,{transport:"sendBeacon"}))})}enable(){this.br=!1,this.kr()}kr(){var e=this;this.br||(this.$r=setTimeout(()=>{if(this.Er(),this.yr.length>0){var t=this.Ir(),n=function(){var o=t[i],a=new Date().getTime();o.data&&OI(o.data)&&av(o.data,s=>{s.offset=Math.abs(s.timestamp-a),delete s.timestamp}),e.Sr(o)};for(var i in t)n()}},this.wr))}Er(){clearTimeout(this.$r),this.$r=void 0}Ir(){var e={};return av(this.yr,t=>{var n,i=t,o=(i?i.batchKey:null)||i.url;dc(e[o])&&(e[o]=Wc({},i,{data:[]})),(n=e[o].data)==null||n.push(i.data)}),this.yr=[],e}}var LWe=["retriesPerformedSoFar"];class GWe{constructor(e){this.Pr=!1,this.Rr=3e3,this.yr=[],this._instance=e,this.yr=[],this.Tr=!0,!dc(xo)&&"onLine"in xo.navigator&&(this.Tr=xo.navigator.onLine,oC(xo,"online",()=>{this.Tr=!0,this.se()}),oC(xo,"offline",()=>{this.Tr=!1}))}get length(){return this.yr.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,n=afe(e,LWe);q_(t)&&t>0&&(n.url=TP(n.url,{retry_count:t})),this._instance.Ee(Wc({},n,{callback:i=>{i.statusCode!==200&&(i.statusCode<400||i.statusCode>=500)&&(t??0)<10?this.Mr(Wc({retriesPerformedSoFar:t},n)):n.callback==null||n.callback(i)}}))}Mr(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var n=function(a){var s=3e3*Math.pow(2,a),l=s/2,c=Math.min(18e5,s),u=(Math.random()-.5)*(c-l);return Math.ceil(c+u)}(t),i=Date.now()+n;this.yr.push({retryAt:i,requestOptions:e});var o="Enqueued failed request for retry in "+n;navigator.onLine||(o+=" (Browser is offline)"),bu.warn(o),this.Pr||(this.Pr=!0,this.Cr())}Cr(){this.Fr&&clearTimeout(this.Fr),this.Fr=setTimeout(()=>{this.Tr&&this.yr.length>0&&this.se(),this.Cr()},this.Rr)}se(){var e=Date.now(),t=[],n=this.yr.filter(o=>o.retryAt<e||(t.push(o),!1));if(this.yr=t,n.length>0)for(var{requestOptions:i}of n)this.retriableRequest(i)}unload(){for(var{requestOptions:e}of(this.Fr&&(clearTimeout(this.Fr),this.Fr=void 0),this.yr))try{this._instance.Ee(Wc({},e,{transport:"sendBeacon"}))}catch(t){bu.error(t)}this.yr=[]}}class OWe{constructor(e){this.Or=()=>{var t,n,i,o;this.Ar||(this.Ar={});var a=this.scrollElement(),s=this.scrollY(),l=a?Math.max(0,a.scrollHeight-a.clientHeight):0,c=s+((a==null?void 0:a.clientHeight)||0),u=(a==null?void 0:a.scrollHeight)||0;this.Ar.lastScrollY=Math.ceil(s),this.Ar.maxScrollY=Math.max(s,(t=this.Ar.maxScrollY)!==null&&t!==void 0?t:0),this.Ar.maxScrollHeight=Math.max(l,(n=this.Ar.maxScrollHeight)!==null&&n!==void 0?n:0),this.Ar.lastContentY=c,this.Ar.maxContentY=Math.max(c,(i=this.Ar.maxContentY)!==null&&i!==void 0?i:0),this.Ar.maxContentHeight=Math.max(u,(o=this.Ar.maxContentHeight)!==null&&o!==void 0?o:0)},this._instance=e}getContext(){return this.Ar}resetContext(){var e=this.Ar;return setTimeout(this.Or,0),e}startMeasuringScrollPosition(){oC(xo,"scroll",this.Or,{capture:!0}),oC(xo,"scrollend",this.Or,{capture:!0}),oC(xo,"resize",this.Or)}scrollElement(){if(!this._instance.config.scroll_root_selector)return xo==null?void 0:xo.document.documentElement;var e=OI(this._instance.config.scroll_root_selector)?this._instance.config.scroll_root_selector:[this._instance.config.scroll_root_selector];for(var t of e){var n=xo==null?void 0:xo.document.querySelector(t);if(n)return n}}scrollY(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return xo&&(xo.scrollY||xo.pageYOffset||xo.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return xo&&(xo.scrollX||xo.pageXOffset||xo.document.documentElement.scrollLeft)||0}}var zWe=r=>Jhe(r==null?void 0:r.config.mask_personal_data_properties,r==null?void 0:r.config.custom_personal_data_properties);class HWe{constructor(e,t,n,i){this.Dr=o=>{var a=this.Lr();if(!a||a.sessionId!==o){var s={sessionId:o,props:this.jr(this._instance)};this.Nr.register({[Nz]:s})}},this._instance=e,this.zr=t,this.Nr=n,this.jr=i||zWe,this.zr.onSessionId(this.Dr)}Lr(){return this.Nr.props[Nz]}getSetOnceProps(){var e,t=(e=this.Lr())==null?void 0:e.props;return t?"r"in t?Whe(t):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){var e={};return av(Bz(this.getSetOnceProps()),(t,n)=>{n==="$current_url"&&(n="url"),e["$session_entry_"+_z(n)]=t}),e}}var rpe=XE("[SessionId]");class YWe{constructor(e,t,n){var i;if(this.Ur=[],!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.__preview_experimental_cookieless_mode)throw new Error("SessionIdManager cannot be used with __preview_experimental_cookieless_mode");this.S=e.config,this.Nr=e.persistence,this.fi=void 0,this.Ct=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.qr=t||aQ,this.Br=n||aQ;var o=this.S.persistence_name||this.S.token,a=this.S.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*xB(a,60,36e3,"session_idle_timeout_seconds",1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.Hr(),this.Wr="ph_"+o+"_window_id",this.Gr="ph_"+o+"_primary_window_exists",this.Jr()){var s=v_.L(this.Wr),l=v_.L(this.Gr);s&&!l?this.fi=s:v_.N(this.Wr),v_.j(this.Gr,!0)}if((i=this.S.bootstrap)!=null&&i.sessionID)try{var c=(u=>{var A=u.replace(/-/g,"");if(A.length!==32)throw new Error("Not a valid UUID");if(A[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(A.substring(0,12),16)})(this.S.bootstrap.sessionID);this.Vr(this.S.bootstrap.sessionID,new Date().getTime(),c)}catch(u){rpe.error("Invalid sessionID in bootstrap",u)}this.Kr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return dc(this.Ur)&&(this.Ur=[]),this.Ur.push(e),this.Ct&&e(this.Ct,this.fi),()=>{this.Ur=this.Ur.filter(t=>t!==e)}}Jr(){return this.S.persistence!=="memory"&&!this.Nr.Fe&&v_.O()}Yr(e){e!==this.fi&&(this.fi=e,this.Jr()&&v_.j(this.Wr,e))}Xr(){return this.fi?this.fi:this.Jr()?v_.L(this.Wr):null}Vr(e,t,n){e===this.Ct&&t===this._sessionActivityTimestamp&&n===this._sessionStartTimestamp||(this._sessionStartTimestamp=n,this._sessionActivityTimestamp=t,this.Ct=e,this.Nr.register({[uP]:[t,e,n]}))}Qr(){if(this.Ct&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this.Ct,this._sessionStartTimestamp];var e=this.Nr.props[uP];return OI(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.Vr(null,null,null)}Kr(){oC(xo,"beforeunload",()=>{this.Jr()&&v_.N(this.Gr)},{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(e===void 0&&(e=!1),t===void 0&&(t=null),this.S.__preview_experimental_cookieless_mode)throw new Error("checkAndGetSessionAndWindowId should not be called in __preview_experimental_cookieless_mode");var n=t||new Date().getTime(),[i,o,a]=this.Qr(),s=this.Xr(),l=q_(a)&&a>0&&Math.abs(n-a)>864e5,c=!1,u=!o,A=!e&&Math.abs(n-i)>this.sessionTimeoutMs;u||A||l?(o=this.qr(),s=this.Br(),rpe.info("new session ID generated",{sessionId:o,windowId:s,changeReason:{noSessionId:u,activityTimeout:A,sessionPastMaximumLength:l}}),a=n,c=!0):s||(s=this.Br(),c=!0);var d=i===0||!e||l?n:i,f=a===0?new Date().getTime():a;return this.Yr(s),this.Vr(o,d,f),e||this.Hr(),c&&this.Ur.forEach(m=>m(o,s,c?{noSessionId:u,activityTimeout:A,sessionPastMaximumLength:l}:void 0)),{sessionId:o,windowId:s,sessionStartTimestamp:f,changeReason:c?{noSessionId:u,activityTimeout:A,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:i}}Hr(){clearTimeout(this.Zr),this.Zr=setTimeout(()=>{this.resetSessionId()},1.1*this.sessionTimeoutMs)}}var VWe=["$set_once","$set"],uQ=XE("[SiteApps]");class KWe{constructor(e){this._instance=e,this.ts=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}es(e,t){if(t){var n=this.globalsForEvent(t);this.ts.push(n),this.ts.length>1e3&&(this.ts=this.ts.slice(10))}}get siteAppLoaders(){var e;return(e=wh._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}init(){if(this.isEnabled){var e=this._instance.Ge(this.es.bind(this));this.rs=()=>{e(),this.ts=[],this.rs=void 0}}}globalsForEvent(e){var t,n,i,o,a,s,l;if(!e)throw new Error("Event payload is required");var c={},u=this._instance.get_property("$groups")||[],A=this._instance.get_property("$stored_group_properties")||{};for(var[d,f]of Object.entries(A))c[d]={id:u[d],type:d,properties:f};var{$set_once:m,$set:C}=e;return{event:Wc({},afe(e,VWe),{properties:Wc({},e.properties,C?{$set:Wc({},(t=(n=e.properties)==null?void 0:n.$set)!==null&&t!==void 0?t:{},C)}:{},m?{$set_once:Wc({},(i=(o=e.properties)==null?void 0:o.$set_once)!==null&&i!==void 0?i:{},m)}:{}),elements_chain:(a=(s=e.properties)==null?void 0:s.$elements_chain)!==null&&a!==void 0?a:"",distinct_id:(l=e.properties)==null?void 0:l.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:c}}setupSiteApp(e){var t=this.apps[e.id],n=()=>{var s;!t.errored&&this.ts.length&&(uQ.info("Processing "+this.ts.length+" events for site app with id "+e.id),this.ts.forEach(l=>t.processEvent==null?void 0:t.processEvent(l)),t.processedBuffer=!0),Object.values(this.apps).every(l=>l.processedBuffer||l.errored)&&((s=this.rs)==null||s.call(this))},i=!1,o=s=>{t.errored=!s,t.loaded=!0,uQ.info("Site app with id "+e.id+" "+(s?"loaded":"errored")),i&&n()};try{var{processEvent:a}=e.init({posthog:this._instance,callback:s=>{o(s)}});a&&(t.processEvent=a),i=!0}catch(s){uQ.error("Error while initializing PostHog app with config id "+e.id,s),o(!1)}if(i&&t.loaded)try{n()}catch(s){uQ.error("Error while processing buffered events PostHog app with config id "+e.id,s),t.errored=!0}}ss(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var n of e)this.setupSiteApp(n)}ns(e){if(Object.keys(this.apps).length!==0){var t=this.globalsForEvent(e);for(var n of Object.values(this.apps))try{n.processEvent==null||n.processEvent(t)}catch(i){uQ.error("Error while processing event "+e.event+" for site app "+n.id,i)}}}onRemoteConfig(e){var t,n,i,o=this;if((t=this.siteAppLoaders)!=null&&t.length)return this.isEnabled?(this.ss(),void this._instance.on("eventCaptured",c=>this.ns(c))):void uQ.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((n=this.rs)==null||n.call(this),(i=e.siteApps)!=null&&i.length)if(this.isEnabled){var a=function(c){var u;wh["__$$ph_site_app_"+c]=o._instance,(u=wh.__PosthogExtensions__)==null||u.loadSiteApp==null||u.loadSiteApp(o._instance,l,A=>{if(A)return uQ.error("Error while initializing PostHog app with config id "+c,A)})};for(var{id:s,url:l}of e.siteApps)a(s)}else uQ.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var jWe=["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","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"],ipe=function(r,e){if(!r)return!1;var t=r.toLowerCase();return jWe.concat(e||[]).some(n=>{var i=n.toLowerCase();return t.indexOf(i)!==-1})},ope=function(r,e){if(!r)return!1;var t=r.userAgent;if(t&&ipe(t,e))return!0;try{var n=r==null?void 0:r.userAgentData;if(n!=null&&n.brands&&n.brands.some(i=>ipe(i==null?void 0:i.brand,e)))return!0}catch{}return!!r.webdriver},P3=function(r){return r.US="us",r.EU="eu",r.CUSTOM="custom",r}({}),ape="i.posthog.com";class JWe{constructor(e){this.os={},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 uiHost(){var e,t=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+ape,".posthog.com")),t==="https://app.posthog.com"?"https://us.posthog.com":t}get region(){return this.os[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.os[this.apiHost]=P3.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.os[this.apiHost]=P3.EU:this.os[this.apiHost]=P3.CUSTOM),this.os[this.apiHost]}endpointFor(e,t){if(t===void 0&&(t=""),t&&(t=t[0]==="/"?t:"/"+t),e==="ui")return this.uiHost+t;if(this.region===P3.CUSTOM)return this.apiHost+t;var n=ape+t;switch(e){case"assets":return"https://"+this.region+"-assets."+n;case"api":return"https://"+this.region+"."+n}}}var WWe={icontains:(r,e)=>!!xo&&e.href.toLowerCase().indexOf(r.toLowerCase())>-1,not_icontains:(r,e)=>!!xo&&e.href.toLowerCase().indexOf(r.toLowerCase())===-1,regex:(r,e)=>!!xo&&SM(e.href,r),not_regex:(r,e)=>!!xo&&!SM(e.href,r),exact:(r,e)=>e.href===r,is_not:(r,e)=>e.href!==r};class $_{constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(n){n===void 0&&(n=!1),t.getWebExperiments(i=>{$_.ls("retrieved web experiments from the server"),t.us=new Map,i.forEach(o=>{if(o.feature_flag_key){var a;t.us&&($_.ls("setting flag key ",o.feature_flag_key," to web experiment ",o),(a=t.us)==null||a.set(o.feature_flag_key,o));var s=t._instance.getFeatureFlag(o.feature_flag_key);PC(s)&&o.variants[s]&&t.hs(o.name,s,o.variants[s].transforms)}else if(o.variants)for(var l in o.variants){var c=o.variants[l];$_.ds(c)&&t.hs(o.name,l,c.transforms)}})},n)},this._instance=e,this._instance.onFeatureFlags(n=>{this.onFeatureFlags(n)})}onFeatureFlags(e){if(this._is_bot())$_.ls("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(Um(this.us))return this.us=new Map,this.loadIfEnabled(),void this.previewWebExperiment();$_.ls("applying feature flags",e),e.forEach(t=>{var n;if(this.us&&(n=this.us)!=null&&n.has(t)){var i,o=this._instance.getFeatureFlag(t),a=(i=this.us)==null?void 0:i.get(t);o&&a!=null&&a.variants[o]&&this.hs(a.name,o,a.variants[o].transforms)}})}}previewWebExperiment(){var e=$_.getWindowLocation();if(e!=null&&e.search){var t=IP(e==null?void 0:e.search,"__experiment_id"),n=IP(e==null?void 0:e.search,"__experiment_variant");t&&n&&($_.ls("previewing web experiments "+t+" && "+n),this.getWebExperiments(i=>{this.vs(parseInt(t),n,i)},!1,!0))}}loadIfEnabled(){this._instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,n){if(this._instance.config.disable_web_experiments&&!n)return e([]);var i=this._instance.get_property("$web_experiments");if(i&&!t)return e(i);this._instance.Ee({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._instance.config.token),method:"GET",callback:o=>{if(o.statusCode!==200||!o.json)return e([]);var a=o.json.experiments||[];return e(a)}})}vs(e,t,n){var i=n.filter(o=>o.id===e);i&&i.length>0&&($_.ls("Previewing web experiment ["+i[0].name+"] with variant ["+t+"]"),this.hs(i[0].name,t,i[0].variants[t].transforms))}static ds(e){return!Um(e.conditions)&&$_.cs(e)&&$_.fs(e)}static cs(e){var t;if(Um(e.conditions)||Um((t=e.conditions)==null?void 0:t.url))return!0;var n,i,o,a=$_.getWindowLocation();return!!a&&((n=e.conditions)==null||!n.url||WWe[(i=(o=e.conditions)==null?void 0:o.urlMatchType)!==null&&i!==void 0?i:"icontains"](e.conditions.url,a))}static getWindowLocation(){return xo==null?void 0:xo.location}static fs(e){var t;if(Um(e.conditions)||Um((t=e.conditions)==null?void 0:t.utm))return!0;var n=Hhe();if(n.utm_source){var i,o,a,s,l,c,u,A,d=(i=e.conditions)==null||(i=i.utm)==null||!i.utm_campaign||((o=e.conditions)==null||(o=o.utm)==null?void 0:o.utm_campaign)==n.utm_campaign,f=(a=e.conditions)==null||(a=a.utm)==null||!a.utm_source||((s=e.conditions)==null||(s=s.utm)==null?void 0:s.utm_source)==n.utm_source,m=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((c=e.conditions)==null||(c=c.utm)==null?void 0:c.utm_medium)==n.utm_medium,C=(u=e.conditions)==null||(u=u.utm)==null||!u.utm_term||((A=e.conditions)==null||(A=A.utm)==null?void 0:A.utm_term)==n.utm_term;return d&&m&&C&&f}return!1}static ls(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];bu.info("[WebExperiments] "+e,n)}hs(e,t,n){this._is_bot()?$_.ls("Refusing to render web experiment since the viewer is a likely bot"):t!=="control"?n.forEach(i=>{if(i.selector){var o;$_.ls("applying transform of variant "+t+" for experiment "+e+" ",i);var a=(o=document)==null?void 0:o.querySelectorAll(i.selector);a==null||a.forEach(s=>{var l=s;i.html&&(l.innerHTML=i.html),i.css&&l.setAttribute("style",i.css)})}}):$_.ls("Control variants leave the page unmodified.")}_is_bot(){return _B&&this._instance?ope(_B,this._instance.config.custom_blocked_useragents):void 0}}var qWe=XE("[PostHog ExternalIntegrations]"),ZWe={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class XWe{constructor(e){this._instance=e}J(e,t){var n;(n=wh.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,e,i=>{if(i)return qWe.error("failed to load script",i);t()})}startIfEnabledOrStop(){var e=this,t=function(a){var s,l,c;!i||(s=wh.__PosthogExtensions__)!=null&&(s=s.integrations)!=null&&s[a]||e.J(ZWe[a],()=>{var u;(u=wh.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[a])==null||u.start(e._instance)}),!i&&(l=wh.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[a]&&((c=wh.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[a])==null||c.stop())};for(var[n,i]of Object.entries((o=this._instance.config.integrations)!==null&&o!==void 0?o:{})){var o;t(n)}}}var k3={},xH=()=>{},RM="posthog",spe=!AWe&&(qx==null?void 0:qx.indexOf("MSIE"))===-1&&(qx==null?void 0:qx.indexOf("Mozilla"))===-1,lpe=r=>{var e;return{api_host:"https://us.i.posthog.com",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:Hje(Au==null?void 0:Au.location),persistence:"localStorage+cookie",persistence_name:"",loaded:xH,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageview:r!=="2025-05-24"||"history_change",capture_pageleave:"if_capture_pageview",defaults:r??"unset",debug:Wx&&PC(Wx==null?void 0:Wx.search)&&Wx.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_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(xo==null||(e=xo.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",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,session_recording:{},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_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error:t=>{var n="Bad HTTP status: "+t.statusCode+" "+t.text;bu.error(n)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",before_send:void 0,request_queue_config:{flush_interval_ms:_H},error_tracking:{},_onCapture:xH}},cpe=r=>{var e={};dc(r.process_person)||(e.person_profiles=r.process_person),dc(r.xhr_headers)||(e.request_headers=r.xhr_headers),dc(r.cookie_name)||(e.persistence_name=r.cookie_name),dc(r.disable_cookie)||(e.disable_persistence=r.disable_cookie),dc(r.store_google)||(e.save_campaign_params=r.store_google),dc(r.verbose)||(e.debug=r.verbose);var t=u1({},e,r);return OI(r.property_blacklist)&&(dc(r.property_denylist)?t.property_denylist=r.property_blacklist:OI(r.property_denylist)?t.property_denylist=[...r.property_blacklist,...r.property_denylist]:bu.error("Invalid value for property_denylist config: "+r.property_denylist)),t};class $We{constructor(){this.__forceAllowLocalhost=!1}get ps(){return this.__forceAllowLocalhost}set ps(e){bu.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class LP{get decideEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){this.webPerformance=new $We,this.gs=!1,this.version=ZS.LIB_VERSION,this._s=new epe,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=lpe(),this.SentryIntegration=tWe,this.sentryIntegration=e=>function(t,n){var i=mhe(t,n);return{name:ghe,processEvent:o=>i(o)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.bs=!1,this.ys=null,this.ws=null,this.Ss=null,this.featureFlags=new DWe(this),this.toolbar=new rWe(this),this.scrollManager=new OWe(this),this.pageViewManager=new cWe(this),this.surveys=new PWe(this),this.experiments=new $_(this),this.exceptions=new hWe(this),this.rateLimiter=new kWe(this),this.requestRouter=new JWe(this),this.consent=new AJe(this),this.externalIntegrations=new XWe(this),this.people={set:(e,t,n)=>{var i=PC(e)?{[e]:t}:e;this.setPersonProperties(i),n==null||n({})},set_once:(e,t,n)=>{var i=PC(e)?{[e]:t}:e;this.setPersonProperties(void 0,i),n==null||n({})}},this.on("eventCaptured",e=>bu.info('send "'+(e==null?void 0:e.event)+'"',e))}init(e,t,n){if(n&&n!==RM){var i,o=(i=k3[n])!==null&&i!==void 0?i:new LP;return o._init(e,t,n),k3[n]=o,k3[RM][n]=o,o}return this._init(e,t,n)}_init(e,t,n){var i,o;if(t===void 0&&(t={}),dc(e)||xz(e))return bu.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 bu.warn("You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},this.$s=t,this.ks=[],t.person_profiles&&(this.ws=t.person_profiles),this.set_config(u1({},lpe(t.defaults),cpe(t),{name:n,token:e})),this.config.on_xhr_error&&bu.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:XS.GZipJS;var a=this.xs();this.persistence=new IH(this.config,a),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new IH(Wc({},this.config,{persistence:"sessionStorage"}),a);var s=Wc({},this.persistence.props),l=Wc({},this.sessionPersistence.props);if(this.register({$initialization_time:new Date().toISOString()}),this.Es=new FWe(x=>this.Is(x),this.config.request_queue_config),this.Ps=new GWe(this),this.__request_queue=[],this.config.__preview_experimental_cookieless_mode||(this.sessionManager=new YWe(this),this.sessionPropsManager=new HWe(this,this.sessionManager,this.persistence)),new oWe(this).startIfEnabledOrStop(),this.siteApps=new KWe(this),(i=this.siteApps)==null||i.init(),this.config.__preview_experimental_cookieless_mode||(this.sessionRecording=new $Je(this),this.sessionRecording.startIfEnabledOrStop()),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),this.autocapture=new rJe(this),this.autocapture.startIfEnabled(),this.surveys.loadIfEnabled(),this.heatmaps=new lWe(this),this.heatmaps.startIfEnabled(),this.webVitalsAutocapture=new aWe(this),this.exceptionObserver=new hJe(this),this.exceptionObserver.startIfEnabled(),this.deadClicksAutocapture=new Ofe(this,fJe),this.deadClicksAutocapture.startIfEnabled(),this.historyAutocapture=new wJe(this),this.historyAutocapture.startIfEnabled(),ZS.DEBUG=ZS.DEBUG||this.config.debug,ZS.DEBUG&&bu.info("Starting in debug mode",{this:this,config:t,thisC:Wc({},this.config),p:s,s:l}),((o=t.bootstrap)==null?void 0:o.distinctID)!==void 0){var c,u,A=this.config.get_device_id(aQ()),d=(c=t.bootstrap)!=null&&c.isIdentifiedID?A:t.bootstrap.distinctID;this.persistence.set_property($S,(u=t.bootstrap)!=null&&u.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:t.bootstrap.distinctID,$device_id:d})}if(this.Rs()){var f,m,C=Object.keys(((f=t.bootstrap)==null?void 0:f.featureFlags)||{}).filter(x=>{var w;return!((w=t.bootstrap)==null||(w=w.featureFlags)==null||!w[x])}).reduce((x,w)=>{var P;return x[w]=((P=t.bootstrap)==null||(P=P.featureFlags)==null?void 0:P[w])||!1,x},{}),E=Object.keys(((m=t.bootstrap)==null?void 0:m.featureFlagPayloads)||{}).filter(x=>C[x]).reduce((x,w)=>{var P,L;return(P=t.bootstrap)!=null&&(P=P.featureFlagPayloads)!=null&&P[w]&&(x[w]=(L=t.bootstrap)==null||(L=L.featureFlagPayloads)==null?void 0:L[w]),x},{});this.featureFlags.receivedFeatureFlags({featureFlags:C,featureFlagPayloads:E})}if(this.config.__preview_experimental_cookieless_mode)this.register_once({distinct_id:gP,$device_id:null},"");else if(!this.get_distinct_id()){var _=this.config.get_device_id(aQ());this.register_once({distinct_id:_,$device_id:_},""),this.persistence.set_property($S,"anonymous")}return oC(xo,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?eWe(this,()=>this.Ts()):this.Ts(),jB(this.config._onCapture)&&this.config._onCapture!==xH&&(bu.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",x=>this.config._onCapture(x.event,x))),this.config.ip&&bu.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}Ie(e){var t,n,i,o,a,s,l,c;if(!Au||!Au.body)return bu.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.Ie(e)},500);this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=Wg(e.supportedCompression,XS.GZipJS)?XS.GZipJS:Wg(e.supportedCompression,XS.Base64)?XS.Base64:void 0),(t=e.analytics)!=null&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.ws?this.ws:"identified_only"}),(n=this.siteApps)==null||n.onRemoteConfig(e),(i=this.sessionRecording)==null||i.onRemoteConfig(e),(o=this.autocapture)==null||o.onRemoteConfig(e),(a=this.heatmaps)==null||a.onRemoteConfig(e),this.surveys.onRemoteConfig(e),(s=this.webVitalsAutocapture)==null||s.onRemoteConfig(e),(l=this.exceptionObserver)==null||l.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),(c=this.deadClicksAutocapture)==null||c.onRemoteConfig(e)}Ts(){try{this.config.loaded(this)}catch(e){bu.critical("`loaded` function failed",e)}this.Ms(),this.config.capture_pageview&&setTimeout(()=>{this.consent.isOptedIn()&&this.Cs()},1),new UWe(this).load(),this.featureFlags.flags()}Ms(){var e;this.has_opted_out_capturing()||this.config.request_batching&&((e=this.Es)==null||e.enable())}_dom_loaded(){this.has_opted_out_capturing()||iQ(this.__request_queue,e=>this.Is(e)),this.__request_queue=[],this.Ms()}_handle_unload(){var e,t;this.config.request_batching?(this.Fs()&&this.capture("$pageleave"),(e=this.Es)==null||e.unload(),(t=this.Ps)==null||t.unload()):this.Fs()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}Ee(e){this.__loaded&&(spe?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=TP(e.url,{ip:this.config.ip?1:0}),e.headers=Wc({},this.config.request_headers),e.compression=e.compression==="best-available"?this.compression:e.compression,e.fetchOptions=e.fetchOptions||this.config.fetch_options,(t=>{var n,i,o,a=Wc({},t);a.timeout=a.timeout||6e4,a.url=TP(a.url,{_:new Date().getTime().toString(),ver:ZS.LIB_VERSION,compression:a.compression});var s=(n=a.transport)!==null&&n!==void 0?n:"fetch",l=(i=(o=lfe(w3,c=>c.transport===s))==null?void 0:o.method)!==null&&i!==void 0?i:w3[0].method;if(!l)throw new Error("No available transport method");l(a)})(Wc({},e,{callback:t=>{var n,i;this.rateLimiter.checkForLimiting(t),t.statusCode>=400&&((n=(i=this.config).on_request_error)==null||n.call(i,t)),e.callback==null||e.callback(t)}}))))}Is(e){this.Ps?this.Ps.retriableRequest(e):this.Ee(e)}_execute_array(e){var t,n=[],i=[],o=[];iQ(e,s=>{s&&(t=s[0],OI(t)?o.push(s):jB(s)?s.call(this):OI(s)&&t==="alias"?n.push(s):OI(s)&&t.indexOf("capture")!==-1&&jB(this[t])?o.push(s):i.push(s))});var a=function(s,l){iQ(s,function(c){if(OI(c[0])){var u=l;av(c,function(A){u=u[A[0]].apply(u,A.slice(1))})}else this[c[0]].apply(this,c.slice(1))},l)};a(n,this),a(i,this),a(o,this)}Rs(){var e,t;return((e=this.config.bootstrap)==null?void 0:e.featureFlags)&&Object.keys((t=this.config.bootstrap)==null?void 0:t.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,t,n){var i;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Es){if(!this.consent.isOptedOut())if(!dc(e)&&PC(e)){if(this.config.opt_out_useragent_filter||!this._is_bot()){var o=n!=null&&n.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(o==null||!o.isRateLimited){t!=null&&t.$current_url&&!PC(t==null?void 0:t.$current_url)&&(bu.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),t==null||delete t.$current_url),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 a=new Date,s=(n==null?void 0:n.timestamp)||a,l=aQ(),c={uuid:l,event:e,properties:this.calculateEventProperties(e,t||{},s,l)};o&&(c.properties.$lib_rate_limit_remaining_tokens=o.remainingTokens),n!=null&&n.$set&&(c.$set=n==null?void 0:n.$set);var u,A,d=this.Os(n==null?void 0:n.$set_once);if(d&&(c.$set_once=d),(c=Oje(c,n!=null&&n._noTruncate?null:this.config.properties_string_max_length)).timestamp=s,dc(n==null?void 0:n.timestamp)||(c.properties.$event_time_override_provided=!0,c.properties.$event_time_override_system_time=a),e===EH.DISMISSED||e===EH.SENT){var f=t==null?void 0:t[tpe.SURVEY_ID],m=t==null?void 0:t[tpe.SURVEY_ITERATION];localStorage.setItem((A=""+CH+(u={id:f,current_iteration:m}).id,u.current_iteration&&u.current_iteration>0&&(A=""+CH+u.id+"_"+u.current_iteration),A),"true"),c.$set=Wc({},c.$set,{[NWe({id:f,current_iteration:m},e===EH.SENT?"responded":"dismissed")]:!0})}var C=Wc({},c.properties.$set,c.$set);if(IM(C)||this.setPersonPropertiesForFlags(C),!Um(this.config.before_send)){var E=this.As(c);if(!E)return;c=E}this._s.emit("eventCaptured",c);var _={method:"POST",url:(i=n==null?void 0:n._url)!==null&&i!==void 0?i:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:c,compression:"best-available",batchKey:n==null?void 0:n._batchKey};return!this.config.request_batching||n&&(n==null||!n._batchKey)||n!=null&&n.send_instantly?this.Is(_):this.Es.enqueue(_),c}bu.critical("This capture call is ignored due to client rate limiting.")}}else bu.error("No event name provided to posthog.capture")}else bu.uninitializedWarning("posthog.capture")}Ge(e){return this.on("eventCaptured",t=>e(t.event,t))}calculateEventProperties(e,t,n,i,o){if(n=n||new Date,!this.persistence||!this.sessionPersistence)return t;var a=o?void 0:this.persistence.remove_event_timer(e),s=Wc({},t);if(s.token=this.config.token,s.$config_defaults=this.config.defaults,this.config.__preview_experimental_cookieless_mode&&(s.$cookieless_mode=!0),e==="$snapshot"){var l=Wc({},this.persistence.properties(),this.sessionPersistence.properties());return s.distinct_id=l.distinct_id,(!PC(s.distinct_id)&&!q_(s.distinct_id)||xz(s.distinct_id))&&bu.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),s}var c,u=wWe(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:A,windowId:d}=this.sessionManager.checkAndGetSessionAndWindowId(o,n.getTime());s.$session_id=A,s.$window_id=d}this.sessionPropsManager&&u1(s,this.sessionPropsManager.getSessionProps());try{var f;this.sessionRecording&&u1(s,this.sessionRecording.sdkDebugProperties),s.$sdk_debug_retry_queue_size=(f=this.Ps)==null?void 0:f.length}catch(_){s.$sdk_debug_error_capturing_properties=String(_)}if(this.requestRouter.region===P3.CUSTOM&&(s.$lib_custom_api_host=this.config.api_host),c=e!=="$pageview"||o?e!=="$pageleave"||o?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(n):this.pageViewManager.doPageView(n,i),s=u1(s,c),e==="$pageview"&&Au&&(s.title=Au.title),!dc(a)){var m=n.getTime()-a;s.$duration=parseFloat((m/1e3).toFixed(3))}qx&&this.config.opt_out_useragent_filter&&(s.$browser_type=this._is_bot()?"bot":"browser"),(s=u1({},u,this.persistence.properties(),this.sessionPersistence.properties(),s)).$is_identified=this._isIdentified(),OI(this.config.property_denylist)?av(this.config.property_denylist,function(_){delete s[_]}):bu.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var C=this.config.sanitize_properties;C&&(bu.error("sanitize_properties is deprecated. Use before_send instead"),s=C(s,e));var E=this.Ds();return s.$process_person_profile=E,E&&!o&&this.Ls("_calculate_event_properties"),s}Os(e){var t;if(!this.persistence||!this.Ds()||this.gs)return e;var n=this.persistence.get_initial_props(),i=(t=this.sessionPropsManager)==null?void 0:t.getSetOnceProps(),o=u1({},n,i||{},e||{}),a=this.config.sanitize_properties;return a&&(bu.error("sanitize_properties is deprecated. Use before_send instead"),o=a(o,"$set_once")),this.gs=!0,IM(o)?void 0:o}register(e,t){var n;(n=this.persistence)==null||n.register(e,t)}register_once(e,t,n){var i;(i=this.persistence)==null||i.register_once(e,t,n)}register_for_session(e){var t;(t=this.sessionPersistence)==null||t.register(e)}unregister(e){var t;(t=this.persistence)==null||t.unregister(e)}unregister_for_session(e){var t;(t=this.sessionPersistence)==null||t.unregister(e)}js(e,t){this.register({[e]:t})}getFeatureFlag(e,t){return this.featureFlags.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t=this.featureFlags.getFeatureFlagPayload(e);try{return JSON.parse(t)}catch{return t}}isFeatureEnabled(e,t){return this.featureFlags.isFeatureEnabled(e,t)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateEarlyAccessFeatureEnrollment(e,t){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t)}getEarlyAccessFeatures(e,t,n){return t===void 0&&(t=!1),this.featureFlags.getEarlyAccessFeatures(e,t,n)}on(e,t){return this._s.on(e,t)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSurveysLoaded(e){return this.surveys.onSurveysLoaded(e)}onSessionId(e){var t,n;return(t=(n=this.sessionManager)==null?void 0:n.onSessionId(e))!==null&&t!==void 0?t:()=>{}}getSurveys(e,t){t===void 0&&(t=!1),this.surveys.getSurveys(e,t)}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys.getActiveMatchingSurveys(e,t)}renderSurvey(e,t){this.surveys.renderSurvey(e,t)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,t){return t===void 0&&(t=!1),this.surveys.canRenderSurveyAsync(e,t)}identify(e,t,n){if(!this.__loaded||!this.persistence)return bu.uninitializedWarning("posthog.identify");if(q_(e)&&(e=e.toString(),bu.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),e)if(["distinct_id","distinctid"].includes(e.toLowerCase()))bu.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.');else if(e!==gP){if(this.Ls("posthog.identify")){var i=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var o=i;this.register_once({$had_persisted_distinct_id:!0,$device_id:o},"")}e!==i&&e!==this.get_property(y3)&&(this.unregister(y3),this.register({distinct_id:e}));var a=(this.persistence.get_property($S)||"anonymous")==="anonymous";e!==i&&a?(this.persistence.set_property($S,"identified"),this.setPersonPropertiesForFlags(Wc({},n||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:i},{$set:t||{},$set_once:n||{}}),this.Ss=_he(e,t,n),this.featureFlags.setAnonymousDistinctId(i)):(t||n)&&this.setPersonProperties(t,n),e!==i&&(this.reloadFeatureFlags(),this.unregister(fP))}}else bu.critical('The string "'+gP+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else bu.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,t){if((e||t)&&this.Ls("posthog.setPersonProperties")){var n=_he(this.get_distinct_id(),e,t);this.Ss!==n?(this.setPersonPropertiesForFlags(Wc({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.Ss=n):bu.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,n){if(e&&t){if(this.Ls("posthog.group")){var i=this.getGroups();i[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:Wc({},i,{[e]:t})}),n&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:n}),this.setGroupPropertiesForFlags({[e]:n})),i[e]===t||n||this.reloadFeatureFlags()}}else bu.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0),this.featureFlags.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0),this.Ls("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,t)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var t,n,i,o;if(bu.info("reset"),!this.__loaded)return bu.uninitializedWarning("posthog.reset");var a=this.get_property("$device_id");if(this.consent.reset(),(t=this.persistence)==null||t.clear(),(n=this.sessionPersistence)==null||n.clear(),this.surveys.reset(),this.featureFlags.reset(),(i=this.persistence)==null||i.set_property($S,"anonymous"),(o=this.sessionManager)==null||o.resetSessionId(),this.Ss=null,this.config.__preview_experimental_cookieless_mode)this.register_once({distinct_id:gP,$device_id:null},"");else{var s=this.config.get_device_id(aQ());this.register_once({distinct_id:s,$device_id:e?s:a},"")}this.register({$last_posthog_reset:new Date().toISOString()},1)}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return(e=(t=this.sessionManager)==null?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:t,sessionStartTimestamp:n}=this.sessionManager.checkAndGetSessionAndWindowId(!0),i=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);if(e!=null&&e.withTimestamp&&n){var o,a=(o=e.timestampLookBack)!==null&&o!==void 0?o:10;if(!n)return i;i+="?t="+Math.max(Math.floor((new Date().getTime()-n)/1e3)-a,0)}return i}alias(e,t){return e===this.get_property(cfe)?(bu.critical("Attempting to create alias for existing People user - aborting."),-2):this.Ls("posthog.alias")?(dc(t)&&(t=this.get_distinct_id()),e!==t?(this.js(y3,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(bu.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=Wc({},this.config);if(TC(e)){var n,i,o,a,s;u1(this.config,cpe(e));var l=this.xs();(n=this.persistence)==null||n.update_config(this.config,t,l),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new IH(Wc({},this.config,{persistence:"sessionStorage"}),l),rE.O()&&rE.D("ph_debug")==="true"&&(this.config.debug=!0),this.config.debug&&(ZS.DEBUG=!0,bu.info("set_config",{config:e,oldConfig:t,newConfig:Wc({},this.config)})),(i=this.sessionRecording)==null||i.startIfEnabledOrStop(),(o=this.autocapture)==null||o.startIfEnabled(),(a=this.heatmaps)==null||a.startIfEnabled(),this.surveys.loadIfEnabled(),this.Ns(),(s=this.externalIntegrations)==null||s.startIfEnabledOrStop()}}startSessionRecording(e){var t=e===!0,n={sampling:t||!(e==null||!e.sampling),linked_flag:t||!(e==null||!e.linked_flag),url_trigger:t||!(e==null||!e.url_trigger),event_trigger:t||!(e==null||!e.event_trigger)};if(Object.values(n).some(Boolean)){var i,o,a,s,l;(i=this.sessionManager)==null||i.checkAndGetSessionAndWindowId(),n.sampling&&((o=this.sessionRecording)==null||o.overrideSampling()),n.linked_flag&&((a=this.sessionRecording)==null||a.overrideLinkedFlag()),n.url_trigger&&((s=this.sessionRecording)==null||s.overrideTrigger("url")),n.event_trigger&&((l=this.sessionRecording)==null||l.overrideTrigger("event"))}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,t){var n=new Error("PostHog syntheticException");return this.exceptions.sendExceptionEvent(Wc({},SJe((i=>i instanceof Error)(e)?{error:e,event:e.message}:{event:e},{syntheticException:n}),t))}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var t;return(t=this.persistence)==null?void 0:t.props[e]}getSessionProperty(e){var t;return(t=this.sessionPersistence)==null?void 0:t.props[e]}toString(){var e,t=(e=this.config.name)!==null&&e!==void 0?e:RM;return t!==RM&&(t=RM+"."+t),t}_isIdentified(){var e,t;return((e=this.persistence)==null?void 0:e.get_property($S))==="identified"||((t=this.sessionPersistence)==null?void 0:t.get_property($S))==="identified"}Ds(){var e,t;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&IM(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[y3])&&((t=this.persistence)==null||(t=t.props)==null||!t[pP]))}Fs(){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.Ds()||this.Ls("posthog.createPersonProfile")&&this.setPersonProperties({},{})}Ls(e){return this.config.person_profiles==="never"?(bu.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.js(pP,!0),!0)}xs(){var e=this.consent.isOptedOut(),t=this.config.opt_out_persistence_by_default;return this.config.disable_persistence||e&&!!t}Ns(){var e,t,n,i,o=this.xs();return((e=this.persistence)==null?void 0:e.Fe)!==o&&((n=this.persistence)==null||n.set_disabled(o)),((t=this.sessionPersistence)==null?void 0:t.Fe)!==o&&((i=this.sessionPersistence)==null||i.set_disabled(o)),o}opt_in_capturing(e){var t;this.consent.optInOut(!0),this.Ns(),(dc(e==null?void 0:e.captureEventName)||e!=null&&e.captureEventName)&&this.capture((t=e==null?void 0:e.captureEventName)!==null&&t!==void 0?t:"$opt_in",e==null?void 0:e.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Cs()}opt_out_capturing(){this.consent.optInOut(!1),this.Ns()}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}clear_opt_in_out_capturing(){this.consent.reset(),this.Ns()}_is_bot(){return _B?ope(_B,this.config.custom_blocked_useragents):void 0}Cs(){Au&&(Au.visibilityState==="visible"?this.bs||(this.bs=!0,this.capture("$pageview",{title:Au.title},{send_instantly:!0}),this.ys&&(Au.removeEventListener("visibilitychange",this.ys),this.ys=null)):this.ys||(this.ys=this.Cs.bind(this),oC(Au,"visibilitychange",this.ys)))}debug(e){e===!1?(xo==null||xo.console.log("You've disabled debug mode."),localStorage&&localStorage.removeItem("ph_debug"),this.set_config({debug:!1})):(xo==null||xo.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)`."),localStorage&&localStorage.setItem("ph_debug","true"),this.set_config({debug:!0}))}I(){var e,t,n,i,o,a,s,l=this.$s||{};return"advanced_disable_flags"in l?!!l.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(bu.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(n="advanced_disable_decide",i=!1,o=bu,a=(t="advanced_disable_flags")in(e=l)&&!dc(e[t]),s=n in e&&!dc(e[n]),a?e[t]:s?(o&&o.warn("Config field '"+n+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[n]):i)}As(e){if(Um(this.config.before_send))return e;var t=OI(this.config.before_send)?this.config.before_send:[this.config.before_send],n=e;for(var i of t){if(n=i(n),Um(n)){var o="Event '"+e.event+"' was rejected in beforeSend function";return Fje(e.event)?bu.warn(o+". This can cause unexpected behavior."):bu.info(o),null}n.properties&&!IM(n.properties)||bu.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return n}getPageViewId(){var e;return(e=this.pageViewManager.ce)==null?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,n){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(n)})}}(function(r,e){for(var t=0;t<e.length;t++)r.prototype[e[t]]=Gje(r.prototype[e[t]])})(LP,["identify"]);var upe,GP=(upe=k3[RM]=new LP,function(){function r(){r.done||(r.done=!0,spe=!1,av(k3,function(e){e._dom_loaded()}))}Au!=null&&Au.addEventListener?Au.readyState==="complete"?r():oC(Au,"DOMContentLoaded",r,{capture:!1}):xo&&bu.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),upe);!window.location.hostname.includes("localhost")&&!window.location.hostname.includes("127.0.0.1")&&(GP.__loaded||GP.init("phc_htd8AQjSfVEsFCLQMAiUooG4Q0DKBCjqYuQglc9V3Wo",{api_host:"https://postpig.tscircuit.com",person_profiles:"always"}));function eqe(r){const e=String.fromCodePoint(...r);return btoa(e)}var BB=Uint8Array,bB=Uint16Array,BH=Int32Array,bH=new BB([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]),SH=new BB([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]),Ape=new BB([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),dpe=function(r,e){for(var t=new bB(31),n=0;n<31;++n)t[n]=e+=1<<r[n-1];for(var i=new BH(t[30]),n=1;n<30;++n)for(var o=t[n];o<t[n+1];++o)i[o]=o-t[n]<<5|n;return{b:t,r:i}},fpe=dpe(bH,2),tqe=fpe.b,wH=fpe.r;tqe[28]=258,wH[258]=28;for(var nqe=dpe(SH,0),hpe=nqe.r,QH=new bB(32768),BI=0;BI<32768;++BI){var AQ=(BI&43690)>>1|(BI&21845)<<1;AQ=(AQ&52428)>>2|(AQ&13107)<<2,AQ=(AQ&61680)>>4|(AQ&3855)<<4,QH[BI]=((AQ&65280)>>8|(AQ&255)<<8)>>1}for(var U3=function(r,e,t){for(var n=r.length,i=0,o=new bB(e);i<n;++i)r[i]&&++o[r[i]-1];var a=new bB(e);for(i=1;i<e;++i)a[i]=a[i-1]+o[i-1]<<1;var s;if(t){s=new bB(1<<e);var l=15-e;for(i=0;i<n;++i)if(r[i])for(var c=i<<4|r[i],u=e-r[i],A=a[r[i]-1]++<<u,d=A|(1<<u)-1;A<=d;++A)s[QH[A]>>l]=c}else for(s=new bB(n),i=0;i<n;++i)r[i]&&(s[i]=QH[a[r[i]-1]++]>>15-r[i]);return s},_2=new BB(288),BI=0;BI<144;++BI)_2[BI]=8;for(var BI=144;BI<256;++BI)_2[BI]=9;for(var BI=256;BI<280;++BI)_2[BI]=7;for(var BI=280;BI<288;++BI)_2[BI]=8;for(var OP=new BB(32),BI=0;BI<32;++BI)OP[BI]=5;var rqe=U3(_2,9,0),iqe=U3(OP,5,0),ppe=function(r){return(r+7)/8|0},gpe=function(r,e,t){return(t==null||t>r.length)&&(t=r.length),new BB(r.subarray(e,t))},nw=function(r,e,t){t<<=e&7;var n=e/8|0;r[n]|=t,r[n+1]|=t>>8},F3=function(r,e,t){t<<=e&7;var n=e/8|0;r[n]|=t,r[n+1]|=t>>8,r[n+2]|=t>>16},MH=function(r,e){for(var t=[],n=0;n<r.length;++n)r[n]&&t.push({s:n,f:r[n]});var i=t.length,o=t.slice();if(!i)return{t:Ipe,l:0};if(i==1){var a=new BB(t[0].s+1);return a[t[0].s]=1,{t:a,l:1}}t.sort(function(L,O){return L.f-O.f}),t.push({s:-1,f:25001});var s=t[0],l=t[1],c=0,u=1,A=2;for(t[0]={s:-1,f:s.f+l.f,l:s,r:l};u!=i-1;)s=t[t[c].f<t[A].f?c++:A++],l=t[c!=u&&t[c].f<t[A].f?c++:A++],t[u++]={s:-1,f:s.f+l.f,l:s,r:l};for(var d=o[0].s,n=1;n<i;++n)o[n].s>d&&(d=o[n].s);var f=new bB(d+1),m=DH(t[u-1],f,0);if(m>e){var n=0,C=0,E=m-e,_=1<<E;for(o.sort(function(O,H){return f[H.s]-f[O.s]||O.f-H.f});n<i;++n){var x=o[n].s;if(f[x]>e)C+=_-(1<<m-f[x]),f[x]=e;else break}for(C>>=E;C>0;){var w=o[n].s;f[w]<e?C-=1<<e-f[w]++-1:++n}for(;n>=0&&C;--n){var P=o[n].s;f[P]==e&&(--f[P],++C)}m=e}return{t:new BB(f),l:m}},DH=function(r,e,t){return r.s==-1?Math.max(DH(r.l,e,t+1),DH(r.r,e,t+1)):e[r.s]=t},mpe=function(r){for(var e=r.length;e&&!r[--e];);for(var t=new bB(++e),n=0,i=r[0],o=1,a=function(l){t[n++]=l},s=1;s<=e;++s)if(r[s]==i&&s!=e)++o;else{if(!i&&o>2){for(;o>138;o-=138)a(32754);o>2&&(a(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(a(i),--o;o>6;o-=6)a(8304);o>2&&(a(o-3<<5|8208),o=0)}for(;o--;)a(i);o=1,i=r[s]}return{c:t.subarray(0,n),n:e}},L3=function(r,e){for(var t=0,n=0;n<e.length;++n)t+=r[n]*e[n];return t},ype=function(r,e,t){var n=t.length,i=ppe(e+2);r[i]=n&255,r[i+1]=n>>8,r[i+2]=r[i]^255,r[i+3]=r[i+1]^255;for(var o=0;o<n;++o)r[i+o+4]=t[o];return(i+4+n)*8},vpe=function(r,e,t,n,i,o,a,s,l,c,u){nw(e,u++,t),++i[256];for(var A=MH(i,15),d=A.t,f=A.l,m=MH(o,15),C=m.t,E=m.l,_=mpe(d),x=_.c,w=_.n,P=mpe(C),L=P.c,O=P.n,H=new bB(19),K=0;K<x.length;++K)++H[x[K]&31];for(var K=0;K<L.length;++K)++H[L[K]&31];for(var q=MH(H,7),Y=q.t,se=q.l,ie=19;ie>4&&!Y[Ape[ie-1]];--ie);var de=c+5<<3,Ce=L3(i,_2)+L3(o,OP)+a,xe=L3(i,d)+L3(o,C)+a+14+3*ie+L3(H,Y)+2*H[16]+3*H[17]+7*H[18];if(l>=0&&de<=Ce&&de<=xe)return ype(e,u,r.subarray(l,l+c));var fe,Ie,ve,Qe;if(nw(e,u,1+(xe<Ce)),u+=2,xe<Ce){fe=U3(d,f,0),Ie=d,ve=U3(C,E,0),Qe=C;var De=U3(Y,se,0);nw(e,u,w-257),nw(e,u+5,O-1),nw(e,u+10,ie-4),u+=14;for(var K=0;K<ie;++K)nw(e,u+3*K,Y[Ape[K]]);u+=3*ie;for(var Fe=[x,L],Ne=0;Ne<2;++Ne)for(var rt=Fe[Ne],K=0;K<rt.length;++K){var et=rt[K]&31;nw(e,u,De[et]),u+=Y[et],et>15&&(nw(e,u,rt[K]>>5&127),u+=rt[K]>>12)}}else fe=rqe,Ie=_2,ve=iqe,Qe=OP;for(var K=0;K<s;++K){var ft=n[K];if(ft>255){var et=ft>>18&31;F3(e,u,fe[et+257]),u+=Ie[et+257],et>7&&(nw(e,u,ft>>23&31),u+=bH[et]);var _t=ft&31;F3(e,u,ve[_t]),u+=Qe[_t],_t>3&&(F3(e,u,ft>>5&8191),u+=SH[_t])}else F3(e,u,fe[ft]),u+=Ie[ft]}return F3(e,u,fe[256]),u+Ie[256]},oqe=new BH([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ipe=new BB(0),aqe=function(r,e,t,n,i,o){var a=o.z||r.length,s=new BB(n+a+5*(1+Math.ceil(a/7e3))+i),l=s.subarray(n,s.length-i),c=o.l,u=(o.r||0)&7;if(e){u&&(l[0]=o.r>>3);for(var A=oqe[e-1],d=A>>13,f=A&8191,m=(1<<t)-1,C=o.p||new bB(32768),E=o.h||new bB(m+1),_=Math.ceil(t/3),x=2*_,w=function(kt){return(r[kt]^r[kt+1]<<_^r[kt+2]<<x)&m},P=new BH(25e3),L=new bB(288),O=new bB(32),H=0,K=0,q=o.i||0,Y=0,se=o.w||0,ie=0;q+2<a;++q){var de=w(q),Ce=q&32767,xe=E[de];if(C[Ce]=xe,E[de]=Ce,se<=q){var fe=a-q;if((H>7e3||Y>24576)&&(fe>423||!c)){u=vpe(r,l,0,P,L,O,K,Y,ie,q-ie,u),Y=H=K=0,ie=q;for(var Ie=0;Ie<286;++Ie)L[Ie]=0;for(var Ie=0;Ie<30;++Ie)O[Ie]=0}var ve=2,Qe=0,De=f,Fe=Ce-xe&32767;if(fe>2&&de==w(q-Fe))for(var Ne=Math.min(d,fe)-1,rt=Math.min(32767,q),et=Math.min(258,fe);Fe<=rt&&--De&&Ce!=xe;){if(r[q+ve]==r[q+ve-Fe]){for(var ft=0;ft<et&&r[q+ft]==r[q+ft-Fe];++ft);if(ft>ve){if(ve=ft,Qe=Fe,ft>Ne)break;for(var _t=Math.min(Fe,ft-2),Ft=0,Ie=0;Ie<_t;++Ie){var Lt=q-Fe+Ie&32767,tt=C[Lt],xt=Lt-tt&32767;xt>Ft&&(Ft=xt,xe=Lt)}}}Ce=xe,xe=C[Ce],Fe+=Ce-xe&32767}if(Qe){P[Y++]=268435456|wH[ve]<<18|hpe[Qe];var vt=wH[ve]&31,Ht=hpe[Qe]&31;K+=bH[vt]+SH[Ht],++L[257+vt],++O[Ht],se=q+ve,++H}else P[Y++]=r[q],++L[r[q]]}}for(q=Math.max(q,se);q<a;++q)P[Y++]=r[q],++L[r[q]];u=vpe(r,l,c,P,L,O,K,Y,ie,q-ie,u),c||(o.r=u&7|l[u/8|0]<<3,u-=7,o.h=E,o.p=C,o.i=q,o.w=se)}else{for(var q=o.w||0;q<a+c;q+=65535){var en=q+65535;en>=a&&(l[u/8|0]=c,en=a),u=ype(l,u+1,r.subarray(q,en))}o.i=a}return gpe(s,0,n+ppe(u)+i)},sqe=function(){for(var r=new Int32Array(256),e=0;e<256;++e){for(var t=e,n=9;--n;)t=(t&1&&-306674912)^t>>>1;r[e]=t}return r}(),lqe=function(){var r=-1;return{p:function(e){for(var t=r,n=0;n<e.length;++n)t=sqe[t&255^e[n]]^t>>>8;r=t},d:function(){return~r}}},cqe=function(r,e,t,n,i){if(!i&&(i={l:1},e.dictionary)){var o=e.dictionary.subarray(-32768),a=new BB(o.length+r.length);a.set(o),a.set(r,o.length),r=a,i.w=o.length}return aqe(r,e.level==null?6:e.level,e.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(r.length)))*1.5):20:12+e.mem,t,n,i)},RH=function(r,e,t){for(;t;++e)r[e]=t,t>>>=8},uqe=function(r,e){var t=e.filename;if(r[0]=31,r[1]=139,r[2]=8,r[8]=e.level<2?4:e.level==9?2:0,r[9]=3,e.mtime!=0&&RH(r,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),t){r[3]=8;for(var n=0;n<=t.length;++n)r[n+10]=t.charCodeAt(n)}},Aqe=function(r){return 10+(r.filename?r.filename.length+1:0)};function Cpe(r,e){e||(e={});var t=lqe(),n=r.length;t.p(r);var i=cqe(r,e,Aqe(e),8),o=i.length;return uqe(i,e),RH(i,o-8,t.d()),RH(i,o-4,n),i}var Epe=typeof TextEncoder<"u"&&new TextEncoder,dqe=typeof TextDecoder<"u"&&new TextDecoder,fqe=0;try{dqe.decode(Ipe,{stream:!0}),fqe=1}catch{}function _pe(r,e){var t;if(Epe)return Epe.encode(r);for(var n=r.length,i=new BB(r.length+(r.length>>1)),o=0,a=function(c){i[o++]=c},t=0;t<n;++t){if(o+5>i.length){var s=new BB(o+8+(n-t<<1));s.set(i),i=s}var l=r.charCodeAt(t);l<128||e?a(l):l<2048?(a(192|l>>6),a(128|l&63)):l>55295&&l<57344?(l=65536+(l&1047552)|r.charCodeAt(++t)&1023,a(240|l>>18),a(128|l>>12&63),a(128|l>>6&63),a(128|l&63)):(a(224|l>>12),a(128|l>>6&63),a(128|l&63))}return gpe(i,0,o)}function hqe(r,e){const t=JSON.stringify(r),n=Cpe(_pe(t)),i=eqe(n);return`${window.location.origin}/editor?#data:application/gzip;base64,${i}`}function nI(...r){return Nje(qb(r))}const xpe=r=>r.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()),pqe=nje,Bpe=pt.forwardRef(({className:r,...e},t)=>ut.jsx(Ode,{ref:t,className:nI("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",r),...e}));Bpe.displayName=Ode.displayName;const NM=pt.forwardRef(({className:r,...e},t)=>ut.jsx(zde,{ref:t,className:nI("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",r),...e}));NM.displayName=zde.displayName;const rS=pt.forwardRef(({className:r,...e},t)=>ut.jsx(Hde,{ref:t,className:nI("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",r),...e}));rS.displayName=Hde.displayName;var Am;(function(r){r.assertEqual=i=>{};function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{const o={};for(const a of i)o[a]=a;return o},r.getValidEnumValues=i=>{const o=r.objectKeys(i).filter(s=>typeof i[i[s]]!="number"),a={};for(const s of o)a[s]=i[s];return r.objectValues(a)},r.objectValues=i=>r.objectKeys(i).map(function(o){return i[o]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const o=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&o.push(a);return o},r.find=(i,o)=>{for(const a of i)if(o(a))return a},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function n(i,o=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(o)}r.joinValues=n,r.jsonStringifyReplacer=(i,o)=>typeof o=="bigint"?o.toString():o})(Am||(Am={}));var bpe;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(bpe||(bpe={}));const du=Am.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),dQ=r=>{switch(typeof r){case"undefined":return du.undefined;case"string":return du.string;case"number":return Number.isNaN(r)?du.nan:du.number;case"boolean":return du.boolean;case"function":return du.function;case"bigint":return du.bigint;case"symbol":return du.symbol;case"object":return Array.isArray(r)?du.array:r===null?du.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?du.promise:typeof Map<"u"&&r instanceof Map?du.map:typeof Set<"u"&&r instanceof Set?du.set:typeof Date<"u"&&r instanceof Date?du.date:du.object;default:return du.unknown}},Is=Am.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);let iS=class AVe extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(o){return o.message},n={_errors:[]},i=o=>{for(const a of o.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else{let s=n,l=0;for(;l<a.path.length;){const c=a.path[l];l===a.path.length-1?(s[c]=s[c]||{_errors:[]},s[c]._errors.push(t(a))):s[c]=s[c]||{_errors:[]},s=s[c],l++}}};return i(this),n}static assert(e){if(!(e instanceof AVe))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Am.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const i of this.issues)if(i.path.length>0){const o=i.path[0];t[o]=t[o]||[],t[o].push(e(i))}else n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};iS.create=r=>new iS(r);const G3=(r,e)=>{let t;switch(r.code){case Is.invalid_type:r.received===du.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case Is.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Am.jsonStringifyReplacer)}`;break;case Is.unrecognized_keys:t=`Unrecognized key(s) in object: ${Am.joinValues(r.keys,", ")}`;break;case Is.invalid_union:t="Invalid input";break;case Is.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Am.joinValues(r.options)}`;break;case Is.invalid_enum_value:t=`Invalid enum value. Expected ${Am.joinValues(r.options)}, received '${r.received}'`;break;case Is.invalid_arguments:t="Invalid function arguments";break;case Is.invalid_return_type:t="Invalid function return type";break;case Is.invalid_date:t="Invalid date";break;case Is.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:Am.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case Is.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="bigint"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case Is.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case Is.custom:t="Invalid input";break;case Is.invalid_intersection_types:t="Intersection results could not be merged";break;case Is.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case Is.not_finite:t="Number must be finite";break;default:t=e.defaultError,Am.assertNever(r)}return{message:t}};let gqe=G3;function NH(){return gqe}const TH=r=>{const{data:e,path:t,errorMaps:n,issueData:i}=r,o=[...t,...i.path||[]],a={...i,path:o};if(i.message!==void 0)return{...i,path:o,message:i.message};let s="";const l=n.filter(c=>!!c).slice().reverse();for(const c of l)s=c(a,{data:e,defaultError:s}).message;return{...i,path:o,message:s}};function Mc(r,e){const t=NH(),n=TH({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===G3?void 0:G3].filter(i=>!!i)});r.common.issues.push(n)}let SB=class dVe{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const i of t){if(i.status==="aborted")return Nf;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const i of t){const o=await i.key,a=await i.value;n.push({key:o,value:a})}return dVe.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:o,value:a}=i;if(o.status==="aborted"||a.status==="aborted")return Nf;o.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),o.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(n[o.value]=a.value)}return{status:e.value,value:n}}};const Nf=Object.freeze({status:"aborted"}),O3=r=>({status:"dirty",value:r}),Xx=r=>({status:"valid",value:r}),Spe=r=>r.status==="aborted",wpe=r=>r.status==="dirty",TM=r=>r.status==="valid",zP=r=>typeof Promise<"u"&&r instanceof Promise;var MA;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(MA||(MA={}));let oS=class{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};const Qpe=(r,e)=>{if(TM(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new iS(r.common.issues);return this._error=t,this._error}}};function Tp(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(a,s)=>{const{message:l}=r;return a.code==="invalid_enum_value"?{message:l??s.defaultError}:typeof s.data>"u"?{message:l??n??s.defaultError}:a.code!=="invalid_type"?{message:s.defaultError}:{message:l??t??s.defaultError}},description:i}}let qg=class{get description(){return this._def.description}_getType(e){return dQ(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:dQ(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new SB,ctx:{common:e.parent.common,data:e.data,parsedType:dQ(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(zP(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){const n={common:{issues:[],async:(t==null?void 0:t.async)??!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:dQ(e)},i=this._parseSync({data:e,path:n.path,parent:n});return Qpe(n,i)}"~validate"(e){var n,i;const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:dQ(e)};if(!this["~standard"].async)try{const o=this._parseSync({data:e,path:[],parent:t});return TM(o)?{value:o.value}:{issues:t.common.issues}}catch(o){(i=(n=o==null?void 0:o.message)==null?void 0:n.toLowerCase())!=null&&i.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(o=>TM(o)?{value:o.value}:{issues:t.common.issues})}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:dQ(e)},i=this._parse({data:e,path:n.path,parent:n}),o=await(zP(i)?i:Promise.resolve(i));return Qpe(n,o)}refine(e,t){const n=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,o)=>{const a=e(i),s=()=>o.addIssue({code:Is.custom,...n(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(l=>l?!0:(s(),!1)):a?!0:(s(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new B2({schema:this,typeName:Kf.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return ow.create(this,this._def)}nullable(){return b2.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return kM.create(this)}promise(){return H3.create(this,this._def)}or(e){return VP.create([this,e],this._def)}and(e){return KP.create(this,e,this._def)}transform(e){return new B2({...Tp(this._def),schema:this,typeName:Kf.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new WP({...Tp(this._def),innerType:this,defaultValue:t,typeName:Kf.ZodDefault})}brand(){return new Gpe({typeName:Kf.ZodBranded,type:this,...Tp(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new qP({...Tp(this._def),innerType:this,catchValue:t,typeName:Kf.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return zqe.create(this,e)}readonly(){return ZP.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const mqe=/^c[^\s-]{8,}$/i,yqe=/^[0-9a-z]+$/,vqe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Iqe=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Cqe=/^[a-z0-9_-]{21}$/i,Eqe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,_qe=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,xqe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Bqe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let PH;const bqe=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Sqe=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,wqe=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Qqe=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Mqe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Dqe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Mpe="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Rqe=new RegExp(`^${Mpe}$`);function Dpe(r){let e="[0-5]\\d";r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`);const t=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function Nqe(r){return new RegExp(`^${Dpe(r)}$`)}function Tqe(r){let e=`${Mpe}T${Dpe(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Pqe(r,e){return!!((e==="v4"||!e)&&bqe.test(r)||(e==="v6"||!e)&&wqe.test(r))}function kqe(r,e){if(!Eqe.test(r))return!1;try{const[t]=r.split(".");if(!t)return!1;const n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),i=JSON.parse(atob(n));return!(typeof i!="object"||i===null||"typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||e&&i.alg!==e)}catch{return!1}}function Uqe(r,e){return!!((e==="v4"||!e)&&Sqe.test(r)||(e==="v6"||!e)&&Qqe.test(r))}let HP=class J4 extends qg{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==du.string){const o=this._getOrReturnCtx(e);return Mc(o,{code:Is.invalid_type,expected:du.string,received:o.parsedType}),Nf}const n=new SB;let i;for(const o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(i=this._getOrReturnCtx(e,i),Mc(i,{code:Is.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="max")e.data.length>o.value&&(i=this._getOrReturnCtx(e,i),Mc(i,{code:Is.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="length"){const a=e.data.length>o.value,s=e.data.length<o.value;(a||s)&&(i=this._getOrReturnCtx(e,i),a?Mc(i,{code:Is.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):s&&Mc(i,{code:Is.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),n.dirty())}else if(o.kind==="email")xqe.test(e.data)||(i=this._getOrReturnCtx(e,i),Mc(i,{validation:"email",code:Is.invalid_string,message:o.message}),n.dirty());else if(o.kind==="emoji")PH||(PH=new RegExp(Bqe,"u")),PH.test(e.data)||(i=this._getOrReturnCtx(e,i),Mc(i,{validation:"emoji",code:Is.invalid_string,message:o.message}),n.dirty());else if(o.kind==="uuid")Iqe.test(e.data)||(i=this._getOrReturnCtx(e,i),Mc(i,{validation:"uuid",code:Is.invalid_string,message:o.message}),n.dirty());else if(o.kind==="nanoid")Cqe.test(e.data)||(i=this._getOrReturnCtx(e,i),Mc(i,{validation:"nanoid",code:Is.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid")mqe.test(e.data)||(i=this._getOrReturnCtx(e,i),Mc(i,{validation:"cuid",code:Is.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid2")yqe.test(e.data)||(i=this._getOrReturnCtx(e,i),Mc(i,{validation:"cuid2",code:Is.invalid_string,message:o.message}),n.dirty());else if(o.kind==="ulid")vqe.test(e.data)||(i=this._getOrReturnCtx(e,i),Mc(i,{validation:"ulid",code:Is.invalid_string,message:o.message}),n.dirty());else if(o.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),Mc(i,{validation:"url",code:Is.invalid_string,message:o.message}),n.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),Mc(i,{validation:"regex",code:Is.invalid_string,message:o.message}),n.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(i=this._getOrReturnCtx(e,i),Mc(i,{code:Is.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),n.dirty()):o.kind==="toLowerCase"?e.data=e.data.toLowerCase():o.kind==="toUpperCase"?e.data=e.data.toUpperCase():o.kind==="startsWith"?e.data.startsWith(o.value)||(i=this._getOrReturnCtx(e,i),Mc(i,{code:Is.invalid_string,validation:{startsWith:o.value},message:o.message}),n.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(i=this._getOrReturnCtx(e,i),Mc(i,{code:Is.invalid_string,validation:{endsWith:o.value},message:o.message}),n.dirty()):o.kind==="datetime"?Tqe(o).test(e.data)||(i=this._getOrReturnCtx(e,i),Mc(i,{code:Is.invalid_string,validation:"datetime",message:o.message}),n.dirty()):o.kind==="date"?Rqe.test(e.data)||(i=this._getOrReturnCtx(e,i),Mc(i,{code:Is.invalid_string,validation:"date",message:o.message}),n.dirty()):o.kind==="time"?Nqe(o).test(e.data)||(i=this._getOrReturnCtx(e,i),Mc(i,{code:Is.invalid_string,validation:"time",message:o.message}),n.dirty()):o.kind==="duration"?_qe.test(e.data)||(i=this._getOrReturnCtx(e,i),Mc(i,{validation:"duration",code:Is.invalid_string,message:o.message}),n.dirty()):o.kind==="ip"?Pqe(e.data,o.version)||(i=this._getOrReturnCtx(e,i),Mc(i,{validation:"ip",code:Is.invalid_string,message:o.message}),n.dirty()):o.kind==="jwt"?kqe(e.data,o.alg)||(i=this._getOrReturnCtx(e,i),Mc(i,{validation:"jwt",code:Is.invalid_string,message:o.message}),n.dirty()):o.kind==="cidr"?Uqe(e.data,o.version)||(i=this._getOrReturnCtx(e,i),Mc(i,{validation:"cidr",code:Is.invalid_string,message:o.message}),n.dirty()):o.kind==="base64"?Mqe.test(e.data)||(i=this._getOrReturnCtx(e,i),Mc(i,{validation:"base64",code:Is.invalid_string,message:o.message}),n.dirty()):o.kind==="base64url"?Dqe.test(e.data)||(i=this._getOrReturnCtx(e,i),Mc(i,{validation:"base64url",code:Is.invalid_string,message:o.message}),n.dirty()):Am.assertNever(o);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:Is.invalid_string,...MA.errToObj(n)})}_addCheck(e){return new J4({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...MA.errToObj(e)})}url(e){return this._addCheck({kind:"url",...MA.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...MA.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...MA.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...MA.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...MA.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...MA.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...MA.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...MA.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...MA.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...MA.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...MA.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...MA.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...MA.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...MA.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...MA.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...MA.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...MA.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...MA.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...MA.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...MA.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...MA.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...MA.errToObj(t)})}nonempty(e){return this.min(1,MA.errToObj(e))}trim(){return new J4({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new J4({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new J4({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};HP.create=r=>new HP({checks:[],typeName:Kf.ZodString,coerce:(r==null?void 0:r.coerce)??!1,...Tp(r)});function Fqe(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,o=Number.parseInt(r.toFixed(i).replace(".","")),a=Number.parseInt(e.toFixed(i).replace(".",""));return o%a/10**i}let kH=class HAe extends qg{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==du.number){const o=this._getOrReturnCtx(e);return Mc(o,{code:Is.invalid_type,expected:du.number,received:o.parsedType}),Nf}let n;const i=new SB;for(const o of this._def.checks)o.kind==="int"?Am.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),Mc(n,{code:Is.invalid_type,expected:"integer",received:"float",message:o.message}),i.dirty()):o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),Mc(n,{code:Is.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),Mc(n,{code:Is.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="multipleOf"?Fqe(e.data,o.value)!==0&&(n=this._getOrReturnCtx(e,n),Mc(n,{code:Is.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),Mc(n,{code:Is.not_finite,message:o.message}),i.dirty()):Am.assertNever(o);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,MA.toString(t))}gt(e,t){return this.setLimit("min",e,!1,MA.toString(t))}lte(e,t){return this.setLimit("max",e,!0,MA.toString(t))}lt(e,t){return this.setLimit("max",e,!1,MA.toString(t))}setLimit(e,t,n,i){return new HAe({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:MA.toString(i)}]})}_addCheck(e){return new HAe({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:MA.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:MA.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:MA.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:MA.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:MA.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:MA.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:MA.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:MA.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:MA.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Am.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}};kH.create=r=>new kH({checks:[],typeName:Kf.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...Tp(r)});let Rpe=class YAe extends qg{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==du.bigint)return this._getInvalidInput(e);let n;const i=new SB;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),Mc(n,{code:Is.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),Mc(n,{code:Is.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),Mc(n,{code:Is.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):Am.assertNever(o);return{status:i.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return Mc(t,{code:Is.invalid_type,expected:du.bigint,received:t.parsedType}),Nf}gte(e,t){return this.setLimit("min",e,!0,MA.toString(t))}gt(e,t){return this.setLimit("min",e,!1,MA.toString(t))}lte(e,t){return this.setLimit("max",e,!0,MA.toString(t))}lt(e,t){return this.setLimit("max",e,!1,MA.toString(t))}setLimit(e,t,n,i){return new YAe({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:MA.toString(i)}]})}_addCheck(e){return new YAe({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:MA.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:MA.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:MA.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:MA.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:MA.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};Rpe.create=r=>new Rpe({checks:[],typeName:Kf.ZodBigInt,coerce:(r==null?void 0:r.coerce)??!1,...Tp(r)});let UH=class extends qg{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==du.boolean){const n=this._getOrReturnCtx(e);return Mc(n,{code:Is.invalid_type,expected:du.boolean,received:n.parsedType}),Nf}return Xx(e.data)}};UH.create=r=>new UH({typeName:Kf.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...Tp(r)});let Npe=class fVe extends qg{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==du.date){const o=this._getOrReturnCtx(e);return Mc(o,{code:Is.invalid_type,expected:du.date,received:o.parsedType}),Nf}if(Number.isNaN(e.data.getTime())){const o=this._getOrReturnCtx(e);return Mc(o,{code:Is.invalid_date}),Nf}const n=new SB;let i;for(const o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(i=this._getOrReturnCtx(e,i),Mc(i,{code:Is.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),n.dirty()):o.kind==="max"?e.data.getTime()>o.value&&(i=this._getOrReturnCtx(e,i),Mc(i,{code:Is.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):Am.assertNever(o);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new fVe({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:MA.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:MA.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};Npe.create=r=>new Npe({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:Kf.ZodDate,...Tp(r)});let Tpe=class extends qg{_parse(e){if(this._getType(e)!==du.symbol){const n=this._getOrReturnCtx(e);return Mc(n,{code:Is.invalid_type,expected:du.symbol,received:n.parsedType}),Nf}return Xx(e.data)}};Tpe.create=r=>new Tpe({typeName:Kf.ZodSymbol,...Tp(r)});let FH=class extends qg{_parse(e){if(this._getType(e)!==du.undefined){const n=this._getOrReturnCtx(e);return Mc(n,{code:Is.invalid_type,expected:du.undefined,received:n.parsedType}),Nf}return Xx(e.data)}};FH.create=r=>new FH({typeName:Kf.ZodUndefined,...Tp(r)});let YP=class extends qg{_parse(e){if(this._getType(e)!==du.null){const n=this._getOrReturnCtx(e);return Mc(n,{code:Is.invalid_type,expected:du.null,received:n.parsedType}),Nf}return Xx(e.data)}};YP.create=r=>new YP({typeName:Kf.ZodNull,...Tp(r)});let z3=class extends qg{constructor(){super(...arguments),this._any=!0}_parse(e){return Xx(e.data)}};z3.create=r=>new z3({typeName:Kf.ZodAny,...Tp(r)});let PM=class extends qg{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Xx(e.data)}};PM.create=r=>new PM({typeName:Kf.ZodUnknown,...Tp(r)});let fQ=class extends qg{_parse(e){const t=this._getOrReturnCtx(e);return Mc(t,{code:Is.invalid_type,expected:du.never,received:t.parsedType}),Nf}};fQ.create=r=>new fQ({typeName:Kf.ZodNever,...Tp(r)});let Ppe=class extends qg{_parse(e){if(this._getType(e)!==du.undefined){const n=this._getOrReturnCtx(e);return Mc(n,{code:Is.invalid_type,expected:du.void,received:n.parsedType}),Nf}return Xx(e.data)}};Ppe.create=r=>new Ppe({typeName:Kf.ZodVoid,...Tp(r)});let kM=class $O extends qg{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==du.array)return Mc(t,{code:Is.invalid_type,expected:du.array,received:t.parsedType}),Nf;if(i.exactLength!==null){const a=t.data.length>i.exactLength.value,s=t.data.length<i.exactLength.value;(a||s)&&(Mc(t,{code:a?Is.too_big:Is.too_small,minimum:s?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(Mc(t,{code:Is.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(Mc(t,{code:Is.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,s)=>i.type._parseAsync(new oS(t,a,t.path,s)))).then(a=>SB.mergeArray(n,a));const o=[...t.data].map((a,s)=>i.type._parseSync(new oS(t,a,t.path,s)));return SB.mergeArray(n,o)}get element(){return this._def.type}min(e,t){return new $O({...this._def,minLength:{value:e,message:MA.toString(t)}})}max(e,t){return new $O({...this._def,maxLength:{value:e,message:MA.toString(t)}})}length(e,t){return new $O({...this._def,exactLength:{value:e,message:MA.toString(t)}})}nonempty(e){return this.min(1,e)}};kM.create=(r,e)=>new kM({type:r,minLength:null,maxLength:null,exactLength:null,typeName:Kf.ZodArray,...Tp(e)});function UM(r){if(r instanceof rw){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=ow.create(UM(n))}return new rw({...r._def,shape:()=>e})}else return r instanceof kM?new kM({...r._def,type:UM(r.element)}):r instanceof ow?ow.create(UM(r.unwrap())):r instanceof b2?b2.create(UM(r.unwrap())):r instanceof x2?x2.create(r.items.map(e=>UM(e))):r}let rw=class jb extends qg{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=Am.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==du.object){const c=this._getOrReturnCtx(e);return Mc(c,{code:Is.invalid_type,expected:du.object,received:c.parsedType}),Nf}const{status:n,ctx:i}=this._processInputParams(e),{shape:o,keys:a}=this._getCached(),s=[];if(!(this._def.catchall instanceof fQ&&this._def.unknownKeys==="strip"))for(const c in i.data)a.includes(c)||s.push(c);const l=[];for(const c of a){const u=o[c],A=i.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new oS(i,A,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof fQ){const c=this._def.unknownKeys;if(c==="passthrough")for(const u of s)l.push({key:{status:"valid",value:u},value:{status:"valid",value:i.data[u]}});else if(c==="strict")s.length>0&&(Mc(i,{code:Is.unrecognized_keys,keys:s}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of s){const A=i.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new oS(i,A,i.path,u)),alwaysSet:u in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of l){const A=await u.key,d=await u.value;c.push({key:A,value:d,alwaysSet:u.alwaysSet})}return c}).then(c=>SB.mergeObjectSync(n,c)):SB.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(e){return MA.errToObj,new jb({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var o,a;const i=((a=(o=this._def).errorMap)==null?void 0:a.call(o,t,n).message)??n.defaultError;return t.code==="unrecognized_keys"?{message:MA.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new jb({...this._def,unknownKeys:"strip"})}passthrough(){return new jb({...this._def,unknownKeys:"passthrough"})}extend(e){return new jb({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new jb({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Kf.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new jb({...this._def,catchall:e})}pick(e){const t={};for(const n of Am.objectKeys(e))e[n]&&this.shape[n]&&(t[n]=this.shape[n]);return new jb({...this._def,shape:()=>t})}omit(e){const t={};for(const n of Am.objectKeys(this.shape))e[n]||(t[n]=this.shape[n]);return new jb({...this._def,shape:()=>t})}deepPartial(){return UM(this)}partial(e){const t={};for(const n of Am.objectKeys(this.shape)){const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}return new jb({...this._def,shape:()=>t})}required(e){const t={};for(const n of Am.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof ow;)o=o._def.innerType;t[n]=o}return new jb({...this._def,shape:()=>t})}keyof(){return Fpe(Am.objectKeys(this.shape))}};rw.create=(r,e)=>new rw({shape:()=>r,unknownKeys:"strip",catchall:fQ.create(),typeName:Kf.ZodObject,...Tp(e)}),rw.strictCreate=(r,e)=>new rw({shape:()=>r,unknownKeys:"strict",catchall:fQ.create(),typeName:Kf.ZodObject,...Tp(e)}),rw.lazycreate=(r,e)=>new rw({shape:r,unknownKeys:"strip",catchall:fQ.create(),typeName:Kf.ZodObject,...Tp(e)});let VP=class extends qg{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function i(o){for(const s of o)if(s.result.status==="valid")return s.result;for(const s of o)if(s.result.status==="dirty")return t.common.issues.push(...s.ctx.common.issues),s.result;const a=o.map(s=>new iS(s.ctx.common.issues));return Mc(t,{code:Is.invalid_union,unionErrors:a}),Nf}if(t.common.async)return Promise.all(n.map(async o=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await o._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(i);{let o;const a=[];for(const l of n){const c={...t,common:{...t.common,issues:[]},parent:null},u=l._parseSync({data:t.data,path:t.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!o&&(o={result:u,ctx:c}),c.common.issues.length&&a.push(c.common.issues)}if(o)return t.common.issues.push(...o.ctx.common.issues),o.result;const s=a.map(l=>new iS(l));return Mc(t,{code:Is.invalid_union,unionErrors:s}),Nf}}get options(){return this._def.options}};VP.create=(r,e)=>new VP({options:r,typeName:Kf.ZodUnion,...Tp(e)});const iw=r=>r instanceof GH?iw(r.schema):r instanceof B2?iw(r.innerType()):r instanceof jP?[r.value]:r instanceof JP?r.options:r instanceof OH?Am.objectValues(r.enum):r instanceof WP?iw(r._def.innerType):r instanceof FH?[void 0]:r instanceof YP?[null]:r instanceof ow?[void 0,...iw(r.unwrap())]:r instanceof b2?[null,...iw(r.unwrap())]:r instanceof Gpe||r instanceof ZP?iw(r.unwrap()):r instanceof qP?iw(r._def.innerType):[];let Lqe=class hVe extends qg{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==du.object)return Mc(t,{code:Is.invalid_type,expected:du.object,received:t.parsedType}),Nf;const n=this.discriminator,i=t.data[n],o=this.optionsMap.get(i);return o?t.common.async?o._parseAsync({data:t.data,path:t.path,parent:t}):o._parseSync({data:t.data,path:t.path,parent:t}):(Mc(t,{code:Is.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Nf)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const i=new Map;for(const o of t){const a=iw(o.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const s of a){if(i.has(s))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);i.set(s,o)}}return new hVe({typeName:Kf.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...Tp(n)})}};function LH(r,e){const t=dQ(r),n=dQ(e);if(r===e)return{valid:!0,data:r};if(t===du.object&&n===du.object){const i=Am.objectKeys(e),o=Am.objectKeys(r).filter(s=>i.indexOf(s)!==-1),a={...r,...e};for(const s of o){const l=LH(r[s],e[s]);if(!l.valid)return{valid:!1};a[s]=l.data}return{valid:!0,data:a}}else if(t===du.array&&n===du.array){if(r.length!==e.length)return{valid:!1};const i=[];for(let o=0;o<r.length;o++){const a=r[o],s=e[o],l=LH(a,s);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return t===du.date&&n===du.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}let KP=class extends qg{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(o,a)=>{if(Spe(o)||Spe(a))return Nf;const s=LH(o.value,a.value);return s.valid?((wpe(o)||wpe(a))&&t.dirty(),{status:t.value,value:s.data}):(Mc(n,{code:Is.invalid_intersection_types}),Nf)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([o,a])=>i(o,a)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};KP.create=(r,e,t)=>new KP({left:r,right:e,typeName:Kf.ZodIntersection,...Tp(t)});let x2=class pVe extends qg{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==du.array)return Mc(n,{code:Is.invalid_type,expected:du.array,received:n.parsedType}),Nf;if(n.data.length<this._def.items.length)return Mc(n,{code:Is.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Nf;!this._def.rest&&n.data.length>this._def.items.length&&(Mc(n,{code:Is.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const o=[...n.data].map((a,s)=>{const l=this._def.items[s]||this._def.rest;return l?l._parse(new oS(n,a,n.path,s)):null}).filter(a=>!!a);return n.common.async?Promise.all(o).then(a=>SB.mergeArray(t,a)):SB.mergeArray(t,o)}get items(){return this._def.items}rest(e){return new pVe({...this._def,rest:e})}};x2.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new x2({items:r,typeName:Kf.ZodTuple,rest:null,...Tp(e)})};let Gqe=class VAe extends qg{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==du.object)return Mc(n,{code:Is.invalid_type,expected:du.object,received:n.parsedType}),Nf;const i=[],o=this._def.keyType,a=this._def.valueType;for(const s in n.data)i.push({key:o._parse(new oS(n,s,n.path,s)),value:a._parse(new oS(n,n.data[s],n.path,s)),alwaysSet:s in n.data});return n.common.async?SB.mergeObjectAsync(t,i):SB.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof qg?new VAe({keyType:e,valueType:t,typeName:Kf.ZodRecord,...Tp(n)}):new VAe({keyType:HP.create(),valueType:e,typeName:Kf.ZodRecord,...Tp(t)})}},kpe=class extends qg{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==du.map)return Mc(n,{code:Is.invalid_type,expected:du.map,received:n.parsedType}),Nf;const i=this._def.keyType,o=this._def.valueType,a=[...n.data.entries()].map(([s,l],c)=>({key:i._parse(new oS(n,s,n.path,[c,"key"])),value:o._parse(new oS(n,l,n.path,[c,"value"]))}));if(n.common.async){const s=new Map;return Promise.resolve().then(async()=>{for(const l of a){const c=await l.key,u=await l.value;if(c.status==="aborted"||u.status==="aborted")return Nf;(c.status==="dirty"||u.status==="dirty")&&t.dirty(),s.set(c.value,u.value)}return{status:t.value,value:s}})}else{const s=new Map;for(const l of a){const c=l.key,u=l.value;if(c.status==="aborted"||u.status==="aborted")return Nf;(c.status==="dirty"||u.status==="dirty")&&t.dirty(),s.set(c.value,u.value)}return{status:t.value,value:s}}}};kpe.create=(r,e,t)=>new kpe({valueType:e,keyType:r,typeName:Kf.ZodMap,...Tp(t)});let Upe=class KAe extends qg{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==du.set)return Mc(n,{code:Is.invalid_type,expected:du.set,received:n.parsedType}),Nf;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(Mc(n,{code:Is.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(Mc(n,{code:Is.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const o=this._def.valueType;function a(l){const c=new Set;for(const u of l){if(u.status==="aborted")return Nf;u.status==="dirty"&&t.dirty(),c.add(u.value)}return{status:t.value,value:c}}const s=[...n.data.values()].map((l,c)=>o._parse(new oS(n,l,n.path,c)));return n.common.async?Promise.all(s).then(l=>a(l)):a(s)}min(e,t){return new KAe({...this._def,minSize:{value:e,message:MA.toString(t)}})}max(e,t){return new KAe({...this._def,maxSize:{value:e,message:MA.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Upe.create=(r,e)=>new Upe({valueType:r,minSize:null,maxSize:null,typeName:Kf.ZodSet,...Tp(e)});let Oqe=class ez extends qg{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==du.function)return Mc(t,{code:Is.invalid_type,expected:du.function,received:t.parsedType}),Nf;function n(s,l){return TH({data:s,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,NH(),G3].filter(c=>!!c),issueData:{code:Is.invalid_arguments,argumentsError:l}})}function i(s,l){return TH({data:s,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,NH(),G3].filter(c=>!!c),issueData:{code:Is.invalid_return_type,returnTypeError:l}})}const o={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof H3){const s=this;return Xx(async function(...l){const c=new iS([]),u=await s._def.args.parseAsync(l,o).catch(f=>{throw c.addIssue(n(l,f)),c}),A=await Reflect.apply(a,this,u);return await s._def.returns._def.type.parseAsync(A,o).catch(f=>{throw c.addIssue(i(A,f)),c})})}else{const s=this;return Xx(function(...l){const c=s._def.args.safeParse(l,o);if(!c.success)throw new iS([n(l,c.error)]);const u=Reflect.apply(a,this,c.data),A=s._def.returns.safeParse(u,o);if(!A.success)throw new iS([i(u,A.error)]);return A.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ez({...this._def,args:x2.create(e).rest(PM.create())})}returns(e){return new ez({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new ez({args:e||x2.create([]).rest(PM.create()),returns:t||PM.create(),typeName:Kf.ZodFunction,...Tp(n)})}},GH=class extends qg{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};GH.create=(r,e)=>new GH({getter:r,typeName:Kf.ZodLazy,...Tp(e)});let jP=class extends qg{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return Mc(t,{received:t.data,code:Is.invalid_literal,expected:this._def.value}),Nf}return{status:"valid",value:e.data}}get value(){return this._def.value}};jP.create=(r,e)=>new jP({value:r,typeName:Kf.ZodLiteral,...Tp(e)});function Fpe(r,e){return new JP({values:r,typeName:Kf.ZodEnum,...Tp(e)})}let JP=class jAe extends qg{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return Mc(t,{expected:Am.joinValues(n),received:t.parsedType,code:Is.invalid_type}),Nf}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return Mc(t,{received:t.data,code:Is.invalid_enum_value,options:n}),Nf}return Xx(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return jAe.create(e,{...this._def,...t})}exclude(e,t=this._def){return jAe.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};JP.create=Fpe;let OH=class extends qg{_parse(e){const t=Am.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==du.string&&n.parsedType!==du.number){const i=Am.objectValues(t);return Mc(n,{expected:Am.joinValues(i),received:n.parsedType,code:Is.invalid_type}),Nf}if(this._cache||(this._cache=new Set(Am.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const i=Am.objectValues(t);return Mc(n,{received:n.data,code:Is.invalid_enum_value,options:i}),Nf}return Xx(e.data)}get enum(){return this._def.values}};OH.create=(r,e)=>new OH({values:r,typeName:Kf.ZodNativeEnum,...Tp(e)});let H3=class extends qg{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==du.promise&&t.common.async===!1)return Mc(t,{code:Is.invalid_type,expected:du.promise,received:t.parsedType}),Nf;const n=t.parsedType===du.promise?t.data:Promise.resolve(t.data);return Xx(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}};H3.create=(r,e)=>new H3({type:r,typeName:Kf.ZodPromise,...Tp(e)});let B2=class extends qg{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Kf.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,o={addIssue:a=>{Mc(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),i.type==="preprocess"){const a=i.transform(n.data,o);if(n.common.async)return Promise.resolve(a).then(async s=>{if(t.value==="aborted")return Nf;const l=await this._def.schema._parseAsync({data:s,path:n.path,parent:n});return l.status==="aborted"?Nf:l.status==="dirty"||t.value==="dirty"?O3(l.value):l});{if(t.value==="aborted")return Nf;const s=this._def.schema._parseSync({data:a,path:n.path,parent:n});return s.status==="aborted"?Nf:s.status==="dirty"||t.value==="dirty"?O3(s.value):s}}if(i.type==="refinement"){const a=s=>{const l=i.refinement(s,o);if(n.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(n.common.async===!1){const s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?Nf:(s.status==="dirty"&&t.dirty(),a(s.value),{status:t.value,value:s.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>s.status==="aborted"?Nf:(s.status==="dirty"&&t.dirty(),a(s.value).then(()=>({status:t.value,value:s.value}))))}if(i.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!TM(a))return Nf;const s=i.transform(a.value,o);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:s}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>TM(a)?Promise.resolve(i.transform(a.value,o)).then(s=>({status:t.value,value:s})):Nf);Am.assertNever(i)}};B2.create=(r,e,t)=>new B2({schema:r,typeName:Kf.ZodEffects,effect:e,...Tp(t)}),B2.createWithPreprocess=(r,e,t)=>new B2({schema:e,effect:{type:"preprocess",transform:r},typeName:Kf.ZodEffects,...Tp(t)});let ow=class extends qg{_parse(e){return this._getType(e)===du.undefined?Xx(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ow.create=(r,e)=>new ow({innerType:r,typeName:Kf.ZodOptional,...Tp(e)});let b2=class extends qg{_parse(e){return this._getType(e)===du.null?Xx(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};b2.create=(r,e)=>new b2({innerType:r,typeName:Kf.ZodNullable,...Tp(e)});let WP=class extends qg{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===du.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};WP.create=(r,e)=>new WP({innerType:r,typeName:Kf.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Tp(e)});let qP=class extends qg{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return zP(i)?i.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new iS(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new iS(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};qP.create=(r,e)=>new qP({innerType:r,typeName:Kf.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Tp(e)});let Lpe=class extends qg{_parse(e){if(this._getType(e)!==du.nan){const n=this._getOrReturnCtx(e);return Mc(n,{code:Is.invalid_type,expected:du.nan,received:n.parsedType}),Nf}return{status:"valid",value:e.data}}};Lpe.create=r=>new Lpe({typeName:Kf.ZodNaN,...Tp(r)});let Gpe=class extends qg{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},zqe=class gVe extends qg{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const o=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?Nf:o.status==="dirty"?(t.dirty(),O3(o.value)):this._def.out._parseAsync({data:o.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?Nf:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new gVe({in:e,out:t,typeName:Kf.ZodPipeline})}},ZP=class extends qg{_parse(e){const t=this._def.innerType._parse(e),n=i=>(TM(i)&&(i.value=Object.freeze(i.value)),i);return zP(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}};ZP.create=(r,e)=>new ZP({innerType:r,typeName:Kf.ZodReadonly,...Tp(e)});function Ope(r,e){const t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function aS(r,e={},t){return r?z3.create().superRefine((n,i)=>{const o=r(n);if(o instanceof Promise)return o.then(a=>{if(!a){const s=Ope(e,n),l=s.fatal??t??!0;i.addIssue({code:"custom",...s,fatal:l})}});if(!o){const a=Ope(e,n),s=a.fatal??t??!0;i.addIssue({code:"custom",...a,fatal:s})}}):z3.create()}var Kf;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(Kf||(Kf={}));const Pe=HP.create,Nr=kH.create,Oo=UH.create,Hqe=YP.create,_x=z3.create;PM.create,fQ.create;const lo=kM.create,Pn=rw.create,Nd=VP.create,hQ=Lqe.create;KP.create,x2.create;const bI=Gqe.create,Yqe=Oqe.create,Qn=jP.create,Ks=JP.create,Vqe=H3.create;ow.create,b2.create;const Kqe="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let zH=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)e+=Kqe[t[r]&63];return e};var zpe={Hz:{baseUnit:"Hz",variants:{MHz:1e6,kHz:1e3,Hz:1}},g:{baseUnit:"g",variants:{kg:1e3,g:1}},Ω:{baseUnit:"Ω",variants:{mΩ:.001,Ω:1,kΩ:1e3,KΩ:1e3,kohm:1e3,MΩ:1e6,GΩ:1e9,TΩ:1e12}},V:{baseUnit:"V",variants:{mV:.001,V:1,kV:1e3,KV:1e3,MV:1e6,GV:1e9,TV:1e12}},A:{baseUnit:"A",variants:{µA:1e-6,mA:.001,ma:.001,A:1,kA:1e3,MA:1e6}},F:{baseUnit:"F",variants:{pF:1e-12,nF:1e-9,µF:1e-6,uF:1e-6,mF:.001,F:1}},ml:{baseUnit:"ml",variants:{ml:1,mL:1,l:1e3,L:1e3}},deg:{baseUnit:"deg",variants:{rad:180/Math.PI}},ms:{baseUnit:"ms",variants:{s:1e3}},mm:{baseUnit:"mm",variants:{nm:1e-6,µm:.001,um:.001,mm:1,cm:10,dm:100,m:1e3,km:1e6,in:25.4,ft:304.8,IN:25.4,FT:304.8,yd:914.4,mi:1609344,mil:.0254}}},HH=new Set;for(const[r,e]of Object.entries(zpe)){HH.add(r);for(const t of Object.keys(e.variants))HH.add(t)}function jqe(r){for(const[e,t]of Object.entries(zpe))if(r in t.variants)return{baseUnit:t.baseUnit,conversionFactor:t.variants[r]};return{baseUnit:r,conversionFactor:1}}var Hpe={tera:1e12,T:1e12,giga:1e9,G:1e9,mega:1e6,M:1e6,kilo:1e3,k:1e3,deci:.1,d:.1,centi:.01,c:.01,milli:.001,m:.001,micro:1e-6,u:1e-6,µ:1e-6,nano:1e-9,n:1e-9,pico:1e-12,p:1e-12},Eb=r=>{var s;if(typeof r>"u")return{parsedUnit:null,unitOfValue:null,value:null};if(typeof r=="string"&&r.match(/^-?[\d\.]+$/))return{value:Number.parseFloat(r),parsedUnit:null,unitOfValue:null};if(typeof r=="number")return{value:r,parsedUnit:null,unitOfValue:null};if(typeof r=="object"&&"x"in r&&"y"in r){const{parsedUnit:l,unitOfValue:c}=Eb(r.x);return{parsedUnit:l,unitOfValue:c,value:{x:Eb(r.x).value,y:Eb(r.y).value}}}const t=(s=r.toString().split("").reverse().join("").match(/[^\d\s]+/))==null?void 0:s[0];if(!t)throw new Error(`Could not determine unit: "${r}"`);const n=t.split("").reverse().join(""),i=r.slice(0,-n.length);if(n in Hpe&&!HH.has(n)){const l=Hpe[n];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(i)*l}}const{baseUnit:o,conversionFactor:a}=jqe(n);return{parsedUnit:n,unitOfValue:o,value:a*Number.parseFloat(i)}},FM=Pe().or(Nr()).transform(r=>Eb(r).value),LM=Pe().or(Nr()).transform(r=>Eb(r).value).transform(r=>Number.parseFloat(r.toPrecision(12))),YH=Pe().or(Nr()).transform(r=>Eb(r).value),GM=Pe().or(Nr()).transform(r=>Eb(r).value),nn=Pe().or(Nr()).transform(r=>Eb(r).value),XP=Pe().or(Nr()).transform(r=>Eb(r).value),Dr=nn,Jqe=Pe().or(Nr()).transform(r=>Eb(r).value),Wqe=Pe().or(Nr()).transform(r=>Eb(r).value),ex=Pe().or(Nr()).transform(r=>typeof r=="number"?r:r.endsWith("deg")?Number.parseFloat(r.split("deg")[0]):r.endsWith("rad")?Number.parseFloat(r.split("rad")[0])*180/Math.PI:Number.parseFloat(r)),Ype=Nr().or(Pe().endsWith("mAh")).transform(r=>{if(typeof r=="string"){const e=r.replace("mAh",""),t=Number.parseFloat(e);if(Number.isNaN(t))throw new Error("Invalid capacity");return t}return r}).describe("Battery capacity in mAh"),Ng=Pn({x:Dr,y:Dr}),qqe=Ng,S2=Pn({x:Dr,y:Dr,z:Dr}),Zqe=S2,VH=Pn({width:Nr(),height:Nr()}),Yd=r=>Pe().optional().default(()=>`${r}_${zH(10)}`),$P=Ks(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]),e8=Ks(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),iE=Pn({type:Qn("source_component"),ftype:Pe().optional(),source_component_id:Pe(),name:Pe(),manufacturer_part_number:Pe().optional(),supplier_part_numbers:bI(e8,lo(Pe())).optional(),display_value:Pe().optional(),are_pins_interchangeable:Oo().optional(),internally_connected_source_port_ids:lo(lo(Pe())).optional(),source_group_id:Pe().optional(),subcircuit_id:Pe().optional()}),KH=iE.extend({ftype:Qn("simple_capacitor"),capacitance:LM,max_voltage_rating:GM.optional(),display_capacitance:Pe().optional(),max_decoupling_trace_length:Dr.optional()}),jH=iE.extend({ftype:Qn("simple_resistor"),resistance:FM,display_resistance:Pe().optional()}),t8=iE.extend({ftype:Qn("simple_diode")}),JH=t8.extend({ftype:Qn("simple_led"),color:Pe().optional(),wavelength:Pe().optional()}),Vpe=iE.extend({ftype:Qn("simple_ground")}),WH=iE.extend({ftype:Qn("simple_chip")}),qH=iE.extend({ftype:Qn("simple_power_source"),voltage:GM}),Xqe=iE.extend({ftype:Qn("simple_fuse"),current_rating_amps:Nr().describe("Nominal current in amps the fuse is rated for"),voltage_rating_volts:Nr().describe("Voltage rating in volts, e.g. ±5V would be 5")}),ZH=iE.extend({ftype:Qn("simple_battery"),capacity:Ype}),XH=iE.extend({ftype:Qn("simple_inductor"),inductance:YH,max_current_rating:Nr().optional()}),$H=iE.extend({ftype:Qn("simple_push_button")}),eY=iE.extend({ftype:Qn("simple_potentiometer"),max_resistance:FM}),Kpe=iE.extend({ftype:Qn("simple_crystal"),frequency:Nr().describe("Frequency in Hz"),load_capacitance:Nr().optional().describe("Load capacitance in pF")}),tY=iE.extend({ftype:Qn("simple_pin_header"),pin_count:Nr(),gender:Ks(["male","female"]).optional().default("male")}),nY=iE.extend({ftype:Qn("simple_resonator"),load_capacitance:LM,equivalent_series_resistance:FM.optional(),frequency:XP}),rY=iE.extend({ftype:Qn("simple_transistor"),transistor_type:Ks(["npn","pnp"])}),iY=iE.extend({ftype:Qn("simple_test_point"),footprint_variant:Ks(["pad","through_hole"]).optional(),pad_shape:Ks(["rect","circle"]).optional(),pad_diameter:Nd([Nr(),Pe()]).optional(),hole_diameter:Nd([Nr(),Pe()]).optional(),width:Nd([Nr(),Pe()]).optional(),height:Nd([Nr(),Pe()]).optional()}),oY=iE.extend({ftype:Qn("simple_mosfet"),channel_type:Ks(["n","p"]),mosfet_mode:Ks(["enhancement","depletion"])}),aY=iE.extend({ftype:Qn("simple_switch")}),sY=Pn({type:Qn("source_project_metadata"),name:Pe().optional(),software_used_string:Pe().optional(),project_url:Pe().optional(),created_at:Pe().datetime().optional()}),jpe=Pn({type:Qn("source_missing_property_error"),source_missing_property_error_id:Yd("source_missing_property_error"),source_component_id:Pe(),property_name:Pe(),subcircuit_id:Pe().optional(),error_type:Qn("source_missing_property_error").default("source_missing_property_error"),message:Pe()}).describe("The source code is missing a property"),Jpe=Pn({type:Qn("source_failed_to_create_component_error"),source_failed_to_create_component_error_id:Yd("source_failed_to_create_component_error"),error_type:Qn("source_failed_to_create_component_error").default("source_failed_to_create_component_error"),component_name:Pe().optional(),subcircuit_id:Pe().optional(),parent_source_component_id:Pe().optional(),message:Pe(),pcb_center:Pn({x:Nr().optional(),y:Nr().optional()}).optional(),schematic_center:Pn({x:Nr().optional(),y:Nr().optional()}).optional()}).describe("Error emitted when a component fails to be constructed"),Wpe=Nd([jH,KH,t8,JH,Vpe,WH,qH,ZH,XH,$H,eY,Kpe,tY,nY,aY,rY,iY,oY,Xqe,sY,jpe,Jpe]),qpe=Pn({type:Qn("source_port"),pin_number:Nr().optional(),port_hints:lo(Pe()).optional(),name:Pe(),source_port_id:Pe(),source_component_id:Pe(),subcircuit_id:Pe().optional(),subcircuit_connectivity_map_key:Pe().optional()}),Zpe=Pn({type:Qn("source_trace"),source_trace_id:Pe(),connected_source_port_ids:lo(Pe()),connected_source_net_ids:lo(Pe()),subcircuit_id:Pe().optional(),subcircuit_connectivity_map_key:Pe().optional(),max_length:Nr().optional(),min_trace_thickness:Nr().optional(),display_name:Pe().optional()}),Xpe=Pn({type:Qn("source_group"),source_group_id:Pe(),subcircuit_id:Pe().optional(),parent_subcircuit_id:Pe().optional(),is_subcircuit:Oo().optional(),name:Pe().optional()}),$pe=Pn({type:Qn("source_net"),source_net_id:Pe(),name:Pe(),member_source_group_ids:lo(Pe()),is_power:Oo().optional(),is_ground:Oo().optional(),is_digital_signal:Oo().optional(),is_analog_signal:Oo().optional(),trace_width:Nr().optional(),subcircuit_id:Pe().optional(),subcircuit_connectivity_map_key:Pe().optional()}),ege=Pn({type:Qn("source_pcb_ground_plane"),source_pcb_ground_plane_id:Pe(),source_group_id:Pe(),source_net_id:Pe(),subcircuit_id:Pe().optional()}).describe("Defines a ground plane in the source domain"),tge=Pn({type:Qn("schematic_box"),schematic_component_id:Pe().optional(),width:Dr,height:Dr,is_dashed:Oo().default(!1),x:Dr,y:Dr,subcircuit_id:Pe().optional()}).describe("Draws a box on the schematic"),nge=Pn({type:Qn("schematic_path"),schematic_component_id:Pe(),fill_color:Ks(["red","blue"]).optional(),is_filled:Oo().optional(),points:lo(Ng),subcircuit_id:Pe().optional()}),rge=bI(Pn({left_margin:nn.optional(),right_margin:nn.optional(),top_margin:nn.optional(),bottom_margin:nn.optional()})),ige=Pn({left_size:Nr(),right_size:Nr(),top_size:Nr().optional(),bottom_size:Nr().optional()}),oge=Pn({left_side:Pn({pins:lo(Nr()),direction:Ks(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:Pn({pins:lo(Nr()),direction:Ks(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:Pn({pins:lo(Nr()),direction:Ks(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:Pn({pins:lo(Nr()),direction:Ks(["left-to-right","right-to-left"]).optional()}).optional()}),age=Nd([ige,oge]),sge=Pn({type:Qn("schematic_component"),size:VH,center:Ng,source_component_id:Pe(),schematic_component_id:Pe(),pin_spacing:nn.optional(),pin_styles:rge.optional(),box_width:nn.optional(),symbol_name:Pe().optional(),port_arrangement:age.optional(),port_labels:bI(Pe()).optional(),symbol_display_value:Pe().optional(),subcircuit_id:Pe().optional(),schematic_group_id:Pe().optional()}),lge=Pn({type:Qn("schematic_line"),schematic_component_id:Pe(),x1:Dr,x2:Dr,y1:Dr,y2:Dr,subcircuit_id:Pe().optional()}),cge=Pn({type:Qn("schematic_trace"),schematic_trace_id:Pe(),source_trace_id:Pe(),junctions:lo(Pn({x:Nr(),y:Nr()})),edges:lo(Pn({from:Pn({x:Nr(),y:Nr()}),to:Pn({x:Nr(),y:Nr()}),is_crossing:Oo().optional(),from_schematic_port_id:Pe().optional(),to_schematic_port_id:Pe().optional()})),subcircuit_id:Pe().optional()}),$qe=Ks(["center","left","right","top","bottom"]),uge=Pn({type:Qn("schematic_text"),schematic_component_id:Pe().optional(),schematic_text_id:Pe(),text:Pe(),font_size:Nr().default(.18),position:Pn({x:Dr,y:Dr}),rotation:Nr().default(0),anchor:Nd([$qe.describe("legacy"),$P]).default("center"),color:Pe().default("#000000"),subcircuit_id:Pe().optional()}),Age=Pn({type:Qn("schematic_port"),schematic_port_id:Pe(),source_port_id:Pe(),schematic_component_id:Pe().optional(),center:Ng,facing_direction:Ks(["up","down","left","right"]).optional(),distance_from_component_edge:Nr().optional(),side_of_component:Ks(["top","bottom","left","right"]).optional(),true_ccw_index:Nr().optional(),pin_number:Nr().optional(),display_pin_label:Pe().optional(),subcircuit_id:Pe().optional(),is_connected:Oo().optional()}).describe("Defines a port on a schematic component"),dge=Pn({type:Qn("schematic_net_label"),schematic_net_label_id:Yd("schematic_net_label"),schematic_trace_id:Pe().optional(),source_trace_id:Pe().optional(),source_net_id:Pe(),center:Ng,anchor_position:Ng.optional(),anchor_side:Ks(["top","bottom","left","right"]),text:Pe(),symbol_name:Pe().optional(),is_movable:Oo().optional(),subcircuit_id:Pe().optional()}),fge=Pn({type:Qn("schematic_error"),schematic_error_id:Pe(),error_type:Qn("schematic_port_not_found").default("schematic_port_not_found"),message:Pe(),subcircuit_id:Pe().optional()}).describe("Defines a schematic error on the schematic"),hge=Pn({type:Qn("schematic_layout_error"),schematic_layout_error_id:Yd("schematic_layout_error"),error_type:Qn("schematic_layout_error").default("schematic_layout_error"),message:Pe(),source_group_id:Pe(),schematic_group_id:Pe(),subcircuit_id:Pe().optional()}).describe("Error emitted when schematic layout fails for a group"),n8=Pn({type:Qn("schematic_debug_object"),label:Pe().optional(),subcircuit_id:Pe().optional()}),pge=n8.extend({shape:Qn("rect"),center:Ng,size:VH}),gge=n8.extend({shape:Qn("line"),start:Ng,end:Ng}),mge=n8.extend({shape:Qn("point"),center:Ng}),yge=hQ("shape",[pge,gge,mge]),vge=Pn({type:Qn("schematic_voltage_probe"),schematic_voltage_probe_id:Pe(),position:Ng,schematic_trace_id:Pe(),voltage:GM.optional(),subcircuit_id:Pe().optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),r8=Pn({type:Qn("schematic_manual_edit_conflict_warning"),schematic_manual_edit_conflict_warning_id:Yd("schematic_manual_edit_conflict_warning"),warning_type:Qn("schematic_manual_edit_conflict_warning").default("schematic_manual_edit_conflict_warning"),message:Pe(),schematic_component_id:Pe(),schematic_group_id:Pe().optional(),subcircuit_id:Pe().optional(),source_component_id:Pe()}).describe("Warning emitted when a component has both manual placement and explicit schX/schY coordinates"),Ige=Pn({type:Qn("schematic_group"),schematic_group_id:Yd("schematic_group"),source_group_id:Pe(),is_subcircuit:Oo().optional(),subcircuit_id:Pe().optional(),width:nn,height:nn,center:Ng,schematic_component_ids:lo(Pe()),name:Pe().optional(),description:Pe().optional()}).describe("Defines a group of components on the schematic"),Cge=Pn({type:Qn("schematic_table"),schematic_table_id:Yd("schematic_table"),anchor_position:Ng,column_widths:lo(Dr),row_heights:lo(Dr),cell_padding:Dr.optional(),border_width:Dr.optional(),subcircuit_id:Pe().optional(),schematic_component_id:Pe().optional(),anchor:$P.optional()}).describe("Defines a table on the schematic"),Ege=Pn({type:Qn("schematic_table_cell"),schematic_table_cell_id:Yd("schematic_table_cell"),schematic_table_id:Pe(),start_row_index:Nr(),end_row_index:Nr(),start_column_index:Nr(),end_column_index:Nr(),text:Pe().optional(),center:Ng,width:Dr,height:Dr,horizontal_align:Ks(["left","center","right"]).optional(),vertical_align:Ks(["top","middle","bottom"]).optional(),font_size:Dr.optional(),subcircuit_id:Pe().optional()}).describe("Defines a cell within a schematic_table"),Y3=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],lY=Ks(Y3),C0=lY.or(Pn({name:lY})).transform(r=>typeof r=="string"?r:r.name),OM=Ks(["top","bottom"]),_ge=Pn({x:Dr,y:Dr,via:Oo().optional(),via_to_layer:C0.optional()}),eZe=lo(_ge),aw=Pn({x:Dr,y:Dr,via:Oo().optional(),to_layer:C0.optional(),trace_width:Dr.optional()}),xge=Pn({type:Qn("pcb_component"),pcb_component_id:Yd("pcb_component"),source_component_id:Pe(),center:Ng,layer:C0,rotation:ex,width:nn,height:nn,subcircuit_id:Pe().optional(),pcb_group_id:Pe().optional()}).describe("Defines a component on the PCB"),Bge=Pn({type:Qn("pcb_hole"),pcb_hole_id:Yd("pcb_hole"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),hole_shape:Ks(["circle","square"]),hole_diameter:Nr(),x:Dr,y:Dr}),tZe=Bge.describe("Defines a circular or square hole on the PCB"),bge=Pn({type:Qn("pcb_hole"),pcb_hole_id:Yd("pcb_hole"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),hole_shape:Qn("oval"),hole_width:Nr(),hole_height:Nr(),x:Dr,y:Dr}),nZe=bge.describe("Defines an oval hole on the PCB"),Sge=Bge.or(bge),rZe=Pn({type:Qn("pcb_plated_hole"),shape:Qn("circle"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),outer_diameter:Nr(),hole_diameter:Nr(),x:Dr,y:Dr,layers:lo(C0),port_hints:lo(Pe()).optional(),pcb_component_id:Pe().optional(),pcb_port_id:Pe().optional(),pcb_plated_hole_id:Yd("pcb_plated_hole")}),iZe=Pn({type:Qn("pcb_plated_hole"),shape:Ks(["oval","pill"]),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),outer_width:Nr(),outer_height:Nr(),hole_width:Nr(),hole_height:Nr(),x:Dr,y:Dr,layers:lo(C0),port_hints:lo(Pe()).optional(),pcb_component_id:Pe().optional(),pcb_port_id:Pe().optional(),pcb_plated_hole_id:Yd("pcb_plated_hole")}),oZe=Pn({type:Qn("pcb_plated_hole"),shape:Qn("circular_hole_with_rect_pad"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),hole_shape:Qn("circle"),pad_shape:Qn("rect"),hole_diameter:Nr(),rect_pad_width:Nr(),rect_pad_height:Nr(),x:Dr,y:Dr,layers:lo(C0),port_hints:lo(Pe()).optional(),pcb_component_id:Pe().optional(),pcb_port_id:Pe().optional(),pcb_plated_hole_id:Yd("pcb_plated_hole")}),aZe=Pn({type:Qn("pcb_plated_hole"),shape:Qn("pill_hole_with_rect_pad"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),hole_shape:Qn("pill"),pad_shape:Qn("rect"),hole_width:Nr(),hole_height:Nr(),rect_pad_width:Nr(),rect_pad_height:Nr(),x:Dr,y:Dr,layers:lo(C0),port_hints:lo(Pe()).optional(),pcb_component_id:Pe().optional(),pcb_port_id:Pe().optional(),pcb_plated_hole_id:Yd("pcb_plated_hole")}),wge=Nd([rZe,iZe,oZe,aZe]),Qge=Pn({type:Qn("pcb_port"),pcb_port_id:Yd("pcb_port"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),source_port_id:Pe(),pcb_component_id:Pe(),x:Dr,y:Dr,layers:lo(C0)}).describe("Defines a port on the PCB"),sZe=Pn({type:Qn("pcb_smtpad"),shape:Qn("circle"),pcb_smtpad_id:Yd("pcb_smtpad"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),x:Dr,y:Dr,radius:Nr(),layer:C0,port_hints:lo(Pe()).optional(),pcb_component_id:Pe().optional(),pcb_port_id:Pe().optional()}),lZe=Pn({type:Qn("pcb_smtpad"),shape:Qn("rect"),pcb_smtpad_id:Yd("pcb_smtpad"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),x:Dr,y:Dr,width:Nr(),height:Nr(),layer:C0,port_hints:lo(Pe()).optional(),pcb_component_id:Pe().optional(),pcb_port_id:Pe().optional()}),cZe=Pn({type:Qn("pcb_smtpad"),shape:Qn("rotated_rect"),pcb_smtpad_id:Yd("pcb_smtpad"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),x:Dr,y:Dr,width:Nr(),height:Nr(),ccw_rotation:ex,layer:C0,port_hints:lo(Pe()).optional(),pcb_component_id:Pe().optional(),pcb_port_id:Pe().optional()}),Mge=Pn({type:Qn("pcb_smtpad"),shape:Qn("pill"),pcb_smtpad_id:Yd("pcb_smtpad"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),x:Dr,y:Dr,width:Nr(),height:Nr(),radius:Nr(),layer:C0,port_hints:lo(Pe()).optional(),pcb_component_id:Pe().optional(),pcb_port_id:Pe().optional()}),uZe=Pn({type:Qn("pcb_smtpad"),shape:Qn("polygon"),pcb_smtpad_id:Yd("pcb_smtpad"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),points:lo(Ng),layer:C0,port_hints:lo(Pe()).optional(),pcb_component_id:Pe().optional(),pcb_port_id:Pe().optional()}),Dge=hQ("shape",[sZe,lZe,cZe,Mge,uZe]).describe("Defines an SMT pad on the PCB"),AZe=Pn({type:Qn("pcb_solder_paste"),shape:Qn("circle"),pcb_solder_paste_id:Yd("pcb_solder_paste"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),x:Dr,y:Dr,radius:Nr(),layer:C0,pcb_component_id:Pe().optional(),pcb_smtpad_id:Pe().optional()}),dZe=Pn({type:Qn("pcb_solder_paste"),shape:Qn("rect"),pcb_solder_paste_id:Yd("pcb_solder_paste"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),x:Dr,y:Dr,width:Nr(),height:Nr(),layer:C0,pcb_component_id:Pe().optional(),pcb_smtpad_id:Pe().optional()}),fZe=Pn({type:Qn("pcb_solder_paste"),shape:Qn("pill"),pcb_solder_paste_id:Yd("pcb_solder_paste"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),x:Dr,y:Dr,width:Nr(),height:Nr(),radius:Nr(),layer:C0,pcb_component_id:Pe().optional(),pcb_smtpad_id:Pe().optional()}),hZe=Pn({type:Qn("pcb_solder_paste"),shape:Qn("rotated_rect"),pcb_solder_paste_id:Yd("pcb_solder_paste"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),x:Dr,y:Dr,width:Nr(),height:Nr(),ccw_rotation:Dr,layer:C0,pcb_component_id:Pe().optional(),pcb_smtpad_id:Pe().optional()}),pZe=Pn({type:Qn("pcb_solder_paste"),shape:Qn("oval"),pcb_solder_paste_id:Yd("pcb_solder_paste"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),x:Dr,y:Dr,width:Nr(),height:Nr(),layer:C0,pcb_component_id:Pe().optional(),pcb_smtpad_id:Pe().optional()}),Rge=Nd([AZe,dZe,fZe,hZe,pZe]).describe("Defines solderpaste on the PCB"),Nge=Pn({type:Qn("pcb_text"),pcb_text_id:Yd("pcb_text"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),text:Pe(),center:Ng,layer:C0,width:nn,height:nn,lines:Nr(),align:Ks(["bottom-left"])}).describe("Defines text on the PCB"),Tge=Pn({route_type:Qn("wire"),x:Dr,y:Dr,width:Dr,start_pcb_port_id:Pe().optional(),end_pcb_port_id:Pe().optional(),layer:C0}),Pge=Pn({route_type:Qn("via"),x:Dr,y:Dr,hole_diameter:Dr.optional(),outer_diameter:Dr.optional(),from_layer:Pe(),to_layer:Pe()}),i8=Nd([Tge,Pge]),kge=Pn({type:Qn("pcb_trace"),source_trace_id:Pe().optional(),pcb_component_id:Pe().optional(),pcb_trace_id:Yd("pcb_trace"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),route_thickness_mode:Ks(["constant","interpolated"]).default("constant").optional(),route_order_index:Nr().optional(),should_round_corners:Oo().optional(),trace_length:Nr().optional(),route:lo(i8)}).describe("Defines a trace on the PCB"),Uge=Pn({type:Qn("pcb_trace_error"),pcb_trace_error_id:Yd("pcb_trace_error"),error_type:Qn("pcb_trace_error").default("pcb_trace_error"),message:Pe(),center:Ng.optional(),pcb_trace_id:Pe(),source_trace_id:Pe(),pcb_component_ids:lo(Pe()),pcb_port_ids:lo(Pe()),subcircuit_id:Pe().optional()}).describe("Defines a trace error on the PCB"),Fge=Pn({type:Qn("pcb_port_not_matched_error"),pcb_error_id:Yd("pcb_error"),error_type:Qn("pcb_port_not_matched_error").default("pcb_port_not_matched_error"),message:Pe(),pcb_component_ids:lo(Pe()),subcircuit_id:Pe().optional()}).describe("Defines a trace error on the PCB where a port is not matched"),Lge=Pn({type:Qn("pcb_via"),pcb_via_id:Yd("pcb_via"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),x:Dr,y:Dr,outer_diameter:Dr.default("0.6mm"),hole_diameter:Dr.default("0.25mm"),from_layer:C0.optional(),to_layer:C0.optional(),layers:lo(C0),pcb_trace_id:Pe().optional()}).describe("Defines a via on the PCB"),Gge=Pn({type:Qn("pcb_board"),pcb_board_id:Yd("pcb_board"),is_subcircuit:Oo().optional(),subcircuit_id:Pe().optional(),width:nn,height:nn,center:Ng,thickness:nn.optional().default(1.4),num_layers:Nr().optional().default(4),outline:lo(Ng).optional(),material:Ks(["fr4","fr1"]).default("fr4")}).describe("Defines the board outline of the PCB"),Oge=Pn({type:Qn("pcb_placement_error"),pcb_placement_error_id:Yd("pcb_placement_error"),error_type:Qn("pcb_placement_error").default("pcb_placement_error"),message:Pe(),subcircuit_id:Pe().optional()}).describe("Defines a placement error on the PCB"),zge=Pn({type:Qn("pcb_trace_hint"),pcb_trace_hint_id:Yd("pcb_trace_hint"),pcb_port_id:Pe(),pcb_component_id:Pe(),route:lo(aw),subcircuit_id:Pe().optional()}).describe("A hint that can be used during generation of a PCB trace"),Hge=Pn({type:Qn("pcb_silkscreen_line"),pcb_silkscreen_line_id:Yd("pcb_silkscreen_line"),pcb_component_id:Pe(),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),stroke_width:Dr.default("0.1mm"),x1:Dr,y1:Dr,x2:Dr,y2:Dr,layer:OM}).describe("Defines a silkscreen line on the PCB"),Yge=Pn({type:Qn("pcb_silkscreen_path"),pcb_silkscreen_path_id:Yd("pcb_silkscreen_path"),pcb_component_id:Pe(),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),layer:OM,route:lo(Ng),stroke_width:nn}).describe("Defines a silkscreen path on the PCB"),Vge=Pn({type:Qn("pcb_silkscreen_text"),pcb_silkscreen_text_id:Yd("pcb_silkscreen_text"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),font:Qn("tscircuit2024").default("tscircuit2024"),font_size:Dr.default("0.2mm"),pcb_component_id:Pe(),text:Pe(),ccw_rotation:Nr().optional(),layer:C0,is_mirrored:Oo().default(!1).optional(),anchor_position:Ng.default({x:0,y:0}),anchor_alignment:$P.default("center")}).describe("Defines silkscreen text on the PCB"),Kge=Pn({type:Qn("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:Yd("pcb_silkscreen_rect"),pcb_component_id:Pe(),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),center:Ng,width:nn,height:nn,layer:C0,stroke_width:nn.default("1mm"),is_filled:Oo().default(!0).optional(),has_stroke:Oo().optional(),is_stroke_dashed:Oo().optional()}).describe("Defines a silkscreen rect on the PCB"),jge=Pn({type:Qn("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:Yd("pcb_silkscreen_circle"),pcb_component_id:Pe(),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),center:Ng,radius:nn,layer:OM,stroke_width:nn.default("1mm")}).describe("Defines a silkscreen circle on the PCB"),Jge=Pn({type:Qn("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:Yd("pcb_silkscreen_oval"),pcb_component_id:Pe(),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),center:Ng,radius_x:Dr,radius_y:Dr,layer:OM}).describe("Defines a silkscreen oval on the PCB"),Wge=Pn({type:Qn("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:Yd("pcb_fabrication_note_text"),subcircuit_id:Pe().optional(),pcb_group_id:Pe().optional(),font:Qn("tscircuit2024").default("tscircuit2024"),font_size:Dr.default("1mm"),pcb_component_id:Pe(),text:Pe(),layer:OM,anchor_position:Ng.default({x:0,y:0}),anchor_alignment:Ks(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:Pe().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),qge=Pn({type:Qn("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:Yd("pcb_fabrication_note_path"),pcb_component_id:Pe(),subcircuit_id:Pe().optional(),layer:C0,route:lo(Ng),stroke_width:nn,color:Pe().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),Zge=Pn({type:Qn("pcb_footprint_overlap_error"),pcb_error_id:Yd("pcb_error"),error_type:Qn("pcb_footprint_overlap_error").default("pcb_footprint_overlap_error"),message:Pe(),pcb_smtpad_ids:lo(Pe()).optional(),pcb_plated_hole_ids:lo(Pe()).optional(),pcb_hole_ids:lo(Pe()).optional(),pcb_keepout_ids:lo(Pe()).optional()}).describe("Error emitted when a pcb footprint overlaps with another element"),Xge=Pn({type:Qn("pcb_keepout"),shape:Qn("rect"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),center:Ng,width:Dr,height:Dr,pcb_keepout_id:Pe(),layers:lo(Pe()),description:Pe().optional()}).or(Pn({type:Qn("pcb_keepout"),shape:Qn("circle"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),center:Ng,radius:Dr,pcb_keepout_id:Pe(),layers:lo(Pe()),description:Pe().optional()})),cY=Pn({type:Qn("pcb_cutout"),pcb_cutout_id:Yd("pcb_cutout"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional()}),$ge=cY.extend({shape:Qn("rect"),center:Ng,width:nn,height:nn,rotation:ex.optional()}),e0e=cY.extend({shape:Qn("circle"),center:Ng,radius:nn}),t0e=cY.extend({shape:Qn("polygon"),points:lo(Ng)}),n0e=hQ("shape",[$ge,e0e,t0e]).describe("Defines a cutout on the PCB, removing board material."),r0e=Pn({type:Qn("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:Yd("pcb_missing_footprint_error"),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),error_type:Qn("pcb_missing_footprint_error").default("pcb_missing_footprint_error"),source_component_id:Pe(),message:Pe()}).describe("Defines a missing footprint error on the PCB"),i0e=Pn({type:Qn("pcb_group"),pcb_group_id:Yd("pcb_group"),source_group_id:Pe(),is_subcircuit:Oo().optional(),subcircuit_id:Pe().optional(),width:nn,height:nn,center:Ng,pcb_component_ids:lo(Pe()),name:Pe().optional(),description:Pe().optional(),autorouter_configuration:Pn({trace_clearance:nn}).optional(),autorouter_used_string:Pe().optional()}).describe("Defines a group of components on the PCB"),o0e=Pn({type:Qn("pcb_autorouting_error"),pcb_error_id:Yd("pcb_autorouting_error"),error_type:Qn("pcb_autorouting_error").default("pcb_autorouting_error"),message:Pe(),subcircuit_id:Pe().optional()}).describe("The autorouting has failed to route a portion of the board"),o8=Pn({type:Qn("pcb_manual_edit_conflict_warning"),pcb_manual_edit_conflict_warning_id:Yd("pcb_manual_edit_conflict_warning"),warning_type:Qn("pcb_manual_edit_conflict_warning").default("pcb_manual_edit_conflict_warning"),message:Pe(),pcb_component_id:Pe(),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),source_component_id:Pe()}).describe("Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),a0e=Pn({type:Qn("pcb_breakout_point"),pcb_breakout_point_id:Yd("pcb_breakout_point"),pcb_group_id:Pe(),subcircuit_id:Pe().optional(),source_trace_id:Pe().optional(),source_port_id:Pe().optional(),source_net_id:Pe().optional(),x:Dr,y:Dr}).describe("Defines a routing target within a pcb_group for a source_trace or source_net"),s0e=Pn({type:Qn("pcb_ground_plane"),pcb_ground_plane_id:Yd("pcb_ground_plane"),source_pcb_ground_plane_id:Pe(),source_net_id:Pe(),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional()}).describe("Defines a ground plane on the PCB"),l0e=Pn({type:Qn("pcb_ground_plane_region"),pcb_ground_plane_region_id:Yd("pcb_ground_plane_region"),pcb_ground_plane_id:Pe(),pcb_group_id:Pe().optional(),subcircuit_id:Pe().optional(),layer:C0,points:lo(Ng)}).describe("Defines a polygon region of a ground plane"),c0e=Pn({type:Qn("pcb_thermal_spoke"),pcb_thermal_spoke_id:Yd("pcb_thermal_spoke"),pcb_ground_plane_id:Pe(),shape:Pe(),spoke_count:Nr(),spoke_thickness:Dr,spoke_inner_diameter:Dr,spoke_outer_diameter:Dr,pcb_plated_hole_id:Pe().optional(),subcircuit_id:Pe().optional()}).describe("Pattern for connecting a ground plane to a plated hole"),u0e=Pn({type:Qn("cad_component"),cad_component_id:Pe(),pcb_component_id:Pe(),source_component_id:Pe(),position:S2,rotation:S2.optional(),size:S2.optional(),layer:C0.optional(),subcircuit_id:Pe().optional(),footprinter_string:Pe().optional(),model_obj_url:Pe().optional(),model_stl_url:Pe().optional(),model_3mf_url:Pe().optional(),model_jscad:_x().optional()}).describe("Defines a component on the PCB"),A0e=Nd([Zpe,qpe,Wpe,$pe,Xpe,WH,KH,t8,JH,jH,qH,ZH,XH,tY,nY,aY,rY,iY,oY,eY,$H,ege,sY,xge,Sge,r0e,o8,wge,Xge,Qge,Nge,kge,Lge,Dge,Rge,Gge,i0e,zge,Hge,Yge,Vge,Kge,jge,Jge,Uge,Oge,Fge,qge,Wge,o0e,Zge,a0e,n0e,s0e,l0e,c0e,tge,uge,lge,sge,Age,cge,nge,fge,hge,dge,yge,vge,r8,Ige,Cge,Ege,u0e]),V3=A0e;const a8=Object.freeze(Object.defineProperty({__proto__:null,all_layers:Y3,any_circuit_element:A0e,any_soup_element:V3,any_source_component:Wpe,battery_capacity:Ype,cad_component:u0e,capacitance:LM,current:Jqe,distance:Dr,frequency:XP,getZodPrefixedIdWithDefault:Yd,inductance:YH,layer_ref:C0,layer_string:lY,length:nn,ninePointAnchor:$P,pcb_autorouting_error:o0e,pcb_board:Gge,pcb_breakout_point:a0e,pcb_component:xge,pcb_cutout:n0e,pcb_cutout_circle:e0e,pcb_cutout_polygon:t0e,pcb_cutout_rect:$ge,pcb_fabrication_note_path:qge,pcb_fabrication_note_text:Wge,pcb_footprint_overlap_error:Zge,pcb_ground_plane:s0e,pcb_ground_plane_region:l0e,pcb_group:i0e,pcb_hole:Sge,pcb_hole_circle_or_square_shape:tZe,pcb_hole_oval_shape:nZe,pcb_keepout:Xge,pcb_manual_edit_conflict_warning:o8,pcb_missing_footprint_error:r0e,pcb_placement_error:Oge,pcb_plated_hole:wge,pcb_port:Qge,pcb_port_not_matched_error:Fge,pcb_route_hint:_ge,pcb_route_hints:eZe,pcb_silkscreen_circle:jge,pcb_silkscreen_line:Hge,pcb_silkscreen_oval:Jge,pcb_silkscreen_path:Yge,pcb_silkscreen_rect:Kge,pcb_silkscreen_text:Vge,pcb_smtpad:Dge,pcb_smtpad_pill:Mge,pcb_solder_paste:Rge,pcb_text:Nge,pcb_thermal_spoke:c0e,pcb_trace:kge,pcb_trace_error:Uge,pcb_trace_hint:zge,pcb_trace_route_point:i8,pcb_trace_route_point_via:Pge,pcb_trace_route_point_wire:Tge,pcb_via:Lge,point:Ng,point3:S2,port_arrangement:age,position:qqe,position3:Zqe,resistance:FM,rotation:ex,route_hint_point:aw,schematic_box:tge,schematic_component:sge,schematic_component_port_arrangement_by_sides:oge,schematic_component_port_arrangement_by_size:ige,schematic_debug_line:gge,schematic_debug_object:yge,schematic_debug_object_base:n8,schematic_debug_point:mge,schematic_debug_rect:pge,schematic_error:fge,schematic_group:Ige,schematic_layout_error:hge,schematic_line:lge,schematic_manual_edit_conflict_warning:r8,schematic_net_label:dge,schematic_path:nge,schematic_pin_styles:rge,schematic_port:Age,schematic_table:Cge,schematic_table_cell:Ege,schematic_text:uge,schematic_trace:cge,schematic_voltage_probe:vge,size:VH,source_component_base:iE,source_failed_to_create_component_error:Jpe,source_group:Xpe,source_missing_property_error:jpe,source_net:$pe,source_pcb_ground_plane:ege,source_port:qpe,source_project_metadata:sY,source_simple_battery:ZH,source_simple_capacitor:KH,source_simple_chip:WH,source_simple_crystal:Kpe,source_simple_diode:t8,source_simple_ground:Vpe,source_simple_inductor:XH,source_simple_led:JH,source_simple_mosfet:oY,source_simple_pin_header:tY,source_simple_potentiometer:eY,source_simple_power_source:qH,source_simple_push_button:$H,source_simple_resistor:jH,source_simple_resonator:nY,source_simple_switch:aY,source_simple_test_point:iY,source_simple_transistor:rY,source_trace:Zpe,supplier_name:e8,time:Wqe,visible_layer:OM,voltage:GM},Symbol.toStringTag,{value:"Module"}));function Xr(r,e){return Array.isArray(e)?[r.a*e[0]+r.c*e[1]+r.e,r.b*e[0]+r.d*e[1]+r.f]:{x:r.a*e.x+r.c*e.y+r.e,y:r.b*e.x+r.d*e.y+r.f}}function gZe(r,e){return e.map(t=>Xr(r,t))}function d0e(r){return{a:parseFloat(r.a),b:parseFloat(r.b),c:parseFloat(r.c),d:parseFloat(r.d),e:parseFloat(r.e),f:parseFloat(r.f)}}const mZe=/^matrix\(\s*([0-9_+-.e]+)\s*,\s*([0-9_+-.e]+)\s*,\s*([0-9_+-.e]+)\s*,\s*([0-9_+-.e]+)\s*,\s*([0-9_+-.e]+)\s*,\s*([0-9_+-.e]+)\s*\)$/i;function uY(r){const e=r.match(mZe);if(e===null||e.length<7)throw new Error(`'${r}' is not a matrix`);return{a:parseFloat(e[1]),b:parseFloat(e[2]),c:parseFloat(e[3]),d:parseFloat(e[4]),e:parseFloat(e[5]),f:parseFloat(e[6])}}function Ny(){return{a:1,c:0,e:0,b:0,d:1,f:0}}function sS(r){const{a:e,b:t,c:n,d:i,e:o,f:a}=r,s=e*i-t*n;return{a:i/s,b:t/-s,c:n/-s,d:e/s,e:(i*o-n*a)/-s,f:(t*o-e*a)/s}}function K3(r){return typeof r>"u"}function zM(r){return typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r)}function yZe(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}function vZe(r){return yZe(r)&&"a"in r&&zM(r.a)&&"b"in r&&zM(r.b)&&"c"in r&&zM(r.c)&&"d"in r&&zM(r.d)&&"e"in r&&zM(r.e)&&"f"in r&&zM(r.f)}function $d(r,e=0){return{a:1,c:0,e:r,b:0,d:1,f:e}}function pQ(...r){r=Array.isArray(r[0])?r[0]:r;const e=(t,n)=>({a:t.a*n.a+t.c*n.b,c:t.a*n.c+t.c*n.d,e:t.a*n.e+t.c*n.f+t.e,b:t.b*n.a+t.d*n.b,d:t.b*n.c+t.d*n.d,f:t.b*n.e+t.d*n.f+t.f});switch(r.length){case 0:throw new Error("no matrices provided");case 1:return r[0];case 2:return e(r[0],r[1]);default:{const[t,n,...i]=r,o=e(t,n);return pQ(o,...i)}}}function Ku(...r){return pQ(...r)}const{cos:IZe,sin:CZe,PI:EZe}=Math;function $x(r,e,t){const n=IZe(r),i=CZe(r),o={a:n,c:-i,e:0,b:i,d:n,f:0};return K3(e)||K3(t)?o:pQ([$d(e,t),o,$d(-e,-t)])}function AY(r,e=void 0,t=void 0){return $x(r*EZe/180,e,t)}function oE(r,e=void 0,t=void 0,n=void 0){K3(e)&&(e=r);const i={a:r,c:0,e:0,b:0,d:e,f:0};return K3(t)||K3(n)?i:pQ([$d(t,n),i,$d(-t,-n)])}function f0e(r,e){return{a:1,c:r,e:0,b:e,d:1,f:0}}const{tan:h0e}=Math;function p0e(r,e){return{a:1,c:h0e(r),e:0,b:h0e(e),d:1,f:0}}function dY(r,e){return p0e(r*Math.PI/180,e*Math.PI/180)}function _Ze(r){return gQ(r)}function g0e(r){return gQ(r)}function gQ(r){return`matrix(${r.a},${r.b},${r.c},${r.d},${r.e},${r.f})`}function m0e(r,e=1e10){return{a:Math.round(r.a*e)/e,b:Math.round(r.b*e)/e,c:Math.round(r.c*e)/e,d:Math.round(r.d*e)/e,e:Math.round(r.e*e)/e,f:Math.round(r.f*e)/e}}function y0e(r,e){const t=r[0].x!=null?r[0].x:r[0][0],n=r[0].y!=null?r[0].y:r[0][1],i=e[0].x!=null?e[0].x:e[0][0],o=e[0].y!=null?e[0].y:e[0][1],a=r[1].x!=null?r[1].x:r[1][0],s=r[1].y!=null?r[1].y:r[1][1],l=e[1].x!=null?e[1].x:e[1][0],c=e[1].y!=null?e[1].y:e[1][1],u=r[2].x!=null?r[2].x:r[2][0],A=r[2].y!=null?r[2].y:r[2][1],d=e[2].x!=null?e[2].x:e[2][0],f=e[2].y!=null?e[2].y:e[2][1],m={a:t-u,b:n-A,c:a-u,d:s-A,e:u,f:A},C={a:i-d,b:o-f,c:l-d,d:c-f,e:d,f},E=sS(m),_=pQ([C,E]);return m0e(_)}function xZe(r){return Array.isArray(r)?r.map(e):e(r);function e(t){switch(t.type){case"matrix":if("a"in t&&"b"in t&&"c"in t&&"d"in t&&"e"in t&&"f"in t)return d0e(t);throw new Error("MISSING_MANDATORY_PARAM");case"translate":if(!("tx"in t))throw new Error("MISSING_MANDATORY_PARAM");return"ty"in t?$d(t.tx,t.ty):$d(t.tx);case"scale":if(!("sx"in t))throw new Error("MISSING_MANDATORY_PARAM");return"sy"in t?oE(t.sx,t.sy):oE(t.sx);case"rotate":if(!("angle"in t))throw new Error("MISSING_MANDATORY_PARAM");return"cx"in t&&"cy"in t?AY(t.angle,t.cx,t.cy):AY(t.angle);case"skewX":if(!("angle"in t))throw new Error("MISSING_MANDATORY_PARAM");return dY(t.angle,0);case"skewY":if(!("angle"in t))throw new Error("MISSING_MANDATORY_PARAM");return dY(0,t.angle);case"shear":if(!("shx"in t&&"shy"in t))throw new Error("MISSING_MANDATORY_PARAM");return f0e(t.shx,t.shy);default:throw new Error("UNSUPPORTED_DESCRIPTOR")}}}function BZe(r,e){function t(){this.constructor=r}t.prototype=e.prototype,r.prototype=new t}function HM(r,e,t,n){var i=Error.call(this,r);return Object.setPrototypeOf&&Object.setPrototypeOf(i,HM.prototype),i.expected=e,i.found=t,i.location=n,i.name="SyntaxError",i}BZe(HM,Error);function fY(r,e,t){return t=t||" ",r.length>e?r:(e-=r.length,t+=t.repeat(e),r+t.slice(0,e))}HM.prototype.format=function(r){var e="Error: "+this.message;if(this.location){var t=null,n;for(n=0;n<r.length;n++)if(r[n].source===this.location.source){t=r[n].text.split(/\r\n|\n|\r/g);break}var i=this.location.start,o=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(i):i,a=this.location.source+":"+o.line+":"+o.column;if(t){var s=this.location.end,l=fY("",o.line.toString().length," "),c=t[i.line-1],u=i.line===s.line?s.column:c.length+1,A=u-i.column||1;e+=`
|
|
245
245
|
--> `+a+`
|
|
246
246
|
`+l+` |
|
|
247
247
|
`+o.line+" | "+c+`
|
|
@@ -13211,12 +13211,12 @@ ${l.join(`
|
|
|
13211
13211
|
`)},vGe=function(){var r=parseInt(document.body.getAttribute(QR)||"0",10);return isFinite(r)?r:0},OHt=function(){pt.useEffect(function(){return document.body.setAttribute(QR,(vGe()+1).toString()),function(){var r=vGe()-1;r<=0?document.body.removeAttribute(QR):document.body.setAttribute(QR,r.toString())}},[])},zHt=function(r){var e=r.noRelative,t=r.noImportant,n=r.gapMode,i=n===void 0?"margin":n;OHt();var o=pt.useMemo(function(){return FHt(i)},[i]);return pt.createElement(LHt,{styles:GHt(o,!e,i,t?"":"!important")})},Yle=!1;if(typeof window<"u")try{var w7=Object.defineProperty({},"passive",{get:function(){return Yle=!0,!0}});window.addEventListener("test",w7,w7),window.removeEventListener("test",w7,w7)}catch{Yle=!1}var MR=Yle?{passive:!1}:!1,HHt=function(r){return r.tagName==="TEXTAREA"},IGe=function(r,e){if(!(r instanceof Element))return!1;var t=window.getComputedStyle(r);return t[e]!=="hidden"&&!(t.overflowY===t.overflowX&&!HHt(r)&&t[e]==="visible")},YHt=function(r){return IGe(r,"overflowY")},VHt=function(r){return IGe(r,"overflowX")},CGe=function(r,e){var t=e.ownerDocument,n=e;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var i=EGe(r,n);if(i){var o=_Ge(r,n),a=o[1],s=o[2];if(a>s)return!0}n=n.parentNode}while(n&&n!==t.body);return!1},KHt=function(r){var e=r.scrollTop,t=r.scrollHeight,n=r.clientHeight;return[e,t,n]},jHt=function(r){var e=r.scrollLeft,t=r.scrollWidth,n=r.clientWidth;return[e,t,n]},EGe=function(r,e){return r==="v"?YHt(e):VHt(e)},_Ge=function(r,e){return r==="v"?KHt(e):jHt(e)},JHt=function(r,e){return r==="h"&&e==="rtl"?-1:1},WHt=function(r,e,t,n,i){var o=JHt(r,window.getComputedStyle(e).direction),a=o*n,s=t.target,l=e.contains(s),c=!1,u=a>0,A=0,d=0;do{if(!s)break;var f=_Ge(r,s),m=f[0],C=f[1],E=f[2],_=C-E-o*m;(m||_)&&EGe(r,s)&&(A+=_,d+=m);var x=s.parentNode;s=x&&x.nodeType===Node.DOCUMENT_FRAGMENT_NODE?x.host:x}while(!l&&s!==document.body||l&&(e.contains(s)||e===s));return(u&&Math.abs(A)<1||!u&&Math.abs(d)<1)&&(c=!0),c},Q7=function(r){return"changedTouches"in r?[r.changedTouches[0].clientX,r.changedTouches[0].clientY]:[0,0]},xGe=function(r){return[r.deltaX,r.deltaY]},BGe=function(r){return r&&"current"in r?r.current:r},qHt=function(r,e){return r[0]===e[0]&&r[1]===e[1]},ZHt=function(r){return`
|
|
13212
13212
|
.block-interactivity-`.concat(r,` {pointer-events: none;}
|
|
13213
13213
|
.allow-interactivity-`).concat(r,` {pointer-events: all;}
|
|
13214
|
-
`)},XHt=0,DR=[];function $Ht(r){var e=pt.useRef([]),t=pt.useRef([0,0]),n=pt.useRef(),i=pt.useState(XHt++)[0],o=pt.useState(yGe)[0],a=pt.useRef(r);pt.useEffect(function(){a.current=r},[r]),pt.useEffect(function(){if(r.inert){document.body.classList.add("block-interactivity-".concat(i));var C=IHt([r.lockRef.current],(r.shards||[]).map(BGe),!0).filter(Boolean);return C.forEach(function(E){return E.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),C.forEach(function(E){return E.classList.remove("allow-interactivity-".concat(i))})}}},[r.inert,r.lockRef.current,r.shards]);var s=pt.useCallback(function(C,E){if("touches"in C&&C.touches.length===2||C.type==="wheel"&&C.ctrlKey)return!a.current.allowPinchZoom;var _=Q7(C),x=t.current,w="deltaX"in C?C.deltaX:x[0]-_[0],P="deltaY"in C?C.deltaY:x[1]-_[1],L,O=C.target,H=Math.abs(w)>Math.abs(P)?"h":"v";if("touches"in C&&H==="h"&&O.type==="range")return!1;var K=CGe(H,O);if(!K)return!0;if(K?L=H:(L=H==="v"?"h":"v",K=CGe(H,O)),!K)return!1;if(!n.current&&"changedTouches"in C&&(w||P)&&(n.current=L),!L)return!0;var q=n.current||L;return WHt(q,E,C,q==="h"?w:P)},[]),l=pt.useCallback(function(C){var E=C;if(!(!DR.length||DR[DR.length-1]!==o)){var _="deltaY"in E?xGe(E):Q7(E),x=e.current.filter(function(L){return L.name===E.type&&(L.target===E.target||E.target===L.shadowParent)&&qHt(L.delta,_)})[0];if(x&&x.should){E.cancelable&&E.preventDefault();return}if(!x){var w=(a.current.shards||[]).map(BGe).filter(Boolean).filter(function(L){return L.contains(E.target)}),P=w.length>0?s(E,w[0]):!a.current.noIsolation;P&&E.cancelable&&E.preventDefault()}}},[]),c=pt.useCallback(function(C,E,_,x){var w={name:C,delta:E,target:_,should:x,shadowParent:eYt(_)};e.current.push(w),setTimeout(function(){e.current=e.current.filter(function(P){return P!==w})},1)},[]),u=pt.useCallback(function(C){t.current=Q7(C),n.current=void 0},[]),A=pt.useCallback(function(C){c(C.type,xGe(C),C.target,s(C,r.lockRef.current))},[]),d=pt.useCallback(function(C){c(C.type,Q7(C),C.target,s(C,r.lockRef.current))},[]);pt.useEffect(function(){return DR.push(o),r.setCallbacks({onScrollCapture:A,onWheelCapture:A,onTouchMoveCapture:d}),document.addEventListener("wheel",l,MR),document.addEventListener("touchmove",l,MR),document.addEventListener("touchstart",u,MR),function(){DR=DR.filter(function(C){return C!==o}),document.removeEventListener("wheel",l,MR),document.removeEventListener("touchmove",l,MR),document.removeEventListener("touchstart",u,MR)}},[]);var f=r.removeScrollBar,m=r.inert;return pt.createElement(pt.Fragment,null,m?pt.createElement(o,{styles:ZHt(i)}):null,f?pt.createElement(zHt,{noRelative:r.noRelative,gapMode:r.gapMode}):null)}function eYt(r){for(var e=null;r!==null;)r instanceof ShadowRoot&&(e=r.host,r=r.host),r=r.parentNode;return e}const tYt=QHt(mGe,$Ht);var bGe=pt.forwardRef(function(r,e){return pt.createElement(S7,GS({},r,{ref:e,sideCar:tYt}))});bGe.classNames=S7.classNames;var Vle=["Enter"," "],nYt=["ArrowDown","PageUp","Home"],SGe=["ArrowUp","PageDown","End"],rYt=[...nYt,...SGe],iYt={ltr:[...Vle,"ArrowRight"],rtl:[...Vle,"ArrowLeft"]},oYt={ltr:["ArrowLeft"],rtl:["ArrowRight"]},GT="Menu",[OT,aYt,sYt]=Ede(GT),[W9,wGe]=gM(GT,[sYt,rGe,nP]),M7=rGe(),QGe=nP(),[lYt,q9]=W9(GT),[cYt,zT]=W9(GT),MGe=r=>{const{__scopeMenu:e,open:t=!1,children:n,dir:i,onOpenChange:o,modal:a=!0}=r,s=M7(e),[l,c]=pt.useState(null),u=pt.useRef(!1),A=WS(o),d=fz(i);return pt.useEffect(()=>{const f=()=>{u.current=!0,document.addEventListener("pointerdown",m,{capture:!0,once:!0}),document.addEventListener("pointermove",m,{capture:!0,once:!0})},m=()=>u.current=!1;return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",m,{capture:!0}),document.removeEventListener("pointermove",m,{capture:!0})}},[]),ut.jsx(AHt,{...s,children:ut.jsx(lYt,{scope:e,open:t,onOpenChange:A,content:l,onContentChange:c,children:ut.jsx(cYt,{scope:e,onClose:pt.useCallback(()=>A(!1),[A]),isUsingKeyboardRef:u,dir:d,modal:a,children:n})})})};MGe.displayName=GT;var uYt="MenuAnchor",Kle=pt.forwardRef((r,e)=>{const{__scopeMenu:t,...n}=r,i=M7(t);return ut.jsx(dHt,{...i,...n,ref:e})});Kle.displayName=uYt;var jle="MenuPortal",[AYt,DGe]=W9(jle,{forceMount:void 0}),RGe=r=>{const{__scopeMenu:e,forceMount:t,children:n,container:i}=r,o=q9(jle,e);return ut.jsx(AYt,{scope:e,forceMount:t,children:ut.jsx(mM,{present:t||o.open,children:ut.jsx(dGe,{asChild:!0,container:i,children:n})})})};RGe.displayName=jle;var db="MenuContent",[dYt,Jle]=W9(db),NGe=pt.forwardRef((r,e)=>{const t=DGe(db,r.__scopeMenu),{forceMount:n=t.forceMount,...i}=r,o=q9(db,r.__scopeMenu),a=zT(db,r.__scopeMenu);return ut.jsx(OT.Provider,{scope:r.__scopeMenu,children:ut.jsx(mM,{present:n||o.open,children:ut.jsx(OT.Slot,{scope:r.__scopeMenu,children:a.modal?ut.jsx(fYt,{...i,ref:e}):ut.jsx(hYt,{...i,ref:e})})})})}),fYt=pt.forwardRef((r,e)=>{const t=q9(db,r.__scopeMenu),n=pt.useRef(null),i=jx(e,n);return pt.useEffect(()=>{const o=n.current;if(o)return vHt(o)},[]),ut.jsx(Wle,{...r,ref:i,trapFocus:t.open,disableOutsidePointerEvents:t.open,disableOutsideScroll:!0,onFocusOutside:Jg(r.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>t.onOpenChange(!1)})}),hYt=pt.forwardRef((r,e)=>{const t=q9(db,r.__scopeMenu);return ut.jsx(Wle,{...r,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>t.onOpenChange(!1)})}),pYt=h3("MenuContent.ScrollLock"),Wle=pt.forwardRef((r,e)=>{const{__scopeMenu:t,loop:n=!1,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:a,disableOutsidePointerEvents:s,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:A,onInteractOutside:d,onDismiss:f,disableOutsideScroll:m,...C}=r,E=q9(db,t),_=zT(db,t),x=M7(t),w=QGe(t),P=aYt(t),[L,O]=pt.useState(null),H=pt.useRef(null),K=jx(e,H,E.onContentChange),q=pt.useRef(0),Y=pt.useRef(""),se=pt.useRef(0),ie=pt.useRef(null),de=pt.useRef("right"),Ce=pt.useRef(0),xe=m?bGe:pt.Fragment,fe=m?{as:pYt,allowPinchZoom:!0}:void 0,Ie=Qe=>{var Ft,Lt;const De=Y.current+Qe,Fe=P().filter(tt=>!tt.disabled),Ne=document.activeElement,rt=(Ft=Fe.find(tt=>tt.ref.current===Ne))==null?void 0:Ft.textValue,et=Fe.map(tt=>tt.textValue),ft=SYt(et,De,rt),_t=(Lt=Fe.find(tt=>tt.textValue===ft))==null?void 0:Lt.ref.current;(function tt(xt){Y.current=xt,window.clearTimeout(q.current),xt!==""&&(q.current=window.setTimeout(()=>tt(""),1e3))})(De),_t&&setTimeout(()=>_t.focus())};pt.useEffect(()=>()=>window.clearTimeout(q.current),[]),FOt();const ve=pt.useCallback(Qe=>{var Fe,Ne;return de.current===((Fe=ie.current)==null?void 0:Fe.side)&&QYt(Qe,(Ne=ie.current)==null?void 0:Ne.area)},[]);return ut.jsx(dYt,{scope:t,searchRef:Y,onItemEnter:pt.useCallback(Qe=>{ve(Qe)&&Qe.preventDefault()},[ve]),onItemLeave:pt.useCallback(Qe=>{var De;ve(Qe)||((De=H.current)==null||De.focus(),O(null))},[ve]),onTriggerLeave:pt.useCallback(Qe=>{ve(Qe)&&Qe.preventDefault()},[ve]),pointerGraceTimerRef:se,onPointerGraceIntentChange:pt.useCallback(Qe=>{ie.current=Qe},[]),children:ut.jsx(xe,{...fe,children:ut.jsx(QLe,{asChild:!0,trapped:i,onMountAutoFocus:Jg(o,Qe=>{var De;Qe.preventDefault(),(De=H.current)==null||De.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:ut.jsx(xLe,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:A,onInteractOutside:d,onDismiss:f,children:ut.jsx(Qde,{asChild:!0,...w,dir:_.dir,orientation:"vertical",loop:n,currentTabStopId:L,onCurrentTabStopIdChange:O,onEntryFocus:Jg(l,Qe=>{_.isUsingKeyboardRef.current||Qe.preventDefault()}),preventScrollOnEntryFocus:!0,children:ut.jsx(fHt,{role:"menu","aria-orientation":"vertical","data-state":qGe(E.open),"data-radix-menu-content":"",dir:_.dir,...x,...C,ref:K,style:{outline:"none",...C.style},onKeyDown:Jg(C.onKeyDown,Qe=>{const Fe=Qe.target.closest("[data-radix-menu-content]")===Qe.currentTarget,Ne=Qe.ctrlKey||Qe.altKey||Qe.metaKey,rt=Qe.key.length===1;Fe&&(Qe.key==="Tab"&&Qe.preventDefault(),!Ne&&rt&&Ie(Qe.key));const et=H.current;if(Qe.target!==et||!rYt.includes(Qe.key))return;Qe.preventDefault();const _t=P().filter(Ft=>!Ft.disabled).map(Ft=>Ft.ref.current);SGe.includes(Qe.key)&&_t.reverse(),BYt(_t)}),onBlur:Jg(r.onBlur,Qe=>{Qe.currentTarget.contains(Qe.target)||(window.clearTimeout(q.current),Y.current="")}),onPointerMove:Jg(r.onPointerMove,YT(Qe=>{const De=Qe.target,Fe=Ce.current!==Qe.clientX;if(Qe.currentTarget.contains(De)&&Fe){const Ne=Qe.clientX>Ce.current?"right":"left";de.current=Ne,Ce.current=Qe.clientX}}))})})})})})})});NGe.displayName=db;var gYt="MenuGroup",qle=pt.forwardRef((r,e)=>{const{__scopeMenu:t,...n}=r;return ut.jsx(nE.div,{role:"group",...n,ref:e})});qle.displayName=gYt;var mYt="MenuLabel",TGe=pt.forwardRef((r,e)=>{const{__scopeMenu:t,...n}=r;return ut.jsx(nE.div,{...n,ref:e})});TGe.displayName=mYt;var D7="MenuItem",PGe="menu.itemSelect",R7=pt.forwardRef((r,e)=>{const{disabled:t=!1,onSelect:n,...i}=r,o=pt.useRef(null),a=zT(D7,r.__scopeMenu),s=Jle(D7,r.__scopeMenu),l=jx(e,o),c=pt.useRef(!1),u=()=>{const A=o.current;if(!t&&A){const d=new CustomEvent(PGe,{bubbles:!0,cancelable:!0});A.addEventListener(PGe,f=>n==null?void 0:n(f),{once:!0}),_de(A,d),d.defaultPrevented?c.current=!1:a.onClose()}};return ut.jsx(kGe,{...i,ref:l,disabled:t,onClick:Jg(r.onClick,u),onPointerDown:A=>{var d;(d=r.onPointerDown)==null||d.call(r,A),c.current=!0},onPointerUp:Jg(r.onPointerUp,A=>{var d;c.current||(d=A.currentTarget)==null||d.click()}),onKeyDown:Jg(r.onKeyDown,A=>{const d=s.searchRef.current!=="";t||d&&A.key===" "||Vle.includes(A.key)&&(A.currentTarget.click(),A.preventDefault())})})});R7.displayName=D7;var kGe=pt.forwardRef((r,e)=>{const{__scopeMenu:t,disabled:n=!1,textValue:i,...o}=r,a=Jle(D7,t),s=QGe(t),l=pt.useRef(null),c=jx(e,l),[u,A]=pt.useState(!1),[d,f]=pt.useState("");return pt.useEffect(()=>{const m=l.current;m&&f((m.textContent??"").trim())},[o.children]),ut.jsx(OT.ItemSlot,{scope:t,disabled:n,textValue:i??d,children:ut.jsx(Mde,{asChild:!0,...s,focusable:!n,children:ut.jsx(nE.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...o,ref:c,onPointerMove:Jg(r.onPointerMove,YT(m=>{n?a.onItemLeave(m):(a.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Jg(r.onPointerLeave,YT(m=>a.onItemLeave(m))),onFocus:Jg(r.onFocus,()=>A(!0)),onBlur:Jg(r.onBlur,()=>A(!1))})})})}),yYt="MenuCheckboxItem",UGe=pt.forwardRef((r,e)=>{const{checked:t=!1,onCheckedChange:n,...i}=r;return ut.jsx(zGe,{scope:r.__scopeMenu,checked:t,children:ut.jsx(R7,{role:"menuitemcheckbox","aria-checked":N7(t)?"mixed":t,...i,ref:e,"data-state":Xle(t),onSelect:Jg(i.onSelect,()=>n==null?void 0:n(N7(t)?!0:!t),{checkForDefaultPrevented:!1})})})});UGe.displayName=yYt;var FGe="MenuRadioGroup",[vYt,IYt]=W9(FGe,{value:void 0,onValueChange:()=>{}}),LGe=pt.forwardRef((r,e)=>{const{value:t,onValueChange:n,...i}=r,o=WS(n);return ut.jsx(vYt,{scope:r.__scopeMenu,value:t,onValueChange:o,children:ut.jsx(qle,{...i,ref:e})})});LGe.displayName=FGe;var GGe="MenuRadioItem",OGe=pt.forwardRef((r,e)=>{const{value:t,...n}=r,i=IYt(GGe,r.__scopeMenu),o=t===i.value;return ut.jsx(zGe,{scope:r.__scopeMenu,checked:o,children:ut.jsx(R7,{role:"menuitemradio","aria-checked":o,...n,ref:e,"data-state":Xle(o),onSelect:Jg(n.onSelect,()=>{var a;return(a=i.onValueChange)==null?void 0:a.call(i,t)},{checkForDefaultPrevented:!1})})})});OGe.displayName=GGe;var Zle="MenuItemIndicator",[zGe,CYt]=W9(Zle,{checked:!1}),HGe=pt.forwardRef((r,e)=>{const{__scopeMenu:t,forceMount:n,...i}=r,o=CYt(Zle,t);return ut.jsx(mM,{present:n||N7(o.checked)||o.checked===!0,children:ut.jsx(nE.span,{...i,ref:e,"data-state":Xle(o.checked)})})});HGe.displayName=Zle;var EYt="MenuSeparator",YGe=pt.forwardRef((r,e)=>{const{__scopeMenu:t,...n}=r;return ut.jsx(nE.div,{role:"separator","aria-orientation":"horizontal",...n,ref:e})});YGe.displayName=EYt;var _Yt="MenuArrow",VGe=pt.forwardRef((r,e)=>{const{__scopeMenu:t,...n}=r,i=M7(t);return ut.jsx(hHt,{...i,...n,ref:e})});VGe.displayName=_Yt;var xYt="MenuSub",[zrn,KGe]=W9(xYt),HT="MenuSubTrigger",jGe=pt.forwardRef((r,e)=>{const t=q9(HT,r.__scopeMenu),n=zT(HT,r.__scopeMenu),i=KGe(HT,r.__scopeMenu),o=Jle(HT,r.__scopeMenu),a=pt.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:l}=o,c={__scopeMenu:r.__scopeMenu},u=pt.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return pt.useEffect(()=>u,[u]),pt.useEffect(()=>{const A=s.current;return()=>{window.clearTimeout(A),l(null)}},[s,l]),ut.jsx(Kle,{asChild:!0,...c,children:ut.jsx(kGe,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":t.open,"aria-controls":i.contentId,"data-state":qGe(t.open),...r,ref:eP(e,i.onTriggerChange),onClick:A=>{var d;(d=r.onClick)==null||d.call(r,A),!(r.disabled||A.defaultPrevented)&&(A.currentTarget.focus(),t.open||t.onOpenChange(!0))},onPointerMove:Jg(r.onPointerMove,YT(A=>{o.onItemEnter(A),!A.defaultPrevented&&!r.disabled&&!t.open&&!a.current&&(o.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{t.onOpenChange(!0),u()},100))})),onPointerLeave:Jg(r.onPointerLeave,YT(A=>{var f,m;u();const d=(f=t.content)==null?void 0:f.getBoundingClientRect();if(d){const C=(m=t.content)==null?void 0:m.dataset.side,E=C==="right",_=E?-5:5,x=d[E?"left":"right"],w=d[E?"right":"left"];o.onPointerGraceIntentChange({area:[{x:A.clientX+_,y:A.clientY},{x,y:d.top},{x:w,y:d.top},{x:w,y:d.bottom},{x,y:d.bottom}],side:C}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(A),A.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:Jg(r.onKeyDown,A=>{var f;const d=o.searchRef.current!=="";r.disabled||d&&A.key===" "||iYt[n.dir].includes(A.key)&&(t.onOpenChange(!0),(f=t.content)==null||f.focus(),A.preventDefault())})})})});jGe.displayName=HT;var JGe="MenuSubContent",WGe=pt.forwardRef((r,e)=>{const t=DGe(db,r.__scopeMenu),{forceMount:n=t.forceMount,...i}=r,o=q9(db,r.__scopeMenu),a=zT(db,r.__scopeMenu),s=KGe(JGe,r.__scopeMenu),l=pt.useRef(null),c=jx(e,l);return ut.jsx(OT.Provider,{scope:r.__scopeMenu,children:ut.jsx(mM,{present:n||o.open,children:ut.jsx(OT.Slot,{scope:r.__scopeMenu,children:ut.jsx(Wle,{id:s.contentId,"aria-labelledby":s.triggerId,...i,ref:c,align:"start",side:a.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var A;a.isUsingKeyboardRef.current&&((A=l.current)==null||A.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:Jg(r.onFocusOutside,u=>{u.target!==s.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Jg(r.onEscapeKeyDown,u=>{a.onClose(),u.preventDefault()}),onKeyDown:Jg(r.onKeyDown,u=>{var f;const A=u.currentTarget.contains(u.target),d=oYt[a.dir].includes(u.key);A&&d&&(o.onOpenChange(!1),(f=s.trigger)==null||f.focus(),u.preventDefault())})})})})})});WGe.displayName=JGe;function qGe(r){return r?"open":"closed"}function N7(r){return r==="indeterminate"}function Xle(r){return N7(r)?"indeterminate":r?"checked":"unchecked"}function BYt(r){const e=document.activeElement;for(const t of r)if(t===e||(t.focus(),document.activeElement!==e))return}function bYt(r,e){return r.map((t,n)=>r[(e+n)%r.length])}function SYt(r,e,t){const i=e.length>1&&Array.from(e).every(c=>c===e[0])?e[0]:e,o=t?r.indexOf(t):-1;let a=bYt(r,Math.max(o,0));i.length===1&&(a=a.filter(c=>c!==t));const l=a.find(c=>c.toLowerCase().startsWith(i.toLowerCase()));return l!==t?l:void 0}function wYt(r,e){const{x:t,y:n}=r;let i=!1;for(let o=0,a=e.length-1;o<e.length;a=o++){const s=e[o],l=e[a],c=s.x,u=s.y,A=l.x,d=l.y;u>n!=d>n&&t<(A-c)*(n-u)/(d-u)+c&&(i=!i)}return i}function QYt(r,e){if(!e)return!1;const t={x:r.clientX,y:r.clientY};return wYt(t,e)}function YT(r){return e=>e.pointerType==="mouse"?r(e):void 0}var MYt=MGe,DYt=Kle,RYt=RGe,NYt=NGe,TYt=qle,PYt=TGe,kYt=R7,UYt=UGe,FYt=LGe,LYt=OGe,GYt=HGe,OYt=YGe,zYt=VGe,HYt=jGe,YYt=WGe,T7="DropdownMenu",[VYt,Hrn]=gM(T7,[wGe]),Mx=wGe(),[KYt,ZGe]=VYt(T7),XGe=r=>{const{__scopeDropdownMenu:e,children:t,dir:n,open:i,defaultOpen:o,onOpenChange:a,modal:s=!0}=r,l=Mx(e),c=pt.useRef(null),[u,A]=dz({prop:i,defaultProp:o??!1,onChange:a,caller:T7});return ut.jsx(KYt,{scope:e,triggerId:tP(),triggerRef:c,contentId:tP(),open:u,onOpenChange:A,onOpenToggle:pt.useCallback(()=>A(d=>!d),[A]),modal:s,children:ut.jsx(MYt,{...l,open:u,onOpenChange:A,dir:n,modal:s,children:t})})};XGe.displayName=T7;var $Ge="DropdownMenuTrigger",e6e=pt.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,disabled:n=!1,...i}=r,o=ZGe($Ge,t),a=Mx(t);return ut.jsx(DYt,{asChild:!0,...a,children:ut.jsx(nE.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":n?"":void 0,disabled:n,...i,ref:eP(e,o.triggerRef),onPointerDown:Jg(r.onPointerDown,s=>{!n&&s.button===0&&s.ctrlKey===!1&&(o.onOpenToggle(),o.open||s.preventDefault())}),onKeyDown:Jg(r.onKeyDown,s=>{n||(["Enter"," "].includes(s.key)&&o.onOpenToggle(),s.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(s.key)&&s.preventDefault())})})})});e6e.displayName=$Ge;var jYt="DropdownMenuPortal",t6e=r=>{const{__scopeDropdownMenu:e,...t}=r,n=Mx(e);return ut.jsx(RYt,{...n,...t})};t6e.displayName=jYt;var n6e="DropdownMenuContent",r6e=pt.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=ZGe(n6e,t),o=Mx(t),a=pt.useRef(!1);return ut.jsx(NYt,{id:i.contentId,"aria-labelledby":i.triggerId,...o,...n,ref:e,onCloseAutoFocus:Jg(r.onCloseAutoFocus,s=>{var l;a.current||(l=i.triggerRef.current)==null||l.focus(),a.current=!1,s.preventDefault()}),onInteractOutside:Jg(r.onInteractOutside,s=>{const l=s.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;(!i.modal||u)&&(a.current=!0)}),style:{...r.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});r6e.displayName=n6e;var JYt="DropdownMenuGroup",WYt=pt.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Mx(t);return ut.jsx(TYt,{...i,...n,ref:e})});WYt.displayName=JYt;var qYt="DropdownMenuLabel",i6e=pt.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Mx(t);return ut.jsx(PYt,{...i,...n,ref:e})});i6e.displayName=qYt;var ZYt="DropdownMenuItem",o6e=pt.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Mx(t);return ut.jsx(kYt,{...i,...n,ref:e})});o6e.displayName=ZYt;var XYt="DropdownMenuCheckboxItem",a6e=pt.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Mx(t);return ut.jsx(UYt,{...i,...n,ref:e})});a6e.displayName=XYt;var $Yt="DropdownMenuRadioGroup",eVt=pt.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Mx(t);return ut.jsx(FYt,{...i,...n,ref:e})});eVt.displayName=$Yt;var tVt="DropdownMenuRadioItem",s6e=pt.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Mx(t);return ut.jsx(LYt,{...i,...n,ref:e})});s6e.displayName=tVt;var nVt="DropdownMenuItemIndicator",l6e=pt.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Mx(t);return ut.jsx(GYt,{...i,...n,ref:e})});l6e.displayName=nVt;var rVt="DropdownMenuSeparator",c6e=pt.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Mx(t);return ut.jsx(OYt,{...i,...n,ref:e})});c6e.displayName=rVt;var iVt="DropdownMenuArrow",oVt=pt.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Mx(t);return ut.jsx(zYt,{...i,...n,ref:e})});oVt.displayName=iVt;var aVt="DropdownMenuSubTrigger",u6e=pt.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Mx(t);return ut.jsx(HYt,{...i,...n,ref:e})});u6e.displayName=aVt;var sVt="DropdownMenuSubContent",A6e=pt.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Mx(t);return ut.jsx(YYt,{...i,...n,ref:e,style:{...r.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});A6e.displayName=sVt;var lVt=XGe,cVt=e6e,uVt=t6e,d6e=r6e,f6e=i6e,h6e=o6e,p6e=a6e,g6e=s6e,m6e=l6e,y6e=c6e,v6e=u6e,I6e=A6e;const C6e=lVt,E6e=cVt,AVt=pt.forwardRef(({className:r,inset:e,children:t,...n},i)=>ut.jsxs(v6e,{ref:i,className:nI("rf-flex rf-cursor-default rf-gap-2 rf-select-none rf-items-center rf-rounded-sm rf-px-2 rf-py-1.5 rf-text-sm rf-outline-none focus:rf-bg-zinc-100 data-[state=open]:rf-bg-zinc-100 [&_svg]:rf-pointer-events-none [&_svg]:rf-size-4 [&_svg]:rf-shrink-0 dark:focus:rf-bg-zinc-800 dark:data-[state=open]:rf-bg-zinc-800",e&&"rf-pl-8",r),...n,children:[t,ut.jsx(Cle,{className:"rf-ml-auto"})]}));AVt.displayName=v6e.displayName;const dVt=pt.forwardRef(({className:r,...e},t)=>ut.jsx(I6e,{ref:t,className:nI("rf-z-50 rf-min-w-[8rem] rf-overflow-hidden rf-rounded-md rf-border rf-border-zinc-200 rf-bg-white rf-p-1 rf-text-zinc-950 rf-shadow-lg 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-[side=bottom]:rf-slide-in-from-top-2 data-[side=left]:rf-slide-in-from-right-2 data-[side=right]:rf-slide-in-from-left-2 data-[side=top]:rf-slide-in-from-bottom-2 dark:rf-border-zinc-800 dark:rf-bg-zinc-950 dark:rf-text-zinc-50",r),...e}));dVt.displayName=I6e.displayName;const $le=pt.forwardRef(({className:r,sideOffset:e=4,...t},n)=>ut.jsx(uVt,{children:ut.jsx(d6e,{ref:n,sideOffset:e,className:nI("rf-z-50 rf-min-w-[8rem] rf-overflow-hidden rf-rounded-md rf-border rf-border-zinc-200 rf-bg-white rf-p-1 rf-text-zinc-950 rf-shadow-md dark:rf-border-zinc-800 dark:rf-bg-zinc-950 dark:rf-text-zinc-50","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-[side=bottom]:rf-slide-in-from-top-2 data-[side=left]:rf-slide-in-from-right-2 data-[side=right]:rf-slide-in-from-left-2 data-[side=top]:rf-slide-in-from-bottom-2",r),...t})}));$le.displayName=d6e.displayName;const VT=pt.forwardRef(({className:r,inset:e,...t},n)=>ut.jsx(h6e,{ref:n,className:nI("rf-relative rf-flex rf-cursor-default rf-select-none rf-items-center rf-gap-2 rf-rounded-sm rf-px-2 rf-py-1.5 rf-text-sm rf-outline-none rf-transition-colors focus:rf-bg-zinc-100 focus:rf-text-zinc-900 data-[disabled]:rf-pointer-events-none data-[disabled]:rf-opacity-50 [&>svg]:rf-size-4 [&>svg]:rf-shrink-0 dark:focus:rf-bg-zinc-800 dark:focus:rf-text-zinc-50",e&&"rf-pl-8",r),...t}));VT.displayName=h6e.displayName;const fVt=pt.forwardRef(({className:r,children:e,checked:t,...n},i)=>ut.jsxs(p6e,{ref:i,className:nI("rf-relative rf-flex rf-cursor-default rf-select-none rf-items-center rf-rounded-sm rf-py-1.5 rf-pl-8 rf-pr-2 rf-text-sm rf-outline-none rf-transition-colors focus:rf-bg-zinc-100 focus:rf-text-zinc-900 data-[disabled]:rf-pointer-events-none data-[disabled]:rf-opacity-50 dark:focus:rf-bg-zinc-800 dark:focus:rf-text-zinc-50",r),checked:t,...n,children:[ut.jsx("span",{className:"rf-absolute rf-left-2 rf-flex rf-h-3.5 rf-w-3.5 rf-items-center rf-justify-center",children:ut.jsx(m6e,{children:ut.jsx(gLe,{className:"rf-h-4 rf-w-4"})})}),e]}));fVt.displayName=p6e.displayName;const hVt=pt.forwardRef(({className:r,children:e,...t},n)=>ut.jsxs(g6e,{ref:n,className:nI("rf-relative rf-flex rf-cursor-default rf-select-none rf-items-center rf-rounded-sm rf-py-1.5 rf-pl-8 rf-pr-2 rf-text-sm rf-outline-none rf-transition-colors focus:rf-bg-zinc-100 focus:rf-text-zinc-900 data-[disabled]:rf-pointer-events-none data-[disabled]:rf-opacity-50 dark:focus:rf-bg-zinc-800 dark:focus:rf-text-zinc-50",r),...t,children:[ut.jsx("span",{className:"rf-absolute rf-left-2 rf-flex rf-h-3.5 rf-w-3.5 rf-items-center rf-justify-center",children:ut.jsx(m6e,{children:ut.jsx(yLe,{className:"rf-h-2 rf-w-2 rf-fill-current"})})}),e]}));hVt.displayName=g6e.displayName;const pVt=pt.forwardRef(({className:r,inset:e,...t},n)=>ut.jsx(f6e,{ref:n,className:nI("rf-px-2 rf-py-1.5 rf-text-sm rf-font-semibold",e&&"rf-pl-8",r),...t}));pVt.displayName=f6e.displayName;const gVt=pt.forwardRef(({className:r,...e},t)=>ut.jsx(y6e,{ref:t,className:nI("rf--mx-1 rf-my-1 rf-h-px rf-bg-zinc-100 dark:rf-bg-zinc-800",r),...e}));gVt.displayName=y6e.displayName;const _6e=({autoroutingLog:r,onReportAutoroutingLog:e})=>ut.jsx(ut.Fragment,{children:Object.keys(r??{}).length>0&&ut.jsxs(C6e,{children:[ut.jsx(E6e,{asChild:!0,children:ut.jsxs(ZQ,{variant:"outline",children:[ut.jsx(gOt,{className:"rf-w-4 rf-h-4 rf-mr-2"}),"Open Autorouting Log"]})}),ut.jsx($le,{className:"rf-w-96",children:Object.entries(r??{}).map(([t,{simpleRouteJson:n}])=>ut.jsxs(VT,{className:"rf-flex rf-justify-between rf-items-center",children:[ut.jsx("span",{className:"rf-truncate rf-text-xs rf-mr-2",children:t}),ut.jsxs("div",{className:"rf-flex rf-gap-2",children:[ut.jsxs(ZQ,{variant:"outline",size:"sm",onClick:i=>{i.stopPropagation();const o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),a=URL.createObjectURL(o),s=document.createElement("a");s.href=a,s.download=`${t}-autorouting.json`,s.click(),URL.revokeObjectURL(a)},children:[ut.jsx(yOt,{className:"rf-w-3 rf-h-3"}),"Download"]}),e&&ut.jsxs(ZQ,{variant:"outline",size:"sm",onClick:i=>{i.stopPropagation(),e&&e(t,{simpleRouteJson:n})},children:[ut.jsx(xOt,{className:"rf-w-3 rf-h-3"}),"Report Bug"]})]})]},t))})]})}),mVt=({code:r,autoroutingLog:e,circuitJsonErrors:t,circuitJsonWarnings:n,fsMap:i,onReportAutoroutingLog:o,errorMessage:a,errorStack:s,circuitJson:l,evalVersion:c})=>{const u=pt.useMemo(()=>{const H=[];if(a&&H.push({type:"Execution Error",message:a,stack:s||void 0,source:"execution"}),t&&t.length>0)for(const K of t)H.push({type:K.type||"Circuit JSON Error",message:K.message||"No error message available",stack:K.stack||"",source:"circuitJson"});return H},[a,s,t]),A=pt.useMemo(()=>{if(!l||!Array.isArray(l))return;const H=l.find(K=>K.type==="source_project_metadata");return H==null?void 0:H.software_used_string},[l]),d=pt.useMemo(()=>{const H=[];if(n&&n.length>0)for(const K of n)H.push({type:K.type||"Circuit JSON Warning",message:K.message||"No warning message available",stack:K.stack||"",source:"circuitJson"});return H},[n]),[f,m]=pt.useState(0),[C,E]=pt.useState(0);if(u.length===0&&d.length===0)return ut.jsxs("div",{className:"px-2",children:[ut.jsx("div",{className:"rf-mt-4 rf-bg-green-50 rf-rounded-md rf-border rf-border-green-200",children:ut.jsxs("div",{className:"rf-p-4",children:[ut.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-green-800 rf-mb-3",children:"No errors or warnings!"}),ut.jsx("p",{className:"rf-text-sm rf-text-green-700",children:"Your code is running without any errors or warnings."})]})}),ut.jsx("div",{className:"rf-mt-4",children:ut.jsx(_6e,{autoroutingLog:e,onReportAutoroutingLog:o})})]});const _=()=>{m(H=>Math.max(H-1,0))},x=()=>{m(H=>Math.min(H+1,u.length-1))},w=()=>{E(H=>Math.max(H-1,0))},P=()=>{E(H=>Math.min(H+1,d.length-1))},L=u[f],O=d[C];return ut.jsxs(ut.Fragment,{children:[ut.jsxs("div",{className:"rf-w-[95%] rf-mx-auto",children:[u.length>1&&ut.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mb-2",children:[ut.jsx("button",{type:"button",className:"rf-p-1 rf-rounded-sm rf-transition-colors",onClick:_,disabled:f===0,children:ut.jsx(mLe,{className:"rf-h-4 rf-w-4 rf-text-red-500"})}),ut.jsx("button",{type:"button",className:"rf-p-1 rf-rounded-sm rf-transition-colors",onClick:x,disabled:f===u.length-1,children:ut.jsx(Cle,{className:"rf-h-4 rf-w-4 rf-text-red-500"})}),ut.jsxs("span",{className:"rf-text-sm rf-text-red-600",children:[f+1," of ",u.length," errors"]})]}),L&&ut.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-max-h-[500px] rf-overflow-y-auto rf-px-2",children:ut.jsxs("div",{className:"rf-p-4",children:[ut.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-1",children:L.type}),ut.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600",children:L.message}),(L.stack||c||A)&&ut.jsxs("details",{style:{whiteSpace:"pre-wrap"},className:"rf-text-xs rf-font-mono rf-text-red-600 rf-mt-2",children:[c&&`@tscircuit/eval@${c}
|
|
13214
|
+
`)},XHt=0,DR=[];function $Ht(r){var e=pt.useRef([]),t=pt.useRef([0,0]),n=pt.useRef(),i=pt.useState(XHt++)[0],o=pt.useState(yGe)[0],a=pt.useRef(r);pt.useEffect(function(){a.current=r},[r]),pt.useEffect(function(){if(r.inert){document.body.classList.add("block-interactivity-".concat(i));var C=IHt([r.lockRef.current],(r.shards||[]).map(BGe),!0).filter(Boolean);return C.forEach(function(E){return E.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),C.forEach(function(E){return E.classList.remove("allow-interactivity-".concat(i))})}}},[r.inert,r.lockRef.current,r.shards]);var s=pt.useCallback(function(C,E){if("touches"in C&&C.touches.length===2||C.type==="wheel"&&C.ctrlKey)return!a.current.allowPinchZoom;var _=Q7(C),x=t.current,w="deltaX"in C?C.deltaX:x[0]-_[0],P="deltaY"in C?C.deltaY:x[1]-_[1],L,O=C.target,H=Math.abs(w)>Math.abs(P)?"h":"v";if("touches"in C&&H==="h"&&O.type==="range")return!1;var K=CGe(H,O);if(!K)return!0;if(K?L=H:(L=H==="v"?"h":"v",K=CGe(H,O)),!K)return!1;if(!n.current&&"changedTouches"in C&&(w||P)&&(n.current=L),!L)return!0;var q=n.current||L;return WHt(q,E,C,q==="h"?w:P)},[]),l=pt.useCallback(function(C){var E=C;if(!(!DR.length||DR[DR.length-1]!==o)){var _="deltaY"in E?xGe(E):Q7(E),x=e.current.filter(function(L){return L.name===E.type&&(L.target===E.target||E.target===L.shadowParent)&&qHt(L.delta,_)})[0];if(x&&x.should){E.cancelable&&E.preventDefault();return}if(!x){var w=(a.current.shards||[]).map(BGe).filter(Boolean).filter(function(L){return L.contains(E.target)}),P=w.length>0?s(E,w[0]):!a.current.noIsolation;P&&E.cancelable&&E.preventDefault()}}},[]),c=pt.useCallback(function(C,E,_,x){var w={name:C,delta:E,target:_,should:x,shadowParent:eYt(_)};e.current.push(w),setTimeout(function(){e.current=e.current.filter(function(P){return P!==w})},1)},[]),u=pt.useCallback(function(C){t.current=Q7(C),n.current=void 0},[]),A=pt.useCallback(function(C){c(C.type,xGe(C),C.target,s(C,r.lockRef.current))},[]),d=pt.useCallback(function(C){c(C.type,Q7(C),C.target,s(C,r.lockRef.current))},[]);pt.useEffect(function(){return DR.push(o),r.setCallbacks({onScrollCapture:A,onWheelCapture:A,onTouchMoveCapture:d}),document.addEventListener("wheel",l,MR),document.addEventListener("touchmove",l,MR),document.addEventListener("touchstart",u,MR),function(){DR=DR.filter(function(C){return C!==o}),document.removeEventListener("wheel",l,MR),document.removeEventListener("touchmove",l,MR),document.removeEventListener("touchstart",u,MR)}},[]);var f=r.removeScrollBar,m=r.inert;return pt.createElement(pt.Fragment,null,m?pt.createElement(o,{styles:ZHt(i)}):null,f?pt.createElement(zHt,{noRelative:r.noRelative,gapMode:r.gapMode}):null)}function eYt(r){for(var e=null;r!==null;)r instanceof ShadowRoot&&(e=r.host,r=r.host),r=r.parentNode;return e}const tYt=QHt(mGe,$Ht);var bGe=pt.forwardRef(function(r,e){return pt.createElement(S7,GS({},r,{ref:e,sideCar:tYt}))});bGe.classNames=S7.classNames;var Vle=["Enter"," "],nYt=["ArrowDown","PageUp","Home"],SGe=["ArrowUp","PageDown","End"],rYt=[...nYt,...SGe],iYt={ltr:[...Vle,"ArrowRight"],rtl:[...Vle,"ArrowLeft"]},oYt={ltr:["ArrowLeft"],rtl:["ArrowRight"]},GT="Menu",[OT,aYt,sYt]=Ede(GT),[W9,wGe]=gM(GT,[sYt,rGe,nP]),M7=rGe(),QGe=nP(),[lYt,q9]=W9(GT),[cYt,zT]=W9(GT),MGe=r=>{const{__scopeMenu:e,open:t=!1,children:n,dir:i,onOpenChange:o,modal:a=!0}=r,s=M7(e),[l,c]=pt.useState(null),u=pt.useRef(!1),A=WS(o),d=fz(i);return pt.useEffect(()=>{const f=()=>{u.current=!0,document.addEventListener("pointerdown",m,{capture:!0,once:!0}),document.addEventListener("pointermove",m,{capture:!0,once:!0})},m=()=>u.current=!1;return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",m,{capture:!0}),document.removeEventListener("pointermove",m,{capture:!0})}},[]),ut.jsx(AHt,{...s,children:ut.jsx(lYt,{scope:e,open:t,onOpenChange:A,content:l,onContentChange:c,children:ut.jsx(cYt,{scope:e,onClose:pt.useCallback(()=>A(!1),[A]),isUsingKeyboardRef:u,dir:d,modal:a,children:n})})})};MGe.displayName=GT;var uYt="MenuAnchor",Kle=pt.forwardRef((r,e)=>{const{__scopeMenu:t,...n}=r,i=M7(t);return ut.jsx(dHt,{...i,...n,ref:e})});Kle.displayName=uYt;var jle="MenuPortal",[AYt,DGe]=W9(jle,{forceMount:void 0}),RGe=r=>{const{__scopeMenu:e,forceMount:t,children:n,container:i}=r,o=q9(jle,e);return ut.jsx(AYt,{scope:e,forceMount:t,children:ut.jsx(mM,{present:t||o.open,children:ut.jsx(dGe,{asChild:!0,container:i,children:n})})})};RGe.displayName=jle;var db="MenuContent",[dYt,Jle]=W9(db),NGe=pt.forwardRef((r,e)=>{const t=DGe(db,r.__scopeMenu),{forceMount:n=t.forceMount,...i}=r,o=q9(db,r.__scopeMenu),a=zT(db,r.__scopeMenu);return ut.jsx(OT.Provider,{scope:r.__scopeMenu,children:ut.jsx(mM,{present:n||o.open,children:ut.jsx(OT.Slot,{scope:r.__scopeMenu,children:a.modal?ut.jsx(fYt,{...i,ref:e}):ut.jsx(hYt,{...i,ref:e})})})})}),fYt=pt.forwardRef((r,e)=>{const t=q9(db,r.__scopeMenu),n=pt.useRef(null),i=jx(e,n);return pt.useEffect(()=>{const o=n.current;if(o)return vHt(o)},[]),ut.jsx(Wle,{...r,ref:i,trapFocus:t.open,disableOutsidePointerEvents:t.open,disableOutsideScroll:!0,onFocusOutside:Jg(r.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>t.onOpenChange(!1)})}),hYt=pt.forwardRef((r,e)=>{const t=q9(db,r.__scopeMenu);return ut.jsx(Wle,{...r,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>t.onOpenChange(!1)})}),pYt=h3("MenuContent.ScrollLock"),Wle=pt.forwardRef((r,e)=>{const{__scopeMenu:t,loop:n=!1,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:a,disableOutsidePointerEvents:s,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:A,onInteractOutside:d,onDismiss:f,disableOutsideScroll:m,...C}=r,E=q9(db,t),_=zT(db,t),x=M7(t),w=QGe(t),P=aYt(t),[L,O]=pt.useState(null),H=pt.useRef(null),K=jx(e,H,E.onContentChange),q=pt.useRef(0),Y=pt.useRef(""),se=pt.useRef(0),ie=pt.useRef(null),de=pt.useRef("right"),Ce=pt.useRef(0),xe=m?bGe:pt.Fragment,fe=m?{as:pYt,allowPinchZoom:!0}:void 0,Ie=Qe=>{var Ft,Lt;const De=Y.current+Qe,Fe=P().filter(tt=>!tt.disabled),Ne=document.activeElement,rt=(Ft=Fe.find(tt=>tt.ref.current===Ne))==null?void 0:Ft.textValue,et=Fe.map(tt=>tt.textValue),ft=SYt(et,De,rt),_t=(Lt=Fe.find(tt=>tt.textValue===ft))==null?void 0:Lt.ref.current;(function tt(xt){Y.current=xt,window.clearTimeout(q.current),xt!==""&&(q.current=window.setTimeout(()=>tt(""),1e3))})(De),_t&&setTimeout(()=>_t.focus())};pt.useEffect(()=>()=>window.clearTimeout(q.current),[]),FOt();const ve=pt.useCallback(Qe=>{var Fe,Ne;return de.current===((Fe=ie.current)==null?void 0:Fe.side)&&QYt(Qe,(Ne=ie.current)==null?void 0:Ne.area)},[]);return ut.jsx(dYt,{scope:t,searchRef:Y,onItemEnter:pt.useCallback(Qe=>{ve(Qe)&&Qe.preventDefault()},[ve]),onItemLeave:pt.useCallback(Qe=>{var De;ve(Qe)||((De=H.current)==null||De.focus(),O(null))},[ve]),onTriggerLeave:pt.useCallback(Qe=>{ve(Qe)&&Qe.preventDefault()},[ve]),pointerGraceTimerRef:se,onPointerGraceIntentChange:pt.useCallback(Qe=>{ie.current=Qe},[]),children:ut.jsx(xe,{...fe,children:ut.jsx(QLe,{asChild:!0,trapped:i,onMountAutoFocus:Jg(o,Qe=>{var De;Qe.preventDefault(),(De=H.current)==null||De.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:ut.jsx(xLe,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:A,onInteractOutside:d,onDismiss:f,children:ut.jsx(Qde,{asChild:!0,...w,dir:_.dir,orientation:"vertical",loop:n,currentTabStopId:L,onCurrentTabStopIdChange:O,onEntryFocus:Jg(l,Qe=>{_.isUsingKeyboardRef.current||Qe.preventDefault()}),preventScrollOnEntryFocus:!0,children:ut.jsx(fHt,{role:"menu","aria-orientation":"vertical","data-state":qGe(E.open),"data-radix-menu-content":"",dir:_.dir,...x,...C,ref:K,style:{outline:"none",...C.style},onKeyDown:Jg(C.onKeyDown,Qe=>{const Fe=Qe.target.closest("[data-radix-menu-content]")===Qe.currentTarget,Ne=Qe.ctrlKey||Qe.altKey||Qe.metaKey,rt=Qe.key.length===1;Fe&&(Qe.key==="Tab"&&Qe.preventDefault(),!Ne&&rt&&Ie(Qe.key));const et=H.current;if(Qe.target!==et||!rYt.includes(Qe.key))return;Qe.preventDefault();const _t=P().filter(Ft=>!Ft.disabled).map(Ft=>Ft.ref.current);SGe.includes(Qe.key)&&_t.reverse(),BYt(_t)}),onBlur:Jg(r.onBlur,Qe=>{Qe.currentTarget.contains(Qe.target)||(window.clearTimeout(q.current),Y.current="")}),onPointerMove:Jg(r.onPointerMove,YT(Qe=>{const De=Qe.target,Fe=Ce.current!==Qe.clientX;if(Qe.currentTarget.contains(De)&&Fe){const Ne=Qe.clientX>Ce.current?"right":"left";de.current=Ne,Ce.current=Qe.clientX}}))})})})})})})});NGe.displayName=db;var gYt="MenuGroup",qle=pt.forwardRef((r,e)=>{const{__scopeMenu:t,...n}=r;return ut.jsx(nE.div,{role:"group",...n,ref:e})});qle.displayName=gYt;var mYt="MenuLabel",TGe=pt.forwardRef((r,e)=>{const{__scopeMenu:t,...n}=r;return ut.jsx(nE.div,{...n,ref:e})});TGe.displayName=mYt;var D7="MenuItem",PGe="menu.itemSelect",R7=pt.forwardRef((r,e)=>{const{disabled:t=!1,onSelect:n,...i}=r,o=pt.useRef(null),a=zT(D7,r.__scopeMenu),s=Jle(D7,r.__scopeMenu),l=jx(e,o),c=pt.useRef(!1),u=()=>{const A=o.current;if(!t&&A){const d=new CustomEvent(PGe,{bubbles:!0,cancelable:!0});A.addEventListener(PGe,f=>n==null?void 0:n(f),{once:!0}),_de(A,d),d.defaultPrevented?c.current=!1:a.onClose()}};return ut.jsx(kGe,{...i,ref:l,disabled:t,onClick:Jg(r.onClick,u),onPointerDown:A=>{var d;(d=r.onPointerDown)==null||d.call(r,A),c.current=!0},onPointerUp:Jg(r.onPointerUp,A=>{var d;c.current||(d=A.currentTarget)==null||d.click()}),onKeyDown:Jg(r.onKeyDown,A=>{const d=s.searchRef.current!=="";t||d&&A.key===" "||Vle.includes(A.key)&&(A.currentTarget.click(),A.preventDefault())})})});R7.displayName=D7;var kGe=pt.forwardRef((r,e)=>{const{__scopeMenu:t,disabled:n=!1,textValue:i,...o}=r,a=Jle(D7,t),s=QGe(t),l=pt.useRef(null),c=jx(e,l),[u,A]=pt.useState(!1),[d,f]=pt.useState("");return pt.useEffect(()=>{const m=l.current;m&&f((m.textContent??"").trim())},[o.children]),ut.jsx(OT.ItemSlot,{scope:t,disabled:n,textValue:i??d,children:ut.jsx(Mde,{asChild:!0,...s,focusable:!n,children:ut.jsx(nE.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...o,ref:c,onPointerMove:Jg(r.onPointerMove,YT(m=>{n?a.onItemLeave(m):(a.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Jg(r.onPointerLeave,YT(m=>a.onItemLeave(m))),onFocus:Jg(r.onFocus,()=>A(!0)),onBlur:Jg(r.onBlur,()=>A(!1))})})})}),yYt="MenuCheckboxItem",UGe=pt.forwardRef((r,e)=>{const{checked:t=!1,onCheckedChange:n,...i}=r;return ut.jsx(zGe,{scope:r.__scopeMenu,checked:t,children:ut.jsx(R7,{role:"menuitemcheckbox","aria-checked":N7(t)?"mixed":t,...i,ref:e,"data-state":Xle(t),onSelect:Jg(i.onSelect,()=>n==null?void 0:n(N7(t)?!0:!t),{checkForDefaultPrevented:!1})})})});UGe.displayName=yYt;var FGe="MenuRadioGroup",[vYt,IYt]=W9(FGe,{value:void 0,onValueChange:()=>{}}),LGe=pt.forwardRef((r,e)=>{const{value:t,onValueChange:n,...i}=r,o=WS(n);return ut.jsx(vYt,{scope:r.__scopeMenu,value:t,onValueChange:o,children:ut.jsx(qle,{...i,ref:e})})});LGe.displayName=FGe;var GGe="MenuRadioItem",OGe=pt.forwardRef((r,e)=>{const{value:t,...n}=r,i=IYt(GGe,r.__scopeMenu),o=t===i.value;return ut.jsx(zGe,{scope:r.__scopeMenu,checked:o,children:ut.jsx(R7,{role:"menuitemradio","aria-checked":o,...n,ref:e,"data-state":Xle(o),onSelect:Jg(n.onSelect,()=>{var a;return(a=i.onValueChange)==null?void 0:a.call(i,t)},{checkForDefaultPrevented:!1})})})});OGe.displayName=GGe;var Zle="MenuItemIndicator",[zGe,CYt]=W9(Zle,{checked:!1}),HGe=pt.forwardRef((r,e)=>{const{__scopeMenu:t,forceMount:n,...i}=r,o=CYt(Zle,t);return ut.jsx(mM,{present:n||N7(o.checked)||o.checked===!0,children:ut.jsx(nE.span,{...i,ref:e,"data-state":Xle(o.checked)})})});HGe.displayName=Zle;var EYt="MenuSeparator",YGe=pt.forwardRef((r,e)=>{const{__scopeMenu:t,...n}=r;return ut.jsx(nE.div,{role:"separator","aria-orientation":"horizontal",...n,ref:e})});YGe.displayName=EYt;var _Yt="MenuArrow",VGe=pt.forwardRef((r,e)=>{const{__scopeMenu:t,...n}=r,i=M7(t);return ut.jsx(hHt,{...i,...n,ref:e})});VGe.displayName=_Yt;var xYt="MenuSub",[zrn,KGe]=W9(xYt),HT="MenuSubTrigger",jGe=pt.forwardRef((r,e)=>{const t=q9(HT,r.__scopeMenu),n=zT(HT,r.__scopeMenu),i=KGe(HT,r.__scopeMenu),o=Jle(HT,r.__scopeMenu),a=pt.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:l}=o,c={__scopeMenu:r.__scopeMenu},u=pt.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return pt.useEffect(()=>u,[u]),pt.useEffect(()=>{const A=s.current;return()=>{window.clearTimeout(A),l(null)}},[s,l]),ut.jsx(Kle,{asChild:!0,...c,children:ut.jsx(kGe,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":t.open,"aria-controls":i.contentId,"data-state":qGe(t.open),...r,ref:eP(e,i.onTriggerChange),onClick:A=>{var d;(d=r.onClick)==null||d.call(r,A),!(r.disabled||A.defaultPrevented)&&(A.currentTarget.focus(),t.open||t.onOpenChange(!0))},onPointerMove:Jg(r.onPointerMove,YT(A=>{o.onItemEnter(A),!A.defaultPrevented&&!r.disabled&&!t.open&&!a.current&&(o.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{t.onOpenChange(!0),u()},100))})),onPointerLeave:Jg(r.onPointerLeave,YT(A=>{var f,m;u();const d=(f=t.content)==null?void 0:f.getBoundingClientRect();if(d){const C=(m=t.content)==null?void 0:m.dataset.side,E=C==="right",_=E?-5:5,x=d[E?"left":"right"],w=d[E?"right":"left"];o.onPointerGraceIntentChange({area:[{x:A.clientX+_,y:A.clientY},{x,y:d.top},{x:w,y:d.top},{x:w,y:d.bottom},{x,y:d.bottom}],side:C}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(A),A.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:Jg(r.onKeyDown,A=>{var f;const d=o.searchRef.current!=="";r.disabled||d&&A.key===" "||iYt[n.dir].includes(A.key)&&(t.onOpenChange(!0),(f=t.content)==null||f.focus(),A.preventDefault())})})})});jGe.displayName=HT;var JGe="MenuSubContent",WGe=pt.forwardRef((r,e)=>{const t=DGe(db,r.__scopeMenu),{forceMount:n=t.forceMount,...i}=r,o=q9(db,r.__scopeMenu),a=zT(db,r.__scopeMenu),s=KGe(JGe,r.__scopeMenu),l=pt.useRef(null),c=jx(e,l);return ut.jsx(OT.Provider,{scope:r.__scopeMenu,children:ut.jsx(mM,{present:n||o.open,children:ut.jsx(OT.Slot,{scope:r.__scopeMenu,children:ut.jsx(Wle,{id:s.contentId,"aria-labelledby":s.triggerId,...i,ref:c,align:"start",side:a.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var A;a.isUsingKeyboardRef.current&&((A=l.current)==null||A.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:Jg(r.onFocusOutside,u=>{u.target!==s.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Jg(r.onEscapeKeyDown,u=>{a.onClose(),u.preventDefault()}),onKeyDown:Jg(r.onKeyDown,u=>{var f;const A=u.currentTarget.contains(u.target),d=oYt[a.dir].includes(u.key);A&&d&&(o.onOpenChange(!1),(f=s.trigger)==null||f.focus(),u.preventDefault())})})})})})});WGe.displayName=JGe;function qGe(r){return r?"open":"closed"}function N7(r){return r==="indeterminate"}function Xle(r){return N7(r)?"indeterminate":r?"checked":"unchecked"}function BYt(r){const e=document.activeElement;for(const t of r)if(t===e||(t.focus(),document.activeElement!==e))return}function bYt(r,e){return r.map((t,n)=>r[(e+n)%r.length])}function SYt(r,e,t){const i=e.length>1&&Array.from(e).every(c=>c===e[0])?e[0]:e,o=t?r.indexOf(t):-1;let a=bYt(r,Math.max(o,0));i.length===1&&(a=a.filter(c=>c!==t));const l=a.find(c=>c.toLowerCase().startsWith(i.toLowerCase()));return l!==t?l:void 0}function wYt(r,e){const{x:t,y:n}=r;let i=!1;for(let o=0,a=e.length-1;o<e.length;a=o++){const s=e[o],l=e[a],c=s.x,u=s.y,A=l.x,d=l.y;u>n!=d>n&&t<(A-c)*(n-u)/(d-u)+c&&(i=!i)}return i}function QYt(r,e){if(!e)return!1;const t={x:r.clientX,y:r.clientY};return wYt(t,e)}function YT(r){return e=>e.pointerType==="mouse"?r(e):void 0}var MYt=MGe,DYt=Kle,RYt=RGe,NYt=NGe,TYt=qle,PYt=TGe,kYt=R7,UYt=UGe,FYt=LGe,LYt=OGe,GYt=HGe,OYt=YGe,zYt=VGe,HYt=jGe,YYt=WGe,T7="DropdownMenu",[VYt,Hrn]=gM(T7,[wGe]),Mx=wGe(),[KYt,ZGe]=VYt(T7),XGe=r=>{const{__scopeDropdownMenu:e,children:t,dir:n,open:i,defaultOpen:o,onOpenChange:a,modal:s=!0}=r,l=Mx(e),c=pt.useRef(null),[u,A]=dz({prop:i,defaultProp:o??!1,onChange:a,caller:T7});return ut.jsx(KYt,{scope:e,triggerId:tP(),triggerRef:c,contentId:tP(),open:u,onOpenChange:A,onOpenToggle:pt.useCallback(()=>A(d=>!d),[A]),modal:s,children:ut.jsx(MYt,{...l,open:u,onOpenChange:A,dir:n,modal:s,children:t})})};XGe.displayName=T7;var $Ge="DropdownMenuTrigger",e6e=pt.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,disabled:n=!1,...i}=r,o=ZGe($Ge,t),a=Mx(t);return ut.jsx(DYt,{asChild:!0,...a,children:ut.jsx(nE.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":n?"":void 0,disabled:n,...i,ref:eP(e,o.triggerRef),onPointerDown:Jg(r.onPointerDown,s=>{!n&&s.button===0&&s.ctrlKey===!1&&(o.onOpenToggle(),o.open||s.preventDefault())}),onKeyDown:Jg(r.onKeyDown,s=>{n||(["Enter"," "].includes(s.key)&&o.onOpenToggle(),s.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(s.key)&&s.preventDefault())})})})});e6e.displayName=$Ge;var jYt="DropdownMenuPortal",t6e=r=>{const{__scopeDropdownMenu:e,...t}=r,n=Mx(e);return ut.jsx(RYt,{...n,...t})};t6e.displayName=jYt;var n6e="DropdownMenuContent",r6e=pt.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=ZGe(n6e,t),o=Mx(t),a=pt.useRef(!1);return ut.jsx(NYt,{id:i.contentId,"aria-labelledby":i.triggerId,...o,...n,ref:e,onCloseAutoFocus:Jg(r.onCloseAutoFocus,s=>{var l;a.current||(l=i.triggerRef.current)==null||l.focus(),a.current=!1,s.preventDefault()}),onInteractOutside:Jg(r.onInteractOutside,s=>{const l=s.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;(!i.modal||u)&&(a.current=!0)}),style:{...r.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});r6e.displayName=n6e;var JYt="DropdownMenuGroup",WYt=pt.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Mx(t);return ut.jsx(TYt,{...i,...n,ref:e})});WYt.displayName=JYt;var qYt="DropdownMenuLabel",i6e=pt.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Mx(t);return ut.jsx(PYt,{...i,...n,ref:e})});i6e.displayName=qYt;var ZYt="DropdownMenuItem",o6e=pt.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Mx(t);return ut.jsx(kYt,{...i,...n,ref:e})});o6e.displayName=ZYt;var XYt="DropdownMenuCheckboxItem",a6e=pt.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Mx(t);return ut.jsx(UYt,{...i,...n,ref:e})});a6e.displayName=XYt;var $Yt="DropdownMenuRadioGroup",eVt=pt.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Mx(t);return ut.jsx(FYt,{...i,...n,ref:e})});eVt.displayName=$Yt;var tVt="DropdownMenuRadioItem",s6e=pt.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Mx(t);return ut.jsx(LYt,{...i,...n,ref:e})});s6e.displayName=tVt;var nVt="DropdownMenuItemIndicator",l6e=pt.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Mx(t);return ut.jsx(GYt,{...i,...n,ref:e})});l6e.displayName=nVt;var rVt="DropdownMenuSeparator",c6e=pt.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Mx(t);return ut.jsx(OYt,{...i,...n,ref:e})});c6e.displayName=rVt;var iVt="DropdownMenuArrow",oVt=pt.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Mx(t);return ut.jsx(zYt,{...i,...n,ref:e})});oVt.displayName=iVt;var aVt="DropdownMenuSubTrigger",u6e=pt.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Mx(t);return ut.jsx(HYt,{...i,...n,ref:e})});u6e.displayName=aVt;var sVt="DropdownMenuSubContent",A6e=pt.forwardRef((r,e)=>{const{__scopeDropdownMenu:t,...n}=r,i=Mx(t);return ut.jsx(YYt,{...i,...n,ref:e,style:{...r.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});A6e.displayName=sVt;var lVt=XGe,cVt=e6e,uVt=t6e,d6e=r6e,f6e=i6e,h6e=o6e,p6e=a6e,g6e=s6e,m6e=l6e,y6e=c6e,v6e=u6e,I6e=A6e;const C6e=lVt,E6e=cVt,AVt=pt.forwardRef(({className:r,inset:e,children:t,...n},i)=>ut.jsxs(v6e,{ref:i,className:nI("rf-flex rf-cursor-default rf-gap-2 rf-select-none rf-items-center rf-rounded-sm rf-px-2 rf-py-1.5 rf-text-sm rf-outline-none focus:rf-bg-zinc-100 data-[state=open]:rf-bg-zinc-100 [&_svg]:rf-pointer-events-none [&_svg]:rf-size-4 [&_svg]:rf-shrink-0 dark:focus:rf-bg-zinc-800 dark:data-[state=open]:rf-bg-zinc-800",e&&"rf-pl-8",r),...n,children:[t,ut.jsx(Cle,{className:"rf-ml-auto"})]}));AVt.displayName=v6e.displayName;const dVt=pt.forwardRef(({className:r,...e},t)=>ut.jsx(I6e,{ref:t,className:nI("rf-z-50 rf-min-w-[8rem] rf-overflow-hidden rf-rounded-md rf-border rf-border-zinc-200 rf-bg-white rf-p-1 rf-text-zinc-950 rf-shadow-lg 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-[side=bottom]:rf-slide-in-from-top-2 data-[side=left]:rf-slide-in-from-right-2 data-[side=right]:rf-slide-in-from-left-2 data-[side=top]:rf-slide-in-from-bottom-2 dark:rf-border-zinc-800 dark:rf-bg-zinc-950 dark:rf-text-zinc-50",r),...e}));dVt.displayName=I6e.displayName;const $le=pt.forwardRef(({className:r,sideOffset:e=4,...t},n)=>ut.jsx(uVt,{children:ut.jsx(d6e,{ref:n,sideOffset:e,className:nI("rf-z-50 rf-min-w-[8rem] rf-overflow-hidden rf-rounded-md rf-border rf-border-zinc-200 rf-bg-white rf-p-1 rf-text-zinc-950 rf-shadow-md dark:rf-border-zinc-800 dark:rf-bg-zinc-950 dark:rf-text-zinc-50","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-[side=bottom]:rf-slide-in-from-top-2 data-[side=left]:rf-slide-in-from-right-2 data-[side=right]:rf-slide-in-from-left-2 data-[side=top]:rf-slide-in-from-bottom-2",r),...t})}));$le.displayName=d6e.displayName;const VT=pt.forwardRef(({className:r,inset:e,...t},n)=>ut.jsx(h6e,{ref:n,className:nI("rf-relative rf-flex rf-cursor-default rf-select-none rf-items-center rf-gap-2 rf-rounded-sm rf-px-2 rf-py-1.5 rf-text-sm rf-outline-none rf-transition-colors focus:rf-bg-zinc-100 focus:rf-text-zinc-900 data-[disabled]:rf-pointer-events-none data-[disabled]:rf-opacity-50 [&>svg]:rf-size-4 [&>svg]:rf-shrink-0 dark:focus:rf-bg-zinc-800 dark:focus:rf-text-zinc-50",e&&"rf-pl-8",r),...t}));VT.displayName=h6e.displayName;const fVt=pt.forwardRef(({className:r,children:e,checked:t,...n},i)=>ut.jsxs(p6e,{ref:i,className:nI("rf-relative rf-flex rf-cursor-default rf-select-none rf-items-center rf-rounded-sm rf-py-1.5 rf-pl-8 rf-pr-2 rf-text-sm rf-outline-none rf-transition-colors focus:rf-bg-zinc-100 focus:rf-text-zinc-900 data-[disabled]:rf-pointer-events-none data-[disabled]:rf-opacity-50 dark:focus:rf-bg-zinc-800 dark:focus:rf-text-zinc-50",r),checked:t,...n,children:[ut.jsx("span",{className:"rf-absolute rf-left-2 rf-flex rf-h-3.5 rf-w-3.5 rf-items-center rf-justify-center",children:ut.jsx(m6e,{children:ut.jsx(gLe,{className:"rf-h-4 rf-w-4"})})}),e]}));fVt.displayName=p6e.displayName;const hVt=pt.forwardRef(({className:r,children:e,...t},n)=>ut.jsxs(g6e,{ref:n,className:nI("rf-relative rf-flex rf-cursor-default rf-select-none rf-items-center rf-rounded-sm rf-py-1.5 rf-pl-8 rf-pr-2 rf-text-sm rf-outline-none rf-transition-colors focus:rf-bg-zinc-100 focus:rf-text-zinc-900 data-[disabled]:rf-pointer-events-none data-[disabled]:rf-opacity-50 dark:focus:rf-bg-zinc-800 dark:focus:rf-text-zinc-50",r),...t,children:[ut.jsx("span",{className:"rf-absolute rf-left-2 rf-flex rf-h-3.5 rf-w-3.5 rf-items-center rf-justify-center",children:ut.jsx(m6e,{children:ut.jsx(yLe,{className:"rf-h-2 rf-w-2 rf-fill-current"})})}),e]}));hVt.displayName=g6e.displayName;const pVt=pt.forwardRef(({className:r,inset:e,...t},n)=>ut.jsx(f6e,{ref:n,className:nI("rf-px-2 rf-py-1.5 rf-text-sm rf-font-semibold",e&&"rf-pl-8",r),...t}));pVt.displayName=f6e.displayName;const gVt=pt.forwardRef(({className:r,...e},t)=>ut.jsx(y6e,{ref:t,className:nI("rf--mx-1 rf-my-1 rf-h-px rf-bg-zinc-100 dark:rf-bg-zinc-800",r),...e}));gVt.displayName=y6e.displayName;const _6e=({autoroutingLog:r,onReportAutoroutingLog:e})=>ut.jsx(ut.Fragment,{children:Object.keys(r??{}).length>0&&ut.jsxs(C6e,{children:[ut.jsx(E6e,{asChild:!0,children:ut.jsxs(ZQ,{variant:"outline",children:[ut.jsx(gOt,{className:"rf-w-4 rf-h-4 rf-mr-2"}),"Open Autorouting Log"]})}),ut.jsx($le,{className:"rf-w-96",children:Object.entries(r??{}).map(([t,{simpleRouteJson:n}])=>ut.jsxs(VT,{className:"rf-flex rf-justify-between rf-items-center",children:[ut.jsx("span",{className:"rf-truncate rf-text-xs rf-mr-2",children:t}),ut.jsxs("div",{className:"rf-flex rf-gap-2",children:[ut.jsxs(ZQ,{variant:"outline",size:"sm",onClick:i=>{i.stopPropagation();const o=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),a=URL.createObjectURL(o),s=document.createElement("a");s.href=a,s.download=`${t}-autorouting.json`,s.click(),URL.revokeObjectURL(a)},children:[ut.jsx(yOt,{className:"rf-w-3 rf-h-3"}),"Download"]}),e&&ut.jsxs(ZQ,{variant:"outline",size:"sm",onClick:i=>{i.stopPropagation(),e&&e(t,{simpleRouteJson:n})},children:[ut.jsx(xOt,{className:"rf-w-3 rf-h-3"}),"Report Bug"]})]})]},t))})]})}),mVt=({code:r,fsMap:e,autoroutingLog:t,circuitJsonErrors:n,circuitJsonWarnings:i,onReportAutoroutingLog:o,errorMessage:a,errorStack:s,circuitJson:l,evalVersion:c})=>{const u=pt.useMemo(()=>{const H=[];if(a&&H.push({type:"Execution Error",message:a,stack:s||void 0,source:"execution"}),n&&n.length>0)for(const K of n)H.push({type:K.type||"Circuit JSON Error",message:K.message||"No error message available",stack:K.stack||"",source:"circuitJson"});return H},[a,s,n]),A=pt.useMemo(()=>{if(!l||!Array.isArray(l))return;const H=l.find(K=>K.type==="source_project_metadata");return H==null?void 0:H.software_used_string},[l]),d=pt.useMemo(()=>{const H=[];if(i&&i.length>0)for(const K of i)H.push({type:K.type||"Circuit JSON Warning",message:K.message||"No warning message available",stack:K.stack||"",source:"circuitJson"});return H},[i]),[f,m]=pt.useState(0),[C,E]=pt.useState(0);if(u.length===0&&d.length===0)return ut.jsxs("div",{className:"px-2",children:[ut.jsx("div",{className:"rf-mt-4 rf-bg-green-50 rf-rounded-md rf-border rf-border-green-200",children:ut.jsxs("div",{className:"rf-p-4",children:[ut.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-green-800 rf-mb-3",children:"No errors or warnings!"}),ut.jsx("p",{className:"rf-text-sm rf-text-green-700",children:"Your code is running without any errors or warnings."})]})}),ut.jsx("div",{className:"rf-mt-4",children:ut.jsx(_6e,{autoroutingLog:t,onReportAutoroutingLog:o})})]});const _=()=>{m(H=>Math.max(H-1,0))},x=()=>{m(H=>Math.min(H+1,u.length-1))},w=()=>{E(H=>Math.max(H-1,0))},P=()=>{E(H=>Math.min(H+1,d.length-1))},L=u[f],O=d[C];return ut.jsxs(ut.Fragment,{children:[ut.jsxs("div",{className:"rf-w-[95%] rf-mx-auto",children:[u.length>1&&ut.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mb-2",children:[ut.jsx("button",{type:"button",className:"rf-p-1 rf-rounded-sm rf-transition-colors",onClick:_,disabled:f===0,children:ut.jsx(mLe,{className:"rf-h-4 rf-w-4 rf-text-red-500"})}),ut.jsx("button",{type:"button",className:"rf-p-1 rf-rounded-sm rf-transition-colors",onClick:x,disabled:f===u.length-1,children:ut.jsx(Cle,{className:"rf-h-4 rf-w-4 rf-text-red-500"})}),ut.jsxs("span",{className:"rf-text-sm rf-text-red-600",children:[f+1," of ",u.length," errors"]})]}),L&&ut.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-max-h-[500px] rf-overflow-y-auto rf-px-2",children:ut.jsxs("div",{className:"rf-p-4",children:[ut.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-1",children:L.type}),ut.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600",children:L.message}),(L.stack||c||A)&&ut.jsxs("details",{style:{whiteSpace:"pre-wrap"},className:"rf-text-xs rf-font-mono rf-text-red-600 rf-mt-2",children:[c&&`@tscircuit/eval@${c}
|
|
13215
13215
|
`,A&&`${A}
|
|
13216
|
-
`,L.stack]})]})}),d.length>0&&ut.jsxs(ut.Fragment,{children:[d.length>1&&ut.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mb-2 rf-mt-4",children:[ut.jsx("button",{type:"button",className:"rf-p-1 rf-rounded-sm rf-transition-colors",onClick:w,disabled:C===0,children:ut.jsx(mLe,{className:"rf-h-4 rf-w-4 rf-text-orange-500"})}),ut.jsx("button",{type:"button",className:"rf-p-1 rf-rounded-sm rf-transition-colors",onClick:P,disabled:C===d.length-1,children:ut.jsx(Cle,{className:"rf-h-4 rf-w-4 rf-text-orange-500"})}),ut.jsxs("span",{className:"rf-text-sm rf-text-orange-600",children:[C+1," of ",d.length," warnings"]})]}),O&&ut.jsx("div",{className:"rf-mt-4 rf-bg-orange-50 rf-rounded-md rf-border rf-border-orange-200 rf-max-h-[500px] rf-overflow-y-auto rf-px-2",children:ut.jsxs("div",{className:"rf-p-4",children:[ut.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-orange-800 rf-mb-1",children:O.type}),ut.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-orange-600",children:O.message}),O.stack&&ut.jsx("details",{style:{whiteSpace:"pre-wrap"},className:"rf-text-xs rf-font-mono rf-text-orange-600 rf-mt-2",children:O.stack})]})})]})]}),ut.jsxs("div",{className:"rf-flex rf-gap-2 rf-mt-4 rf-justify-end",children:[ut.jsx(_6e,{autoroutingLog:
|
|
13216
|
+
`,L.stack]})]})}),d.length>0&&ut.jsxs(ut.Fragment,{children:[d.length>1&&ut.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2 rf-mb-2 rf-mt-4",children:[ut.jsx("button",{type:"button",className:"rf-p-1 rf-rounded-sm rf-transition-colors",onClick:w,disabled:C===0,children:ut.jsx(mLe,{className:"rf-h-4 rf-w-4 rf-text-orange-500"})}),ut.jsx("button",{type:"button",className:"rf-p-1 rf-rounded-sm rf-transition-colors",onClick:P,disabled:C===d.length-1,children:ut.jsx(Cle,{className:"rf-h-4 rf-w-4 rf-text-orange-500"})}),ut.jsxs("span",{className:"rf-text-sm rf-text-orange-600",children:[C+1," of ",d.length," warnings"]})]}),O&&ut.jsx("div",{className:"rf-mt-4 rf-bg-orange-50 rf-rounded-md rf-border rf-border-orange-200 rf-max-h-[500px] rf-overflow-y-auto rf-px-2",children:ut.jsxs("div",{className:"rf-p-4",children:[ut.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-orange-800 rf-mb-1",children:O.type}),ut.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-orange-600",children:O.message}),O.stack&&ut.jsx("details",{style:{whiteSpace:"pre-wrap"},className:"rf-text-xs rf-font-mono rf-text-orange-600 rf-mt-2",children:O.stack})]})})]})]}),ut.jsxs("div",{className:"rf-flex rf-gap-2 rf-mt-4 rf-justify-end",children:[ut.jsx(_6e,{autoroutingLog:t,onReportAutoroutingLog:o}),ut.jsxs(ZQ,{variant:"outline",className:"rf-p-1",onClick:()=>{let H=`${L.type}: ${L.message}`;c&&(H+=`
|
|
13217
13217
|
@tscircuit/eval@${c}`),A&&(H+=`
|
|
13218
13218
|
${A}`),L.stack&&(H+=`
|
|
13219
|
-
${L.stack}`),navigator.clipboard.writeText(H),alert("Error copied to clipboard!")},children:[ut.jsx(mOt,{className:"rf-w-4 rf-h-4"}),"Copy Error"]}),ut.jsxs(ZQ,{variant:"outline",className:"rf-p-1",onClick:()=>{const H=`Error ${L.type}`.replace(/[^a-zA-Z0-9 ]/g," ").replace(/\s+/g," ").slice(0,100),K=
|
|
13219
|
+
${L.stack}`),navigator.clipboard.writeText(H),alert("Error copied to clipboard!")},children:[ut.jsx(mOt,{className:"rf-w-4 rf-h-4"}),"Copy Error"]}),ut.jsxs(ZQ,{variant:"outline",className:"rf-p-1",onClick:()=>{const H=`Error ${L.type}`.replace(/[^a-zA-Z0-9 ]/g," ").replace(/\s+/g," ").slice(0,100),K=e?hqe(e instanceof Map?Object.fromEntries(e.entries()):e):QOt(r??"");let q=`${L.type}: ${L.message}`;c&&(q+=`
|
|
13220
13220
|
@tscircuit/eval@${c}`),A&&(q+=`
|
|
13221
13221
|
${A}`),L.stack&&(q+=`
|
|
13222
13222
|
${L.stack}`);let Y=`[Package code to reproduce](${K})
|
|
@@ -13306,7 +13306,7 @@ ${L.type}: ${ie}
|
|
|
13306
13306
|
50% { opacity: 0.2; }
|
|
13307
13307
|
100% { opacity: 0.6; }
|
|
13308
13308
|
}
|
|
13309
|
-
`,i.appendChild(w)}})}};o();const a=new MutationObserver(o);return a.observe(i,{childList:!0,subtree:!1,characterData:!1}),()=>{a.disconnect()}},[r,t,e,n])},JKt=uC("schematic-viewer"),WKt=()=>{uC.enable("schematic-viewer*")},qKt=JKt,ZKt=r=>{const[e,t]=pt.useState(0),[n,i]=pt.useState(0);return pt.useEffect(()=>{if(!r.current)return;const o=()=>{var l;const s=(l=r.current)==null?void 0:l.getBoundingClientRect();t((s==null?void 0:s.width)||0),i((s==null?void 0:s.height)||0)};o();const a=new ResizeObserver(o);return a.observe(r.current),window.addEventListener("resize",o),()=>{a.disconnect(),window.removeEventListener("resize",o)}},[]),{containerWidth:e,containerHeight:n}},XKt=qKt.extend("useComponentDragging"),$Kt=({onEditEvent:r,editEvents:e=[],circuitJson:t,cancelDrag:n,svgToScreenProjection:i,realToSvgProjection:o,enabled:a=!1,snapToGrid:s=!1})=>{const[l,c]=pt.useState(null),u=Ku(o,i),A=pt.useRef(null),d=pt.useRef(null),f=pt.useRef(new Map);pt.useEffect(()=>{e.forEach(_=>{"edit_event_type"in _&&_.edit_event_type==="edit_schematic_component_location"&&!_.in_progress&&f.current.set(_.schematic_component_id,{..._.new_center})})},[e]);const m=pt.useCallback(_=>{if(!a)return;const w=_.target.closest('[data-circuit-json-type="schematic_component"]');if(!w)return;const P=w.getAttribute("data-schematic-component-id");if(!P)return;n&&n();const L=dm(t).schematic_component.get(P);if(!L)return;A.current={x:_.clientX,y:_.clientY};let O;const H=f.current.get(P);if(H)O={...H};else{const q=J6e({editEvents:e,schematic_component_id:P});O={x:L.center.x+q.x,y:L.center.y+q.y},f.current.set(P,{...O})}const K={edit_event_id:Math.random().toString(36).substr(2,9),edit_event_type:"edit_schematic_component_location",schematic_component_id:P,original_center:O,new_center:{...O},in_progress:!0,created_at:Date.now(),_element:w};d.current=K,c(K)},[n,a,t,e]),C=pt.useCallback(_=>{if(!d.current||!A.current)return;const x={x:_.clientX-A.current.x,y:_.clientY-A.current.y},w={x:x.x/u.a,y:x.y/u.d};let P={x:d.current.original_center.x+w.x,y:d.current.original_center.y+w.y};if(s){const O=H=>Math.round(H*10)/10;P={x:O(P.x),y:O(P.y)}}const L={...d.current,new_center:P};d.current=L,c(L)},[u,s]),E=pt.useCallback(()=>{if(!d.current)return;const _={...d.current,in_progress:!1};f.current.set(_.schematic_component_id,{..._.new_center}),XKt("handleMouseUp calling onEditEvent with new edit event",{newEditEvent:_}),r&&r(_),d.current=null,A.current=null,c(null)},[r]);return pt.useEffect(()=>(window.addEventListener("mousemove",C),window.addEventListener("mouseup",E),()=>{window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",E)}),[C,E]),{handleMouseDown:m,isDragging:!!d.current,activeEditEvent:l}},hce={schematicEditIcon:50,schematicGridIcon:49,clickToInteractOverlay:100},ejt=({onClick:r,active:e})=>ut.jsx("div",{onClick:r,style:{position:"absolute",top:"16px",right:"16px",backgroundColor:e?"#4CAF50":"#fff",color:e?"#fff":"#000",padding:"8px",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:"4px",zIndex:hce.schematicEditIcon},children:ut.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[ut.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),ut.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),tjt=({onClick:r,active:e})=>ut.jsx("div",{onClick:r,style:{position:"absolute",top:"56px",right:"16px",backgroundColor:e?"#4CAF50":"#fff",color:e?"#fff":"#000",padding:"8px",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:"4px",zIndex:hce.schematicGridIcon},children:ut.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:ut.jsx("path",{d:"M3 3h7v7H3zM14 3h7v7h-7zM3 14h7v7H3zM14 14h7v7h-7z"})})}),njt=({circuitJson:r,containerStyle:e,editEvents:t=[],onEditEvent:n,defaultEditMode:i=!1,debugGrid:o=!1,editingEnabled:a=!1,debug:s=!1,clickToInteractEnabled:l=!1,colorOverrides:c})=>{s&&WKt();const[u,A]=pt.useState(i),[d,f]=pt.useState(!0),[m,C]=pt.useState(!l),E=pt.useRef(null),_=pt.useRef(null),x=Ne=>{const rt=Ne.touches[0];_.current={x:rt.clientX,y:rt.clientY}},w=Ne=>{const rt=Ne.changedTouches[0],et=_.current;if(!et)return;const ft=Math.abs(rt.clientX-et.x),_t=Math.abs(rt.clientY-et.y);ft<10&&_t<10&&(Ne.preventDefault(),C(!0)),_.current=null},[P,L]=pt.useState([]),O=pt.useRef(r),H=Ne=>`${(Ne==null?void 0:Ne.length)||0}_${(Ne==null?void 0:Ne.editCount)||0}`;pt.useEffect(()=>{const Ne=H(r),rt=H(O.current);Ne!==rt&&(L([]),O.current=r)},[r]);const{ref:K,cancelDrag:q,transform:Y}=j6e({onSetTransform(Ne){E.current&&(E.current.style.transform=gQ(Ne))},enabled:m}),{containerWidth:se,containerHeight:ie}=ZKt(K),de=pt.useMemo(()=>!se||!ie?"":uce(r,{width:se,height:ie||720,grid:o?{cellSize:1,labelCells:!0}:void 0,colorOverrides:c}),[r,se,ie]),Ce=pt.useMemo(()=>{const Ne=de.match(/<svg[^>]*style="[^"]*background-color:\s*([^;\"]+)/i);return(Ne==null?void 0:Ne[1])??"transparent"},[de]),xe=pt.useMemo(()=>{var rt;if(!de)return Ny();const Ne=(rt=de.match(/data-real-to-screen-transform="([^"]+)"/))==null?void 0:rt[1];try{return uY(Ne)}catch(et){return console.error(et),Ny()}},[de]),fe=Ne=>{L(rt=>[...rt,Ne]),n&&n(Ne)},Ie=pt.useMemo(()=>[...t,...P],[t,P]),{handleMouseDown:ve,isDragging:Qe,activeEditEvent:De}=$Kt({onEditEvent:fe,cancelDrag:q,realToSvgProjection:xe,svgToScreenProjection:Y,circuitJson:r,editEvents:Ie,enabled:u&&m,snapToGrid:d});KKt({svgDivRef:E,editEvents:Ie,realToSvgProjection:xe,svgToScreenProjection:Y,activeEditEvent:De}),jKt({svgDivRef:E,circuitJson:r,activeEditEvent:De,editEvents:Ie});const Fe=pt.useMemo(()=>ut.jsx("div",{ref:E,style:{pointerEvents:l?m?"auto":"none":"auto",transformOrigin:"0 0"},dangerouslySetInnerHTML:{__html:de}}),[de,m,l]);return ut.jsxs("div",{ref:K,style:{position:"relative",backgroundColor:Ce,overflow:"hidden",cursor:Qe?"grabbing":l&&!m?"pointer":"grab",minHeight:"300px",...e},onMouseDown:Ne=>{if(l&&!m){Ne.preventDefault(),Ne.stopPropagation();return}ve(Ne)},onMouseDownCapture:Ne=>{if(l&&!m){Ne.preventDefault(),Ne.stopPropagation();return}},onTouchStart:x,onTouchEnd:w,children:[!m&&l&&ut.jsx("div",{onClick:Ne=>{Ne.preventDefault(),Ne.stopPropagation(),C(!0)},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:hce.clickToInteractOverlay,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"all",touchAction:"pan-x pan-y pinch-zoom"},children:ut.jsx("div",{style:{backgroundColor:"rgba(0, 0, 0, 0.8)",color:"white",padding:"12px 24px",borderRadius:"8px",fontSize:"16px",fontFamily:"sans-serif",pointerEvents:"none"},children:typeof window<"u"&&("ontouchstart"in window||navigator.maxTouchPoints>0)?"Touch to Interact":"Click to Interact"})}),a&&ut.jsx(ejt,{active:u,onClick:()=>A(!u)}),a&&u&&ut.jsx(tjt,{active:d,onClick:()=>f(!d)}),Fe]})},rjt=r=>{const[e,t]=pt.useState(0),[n,i]=pt.useState(0);return pt.useEffect(()=>{if(!r.current)return;const o=()=>{var l;const s=(l=r.current)==null?void 0:l.getBoundingClientRect();t((s==null?void 0:s.width)||0),i((s==null?void 0:s.height)||0)};o();const a=new ResizeObserver(o);return a.observe(r.current),window.addEventListener("resize",o),()=>{a.disconnect(),window.removeEventListener("resize",o)}},[]),{containerWidth:e,containerHeight:n}};uC("assembly-viewer");var ijt=()=>{uC.enable("assembly-viewer*")},ojt=({circuitJson:r,containerStyle:e,debugGrid:t=!1,debug:n=!1})=>{n&&ijt();const i=pt.useRef(null),{ref:o}=j6e({onSetTransform(u){i.current&&(i.current.style.transform=gQ(u))}}),{containerWidth:a,containerHeight:s}=rjt(o),l=pt.useMemo(()=>!a||!s?"":U6e(r,{width:a,height:s||720}),[r,a,s]);pt.useMemo(()=>{var A;if(!l)return Ny();const u=(A=l.match(/data-real-to-screen-transform="([^"]+)"/))==null?void 0:A[1];try{return uY(u)}catch(d){return console.error(d),Ny()}},[l]);const c=pt.useMemo(()=>ut.jsx("div",{ref:i,style:{pointerEvents:"auto",transformOrigin:"0 0"},dangerouslySetInnerHTML:{__html:l}}),[l]);return ut.jsx("div",{ref:o,style:{position:"relative",backgroundColor:"#F5F1ED",overflow:"hidden",minHeight:"300px",...e},children:c})};const W6e=["Initialize a tscircuit project using [tsci init](https://github.com/tscircuit/cli) before adding components.","Define reusable modules with cached routes using [<subcircuit />](https://docs.tscircuit.com/elements/subcircuit)","Run `tsci dev` on the command line to preview your boards before export",'Use units like mm or mils consistently across your designs (e.g. pcbX="10mm")',"Quickly set footprints with the [footprint prop](https://docs.tscircuit.com/footprints/footprinter-strings)","Check out the guide on [ordering prototypes](https://docs.tscircuit.com/building-electronics/ordering-prototypes)","Use [net labels](https://docs.tscircuit.com/elements/net) and [group elements](https://docs.tscircuit.com/elements/group) to organize complex schematics.","You can manually drag components on the PCB and Schematic using [manual edits](https://docs.tscircuit.com/guides/manual-edits)","Every tscircuit module can export to [Circuit JSON](https://github.com/tscircuit/circuit-json), Gerbers, Pick'n'Place CSV files, Bill of Materials CSV and more","You can import components from [JLCPCB](https://docs.tscircuit.com/guides/importing-modules-and-chips/importing-from-jlcpcb) or [KiCad](https://docs.tscircuit.com/guides/importing-modules-and-chips/importing-from-kicad)","Any module you push to the [registry](https://tscircuit.com/trending) will have [simple image urls](https://docs.tscircuit.com/web-apis/image-generation-api) you can use display images on a website","The default [Parts Engine](https://docs.tscircuit.com/guides/platform-configuration) will automatically find parts from common vendors for your BOM",'[Pin selectors](https://docs.tscircuit.com/guides/using-sel-references) are similar to CSS selectors, ".R1 > .pin1" means "connect to the first pin of the component R1"',"You can use the [sel](https://docs.tscircuit.com/guides/using-sel-references) object to select pins in a type-safe way","Publish modules via the [registry](https://tscircuit.com/trending) for working with a team or sharing your work","[Explore tutorials](https://docs.tscircuit.com/category/tutorials) for real-world circuit design examples.","Upload your Circuit JSON to [circuitjson.com](https://circuitjson.com) for a quick preview.","You can display Circuit JSON in 3D, PCB or Schematic mode with the [<CircuitJsonPreview />](https://docs.tscircuit.com/elements/circuitjsonpreview) React component","Use a [<group />](https://docs.tscircuit.com/elements/group) element to move multiple components at once in a schematic or PCB layout.","Check out the [GitHub Discussions page](https://github.com/tscircuit/tscircuit/discussions) to upvote features","You can customize the autorouter using the [autorouter prop](https://docs.tscircuit.com/elements/board#setting-the-autorouter)","Use the [<constraint />](https://docs.tscircuit.com/footprints/constraint) element to enforce geometric relationships in PCB designs.","Join the [Discord server](https://tscircuit.com/join) to discuss issues and get help directly from the community."],ajt=(()=>{let r=W6e[Math.floor(Math.random()*W6e.length)];return r=r.replace(/</g,"<"),r=r.replace(/>/g,">"),r=r.replace(new RegExp('(?<!href=")(?<!\\()(?<!\\]\\()(https?:\\/\\/[^\\s\\)\\]]+)',"g"),(e,t)=>`<a class="rf-text-blue-500 rf-underline" href="${e}" target="_blank">${e}</a>`),r=r.replace(/\[([^\]]+)\]\((https?:\/\/[^\)]+)\)/g,'<a class="rf-text-blue-500 rf-underline" href="$2" target="_blank">$1</a>'),r})(),X9=({onRunClicked:r})=>ut.jsxs("div",{className:"rf-flex rf-flex-col rf-items-center rf-justify-center rf-h-full rf-bg-gray-50 rf-text-gray-500 rf-p-4",children:[ut.jsx(COt,{className:"rf-size-14 rf-mb-4"}),ut.jsxs("p",{className:"rf-text-md rf-break-words rf-max-w-xl rf-text-center",children:["Tip: ",ut.jsx("span",{dangerouslySetInnerHTML:{__html:ajt}})]}),r&&ut.jsxs(ZQ,{className:"rf-mt-4 rf-bg-blue-600 rf-hover:bg-blue-500",onClick:r,children:["Run Code",ut.jsx(_Ot,{className:"rf-w-3 rf-h-3 rf-ml-2"})]})]}),z7=({text:r,onClick:e})=>ut.jsx("span",{className:"rf-cursor-pointer rf-underline rf-text-blue-600 rf-mx-2",onClick:e,children:r}),H7=r=>{var e;return ut.jsxs("div",{className:"rf-leading-5",children:[ut.jsx("div",{className:"rf-py-2 rf-font-bold",children:r.column.name}),ut.jsx("div",{children:((e=r.field)==null?void 0:e.call(r))??ut.jsx("input",{type:"text",className:"rf-border rf-rounded rf-p-1 rf-w-full",onChange:t=>{var n;(n=r.onTextChange)==null||n.call(r,t.target.value)}})})]})},sjt=({open:r,children:e,title:t,onClose:n})=>r?ut.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-justify-center rf-items-center rf-z-50",onClick:n,children:ut.jsxs("div",{className:"rf-bg-white rf-p-5 rf-rounded-lg rf-relative rf-w-11/12 rf-max-w-2xl",onClick:i=>{i.preventDefault(),i.stopPropagation()},children:[ut.jsx("h2",{className:"rf-mt-0 rf-text-md rf-pb-4",children:t}),ut.jsx("button",{type:"button",className:"rf-absolute rf-top-2 rf-right-4 rf-text-2xl rf-font-bold",onClick:n,children:"×"}),e]})}):null,ljt=({elements:r})=>{const[e,t]=pt.useState({open:!1}),[n,i]=pt.useReducer((u,A)=>({...u,...A}),{}),o=[...new Set(r.map(u=>u.type))],a=r.map(u=>{const A=u[`${u.type}_id`],d=Object.fromEntries(Object.entries(u).filter(([m])=>!(m===`${u.type}_id`||!m.endsWith("_id")))),f=Object.fromEntries(Object.entries(u).filter(([m])=>!m.endsWith("_id")));return{primary_id:A,other_ids:d,...f,_og_elm:u}}),s=a.map(u=>{let A="";const d=f=>{const m=Object.keys(f.other_ids).find(_=>_.startsWith("source_"));if(!m)return`.${f.name}`;const C=m.slice(0,-3),E=a.find(_=>_.type===C&&_.primary_id===f.other_ids[m]);return E?"name"in E?`${d(E)} > .${f.name}`:`#${E.primary_id} > .${f.name}`:`??? > .${f.name}`};return"name"in u&&(A=d(u)),{...u,selector_path:A}}),l=[{key:"primary_id",name:"primary_id",renderCell:u=>ut.jsxs("div",{className:"rf-flex rf-items-center",children:[ut.jsx(z7,{text:u.primary_id,onClick:()=>i({focused_id:u.primary_id,id_search:void 0,selector_search:void 0})}),ut.jsx("span",{className:"rf-flex-grow"}),ut.jsx(z7,{text:"(JSON)",onClick:()=>t({open:!0,element:u._og_elm,title:u.primary_id})})]}),renderHeaderCell:u=>ut.jsx(H7,{column:u,onTextChange:A=>i({id_search:A}),field:n.focused_id?()=>ut.jsxs("div",{children:["Focus:"," ",ut.jsx("span",{className:"rf-underline",children:n.focused_id}),ut.jsx(z7,{text:"(unfocus)",onClick:()=>i({focused_id:void 0})})]}):void 0})},{key:"type",name:"type",renderHeaderCell:u=>ut.jsx(H7,{column:u,field:()=>ut.jsxs("select",{onChange:A=>i({component_type_filter:A.target.value}),className:"rf-border rf-rounded rf-p-1 rf-w-full",children:[ut.jsx("option",{value:"any",children:"any"},"any"),ut.jsx("option",{value:"source",children:"source"},"source"),ut.jsx("option",{value:"source/pcb",children:"source/pcb"},"source/pcb"),ut.jsx("option",{value:"source/schematic",children:"source/schematic"},"source/schematic"),o.map(A=>ut.jsx("option",{value:A,children:A},A))]})})},{key:"name",name:"name",renderHeaderCell:u=>ut.jsx(H7,{column:u,onTextChange:A=>i({name_search:A})})},{key:"selector_path",name:"selector_path",renderHeaderCell:u=>ut.jsx(H7,{column:u,onTextChange:A=>i({selector_search:A})})},{key:"other_ids",name:"other_ids",renderCell:u=>ut.jsx("div",{className:"rf-space-x-2",children:Object.entries(u.other_ids).map(([A,d])=>ut.jsx(z7,{text:d,onClick:()=>i({focused_id:d})},d))})}],c=s.filter(u=>{var A,d;return n.name_search?(d=(A=u.name)==null?void 0:A.toLowerCase())==null?void 0:d.includes(n.name_search.toLowerCase()):!0}).filter(u=>{var A;return!n.component_type_filter||n.component_type_filter==="any"?!0:n.component_type_filter==="source"?u.type.startsWith("source_"):n.component_type_filter==="source/pcb"?u.type.startsWith("source_")||u.type.startsWith("pcb_"):n.component_type_filter==="source/schematic"?u.type.startsWith("source_")||u.type.startsWith("schematic_"):(A=u.type)==null?void 0:A.includes(n.component_type_filter)}).filter(u=>n.selector_search?n.selector_search.split(" ").filter(d=>d.length>0).every(d=>{var f;return(f=u.selector_path)==null?void 0:f.includes(d)}):!0).filter(u=>{var A;return n.id_search?(A=u.primary_id)==null?void 0:A.includes(n.id_search):!0}).filter(u=>!!(!n.focused_id||u.primary_id===n.focused_id||Object.values(u.other_ids).includes(n.focused_id)));return ut.jsxs("div",{className:"rf-font-mono rf-text-xs rf-bg-white",children:[ut.jsx("div",{className:"rf-overflow-x-auto",children:ut.jsxs("table",{className:"rf-table-auto rf-w-full rf-text-left",children:[ut.jsx("thead",{children:ut.jsx("tr",{children:l.map(u=>ut.jsx("th",{className:"rf-px-4 rf-py-2 rf-border-b",children:u.renderHeaderCell?u.renderHeaderCell(u):u.name},u.key))})}),ut.jsx("tbody",{children:c.map((u,A)=>ut.jsx("tr",{className:"rf-hover:bg-gray-100",children:l.map(d=>ut.jsx("td",{className:"rf-px-4 rf-py-2 rf-border-b",children:d.renderCell?d.renderCell(u):u[d.key]},d.key))},A))})]})}),ut.jsx(sjt,{open:e.open,onClose:()=>t({open:!1}),title:e.open?e.title:"",children:ut.jsx("div",{className:"rf-bg-gray-800 rf-p-3 rf-text-white rf-rounded",children:ut.jsx("pre",{className:"rf-whitespace-pre-wrap",children:e.open?JSON.stringify(e.element,null,2):""})})})]})},cjt=(r,e)=>r==="jlcpcb"?ut.jsx("a",{className:"rf-underline rf-text-blue-500",target:"_blank",rel:"noreferrer",href:`https://jlcpcb.com/partdetail/${e}`,children:e}):e,ujt=({circuitJson:r})=>{const e=r.filter(n=>n.type==="source_component"),t=new Set;for(const n of e)if(n.supplier_part_numbers)for(const i of Object.keys(n.supplier_part_numbers))t.add(i);return ut.jsx("div",{className:"rf-overflow-x-auto",children:ut.jsxs("table",{className:"rf-w-full rf-text-left rf-text-sm",children:[ut.jsx("thead",{children:ut.jsxs("tr",{className:"rf-border-b",children:[ut.jsx("th",{className:"rf-p-2",children:"Name"}),Array.from(t).map(n=>ut.jsx("th",{className:"rf-p-2 rf-capitalize",children:n},n))]})}),ut.jsx("tbody",{children:e.map(n=>ut.jsxs("tr",{className:"rf-border-b",children:[ut.jsx("td",{className:"rf-p-2",children:n.name}),Array.from(t).map(i=>{var o,a;return ut.jsx("td",{className:"rf-p-2",children:cjt(i,((a=(o=n.supplier_part_numbers)==null?void 0:o[i])==null?void 0:a[0])||"")},i)})]},n.source_component_id))})]})})};function q6e([r,e],[t,n],{lineThickness:i=0}={}){return i===0?Z6e(r,e,t,n):Ajt(r,e,t,n)<=i}function Z6e(r,e,t,n){const i=Y7(r,e,t),o=Y7(r,e,n),a=Y7(t,n,r),s=Y7(t,n,e);return!!(i!==o&&a!==s||i===0&&V7(r,t,e)||o===0&&V7(r,n,e)||a===0&&V7(t,r,n)||s===0&&V7(t,e,n))}function Y7(r,e,t){const n=(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y);return n===0?0:n>0?1:2}function V7(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function Ajt(r,e,t,n){if(r.x===e.x&&r.y===e.y)return $9(r,t,n);if(t.x===n.x&&t.y===n.y)return $9(t,r,e);if(Z6e(r,e,t,n))return 0;const i=[$9(r,t,n),$9(e,t,n),$9(t,r,e),$9(n,r,e)];return Math.min(...i)}function $9(r,e,t){const n=(t.x-e.x)**2+(t.y-e.y)**2;if(n===0)return qT(r,e);let i=((r.x-e.x)*(t.x-e.x)+(r.y-e.y)*(t.y-e.y))/n;i=Math.max(0,Math.min(1,i));const o={x:e.x+i*(t.x-e.x),y:e.y+i*(t.y-e.y)};return qT(r,o)}function qT(r,e){const t=r.x-e.x,n=r.y-e.y;return Math.sqrt(t*t+n*n)}var djt=(r,e)=>{const t={x:e.x-r.x,y:e.y-r.y},n=Math.sqrt(t.x**2+t.y**2);return{x:t.x/n,y:t.y/n}},fjt=r=>{switch(r){case"up":return{x:0,y:1};case"down":return{x:0,y:-1};case"left":return{x:-1,y:0};case"right":return{x:1,y:0}}},hjt=Object.defineProperty,pjt=(r,e)=>{for(var t in e)hjt(r,t,{get:e[t],enumerable:!0})},X6e={};pjt(X6e,{Battery:()=>RJt,Board:()=>dJt,Capacitor:()=>hJt,Chip:()=>I7e,Constraint:()=>EJt,Crystal:()=>GJt,Cutout:()=>DJt,Diode:()=>pJt,FabricationNotePath:()=>_Jt,FabricationNoteText:()=>xJt,Footprint:()=>Fjt,Fuse:()=>gJt,Group:()=>bce,Hole:()=>c7e,Inductor:()=>kJt,Jumper:()=>mJt,Keepout:()=>Ice,Led:()=>yJt,Mosfet:()=>zJt,Net:()=>o7e,NetAlias:()=>bJt,NormalComponent:()=>L1,PcbTrace:()=>l7e,PinHeader:()=>NJt,PlatedHole:()=>vce,Port:()=>Hw,Potentiometer:()=>FJt,PowerSource:()=>vJt,PrimitiveComponent:()=>aI,PushButton:()=>LJt,Renderable:()=>$6e,Resistor:()=>IJt,Resonator:()=>PJt,SchematicBox:()=>VJt,SchematicText:()=>YJt,SilkscreenCircle:()=>SJt,SilkscreenLine:()=>QJt,SilkscreenPath:()=>s7e,SilkscreenRect:()=>wJt,SilkscreenText:()=>Cce,SmtPad:()=>yce,Subcircuit:()=>BJt,Switch:()=>HJt,Trace:()=>Yw,TraceHint:()=>y7e,Transistor:()=>OJt,Via:()=>MJt});var gjt=uC("tscircuit:renderable"),eM=["ReactSubtreesRender","PcbFootprintStringRender","InitializePortsFromChildren","CreateNetsFromProps","CreateTracesFromProps","CreateTraceHintsFromProps","SourceRender","SourceParentAttachment","PortMatching","OptimizeSelectorCache","SourceTraceRender","SourceAddConnectivityMapKey","SchematicComponentRender","SchematicPortRender","SchematicPrimitiveRender","SchematicLayout","SchematicTraceRender","SchematicReplaceNetLabelsWithSymbols","PcbComponentRender","PcbPrimitiveRender","PcbFootprintLayout","PcbPortRender","PcbPortAttachment","PcbLayout","PcbComponentSizeCalculation","PcbBoardAutoSize","PcbTraceHintRender","PcbTraceRender","PcbRouteNetIslands","PcbDesignRuleChecks","CadModelRender","PartsEngineRender"],mjt=0,$6e=class{constructor(r){Ye(this,"renderPhaseStates");Ye(this,"shouldBeRemoved",!1);Ye(this,"children");Ye(this,"isPcbPrimitive",!1);Ye(this,"isSchematicPrimitive",!1);Ye(this,"_renderId");Ye(this,"_currentRenderPhase",null);Ye(this,"_asyncEffects",[]);Ye(this,"parent",null);this._renderId=`${mjt++}`,this.children=[],this.renderPhaseStates={};for(const e of eM)this.renderPhaseStates[e]={initialized:!1,dirty:!1}}_markDirty(r){var t;this.renderPhaseStates[r].dirty=!0;const e=eM.indexOf(r);for(let n=e+1;n<eM.length;n++)this.renderPhaseStates[eM[n]].dirty=!0;(t=this.parent)!=null&&t._markDirty&&this.parent._markDirty(r)}_queueAsyncEffect(r,e){const t={promise:e(),phase:this._currentRenderPhase,effectName:r,complete:!1};this._asyncEffects.push(t),"root"in this&&this.root&&this.root.emit("asyncEffect:start",{effectName:r,componentDisplayName:this.getString(),phase:t.phase}),t.promise.then(()=>{t.complete=!0,"root"in this&&this.root&&this.root.emit("asyncEffect:end",{effectName:r,componentDisplayName:this.getString(),phase:t.phase})}).catch(n=>{console.error(`Async effect error in ${t.phase} "${r}":
|
|
13309
|
+
`,i.appendChild(w)}})}};o();const a=new MutationObserver(o);return a.observe(i,{childList:!0,subtree:!1,characterData:!1}),()=>{a.disconnect()}},[r,t,e,n])},JKt=uC("schematic-viewer"),WKt=()=>{uC.enable("schematic-viewer*")},qKt=JKt,ZKt=r=>{const[e,t]=pt.useState(0),[n,i]=pt.useState(0);return pt.useEffect(()=>{if(!r.current)return;const o=()=>{var l;const s=(l=r.current)==null?void 0:l.getBoundingClientRect();t((s==null?void 0:s.width)||0),i((s==null?void 0:s.height)||0)};o();const a=new ResizeObserver(o);return a.observe(r.current),window.addEventListener("resize",o),()=>{a.disconnect(),window.removeEventListener("resize",o)}},[]),{containerWidth:e,containerHeight:n}},XKt=qKt.extend("useComponentDragging"),$Kt=({onEditEvent:r,editEvents:e=[],circuitJson:t,cancelDrag:n,svgToScreenProjection:i,realToSvgProjection:o,enabled:a=!1,snapToGrid:s=!1})=>{const[l,c]=pt.useState(null),u=Ku(o,i),A=pt.useRef(null),d=pt.useRef(null),f=pt.useRef(new Map);pt.useEffect(()=>{e.forEach(_=>{"edit_event_type"in _&&_.edit_event_type==="edit_schematic_component_location"&&!_.in_progress&&f.current.set(_.schematic_component_id,{..._.new_center})})},[e]);const m=pt.useCallback(_=>{if(!a)return;const w=_.target.closest('[data-circuit-json-type="schematic_component"]');if(!w)return;const P=w.getAttribute("data-schematic-component-id");if(!P)return;n&&n();const L=dm(t).schematic_component.get(P);if(!L)return;A.current={x:_.clientX,y:_.clientY};let O;const H=f.current.get(P);if(H)O={...H};else{const q=J6e({editEvents:e,schematic_component_id:P});O={x:L.center.x+q.x,y:L.center.y+q.y},f.current.set(P,{...O})}const K={edit_event_id:Math.random().toString(36).substr(2,9),edit_event_type:"edit_schematic_component_location",schematic_component_id:P,original_center:O,new_center:{...O},in_progress:!0,created_at:Date.now(),_element:w};d.current=K,c(K)},[n,a,t,e]),C=pt.useCallback(_=>{if(!d.current||!A.current)return;const x={x:_.clientX-A.current.x,y:_.clientY-A.current.y},w={x:x.x/u.a,y:x.y/u.d};let P={x:d.current.original_center.x+w.x,y:d.current.original_center.y+w.y};if(s){const O=H=>Math.round(H*10)/10;P={x:O(P.x),y:O(P.y)}}const L={...d.current,new_center:P};d.current=L,c(L)},[u,s]),E=pt.useCallback(()=>{if(!d.current)return;const _={...d.current,in_progress:!1};f.current.set(_.schematic_component_id,{..._.new_center}),XKt("handleMouseUp calling onEditEvent with new edit event",{newEditEvent:_}),r&&r(_),d.current=null,A.current=null,c(null)},[r]);return pt.useEffect(()=>(window.addEventListener("mousemove",C),window.addEventListener("mouseup",E),()=>{window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",E)}),[C,E]),{handleMouseDown:m,isDragging:!!d.current,activeEditEvent:l}},hce={schematicEditIcon:50,schematicGridIcon:49,clickToInteractOverlay:100},ejt=({onClick:r,active:e})=>ut.jsx("div",{onClick:r,style:{position:"absolute",top:"16px",right:"16px",backgroundColor:e?"#4CAF50":"#fff",color:e?"#fff":"#000",padding:"8px",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:"4px",zIndex:hce.schematicEditIcon},children:ut.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[ut.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),ut.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),tjt=({onClick:r,active:e})=>ut.jsx("div",{onClick:r,style:{position:"absolute",top:"56px",right:"16px",backgroundColor:e?"#4CAF50":"#fff",color:e?"#fff":"#000",padding:"8px",borderRadius:"4px",cursor:"pointer",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:"4px",zIndex:hce.schematicGridIcon},children:ut.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:ut.jsx("path",{d:"M3 3h7v7H3zM14 3h7v7h-7zM3 14h7v7H3zM14 14h7v7h-7z"})})}),njt=({circuitJson:r,containerStyle:e,editEvents:t=[],onEditEvent:n,defaultEditMode:i=!1,debugGrid:o=!1,editingEnabled:a=!1,debug:s=!1,clickToInteractEnabled:l=!1,colorOverrides:c})=>{s&&WKt();const[u,A]=pt.useState(i),[d,f]=pt.useState(!0),[m,C]=pt.useState(!l),E=pt.useRef(null),_=pt.useRef(null),x=Ne=>{const rt=Ne.touches[0];_.current={x:rt.clientX,y:rt.clientY}},w=Ne=>{const rt=Ne.changedTouches[0],et=_.current;if(!et)return;const ft=Math.abs(rt.clientX-et.x),_t=Math.abs(rt.clientY-et.y);ft<10&&_t<10&&(Ne.preventDefault(),C(!0)),_.current=null},[P,L]=pt.useState([]),O=pt.useRef(r),H=Ne=>`${(Ne==null?void 0:Ne.length)||0}_${(Ne==null?void 0:Ne.editCount)||0}`;pt.useEffect(()=>{const Ne=H(r),rt=H(O.current);Ne!==rt&&(L([]),O.current=r)},[r]);const{ref:K,cancelDrag:q,transform:Y}=j6e({onSetTransform(Ne){E.current&&(E.current.style.transform=gQ(Ne))},enabled:m}),{containerWidth:se,containerHeight:ie}=ZKt(K),de=pt.useMemo(()=>!se||!ie?"":uce(r,{width:se,height:ie||720,grid:o?{cellSize:1,labelCells:!0}:void 0,colorOverrides:c}),[r,se,ie]),Ce=pt.useMemo(()=>{const Ne=de.match(/<svg[^>]*style="[^"]*background-color:\s*([^;\"]+)/i);return(Ne==null?void 0:Ne[1])??"transparent"},[de]),xe=pt.useMemo(()=>{var rt;if(!de)return Ny();const Ne=(rt=de.match(/data-real-to-screen-transform="([^"]+)"/))==null?void 0:rt[1];try{return uY(Ne)}catch(et){return console.error(et),Ny()}},[de]),fe=Ne=>{L(rt=>[...rt,Ne]),n&&n(Ne)},Ie=pt.useMemo(()=>[...t,...P],[t,P]),{handleMouseDown:ve,isDragging:Qe,activeEditEvent:De}=$Kt({onEditEvent:fe,cancelDrag:q,realToSvgProjection:xe,svgToScreenProjection:Y,circuitJson:r,editEvents:Ie,enabled:u&&m,snapToGrid:d});KKt({svgDivRef:E,editEvents:Ie,realToSvgProjection:xe,svgToScreenProjection:Y,activeEditEvent:De}),jKt({svgDivRef:E,circuitJson:r,activeEditEvent:De,editEvents:Ie});const Fe=pt.useMemo(()=>ut.jsx("div",{ref:E,style:{pointerEvents:l?m?"auto":"none":"auto",transformOrigin:"0 0"},dangerouslySetInnerHTML:{__html:de}}),[de,m,l]);return ut.jsxs("div",{ref:K,style:{position:"relative",backgroundColor:Ce,overflow:"hidden",cursor:Qe?"grabbing":l&&!m?"pointer":"grab",minHeight:"300px",...e},onMouseDown:Ne=>{if(l&&!m){Ne.preventDefault(),Ne.stopPropagation();return}ve(Ne)},onMouseDownCapture:Ne=>{if(l&&!m){Ne.preventDefault(),Ne.stopPropagation();return}},onTouchStart:x,onTouchEnd:w,children:[!m&&l&&ut.jsx("div",{onClick:Ne=>{Ne.preventDefault(),Ne.stopPropagation(),C(!0)},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:hce.clickToInteractOverlay,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"all",touchAction:"pan-x pan-y pinch-zoom"},children:ut.jsx("div",{style:{backgroundColor:"rgba(0, 0, 0, 0.8)",color:"white",padding:"12px 24px",borderRadius:"8px",fontSize:"16px",fontFamily:"sans-serif",pointerEvents:"none"},children:typeof window<"u"&&("ontouchstart"in window||navigator.maxTouchPoints>0)?"Touch to Interact":"Click to Interact"})}),a&&ut.jsx(ejt,{active:u,onClick:()=>A(!u)}),a&&u&&ut.jsx(tjt,{active:d,onClick:()=>f(!d)}),Fe]})},rjt=r=>{const[e,t]=pt.useState(0),[n,i]=pt.useState(0);return pt.useEffect(()=>{if(!r.current)return;const o=()=>{var l;const s=(l=r.current)==null?void 0:l.getBoundingClientRect();t((s==null?void 0:s.width)||0),i((s==null?void 0:s.height)||0)};o();const a=new ResizeObserver(o);return a.observe(r.current),window.addEventListener("resize",o),()=>{a.disconnect(),window.removeEventListener("resize",o)}},[]),{containerWidth:e,containerHeight:n}};uC("assembly-viewer");var ijt=()=>{uC.enable("assembly-viewer*")},ojt=({circuitJson:r,containerStyle:e,debugGrid:t=!1,debug:n=!1})=>{n&&ijt();const i=pt.useRef(null),{ref:o}=j6e({onSetTransform(u){i.current&&(i.current.style.transform=gQ(u))}}),{containerWidth:a,containerHeight:s}=rjt(o),l=pt.useMemo(()=>!a||!s?"":U6e(r,{width:a,height:s||720}),[r,a,s]);pt.useMemo(()=>{var A;if(!l)return Ny();const u=(A=l.match(/data-real-to-screen-transform="([^"]+)"/))==null?void 0:A[1];try{return uY(u)}catch(d){return console.error(d),Ny()}},[l]);const c=pt.useMemo(()=>ut.jsx("div",{ref:i,style:{pointerEvents:"auto",transformOrigin:"0 0"},dangerouslySetInnerHTML:{__html:l}}),[l]);return ut.jsx("div",{ref:o,style:{position:"relative",backgroundColor:"#FFFFFF",overflow:"hidden",minHeight:"300px",...e},children:c})};const W6e=["Initialize a tscircuit project using [tsci init](https://github.com/tscircuit/cli) before adding components.","Define reusable modules with cached routes using [<subcircuit />](https://docs.tscircuit.com/elements/subcircuit)","Run `tsci dev` on the command line to preview your boards before export",'Use units like mm or mils consistently across your designs (e.g. pcbX="10mm")',"Quickly set footprints with the [footprint prop](https://docs.tscircuit.com/footprints/footprinter-strings)","Check out the guide on [ordering prototypes](https://docs.tscircuit.com/building-electronics/ordering-prototypes)","Use [net labels](https://docs.tscircuit.com/elements/net) and [group elements](https://docs.tscircuit.com/elements/group) to organize complex schematics.","You can manually drag components on the PCB and Schematic using [manual edits](https://docs.tscircuit.com/guides/manual-edits)","Every tscircuit module can export to [Circuit JSON](https://github.com/tscircuit/circuit-json), Gerbers, Pick'n'Place CSV files, Bill of Materials CSV and more","You can import components from [JLCPCB](https://docs.tscircuit.com/guides/importing-modules-and-chips/importing-from-jlcpcb) or [KiCad](https://docs.tscircuit.com/guides/importing-modules-and-chips/importing-from-kicad)","Any module you push to the [registry](https://tscircuit.com/trending) will have [simple image urls](https://docs.tscircuit.com/web-apis/image-generation-api) you can use display images on a website","The default [Parts Engine](https://docs.tscircuit.com/guides/platform-configuration) will automatically find parts from common vendors for your BOM",'[Pin selectors](https://docs.tscircuit.com/guides/using-sel-references) are similar to CSS selectors, ".R1 > .pin1" means "connect to the first pin of the component R1"',"You can use the [sel](https://docs.tscircuit.com/guides/using-sel-references) object to select pins in a type-safe way","Publish modules via the [registry](https://tscircuit.com/trending) for working with a team or sharing your work","[Explore tutorials](https://docs.tscircuit.com/category/tutorials) for real-world circuit design examples.","Upload your Circuit JSON to [circuitjson.com](https://circuitjson.com) for a quick preview.","You can display Circuit JSON in 3D, PCB or Schematic mode with the [<CircuitJsonPreview />](https://docs.tscircuit.com/elements/circuitjsonpreview) React component","Use a [<group />](https://docs.tscircuit.com/elements/group) element to move multiple components at once in a schematic or PCB layout.","Check out the [GitHub Discussions page](https://github.com/tscircuit/tscircuit/discussions) to upvote features","You can customize the autorouter using the [autorouter prop](https://docs.tscircuit.com/elements/board#setting-the-autorouter)","Use the [<constraint />](https://docs.tscircuit.com/footprints/constraint) element to enforce geometric relationships in PCB designs.","Join the [Discord server](https://tscircuit.com/join) to discuss issues and get help directly from the community."],ajt=(()=>{let r=W6e[Math.floor(Math.random()*W6e.length)];return r=r.replace(/</g,"<"),r=r.replace(/>/g,">"),r=r.replace(new RegExp('(?<!href=")(?<!\\()(?<!\\]\\()(https?:\\/\\/[^\\s\\)\\]]+)',"g"),(e,t)=>`<a class="rf-text-blue-500 rf-underline" href="${e}" target="_blank">${e}</a>`),r=r.replace(/\[([^\]]+)\]\((https?:\/\/[^\)]+)\)/g,'<a class="rf-text-blue-500 rf-underline" href="$2" target="_blank">$1</a>'),r})(),X9=({onRunClicked:r})=>ut.jsxs("div",{className:"rf-flex rf-flex-col rf-items-center rf-justify-center rf-h-full rf-bg-gray-50 rf-text-gray-500 rf-p-4",children:[ut.jsx(COt,{className:"rf-size-14 rf-mb-4"}),ut.jsxs("p",{className:"rf-text-md rf-break-words rf-max-w-xl rf-text-center",children:["Tip: ",ut.jsx("span",{dangerouslySetInnerHTML:{__html:ajt}})]}),r&&ut.jsxs(ZQ,{className:"rf-mt-4 rf-bg-blue-600 rf-hover:bg-blue-500",onClick:r,children:["Run Code",ut.jsx(_Ot,{className:"rf-w-3 rf-h-3 rf-ml-2"})]})]}),z7=({text:r,onClick:e})=>ut.jsx("span",{className:"rf-cursor-pointer rf-underline rf-text-blue-600 rf-mx-2",onClick:e,children:r}),H7=r=>{var e;return ut.jsxs("div",{className:"rf-leading-5",children:[ut.jsx("div",{className:"rf-py-2 rf-font-bold",children:r.column.name}),ut.jsx("div",{children:((e=r.field)==null?void 0:e.call(r))??ut.jsx("input",{type:"text",className:"rf-border rf-rounded rf-p-1 rf-w-full",onChange:t=>{var n;(n=r.onTextChange)==null||n.call(r,t.target.value)}})})]})},sjt=({open:r,children:e,title:t,onClose:n})=>r?ut.jsx("div",{className:"rf-fixed rf-inset-0 rf-bg-black rf-bg-opacity-50 rf-flex rf-justify-center rf-items-center rf-z-50",onClick:n,children:ut.jsxs("div",{className:"rf-bg-white rf-p-5 rf-rounded-lg rf-relative rf-w-11/12 rf-max-w-2xl",onClick:i=>{i.preventDefault(),i.stopPropagation()},children:[ut.jsx("h2",{className:"rf-mt-0 rf-text-md rf-pb-4",children:t}),ut.jsx("button",{type:"button",className:"rf-absolute rf-top-2 rf-right-4 rf-text-2xl rf-font-bold",onClick:n,children:"×"}),e]})}):null,ljt=({elements:r})=>{const[e,t]=pt.useState({open:!1}),[n,i]=pt.useReducer((u,A)=>({...u,...A}),{}),o=[...new Set(r.map(u=>u.type))],a=r.map(u=>{const A=u[`${u.type}_id`],d=Object.fromEntries(Object.entries(u).filter(([m])=>!(m===`${u.type}_id`||!m.endsWith("_id")))),f=Object.fromEntries(Object.entries(u).filter(([m])=>!m.endsWith("_id")));return{primary_id:A,other_ids:d,...f,_og_elm:u}}),s=a.map(u=>{let A="";const d=f=>{const m=Object.keys(f.other_ids).find(_=>_.startsWith("source_"));if(!m)return`.${f.name}`;const C=m.slice(0,-3),E=a.find(_=>_.type===C&&_.primary_id===f.other_ids[m]);return E?"name"in E?`${d(E)} > .${f.name}`:`#${E.primary_id} > .${f.name}`:`??? > .${f.name}`};return"name"in u&&(A=d(u)),{...u,selector_path:A}}),l=[{key:"primary_id",name:"primary_id",renderCell:u=>ut.jsxs("div",{className:"rf-flex rf-items-center",children:[ut.jsx(z7,{text:u.primary_id,onClick:()=>i({focused_id:u.primary_id,id_search:void 0,selector_search:void 0})}),ut.jsx("span",{className:"rf-flex-grow"}),ut.jsx(z7,{text:"(JSON)",onClick:()=>t({open:!0,element:u._og_elm,title:u.primary_id})})]}),renderHeaderCell:u=>ut.jsx(H7,{column:u,onTextChange:A=>i({id_search:A}),field:n.focused_id?()=>ut.jsxs("div",{children:["Focus:"," ",ut.jsx("span",{className:"rf-underline",children:n.focused_id}),ut.jsx(z7,{text:"(unfocus)",onClick:()=>i({focused_id:void 0})})]}):void 0})},{key:"type",name:"type",renderHeaderCell:u=>ut.jsx(H7,{column:u,field:()=>ut.jsxs("select",{onChange:A=>i({component_type_filter:A.target.value}),className:"rf-border rf-rounded rf-p-1 rf-w-full",children:[ut.jsx("option",{value:"any",children:"any"},"any"),ut.jsx("option",{value:"source",children:"source"},"source"),ut.jsx("option",{value:"source/pcb",children:"source/pcb"},"source/pcb"),ut.jsx("option",{value:"source/schematic",children:"source/schematic"},"source/schematic"),o.map(A=>ut.jsx("option",{value:A,children:A},A))]})})},{key:"name",name:"name",renderHeaderCell:u=>ut.jsx(H7,{column:u,onTextChange:A=>i({name_search:A})})},{key:"selector_path",name:"selector_path",renderHeaderCell:u=>ut.jsx(H7,{column:u,onTextChange:A=>i({selector_search:A})})},{key:"other_ids",name:"other_ids",renderCell:u=>ut.jsx("div",{className:"rf-space-x-2",children:Object.entries(u.other_ids).map(([A,d])=>ut.jsx(z7,{text:d,onClick:()=>i({focused_id:d})},d))})}],c=s.filter(u=>{var A,d;return n.name_search?(d=(A=u.name)==null?void 0:A.toLowerCase())==null?void 0:d.includes(n.name_search.toLowerCase()):!0}).filter(u=>{var A;return!n.component_type_filter||n.component_type_filter==="any"?!0:n.component_type_filter==="source"?u.type.startsWith("source_"):n.component_type_filter==="source/pcb"?u.type.startsWith("source_")||u.type.startsWith("pcb_"):n.component_type_filter==="source/schematic"?u.type.startsWith("source_")||u.type.startsWith("schematic_"):(A=u.type)==null?void 0:A.includes(n.component_type_filter)}).filter(u=>n.selector_search?n.selector_search.split(" ").filter(d=>d.length>0).every(d=>{var f;return(f=u.selector_path)==null?void 0:f.includes(d)}):!0).filter(u=>{var A;return n.id_search?(A=u.primary_id)==null?void 0:A.includes(n.id_search):!0}).filter(u=>!!(!n.focused_id||u.primary_id===n.focused_id||Object.values(u.other_ids).includes(n.focused_id)));return ut.jsxs("div",{className:"rf-font-mono rf-text-xs rf-bg-white",children:[ut.jsx("div",{className:"rf-overflow-x-auto",children:ut.jsxs("table",{className:"rf-table-auto rf-w-full rf-text-left",children:[ut.jsx("thead",{children:ut.jsx("tr",{children:l.map(u=>ut.jsx("th",{className:"rf-px-4 rf-py-2 rf-border-b",children:u.renderHeaderCell?u.renderHeaderCell(u):u.name},u.key))})}),ut.jsx("tbody",{children:c.map((u,A)=>ut.jsx("tr",{className:"rf-hover:bg-gray-100",children:l.map(d=>ut.jsx("td",{className:"rf-px-4 rf-py-2 rf-border-b",children:d.renderCell?d.renderCell(u):u[d.key]},d.key))},A))})]})}),ut.jsx(sjt,{open:e.open,onClose:()=>t({open:!1}),title:e.open?e.title:"",children:ut.jsx("div",{className:"rf-bg-gray-800 rf-p-3 rf-text-white rf-rounded",children:ut.jsx("pre",{className:"rf-whitespace-pre-wrap",children:e.open?JSON.stringify(e.element,null,2):""})})})]})},cjt=(r,e)=>r==="jlcpcb"?ut.jsx("a",{className:"rf-underline rf-text-blue-500",target:"_blank",rel:"noreferrer",href:`https://jlcpcb.com/partdetail/${e}`,children:e}):e,ujt=({circuitJson:r})=>{const e=r.filter(n=>n.type==="source_component"),t=new Set;for(const n of e)if(n.supplier_part_numbers)for(const i of Object.keys(n.supplier_part_numbers))t.add(i);return ut.jsx("div",{className:"rf-overflow-x-auto",children:ut.jsxs("table",{className:"rf-w-full rf-text-left rf-text-sm",children:[ut.jsx("thead",{children:ut.jsxs("tr",{className:"rf-border-b",children:[ut.jsx("th",{className:"rf-p-2",children:"Name"}),Array.from(t).map(n=>ut.jsx("th",{className:"rf-p-2 rf-capitalize",children:n},n))]})}),ut.jsx("tbody",{children:e.map(n=>ut.jsxs("tr",{className:"rf-border-b",children:[ut.jsx("td",{className:"rf-p-2",children:n.name}),Array.from(t).map(i=>{var o,a;return ut.jsx("td",{className:"rf-p-2",children:cjt(i,((a=(o=n.supplier_part_numbers)==null?void 0:o[i])==null?void 0:a[0])||"")},i)})]},n.source_component_id))})]})})};function q6e([r,e],[t,n],{lineThickness:i=0}={}){return i===0?Z6e(r,e,t,n):Ajt(r,e,t,n)<=i}function Z6e(r,e,t,n){const i=Y7(r,e,t),o=Y7(r,e,n),a=Y7(t,n,r),s=Y7(t,n,e);return!!(i!==o&&a!==s||i===0&&V7(r,t,e)||o===0&&V7(r,n,e)||a===0&&V7(t,r,n)||s===0&&V7(t,e,n))}function Y7(r,e,t){const n=(e.y-r.y)*(t.x-e.x)-(e.x-r.x)*(t.y-e.y);return n===0?0:n>0?1:2}function V7(r,e,t){return e.x<=Math.max(r.x,t.x)&&e.x>=Math.min(r.x,t.x)&&e.y<=Math.max(r.y,t.y)&&e.y>=Math.min(r.y,t.y)}function Ajt(r,e,t,n){if(r.x===e.x&&r.y===e.y)return $9(r,t,n);if(t.x===n.x&&t.y===n.y)return $9(t,r,e);if(Z6e(r,e,t,n))return 0;const i=[$9(r,t,n),$9(e,t,n),$9(t,r,e),$9(n,r,e)];return Math.min(...i)}function $9(r,e,t){const n=(t.x-e.x)**2+(t.y-e.y)**2;if(n===0)return qT(r,e);let i=((r.x-e.x)*(t.x-e.x)+(r.y-e.y)*(t.y-e.y))/n;i=Math.max(0,Math.min(1,i));const o={x:e.x+i*(t.x-e.x),y:e.y+i*(t.y-e.y)};return qT(r,o)}function qT(r,e){const t=r.x-e.x,n=r.y-e.y;return Math.sqrt(t*t+n*n)}var djt=(r,e)=>{const t={x:e.x-r.x,y:e.y-r.y},n=Math.sqrt(t.x**2+t.y**2);return{x:t.x/n,y:t.y/n}},fjt=r=>{switch(r){case"up":return{x:0,y:1};case"down":return{x:0,y:-1};case"left":return{x:-1,y:0};case"right":return{x:1,y:0}}},hjt=Object.defineProperty,pjt=(r,e)=>{for(var t in e)hjt(r,t,{get:e[t],enumerable:!0})},X6e={};pjt(X6e,{Battery:()=>RJt,Board:()=>dJt,Capacitor:()=>hJt,Chip:()=>I7e,Constraint:()=>EJt,Crystal:()=>GJt,Cutout:()=>DJt,Diode:()=>pJt,FabricationNotePath:()=>_Jt,FabricationNoteText:()=>xJt,Footprint:()=>Fjt,Fuse:()=>gJt,Group:()=>bce,Hole:()=>c7e,Inductor:()=>kJt,Jumper:()=>mJt,Keepout:()=>Ice,Led:()=>yJt,Mosfet:()=>zJt,Net:()=>o7e,NetAlias:()=>bJt,NormalComponent:()=>L1,PcbTrace:()=>l7e,PinHeader:()=>NJt,PlatedHole:()=>vce,Port:()=>Hw,Potentiometer:()=>FJt,PowerSource:()=>vJt,PrimitiveComponent:()=>aI,PushButton:()=>LJt,Renderable:()=>$6e,Resistor:()=>IJt,Resonator:()=>PJt,SchematicBox:()=>VJt,SchematicText:()=>YJt,SilkscreenCircle:()=>SJt,SilkscreenLine:()=>QJt,SilkscreenPath:()=>s7e,SilkscreenRect:()=>wJt,SilkscreenText:()=>Cce,SmtPad:()=>yce,Subcircuit:()=>BJt,Switch:()=>HJt,Trace:()=>Yw,TraceHint:()=>y7e,Transistor:()=>OJt,Via:()=>MJt});var gjt=uC("tscircuit:renderable"),eM=["ReactSubtreesRender","PcbFootprintStringRender","InitializePortsFromChildren","CreateNetsFromProps","CreateTracesFromProps","CreateTraceHintsFromProps","SourceRender","SourceParentAttachment","PortMatching","OptimizeSelectorCache","SourceTraceRender","SourceAddConnectivityMapKey","SchematicComponentRender","SchematicPortRender","SchematicPrimitiveRender","SchematicLayout","SchematicTraceRender","SchematicReplaceNetLabelsWithSymbols","PcbComponentRender","PcbPrimitiveRender","PcbFootprintLayout","PcbPortRender","PcbPortAttachment","PcbLayout","PcbComponentSizeCalculation","PcbBoardAutoSize","PcbTraceHintRender","PcbTraceRender","PcbRouteNetIslands","PcbDesignRuleChecks","CadModelRender","PartsEngineRender"],mjt=0,$6e=class{constructor(r){Ye(this,"renderPhaseStates");Ye(this,"shouldBeRemoved",!1);Ye(this,"children");Ye(this,"isPcbPrimitive",!1);Ye(this,"isSchematicPrimitive",!1);Ye(this,"_renderId");Ye(this,"_currentRenderPhase",null);Ye(this,"_asyncEffects",[]);Ye(this,"parent",null);this._renderId=`${mjt++}`,this.children=[],this.renderPhaseStates={};for(const e of eM)this.renderPhaseStates[e]={initialized:!1,dirty:!1}}_markDirty(r){var t;this.renderPhaseStates[r].dirty=!0;const e=eM.indexOf(r);for(let n=e+1;n<eM.length;n++)this.renderPhaseStates[eM[n]].dirty=!0;(t=this.parent)!=null&&t._markDirty&&this.parent._markDirty(r)}_queueAsyncEffect(r,e){const t={promise:e(),phase:this._currentRenderPhase,effectName:r,complete:!1};this._asyncEffects.push(t),"root"in this&&this.root&&this.root.emit("asyncEffect:start",{effectName:r,componentDisplayName:this.getString(),phase:t.phase}),t.promise.then(()=>{t.complete=!0,"root"in this&&this.root&&this.root.emit("asyncEffect:end",{effectName:r,componentDisplayName:this.getString(),phase:t.phase})}).catch(n=>{console.error(`Async effect error in ${t.phase} "${r}":
|
|
13310
13310
|
${n.stack}`),t.complete=!0,"root"in this&&this.root&&this.root.emit("asyncEffect:end",{effectName:r,componentDisplayName:this.getString(),phase:t.phase,error:n.toString()})})}_emitRenderLifecycleEvent(r,e){gjt(`${r}:${e} ${this.getString()}`);const t=`renderable:renderLifecycle:${r}:${e}`,n={renderId:this._renderId,componentDisplayName:this.getString(),type:t};"root"in this&&this.root&&(this.root.emit(t,n),this.root.emit("renderable:renderLifecycle:anyEvent",{...n,type:t}))}getString(){return this.constructor.name}_hasIncompleteAsyncEffects(){return this._asyncEffects.some(r=>!r.complete)}getCurrentRenderPhase(){return this._currentRenderPhase}getRenderGraph(){return{id:this._renderId,currentPhase:this._currentRenderPhase,renderPhaseStates:this.renderPhaseStates,shouldBeRemoved:this.shouldBeRemoved,children:this.children.map(r=>r.getRenderGraph())}}runRenderCycle(){for(const r of eM)this.runRenderPhaseForChildren(r),this.runRenderPhase(r)}runRenderPhase(r){var o,a,s;this._currentRenderPhase=r;const e=this.renderPhaseStates[r],t=e.initialized,n=e.dirty;if(!t&&this.shouldBeRemoved)return;if(this.shouldBeRemoved&&t){this._emitRenderLifecycleEvent(r,"start"),(o=this==null?void 0:this[`remove${r}`])==null||o.call(this),e.initialized=!1,e.dirty=!1,this._emitRenderLifecycleEvent(r,"end");return}const i=eM.indexOf(r)-1;if(i>=0){const l=eM[i];if(this._asyncEffects.filter(u=>u.phase===l).some(u=>!u.complete))return}if(this._emitRenderLifecycleEvent(r,"start"),t){n&&((a=this==null?void 0:this[`update${r}`])==null||a.call(this),e.dirty=!1),this._emitRenderLifecycleEvent(r,"end");return}e.dirty=!1,(s=this==null?void 0:this[`doInitial${r}`])==null||s.call(this),e.initialized=!0,this._emitRenderLifecycleEvent(r,"end")}runRenderPhaseForChildren(r){for(const e of this.children)e.runRenderPhaseForChildren(r),e.runRenderPhase(r)}renderError(r){throw typeof r=="string"?new Error(r):new Error(JSON.stringify(r,null,2))}},K7={},e7e=r=>{const e=Object.fromEntries(Object.entries(r).map(([t,n])=>[t.toLowerCase(),n]));Object.assign(K7,r),Object.assign(K7,e)},yjt=class extends Error{constructor(r,e,t){let n;const o=Object.keys(t).filter(a=>a!=="_errors").map(a=>t[a]._errors[0]?`${a} (${t[a]._errors[0]})`:`${a} (${JSON.stringify(t[a])})`).join(", ");"name"in e?n=`Invalid props for ${r} "${e.name}": ${o}`:"footprint"in e&&typeof e.footprint=="string"?n=`Invalid props for ${r} (unnamed ${e.footprint} component): ${o}`:n=`Invalid props for ${r} (unnamed): ${o}`,super(n),this.componentName=r,this.originalProps=e,this.formattedError=t}};function pce(r,e){const t=e.match(/^#(\w+)/);if(t)return r.props.id===t[1];const n=e.match(/^\.(\w+)/);if(n)return r.isMatchingNameOrAlias(n[1]);let[i,...o]=e.split(/(?=[#.[])/);return i==="pin"&&(i="port"),i&&i!=="*"&&r.lowercaseComponentName!==i.toLowerCase()?!1:o.every(a=>{if(a.startsWith("#"))return r.props.id===a.slice(1);if(a.startsWith("."))return r.isMatchingNameOrAlias(a.slice(1));const s=a.match(/\[(\w+)=['"]?(.+?)['"]?\]/);if(!s)return!0;const[,l,c]=s;return r.props[l].toString()===c})}var gce={isTag:r=>!0,getParent:r=>r.parent,getChildren:r=>r.children,getName:r=>r.lowercaseComponentName,getAttributeValue:(r,e)=>{var t;if(e==="class"&&"getNameAndAliases"in r)return r.getNameAndAliases().join(" ");if(e==="name"&&((t=r._parsedProps)!=null&&t.name))return r._parsedProps.name;if(r._parsedProps&&e in r._parsedProps){const n=r._parsedProps[e];return typeof n=="string"?n:n!=null?String(n):null}return null},hasAttrib:(r,e)=>{var t;return e==="class"?!!((t=r._parsedProps)!=null&&t.name):r._parsedProps&&e in r._parsedProps},getSiblings:r=>r.parent?r.parent.children:[],prevElementSibling:r=>{if(!r.parent)return null;const e=r.parent.children,t=e.indexOf(r);return t>0?e[t-1]:null},getText:()=>"",removeSubsets:r=>r.filter((e,t)=>!r.some((n,i)=>t!==i&&n!==e&&n.getDescendants().includes(e))),existsOne:(r,e)=>e.some(r),findAll:(r,e)=>{const t=[],n=i=>{r(i)&&t.push(i);for(const o of i.children)n(o)};for(const i of e)n(i);return t},findOne:(r,e)=>{for(const t of e){if(r(t))return t;const n=t.children;if(n.length>0){const i=gce.findOne(r,n);if(i)return i}}return null},equals:(r,e)=>r._renderId===e._renderId,isHovered:r=>!1,isVisited:r=>!1,isActive:r=>!1},vjt={...gce,getChildren:r=>r.children.filter(e=>!e.isSubcircuit)},t7e={...gce,getChildren:r=>r.children.filter(e=>e.isSubcircuit)},n7e=r=>{if(/net\.[^\s>]*\./.test(r))throw new Error('Net names cannot contain a period, try using "sel.net..." to autocomplete with conventional net names, e.g. V3_3');if(/net\.[0-9]/.test(r))throw new Error('Net names cannot start with a number, try using a prefix like "VBUS1"');return r.replace(/ pin/g," port").replace(/ subcircuit\./g," group[isSubcircuit=true]").replace(/([^ ])\>([^ ])/g,"$1 > $2").replace(/(^|[ >])(?!pin\.)(?!port\.)(?!net\.)([A-Z][A-Za-z0-9_-]*)\.([A-Za-z0-9_-]+)/g,(e,t,n,i)=>{const o=/^\d+$/.test(i)?`pin${i}`:i;return`${t}.${n} > .${o}`}).trim()},mce={adapter:vjt,cacheResults:!0},aI=class extends $6e{constructor(e){super(e);Ye(this,"parent",null);Ye(this,"children");Ye(this,"childrenPendingRemoval");Ye(this,"props");Ye(this,"_parsedProps");Ye(this,"externallyAddedAliases");Ye(this,"isPrimitiveContainer",!1);Ye(this,"source_group_id",null);Ye(this,"source_component_id",null);Ye(this,"schematic_component_id",null);Ye(this,"pcb_component_id",null);Ye(this,"cad_component_id",null);Ye(this,"_cachedSelectAllQueries",new Map);Ye(this,"_cachedSelectOneQueries",new Map);this.children=[],this.childrenPendingRemoval=[],this.props=e??{},this.externallyAddedAliases=[];const t=this.config.zodProps.safeParse(e??{});if(t.success)this._parsedProps=t.data;else throw new yjt(this.lowercaseComponentName,this.props,t.error.format())}get config(){return{componentName:"",zodProps:Pn({}).passthrough()}}get componentName(){return this.config.componentName}getInheritedProperty(e){var n;let t=this;for(;t;){if(t._parsedProps&&e in t._parsedProps)return t._parsedProps[e];t=t.parent}if((n=this.root)!=null&&n.platform&&e in this.root.platform)return this.root.platform[e]}get lowercaseComponentName(){return this.componentName.toLowerCase()}get isSubcircuit(){var e;return!!this.props.subcircuit||this.lowercaseComponentName==="group"&&((e=this==null?void 0:this.parent)==null?void 0:e.isRoot)}get isGroup(){return this.lowercaseComponentName==="group"}setProps(e){var i,o;const t=this.config.zodProps.parse({...this.props,...e}),n=this.props;this.props=t,this._parsedProps=this.config.zodProps.parse(e),this.onPropsChange({oldProps:n,newProps:t,changedProps:Object.keys(e)}),(o=(i=this.parent)==null?void 0:i.onChildChanged)==null||o.call(i,this)}computePcbPropsTransform(){const{_parsedProps:e}=this;return Ku($d(e.pcbX??0,e.pcbY??0),$x((e.pcbRotation??0)*Math.PI/180))}_computePcbGlobalTransformBeforeLayout(){var n,i,o;const{_parsedProps:e}=this,t=this.getSubcircuit()._getPcbManualPlacementForComponent(this);if(t&&this.props.pcbX===void 0&&this.props.pcbY===void 0)return Ku(((n=this.parent)==null?void 0:n._computePcbGlobalTransformBeforeLayout())??Ny(),Ku($d(t.x,t.y),$x((e.pcbRotation??0)*Math.PI/180)));if(this.isPcbPrimitive){const a=this.getPrimitiveContainer();if(a){const s=a._parsedProps.layer==="bottom",l=a._getGlobalPcbPositionBeforeLayout();if(s)return Ku($d(l.x,l.y),j3(),$d(-l.x,-l.y)),Ku(((i=this.parent)==null?void 0:i._computePcbGlobalTransformBeforeLayout())??Ny(),j3(),this.computePcbPropsTransform())}}return Ku(((o=this.parent)==null?void 0:o._computePcbGlobalTransformBeforeLayout())??Ny(),this.computePcbPropsTransform())}getPrimitiveContainer(){var e,t;return this.isPrimitiveContainer?this:((t=(e=this.parent)==null?void 0:e.getPrimitiveContainer)==null?void 0:t.call(e))??null}_getPcbCircuitJsonBounds(){return{center:{x:0,y:0},bounds:{left:0,top:0,right:0,bottom:0},width:0,height:0}}_getPcbPrimitiveFlippedHelpers(){const e=this.getPrimitiveContainer(),t=e?e._parsedProps.layer==="bottom":!1;return{isFlipped:t,maybeFlipLayer:i=>t?i==="top"?"bottom":"top":i}}_setPositionFromLayout(e){throw new Error(`_setPositionFromLayout not implemented for ${this.componentName}`)}computeSchematicPropsTransform(){const{_parsedProps:e}=this;return Ku($d(e.schX??0,e.schY??0))}computeSchematicGlobalTransform(){var t,n;const e=this._getSchematicGlobalManualPlacementTransform(this);return e||Ku(((n=(t=this.parent)==null?void 0:t.computeSchematicGlobalTransform)==null?void 0:n.call(t))??Ny(),this.computeSchematicPropsTransform())}_getSchematicSymbolName(){const{_parsedProps:e}=this,t=this.config.schematicSymbolName;let n=e.schRotation;if(n===void 0&&(n=0),n=n%360,n<0&&(n+=360),e.schRotation!==void 0&&n%90!==0)throw new Error(`Schematic rotation ${e.schRotation} is not supported for ${this.componentName}`);const i=`${t}_horz`,o=`${t}_vert`,a=`${t}_up`,s=`${t}_down`,l=`${t}_left`,c=`${t}_right`;if(c in SI&&n===0)return c;if(a in SI&&n===90)return a;if(l in SI&&n===180)return l;if(s in SI&&n===270)return s;if(i in SI&&(n===0||n===180))return i;if(o in SI&&(n===90||n===270))return o;if(t in SI)return t}_getSchematicSymbolNameOrThrow(){const e=this._getSchematicSymbolName();if(!e)throw new Error(`No schematic symbol found (given: "${this.config.schematicSymbolName}")`);return e}getSchematicSymbol(){const e=this._getSchematicSymbolName();return e?SI[e]??null:null}_getPcbManualPlacementForComponent(e){var o;if(!this.isSubcircuit)return null;const t=this.props.layout,n=this.props.manualEdits;if(!t&&!n)return null;const i=((o=t==null?void 0:t.manual_pcb_placement_config)==null?void 0:o.positions)||(n==null?void 0:n.pcb_placements);if(!i)return null;for(const a of i)if(t&&pce(e,a.selector)||e.props.name===a.selector)return Xr(this._computePcbGlobalTransformBeforeLayout(),a.center);return null}_getSchematicManualPlacementForComponent(e){if(!this.isSubcircuit)return null;const t=this.props.manualEdits;if(!t)return null;const n=t.schematic_placements;if(!n)return null;for(const i of n)if(pce(e,i.selector)||e.props.name===i.selector)return Xr(this.computeSchematicGlobalTransform(),i.center);return null}_getSchematicGlobalManualPlacementTransform(e){var n,i;const t=(n=this.getSubcircuit())==null?void 0:n._parsedProps.manualEdits;if(!t)return null;for(const o of t.schematic_placements??[])if((pce(e,o.selector)||e.props.name===o.selector)&&o.relative_to==="group_center")return Ku(((i=this.parent)==null?void 0:i._computePcbGlobalTransformBeforeLayout())??Ny(),$d(o.center.x,o.center.y));return null}_getGlobalPcbPositionBeforeLayout(){return Xr(this._computePcbGlobalTransformBeforeLayout(),{x:0,y:0})}_getGlobalSchematicPositionBeforeLayout(){return Xr(this.computeSchematicGlobalTransform(),{x:0,y:0})}get root(){var e;return((e=this.parent)==null?void 0:e.root)??null}onAddToParent(e){this.parent=e}onPropsChange(e){}onChildChanged(e){var t,n;(n=(t=this.parent)==null?void 0:t.onChildChanged)==null||n.call(t,e)}add(e){if(!e.onAddToParent)throw new Error(`Invalid JSX Element: Expected a React component but received "${JSON.stringify(e)}"`);e.onAddToParent(this),e.parent=this,this.children.push(e)}addAll(e){for(const t of e)this.add(t)}remove(e){this.children=this.children.filter(t=>t!==e),this.childrenPendingRemoval.push(e),e.shouldBeRemoved=!0}getSubcircuitSelector(){const e=this._parsedProps.name,t=e?`${this.lowercaseComponentName}.${e}`:this.lowercaseComponentName;return!this.parent||this.parent.isSubcircuit?t:`${this.parent.getSubcircuitSelector()} > ${t}`}getFullPathSelector(){var i,o;const e=this._parsedProps.name,t=e?`${this.lowercaseComponentName}.${e}`:this.lowercaseComponentName,n=(o=(i=this.parent)==null?void 0:i.getFullPathSelector)==null?void 0:o.call(i);return n?`${n} > ${t}`:t}getNameAndAliases(){return[this._parsedProps.name,...this._parsedProps.portHints??[]].filter(Boolean)}isMatchingNameOrAlias(e){return this.getNameAndAliases().includes(e)}isMatchingAnyOf(e){return this.getNameAndAliases().some(t=>e.map(n=>n.toString()).includes(t))}getPcbSize(){throw new Error(`getPcbSize not implemented for ${this.componentName}`)}doesSelectorMatch(e){const t=[this.componentName,this.lowercaseComponentName],n=[this._parsedProps.name].filter(Boolean),i=e.trim().split(/\> /)[0],o=i[0];return i.length>1?!1:!!(e==="*"||e[0]==="#"&&e.slice(1)===this.props.id||e[0]==="."&&n.includes(e.slice(1))||/^[a-zA-Z0-9_]/.test(o)&&t.includes(o))}getSubcircuit(){var t,n;if(this.isSubcircuit)return this;const e=(n=(t=this.parent)==null?void 0:t.getSubcircuit)==null?void 0:n.call(t);if(!e)throw new Error("Component is not inside an opaque group (no board?)");return e}getGroup(){var e,t;return this.isGroup?this:((t=(e=this.parent)==null?void 0:e.getGroup)==null?void 0:t.call(e))??null}doInitialOptimizeSelectorCache(){var t;if(!this.isSubcircuit)return;const e=this.selectAll("port");for(const n of e){const i=(t=n.parent)==null?void 0:t.getNameAndAliases(),o=n.getNameAndAliases();if(i)for(const a of i)for(const s of o){const l=[`.${a} > .${s}`,`.${a} .${s}`];for(const c of l){const u=this._cachedSelectAllQueries.get(c);u?u.push(n):this._cachedSelectAllQueries.set(c,[n])}}}for(const[n,i]of this._cachedSelectAllQueries.entries())i.length===1&&this._cachedSelectOneQueries.set(n,i[0])}selectAll(e){if(this._cachedSelectAllQueries.has(e))return this._cachedSelectAllQueries.get(e);const t=n7e(e),n=qG(t,this,mce);if(n.length>0)return this._cachedSelectAllQueries.set(e,n),n;const[i,...o]=t.split(" "),a=oR(i,this,{adapter:t7e});if(!a)return[];const s=a.selectAll(o.join(" "));return this._cachedSelectAllQueries.set(e,s),s}selectOne(e,t){if(this._cachedSelectOneQueries.has(e))return this._cachedSelectOneQueries.get(e);const n=n7e(e);t!=null&&t.port&&(t.type="port");let i=null;if(t!=null&&t.type&&(i=qG(n,this,mce).find(c=>c.lowercaseComponentName===t.type)),i??(i=oR(n,this,mce)),i)return this._cachedSelectOneQueries.set(e,i),i;const[o,...a]=n.split(" "),s=oR(o,this,{adapter:t7e});return s?(i=s.selectOne(a.join(" "),t),this._cachedSelectOneQueries.set(e,i),i):null}getAvailablePcbLayers(){var e,t;if(this.isPcbPrimitive){const{maybeFlipLayer:n}=this._getPcbPrimitiveFlippedHelpers();return"layer"in this._parsedProps||this.componentName==="SmtPad"?[n(this._parsedProps.layer??"top")]:"layers"in this._parsedProps?this._parsedProps.layers:this.componentName==="PlatedHole"?((t=(e=this.root)==null?void 0:e._getBoard())==null?void 0:t.allLayers)??["top","bottom"]:[]}return[]}getDescendants(){const e=[];for(const t of this.children)e.push(t),e.push(...t.getDescendants());return e}getSelectableDescendants(){const e=[];for(const t of this.children)t.isSubcircuit?e.push(t):(e.push(t),e.push(...t.getSelectableDescendants()));return e}_getPinCount(){return 0}_getSchematicBoxDimensions(){return null}_getSchematicBoxComponentDimensions(){if(this.getSchematicSymbol()||!this.config.shouldRenderAsSchematicBox)return null;const{_parsedProps:e}=this;return{schWidth:e.schWidth,schHeight:e.schHeight}}renderError(e){var t;if(typeof e=="string")return super.renderError(e);(t=this.root)==null||t.db.pcb_placement_error.insert(e)}getString(){var i,o;const{lowercaseComponentName:e,_parsedProps:t,parent:n}=this;return(t==null?void 0:t.pinNumber)!==void 0&&((i=n==null?void 0:n.props)!=null&&i.name)&&(t!=null&&t.name)?`<${e}#${this._renderId}(pin:${t.pinNumber} .${n==null?void 0:n.props.name}>.${t.name}) />`:(o=n==null?void 0:n.props)!=null&&o.name&&(t!=null&&t.name)?`<${e}#${this._renderId}(.${n==null?void 0:n.props.name}>.${t==null?void 0:t.name}) />`:t!=null&&t.from&&(t!=null&&t.to)?`<${e}#${this._renderId}(from:${t.from} to:${t==null?void 0:t.to}) />`:t!=null&&t.name?`<${e}#${this._renderId} name=".${t==null?void 0:t.name}" />`:t!=null&&t.portHints?`<${e}#${this._renderId}(${t.portHints.map(a=>`.${a}`).join(", ")}) />`:`<${e}#${this._renderId} />`}get[Symbol.toStringTag](){return this.getString()}[Symbol.for("nodejs.util.inspect.custom")](){return this.getString()}},Ijt=class extends aI{constructor(r,e){super(r),this._parsedProps={...r,error:e,type:r.type||"unknown",component_name:r.name,error_type:"source_failed_to_create_component_error",message:e instanceof Error?e.message:String(e),pcbX:r.pcbX,pcbY:r.pcbY,schX:r.schX,schY:r.schY}}get config(){return{componentName:"ErrorPlaceholder",zodProps:Pn({}).passthrough()}}doInitialSourceRender(){var r,e,t,n;if((r=this.root)!=null&&r.db){const i=this._getGlobalPcbPositionBeforeLayout(),o=this._getGlobalSchematicPositionBeforeLayout();this.root.db.source_failed_to_create_component_error.insert({component_name:this._parsedProps.component_name,message:((n=(t=(e=this._parsedProps.error)==null?void 0:e.formattedError)==null?void 0:t._errors)==null?void 0:n.join("; "))||this._parsedProps.message,pcb_center:i,schematic_center:o})}}};function Cjt(r,e){return new Ijt(r,e)}function Ejt(r,e){const t=r;return t.__tsci={...e},r}var r7e={supportsMutation:!0,createInstance(r,e){const t=K7[r];if(!t)throw Object.keys(K7).length===0?new Error("No components registered in catalogue, did you forget to import lib/register-catalogue in your test file?"):new Error(`Unsupported component type (not registered in @tscircuit/core catalogue): "${r}" See CREATING_NEW_COMPONENTS.md`);try{return Ejt(new t(e),{})}catch(n){return Cjt(e,n)}},createTextInstance(){return{}},appendInitialChild(r,e){r.add(e)},appendChild(r,e){r.add(e)},appendChildToContainer(r,e){r.add(e)},finalizeInitialChildren(){return!1},prepareUpdate(){return null},shouldSetTextContent(){return!1},getRootHostContext(){return{}},getChildHostContext(){return{}},prepareForCommit(){return null},resetAfterCommit(){},commitMount(){},commitUpdate(){},removeChild(){},clearContainer(){},supportsPersistence:!1,getPublicInstance(r){return r},preparePortalMount(r){throw new Error("Function not implemented.")},scheduleTimeout(r,e){throw new Error("Function not implemented.")},cancelTimeout(r){throw new Error("Function not implemented.")},noTimeout:void 0,isPrimaryRenderer:!1,getInstanceFromNode(r){throw new Error("Function not implemented.")},beforeActiveInstanceBlur(){throw new Error("Function not implemented.")},afterActiveInstanceBlur(){throw new Error("Function not implemented.")},prepareScopeUpdate:(r,e)=>{throw new Error("Function not implemented.")},getInstanceFromScope:r=>{throw new Error("Function not implemented.")},detachDeletedInstance:r=>{throw new Error("Function not implemented.")},getCurrentEventPriority:()=>tR.DefaultEventPriority,getCurrentUpdatePriority:()=>tR.DefaultEventPriority,resolveUpdatePriority:()=>tR.DefaultEventPriority,setCurrentUpdatePriority:()=>{},maySuspendCommit:()=>!1,supportsHydration:!1},tM;Jh.version.startsWith("19.")?tM=a5e(r7e):tM=u5e(r7e);var _jt=r=>{const e={children:[],props:{name:"$root"},add(o){o.parent=this,this.children.push(o)},computePcbGlobalTransform(){return Ny()}},t=[],n=tM.createContainer(e,0,null,!1,null,"tsci",o=>{console.log("Error in createContainer"),console.error(o),t.push(o)},null);if(Jh.version.startsWith("19.")?(tM.updateContainerSync(r,n,null,()=>{}),tM.flushSyncWork()):tM.updateContainer(r,n,null,()=>{}),t.length>0)throw t[0];const i=tM.getPublicRootInstance(n);return i||e.children[0]},ZT=(r,e)=>{if(typeof r=="number")return r;if(r.startsWith("pin"))return Number(r.slice(3));if(!e)throw new Error(`No pin labels provided and pin number or label is not a number: "${r}"`);for(const t in e)if((Array.isArray(e[t])?e[t]:[e[t]]).includes(r))return Number(t.replace("pin",""));throw new Error(`No pin labels provided and pin number or label is not a number: "${r}"`)},xjt=(r,e)=>{if(!r)return;const t={},n={};for(const[i,o]of Object.entries(r)){const a=ZT(i,e);n[a]={...n[a],...o}}for(const[i,o]of Object.entries(n)){const a=`pin${i}`;t[a]={bottom_margin:o.bottomMargin,left_margin:o.leftMargin,right_margin:o.rightMargin,top_margin:o.topMargin}}return t},Bjt=r=>{if(r){if("leftSide"in r||"rightSide"in r||"topSide"in r||"bottomSide"in r)return{left_side:r.leftSide,right_side:r.rightSide,top_side:r.topSide,bottom_side:r.bottomSide};if("leftPinCount"in r||"rightPinCount"in r||"topPinCount"in r||"bottomPinCount"in r)return{left_size:r.leftPinCount,right_size:r.rightPinCount,top_size:r.topPinCount,bottom_size:r.bottomPinCount};if("leftSize"in r||"rightSize"in r||"topSize"in r||"bottomSize"in r)return{left_size:r.leftSize,right_size:r.rightSize,top_size:r.topSize,bottom_size:r.bottomSize}}};function i7e(r){const e=[];for(let t=0;t<r.length-1;t++)e.push([r[t],r[t+1]]);return e}var bjt=Pn({name:Pe()}),o7e=class extends aI{constructor(){super(...arguments);Ye(this,"source_net_id")}get config(){return{componentName:"Net",zodProps:bjt}}getPortSelector(){return`net.${this.props.name}`}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_net.insert({name:t.name,member_source_group_ids:[]});this.source_net_id=n.source_net_id}doInitialSourceParentAttachment(){const e=this.getSubcircuit();if(!e)return;const{db:t}=this.root;t.source_net.update(this.source_net_id,{subcircuit_id:e.subcircuit_id})}getAllConnectedPorts(){const e=this.getSubcircuit().selectAll("port"),t=[];for(const n of e){const i=n._getDirectlyConnectedTraces();for(const o of i)if(o._isExplicitlyConnectedToNet(this)){t.push(n);break}}return t}_getAllDirectlyConnectedTraces(){const e=this.getSubcircuit().selectAll("trace"),t=[];for(const n of e)n._isExplicitlyConnectedToNet(this)&&t.push(n);return t}doInitialPcbRouteNetIslands(){var a;if((a=this.root)!=null&&a.pcbDisabled||this.getSubcircuit()._parsedProps.routingDisabled||this.getSubcircuit()._getAutorouterConfig().groupMode!=="sequential-trace")return;const{db:e}=this.root,{_parsedProps:t}=this,n=this._getAllDirectlyConnectedTraces().filter(s=>{var l;return(((l=s._portsRoutedOnPcb)==null?void 0:l.length)??0)>0}),i=[];for(const s of n){const l=s._portsRoutedOnPcb,c=i.find(u=>l.some(A=>u.ports.includes(A)));if(!c){i.push({ports:[...l],traces:[s]});continue}c.traces.push(s),c.ports.push(...l)}if(i.length===0)return;const o=i7e(i);for(const[s,l]of o){const c=s.ports.map(x=>x._getGlobalPcbPositionBeforeLayout()),u=l.ports.map(x=>x._getGlobalPcbPositionBeforeLayout());let A=1/0,d=[-1,-1];for(let x=0;x<c.length;x++){const w=c[x];for(let P=0;P<u.length;P++){const L=u[P],O=Math.sqrt((w.x-L.x)**2+(w.y-L.y)**2);O<A&&(A=O,d=[x,P])}}const f=s.ports[d[0]],m=l.ports[d[1]],C=e.toArray().filter(x=>x.type==="pcb_smtpad"||x.type==="pcb_trace"||x.type==="pcb_plated_hole"||x.type==="pcb_hole"||x.type==="source_port"||x.type==="pcb_port"),{solution:E}=CPe(C.concat([{type:"source_trace",source_trace_id:"__net_trace_tmp",connected_source_port_ids:[f.source_port_id,m.source_port_id]}])),_=E[0];if(!_){this.renderError({pcb_trace_error_id:"",pcb_trace_id:"__net_trace_tmp",pcb_component_ids:[f.pcb_component_id,m.pcb_component_id].filter(Boolean),pcb_port_ids:[f.pcb_port_id,m.pcb_port_id].filter(Boolean),type:"pcb_trace_error",error_type:"pcb_trace_error",message:`Failed to route net islands for "${this.getString()}"`,source_trace_id:"__net_trace_tmp"});return}e.pcb_trace.insert(_)}}renderError(e){var t;if(typeof e=="string")return super.renderError(e);(t=this.root)==null||t.db.pcb_trace_error.insert(e)}},a7e=(r,e)=>{for(const t of e)if(typeof t=="string"&&t.startsWith("net.")){if(/net\.[^\s>]*\./.test(t))throw new Error('Net names cannot contain a period, try using "sel.net..." to autocomplete with conventional net names, e.g. V3_3');if(/net\.[0-9]/.test(t))throw new Error('Net names cannot start with a number, try using a prefix like "VBUS1"');const n=r.getSubcircuit();if(!n.selectOne(t)){const i=new o7e({name:t.split("net.")[1]});n.add(i)}}},yce=class extends aI{constructor(){super(...arguments);Ye(this,"pcb_smtpad_id",null);Ye(this,"matchedPort",null);Ye(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SmtPad",zodProps:UPe}}getPcbSize(){const{_parsedProps:e}=this;if(e.shape==="circle")return{width:e.radius*2,height:e.radius*2};if(e.shape==="rect")return{width:e.width,height:e.height};throw new Error(`getPcbSize for shape "${e.shape}" not implemented for ${this.componentName}`)}doInitialPortMatching(){var t;const e=(t=this.getPrimitiveContainer())==null?void 0:t.selectAll("port");if(this.props.portHints){for(const n of e)if(n.isMatchingAnyOf(this.props.portHints)){this.matchedPort=n,n.registerMatch(this);return}}}doInitialPcbPrimitiveRender(){var d,f,m,C,E,_,x,w,P,L;if((d=this.root)!=null&&d.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this;if(!t.portHints)return;const n=this.getPrimitiveContainer(),i=this.getSubcircuit(),o=this._getGlobalPcbPositionBeforeLayout();n==null||n._getGlobalPcbPositionBeforeLayout();const a=YM(this._computePcbGlobalTransformBeforeLayout()),s=Math.abs(a.rotation.angle*(180/Math.PI)-90)%180<.01,{maybeFlipLayer:l}=this._getPcbPrimitiveFlippedHelpers(),c=(n==null?void 0:n._parsedProps.pcbRotation)??0;let u=null;const A=((f=this.parent)==null?void 0:f.pcb_component_id)??((m=this.getPrimitiveContainer())==null?void 0:m.pcb_component_id);t.shape==="circle"?(u=e.pcb_smtpad.insert({pcb_component_id:A,pcb_port_id:(C=this.matchedPort)==null?void 0:C.pcb_port_id,layer:l(t.layer??"top"),shape:"circle",radius:t.radius,port_hints:t.portHints.map(O=>O.toString()),x:o.x,y:o.y,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0}),e.pcb_solder_paste.insert({layer:u.layer,shape:"circle",radius:u.radius*.7,x:u.x,y:u.y,pcb_component_id:u.pcb_component_id,pcb_smtpad_id:u.pcb_smtpad_id,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((E=this.getGroup())==null?void 0:E.pcb_group_id)??void 0})):t.shape==="rect"&&(u=c===0||s?e.pcb_smtpad.insert({pcb_component_id:A,pcb_port_id:(_=this.matchedPort)==null?void 0:_.pcb_port_id,layer:l(t.layer??"top"),shape:"rect",width:s?t.height:t.width,height:s?t.width:t.height,port_hints:t.portHints.map(O=>O.toString()),x:o.x,y:o.y,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((x=this.getGroup())==null?void 0:x.pcb_group_id)??void 0}):e.pcb_smtpad.insert({pcb_component_id:A,layer:l(t.layer??"top"),shape:"rotated_rect",width:t.width,height:t.height,x:o.x,y:o.y,ccw_rotation:c,port_hints:t.portHints.map(O=>O.toString()),subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((w=this.getGroup())==null?void 0:w.pcb_group_id)??void 0}),u.shape==="rect"&&e.pcb_solder_paste.insert({layer:l(t.layer??"top"),shape:"rect",width:u.width*.7,height:u.height*.7,x:u.x,y:u.y,pcb_component_id:u.pcb_component_id,pcb_smtpad_id:u.pcb_smtpad_id,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((P=this.getGroup())==null?void 0:P.pcb_group_id)??void 0}),u.shape==="rotated_rect"&&e.pcb_solder_paste.insert({layer:l(t.layer??"top"),shape:"rotated_rect",width:u.width*.7,height:u.height*.7,x:u.x,y:u.y,ccw_rotation:c,pcb_component_id:u.pcb_component_id,pcb_smtpad_id:u.pcb_smtpad_id,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((L=this.getGroup())==null?void 0:L.pcb_group_id)??void 0})),u&&(this.pcb_smtpad_id=u.pcb_smtpad_id)}doInitialPcbPortAttachment(){var t,n;if((t=this.root)!=null&&t.pcbDisabled)return;const{db:e}=this.root;e.pcb_smtpad.update(this.pcb_smtpad_id,{pcb_port_id:(n=this.matchedPort)==null?void 0:n.pcb_port_id})}_getPcbCircuitJsonBounds(){const{db:e}=this.root,t=e.pcb_smtpad.get(this.pcb_smtpad_id);if(t.shape==="rect")return{center:{x:t.x,y:t.y},bounds:{left:t.x-t.width/2,top:t.y+t.height/2,right:t.x+t.width/2,bottom:t.y-t.height/2},width:t.width,height:t.height};if(t.shape==="rotated_rect"){const n=t.ccw_rotation*Math.PI/180,i=Math.cos(n),o=Math.sin(n),a=t.width/2,s=t.height/2,l=Math.abs(a*i)+Math.abs(s*o),c=Math.abs(a*o)+Math.abs(s*i);return{center:{x:t.x,y:t.y},bounds:{left:t.x-l,right:t.x+l,top:t.y-c,bottom:t.y+c},width:l*2,height:c*2}}if(t.shape==="circle")return{center:{x:t.x,y:t.y},bounds:{left:t.x-t.radius,top:t.y-t.radius,right:t.x+t.radius,bottom:t.y+t.radius},width:t.radius*2,height:t.radius*2};throw new Error(`circuitJson bounds calculation not implemented for shape "${t.shape}"`)}_setPositionFromLayout(e){var i;const{db:t}=this.root;t.pcb_smtpad.update(this.pcb_smtpad_id,{x:e.x,y:e.y});const n=t.pcb_solder_paste.list().find(o=>o.pcb_smtpad_id===this.pcb_smtpad_id);t.pcb_solder_paste.update(n==null?void 0:n.pcb_solder_paste_id,{x:e.x,y:e.y}),(i=this.matchedPort)==null||i._setPositionFromLayout(e)}},s7e=class extends aI{constructor(){super(...arguments);Ye(this,"pcb_silkscreen_path_id",null);Ye(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenPath",zodProps:o8e}}doInitialPcbPrimitiveRender(){var l,c,u;if((l=this.root)!=null&&l.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,{maybeFlipLayer:n}=this._getPcbPrimitiveFlippedHelpers(),i=n(t.layer??"top");if(i!=="top"&&i!=="bottom")throw new Error(`Invalid layer "${i}" for SilkscreenPath. Must be "top" or "bottom".`);const o=this._computePcbGlobalTransformBeforeLayout(),a=this.getSubcircuit(),s=e.pcb_silkscreen_path.insert({pcb_component_id:(c=this.parent)==null?void 0:c.pcb_component_id,layer:i,route:t.route.map(A=>{const d=Xr(o,{x:A.x,y:A.y});return{...A,x:d.x,y:d.y}}),stroke_width:t.strokeWidth??.1,subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((u=this.getGroup())==null?void 0:u.pcb_group_id)??void 0});this.pcb_silkscreen_path_id=s.pcb_silkscreen_path_id}getPcbSize(){const{_parsedProps:e}=this;if(!e.route||e.route.length===0)return{width:0,height:0};let t=1/0,n=-1/0,i=1/0,o=-1/0;for(const a of e.route)t=Math.min(t,a.x),n=Math.max(n,a.x),i=Math.min(i,a.y),o=Math.max(o,a.y);return{width:n-t,height:o-i}}},Sjt=Pn({route:lo(i8),source_trace_id:Pe().optional()}),l7e=class extends aI{constructor(){super(...arguments);Ye(this,"pcb_trace_id",null);Ye(this,"isPcbPrimitive",!0)}get config(){return{componentName:"PcbTrace",zodProps:Sjt}}doInitialPcbPrimitiveRender(){var c,u;if((c=this.root)!=null&&c.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this.getPrimitiveContainer(),i=this.getSubcircuit(),{maybeFlipLayer:o}=this._getPcbPrimitiveFlippedHelpers(),a=this._computePcbGlobalTransformBeforeLayout(),s=t.route.map(A=>{const{x:d,y:f,...m}=A,C=Xr(a,{x:d,y:f});return A.route_type==="wire"&&A.layer?{...C,...m,layer:o(A.layer)}:{...C,...m}}),l=e.pcb_trace.insert({pcb_component_id:n.pcb_component_id,source_trace_id:t.source_trace_id,route:s,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((u=this.getGroup())==null?void 0:u.pcb_group_id)??void 0});this.pcb_trace_id=l.pcb_trace_id}getPcbSize(){const{_parsedProps:e}=this;if(!e.route||e.route.length===0)return{width:0,height:0};let t=1/0,n=-1/0,i=1/0,o=-1/0;for(const a of e.route)t=Math.min(t,a.x),n=Math.max(n,a.x),i=Math.min(i,a.y),o=Math.max(o,a.y),a.route_type==="wire"&&(t=Math.min(t,a.x-a.width/2),n=Math.max(n,a.x+a.width/2),i=Math.min(i,a.y-a.width/2),o=Math.max(o,a.y+a.width/2));return t===1/0||n===-1/0||i===1/0||o===-1/0?{width:0,height:0}:{width:n-t,height:o-i}}},vce=class extends aI{constructor(){super(...arguments);Ye(this,"pcb_plated_hole_id",null);Ye(this,"matchedPort",null);Ye(this,"isPcbPrimitive",!0)}get config(){return{componentName:"PlatedHole",zodProps:QPe}}getAvailablePcbLayers(){return["top","inner1","inner2","bottom"]}getPcbSize(){const{_parsedProps:e}=this;if(e.shape==="circle")return{width:e.outerDiameter,height:e.outerDiameter};if(e.shape==="oval"||e.shape==="pill")return{width:e.outerWidth,height:e.outerHeight};if(e.shape==="circular_hole_with_rect_pad")return{width:e.rectPadWidth,height:e.rectPadHeight};if(e.shape==="pill_hole_with_rect_pad")return{width:e.rectPadWidth,height:e.rectPadHeight};throw new Error(`getPcbSize for shape "${e.shape}" not implemented for ${this.componentName}`)}_getPcbCircuitJsonBounds(){const{db:e}=this.root,t=e.pcb_plated_hole.get(this.pcb_plated_hole_id),n=this.getPcbSize();return{center:{x:t.x,y:t.y},bounds:{left:t.x-n.width/2,top:t.y+n.height/2,right:t.x+n.width/2,bottom:t.y-n.height/2},width:n.width,height:n.height}}_setPositionFromLayout(e){var n;const{db:t}=this.root;t.pcb_plated_hole.update(this.pcb_plated_hole_id,{x:e.x,y:e.y}),(n=this.matchedPort)==null||n._setPositionFromLayout(e)}doInitialPortMatching(){var t;const e=(t=this.getPrimitiveContainer())==null?void 0:t.selectAll("port");if(this.props.portHints){for(const n of e)if(n.isMatchingAnyOf(this.props.portHints)){this.matchedPort=n,n.registerMatch(this);return}}}doInitialPcbPrimitiveRender(){var a,s,l,c,u,A,d,f,m,C,E,_,x,w,P;if((a=this.root)!=null&&a.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this._getGlobalPcbPositionBeforeLayout(),i=((s=this.parent)==null?void 0:s.pcb_component_id)??((l=this.getPrimitiveContainer())==null?void 0:l.pcb_component_id),o=this.getSubcircuit();if(t.shape==="circle"){const L=e.pcb_plated_hole.insert({pcb_component_id:i,pcb_port_id:(c=this.matchedPort)==null?void 0:c.pcb_port_id,outer_diameter:t.outerDiameter,hole_diameter:t.holeDiameter,shape:"circle",port_hints:this.getNameAndAliases(),x:n.x,y:n.y,layers:["top","bottom"],subcircuit_id:(o==null?void 0:o.subcircuit_id)??void 0,pcb_group_id:((u=this.getGroup())==null?void 0:u.pcb_group_id)??void 0});this.pcb_plated_hole_id=L.pcb_plated_hole_id,e.pcb_solder_paste.insert({layer:"top",shape:"circle",radius:t.outerDiameter/2,x:n.x,y:n.y,subcircuit_id:(o==null?void 0:o.subcircuit_id)??void 0,pcb_group_id:((A=this.getGroup())==null?void 0:A.pcb_group_id)??void 0}),e.pcb_solder_paste.insert({layer:"bottom",shape:"circle",radius:t.outerDiameter/2,x:n.x,y:n.y,subcircuit_id:(o==null?void 0:o.subcircuit_id)??void 0,pcb_group_id:((d=this.getGroup())==null?void 0:d.pcb_group_id)??void 0})}else if(t.shape==="pill"||t.shape==="oval"){const L=e.pcb_plated_hole.insert({pcb_component_id:i,pcb_port_id:(f=this.matchedPort)==null?void 0:f.pcb_port_id,outer_width:t.outerWidth,outer_height:t.outerHeight,hole_width:t.holeWidth,hole_height:t.holeHeight,shape:t.shape,port_hints:this.getNameAndAliases(),x:n.x,y:n.y,layers:["top","bottom"],subcircuit_id:(o==null?void 0:o.subcircuit_id)??void 0,pcb_group_id:((m=this.getGroup())==null?void 0:m.pcb_group_id)??void 0});this.pcb_plated_hole_id=L.pcb_plated_hole_id,e.pcb_solder_paste.insert({layer:"top",shape:t.shape,width:t.outerWidth,height:t.outerHeight,x:n.x,y:n.y,subcircuit_id:(o==null?void 0:o.subcircuit_id)??void 0,pcb_group_id:((C=this.getGroup())==null?void 0:C.pcb_group_id)??void 0}),e.pcb_solder_paste.insert({layer:"bottom",shape:t.shape,width:t.outerWidth,height:t.outerHeight,x:n.x,y:n.y,subcircuit_id:(o==null?void 0:o.subcircuit_id)??void 0,pcb_group_id:((E=this.getGroup())==null?void 0:E.pcb_group_id)??void 0})}else if(t.shape==="circular_hole_with_rect_pad"){const L=e.pcb_plated_hole.insert({pcb_component_id:i,pcb_port_id:(_=this.matchedPort)==null?void 0:_.pcb_port_id,hole_diameter:t.holeDiameter,rect_pad_width:t.rectPadWidth,rect_pad_height:t.rectPadHeight,shape:"circular_hole_with_rect_pad",port_hints:this.getNameAndAliases(),x:n.x,y:n.y,layers:["top","bottom"],subcircuit_id:(o==null?void 0:o.subcircuit_id)??void 0,pcb_group_id:((x=this.getGroup())==null?void 0:x.pcb_group_id)??void 0});this.pcb_plated_hole_id=L.pcb_plated_hole_id}else if(t.shape==="pill_hole_with_rect_pad"){const L=e.pcb_plated_hole.insert({pcb_component_id:i,pcb_port_id:(w=this.matchedPort)==null?void 0:w.pcb_port_id,hole_width:t.holeWidth,hole_height:t.holeHeight,rect_pad_width:t.rectPadWidth,rect_pad_height:t.rectPadHeight,shape:"pill_hole_with_rect_pad",port_hints:this.getNameAndAliases(),x:n.x,y:n.y,layers:["top","bottom"],subcircuit_id:(o==null?void 0:o.subcircuit_id)??void 0,pcb_group_id:((P=this.getGroup())==null?void 0:P.pcb_group_id)??void 0});this.pcb_plated_hole_id=L.pcb_plated_hole_id}}doInitialPcbPortAttachment(){var t,n;if((t=this.root)!=null&&t.pcbDisabled)return;const{db:e}=this.root;e.pcb_plated_hole.update(this.pcb_plated_hole_id,{pcb_port_id:(n=this.matchedPort)==null?void 0:n.pcb_port_id})}},Ice=class extends aI{constructor(){super(...arguments);Ye(this,"pcb_keepout_id",null);Ye(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Keepout",zodProps:t8e}}doInitialPcbPrimitiveRender(){var l,c,u;if((l=this.root)!=null&&l.pcbDisabled)return;const e=this.getSubcircuit(),{db:t}=this.root,{_parsedProps:n}=this,i=this._getGlobalPcbPositionBeforeLayout(),o=YM(this._computePcbGlobalTransformBeforeLayout()),a=Math.abs(o.rotation.angle*(180/Math.PI)-90)%180<.01;let s=null;n.shape==="circle"?s=t.pcb_keepout.insert({layers:["top"],shape:"circle",radius:n.radius,center:{x:i.x,y:i.y},subcircuit_id:(e==null?void 0:e.subcircuit_id)??void 0,pcb_group_id:((c=e==null?void 0:e.getGroup())==null?void 0:c.pcb_group_id)??void 0}):n.shape==="rect"&&(s=t.pcb_keepout.insert({layers:["top"],shape:"rect",...a?{width:n.height,height:n.width}:{width:n.width,height:n.height},center:{x:i.x,y:i.y},subcircuit_id:(e==null?void 0:e.subcircuit_id)??void 0,pcb_group_id:((u=e==null?void 0:e.getGroup())==null?void 0:u.pcb_group_id)??void 0})),s&&(this.pcb_keepout_id=s.pcb_keepout_id)}},c7e=class extends aI{constructor(){super(...arguments);Ye(this,"pcb_hole_id",null);Ye(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Hole",zodProps:FPe}}getPcbSize(){const{_parsedProps:e}=this;return{width:e.diameter,height:e.diameter}}doInitialPcbPrimitiveRender(){var a,s;if((a=this.root)!=null&&a.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this.getSubcircuit(),i=this._getGlobalPcbPositionBeforeLayout(),o=e.pcb_hole.insert({hole_shape:"circle",hole_diameter:t.diameter,x:i.x,y:i.y,subcircuit_id:(n==null?void 0:n.subcircuit_id)??void 0,pcb_group_id:((s=n==null?void 0:n.getGroup())==null?void 0:s.pcb_group_id)??void 0});this.pcb_hole_id=o.pcb_hole_id}_getPcbCircuitJsonBounds(){const{db:e}=this.root,t=e.pcb_hole.get(this.pcb_hole_id),n=this.getPcbSize();return{center:{x:t.x,y:t.y},bounds:{left:t.x-n.width/2,top:t.y-n.height/2,right:t.x+n.width/2,bottom:t.y+n.height/2},width:n.width,height:n.height}}_setPositionFromLayout(e){const{db:t}=this.root;t.pcb_hole.update(this.pcb_hole_id,{x:e.x,y:e.y})}},Cce=class extends aI{constructor(){super(...arguments);Ye(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenText",zodProps:i8e}}doInitialPcbPrimitiveRender(){var s,l;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this.getPrimitiveContainer(),i=this._getGlobalPcbPositionBeforeLayout(),{maybeFlipLayer:o}=this._getPcbPrimitiveFlippedHelpers(),a=this.getSubcircuit();e.pcb_silkscreen_text.insert({anchor_alignment:t.anchorAlignment,anchor_position:{x:i.x,y:i.y},font:t.font??"tscircuit2024",font_size:t.fontSize??1,layer:o(t.layer??"top"),text:t.text??"",ccw_rotation:t.pcbRotation,pcb_component_id:n.pcb_component_id,subcircuit_id:(a==null?void 0:a.subcircuit_id)??void 0,pcb_group_id:((l=this.getGroup())==null?void 0:l.pcb_group_id)??void 0})}getPcbSize(){const{_parsedProps:e}=this,t=e.fontSize??1,i=(e.text??"").length*t,o=t;return{width:i*t,height:o*t}}},wjt=({elm:r,pinLabels:e,layer:t,readableRotation:n,anchorAlignment:i})=>{const o=r.text.replace(/[{}]/g,"").toLowerCase();let a=o;if(Array.isArray(e)){const s=parseInt(o.replace(/[^\d]/g,""),10)-1;a=String(e[s]??o)}else typeof e=="object"&&(a=String(e[o]??o));return new Cce({anchorAlignment:i||"center",text:a??o,layer:t||"top",fontSize:r.font_size+.2,pcbX:isNaN(r.anchor_position.x)?0:r.anchor_position.x,pcbY:r.anchor_position.y,pcbRotation:n??0})},Qjt=(r,e)=>((-parseInt(r||"0",10)+(e??0))%360+360)%360,u7e=({componentName:r,componentRotation:e,footprint:t,pinLabels:n},i)=>{const o=[];for(const a of i)if(a.type==="pcb_smtpad"&&a.shape==="rect")o.push(new yce({pcbX:a.x,pcbY:a.y,layer:a.layer,shape:"rect",height:a.height,width:a.width,portHints:a.port_hints}));else if(a.type==="pcb_smtpad"&&a.shape==="circle")o.push(new yce({pcbX:a.x,pcbY:a.y,layer:a.layer,shape:"circle",radius:a.radius,portHints:a.port_hints}));else if(a.type==="pcb_silkscreen_path")o.push(new s7e({layer:a.layer,route:a.route,strokeWidth:a.stroke_width}));else if(a.type==="pcb_plated_hole")a.shape==="circle"?o.push(new vce({pcbX:a.x,pcbY:a.y,shape:"circle",holeDiameter:a.hole_diameter,outerDiameter:a.outer_diameter,portHints:a.port_hints})):a.shape==="circular_hole_with_rect_pad"&&o.push(new vce({pcbX:a.x,pcbY:a.y,shape:"circular_hole_with_rect_pad",holeDiameter:a.hole_diameter,rectPadHeight:a.rect_pad_height,rectPadWidth:a.rect_pad_width,portHints:a.port_hints}));else if(a.type==="pcb_keepout"&&a.shape==="circle")o.push(new Ice({pcbX:a.center.x,pcbY:a.center.y,shape:"circle",radius:a.radius}));else if(a.type==="pcb_keepout"&&a.shape==="rect")o.push(new Ice({pcbX:a.center.x,pcbY:a.center.y,shape:"rect",width:a.width,height:a.height}));else if(a.type==="pcb_hole"&&a.hole_shape==="circle")o.push(new c7e({pcbX:a.x,pcbY:a.y,diameter:a.hole_diameter}));else if(a.type==="pcb_silkscreen_text"){const s=Qjt(e,a.ccw_rotation);t.includes("pinrow")&&a.text.includes("PIN")?o.push(wjt({elm:a,pinLabels:n,layer:a.layer,readableRotation:s,anchorAlignment:a.anchor_alignment})):o.push(new Cce({anchorAlignment:a.anchor_alignment||"center",text:r,fontSize:a.font_size+.2,pcbX:isNaN(a.anchor_position.x)?0:a.anchor_position.x,pcbY:a.anchor_position.y,pcbRotation:s??0}))}else a.type==="pcb_trace"&&o.push(new l7e({route:a.route}));return o};function Ece(r){let e=1/0,t=1/0,n=-1/0,i=-1/0,o=!1;for(const l of r)if(l.isPcbPrimitive&&!l.componentName.startsWith("Silkscreen")){const{x:c,y:u}=l._getGlobalPcbPositionBeforeLayout(),{width:A,height:d}=l.getPcbSize();e=Math.min(e,c-A/2),t=Math.min(t,u-d/2),n=Math.max(n,c+A/2),i=Math.max(i,u+d/2),o=!0}else if(l.children.length>0){const c=Ece(l.children);(c.width>0||c.height>0)&&(e=Math.min(e,c.minX),t=Math.min(t,c.minY),n=Math.max(n,c.maxX),i=Math.max(i,c.maxY),o=!0)}if(!o)return{minX:0,minY:0,maxX:0,maxY:0,width:0,height:0};let a=n-e,s=i-t;return a<0&&(a=0),s<0&&(s=0),{minX:e,minY:t,maxX:n,maxY:i,width:a,height:s}}function Mjt(r,e){const t=e.x-r.x,n=e.y-r.y;return Math.abs(t)>Math.abs(n)?t>=0?"right":"left":n>=0?"up":"down"}var Djt=r=>{if(r.length<=1)return!0;const e=r.map(o=>{const a=o._getPcbCircuitJsonBounds();return{left:a.bounds.left,right:a.bounds.right,top:a.bounds.top,bottom:a.bounds.bottom}}),t=Array(e.length).fill(!1).map(()=>Array(e.length).fill(!1));for(let o=0;o<e.length;o++)for(let a=o+1;a<e.length;a++){const s=e[o],l=e[a];t[o][a]=t[a][o]=!(s.right<l.left||s.left>l.right||s.bottom>l.top||s.top<l.bottom)}const n=new Set,i=o=>{n.add(o);for(let a=0;a<e.length;a++)t[o][a]&&!n.has(a)&&i(a)};return i(0),n.size===e.length},Rjt=r=>{if(r.length===0)throw new Error("Cannot get center of empty PCB primitives array");const e=r.map(i=>i._getPcbCircuitJsonBounds().center).filter(Boolean),t=e.reduce((i,o)=>i+o.x,0),n=e.reduce((i,o)=>i+o.y,0);return{x:t/e.length,y:n/e.length}},Njt=Pn({name:Pe().optional(),pinNumber:Nr().optional(),aliases:lo(Pe()).optional()}),Hw=class extends aI{constructor(e,t={}){if(!e.name&&e.pinNumber!==void 0&&(e.name=`pin${e.pinNumber}`),!e.name)throw new Error("Port must have a name or a pinNumber");super(e);Ye(this,"source_port_id",null);Ye(this,"pcb_port_id",null);Ye(this,"schematic_port_id",null);Ye(this,"schematicSymbolPortDef",null);Ye(this,"matchedComponents");Ye(this,"facingDirection",null);Ye(this,"originDescription",null);t.originDescription&&(this.originDescription=t.originDescription),this.matchedComponents=[]}get config(){return{componentName:"Port",zodProps:Njt}}_getGlobalPcbPositionBeforeLayout(){const e=this.matchedComponents.find(n=>n.isPcbPrimitive),t=this.parent;if(t&&!t.props.footprint)throw new Error(`${t.componentName} "${t.props.name}" does not have a footprint. Add a footprint prop, e.g. <${t.componentName.toLowerCase()} footprint="..." />`);if(!e)throw new Error(`Port ${this} has no matching PCB primitives. This often means the footprint's pads lack matching port hints.`);return(e==null?void 0:e._getGlobalPcbPositionBeforeLayout())??{x:0,y:0}}_getPcbCircuitJsonBounds(){if(!this.pcb_port_id)return super._getPcbCircuitJsonBounds();const{db:e}=this.root,t=e.pcb_port.get(this.pcb_port_id);return{center:{x:t.x,y:t.y},bounds:{left:0,top:0,right:0,bottom:0},width:0,height:0}}_getGlobalPcbPositionAfterLayout(){return this._getPcbCircuitJsonBounds().center}_getPortsInternallyConnectedToThisPort(){const e=this.parent;if(!e||!e._getInternallyConnectedPins)return[];const t=e._getInternallyConnectedPins();for(const n of t)if(n.some(i=>i===this))return n;return[]}_hasSchematicPort(){var n,i;if((n=this.parent)==null?void 0:n.getSchematicSymbol())return!!(this.schematicSymbolPortDef||this._getPortsInternallyConnectedToThisPort().some(a=>a.schematicSymbolPortDef));const t=(i=this==null?void 0:this.parent)==null?void 0:i._getSchematicBoxDimensions();return!!(t&&this.props.pinNumber!==void 0&&t.getPortPositionByPinNumber(this.props.pinNumber))}_getGlobalSchematicPositionBeforeLayout(){var n,i,o;const e=(n=this.parent)==null?void 0:n.getSchematicSymbol();if(e){let a=this.schematicSymbolPortDef;if(!a&&(a=((i=this._getPortsInternallyConnectedToThisPort().find(l=>l.schematicSymbolPortDef))==null?void 0:i.schematicSymbolPortDef)??null,!a))throw new Error(`Couldn't find schematicSymbolPortDef for port ${this.getString()}, searched internally connected ports and none had a schematicSymbolPortDef. Why are we trying to get the schematic position of this port?`);const s=Ku(this.parent.computeSchematicGlobalTransform(),$d(-e.center.x,-e.center.y));return Xr(s,a)}const t=(o=this==null?void 0:this.parent)==null?void 0:o._getSchematicBoxDimensions();if(t&&this.props.pinNumber!==void 0){const a=t.getPortPositionByPinNumber(this.props.pinNumber);if(!a)throw new Error(`Couldn't find position for schematic_port for port ${this.getString()} inside of the schematic box`);return Xr(this.parent.computeSchematicGlobalTransform(),a)}throw new Error(`Couldn't find position for schematic_port for port ${this.getString()}`)}_getGlobalSchematicPositionAfterLayout(){const{db:e}=this.root;if(!this.schematic_port_id)throw new Error(`Can't get schematic port position after layout for "${this.getString()}", no schematic_port_id`);const t=e.schematic_port.get(this.schematic_port_id);if(!t)throw new Error(`Schematic port not found when trying to get post-layout position: ${this.schematic_port_id}`);return t.center}registerMatch(e){this.matchedComponents.push(e)}getNameAndAliases(){const{_parsedProps:e}=this;return Array.from(new Set([...e.aliases??[],...e.name?[e.name]:[],...typeof e.pinNumber=="number"?[`pin${e.pinNumber}`,e.pinNumber.toString()]:[],...this.externallyAddedAliases??[]]))}isMatchingPort(e){return this.isMatchingAnyOf(e.getNameAndAliases())}getPortSelector(){var e;return`.${(e=this.parent)==null?void 0:e.props.name} > port.${this.props.name}`}getAvailablePcbLayers(){return Array.from(new Set(this.matchedComponents.flatMap(e=>e.getAvailablePcbLayers())))}_getDirectlyConnectedTraces(){return this.getSubcircuit().selectAll("trace").filter(n=>n._isExplicitlyConnectedToPort(this))}doInitialSourceRender(){var o,a;const{db:e}=this.root,{_parsedProps:t}=this,n=this.getNameAndAliases(),i=e.source_port.insert({name:t.name,pin_number:t.pinNumber,port_hints:n,source_component_id:(o=this.parent)==null?void 0:o.source_component_id,subcircuit_id:(a=this.getSubcircuit())==null?void 0:a.subcircuit_id});this.source_port_id=i.source_port_id}doInitialSourceParentAttachment(){var t,n,i,o,a;const{db:e}=this.root;if(!((t=this.parent)!=null&&t.source_component_id))throw new Error(`${this.getString()} has no parent source component (parent: ${(n=this.parent)==null?void 0:n.getString()})`);e.source_port.update(this.source_port_id,{source_component_id:(i=this.parent)==null?void 0:i.source_component_id,subcircuit_id:(o=this.getSubcircuit())==null?void 0:o.subcircuit_id}),this.source_component_id=(a=this.parent)==null?void 0:a.source_component_id}doInitialPcbPortRender(){var o,a,s,l,c;if((o=this.root)!=null&&o.pcbDisabled)return;const{db:e}=this.root,{matchedComponents:t}=this;if(!((a=this.parent)!=null&&a.pcb_component_id))throw new Error(`${this.getString()} has no parent pcb component, cannot render pcb_port (parent: ${(s=this.parent)==null?void 0:s.getString()})`);const n=t.filter(u=>u.isPcbPrimitive);if(n.length===0)return;let i=null;if(n.length===1&&(i=n[0]._getPcbCircuitJsonBounds().center),n.length>1){if(!Djt(n))throw new Error(`${this.getString()} has multiple non-overlapping pcb matches, unclear how to place pcb_port: ${n.map(u=>u.getString()).join(", ")}. (Note: tscircuit core does not currently allow you to specify internally connected pcb primitives with the same port hints, try giving them different port hints and specifying they are connected externally- or file an issue)`);i=Rjt(n)}if(i){const u=this.getSubcircuit(),A=e.pcb_port.insert({pcb_component_id:(l=this.parent)==null?void 0:l.pcb_component_id,layers:this.getAvailablePcbLayers(),subcircuit_id:(u==null?void 0:u.subcircuit_id)??void 0,pcb_group_id:((c=this.getGroup())==null?void 0:c.pcb_group_id)??void 0,...i,source_port_id:this.source_port_id});this.pcb_port_id=A.pcb_port_id}else{const u=n[0];throw new Error(`${u.getString()} does not have a center or _getGlobalPcbPositionBeforeLayout method (needed for pcb_port placement)`)}}doInitialSchematicPortRender(){var A;const{db:e}=this.root,{_parsedProps:t}=this,n=this.getPrimitiveContainer();if(!n||!this._hasSchematicPort())return;const i=n._getGlobalSchematicPositionBeforeLayout(),o=this._getGlobalSchematicPositionBeforeLayout();let a=null;const s=n._getSchematicBoxDimensions();s&&t.pinNumber!==void 0&&(a=s.getPortPositionByPinNumber(t.pinNumber)),this.getSubcircuit().props._schDebugObjectsEnabled&&e.schematic_debug_object.insert({shape:"rect",center:o,size:{width:.1,height:.1},label:"obstacle"}),a!=null&&a.side?this.facingDirection={left:"left",right:"right",top:"up",bottom:"down"}[a.side]:this.facingDirection=Mjt(i,o);const l=e.source_port.get(this.source_port_id);let c;for(const d of(l==null?void 0:l.port_hints)??[])d.match(/^(pin)?\d+$/)||d.match(/^(left|right)/)&&!(l!=null&&l.name.match(/^(left|right)/))||(c=d);const u=e.schematic_port.insert({schematic_component_id:(A=this.parent)==null?void 0:A.schematic_component_id,center:o,source_port_id:this.source_port_id,facing_direction:this.facingDirection,distance_from_component_edge:.4,side_of_component:a==null?void 0:a.side,pin_number:t.pinNumber,true_ccw_index:a==null?void 0:a.trueIndex,display_pin_label:c});this.schematic_port_id=u.schematic_port_id}_setPositionFromLayout(e){const{db:t}=this.root;this.pcb_port_id&&t.pcb_port.update(this.pcb_port_id,{x:e.x,y:e.y})}_hasMatchedPcbPrimitive(){return this.matchedComponents.some(e=>e.isPcbPrimitive)}},A7e=r=>{const e=r.find(t=>/^(pin)?\d+$/.test(t));return e?Number.parseInt(e.replace(/^pin/,"")):null};function XT(r,e){var o;const t=A7e(r);if(!t)return null;const i=[...r.filter(a=>a.toString()!==t.toString()&&a!==`pin${t}`),...((o=e==null?void 0:e.additionalAliases)==null?void 0:o[`pin${t}`])??[]];return new Hw({pinNumber:t,aliases:i})}var Tjt=r=>{for(const e of["leftSide","rightSide","topSide","bottomSide"])if(e in r&&typeof r[e]=="number")throw new Error(`A number was specified for "${e}", you probably meant to use "size" not "side"`);return"leftSide"in r||"rightSide"in r||"topSide"in r||"bottomSide"in r},Pjt=r=>{var o,a,s,l;if(Tjt(r))return{leftSize:((o=r.leftSide)==null?void 0:o.pins.length)??0,rightSize:((a=r.rightSide)==null?void 0:a.pins.length)??0,topSize:((s=r.topSide)==null?void 0:s.pins.length)??0,bottomSize:((l=r.bottomSide)==null?void 0:l.pins.length)??0};const{leftSize:e=0,rightSize:t=0,topSize:n=0,bottomSize:i=0}=r;return{leftSize:e,rightSize:t,topSize:n,bottomSize:i}};function d7e(r){return r.leftSide!==void 0}var kjt=r=>{var E,_,x,w,P,L,O,H;const e=r.portDistanceFromEdge??.4;let t=r.schPortArrangement?Pjt(r.schPortArrangement):null;const n={left:0,right:0,top:0,bottom:0};let i=r.pinCount??null;if(i===null)if(t)i=t.leftSize+t.rightSize+t.topSize;else throw new Error("Could not determine pin count for the schematic box");if(i&&!t){const K=Math.floor(i/2);t={leftSize:i-K,rightSize:K,topSize:0,bottomSize:0}}t||(t={leftSize:0,rightSize:0,topSize:0,bottomSize:0});const o=({side:K,sideIndex:q,truePinIndex:Y})=>{var xe,fe,Ie,ve;if(!r.schPortArrangement||!d7e(r.schPortArrangement))return Y+1;const se={left:"top-to-bottom",bottom:"left-to-right",right:"bottom-to-top",top:"right-to-left"}[K],ie=((fe=(xe=r.schPortArrangement)==null?void 0:xe[`${K}Side`])==null?void 0:fe.direction)??se,de=(ve=(Ie=r.schPortArrangement)==null?void 0:Ie[`${K}Side`])==null?void 0:ve.pins;let Ce=q;return ie!==se&&(Ce=de.length-q-1),ZT(de[Ce],r.pinLabels)},a=[];let s=0,l=0;for(let K=0;K<t.leftSize;K++){const q=o({side:"left",sideIndex:K,truePinIndex:l}),Y=((E=r.numericSchPinStyle)==null?void 0:E[`pin${q}`])??((_=r.numericSchPinStyle)==null?void 0:_[q]);Y!=null&&Y.topMargin&&(s+=Y.topMargin),a.push({trueIndex:l,pinNumber:q,side:"left",distanceFromOrthogonalEdge:s}),Y!=null&&Y.bottomMargin&&(s+=Y.bottomMargin),K===t.leftSize-1?n.left=s:s+=r.schPinSpacing,l++}s=0;for(let K=0;K<t.bottomSize;K++){const q=o({side:"bottom",sideIndex:K,truePinIndex:l}),Y=((x=r.numericSchPinStyle)==null?void 0:x[`pin${q}`])??((w=r.numericSchPinStyle)==null?void 0:w[q]);Y!=null&&Y.leftMargin&&(s+=Y.leftMargin),a.push({trueIndex:l,pinNumber:q,side:"bottom",distanceFromOrthogonalEdge:s}),Y!=null&&Y.rightMargin&&(s+=Y.rightMargin),K===t.bottomSize-1?n.bottom=s:s+=r.schPinSpacing,l++}s=0;for(let K=0;K<t.rightSize;K++){const q=o({side:"right",sideIndex:K,truePinIndex:l}),Y=((P=r.numericSchPinStyle)==null?void 0:P[`pin${q}`])??((L=r.numericSchPinStyle)==null?void 0:L[q]);Y!=null&&Y.bottomMargin&&(s+=Y.bottomMargin),a.push({trueIndex:l,pinNumber:q,side:"right",distanceFromOrthogonalEdge:s}),Y!=null&&Y.topMargin&&(s+=Y.topMargin),K===t.rightSize-1?n.right=s:s+=r.schPinSpacing,l++}s=0;for(let K=0;K<t.topSize;K++){const q=o({side:"top",sideIndex:K,truePinIndex:l}),Y=((O=r.numericSchPinStyle)==null?void 0:O[`pin${q}`])??((H=r.numericSchPinStyle)==null?void 0:H[q]);Y!=null&&Y.rightMargin&&(s+=Y.rightMargin),a.push({trueIndex:l,pinNumber:q,side:"top",distanceFromOrthogonalEdge:s}),Y!=null&&Y.leftMargin&&(s+=Y.leftMargin),K===t.topSize-1?n.top=s:s+=r.schPinSpacing,l++}let c=r.schWidth;c||(c=Math.max(n.top+r.schPinSpacing*2,n.bottom+r.schPinSpacing*2));const u=r.pinLabels?Math.max(...Object.values(r.pinLabels).map(K=>K.length*.1)):0,A=u>0?1.1:0;c=Math.max(c,u+A);let d=r.schHeight;d||(d=Math.max(n.left+r.schPinSpacing*2,n.right+r.schPinSpacing*2));const f={left:{x:-c/2-e,y:n.left/2},bottom:{x:-n.bottom/2,y:-d/2-e},right:{x:c/2+e,y:-n.right/2},top:{x:n.top/2,y:d/2+e}},m={left:{x:0,y:-1},right:{x:0,y:1},top:{x:-1,y:0},bottom:{x:1,y:0}},C=a.map(K=>{const{distanceFromOrthogonalEdge:q,side:Y}=K,se=f[Y],ie=m[Y];return{x:se.x+q*ie.x,y:se.y+q*ie.y,...K}});return{getPortPositionByPinNumber(K){const q=C.find(Y=>Y.pinNumber.toString()===K.toString());return q||null},getSize(){return{width:c,height:d}},getSizeIncludingPins(){return{width:c+(t.leftSize||t.rightSize?.4:0),height:d+(t.topSize||t.bottomSize?.4:0)}},pinCount:i}},Ujt=uC("tscircuit:core:footprint"),Fjt=class extends aI{get config(){return{componentName:"Footprint",zodProps:OPe}}doInitialPcbFootprintLayout(){var A,d,f,m,C;if((A=this.root)!=null&&A.pcbDisabled)return;const r=this.children.filter(E=>E.componentName==="Constraint");if(r.length===0)return;const{isFlipped:e}=this._getPcbPrimitiveFlippedHelpers(),t=E=>e&&"left"in E&&"right"in E?{...E,left:E.right,right:E.left}:E,n=r.flatMap(E=>E._getAllReferencedComponents().componentsWithSelectors).map(({component:E,selector:_,componentSelector:x,edge:w})=>({component:E,selector:_,componentSelector:x,edge:w,bounds:E._getPcbCircuitJsonBounds()}));if(n.some(E=>E.edge))throw new Error("edge constraints not implemented yet for footprint layout, contributions welcome!");function i(E){return n.find(({selector:_})=>_===E)}const o=new A8e,a={};function s(E){return E in a||(a[E]=new A6(E),o.addEditVariable(a[E],AC.weak)),a[E]}for(const{selector:E,bounds:_}of n){const x=s(`${E}_x`),w=s(`${E}_y`);o.suggestValue(x,_.center.x),o.suggestValue(w,_.center.y)}for(const E of r){const _=E._parsedProps;if("xDist"in _){const{xDist:x,left:w,right:P,edgeToEdge:L,centerToCenter:O}=t(_),H=s(`${w}_x`),K=s(`${P}_x`),q=(d=i(w))==null?void 0:d.bounds,Y=(f=i(P))==null?void 0:f.bounds;if(O){const se=new wI(K,[-1,H]);o.addConstraint(new uB(se,mE.Eq,_.xDist,AC.required))}else if(L){const se=new wI(K,-Y.width/2,[-1,H],-q.width/2);o.addConstraint(new uB(se,mE.Eq,_.xDist,AC.required))}}else if("yDist"in _){const{yDist:x,top:w,bottom:P,edgeToEdge:L,centerToCenter:O}=_,H=s(`${w}_y`),K=s(`${P}_y`),q=(m=i(w))==null?void 0:m.bounds,Y=(C=i(P))==null?void 0:C.bounds;if(O){const se=new wI(H,[-1,K]);o.addConstraint(new uB(se,mE.Eq,_.yDist,AC.required))}else if(L){const se=new wI(H,q.height/2,[-1,K],-Y.height/2);o.addConstraint(new uB(se,mE.Eq,_.yDist,AC.required))}}else if("sameY"in _){const{for:x}=_;if(x.length<2)continue;const w=x.map(L=>s(`${L}_y`)),P=new wI(...w.slice(1));o.addConstraint(new uB(P,mE.Eq,w[0],AC.required))}else if("sameX"in _){const{for:x}=_;if(x.length<2)continue;const w=x.map(L=>s(`${L}_x`)),P=new wI(...w.slice(1));o.addConstraint(new uB(P,mE.Eq,w[0],AC.required))}}o.updateVariables(),Ujt.enabled&&(console.log("Solution to layout constraints:"),console.table(Object.entries(a).map(([E,_])=>({var:E,val:_.value()}))));const l={left:1/0,right:-1/0,top:-1/0,bottom:1/0};for(const{selector:E,bounds:{width:_,height:x}}of n){const w=s(`${E}_x`),P=s(`${E}_y`),L=w.value()-_/2,O=w.value()+_/2,H=P.value()+x/2,K=P.value()-x/2;l.left=Math.min(l.left,L),l.right=Math.max(l.right,O),l.top=Math.max(l.top,H),l.bottom=Math.min(l.bottom,K)}const c={x:-(l.right+l.left)/2,y:-(l.top+l.bottom)/2},u=this.getPrimitiveContainer()._getGlobalPcbPositionBeforeLayout();c.x+=u.x,c.y+=u.y;for(const{component:E,selector:_}of n){const x=s(`${_}_x`),w=s(`${_}_y`);E._setPositionFromLayout({x:x.value()+c.x,y:w.value()+c.y})}}},Ljt=(r,e)=>{if(!r)return;const t={};for(const[n,i]of Object.entries(r)){const o=ZT(n,e),a={leftMargin:i.marginLeft??i.leftMargin,rightMargin:i.marginRight??i.rightMargin,topMargin:i.marginTop??i.topMargin,bottomMargin:i.marginBottom??i.bottomMargin};t[`pin${o}`]={...t[`pin${o}`],...a}}return t},f7e=class{constructor({input:r}){Ye(this,"input");this.input=r}solveAndMapToTraces(){const r=[];for(const e of this.input.connections){if(e.pointsToConnect.length!==2)continue;const[t,n]=e.pointsToConnect,i={type:"pcb_trace",pcb_trace_id:"",connection_name:e.name,route:[{route_type:"wire",x:t.x,y:t.y,layer:"top",width:.1},{route_type:"wire",x:n.x,y:n.y,layer:"top",width:.1}]};r.push(i)}return r}},Gjt=r=>{const e=Math.min(...r.map(o=>o.center.x)),t=Math.max(...r.map(o=>o.center.x)),n=Math.min(...r.map(o=>o.center.y)),i=Math.max(...r.map(o=>o.center.y));return{minX:e,maxX:t,minY:n,maxY:i}},h7e=["top","bottom","inner1","inner2"],j7=(r,e=[])=>{var s;const t=[];if(e.length===0){const l=r[0].layers;for(const c of l)t.push(...j7(r.slice(1),[c]));return t}if(r.length===0)return[];const n=r[0],i=n.via||n.optional_via,o=e[e.length-1];if(r.length===1){const l=n;return l.layers&&i?l.layers.map(c=>({layer_path:[...e,c]})):(s=l.layers)!=null&&s.includes(o)?[{layer_path:[...e,o]}]:[]}if(!i)return n.layers&&!n.layers.includes(o)?[]:j7(r.slice(1),e.concat([o]));const a=(n.optional_via?h7e:h7e.filter(l=>l!==o)).filter(l=>{var c;return!n.layers||((c=n.layers)==null?void 0:c.includes(l))});for(const l of a)t.push(...j7(r.slice(1),e.concat(l)));return t};function p7e(r){const e={x:r.to.x-r.from.x,y:r.to.y-r.from.y},t=Math.abs(e.x),n=Math.abs(e.y);return t>n?e.x>0?"right":"left":e.y>0?"down":"up"}function UR(r,e){return Math.hypot(r.x-e.x,r.y-e.y)}var Ojt=r=>{if(r.length===1)return r[0];if(r.some(l=>l.length===0))throw new Error("Cannot merge routes with zero length");const e=[],t=r[0][0],n=r[0][r[0].length-1],i=r[1][0],o=r[1][r[1].length-1],a=Math.min(UR(t,i),UR(t,o)),s=Math.min(UR(n,i),UR(n,o));a<s?e.push(...r[0].reverse()):e.push(...r[0]);for(let l=1;l<r.length;l++){const c=e[e.length-1],u=r[l],A=u[0],d=u[u.length-1],f=UR(c,A),m=UR(c,d);f<m?e.push(...u):e.push(...u.reverse())}for(let l=1;l<e.length-1;l++){const c=e[l-1],u=e[l];c.route_type==="wire"&&u.route_type==="wire"&&c.layer!==u.layer&&e.splice(l,0,{x:c.x,y:c.y,from_layer:c.layer,to_layer:u.layer,route_type:"via"})}return e},zjt=(r,e)=>{const t="_getGlobalPcbPositionBeforeLayout"in r?r._getGlobalPcbPositionBeforeLayout():r,n="_getGlobalPcbPositionBeforeLayout"in e?e._getGlobalPcbPositionBeforeLayout():e;return Math.sqrt((t.x-n.x)**2+(t.y-n.y)**2)};function Hjt(r,e){if(e.length===0)throw new Error("No candidates given to getClosest method");let t=e[0],n=1/0;for(const i of e){const o=zjt(r,i);o<n&&(t=i,n=o)}return t}var Yjt=(r,e)=>{let t=0;t+=r.length??0,t+=e.filter(n=>n.is_crossing).length;for(let n=1;n<e.length;n++){const i=e[n-1],o=e[n],a=Math.abs(i.from.x-i.to.x)<.01,s=Math.abs(o.from.x-o.to.x)<.01;a!==s&&t++}return t},_ce=r=>({up:"bottom",down:"top",left:"right",right:"left"})[r]??null,xce=({firstEdge:r,firstEdgePort:e,firstDominantDirection:t,lastEdge:n,lastEdgePort:i,lastDominantDirection:o})=>{if(r&&e)return xce({lastEdge:{from:r.to,to:r.from},lastEdgePort:e,lastDominantDirection:t}).reverse().map(s=>({from:s.to,to:s.from}));let a=[];if(n&&i){const s={x:n.to.x,y:n.to.y};o==="left"||o==="right"?(s.x=i.position.x,a.push({from:n.to,to:{...s}}),a.push({from:s,to:{...i.position}})):(s.y=i.position.y,a.push({from:n.to,to:{...s}}),a.push({from:s,to:{...i.position}}))}return a=a.filter(s=>qT(s.from,s.to)>.01),a};function Vjt(r){try{return[r(),null]}catch(e){return[null,e]}}function Kjt(r){let e=0;for(let t=0;t<r.length;t++){const n=r[t];if(n.route_type==="wire"){const i=r[t+1];if(i){const o=i.x-n.x,a=i.y-n.y;e+=Math.sqrt(o*o+a*a)}}else n.route_type==="via"&&(e+=1.6)}return e}var J7=({db:r,source_trace_id:e,sameNetOnly:t,differentNetOnly:n})=>{!t&&!n&&(n=!0);const i=r.source_trace.get(e),o=[];for(const a of r.schematic_trace.list()){if(a.source_trace_id===e)continue;const s=r.source_trace.get(a.source_trace_id),l=(s==null?void 0:s.subcircuit_connectivity_map_key)===i.subcircuit_connectivity_map_key;n&&l||t&&!l||o.push(a)}return o},g7e=({edges:r,otherEdges:e})=>{const t=[...r];for(let n=0;n<t.length;n++){if(n>2e3)throw new Error("Over 2000 iterations spent inside createSchematicTraceCrossingSegments, you have triggered an infinite loop, please report this!");const i=t[n],o=Math.abs(i.from.x-i.to.x)<.01?"vertical":i.from.y===i.to.y?"horizontal":"not-orthogonal";if(o==="not-orthogonal")continue;const a=[];for(const C of e){const E=C.from.x===C.to.x?"vertical":C.from.y===C.to.y?"horizontal":"not-orthogonal";if(E==="not-orthogonal"||o===E)continue;if(q6e([i.from,i.to],[C.from,C.to],{lineThickness:.01})){const x=o==="vertical"?i.from.x:C.from.x,w=o==="vertical"?C.from.y:i.from.y,P={x,y:w};a.push({otherEdge:C,crossingPoint:P,distanceFromEdgeFrom:qT(i.from,P)})}}if(a.length===0)continue;let s=a[0];for(const C of a)C.distanceFromEdgeFrom<s.distanceFromEdgeFrom&&(s=C);const l=s.crossingPoint,c=.075;if(l.x===i.from.x&&l.y===i.from.y)continue;const u=djt(i.from,l),A={x:l.x-u.x*c/2,y:l.y-u.y*c/2},d={x:l.x+u.x*c/2,y:l.y+u.y*c/2},f=qT(d,i.to)<c,m=[{from:i.from,to:A},{from:A,to:d,is_crossing:!0},{from:d,to:i.to}];t.splice(n,1,...m),n+=m.length-2,f&&n++}return t},jjt=(r,e)=>{if(r.from.x===r.to.x&&e.from.x===e.to.x)return null;if(r.from.x===r.to.x){const u=r.from.x,A=(e.to.y-e.from.y)/(e.to.x-e.from.x),d=e.from.y-A*e.from.x,f=A*u+d;return u>=Math.min(e.from.x,e.to.x)&&u<=Math.max(e.from.x,e.to.x)&&f>=Math.min(e.from.y,e.to.y)&&f<=Math.max(e.from.y,e.to.y)?{x:u,y:f}:null}if(e.from.x===e.to.x){const u=e.from.x,A=(r.to.y-r.from.y)/(r.to.x-r.from.x),d=r.from.y-A*r.from.x,f=A*u+d;return u>=Math.min(r.from.x,r.to.x)&&u<=Math.max(r.from.x,r.to.x)&&f>=Math.min(r.from.y,r.to.y)&&f<=Math.max(r.from.y,r.to.y)?{x:u,y:f}:null}const t=(r.to.y-r.from.y)/(r.to.x-r.from.x),n=r.from.y-t*r.from.x,i=(e.to.y-e.from.y)/(e.to.x-e.from.x),o=e.from.y-i*e.from.x;if(t===i)return null;const a=(o-n)/(t-i),s=t*a+n,l=a>=Math.min(r.from.x,r.to.x)&&a<=Math.max(r.from.x,r.to.x)&&s>=Math.min(r.from.y,r.to.y)&&s<=Math.max(r.from.y,r.to.y),c=a>=Math.min(e.from.x,e.to.x)&&a<=Math.max(e.from.x,e.to.x)&&s>=Math.min(e.from.y,e.to.y)&&s<=Math.max(e.from.y,e.to.y);return l&&c?{x:a,y:s}:null},m7e=({edges:r,db:e,source_trace_id:t})=>{const n=J7({db:e,source_trace_id:t,sameNetOnly:!0}).flatMap(i=>i.edges);for(const i of r)for(const o of n){const a=jjt(i,o);if(a)return`${a.x}${a.y}`,[{x:a.x,y:a.y}]}return[]},Jjt=(r,{db:e})=>{const t=r.map(n=>{const i=e.source_port.get(n.source_port_id);if(!(i!=null&&i.source_component_id))return null;const o=e.source_component.get(i.source_component_id);return(o==null?void 0:o.ftype)==="simple_capacitor"?o.max_decoupling_trace_length:null}).filter(n=>n!==null);if(t.length!==0)return Math.min(...t)};function Wjt(r){var o,a,s,l,c,u,A,d,f;let e=1/0,t=1/0,n=-1/0,i=-1/0;for(const m of r){let C,E,_,x;m.type==="schematic_component"?(C=(o=m.center)==null?void 0:o.x,E=(a=m.center)==null?void 0:a.y,_=(s=m.size)==null?void 0:s.width,x=(l=m.size)==null?void 0:l.height):m.type==="schematic_box"?(C=m.x,E=m.y,_=m.width,x=m.height):m.type==="schematic_port"?(C=(c=m.center)==null?void 0:c.x,E=(u=m.center)==null?void 0:u.y,_=.2,x=.2):m.type==="schematic_text"&&(C=(A=m.position)==null?void 0:A.x,E=(d=m.position)==null?void 0:d.y,_=(((f=m.text)==null?void 0:f.length)??0)*.1,x=.2),typeof C=="number"&&typeof E=="number"&&typeof _=="number"&&typeof x=="number"&&(e=Math.min(e,C-_/2),n=Math.max(n,C+_/2),t=Math.min(t,E-x/2),i=Math.max(i,E+x/2))}return{minX:e,maxX:n,minY:t,maxY:i}}function qjt(r,e={}){const{minX:t,maxX:n,minY:i,maxY:o}=r,a=e.padding??1;if(!isFinite(t)||!isFinite(n)||!isFinite(i)||!isFinite(o))return[];const s=t-a,l=n+a,c=o+a,u=i-a,A=.01;return[{type:"rect",layers:["top"],center:{x:(s+l)/2,y:c},width:l-s,height:A,connectedTo:[]},{type:"rect",layers:["top"],center:{x:(s+l)/2,y:u},width:l-s,height:A,connectedTo:[]},{type:"rect",layers:["top"],center:{x:s,y:(c+u)/2},width:A,height:c-u,connectedTo:[]},{type:"rect",layers:["top"],center:{x:l,y:(c+u)/2},width:A,height:c-u,connectedTo:[]}]}var Zjt=r=>{var a;const e=r.root.db,t=r._findConnectedPorts().ports??[],n=new Set(t.map(s=>s.schematic_port_id)),i=[];for(const s of e.toArray()){if(s.type==="schematic_component"){const l=!!s.symbol_name,c=s.size.width>s.size.height?"horz":"vert";i.push({type:"rect",layers:["top"],center:s.center,width:s.size.width+(l&&c==="horz"?-.5:0),height:s.size.height+(l&&c==="vert"?-.5:0),connectedTo:[]})}if(s.type==="schematic_port"){if(n.has(s.schematic_port_id))continue;const l=s.facing_direction?fjt(s.facing_direction):{x:0,y:0};i.push({type:"rect",layers:["top"],center:{x:s.center.x-l.x*.1,y:s.center.y-l.y*.1},width:.1+Math.abs(l.x)*.3,height:.1+Math.abs(l.y)*.3,connectedTo:[]})}s.type==="schematic_text"&&i.push({type:"rect",layers:["top"],center:s.position,width:(((a=s.text)==null?void 0:a.length)??0)*.1,height:.2,connectedTo:[]}),s.type==="schematic_box"&&i.push({type:"rect",layers:["top"],center:{x:s.x,y:s.y},width:s.width,height:s.height,connectedTo:[]})}const o=Wjt(e.toArray());return i.push(...qjt(o,{padding:1})),i};function Xjt({ports:r,nets:e}){var t,n,i;if(r.length>=2)return`${(t=r[0])==null?void 0:t.selector} to ${(n=r[1])==null?void 0:n.selector}`;if(r.length===1&&e.length===1)return`${(i=r[0])==null?void 0:i.selector} to net.${e[0]._parsedProps.name}`}var $jt=({edges:r,db:e,source_trace_id:t})=>{e.source_trace.get(t);const n=J7({db:e,source_trace_id:t,differentNetOnly:!0}).flatMap(o=>o.edges),i=o=>{const{from:a,to:s}=o;return a.x===s.x?"vertical":"horizontal"};for(const o of r){const a=i(o),s=()=>n.find(c=>i(c)===a&&q6e([o.from,o.to],[c.from,c.to],{lineThickness:.05}));let l=s();for(;l;)a==="horizontal"?(o.from.y+=.1,o.to.y+=.1):(o.from.x+=.1,o.to.x+=.1),l=s()}},eJt=(r,{db:e})=>{const t=e.pcb_board.list()[0];if(t.outline){const l=t.outline,c=(u,A)=>{let d=!1;for(let f=0,m=A.length-1;f<A.length;m=f++){const C=A[f].x,E=A[f].y,_=A[m].x,x=A[m].y;E>u.y!=x>u.y&&u.x<(_-C)*(u.y-E)/(x-E)+C&&(d=!d)}return d};return r.some(u=>!c(u,l))}const n=t.width,i=t.height,o=t.center.x,a=t.center.y;return r.some(l=>l.x<o-n/2||l.y<a-i/2||l.x>o+n/2||l.y>a+i/2)},W7=r=>({...r._getGlobalPcbPositionAfterLayout(),layers:r.getAvailablePcbLayers()}),Yw=class extends aI{constructor(e){super(e);Ye(this,"source_trace_id",null);Ye(this,"pcb_trace_id",null);Ye(this,"schematic_trace_id",null);Ye(this,"_portsRoutedOnPcb");Ye(this,"subcircuit_connectivity_map_key",null);Ye(this,"_traceConnectionHash",null);this._portsRoutedOnPcb=[]}get config(){return{zodProps:GPe,componentName:"Trace"}}_getTracePortOrNetSelectorListFromProps(){return"from"in this.props&&"to"in this.props?[typeof this.props.from=="string"?this.props.from:this.props.from.getPortSelector(),typeof this.props.to=="string"?this.props.to:this.props.to.getPortSelector()]:"path"in this.props?this.props.path.map(e=>typeof e=="string"?e:e.getPortSelector()):[]}getTracePortPathSelectors(){return this._getTracePortOrNetSelectorListFromProps().filter(e=>!e.includes("net."))}getTracePathNetSelectors(){return this._getTracePortOrNetSelectorListFromProps().filter(e=>e.includes("net."))}_findConnectedPorts(){const{db:e}=this.root,{_parsedProps:t,parent:n}=this;if(!n)throw new Error("Trace has no parent");const o=this.getTracePortPathSelectors().map(a=>({selector:a,port:this.getSubcircuit().selectOne(a,{type:"port"})??null}));for(const{selector:a,port:s}of o)if(!s){const l=a.replace(/(\> )?[^ ]+$/,""),c=this.getSubcircuit().selectOne(l);c?this.renderError(`Could not find port for selector "${a}" (did you forget to include the pin name?)
|
|
13311
13311
|
searched component ${c.getString()}, which has ports: ${c.children.filter(u=>u.componentName==="Port").map(u=>`${u.getString()}(${u.getNameAndAliases().join(",")})`).join(" & ")}`):this.renderError(`Could not find port for selector "${a}"`)}return o.some(a=>!a.port)?{allPortsFound:!1}:{allPortsFound:!0,portsWithSelectors:o,ports:o.map(({port:a})=>a)}}_findConnectedNets(){const e=this.getTracePathNetSelectors().map(n=>({selector:n,net:this.getSubcircuit().selectOne(n,{type:"net"})})),t=e.filter(n=>!n.net);return t.length>0&&this.renderError(`Could not find net for selector "${t[0].selector}" inside ${this}`),{netsWithSelectors:e,nets:e.map(n=>n.net)}}_getAllTracesConnectedToSameNet(){const e=this.getSubcircuit().selectAll("trace"),t=this._findConnectedNets().nets,n=this._findConnectedPorts().ports??[];return e.filter(i=>{if(i===this)return!1;const o=i._findConnectedNets().nets,a=i._findConnectedPorts().ports??[];return o.some(s=>t.includes(s))||a.some(s=>n.includes(s))})}_isExplicitlyConnectedToPort(e){const{allPortsFound:t,portsWithSelectors:n}=this._findConnectedPorts();return t?n.map(o=>o.port).includes(e):!1}_isExplicitlyConnectedToNet(e){return this._findConnectedNets().nets.includes(e)}doInitialCreateNetsFromProps(){a7e(this,this.getTracePathNetSelectors())}_computeTraceConnectionHash(){const{allPortsFound:e,ports:t}=this._findConnectedPorts();return!e||!t?null:[...t].sort((o,a)=>(o.pcb_port_id||"").localeCompare(a.pcb_port_id||"")).map(o=>o.pcb_port_id).join(",")}doInitialSourceTraceRender(){var A;const{db:e}=this.root,{_parsedProps:t,parent:n}=this;if(!n){this.renderError("Trace has no parent");return}const{allPortsFound:i,portsWithSelectors:o}=this._findConnectedPorts();if(!i)return;this._traceConnectionHash=this._computeTraceConnectionHash();const s=e.source_trace.list().find(d=>d.subcircuit_connectivity_map_key===this.subcircuit_connectivity_map_key&&d.connected_source_port_ids.sort().join(",")===this._traceConnectionHash);if(s){this.source_trace_id=s.source_trace_id;return}const l=this._findConnectedNets().nets,c=Xjt({ports:o,nets:l}),u=e.source_trace.insert({connected_source_port_ids:o.map(d=>d.port.source_port_id),connected_source_net_ids:l.map(d=>d.source_net_id),subcircuit_id:(A=this.getSubcircuit())==null?void 0:A.subcircuit_id,max_length:Jjt(o.map(d=>d.port),{db:e})??t.maxLength,display_name:c,min_trace_thickness:t.thickness});this.source_trace_id=u.source_trace_id}_insertErrorIfTraceIsOutsideBoard(e,t){const{db:n}=this.root;eJt(e,{db:n})&&n.pcb_trace_error.insert({error_type:"pcb_trace_error",source_trace_id:this.source_trace_id,message:`Trace ${this.getString()} routed outside the board boundaries.`,pcb_trace_id:this.pcb_trace_id,pcb_component_ids:[],pcb_port_ids:t.map(o=>o.pcb_port_id)})}doInitialPcbTraceRender(){var K,q,Y,se;if((K=this.root)!=null&&K.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t,parent:n}=this,i=this.getSubcircuit();if(!n)throw new Error("Trace has no parent");if(i._parsedProps.routingDisabled)return;const o=(q=i._parsedProps.pcbRouteCache)==null?void 0:q.pcbTraces;if(o){const ie=e.pcb_trace.insert({route:o.flatMap(de=>de.route),source_trace_id:this.source_trace_id,subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((Y=this.getGroup())==null?void 0:Y.pcb_group_id)??void 0});this.pcb_trace_id=ie.pcb_trace_id;return}if(!i._shouldUseTraceByTraceRouting())return;const{allPortsFound:a,ports:s}=this._findConnectedPorts();if(!a)return;const l=[];for(const ie of s)ie._hasMatchedPcbPrimitive()||l.push(ie);if(l.length>0){e.pcb_trace_error.insert({error_type:"pcb_trace_error",source_trace_id:this.source_trace_id,message:`Some ports did not have a matching PCB primitive (e.g. a pad or plated hole), this can happen if a footprint is missing. As a result, ${this} wasn't routed. Missing ports: ${l.map(ie=>ie.getString()).join(", ")}`,pcb_trace_id:this.pcb_trace_id,pcb_component_ids:[],pcb_port_ids:l.map(ie=>ie.pcb_port_id).filter(Boolean)});return}const c=this._findConnectedNets().netsWithSelectors;if(s.length===0&&c.length===2){this.renderError("Trace connects two nets, we haven't implemented a way to route this yet");return}else if(s.length===1&&c.length===1){const ie=s[0],Ce=c[0].net.getAllConnectedPorts().filter(fe=>fe!==ie);if(Ce.length===0){console.log("Nothing to connect this port to, the net is empty. TODO should emit a warning!");return}const xe=Hjt(ie,Ce);s.push(xe)}else if(s.length>1&&c.length>=1){this.renderError("Trace has more than one port and one or more nets, we don't currently support this type of complex trace routing");return}const u=s.flatMap(ie=>ie.matchedComponents.filter(de=>de.componentName==="TraceHint")),A=(this._parsedProps.pcbRouteHints??[]).concat(u.flatMap(ie=>ie.getPcbRouteHints()));if(s.length>2){this.renderError(`Trace has more than two ports (${s.map(ie=>ie.getString()).join(", ")}), routing between more than two ports for a single trace is not implemented`);return}if(this.getSubcircuit().selectAll("trace").filter(ie=>ie.renderPhaseStates.PcbTraceRender.initialized).some(ie=>ie._portsRoutedOnPcb.length===s.length&&ie._portsRoutedOnPcb.every(de=>s.includes(de))))return;let m=[];A.length===0?m=[W7(s[0]),W7(s[1])]:m=[W7(s[0]),...A,W7(s[1])];const C=j7(m),E=Tw(this.root.db.toArray()),[_,x]=Vjt(()=>t6(this.root.db.toArray()));if(x){this.renderError({type:"pcb_trace_error",error_type:"pcb_trace_error",pcb_trace_error_id:this.pcb_trace_id,message:`Error getting obstacles for autorouting: ${x.message}`,source_trace_id:this.source_trace_id,center:{x:0,y:0},pcb_port_ids:s.map(ie=>ie.pcb_port_id),pcb_trace_id:this.pcb_trace_id,pcb_component_ids:[]});return}for(const ie of _)if(ie.connectedTo.length>0){const Ce=E.getNetConnectedToId(ie.connectedTo[0]);Ce&&ie.connectedTo.push(Ce)}let w=[];if(C.length===0)w=m;else{const ie=C[0].layer_path;w=m.map((de,Ce)=>de.via?{...de,via_to_layer:ie[Ce]}:{...de,layers:[ie[Ce]]})}w[0].pcb_port_id=s[0].pcb_port_id,w[w.length-1].pcb_port_id=s[1].pcb_port_id;const P=[];for(const[ie,de]of i7e(w)){const Ce="via_to_layer"in ie?ie.via_to_layer:null,xe=2,fe="layers"in ie&&ie.layers.length===1?ie.layers[0]:Ce??"top",Ie="layers"in de&&de.layers.length===1?de.layers[0]:Ce??"top",ve="pcb_port_id"in ie?ie.pcb_port_id:null,Qe="pcb_port_id"in de?de.pcb_port_id:null,De=this.getSubcircuit()._parsedProps.minTraceWidth??.16,Fe=new e6({OBSTACLE_MARGIN:De*2,isRemovePathLoopsEnabled:!0,optimizeWithGoalBoxes:!!(ve&&Qe),connMap:E,input:{obstacles:_,minTraceWidth:De,connections:[{name:this.source_trace_id,pointsToConnect:[{...ie,layer:fe,pcb_port_id:ve},{...de,layer:Ie,pcb_port_id:Qe}]}],layerCount:2,bounds:{minX:Math.min(ie.x,de.x)-xe,maxX:Math.max(ie.x,de.x)+xe,minY:Math.min(ie.y,de.y)-xe,maxY:Math.max(ie.y,de.y)+xe}}});let Ne=null;try{Ne=Fe.solveAndMapToTraces()}catch(ft){this.renderError({type:"pcb_trace_error",pcb_trace_error_id:this.source_trace_id,error_type:"pcb_trace_error",message:`error solving route: ${ft.message}`,source_trace_id:this.pcb_trace_id,center:{x:(ie.x+de.x)/2,y:(ie.y+de.y)/2},pcb_port_ids:s.map(_t=>_t.pcb_port_id),pcb_trace_id:this.pcb_trace_id,pcb_component_ids:s.map(_t=>_t.pcb_component_id)})}if(!Ne)return;if(Ne.length===0){this.renderError({type:"pcb_trace_error",error_type:"pcb_trace_error",pcb_trace_error_id:this.pcb_trace_id,message:`Could not find a route for ${this}`,source_trace_id:this.source_trace_id,center:{x:(ie.x+de.x)/2,y:(ie.y+de.y)/2},pcb_port_ids:s.map(ft=>ft.pcb_port_id),pcb_trace_id:this.pcb_trace_id,pcb_component_ids:s.map(ft=>ft.pcb_component_id)});return}const[rt]=Ne;Ce&&(rt.route=rt.route.map(ft=>(ft.route_type==="wire"&&!ft.layer&&(ft.layer=Ce),ft))),ve&&rt.route[0].route_type==="wire"&&(rt.route[0].start_pcb_port_id=ve);const et=rt.route[rt.route.length-1];Qe&&et.route_type==="wire"&&(et.end_pcb_port_id=Qe),P.push(rt.route)}const L=Ojt(P),O=Kjt(L),H=e.pcb_trace.insert({route:L,source_trace_id:this.source_trace_id,subcircuit_id:(se=this.getSubcircuit())==null?void 0:se.subcircuit_id,trace_length:O});this._portsRoutedOnPcb=s,this.pcb_trace_id=H.pcb_trace_id;for(const ie of L)ie.route_type==="via"&&e.pcb_via.insert({pcb_trace_id:H.pcb_trace_id,x:ie.x,y:ie.y,hole_diameter:.3,outer_diameter:.6,layers:[ie.from_layer,ie.to_layer],from_layer:ie.from_layer,to_layer:ie.to_layer});this._insertErrorIfTraceIsOutsideBoard(L,s)}_doInitialSchematicTraceRenderWithDisplayLabel(){var P,L,O,H;if((P=this.root)!=null&&P.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t,parent:n}=this;if(!n)throw new Error("Trace has no parent");const{allPortsFound:i,portsWithSelectors:o}=this._findConnectedPorts();if(!i)return;const a=o.map(({port:K})=>({port:K,position:K._getGlobalSchematicPositionAfterLayout(),schematic_port_id:K.schematic_port_id,facingDirection:K.facingDirection}));if(a.length<2)throw new Error("Expected at least two ports in portsWithPosition.");let s,l;const c=a[0].position,u=a[0].port;if("path"in this.props){if(this.props.path.length!==2)throw new Error("Invalid 'path': Must contain exactly two elements.");[s,l]=this.props.path}else{if(!("from"in this.props&&"to"in this.props))throw new Error("Missing 'from' or 'to' properties in props.");s=this.props.from,l=this.props.to}if(!u.source_port_id)throw new Error(`Missing source_port_id for the 'from' port (${s}).`);const A=a[1].position,d=a[1].port;if(!d.source_port_id)throw new Error(`Missing source_port_id for the 'to' port (${l}).`);const f=e.schematic_net_label.list().find(K=>K.source_net_id===u.source_port_id),m=e.schematic_net_label.list().find(K=>K.source_net_id===d.source_port_id),[C,E]=o.map(({port:K})=>K),x=((L=C.parent)==null?void 0:L.config.shouldRenderAsSchematicBox)?`${(O=C==null?void 0:C.parent)==null?void 0:O.props.name}_${C==null?void 0:C.props.name}`:`${(H=E==null?void 0:E.parent)==null?void 0:H.props.name}_${E==null?void 0:E.props.name}`,w=this.props.schDisplayLabel??x;f&&f.text!==w&&(f.text=`${w} / ${f.text}`),m&&(m==null?void 0:m.text)!==w&&(m.text=`${w} / ${m.text}`),m||e.schematic_net_label.insert({text:this.props.schDisplayLabel??x,source_net_id:d.source_port_id,anchor_position:A,center:A,anchor_side:_ce(d.facingDirection)??"bottom"}),f||e.schematic_net_label.insert({text:this.props.schDisplayLabel??x,source_net_id:u.source_port_id,anchor_position:c,center:c,anchor_side:_ce(u.facingDirection)??"bottom"})}_isSymbolToChipConnection(){const{allPortsFound:e,ports:t}=this._findConnectedPorts();if(!e||t.length!==2)return!1;const[n,i]=t;if(!(n!=null&&n.parent)||!(i!=null&&i.parent))return!1;const o=n.parent.config.shouldRenderAsSchematicBox,a=i.parent.config.shouldRenderAsSchematicBox;return o&&!a||!o&&a}_isSymbolToSymbolConnection(){const{allPortsFound:e,ports:t}=this._findConnectedPorts();if(!e||t.length!==2)return!1;const[n,i]=t;if(!(n!=null&&n.parent)||!(i!=null&&i.parent))return!1;const o=!n.parent.config.shouldRenderAsSchematicBox,a=!i.parent.config.shouldRenderAsSchematicBox;return o&&a}_isChipToChipConnection(){const{allPortsFound:e,ports:t}=this._findConnectedPorts();if(!e||t.length!==2)return!1;const[n,i]=t;if(!(n!=null&&n.parent)||!(i!=null&&i.parent))return!1;const o=n.parent.config.shouldRenderAsSchematicBox,a=i.parent.config.shouldRenderAsSchematicBox;return o&&a}doInitialSchematicTraceRender(){var fe,Ie,ve;if((fe=this.root)!=null&&fe.schematicDisabled||((Ie=this.getGroup())==null?void 0:Ie._getSchematicLayoutMode())==="match-adapt")return;const{db:e}=this.root,{_parsedProps:t,parent:n}=this;if(!n)throw new Error("Trace has no parent");const{allPortsFound:i,portsWithSelectors:o}=this._findConnectedPorts(),{netsWithSelectors:a}=this._findConnectedNets();if(!i)return;const l=o.map(Qe=>Qe.port.schematic_port_id).sort().join(","),c=(ve=this.root)==null?void 0:ve._getBoard();if(c!=null&&c._connectedSchematicPortPairs&&c._connectedSchematicPortPairs.has(l))return;if(this.props.schDisplayLabel&&("from"in this.props&&"to"in this.props||"path"in this.props)){this._doInitialSchematicTraceRenderWithDisplayLabel();return}const u={name:this.source_trace_id,pointsToConnect:[]},A=Zjt(this),d=o.map(({port:Qe})=>({port:Qe,position:Qe._getGlobalSchematicPositionAfterLayout(),schematic_port_id:Qe.schematic_port_id??void 0,facingDirection:Qe.facingDirection}));if(d.length===1&&a.length===1){const Qe=a[0].net,{port:De,position:Fe}=d[0];e.schematic_net_label.insert({text:Qe._parsedProps.name,source_net_id:Qe.source_net_id,anchor_position:Fe,center:Fe,anchor_side:_ce(De.facingDirection)??"bottom"});return}if(d.length<2)return;u.pointsToConnect=d.map(({position:Qe})=>({...Qe,layer:"top"}));const m=Gjt(A),C=2,E={minTraceWidth:.1,obstacles:A,connections:[u],bounds:{minX:m.minX-C,maxX:m.maxX+C,minY:m.minY-C,maxY:m.maxY+C},layerCount:1};let _=e6,x=!1;this.getSubcircuit().props._schDirectLineRoutingEnabled&&(_=f7e,x=!0);let P=new _({input:E,MAX_ITERATIONS:100,OBSTACLE_MARGIN:.1,isRemovePathLoopsEnabled:!0,isShortenPathWithShortcutsEnabled:!0,marginsWithCosts:[{margin:1,enterCost:0,travelCostFactor:1},{margin:.3,enterCost:0,travelCostFactor:1},{margin:.2,enterCost:0,travelCostFactor:2},{margin:.1,enterCost:0,travelCostFactor:3}]}).solveAndMapToTraces();if(P.length===0){if(this._isSymbolToChipConnection()||this._isSymbolToSymbolConnection()||this._isChipToChipConnection()){this._doInitialSchematicTraceRenderWithDisplayLabel();return}P=new f7e({input:E}).solveAndMapToTraces(),x=!0}const[{route:L}]=P;let O=[];for(let Qe=0;Qe<L.length-1;Qe++)O.push({from:L[Qe],to:L[Qe+1]});const H=this.source_trace_id;let K=[];if(!x){$jt({edges:O,db:e,source_trace_id:H});const Qe=J7({db:e,source_trace_id:H,differentNetOnly:!0}).flatMap(De=>De.edges);O=g7e({edges:O,otherEdges:Qe}),K=m7e({edges:O,db:e,source_trace_id:this.source_trace_id})}const q=O[O.length-1],Y=d[d.length-1],se=p7e(q);O.push(...xce({lastEdge:q,lastEdgePort:Y,lastDominantDirection:se}));const ie=O[0],de=d[0],Ce=p7e(ie);if(O.unshift(...xce({firstEdge:ie,firstEdgePort:de,firstDominantDirection:Ce})),!this.source_trace_id)throw new Error("Missing source_trace_id for schematic trace insertion.");if(this.getSubcircuit()._parsedProps.schTraceAutoLabelEnabled&&Yjt(K,O)>=5&&(this._isSymbolToChipConnection()||this._isSymbolToSymbolConnection()||this._isChipToChipConnection())){this._doInitialSchematicTraceRenderWithDisplayLabel();return}const xe=e.schematic_trace.insert({source_trace_id:this.source_trace_id,edges:O,junctions:K});this.schematic_trace_id=xe.schematic_trace_id,c!=null&&c._connectedSchematicPortPairs&&c._connectedSchematicPortPairs.add(l)}},tJt=uC("tscircuit:core"),nJt=Pn({x:ex,y:ex,z:ex}),L1=class extends aI{constructor(e){super(e);Ye(this,"reactSubtrees",[]);Ye(this,"_impliedFootprint");Ye(this,"isPrimitiveContainer",!0);Ye(this,"_asyncSupplierPartNumbers");Ye(this,"pcb_missing_footprint_error_id");Ye(this,"_hasStartedFootprintUrlLoad",!1);this._addChildrenFromStringFootprint(),this.initPorts()}get defaultInternallyConnectedPinNames(){return[]}get internallyConnectedPinNames(){return this._parsedProps.internallyConnectedPins??this.defaultInternallyConnectedPinNames}initPorts(e={}){var a,s,l,c,u,A,d,f,m,C;if((a=this.root)!=null&&a.schematicDisabled)return;const{config:t}=this,n=[],i=this._getSchematicPortArrangement();if(i&&!this._parsedProps.pinLabels){for(const x in i){const w=i[x].pins;if(Array.isArray(w))for(const P of w){const L=ZT(P,this._parsedProps.pinLabels);n.push(new Hw({pinNumber:L,aliases:((s=e.additionalAliases)==null?void 0:s[`pin${L}`])??[]},{originDescription:`schPortArrangement:${x}`}))}}const E=["left","right","top","bottom"];let _=1;for(const x of E){const w=i[`${x}Size`];for(let P=0;P<w;P++)n.push(new Hw({pinNumber:_++,aliases:((l=e.additionalAliases)==null?void 0:l[`pin${_}`])??[]},{originDescription:`schPortArrangement:${x}`}))}}const o=this._parsedProps.pinLabels;if(o)for(let[E,_]of Object.entries(o)){E=E.replace("pin","");let x=n.find(L=>L._parsedProps.pinNumber===Number(E));const w=Array.isArray(_)?_[0]:_,P=Array.isArray(_)?_.slice(1):[];x?(x.externallyAddedAliases.push(w,...P),x.props.name=w):(x=new Hw({pinNumber:parseInt(E),name:w,aliases:[...P,...((c=e.additionalAliases)==null?void 0:c[`pin${parseInt(E)}`])??[]]},{originDescription:`pinLabels:pin${E}`}),n.push(x))}if(t.schematicSymbolName){const E=SI[this._getSchematicSymbolNameOrThrow()];if(!E)return;for(const _ of E.ports){const x=A7e(_.labels);if(!x)continue;const w=n.find(P=>P._parsedProps.pinNumber===Number(x));if(w)w.schematicSymbolPortDef=_;else{const P=XT(_.labels.concat(((u=e.additionalAliases)==null?void 0:u[`pin${x}`])??[]));P&&(P.originDescription=`schematicSymbol:labels[0]:${_.labels[0]}`,P.schematicSymbolPortDef=_,n.push(P))}}this.addAll(n)}if(!this._getSchematicPortArrangement()){const E=this.getPortsFromFootprint(e);for(const _ of E)n.some(x=>x.isMatchingAnyOf(_.getNameAndAliases()))||n.push(_)}for(let E=1;E<=(e.pinCount??this._getPinCount());E++){if(!i||n.find(x=>x._parsedProps.pinNumber===E))continue;let _=[...((A=i.leftSide)==null?void 0:A.pins)??[],...((d=i.rightSide)==null?void 0:d.pins)??[],...((f=i.topSide)==null?void 0:f.pins)??[],...((m=i.bottomSide)==null?void 0:m.pins)??[]].map(x=>ZT(x,this._parsedProps.pinLabels));["leftSize","rightSize","topSize","bottomSize","leftPinCount","rightPinCount","topPinCount","bottomPinCount"].some(x=>x in i)&&(_=Array.from({length:this._getPinCount()},(x,w)=>w+1)),_.includes(E)&&n.push(new Hw({pinNumber:E,aliases:((C=e.additionalAliases)==null?void 0:C[`pin${E}`])??[]},{originDescription:`notOtherwiseAddedButDeducedFromPinCount:${E}`}))}n.length>0&&this.addAll(n)}_getImpliedFootprintString(){return null}_isFootprintUrl(e){return e.startsWith("http://")||e.startsWith("https://")}_addChildrenFromStringFootprint(){var o;const{name:e,pcbRotation:t,pinLabels:n}=this.props;let{footprint:i}=this.props;if(i??(i=(o=this._getImpliedFootprintString)==null?void 0:o.call(this)),!!i&&typeof i=="string"){if(this._isFootprintUrl(i))return;const a=nL.string(i).soup(),s=u7e({componentName:e,componentRotation:t,footprint:i,pinLabels:n},a);this.addAll(s)}}get portMap(){return new Proxy({},{get:(e,t)=>{const n=this.children.find(i=>i.componentName==="Port"&&i.isMatchingNameOrAlias(t));if(!n)throw new Error(`There was an issue finding the port "${t.toString()}" inside of a ${this.componentName} component with name: "${this.props.name}". This is a bug in @tscircuit/core`);return n}})}getInstanceForReactElement(e){for(const t of this.reactSubtrees)if(t.element===e)return t.component;return null}doInitialSourceRender(){const e=this.config.sourceFtype;if(!e)return;const{db:t}=this.root,{_parsedProps:n}=this,i=t.source_component.insert({ftype:e,name:n.name,manufacturer_part_number:n.manufacturerPartNumber??n.mfn,supplier_part_numbers:n.supplierPartNumbers});this.source_component_id=i.source_component_id}doInitialSchematicComponentRender(){var i,o,a;if((i=this.root)!=null&&i.schematicDisabled)return;const{db:e}=this.root,{schematicSymbolName:t}=this.config;t?this._doInitialSchematicComponentRenderWithSymbol():this._getSchematicBoxDimensions()&&this._doInitialSchematicComponentRenderWithSchematicBoxDimensions();const n=(o=this.getSubcircuit())==null?void 0:o._getSchematicManualPlacementForComponent(this);if(this.schematic_component_id&&(this.props.schX!==void 0||this.props.schY!==void 0)&&n){if(!this.schematic_component_id)return;const s=r8.parse({type:"schematic_manual_edit_conflict_warning",schematic_manual_edit_conflict_warning_id:`schematic_manual_edit_conflict_${this.source_component_id}`,message:`${this.getString()} has both manual placement and prop coordinates. schX and schY will be used. Remove schX/schY or clear the manual placement.`,schematic_component_id:this.schematic_component_id,source_component_id:this.source_component_id,subcircuit_id:(a=this.getSubcircuit())==null?void 0:a.subcircuit_id});e.schematic_manual_edit_conflict_warning.insert(s)}}_getSchematicSymbolDisplayValue(){}_getInternallyConnectedPins(){if(this.internallyConnectedPinNames.length===0)return[];const e=[];for(const t of this.internallyConnectedPinNames){const n=[];for(const i of t)n.push(this.portMap[i]);e.push(n)}return e}_doInitialSchematicComponentRenderWithSymbol(){var a;if((a=this.root)!=null&&a.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this._getSchematicSymbolNameOrThrow(),i=SI[n],o=this._getGlobalSchematicPositionBeforeLayout();if(i){const s=e.schematic_component.insert({center:o,size:i.size,source_component_id:this.source_component_id,symbol_name:n,symbol_display_value:this._getSchematicSymbolDisplayValue()});this.schematic_component_id=s.schematic_component_id}}_doInitialSchematicComponentRenderWithSchematicBoxDimensions(){var A;if((A=this.root)!=null&&A.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this._getSchematicBoxDimensions(),i={};if(Array.isArray(t.pinLabels))t.pinLabels.forEach((d,f)=>{i[String(f+1)]=d});else for(const[d,f]of Object.entries(t.pinLabels??{}))i[d]=Array.isArray(f)?f[0]:f;const o=this._getGlobalSchematicPositionBeforeLayout(),a=this._getSchematicPortArrangement(),s=e.schematic_component.insert({center:o,rotation:t.schRotation??0,size:n.getSize(),port_arrangement:Bjt(a),pin_spacing:t.schPinSpacing??.2,pin_styles:xjt(t.schPinStyle,t.pinLabels),port_labels:i,source_component_id:this.source_component_id}),l=(a==null?void 0:a.topSide)!==void 0||(a==null?void 0:a.bottomSide)!==void 0,c=n==null?void 0:n.getSize().width,u=n==null?void 0:n.getSize().height;e.schematic_text.insert({text:t.manufacturerPartNumber??"",schematic_component_id:s.schematic_component_id,anchor:"left",rotation:0,position:{x:l?o.x+(c??0)/2+.1:o.x-(c??0)/2,y:l?o.y+(u??0)/2+.35:o.y-(u??0)/2-.13},color:"#006464",font_size:.18}),e.schematic_text.insert({text:t.name??"",schematic_component_id:s.schematic_component_id,anchor:"left",rotation:0,position:{x:l?o.x+(c??0)/2+.1:o.x-(c??0)/2,y:l?o.y+(u??0)/2+.55:o.y+(u??0)/2+.13},color:"#006464",font_size:.18}),this.schematic_component_id=s.schematic_component_id}doInitialPcbComponentRender(){var a;if((a=this.root)!=null&&a.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this.getSubcircuit(),i=e.pcb_component.insert({center:this._getGlobalPcbPositionBeforeLayout(),width:0,height:0,layer:t.layer??"top",rotation:t.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:n.subcircuit_id??void 0});if(!t.footprint&&!this.isGroup){const s=e.pcb_missing_footprint_error.insert({message:`No footprint found for component: ${this.getString()}`,source_component_id:`${this.source_component_id}`,error_type:"pcb_missing_footprint_error"});this.pcb_missing_footprint_error_id=s.pcb_missing_footprint_error_id}this.pcb_component_id=i.pcb_component_id;const o=this.getSubcircuit()._getPcbManualPlacementForComponent(this);if((this.props.pcbX!==void 0||this.props.pcbY!==void 0)&&o){const s=o8.parse({type:"pcb_manual_edit_conflict_warning",pcb_manual_edit_conflict_warning_id:`pcb_manual_edit_conflict_${this.source_component_id}`,message:`${this.getString()} has both manual placement and prop coordinates. pcbX and pcbY will be used. Remove pcbX/pcbY or clear the manual placement.`,pcb_component_id:this.pcb_component_id,source_component_id:this.source_component_id,subcircuit_id:n.subcircuit_id??void 0});e.pcb_manual_edit_conflict_warning.insert(s)}}doInitialPcbComponentSizeCalculation(){var o;if((o=this.root)!=null&&o.pcbDisabled||!this.pcb_component_id)return;const{db:e}=this.root,{_parsedProps:t}=this,n=Ece(this.children);if(n.width===0||n.height===0)return;const i={x:(n.minX+n.maxX)/2,y:(n.minY+n.maxY)/2};e.pcb_component.update(this.pcb_component_id,{center:i,width:n.width,height:n.height})}_renderReactSubtree(e){return{element:e,component:_jt(e)}}doInitialInitializePortsFromChildren(){this.initPorts()}doInitialReactSubtreesRender(){}doInitialPcbFootprintStringRender(){var o;let{footprint:e}=this.props;if(e??(e=(o=this._getImpliedFootprintString)==null?void 0:o.call(this)),!e)return;const{name:t,pcbRotation:n,pinLabels:i}=this.props;if(typeof e=="string"&&this._isFootprintUrl(e)){if(this._hasStartedFootprintUrlLoad)return;this._hasStartedFootprintUrlLoad=!0;const a=e;this._queueAsyncEffect("load-footprint-url",async()=>{const l=await(await fetch(a)).json(),c=u7e({componentName:t,componentRotation:n,footprint:a,pinLabels:i},l);this.addAll(c),this._markDirty("InitializePortsFromChildren")});return}if(pt.isValidElement(e)){if(this.reactSubtrees.some(s=>s.element===e))return;const a=this._renderReactSubtree(e);this.reactSubtrees.push(a),this.add(a.component);return}!pt.isValidElement(e)&&e.componentName==="Footprint"&&this.add(e)}_hasExistingPortExactly(e){return this.children.filter(n=>n.componentName==="Port").some(n=>{const i=e.getNameAndAliases(),o=n.getNameAndAliases();return i.length===o.length&&i.every(a=>o.includes(a))})}add(e){let t;if(pt.isValidElement(e)){const n=this._renderReactSubtree(e);this.reactSubtrees.push(n),t=n.component}else t=e;if(t.componentName==="Port"){if(this._hasExistingPortExactly(t))return;const i=this.children.filter(o=>o.componentName==="Port").find(o=>o.isMatchingAnyOf(t.getNameAndAliases()));i&&tJt(`Similar ports added. Port 1: ${i}, Port 2: ${t}`)}super.add(t)}getPortsFromFootprint(e){let{footprint:t}=this.props;if((!t||pt.isValidElement(t))&&(t=this.children.find(i=>i.componentName==="Footprint")),typeof t=="string"){if(this._isFootprintUrl(t))return[];const i=nL.string(t).soup(),o=[];for(const a of i)if("port_hints"in a&&a.port_hints){const s=XT(a.port_hints,e);if(!s)continue;s.originDescription=`footprint:string:${t}:port_hints[0]:${a.port_hints[0]}`,o.push(s)}return o}if(!pt.isValidElement(t)&&t&&t.componentName==="Footprint"){const i=t;let o=1;const a=[];for(const s of i.children){if(!s.props.portHints)continue;let l=s.props.portHints;l.some(A=>A.startsWith("pin"))||(l=[...l,`pin${o}`]),o++;const u=XT(l);u&&(u.originDescription=`footprint:${t}`,a.push(u))}return a}const n=[];if(!t){for(const i of this.children)if(i.props.portHints&&i.isPcbPrimitive){const o=XT(i.props.portHints);o&&n.push(o)}}return n}getPortsFromSchematicSymbol(){var i;if((i=this.root)!=null&&i.schematicDisabled)return[];const{config:e}=this;if(!e.schematicSymbolName)return[];const t=SI[e.schematicSymbolName];if(!t)return[];const n=[];for(const o of t.ports){const a=XT(o.labels);a&&(a.schematicSymbolPortDef=o,n.push(a))}return n}doInitialCreateNetsFromProps(){this._createNetsFromProps(this._getNetsFromConnectionsProp())}_getNetsFromConnectionsProp(){const{_parsedProps:e}=this,t=[];if(e.connections)for(const[n,i]of Object.entries(e.connections)){const o=Array.isArray(i)?i:[i];for(const a of o)t.push(a)}return t}_createNetsFromProps(e){a7e(this,e)}_getPcbCircuitJsonBounds(){const{db:e}=this.root;if(!this.pcb_component_id)return super._getPcbCircuitJsonBounds();const t=e.pcb_component.get(this.pcb_component_id);return{center:{x:t.center.x,y:t.center.y},bounds:{left:t.center.x-t.width/2,top:t.center.y-t.height/2,right:t.center.x+t.width/2,bottom:t.center.y+t.height/2},width:t.width,height:t.height}}_getPinCountFromSchematicPortArrangement(){const e=this._getSchematicPortArrangement();if(!e)return 0;if(!d7e(e))return(e.leftSize??e.leftPinCount??0)+(e.rightSize??e.rightPinCount??0)+(e.topSize??e.topPinCount??0)+(e.bottomSize??e.bottomPinCount??0);const{leftSide:n,rightSide:i,topSide:o,bottomSide:a}=e;return Math.max(...(n==null?void 0:n.pins)??[],...(i==null?void 0:i.pins)??[],...(o==null?void 0:o.pins)??[],...(a==null?void 0:a.pins)??[])}_getPinCount(){return this._getSchematicPortArrangement()?this._getPinCountFromSchematicPortArrangement():this.getPortsFromFootprint().length}_getSchematicPortArrangement(){return this._parsedProps.schPinArrangement??this._parsedProps.schPortArrangement}_getSchematicBoxDimensions(){if(this.getSchematicSymbol()||!this.config.shouldRenderAsSchematicBox)return null;const{_parsedProps:e}=this,t=this._getPinCount(),n=e.schPinSpacing??.2;return kjt({schWidth:e.schWidth,schHeight:e.schHeight,schPinSpacing:n,numericSchPinStyle:Ljt(e.schPinStyle,e.pinLabels),pinCount:t,schPortArrangement:this._getSchematicPortArrangement(),pinLabels:e.pinLabels})}doInitialCadModelRender(){var c;const{db:e}=this.root,{boardThickness:t=0}=((c=this.root)==null?void 0:c._getBoard())??{},n=this._parsedProps.cadModel;if(!this.pcb_component_id||!n&&!this.props.footprint||n===null)return;const i=this._getPcbCircuitJsonBounds(),o=e.pcb_component.get(this.pcb_component_id);if(typeof n=="string")throw new Error("String cadModel not yet implemented");const a=nJt.parse({x:0,y:0,z:typeof(n==null?void 0:n.rotationOffset)=="number"?n.rotationOffset:0,...typeof(n==null?void 0:n.rotationOffset)=="object"?n.rotationOffset??{}:{}}),s=S2.parse({x:0,y:0,z:0,...typeof(n==null?void 0:n.positionOffset)=="object"?n.positionOffset:{}}),l=this.props.layer==="bottom"?"bottom":"top";e.cad_component.insert({position:{x:i.center.x+s.x,y:i.center.y+s.y,z:(l==="bottom"?-t/2:t/2)+s.z},rotation:{x:a.x,y:(l==="top"?0:180)+a.y,z:l==="bottom"?-(((o==null?void 0:o.rotation)??0)+a.z)+180:((o==null?void 0:o.rotation)??0)+a.z},pcb_component_id:this.pcb_component_id,source_component_id:this.source_component_id,model_stl_url:"stlUrl"in(n??{})?this._addCachebustToModelUrl(n.stlUrl):void 0,model_obj_url:"objUrl"in(n??{})?this._addCachebustToModelUrl(n.objUrl):void 0,model_jscad:"jscad"in(n??{})?n.jscad:void 0,footprinter_string:typeof this.props.footprint=="string"&&!n?this.props.footprint:void 0})}_addCachebustToModelUrl(e){var n;if(!e||!e.includes("modelcdn.tscircuit.com"))return e;const t=((n=this.root)==null?void 0:n.getClientOrigin())??"";return`${e}${e.includes("?")?"&":"?"}cachebust_origin=${encodeURIComponent(t)}`}_getPartsEngineCacheKey(e,t){return JSON.stringify({ftype:e.ftype,name:e.name,manufacturer_part_number:e.manufacturer_part_number,footprinterString:t})}async _getSupplierPartNumbers(e,t,n){var l,c;if(this.props.doNotPlace)return{};const i=(c=(l=this.root)==null?void 0:l.platform)==null?void 0:c.localCacheEngine,o=this._getPartsEngineCacheKey(t,n);if(i){const u=await i.getItem(o);if(u)try{return JSON.parse(u)}catch{}}const a=await Promise.resolve(e.findPart({sourceComponent:t,footprinterString:n})),s=a==="Not found"?{}:a;if(i)try{await i.setItem(o,JSON.stringify(s))}catch{}return s}doInitialPartsEngineRender(){if(this.props.doNotPlace)return;const e=this.getInheritedProperty("partsEngine");if(!e)return;const{db:t}=this.root,n=t.source_component.get(this.source_component_id);if(!n||n.supplier_part_numbers)return;let i;this.props.footprint&&typeof this.props.footprint=="string"&&(i=this.props.footprint);const o=this._getSupplierPartNumbers(e,n,i);if(!(o instanceof Promise)){t.source_component.update(this.source_component_id,{supplier_part_numbers:o});return}this._queueAsyncEffect("get-supplier-part-numbers",async()=>{this._asyncSupplierPartNumbers=await o,this._markDirty("PartsEngineRender")})}updatePartsEngineRender(){if(this.props.doNotPlace)return;const{db:e}=this.root,t=e.source_component.get(this.source_component_id);if(t&&!t.supplier_part_numbers&&this._asyncSupplierPartNumbers){e.source_component.update(this.source_component_id,{supplier_part_numbers:this._asyncSupplierPartNumbers});return}}doInitialCreateTracesFromProps(){this._createTracesFromConnectionsProp()}_createTracesFromConnectionsProp(){const{_parsedProps:e}=this;if(e.connections)for(const[t,n]of Object.entries(e.connections)){const i=Array.isArray(n)?n:[n];for(const o of i)this.add(new Yw({from:`${this.getSubcircuitSelector()} > port.${t}`,to:o}))}}},rJt=class{constructor(r,e={}){Ye(this,"input");Ye(this,"isRouting",!1);Ye(this,"solver");Ye(this,"eventHandlers",{complete:[],error:[],progress:[]});Ye(this,"cycleCount",0);Ye(this,"stepDelay");Ye(this,"timeoutId");this.input=r;const{capacityDepth:t,targetMinCapacity:n,stepDelay:i=0}=e;this.solver=new oke(r,{capacityDepth:t,targetMinCapacity:n,cacheProvider:null}),this.stepDelay=i}start(){this.isRouting||(this.isRouting=!0,this.cycleCount=0,this.runCycleAndQueueNextCycle())}runCycleAndQueueNextCycle(){var r;if(this.isRouting)try{if(this.solver.solved||this.solver.failed){this.solver.failed?this.emitEvent({type:"error",error:new Error(this.solver.error||"Routing failed")}):this.emitEvent({type:"complete",traces:this.solver.getOutputSimpleRouteJson().traces||[]}),this.isRouting=!1;return}const e=Date.now(),t=this.solver.iterations;for(;Date.now()-e<250&&!this.solver.failed&&!this.solver.solved;)this.solver.step();const n=(this.solver.iterations-t)/(Date.now()-e)*1e3;this.cycleCount++;const i=((r=this.solver)==null?void 0:r.preview())||void 0,o=this.solver.progress;this.emitEvent({type:"progress",steps:this.cycleCount,iterationsPerSecond:n,progress:o,phase:this.solver.getCurrentPhase(),debugGraphics:i}),this.stepDelay>0?this.timeoutId=setTimeout(()=>this.runCycleAndQueueNextCycle(),this.stepDelay):this.timeoutId=setTimeout(()=>this.runCycleAndQueueNextCycle(),0)}catch(e){this.emitEvent({type:"error",error:e instanceof Error?e:new Error(String(e))}),this.isRouting=!1}}stop(){this.isRouting&&(this.isRouting=!1,this.timeoutId!==void 0&&(clearTimeout(this.timeoutId),this.timeoutId=void 0))}on(r,e){r==="complete"?this.eventHandlers.complete.push(e):r==="error"?this.eventHandlers.error.push(e):r==="progress"&&this.eventHandlers.progress.push(e)}emitEvent(r){if(r.type==="complete")for(const e of this.eventHandlers.complete)e(r);else if(r.type==="error")for(const e of this.eventHandlers.error)e(r);else if(r.type==="progress")for(const e of this.eventHandlers.progress)e(r)}solveSync(){if(this.solver.solve(),this.solver.failed)throw new Error(this.solver.error||"Routing failed");return this.solver.getOutputSimpleRouteJson().traces||[]}},y7e=class extends aI{constructor(){super(...arguments);Ye(this,"matchedPort",null)}get config(){return{componentName:"TraceHint",zodProps:u8e}}doInitialPortMatching(){const{db:e}=this.root,{_parsedProps:t,parent:n}=this;if(!n)return;if(n.componentName==="Trace"){this.renderError(`Port inference inside trace is not yet supported (${this})`);return}if(!n)throw new Error("TraceHint has no parent");if(!t.for){this.renderError(`TraceHint has no for property (${this})`);return}const i=n.selectOne(t.for,{type:"port"});i||this.renderError(`${this} could not find port for selector "${t.for}"`),this.matchedPort=i,i.registerMatch(this)}getPcbRouteHints(){const{_parsedProps:e}=this,t=e.offset?[e.offset]:e.offsets;if(!t)return[];const n=this._computePcbGlobalTransformBeforeLayout();return t.map(i=>({...Xr(n,i),via:i.via,to_layer:i.to_layer,trace_width:i.trace_width}))}doInitialPcbTraceHintRender(){var n,i,o;if((n=this.root)!=null&&n.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this;e.pcb_trace_hint.insert({pcb_component_id:(i=this.matchedPort)==null?void 0:i.pcb_component_id,pcb_port_id:(o=this.matchedPort)==null?void 0:o.pcb_port_id,route:this.getPcbRouteHints()})}},iJt=(r,e)=>{if(r_(r).pcb_trace_hint.get(e.pcb_trace_hint_id))r=r.map(n=>n.pcb_trace_hint_id===e.pcb_trace_hint_id?{...n,route:e.route}:n);else{const n=r_(r).pcb_port.get(e.pcb_port_id);r=r.filter(i=>!(i.type==="pcb_trace_hint"&&i.pcb_port_id===e.pcb_port_id)).concat([{type:"pcb_trace_hint",pcb_trace_hint_id:e.pcb_trace_hint_id,route:e.route,pcb_port_id:e.pcb_port_id,pcb_component_id:n==null?void 0:n.pcb_component_id}])}return r},oJt=({circuitJson:r,editEvents:e})=>{r=JSON.parse(JSON.stringify(r));for(const t of e)if(t.edit_event_type==="edit_pcb_component_location"){const n=r.find(o=>o.type==="pcb_component"&&o.pcb_component_id===t.pcb_component_id);if((!n||n.center.x!==t.new_center.x||n.center.y!==t.new_center.y)&&t.original_center){const o=$d(t.new_center.x-t.original_center.x,t.new_center.y-t.original_center.y);r=r.map(a=>a.pcb_component_id!==t.pcb_component_id?a:lke(a,o))}}else t.edit_event_type==="edit_schematic_component_location"?r=r.map(n=>n.type==="schematic_component"&&n.schematic_component_id===t.schematic_component_id?{...n,center:t.new_center}:n):t.edit_event_type==="edit_pcb_trace_hint"&&(r=iJt(r,t));return r},aJt=(r,e)=>{const t=r.source_group.list(),n=[],i=o=>{const a=t.filter(s=>s.parent_subcircuit_id===o);for(const s of a)s.subcircuit_id&&(n.push(s.subcircuit_id),i(s.subcircuit_id))};return i(e),n},v7e=({db:r,circuitJson:e,subcircuit_id:t,minTraceWidth:n=.1})=>{if(!r&&e&&(r=r_(e)),!r)throw new Error("db or circuitJson is required");const i=r.pcb_trace_hint.list(),o=t?new Set([t]):null;if(t){const C=aJt(r,t);for(const E of C)o.add(E)}const a=(e??r.toArray()).filter(C=>!t||"subcircuit_id"in C&&o.has(C.subcircuit_id)),s=r.pcb_board.list()[0];r=r_(a);const l=Tw(a),c=t6([...r.pcb_component.list(),...r.pcb_smtpad.list(),...r.pcb_plated_hole.list(),...r.pcb_hole.list(),...r.pcb_via.list()].filter(C=>!t||(o==null?void 0:o.has(C.subcircuit_id))),l);for(const C of c){const E=C.connectedTo.flatMap(_=>l.getIdsConnectedToNet(_));C.connectedTo.push(...E)}const u=c.flatMap(C=>[{x:C.center.x-C.width/2,y:C.center.y-C.height/2},{x:C.center.x+C.width/2,y:C.center.y+C.height/2}]);let A;s?A={minX:s.center.x-s.width/2,maxX:s.center.x+s.width/2,minY:s.center.y-s.height/2,maxY:s.center.y+s.height/2}:A={minX:Math.min(...u.map(C=>C.x))-1,maxX:Math.max(...u.map(C=>C.x))+1,minY:Math.min(...u.map(C=>C.y))-1,maxY:Math.max(...u.map(C=>C.y))+1};const d=r.source_trace.list().map(C=>{var H,K,q;const E=C.connected_source_port_ids.map(Y=>{const se=r.source_port.get(Y),ie=r.pcb_port.getWhere({source_port_id:Y});return{...se,...ie}});if(E.length<2)return null;const[_,x]=E,w=((H=_.layers)==null?void 0:H[0])??"top",P=((K=x.layers)==null?void 0:K[0])??"top",L=i.filter(Y=>Y.pcb_port_id===_.pcb_port_id||Y.pcb_port_id===x.pcb_port_id),O=[];for(const Y of L){const se=r.pcb_port.get(Y.pcb_port_id),ie=((q=se==null?void 0:se.layers)==null?void 0:q[0])??"top";for(const de of Y.route)O.push({x:de.x,y:de.y,layer:ie})}return{name:C.source_trace_id??l.getNetConnectedToId(C.source_trace_id)??"",source_trace_id:C.source_trace_id,pointsToConnect:[{x:_.x,y:_.y,layer:w},...O,{x:x.x,y:x.y,layer:P}]}}).filter(C=>C!==null),f=r.source_net.list().filter(C=>!t||(o==null?void 0:o.has(C.subcircuit_id))),m=[];for(const C of f){const E=r.source_trace.list().filter(_=>{var x;return(x=_.connected_source_net_ids)==null?void 0:x.includes(C.source_net_id)});m.push({name:C.source_net_id??l.getNetConnectedToId(C.source_net_id),pointsToConnect:E.flatMap(_=>r.pcb_port.list().filter(w=>_.connected_source_port_ids.includes(w.source_port_id)).map(w=>{var P;return{x:w.x,y:w.y,layer:((P=w.layers)==null?void 0:P[0])??"top",pcb_port_id:w.pcb_port_id}}))})}return{simpleRouteJson:{bounds:A,obstacles:c,connections:[...d,...m],layerCount:2,minTraceWidth:n},connMap:l}};function Bce(r,e){if("boxId"in r){const{boxId:t,pinNumber:n}=r,i=e.source_component.getWhere({name:t});if(!i)throw new Error(`Source component "${t}" not found, but returned from match-adapt ${JSON.stringify(r)}`);const o=e.source_port.getWhere({source_component_id:i.source_component_id,pin_number:n});return{subcircuit_connectivity_map_key:(o==null?void 0:o.subcircuit_connectivity_map_key)??null,source_port_id:o.source_port_id}}if("netId"in r){const{netId:t}=r;return e.source_net.getWhere({name:t}),null}if("junctionId"in r){const{junctionId:t}=r;return null}return null}function sJt({path:r,db:e,layoutConnMap:t}){let n=Bce(r.to,e)??Bce(r.from,e);if(!n){const o=t.getNetConnectedToId(D_(r.to));n=t.getIdsConnectedToNet(o).map(s=>L6(s)).map(s=>Bce(s,e)).find(Boolean)}if(!(n!=null&&n.subcircuit_connectivity_map_key))throw new Error(`No connectivity net id found for match-adapt path ${JSON.stringify(r)}`);const i=e.source_trace.list({subcircuit_connectivity_map_key:n.subcircuit_connectivity_map_key});for(const o of i)if(o.connected_source_port_ids.includes(n.source_port_id))return o.source_trace_id;if(i.length>0)return i[0].source_trace_id;throw new Error(`No source trace found for match-adapt path "${JSON.stringify(r)}"`)}function lJt(r){const{db:e}=r.root;let t=structuredClone(e.toArray());t=Ske(t);const n=bke(t),i=new Bke({inputNetlist:n});let o=null;try{i.solve(),o=i.getLayout()}catch(A){e.schematic_layout_error.insert({message:`Match-adapt layout failed: ${A.toString()}`,source_group_id:r.source_group_id,schematic_group_id:r.schematic_group_id});return}const{boxes:a,junctions:s,netLabels:l,paths:c}=o,u=new N9({});for(const A of c)u.addConnections([[D_(A.from),D_(A.to)]]);for(const A of s)for(const d of c)for(const f of d.points)Math.abs(f.x-A.x)<.001&&Math.abs(f.y-A.y)<.001&&u.addConnections([[D_(d.from),D_(A)],[D_(d.to),D_(A)]]);for(const A of a){const d=e.source_component.list().find(_=>_.name===A.boxId);if(!d)continue;const f=e.schematic_component.getWhere({source_component_id:d.source_component_id});if(!f)continue;const m={x:A.centerX-f.center.x+.1,y:A.centerY-f.center.y-.1};e.schematic_component.update(f.schematic_component_id,{center:{x:f.center.x+m.x,y:f.center.y+m.y}});const C=e.schematic_port.list({schematic_component_id:f.schematic_component_id});for(const _ of C)e.schematic_port.update(_.schematic_port_id,{center:{x:_.center.x+m.x,y:_.center.y+m.y}});const E=e.schematic_text.list({schematic_component_id:f.schematic_component_id});for(const _ of E)e.schematic_text.update(_.schematic_text_id,{position:{x:_.position.x+m.x,y:_.position.y+m.y}})}for(const A of l){const d=e.source_net.list().find(f=>f.name===A.netId);e.schematic_net_label.insert({text:A.netId,source_net_id:d==null?void 0:d.source_net_id,anchor_position:{x:A.x,y:A.y},center:{x:A.x,y:A.y},anchor_side:A.anchorPosition})}for(const A of c){if(!A.points||A.points.length<2)continue;const d=sJt({path:A,db:TB(t),layoutConnMap:u});let f=[];for(let E=0;E<A.points.length-1;E++)f.push({from:{x:A.points[E].x,y:A.points[E].y},to:{x:A.points[E+1].x,y:A.points[E+1].y}});const m=J7({db:e,source_trace_id:d,differentNetOnly:!0}).flatMap(E=>E.edges);m.length>0&&(f=g7e({edges:f,otherEdges:m}));const C=m7e({edges:f,db:e,source_trace_id:d});e.schematic_trace.insert({source_trace_id:d,edges:f,junctions:C})}}function cJt(r){if(!r.isSubcircuit)return;const{db:e}=r.root,t=r.selectAll("trace"),n=new N9({});n.addConnections(t.map(s=>{const l=e.source_trace.get(s.source_trace_id);return l?[l.source_trace_id,...l.connected_source_port_ids,...l.connected_source_net_ids]:null}).filter(s=>s!==null));const{name:i}=r._parsedProps;for(const s of t){if(!s.source_trace_id)continue;const l=n.getNetConnectedToId(s.source_trace_id);l&&(s.subcircuit_connectivity_map_key=`${i??`unnamedsubcircuit${r._renderId}`}_${l}`,e.source_trace.update(s.source_trace_id,{subcircuit_connectivity_map_key:s.subcircuit_connectivity_map_key}))}const o=new Set;for(const s of t){if(!s.source_trace_id)continue;const l=e.source_trace.get(s.source_trace_id);if(l)for(const c of l.connected_source_port_ids)o.add(c)}for(const s of o){const l=n.getNetConnectedToId(s);if(!l)continue;const c=`${i??`unnamedsubcircuit${r._renderId}`}_${l}`;e.source_port.update(s,{subcircuit_connectivity_map_key:c})}const a=new Set;for(const s of t){if(!s.source_trace_id)continue;const l=e.source_trace.get(s.source_trace_id);if(l)for(const c of l.connected_source_net_ids)a.add(c)}for(const s of a){const l=n.getNetConnectedToId(s);if(!l)continue;const c=`${i??`unnamedsubcircuit${r._renderId}`}_${l}`;e.source_net.update(s,{subcircuit_connectivity_map_key:c})}}function uJt(r){var x;const{db:e}=r.root,t=r._parsedProps,n=r.children.filter(w=>w.schematic_component_id);if(n.length===0)return;let i=0,o=0;for(const w of n){const P=e.schematic_component.get(w.schematic_component_id);P!=null&&P.size&&(i=Math.max(i,P.size.width),o=Math.max(o,P.size.height))}i===0&&n.length>0&&(i=1),o===0&&n.length>0&&(o=1);let a=t.gridCols,s,l=t.gridGap;(x=t.schLayout)!=null&&x.grid&&(a=t.schLayout.grid.cols??a,s=t.schLayout.grid.rows,l=t.schLayout.grid.gap??l);let c,u;a!==void 0&&s!==void 0?(c=a,u=s):a!==void 0?(c=a,u=Math.ceil(n.length/c)):s!==void 0?(u=s,c=Math.ceil(n.length/u)):(c=Math.ceil(Math.sqrt(n.length)),u=Math.ceil(n.length/c)),c===0&&n.length>0&&(c=1),u===0&&n.length>0&&(u=n.length);let A,d;typeof l=="number"?(A=l,d=l):typeof l=="object"&&l!==null?(A=l.x,d=l.y):(A=1,d=1);const f=c*i+Math.max(0,c-1)*A,m=u*o+Math.max(0,u-1)*d,C=r._getGlobalSchematicPositionBeforeLayout(),E=C.x-f/2+i/2,_=C.y+m/2-o/2;for(let w=0;w<n.length;w++){const P=n[w];if(!P.schematic_component_id)continue;const L=Math.floor(w/c),O=w%c;if(L>=u||O>=c){console.warn(`Schematic grid layout: Child ${P.getString()} at index ${w} (row ${L}, col ${O}) exceeds specified grid dimensions (${u}x${c}). Skipping placement.`);continue}const H=E+O*(i+A),K=_-L*(o+d),q=e.schematic_component.get(P.schematic_component_id);if(q){const Y=q.center,se={x:H,y:K};e.schematic_component.update(P.schematic_component_id,{center:se});const ie=se.x-Y.x,de=se.y-Y.y,Ce=e.schematic_port.list({schematic_component_id:P.schematic_component_id});for(const fe of Ce)e.schematic_port.update(fe.schematic_port_id,{center:{x:fe.center.x+ie,y:fe.center.y+de}});const xe=e.schematic_text.list({schematic_component_id:P.schematic_component_id});for(const fe of xe)e.schematic_text.update(fe.schematic_text_id,{position:{x:fe.position.x+ie,y:fe.position.y+de}})}}r.schematic_group_id&&e.schematic_group.update(r.schematic_group_id,{width:f,height:m,center:C})}function AJt(r){var x;const{db:e}=r.root,t=r._parsedProps,n=r.children.filter(w=>w.pcb_component_id);if(n.length===0)return;let i=0,o=0;for(const w of n){const P=e.pcb_component.get(w.pcb_component_id);P&&(i=Math.max(i,P.width),o=Math.max(o,P.height))}i===0&&n.length>0&&(i=1),o===0&&n.length>0&&(o=1);let a=t.gridCols,s,l=t.gridGap;(x=t.pcbLayout)!=null&&x.grid&&(a=t.pcbLayout.grid.cols??a,s=t.pcbLayout.grid.rows,l=t.pcbLayout.grid.gap??l);let c,u;a!==void 0&&s!==void 0?(c=a,u=s):a!==void 0?(c=a,u=Math.ceil(n.length/c)):s!==void 0?(u=s,c=Math.ceil(n.length/u)):(c=Math.ceil(Math.sqrt(n.length)),u=Math.ceil(n.length/c)),c===0&&n.length>0&&(c=1),u===0&&n.length>0&&(u=n.length);let A,d;typeof l=="number"?(A=l,d=l):typeof l=="object"&&l!==null?(A=l.x,d=l.y):(A=1,d=1);const f=c*i+Math.max(0,c-1)*A,m=u*o+Math.max(0,u-1)*d,C=r._getGlobalPcbPositionBeforeLayout(),E=C.x-f/2+i/2,_=C.y+m/2-o/2;for(let w=0;w<n.length;w++){const P=n[w];if(!P.pcb_component_id)continue;const L=Math.floor(w/c),O=w%c;if(L>=u||O>=c){console.warn(`PCB grid layout: Child ${P.getString()} at index ${w} (row ${L}, col ${O}) exceeds grid dimensions (${u}x${c}). Skipping placement.`);continue}const H=E+O*(i+A),K=_-L*(o+d),q=e.pcb_component.get(P.pcb_component_id);if(q){const Y=q.center,se={x:H,y:K},ie=se.x-Y.x,de=se.y-Y.y,Ce=$d(ie,de),xe=e.toArray().filter(Ie=>Ie.pcb_component_id===P.pcb_component_id),fe=cke(xe,Ce);for(const Ie of fe){const ve=IT(Ie);e[Ie.type].update(Ie[ve],Ie)}e.pcb_component.update(P.pcb_component_id,{center:se}),P.setProps({...P.props,pcbX:(P.props.pcbX??0)+ie,pcbY:(P.props.pcbY??0)+de})}}r.pcb_group_id&&e.pcb_group.update(r.pcb_group_id,{width:f,height:m,center:C})}var bce=class extends L1{constructor(){super(...arguments);Ye(this,"pcb_group_id",null);Ye(this,"schematic_group_id",null);Ye(this,"subcircuit_id",null);Ye(this,"_hasStartedAsyncAutorouting",!1);Ye(this,"_asyncAutoroutingResult",null)}get config(){return{zodProps:SPe,componentName:"Group"}}doInitialSourceRender(){const{db:e}=this.root,t=e.source_group.insert({name:this._parsedProps.name,is_subcircuit:this.isSubcircuit});this.subcircuit_id=`subcircuit_${t.source_group_id}`,this.source_group_id=t.source_group_id,e.source_group.update(t.source_group_id,{subcircuit_id:this.subcircuit_id});for(const n of this.children)e.source_component.update(n.source_component_id,{source_group_id:this.source_group_id})}doInitialSourceParentAttachment(){var n,i,o;const{db:e}=this.root;if(!this.isSubcircuit)return;const t=(o=(i=(n=this.parent)==null?void 0:n.getSubcircuit)==null?void 0:i.call(n))==null?void 0:o.subcircuit_id;t&&e.source_group.update(this.source_group_id,{parent_subcircuit_id:t})}doInitialPcbComponentRender(){var i;if((i=this.root)!=null&&i.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=e.pcb_group.insert({is_subcircuit:this.isSubcircuit,subcircuit_id:this.subcircuit_id,name:this._parsedProps.name,center:this._getGlobalPcbPositionBeforeLayout(),width:0,height:0,pcb_component_ids:[],source_group_id:this.source_group_id});this.pcb_group_id=n.pcb_group_id;for(const o of this.children)e.pcb_component.update(o.pcb_component_id,{pcb_group_id:n.pcb_group_id})}doInitialPcbPrimitiveRender(){var n;if((n=this.root)!=null&&n.pcbDisabled)return;const{db:e}=this.root,t=Ece(this.children);this.pcb_group_id&&e.pcb_group.update(this.pcb_group_id,{width:t.width,height:t.height,center:{x:(t.minX+t.maxX)/2,y:(t.minY+t.maxY)/2}})}doInitialCreateTraceHintsFromProps(){var o;const{_parsedProps:e}=this,{db:t}=this.root,n=e;if(!this.isSubcircuit)return;const i=(o=n.layout)==null?void 0:o.manual_trace_hints;if(i)for(const a of i)this.add(new y7e({for:a.pcb_port_selector,offsets:a.offsets}))}doInitialSourceAddConnectivityMapKey(){cJt(this)}_areChildSubcircuitsRouted(){const e=this.selectAll("group").filter(t=>t.isSubcircuit);for(const t of e)if(t._shouldRouteAsync()&&!t._asyncAutoroutingResult)return!1;return!0}_shouldRouteAsync(){const e=this._getAutorouterConfig();return e.groupMode==="sequential-trace"?!1:!!(e.local&&e.groupMode==="subcircuit"||!e.local)}_hasTracesToRoute(){const e=uC("tscircuit:core:_hasTracesToRoute"),t=this.selectAll("trace");return e(`[${this.getString()}] has ${t.length} traces to route`),t.length>0}async _runEffectMakeHttpAutoroutingRequest(){var c,u,A,d;const{db:e}=this.root,t=uC("tscircuit:core:_runEffectMakeHttpAutoroutingRequest");this._parsedProps;const n=this._getAutorouterConfig(),i=n.serverUrl,o=n.serverMode,a=(f,m)=>{var C;return t("fetching",f),m.headers&&(m.headers["Tscircuit-Core-Version"]=(C=this.root)==null?void 0:C.getCoreVersion()),fetch(f,m)},s=this.root.db.toArray().filter(f=>f.type.startsWith("source_")||f.type.startsWith("pcb_"));if(o==="solve-endpoint"){if(((c=this.props.autorouter)==null?void 0:c.inputFormat)==="simplified"){const{autorouting_result:m}=await a(`${i}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_simple_route_json:v7e({db:e,minTraceWidth:((u=this.props.autorouter)==null?void 0:u.minTraceWidth)??.15,subcircuit_id:this.subcircuit_id}).simpleRouteJson,subcircuit_id:this.subcircuit_id}),headers:{"Content-Type":"application/json"}}).then(C=>C.json());this._asyncAutoroutingResult=m,this._markDirty("PcbTraceRender");return}const{autorouting_result:f}=await a(`${i}/autorouting/solve`,{method:"POST",body:JSON.stringify({input_circuit_json:s,subcircuit_id:this.subcircuit_id}),headers:{"Content-Type":"application/json"}}).then(m=>m.json());this._asyncAutoroutingResult=f,this._markDirty("PcbTraceRender");return}const{autorouting_job:l}=await a(`${i}/autorouting/jobs/create`,{method:"POST",body:JSON.stringify({input_circuit_json:s,provider:"freerouting",autostart:!0,display_name:(A=this.root)==null?void 0:A.name,subcircuit_id:this.subcircuit_id,server_cache_enabled:n.serverCacheEnabled}),headers:{"Content-Type":"application/json"}}).then(f=>f.json());for(;;){const{autorouting_job:f}=await a(`${i}/autorouting/jobs/get`,{method:"POST",body:JSON.stringify({autorouting_job_id:l.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(m=>m.json());if(f.is_finished){const{autorouting_job_output:m}=await a(`${i}/autorouting/jobs/get_output`,{method:"POST",body:JSON.stringify({autorouting_job_id:l.autorouting_job_id}),headers:{"Content-Type":"application/json"}}).then(C=>C.json());this._asyncAutoroutingResult={output_pcb_traces:m.output_pcb_traces},this._markDirty("PcbTraceRender");break}if(f.has_error)throw e.pcb_autorouting_error.insert({pcb_error_id:l.autorouting_job_id,message:((d=f.error)==null?void 0:d.message)??JSON.stringify(f.error)}),new Error(`Autorouting job failed: ${JSON.stringify(f.error)}`);await new Promise(m=>setTimeout(m,100))}}async _runLocalAutorouting(){var s,l,c,u,A;const{db:e}=this.root;this._parsedProps;const t=uC("tscircuit:core:_runLocalAutorouting");t(`[${this.getString()}] starting local autorouting`);const n=this._getAutorouterConfig(),{simpleRouteJson:i}=v7e({db:e,minTraceWidth:((s=this.props.autorouter)==null?void 0:s.minTraceWidth)??.15,subcircuit_id:this.subcircuit_id});(l=this.root)==null||l.emit("autorouting:start",{subcircuit_id:this.subcircuit_id,componentDisplayName:this.getString(),simpleRouteJson:i});let o;n.algorithmFn?o=await n.algorithmFn(i):o=new rJt(i,{capacityDepth:(c=this.props.autorouter)==null?void 0:c.capacityDepth,targetMinCapacity:(u=this.props.autorouter)==null?void 0:u.targetMinCapacity});const a=new Promise((d,f)=>{o.on("complete",m=>{t(`[${this.getString()}] local autorouting complete`),d(m.traces)}),o.on("error",m=>{t(`[${this.getString()}] local autorouting error: ${m.error.message}`),f(m.error)})});o.on("progress",d=>{var f;(f=this.root)==null||f.emit("autorouting:progress",{subcircuit_id:this.subcircuit_id,componentDisplayName:this.getString(),...d})}),o.start();try{const d=await a;this._asyncAutoroutingResult={output_pcb_traces:d},this._markDirty("PcbTraceRender")}catch(d){const{db:f}=this.root;throw f.pcb_autorouting_error.insert({pcb_error_id:`pcb_autorouter_error_subcircuit_${this.subcircuit_id}`,message:d instanceof Error?d.message:String(d)}),(A=this.root)==null||A.emit("autorouting:error",{subcircuit_id:this.subcircuit_id,componentDisplayName:this.getString(),error:{message:d instanceof Error?d.message:String(d)},simpleRouteJson:i}),d}finally{o.stop()}}_startAsyncAutorouting(){this._hasStartedAsyncAutorouting||(this._hasStartedAsyncAutorouting=!0,this._getAutorouterConfig().local?this._queueAsyncEffect("capacity-mesh-autorouting",async()=>this._runLocalAutorouting()):this._queueAsyncEffect("make-http-autorouting-request",async()=>this._runEffectMakeHttpAutoroutingRequest()))}doInitialPcbTraceRender(){var t;const e=uC("tscircuit:core:doInitialPcbTraceRender");if(this.isSubcircuit&&!((t=this.root)!=null&&t.pcbDisabled)&&!this.getInheritedProperty("routingDisabled")&&!this._shouldUseTraceByTraceRouting()){if(!this._areChildSubcircuitsRouted()){e(`[${this.getString()}] child subcircuits are not routed, skipping async autorouting until subcircuits routed`);return}e(`[${this.getString()}] no child subcircuits to wait for, initiating async routing`),this._hasTracesToRoute()&&this._startAsyncAutorouting()}}updatePcbTraceRender(){var n;const e=uC("tscircuit:core:updatePcbTraceRender");if(e(`[${this.getString()}] updating...`),!this.isSubcircuit)return;if(this._shouldRouteAsync()&&this._hasTracesToRoute()&&!this._hasStartedAsyncAutorouting){this._areChildSubcircuitsRouted()&&(e(`[${this.getString()}] child subcircuits are now routed, starting async autorouting`),this._startAsyncAutorouting());return}if(!this._asyncAutoroutingResult||this._shouldUseTraceByTraceRouting())return;const{db:t}=this.root;if(this._asyncAutoroutingResult.output_simple_route_json){e(`[${this.getString()}] updating PCB traces from simple route json (${(n=this._asyncAutoroutingResult.output_simple_route_json.traces)==null?void 0:n.length} traces)`),this._updatePcbTraceRenderFromSimpleRouteJson();return}if(this._asyncAutoroutingResult.output_pcb_traces){e(`[${this.getString()}] updating PCB traces from ${this._asyncAutoroutingResult.output_pcb_traces.length} traces`),this._updatePcbTraceRenderFromPcbTraces();return}}_updatePcbTraceRenderFromSimpleRouteJson(){const{db:e}=this.root,{traces:t}=this._asyncAutoroutingResult.output_simple_route_json;if(t)for(const n of t)e.pcb_trace.insert({subcircuit_id:this.subcircuit_id,route:n.route})}_updatePcbTraceRenderFromPcbTraces(){const{output_pcb_traces:e}=this._asyncAutoroutingResult;if(!e)return;const{db:t}=this.root;for(const n of e)if(n.type==="pcb_trace"){if(n.subcircuit_id=this.subcircuit_id,n.connection_name){const i=n.connection_name;n.source_trace_id=i}t.pcb_trace.insert(n)}for(const n of e)if(n.type!=="pcb_via"&&n.type==="pcb_trace")for(const i of n.route)i.route_type==="via"&&t.pcb_via.insert({pcb_trace_id:n.pcb_trace_id,x:i.x,y:i.y,hole_diameter:.3,outer_diameter:.6,layers:[i.from_layer,i.to_layer],from_layer:i.from_layer,to_layer:i.to_layer})}doInitialSchematicComponentRender(){var i;if((i=this.root)!=null&&i.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=e.schematic_group.insert({is_subcircuit:this.isSubcircuit,subcircuit_id:this.subcircuit_id,name:this._parsedProps.name,center:this._getGlobalSchematicPositionBeforeLayout(),width:0,height:0,schematic_component_ids:[],source_group_id:this.source_group_id});this.schematic_group_id=n.schematic_group_id;for(const o of this.children)o.schematic_component_id&&e.schematic_component.update(o.schematic_component_id,{schematic_group_id:n.schematic_group_id})}_getSchematicLayoutMode(){var t,n,i;const e=this._parsedProps;return(t=e.schLayout)!=null&&t.matchAdapt?"match-adapt":(n=e.schLayout)!=null&&n.flex?"flex":(i=e.schLayout)!=null&&i.grid?"grid":e.matchAdapt?"match-adapt":e.flex?"flex":e.grid?"grid":"none"}doInitialSchematicLayout(){this._parsedProps;const e=this._getSchematicLayoutMode();e==="match-adapt"&&this._doInitialSchematicLayoutMatchAdapt(),e==="grid"&&this._doInitialSchematicLayoutGrid()}_doInitialSchematicLayoutMatchAdapt(){lJt(this)}_doInitialSchematicLayoutGrid(){uJt(this)}_getPcbLayoutMode(){var t,n,i;const e=this._parsedProps;return(t=e.pcbLayout)!=null&&t.matchAdapt?"match-adapt":(n=e.pcbLayout)!=null&&n.flex?"flex":(i=e.pcbLayout)!=null&&i.grid?"grid":e.matchAdapt?"match-adapt":e.flex?"flex":e.grid?"grid":"none"}doInitialPcbLayout(){this._getPcbLayoutMode()==="grid"&&this._doInitialPcbLayoutGrid()}_doInitialPcbLayoutGrid(){AJt(this)}_determineSideFromPosition(e,t){if(!e.center||!t.center)return"left";const n=e.center.x-t.center.x,i=e.center.y-t.center.y;return Math.abs(n)>Math.abs(i)?n>0?"right":"left":i>0?"bottom":"top"}_calculateSchematicBounds(e){if(e.length===0)return{minX:0,maxX:0,minY:0,maxY:0};let t=1/0,n=-1/0,i=1/0,o=-1/0;for(const s of e)t=Math.min(t,s.centerX),n=Math.max(n,s.centerX),i=Math.min(i,s.centerY),o=Math.max(o,s.centerY);const a=2;return{minX:t-a,maxX:n+a,minY:i-a,maxY:o+a}}_getAutorouterConfig(){const e={serverUrl:"https://registry-api.tscircuit.com",serverMode:"job",serverCacheEnabled:!0},t=this._parsedProps.autorouter??this.getInheritedProperty("autorouter");return typeof t=="object"?{local:!(t.serverUrl||t.serverMode||t.serverCacheEnabled),...e,...t}:t==="auto-local"?{local:!0,groupMode:"subcircuit"}:t==="sequential-trace"?{local:!0,groupMode:"sequential-trace"}:t==="subcircuit"?{local:!0,groupMode:"subcircuit"}:t==="auto-cloud"?{local:!1,groupMode:"subcircuit",serverUrl:e.serverUrl,serverMode:e.serverMode,serverCacheEnabled:!0}:{local:!0,groupMode:"subcircuit"}}_shouldUseTraceByTraceRouting(){return this._getAutorouterConfig().groupMode==="sequential-trace"}doInitialPcbDesignRuleChecks(){var t;if((t=this.root)!=null&&t.pcbDisabled||this.getInheritedProperty("routingDisabled"))return;const{db:e}=this.root;if(this.isSubcircuit){const n=new Map;for(const i of this.children)if(!i.isSubcircuit&&i._parsedProps.name){const o=n.get(i._parsedProps.name)||[];o.push(i),n.set(i._parsedProps.name,o)}for(const[i,o]of n.entries())o.length>1&&e.pcb_trace_error.insert({error_type:"pcb_trace_error",message:`Multiple components found with name "${i}" in subcircuit "${this._parsedProps.name||"unnamed"}". Component names must be unique within a subcircuit.`,source_trace_id:"",pcb_trace_id:"",pcb_component_ids:o.map(a=>a.pcb_component_id).filter(Boolean),pcb_port_ids:[]})}}doInitialSchematicReplaceNetLabelsWithSymbols(){var t;if((t=this.root)!=null&&t.schematicDisabled)return;const{db:e}=this.root;for(const n of e.schematic_net_label.list()){const i=e.source_net.get(n.source_net_id),o=n.text||(i==null?void 0:i.name)||"";if(n.anchor_side==="top"&&/^gnd/i.test(o)){e.schematic_net_label.update(n.schematic_net_label_id,{symbol_name:"ground_down"});continue}n.anchor_side==="bottom"&&/^v/i.test(o)&&e.schematic_net_label.update(n.schematic_net_label_id,{symbol_name:"vcc_up"})}}},dJt=class extends bce{constructor(){super(...arguments);Ye(this,"pcb_board_id",null);Ye(this,"_drcChecksComplete",!1);Ye(this,"_connectedSchematicPortPairs",new Set)}get isSubcircuit(){return!0}get isGroup(){return!0}get config(){return{componentName:"Board",zodProps:bae}}get boardThickness(){const{_parsedProps:e}=this;return 1.4}get allLayers(){return["top","bottom","inner1","inner2"]}doInitialPcbBoardAutoSize(){var f;if((f=this.root)!=null&&f.pcbDisabled||!this.pcb_board_id)return;const{db:e}=this.root,{_parsedProps:t}=this;if(t.width&&t.height)return;let n=1/0,i=1/0,o=-1/0,a=-1/0;const s=e.pcb_component.list();let l=!1;for(const m of s){const{width:C,height:E,center:_}=m;C===0||E===0||(l=!0,n=Math.min(n,_.x-C/2),i=Math.min(i,_.y-E/2),o=Math.max(o,_.x+C/2),a=Math.max(a,_.y+E/2))}const c=2,u=l?o-n+c*2:0,A=l?a-i+c*2:0,d={x:l?(n+o)/2+(t.outlineOffsetX??0):t.outlineOffsetX??0,y:l?(i+a)/2+(t.outlineOffsetY??0):t.outlineOffsetY??0};e.pcb_board.update(this.pcb_board_id,{width:u,height:A,center:d})}doInitialPcbComponentRender(){var a,s;if((a=this.root)!=null&&a.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this;let n=t.width??0,i=t.height??0;if(t.outline){const l=t.outline.map(m=>m.x),c=t.outline.map(m=>m.y),u=Math.min(...l),A=Math.max(...l),d=Math.min(...c),f=Math.max(...c);n=A-u,i=f-d}const o=e.pcb_board.insert({center:{x:(t.pcbX??0)+(t.outlineOffsetX??0),y:(t.pcbY??0)+(t.outlineOffsetY??0)},thickness:this.boardThickness,num_layers:this.allLayers.length,width:n,height:i,outline:(s=t.outline)==null?void 0:s.map(l=>({x:l.x+(t.outlineOffsetX??0),y:l.y+(t.outlineOffsetY??0)})),material:t.material});this.pcb_board_id=o.pcb_board_id}removePcbComponentRender(){const{db:e}=this.root;this.pcb_board_id&&(e.pcb_board.delete(this.pcb_board_id),this.pcb_board_id=null)}_computePcbGlobalTransformBeforeLayout(){return Ny()}doInitialPcbDesignRuleChecks(){var e;(e=this.root)!=null&&e.pcbDisabled||this.getInheritedProperty("routingDisabled")||super.doInitialPcbDesignRuleChecks()}updatePcbDesignRuleChecks(){var n;if((n=this.root)!=null&&n.pcbDisabled||this.getInheritedProperty("routingDisabled"))return;const{db:e}=this.root;if(!this._areChildSubcircuitsRouted()||this._drcChecksComplete)return;this._drcChecksComplete=!0;const t=pke(e.toArray());for(const i of t)e.pcb_trace_error.insert(i)}_emitRenderLifecycleEvent(e,t){var n;super._emitRenderLifecycleEvent(e,t),t==="start"&&((n=this.root)==null||n.emit("board:renderPhaseStarted",{renderId:this._renderId,phase:e}))}},fJt=new Proxy({},{get:(r,e)=>e}),nM=fJt,hJt=class extends L1{get config(){return{componentName:"Capacitor",schematicSymbolName:this.props.polarized?"capacitor_polarized":this.props.symbolName??"capacitor",zodProps:TPe,sourceFtype:nM.simple_capacitor}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}_getSchematicSymbolDisplayValue(){const r=`${i_(this._parsedProps.capacitance)}F`;return this._parsedProps.schShowRatings&&this._parsedProps.maxVoltageRating?`${r}/${i_(this._parsedProps.maxVoltageRating)}V`:r}doInitialCreateNetsFromProps(){this._createNetsFromProps([this.props.decouplingFor,this.props.decouplingTo,...this._getNetsFromConnectionsProp()])}doInitialCreateTracesFromProps(){this.props.decouplingFor&&this.props.decouplingTo&&(this.add(new Yw({from:`${this.getSubcircuitSelector()} > port.1`,to:this.props.decouplingFor})),this.add(new Yw({from:`${this.getSubcircuitSelector()} > port.2`,to:this.props.decouplingTo}))),this._createTracesFromConnectionsProp()}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_capacitor",name:e.name,manufacturer_part_number:e.manufacturerPartNumber??e.mfn,supplier_part_numbers:e.supplierPartNumbers,capacitance:e.capacitance,max_voltage_rating:e.maxVoltageRating,max_decoupling_trace_length:e.maxDecouplingTraceLength,display_capacitance:this._getSchematicSymbolDisplayValue(),are_pins_interchangeable:!e.polarized});this.source_component_id=t.source_component_id}},I7e=class extends L1{constructor(){super(...arguments);Ye(this,"schematicBoxDimensions",null)}get config(){return{componentName:"Chip",zodProps:Sae,shouldRenderAsSchematicBox:!0}}doInitialSchematicComponentRender(){const{_parsedProps:e}=this;(e==null?void 0:e.noSchematicRepresentation)!==!0&&super.doInitialSchematicComponentRender()}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_chip",name:t.name,manufacturer_part_number:t.manufacturerPartNumber,supplier_part_numbers:t.supplierPartNumbers});this.source_component_id=n.source_component_id}doInitialPcbComponentRender(){var i;if((i=this.root)!=null&&i.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=e.pcb_component.insert({center:{x:t.pcbX??0,y:t.pcbY??0},width:2,height:3,layer:t.layer??"top",rotation:t.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0});this.pcb_component_id=n.pcb_component_id}doInitialCreateTracesFromProps(){const{_parsedProps:e}=this;if(e.externallyConnectedPins)for(const[t,n]of e.externallyConnectedPins)this.add(new Yw({from:`${this.getSubcircuitSelector()} > port.${t}`,to:`${this.getSubcircuitSelector()} > port.${n}`}));this._createTracesFromConnectionsProp()}},pJt=class extends L1{constructor(){super(...arguments);Ye(this,"pos",this.portMap.pin1);Ye(this,"anode",this.portMap.pin1);Ye(this,"neg",this.portMap.pin2);Ye(this,"cathode",this.portMap.pin2)}get config(){return{schematicSymbolName:this.props.symbolName??"diode",componentName:"Diode",zodProps:WPe,sourceFtype:"simple_diode"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_diode",name:t.name,manufacturer_part_number:t.manufacturerPartNumber??t.mfn,supplier_part_numbers:t.supplierPartNumbers,are_pins_interchangeable:!1});this.source_component_id=n.source_component_id}},gJt=class extends L1{get config(){return{componentName:"fuse",schematicSymbolName:this.props.symbolName??"fuse",zodProps:wPe,sourceFtype:nM.simple_fuse}}_getSchematicSymbolDisplayValue(){const r=this._parsedProps.currentRating,e=this._parsedProps.voltageRating,t=typeof r=="string"?parseFloat(r):r,n=typeof e=="string"?parseFloat(e):e;return`${i_(t)}A / ${i_(n)}V`}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=typeof e.currentRating=="string"?parseFloat(e.currentRating):e.currentRating,n=typeof e.voltageRating=="string"?parseFloat(e.voltageRating):e.voltageRating,i=r.source_component.insert({name:e.name,ftype:nM.simple_fuse,current_rating_amps:t,voltage_rating_volts:n,display_current_rating:`${i_(t)}A`,display_voltage_rating:`${i_(n)}V`});this.source_component_id=i.source_component_id}},mJt=class extends L1{constructor(){super(...arguments);Ye(this,"schematicDimensions",null)}get config(){let e="";if(this.props.pinCount&&(e+=`solderjumper${this.props.pinCount||2}`),Array.isArray(this.props.internallyConnectedPins)&&this.props.internallyConnectedPins.length>0){const t=Array.from(new Set(this.props.internallyConnectedPins.flat())).sort().join("");e+=`_bridged${t}`}return{schematicSymbolName:e,componentName:"Jumper",zodProps:Qae,shouldRenderAsSchematicBox:!0}}_getSchematicPortArrangement(){const e=super._getSchematicPortArrangement();if(e)return e;const t=this._parsedProps.pinCount??(Array.isArray(this._parsedProps.pinLabels)?this._parsedProps.pinLabels.length:this._parsedProps.pinLabels?Object.keys(this._parsedProps.pinLabels).length:this.getPortsFromFootprint().length),n=this._parsedProps.schDirection??"right";return{leftSize:n==="left"?t:0,rightSize:n==="right"?t:0}}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_chip",name:t.name,manufacturer_part_number:t.manufacturerPartNumber,supplier_part_numbers:t.supplierPartNumbers,are_pins_interchangeable:!0});this.source_component_id=n.source_component_id}doInitialPcbComponentRender(){var i;if((i=this.root)!=null&&i.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=e.pcb_component.insert({center:{x:t.pcbX??0,y:t.pcbY??0},width:2,height:3,layer:t.layer??"top",rotation:t.pcbRotation??0,source_component_id:this.source_component_id,subcircuit_id:this.getSubcircuit().subcircuit_id??void 0});this.pcb_component_id=n.pcb_component_id}doInitialPcbTraceRender(){const{db:e}=this.root,t=e.pcb_port.list({pcb_component_id:this.pcb_component_id}),n={};for(let a=0;a<t.length;a++){const s=t[a],l=e.source_port.get(s.source_port_id);let c="";if(typeof(l==null?void 0:l.pin_number)=="number")c=l.pin_number.toString();else if(Array.isArray(l==null?void 0:l.port_hints)){let u=l.port_hints.find(A=>/^(pin)?\d+$/.test(A));u&&(/^pin\d+$/.test(u)?c=u.replace(/^pin/,""):c=u)}n[c]=s.pcb_port_id}const i=e.pcb_trace.list(),o=a=>{if(a&&typeof a=="string"&&a.startsWith("{PIN")){const s=a.replace("{PIN","").replace("}","");return n[s]||a}return a};for(const a of i)if(a.route)for(const s of a.route)s.route_type==="wire"&&(s.start_pcb_port_id=o(s.start_pcb_port_id),s.end_pcb_port_id=o(s.end_pcb_port_id))}},yJt=class extends L1{constructor(){super(...arguments);Ye(this,"pos",this.portMap.pin1);Ye(this,"anode",this.portMap.pin1);Ye(this,"neg",this.portMap.pin2);Ye(this,"cathode",this.portMap.pin2)}get config(){return{componentName:"Led",schematicSymbolName:this.props.symbolName??"led",zodProps:qPe,sourceFtype:"simple_led"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}_getSchematicSymbolDisplayValue(){return this._parsedProps.schDisplayValue||this._parsedProps.color||void 0}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_led",name:t.name,wave_length:t.wavelength,color:t.color,symbol_display_value:this._getSchematicSymbolDisplayValue(),manufacturer_part_number:t.manufacturerPartNumber??t.mfn,supplier_part_numbers:t.supplierPartNumbers,are_pins_interchangeable:!1});this.source_component_id=n.source_component_id}},vJt=class extends L1{constructor(){super(...arguments);Ye(this,"pos",this.portMap.pin1);Ye(this,"positive",this.portMap.pin1);Ye(this,"neg",this.portMap.pin2);Ye(this,"negative",this.portMap.pin2)}get config(){return{schematicSymbolName:this.props.symbolName??"power_factor_meter_horz",componentName:"PowerSource",zodProps:n8e,sourceFtype:"simple_power_source"}}initPorts(){this.add(new Hw({name:"pin1",pinNumber:1,aliases:["positive","pos"]})),this.add(new Hw({name:"pin2",pinNumber:2,aliases:["negative","neg"]}))}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_power_source",name:t.name,voltage:t.voltage,supplier_part_numbers:t.supplierPartNumbers,are_pins_interchangeable:!1});this.source_component_id=n.source_component_id}},IJt=class extends L1{get config(){return{componentName:"Resistor",schematicSymbolName:this.props.symbolName??"boxresistor",zodProps:MPe,sourceFtype:"simple_resistor"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}_getSchematicSymbolDisplayValue(){return`${i_(this._parsedProps.resistance)}Ω`}doInitialCreateNetsFromProps(){this._createNetsFromProps([this.props.pullupFor,this.props.pullupTo,this.props.pulldownFor,this.props.pulldownTo,...this._getNetsFromConnectionsProp()])}doInitialCreateTracesFromProps(){this.props.pullupFor&&this.props.pullupTo&&(this.add(new Yw({from:`${this.getSubcircuitSelector()} > port.1`,to:this.props.pullupFor})),this.add(new Yw({from:`${this.getSubcircuitSelector()} > port.2`,to:this.props.pullupTo}))),this.props.pulldownFor&&this.props.pulldownTo&&(this.add(new Yw({from:`${this.getSubcircuitSelector()} > port.1`,to:this.props.pulldownFor})),this.add(new Yw({from:`${this.getSubcircuitSelector()} > port.2`,to:this.props.pulldownTo}))),this._createTracesFromConnectionsProp()}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_resistor",name:e.name,manufacturer_part_number:e.manufacturerPartNumber??e.mfn,supplier_part_numbers:e.supplierPartNumbers,resistance:e.resistance,display_resistance:this._getSchematicSymbolDisplayValue(),are_pins_interchangeable:!0});this.source_component_id=t.source_component_id}},CJt=["leftedge","rightedge","topedge","bottomedge","center"],EJt=class extends aI{get config(){return{componentName:"Constraint",zodProps:PPe}}constructor(r){if(super(r),("xdist"in r||"ydist"in r)&&!("edgeToEdge"in r)&&!("centerToCenter"in r))throw new Error(`edgeToEdge, centerToCenter must be set for xDist or yDist for ${this}`);if("for"in r&&r.for.length<2)throw new Error(`"for" must have at least two selectors for ${this}`)}_getAllReferencedComponents(){const r=[],e=this.getPrimitiveContainer();function t(n){const i=n.split(" ").pop(),o=CJt.includes(i)?i:void 0,a=o?n.replace(` ${o}`,""):n,s=e.selectOne(a,{pcbPrimitive:!0});s&&r.push({selector:n,component:s,componentSelector:a,edge:o})}for(const n of["left","right","top","bottom"])n in this._parsedProps&&t(this._parsedProps[n]);if("for"in this._parsedProps)for(const n of this._parsedProps.for)t(n);return{componentsWithSelectors:r}}},_Jt=class extends aI{constructor(){super(...arguments);Ye(this,"fabrication_note_path_id",null)}get config(){return{componentName:"FabricationNotePath",zodProps:$Pe}}doInitialPcbPrimitiveRender(){var s,l;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:e}=this.root,t=this.getSubcircuit(),{_parsedProps:n}=this,i=n.layer??"top";if(i!=="top"&&i!=="bottom")throw new Error(`Invalid layer "${i}" for SilkscreenPath. Must be "top" or "bottom".`);const o=this._computePcbGlobalTransformBeforeLayout(),a=e.pcb_fabrication_note_path.insert({pcb_component_id:(l=this.parent)==null?void 0:l.pcb_component_id,layer:i,color:n.color,route:n.route.map(c=>{const u=Xr(o,{x:c.x,y:c.y});return{...c,x:u.x,y:u.y}}),stroke_width:n.strokeWidth??.1,subcircuit_id:(t==null?void 0:t.subcircuit_id)??void 0});this.fabrication_note_path_id=a.pcb_fabrication_note_path_id}},xJt=class extends aI{get config(){return{componentName:"FabricationNoteText",zodProps:XPe}}doInitialPcbPrimitiveRender(){var i,o;if((i=this.root)!=null&&i.pcbDisabled)return;const{db:r}=this.root,{_parsedProps:e}=this,t=this.getPrimitiveContainer(),n=this.getSubcircuit();r.pcb_fabrication_note_text.insert({anchor_alignment:e.anchorAlignment,anchor_position:{x:e.pcbX??0,y:e.pcbY??0},font:e.font??"tscircuit2024",font_size:e.fontSize??1,layer:"top",color:e.color,text:e.text??"",pcb_component_id:t.pcb_component_id,subcircuit_id:(n==null?void 0:n.subcircuit_id)??void 0,pcb_group_id:((o=this.getGroup())==null?void 0:o.pcb_group_id)??void 0})}},BJt=class extends bce{constructor(r){super({...r,subcircuit:!0})}},bJt=class extends aI{constructor(){super(...arguments);Ye(this,"source_net_alias_id")}get config(){return{componentName:"NetAlias",zodProps:YPe}}doInitialSchematicComponentRender(){var o;if((o=this.root)!=null&&o.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n={x:t.schX??0,y:t.schY??0},i=e.schematic_net_label.insert({text:t.net,source_net_id:t.net,anchor_position:n,center:n,anchor_side:"bottom"});this.source_net_alias_id=i.source_net_id}},SJt=class extends aI{constructor(){super(...arguments);Ye(this,"pcb_silkscreen_circle_id",null);Ye(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenCircle",zodProps:l8e}}doInitialPcbPrimitiveRender(){var s,l,c;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,{maybeFlipLayer:n}=this._getPcbPrimitiveFlippedHelpers(),i=n(t.layer??"top");if(i!=="top"&&i!=="bottom")throw new Error(`Invalid layer "${i}" for SilkscreenCircle. Must be "top" or "bottom".`);this._computePcbGlobalTransformBeforeLayout();const o=this.getSubcircuit(),a=e.pcb_silkscreen_circle.insert({pcb_component_id:(l=this.parent)==null?void 0:l.pcb_component_id,layer:i,center:{x:t.pcbX??0,y:t.pcbY??0},radius:t.radius,subcircuit_id:(o==null?void 0:o.subcircuit_id)??void 0,pcb_group_id:((c=this.getGroup())==null?void 0:c.pcb_group_id)??void 0,stroke_width:t.strokeWidth??.1});this.pcb_silkscreen_circle_id=a.pcb_silkscreen_circle_id}getPcbSize(){const{_parsedProps:e}=this,t=e.radius*2;return{width:t,height:t}}},wJt=class extends aI{constructor(){super(...arguments);Ye(this,"pcb_silkscreen_rect_id",null);Ye(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenRect",zodProps:s8e}}doInitialPcbPrimitiveRender(){var s,l,c;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,{maybeFlipLayer:n}=this._getPcbPrimitiveFlippedHelpers(),i=n(t.layer??"top");if(i!=="top"&&i!=="bottom")throw new Error(`Invalid layer "${i}" for SilkscreenRect. Must be "top" or "bottom".`);const o=this.getSubcircuit(),a=e.pcb_silkscreen_rect.insert({pcb_component_id:(l=this.parent)==null?void 0:l.pcb_component_id,layer:i,center:{x:t.pcbX??0,y:t.pcbY??0},width:t.width,height:t.height,subcircuit_id:(o==null?void 0:o.subcircuit_id)??void 0,pcb_group_id:((c=this==null?void 0:this.getGroup())==null?void 0:c.pcb_group_id)??void 0,stroke_width:t.strokeWidth??.1});this.pcb_silkscreen_rect_id=a.pcb_silkscreen_rect_id}getPcbSize(){const{_parsedProps:e}=this;return{width:e.width,height:e.height}}},QJt=class extends aI{constructor(){super(...arguments);Ye(this,"pcb_silkscreen_line_id",null);Ye(this,"isPcbPrimitive",!0)}get config(){return{componentName:"SilkscreenLine",zodProps:a8e}}doInitialPcbPrimitiveRender(){var s,l,c;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,{maybeFlipLayer:n}=this._getPcbPrimitiveFlippedHelpers(),i=n(t.layer??"top");if(i!=="top"&&i!=="bottom")throw new Error(`Invalid layer "${i}" for SilkscreenLine. Must be "top" or "bottom".`);const o=this.getSubcircuit(),a=e.pcb_silkscreen_line.insert({pcb_component_id:(l=this.parent)==null?void 0:l.pcb_component_id,layer:i,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke_width:t.strokeWidth??.1,subcircuit_id:(o==null?void 0:o.subcircuit_id)??void 0,pcb_group_id:((c=o==null?void 0:o.getGroup())==null?void 0:c.pcb_group_id)??void 0});this.pcb_silkscreen_line_id=a.pcb_silkscreen_line_id}getPcbSize(){const{_parsedProps:e}=this,t=Math.abs(e.x2-e.x1),n=Math.abs(e.y2-e.y1);return{width:t,height:n}}},MJt=class extends aI{constructor(){super(...arguments);Ye(this,"pcb_via_id",null);Ye(this,"matchedPort",null);Ye(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Via",zodProps:e8e}}getAvailablePcbLayers(){return["top","inner1","inner2","bottom"]}getPcbSize(){const{_parsedProps:e}=this;return{width:e.outerDiameter,height:e.outerDiameter}}_getPcbCircuitJsonBounds(){const{db:e}=this.root,t=e.pcb_via.get(this.pcb_via_id),n=this.getPcbSize();return{center:{x:t.x,y:t.y},bounds:{left:t.x-n.width/2,top:t.y-n.height/2,right:t.x+n.width/2,bottom:t.y+n.height/2},width:n.width,height:n.height}}_setPositionFromLayout(e){const{db:t}=this.root;t.pcb_via.update(this.pcb_via_id,{x:e.x,y:e.y})}doInitialPcbPrimitiveRender(){var a,s;if((a=this.root)!=null&&a.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this._getGlobalPcbPositionBeforeLayout(),i=this.getSubcircuit(),o=e.pcb_via.insert({x:n.x,y:n.y,hole_diameter:t.holeDiameter,outer_diameter:t.outerDiameter,layers:["bottom","top"],from_layer:t.fromLayer||"bottom",to_layer:t.toLayer||"top",subcircuit_id:(i==null?void 0:i.subcircuit_id)??void 0,pcb_group_id:((s=this.getGroup())==null?void 0:s.pcb_group_id)??void 0});this.pcb_via_id=o.pcb_via_id}},DJt=class extends aI{constructor(){super(...arguments);Ye(this,"pcb_cutout_id",null);Ye(this,"isPcbPrimitive",!0)}get config(){return{componentName:"Cutout",zodProps:kPe}}doInitialPcbPrimitiveRender(){var s,l;if((s=this.root)!=null&&s.pcbDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=this.getSubcircuit(),i=((l=this.getGroup())==null?void 0:l.pcb_group_id)??void 0,o=this._getGlobalPcbPositionBeforeLayout();let a;if(t.shape==="rect"){const c={shape:"rect",center:o,width:t.width,height:t.height,subcircuit_id:(n==null?void 0:n.subcircuit_id)??void 0,pcb_group_id:i};a=e.pcb_cutout.insert(c)}else if(t.shape==="circle"){const c={shape:"circle",center:o,radius:t.radius,subcircuit_id:(n==null?void 0:n.subcircuit_id)??void 0,pcb_group_id:i};a=e.pcb_cutout.insert(c)}else if(t.shape==="polygon"){const c=this._computePcbGlobalTransformBeforeLayout(),A={shape:"polygon",points:t.points.map(d=>Xr(c,d)),subcircuit_id:(n==null?void 0:n.subcircuit_id)??void 0,pcb_group_id:i};a=e.pcb_cutout.insert(A)}a&&(this.pcb_cutout_id=a.pcb_cutout_id)}getPcbSize(){const{_parsedProps:e}=this;if(e.shape==="rect")return{width:e.width,height:e.height};if(e.shape==="circle")return{width:e.radius*2,height:e.radius*2};if(e.shape==="polygon"){if(e.points.length===0)return{width:0,height:0};let t=1/0,n=-1/0,i=1/0,o=-1/0;for(const a of e.points)t=Math.min(t,a.x),n=Math.max(n,a.x),i=Math.min(i,a.y),o=Math.max(o,a.y);return{width:n-t,height:o-i}}return{width:0,height:0}}_getPcbCircuitJsonBounds(){if(!this.pcb_cutout_id)return super._getPcbCircuitJsonBounds();const{db:e}=this.root,t=e.pcb_cutout.get(this.pcb_cutout_id);if(!t)return super._getPcbCircuitJsonBounds();if(t.shape==="rect")return{center:t.center,bounds:{left:t.center.x-t.width/2,top:t.center.y+t.height/2,right:t.center.x+t.width/2,bottom:t.center.y-t.height/2},width:t.width,height:t.height};if(t.shape==="circle")return{center:t.center,bounds:{left:t.center.x-t.radius,top:t.center.y+t.radius,right:t.center.x+t.radius,bottom:t.center.y-t.radius},width:t.radius*2,height:t.radius*2};if(t.shape==="polygon"){if(t.points.length===0)return super._getPcbCircuitJsonBounds();let n=1/0,i=-1/0,o=1/0,a=-1/0;for(const s of t.points)n=Math.min(n,s.x),i=Math.max(i,s.x),o=Math.min(o,s.y),a=Math.max(a,s.y);return{center:{x:(n+i)/2,y:(o+a)/2},bounds:{left:n,top:a,right:i,bottom:o},width:i-n,height:a-o}}return super._getPcbCircuitJsonBounds()}_setPositionFromLayout(e){if(!this.pcb_cutout_id)return;const{db:t}=this.root,n=t.pcb_cutout.get(this.pcb_cutout_id);if(n){if(n.shape==="rect"||n.shape==="circle")t.pcb_cutout.update(this.pcb_cutout_id,{...n,center:e});else if(n.shape==="polygon"){const i=this._getPcbCircuitJsonBounds().center,o=e.x-i.x,a=e.y-i.y,s=n.points.map(l=>({x:l.x+o,y:l.y+a}));t.pcb_cutout.update(this.pcb_cutout_id,{...n,points:s})}}}},RJt=class extends L1{get config(){return{componentName:"Battery",schematicSymbolName:this.props.symbolName??"battery",zodProps:zPe,sourceFtype:"simple_power_source"}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({name:e.name,ftype:"simple_power_source",capacity:e.capacity,supplier_part_numbers:e.supplierPartNumbers,are_pins_interchangeable:!1});this.source_component_id=t.source_component_id}},NJt=class extends L1{get config(){return{componentName:"PinHeader",zodProps:HPe,shouldRenderAsSchematicBox:!0}}_getImpliedFootprintString(){var i;const r=this._parsedProps.pinCount??((i=this._parsedProps.pinLabels)==null?void 0:i.length)??0,e=this._parsedProps.holeDiameter,t=this._parsedProps.platedDiameter,n=this._parsedProps.pitch;return r>0&&n?!e&&!t?`pinrow${r}_p${n}`:`pinrow${r}_p${n}_id${e}_od${t}`:null}initPorts(){var e,t;const r=this._parsedProps.pinCount??((e=this._parsedProps.pinLabels)==null?void 0:e.length)??1;for(let n=1;n<=r;n++)this.add(new Hw({name:`pin${n}`,pinNumber:n,aliases:[(t=this._parsedProps.pinLabels)==null?void 0:t[n-1]].filter(Boolean)}))}_getSchematicPortArrangement(){var n,i,o,a;const r=this._parsedProps.pinCount??1,e=this._parsedProps.facingDirection??"right",t=this._parsedProps.schPinArrangement;return e==="left"?{leftSide:{direction:((n=t==null?void 0:t.leftSide)==null?void 0:n.direction)??"top-to-bottom",pins:((i=t==null?void 0:t.leftSide)==null?void 0:i.pins)??Array.from({length:r},(s,l)=>`pin${l+1}`)}}:{rightSide:{direction:((o=t==null?void 0:t.rightSide)==null?void 0:o.direction)??"top-to-bottom",pins:((a=t==null?void 0:t.rightSide)==null?void 0:a.pins)??Array.from({length:r},(s,l)=>`pin${l+1}`)}}}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_pin_header",name:e.name,supplier_part_numbers:e.supplierPartNumbers,pin_count:e.pinCount,gender:e.gender,are_pins_interchangeable:!0});this.source_component_id=t.source_component_id}};function TJt(r){switch(r){case"two_ground_pins":return"crystal_4pin";case"ground_pin":return"resonator";case"no_ground":return"crystal";default:return"crystal"}}var PJt=class extends L1{get config(){return{componentName:"Resonator",schematicSymbolName:this.props.symbolName??TJt(this.props.pinVariant),zodProps:NPe,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=e.pinVariant||"no_ground",n=r.source_component.insert({ftype:"simple_resonator",name:e.name,frequency:e.frequency,load_capacitance:e.loadCapacitance,supplier_part_numbers:e.supplierPartNumbers,pin_variant:t,are_pins_interchangeable:t==="no_ground"||t==="ground_pin"});this.source_component_id=n.source_component_id}},kJt=class extends L1{get config(){return{componentName:"Inductor",schematicSymbolName:this.props.symbolName??"inductor",zodProps:JPe,sourceFtype:nM.simple_inductor}}initPorts(){super.initPorts({additionalAliases:{pin1:["anode","pos","left"],pin2:["cathode","neg","right"]}})}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({name:e.name,ftype:nM.simple_inductor,inductance:e.inductance,supplier_part_numbers:e.supplierPartNumbers,are_pins_interchangeable:!0});this.source_component_id=t.source_component_id}};function UJt(r){switch(r){case"three_pin":return"potentiometer3";case"two_pin":return"potentiometer2";default:return"potentiometer2"}}var FJt=class extends L1{get config(){return{componentName:"Potentiometer",schematicSymbolName:this.props.symbolName??UJt(this.props.pinVariant),zodProps:DPe,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=e.pinVariant||"two_pin",n=r.source_component.insert({ftype:"simple_potentiometer",name:e.name,max_resistance:e.maxResistance,pin_variant:t,are_pins_interchangeable:t==="two_pin"});this.source_component_id=n.source_component_id}},LJt=class extends L1{get config(){return{componentName:"PushButton",schematicSymbolName:this.props.symbolName??"push_button_normally_open_momentary",zodProps:VPe,sourceFtype:nM.simple_push_button}}get defaultInternallyConnectedPinNames(){return[["pin1","pin4"],["pin2","pin3"]]}initPorts(){super.initPorts({pinCount:4,additionalAliases:{pin1:["side1"],pin3:["side2"]}})}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({name:e.name,ftype:nM.simple_push_button,supplier_part_numbers:e.supplierPartNumbers,are_pins_interchangeable:!0});this.source_component_id=t.source_component_id}},GJt=class extends L1{get config(){return{schematicSymbolName:this.props.symbolName??(this.props.pinVariant==="four_pin"?"crystal_4pin":"crystal"),componentName:"Crystal",zodProps:RPe,sourceFtype:"simple_crystal"}}initPorts(){const r=this.props.pinVariant==="four_pin"?{pin1:["left1","1"],pin2:["top1","2","gnd1"],pin3:["right1","3"],pin4:["bottom1","4","gnd2"]}:{pin1:["pos","left"],pin2:["neg","right"]};super.initPorts({additionalAliases:r})}_getSchematicSymbolDisplayValue(){return`${i_(this._parsedProps.frequency)}Hz`}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({name:e.name,ftype:"simple_crystal",frequency:e.frequency,load_capacitance:e.loadCapacitance,pin_variant:e.pinVariant||"two_pin",are_pins_interchangeable:(e.pinVariant||"two_pin")==="two_pin"});this.source_component_id=t.source_component_id}},OJt=class extends L1{constructor(){super(...arguments);Ye(this,"emitter",this.portMap.pin1);Ye(this,"collector",this.portMap.pin2);Ye(this,"base",this.portMap.pin3)}get config(){return{componentName:"Transistor",schematicSymbolName:this.props.type==="npn"?"npn_bipolar_transistor":"pnp_bipolar_transistor",zodProps:KPe,sourceFtype:"simple_transistor",shouldRenderAsSchematicBox:!1}}initPorts(){const e=this.props.type==="npn"?{pin1:["emitter","e"],pin2:["collector","c"],pin3:["base","b"]}:{pin1:["collector","c"],pin2:["emitter","e"],pin3:["base","b"]};super.initPorts({pinCount:3,additionalAliases:e})}doInitialSourceRender(){const{db:e}=this.root,{_parsedProps:t}=this,n=e.source_component.insert({ftype:"simple_transistor",name:t.name,transistor_type:t.type});this.source_component_id=n.source_component_id}},zJt=class extends L1{get config(){const r=this.props.mosfetMode==="depletion"?"d":"e";return{componentName:"Mosfet",schematicSymbolName:`${this.props.channelType}_channel_${r}_mosfet_transistor`,zodProps:jPe,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_mosfet",name:e.name,mosfet_mode:e.mosfetMode,channel_type:e.channelType});this.source_component_id=t.source_component_id}},HJt=class extends L1{_getSwitchType(){const{spst:r,spdt:e,dpst:t,dpdt:n,type:i}=this._parsedProps??{};return n?"dpdt":r?"spst":e?"spdt":t?"dpst":i??"spst"}get config(){const r=this._getSwitchType(),{isNormallyClosed:e}=this._parsedProps??{};return{componentName:"Switch",schematicSymbolName:{spst:e?"spst_normally_closed_switch":"spst_switch",spdt:e?"spdt_normally_closed_switch":"spdt_switch",dpst:e?"dpst_normally_closed_switch":"dpst_switch",dpdt:e?"dpdt_normally_closed_switch":"dpdt_switch"}[r]??"spst_switch",zodProps:ZPe,shouldRenderAsSchematicBox:!1}}doInitialSourceRender(){const{db:r}=this.root,{_parsedProps:e}=this,t=r.source_component.insert({ftype:"simple_switch",name:e.name,switch_type:e.type,is_normally_closed:e.isNormallyClosed??!1,are_pins_interchangeable:this._getSwitchType()==="spst"});this.source_component_id=t.source_component_id}},YJt=class extends aI{constructor(){super(...arguments);Ye(this,"isSchematicPrimitive",!0)}get config(){return{componentName:"SchematicText",zodProps:r8e}}doInitialSchematicPrimitiveRender(){var n;if((n=this.root)!=null&&n.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this;e.schematic_text.insert({anchor:t.anchor??"center",text:t.text,font_size:t.fontSize,color:t.color||"#000000",position:{x:t.schX,y:t.schY},rotation:t.schRotation??0})}},VJt=class extends aI{constructor(){super(...arguments);Ye(this,"isSchematicPrimitive",!0)}get config(){return{componentName:"SchematicBox",zodProps:c6,shouldRenderAsSchematicBox:!0}}doInitialSchematicPrimitiveRender(){var E;if((E=this.root)!=null&&E.schematicDisabled)return;const{db:e}=this.root,{_parsedProps:t}=this,n=c6.safeParse(t);if(!n.success)throw console.error("Validation failed:",n.error.format()),n.error;const i=.6,o=typeof t.padding=="number"?t.padding:0,a=typeof t.paddingTop=="number"?t.paddingTop:o,s=typeof t.paddingBottom=="number"?t.paddingBottom:o,l=typeof t.paddingLeft=="number"?t.paddingLeft:o,c=typeof t.paddingRight=="number"?t.paddingRight:o,u=t.overlay&&t.overlay.length>0,A=typeof t.width=="number"&&typeof t.height=="number";let d,f,m,C;if(u){const x=t.overlay.map(Fe=>({selector:Fe,port:this.getSubcircuit().selectOne(Fe,{type:"port"})})).filter(({port:Fe})=>Fe!=null).map(({port:Fe})=>({position:Fe._getGlobalSchematicPositionAfterLayout()}));if(x.length===0)return;const w=x.map(Fe=>Fe.position.x),P=x.map(Fe=>Fe.position.y),L=Math.min(...w),O=Math.max(...w),H=Math.min(...P),K=Math.max(...P),q=O-L,Y=K-H,se=q===0?i:0,ie=Y===0?i:0,de=l+se/2,Ce=c+se/2,xe=a+ie/2,fe=s+ie/2,Ie=L-de,ve=O+Ce,Qe=H-fe,De=K+xe;d=ve-Ie,f=De-Qe,m=Ie+(t.schX??0),C=Qe+(t.schY??0)}else if(A){d=t.width,f=t.height;const _=typeof t.schX=="number"?t.schX:0,x=typeof t.schY=="number"?t.schY:0;m=_-d/2,C=x-f/2}else return;e.schematic_box.insert({height:f,width:d,x:m,y:C,is_dashed:t.strokeStyle==="dashed",schematic_component_id:""})}};new Proxy({},{get:(r,e)=>{const t=(...n)=>(n[0],new Proxy({},{get:(i,o)=>`.${e} > .${o}`}));return new Proxy(t,{get:(n,i)=>e==="net"?`net.${i}`:e==="subcircuit"?new Proxy({},{get:(o,a)=>new Proxy({},{get:(s,l)=>`subcircuit.${i} > .${a} > .${l}`})}):`.${e} > .${i}`,apply:(n,i,o)=>new Proxy({},{get:(a,s)=>{const l=`.${e} > .${s}`;return e.startsWith("U")?l:new Proxy(new String(l),{get:(c,u)=>typeof u=="symbol"||u==="toString"?()=>l:`.${e} > .${s} > .${u}`})}})})}}),e7e(X6e),e7e({Bug:I7e});const $T=r=>typeof r=="number"&&!isNaN(r),rM=r=>typeof r=="string",FB=r=>typeof r=="function",q7=r=>rM(r)||FB(r)?r:null,Sce=r=>pt.isValidElement(r)||rM(r)||FB(r)||$T(r);function KJt(r,e,t){t===void 0&&(t=300);const{scrollHeight:n,style:i}=r;requestAnimationFrame(()=>{i.minHeight="initial",i.height=n+"px",i.transition=`all ${t}ms`,requestAnimationFrame(()=>{i.height="0",i.padding="0",i.margin="0",setTimeout(e,t)})})}function Z7(r){let{enter:e,exit:t,appendPosition:n=!1,collapse:i=!0,collapseDuration:o=300}=r;return function(a){let{children:s,position:l,preventExitTransition:c,done:u,nodeRef:A,isIn:d,playToast:f}=a;const m=n?`${e}--${l}`:e,C=n?`${t}--${l}`:t,E=pt.useRef(0);return pt.useLayoutEffect(()=>{const _=A.current,x=m.split(" "),w=P=>{P.target===A.current&&(f(),_.removeEventListener("animationend",w),_.removeEventListener("animationcancel",w),E.current===0&&P.type!=="animationcancel"&&_.classList.remove(...x))};_.classList.add(...x),_.addEventListener("animationend",w),_.addEventListener("animationcancel",w)},[]),pt.useEffect(()=>{const _=A.current,x=()=>{_.removeEventListener("animationend",x),i?KJt(_,u,o):u()};d||(c?x():(E.current=1,_.className+=` ${C}`,_.addEventListener("animationend",x)))},[d]),Jh.createElement(Jh.Fragment,null,s)}}function C7e(r,e){return r!=null?{content:r.content,containerId:r.props.containerId,id:r.props.toastId,theme:r.props.theme,type:r.props.type,data:r.props.data||{},isLoading:r.props.isLoading,icon:r.props.icon,status:e}:{}}const Dx=new Map;let e4=[];const wce=new Set,jJt=r=>wce.forEach(e=>e(r)),E7e=()=>Dx.size>0;function _7e(r,e){var t;if(e)return!((t=Dx.get(e))==null||!t.isToastActive(r));let n=!1;return Dx.forEach(i=>{i.isToastActive(r)&&(n=!0)}),n}function x7e(r,e){Sce(r)&&(E7e()||e4.push({content:r,options:e}),Dx.forEach(t=>{t.buildToast(r,e)}))}function B7e(r,e){Dx.forEach(t=>{e!=null&&e!=null&&e.containerId?(e==null?void 0:e.containerId)===t.id&&t.toggle(r,e==null?void 0:e.id):t.toggle(r,e==null?void 0:e.id)})}function JJt(r){const{subscribe:e,getSnapshot:t,setProps:n}=pt.useRef(function(o){const a=o.containerId||1;return{subscribe(s){const l=function(u,A,d){let f=1,m=0,C=[],E=[],_=[],x=A;const w=new Map,P=new Set,L=()=>{_=Array.from(w.values()),P.forEach(K=>K())},O=K=>{E=K==null?[]:E.filter(q=>q!==K),L()},H=K=>{const{toastId:q,onOpen:Y,updateId:se,children:ie}=K.props,de=se==null;K.staleId&&w.delete(K.staleId),w.set(q,K),E=[...E,K.props.toastId].filter(Ce=>Ce!==K.staleId),L(),d(C7e(K,de?"added":"updated")),de&&FB(Y)&&Y(pt.isValidElement(ie)&&ie.props)};return{id:u,props:x,observe:K=>(P.add(K),()=>P.delete(K)),toggle:(K,q)=>{w.forEach(Y=>{q!=null&&q!==Y.props.toastId||FB(Y.toggle)&&Y.toggle(K)})},removeToast:O,toasts:w,clearQueue:()=>{m-=C.length,C=[]},buildToast:(K,q)=>{if((Ne=>{let{containerId:rt,toastId:et,updateId:ft}=Ne;const _t=rt?rt!==u:u!==1,Ft=w.has(et)&&ft==null;return _t||Ft})(q))return;const{toastId:Y,updateId:se,data:ie,staleId:de,delay:Ce}=q,xe=()=>{O(Y)},fe=se==null;fe&&m++;const Ie={...x,style:x.toastStyle,key:f++,...Object.fromEntries(Object.entries(q).filter(Ne=>{let[rt,et]=Ne;return et!=null})),toastId:Y,updateId:se,data:ie,closeToast:xe,isIn:!1,className:q7(q.className||x.toastClassName),bodyClassName:q7(q.bodyClassName||x.bodyClassName),progressClassName:q7(q.progressClassName||x.progressClassName),autoClose:!q.isLoading&&(ve=q.autoClose,Qe=x.autoClose,ve===!1||$T(ve)&&ve>0?ve:Qe),deleteToast(){const Ne=w.get(Y),{onClose:rt,children:et}=Ne.props;FB(rt)&&rt(pt.isValidElement(et)&&et.props),d(C7e(Ne,"removed")),w.delete(Y),m--,m<0&&(m=0),C.length>0?H(C.shift()):L()}};var ve,Qe;Ie.closeButton=x.closeButton,q.closeButton===!1||Sce(q.closeButton)?Ie.closeButton=q.closeButton:q.closeButton===!0&&(Ie.closeButton=!Sce(x.closeButton)||x.closeButton);let De=K;pt.isValidElement(K)&&!rM(K.type)?De=pt.cloneElement(K,{closeToast:xe,toastProps:Ie,data:ie}):FB(K)&&(De=K({closeToast:xe,toastProps:Ie,data:ie}));const Fe={content:De,props:Ie,staleId:de};x.limit&&x.limit>0&&m>x.limit&&fe?C.push(Fe):$T(Ce)?setTimeout(()=>{H(Fe)},Ce):H(Fe)},setProps(K){x=K},setToggle:(K,q)=>{w.get(K).toggle=q},isToastActive:K=>E.some(q=>q===K),getSnapshot:()=>_}}(a,o,jJt);Dx.set(a,l);const c=l.observe(s);return e4.forEach(u=>x7e(u.content,u.options)),e4=[],()=>{c(),Dx.delete(a)}},setProps(s){var l;(l=Dx.get(a))==null||l.setProps(s)},getSnapshot(){var s;return(s=Dx.get(a))==null?void 0:s.getSnapshot()}}}(r)).current;n(r);const i=pt.useSyncExternalStore(e,t,t);return{getToastToRender:function(o){if(!i)return[];const a=new Map;return r.newestOnTop&&i.reverse(),i.forEach(s=>{const{position:l}=s.props;a.has(l)||a.set(l,[]),a.get(l).push(s)}),Array.from(a,s=>o(s[0],s[1]))},isToastActive:_7e,count:i==null?void 0:i.length}}function WJt(r){const[e,t]=pt.useState(!1),[n,i]=pt.useState(!1),o=pt.useRef(null),a=pt.useRef({start:0,delta:0,removalDistance:0,canCloseOnClick:!0,canDrag:!1,didMove:!1}).current,{autoClose:s,pauseOnHover:l,closeToast:c,onClick:u,closeOnClick:A}=r;var d,f;function m(){t(!0)}function C(){t(!1)}function E(w){const P=o.current;a.canDrag&&P&&(a.didMove=!0,e&&C(),a.delta=r.draggableDirection==="x"?w.clientX-a.start:w.clientY-a.start,a.start!==w.clientX&&(a.canCloseOnClick=!1),P.style.transform=`translate3d(${r.draggableDirection==="x"?`${a.delta}px, var(--y)`:`0, calc(${a.delta}px + var(--y))`},0)`,P.style.opacity=""+(1-Math.abs(a.delta/a.removalDistance)))}function _(){document.removeEventListener("pointermove",E),document.removeEventListener("pointerup",_);const w=o.current;if(a.canDrag&&a.didMove&&w){if(a.canDrag=!1,Math.abs(a.delta)>a.removalDistance)return i(!0),r.closeToast(),void r.collapseAll();w.style.transition="transform 0.2s, opacity 0.2s",w.style.removeProperty("transform"),w.style.removeProperty("opacity")}}(f=Dx.get((d={id:r.toastId,containerId:r.containerId,fn:t}).containerId||1))==null||f.setToggle(d.id,d.fn),pt.useEffect(()=>{if(r.pauseOnFocusLoss)return document.hasFocus()||C(),window.addEventListener("focus",m),window.addEventListener("blur",C),()=>{window.removeEventListener("focus",m),window.removeEventListener("blur",C)}},[r.pauseOnFocusLoss]);const x={onPointerDown:function(w){if(r.draggable===!0||r.draggable===w.pointerType){a.didMove=!1,document.addEventListener("pointermove",E),document.addEventListener("pointerup",_);const P=o.current;a.canCloseOnClick=!0,a.canDrag=!0,P.style.transition="none",r.draggableDirection==="x"?(a.start=w.clientX,a.removalDistance=P.offsetWidth*(r.draggablePercent/100)):(a.start=w.clientY,a.removalDistance=P.offsetHeight*(r.draggablePercent===80?1.5*r.draggablePercent:r.draggablePercent)/100)}},onPointerUp:function(w){const{top:P,bottom:L,left:O,right:H}=o.current.getBoundingClientRect();w.nativeEvent.type!=="touchend"&&r.pauseOnHover&&w.clientX>=O&&w.clientX<=H&&w.clientY>=P&&w.clientY<=L?C():m()}};return s&&l&&(x.onMouseEnter=C,r.stacked||(x.onMouseLeave=m)),A&&(x.onClick=w=>{u&&u(w),a.canCloseOnClick&&c()}),{playToast:m,pauseToast:C,isRunning:e,preventExitTransition:n,toastRef:o,eventHandlers:x}}function qJt(r){let{delay:e,isRunning:t,closeToast:n,type:i="default",hide:o,className:a,style:s,controlledProgress:l,progress:c,rtl:u,isIn:A,theme:d}=r;const f=o||l&&c===0,m={...s,animationDuration:`${e}ms`,animationPlayState:t?"running":"paused"};l&&(m.transform=`scaleX(${c})`);const C=qb("Toastify__progress-bar",l?"Toastify__progress-bar--controlled":"Toastify__progress-bar--animated",`Toastify__progress-bar-theme--${d}`,`Toastify__progress-bar--${i}`,{"Toastify__progress-bar--rtl":u}),E=FB(a)?a({rtl:u,type:i,defaultClassName:C}):qb(C,a),_={[l&&c>=1?"onTransitionEnd":"onAnimationEnd"]:l&&c<1?null:()=>{A&&n()}};return Jh.createElement("div",{className:"Toastify__progress-bar--wrp","data-hidden":f},Jh.createElement("div",{className:`Toastify__progress-bar--bg Toastify__progress-bar-theme--${d} Toastify__progress-bar--${i}`}),Jh.createElement("div",{role:"progressbar","aria-hidden":f?"true":"false","aria-label":"notification timer",className:E,style:m,..._}))}let ZJt=1;const b7e=()=>""+ZJt++;function XJt(r){return r&&(rM(r.toastId)||$T(r.toastId))?r.toastId:b7e()}function t4(r,e){return x7e(r,e),e.toastId}function X7(r,e){return{...e,type:e&&e.type||r,toastId:XJt(e)}}function $7(r){return(e,t)=>t4(e,X7(r,t))}function hv(r,e){return t4(r,X7("default",e))}hv.loading=(r,e)=>t4(r,X7("default",{isLoading:!0,autoClose:!1,closeOnClick:!1,closeButton:!1,draggable:!1,...e})),hv.promise=function(r,e,t){let n,{pending:i,error:o,success:a}=e;i&&(n=rM(i)?hv.loading(i,t):hv.loading(i.render,{...t,...i}));const s={isLoading:null,autoClose:null,closeOnClick:null,closeButton:null,draggable:null},l=(u,A,d)=>{if(A==null)return void hv.dismiss(n);const f={type:u,...s,...t,data:d},m=rM(A)?{render:A}:A;return n?hv.update(n,{...f,...m}):hv(m.render,{...f,...m}),d},c=FB(r)?r():r;return c.then(u=>l("success",a,u)).catch(u=>l("error",o,u)),c},hv.success=$7("success"),hv.info=$7("info"),hv.error=$7("error"),hv.warning=$7("warning"),hv.warn=hv.warning,hv.dark=(r,e)=>t4(r,X7("default",{theme:"dark",...e})),hv.dismiss=function(r){(function(e){var t;if(E7e()){if(e==null||rM(t=e)||$T(t))Dx.forEach(n=>{n.removeToast(e)});else if(e&&("containerId"in e||"id"in e)){const n=Dx.get(e.containerId);n?n.removeToast(e.id):Dx.forEach(i=>{i.removeToast(e.id)})}}else e4=e4.filter(n=>e!=null&&n.options.toastId!==e)})(r)},hv.clearWaitingQueue=function(r){r===void 0&&(r={}),Dx.forEach(e=>{!e.props.limit||r.containerId&&e.id!==r.containerId||e.clearQueue()})},hv.isActive=_7e,hv.update=function(r,e){e===void 0&&(e={});const t=((n,i)=>{var o;let{containerId:a}=i;return(o=Dx.get(a||1))==null?void 0:o.toasts.get(n)})(r,e);if(t){const{props:n,content:i}=t,o={delay:100,...n,...e,toastId:e.toastId||r,updateId:b7e()};o.toastId!==r&&(o.staleId=r);const a=o.render||i;delete o.render,t4(a,o)}},hv.done=r=>{hv.update(r,{progress:1})},hv.onChange=function(r){return wce.add(r),()=>{wce.delete(r)}},hv.play=r=>B7e(!0,r),hv.pause=r=>B7e(!1,r);const $Jt=typeof window<"u"?pt.useLayoutEffect:pt.useEffect,eO=r=>{let{theme:e,type:t,isLoading:n,...i}=r;return Jh.createElement("svg",{viewBox:"0 0 24 24",width:"100%",height:"100%",fill:e==="colored"?"currentColor":`var(--toastify-icon-color-${t})`,...i})},Qce={info:function(r){return Jh.createElement(eO,{...r},Jh.createElement("path",{d:"M12 0a12 12 0 1012 12A12.013 12.013 0 0012 0zm.25 5a1.5 1.5 0 11-1.5 1.5 1.5 1.5 0 011.5-1.5zm2.25 13.5h-4a1 1 0 010-2h.75a.25.25 0 00.25-.25v-4.5a.25.25 0 00-.25-.25h-.75a1 1 0 010-2h1a2 2 0 012 2v4.75a.25.25 0 00.25.25h.75a1 1 0 110 2z"}))},warning:function(r){return Jh.createElement(eO,{...r},Jh.createElement("path",{d:"M23.32 17.191L15.438 2.184C14.728.833 13.416 0 11.996 0c-1.42 0-2.733.833-3.443 2.184L.533 17.448a4.744 4.744 0 000 4.368C1.243 23.167 2.555 24 3.975 24h16.05C22.22 24 24 22.044 24 19.632c0-.904-.251-1.746-.68-2.44zm-9.622 1.46c0 1.033-.724 1.823-1.698 1.823s-1.698-.79-1.698-1.822v-.043c0-1.028.724-1.822 1.698-1.822s1.698.79 1.698 1.822v.043zm.039-12.285l-.84 8.06c-.057.581-.408.943-.897.943-.49 0-.84-.367-.896-.942l-.84-8.065c-.057-.624.25-1.095.779-1.095h1.91c.528.005.84.476.784 1.1z"}))},success:function(r){return Jh.createElement(eO,{...r},Jh.createElement("path",{d:"M12 0a12 12 0 1012 12A12.014 12.014 0 0012 0zm6.927 8.2l-6.845 9.289a1.011 1.011 0 01-1.43.188l-4.888-3.908a1 1 0 111.25-1.562l4.076 3.261 6.227-8.451a1 1 0 111.61 1.183z"}))},error:function(r){return Jh.createElement(eO,{...r},Jh.createElement("path",{d:"M11.983 0a12.206 12.206 0 00-8.51 3.653A11.8 11.8 0 000 12.207 11.779 11.779 0 0011.8 24h.214A12.111 12.111 0 0024 11.791 11.766 11.766 0 0011.983 0zM10.5 16.542a1.476 1.476 0 011.449-1.53h.027a1.527 1.527 0 011.523 1.47 1.475 1.475 0 01-1.449 1.53h-.027a1.529 1.529 0 01-1.523-1.47zM11 12.5v-6a1 1 0 012 0v6a1 1 0 11-2 0z"}))},spinner:function(){return Jh.createElement("div",{className:"Toastify__spinner"})}},eWt=r=>{const{isRunning:e,preventExitTransition:t,toastRef:n,eventHandlers:i,playToast:o}=WJt(r),{closeButton:a,children:s,autoClose:l,onClick:c,type:u,hideProgressBar:A,closeToast:d,transition:f,position:m,className:C,style:E,bodyClassName:_,bodyStyle:x,progressClassName:w,progressStyle:P,updateId:L,role:O,progress:H,rtl:K,toastId:q,deleteToast:Y,isIn:se,isLoading:ie,closeOnClick:de,theme:Ce}=r,xe=qb("Toastify__toast",`Toastify__toast-theme--${Ce}`,`Toastify__toast--${u}`,{"Toastify__toast--rtl":K},{"Toastify__toast--close-on-click":de}),fe=FB(C)?C({rtl:K,position:m,type:u,defaultClassName:xe}):qb(xe,C),Ie=function(Fe){let{theme:Ne,type:rt,isLoading:et,icon:ft}=Fe,_t=null;const Ft={theme:Ne,type:rt};return ft===!1||(FB(ft)?_t=ft({...Ft,isLoading:et}):pt.isValidElement(ft)?_t=pt.cloneElement(ft,Ft):et?_t=Qce.spinner():(Lt=>Lt in Qce)(rt)&&(_t=Qce[rt](Ft))),_t}(r),ve=!!H||!l,Qe={closeToast:d,type:u,theme:Ce};let De=null;return a===!1||(De=FB(a)?a(Qe):pt.isValidElement(a)?pt.cloneElement(a,Qe):function(Fe){let{closeToast:Ne,theme:rt,ariaLabel:et="close"}=Fe;return Jh.createElement("button",{className:`Toastify__close-button Toastify__close-button--${rt}`,type:"button",onClick:ft=>{ft.stopPropagation(),Ne(ft)},"aria-label":et},Jh.createElement("svg",{"aria-hidden":"true",viewBox:"0 0 14 16"},Jh.createElement("path",{fillRule:"evenodd",d:"M7.71 8.23l3.75 3.75-1.48 1.48-3.75-3.75-3.75 3.75L1 11.98l3.75-3.75L1 4.48 2.48 3l3.75 3.75L9.98 3l1.48 1.48-3.75 3.75z"})))}(Qe)),Jh.createElement(f,{isIn:se,done:Y,position:m,preventExitTransition:t,nodeRef:n,playToast:o},Jh.createElement("div",{id:q,onClick:c,"data-in":se,className:fe,...i,style:E,ref:n},Jh.createElement("div",{...se&&{role:O},className:FB(_)?_({type:u}):qb("Toastify__toast-body",_),style:x},Ie!=null&&Jh.createElement("div",{className:qb("Toastify__toast-icon",{"Toastify--animate-icon Toastify__zoom-enter":!ie})},Ie),Jh.createElement("div",null,s)),De,Jh.createElement(qJt,{...L&&!ve?{key:`pb-${L}`}:{},rtl:K,theme:Ce,delay:l,isRunning:e,isIn:se,closeToast:d,hide:A,type:u,style:P,className:w,controlledProgress:ve,progress:H||0})))},tO=function(r,e){return e===void 0&&(e=!1),{enter:`Toastify--animate Toastify__${r}-enter`,exit:`Toastify--animate Toastify__${r}-exit`,appendPosition:e}},tWt=Z7(tO("bounce",!0));Z7(tO("slide",!0)),Z7(tO("zoom")),Z7(tO("flip"));const nWt={position:"top-right",transition:tWt,autoClose:5e3,closeButton:!0,pauseOnHover:!0,pauseOnFocusLoss:!0,draggable:"touch",draggablePercent:80,draggableDirection:"x",role:"alert",theme:"light"};function rWt(r){let e={...nWt,...r};const t=r.stacked,[n,i]=pt.useState(!0),o=pt.useRef(null),{getToastToRender:a,isToastActive:s,count:l}=JJt(e),{className:c,style:u,rtl:A,containerId:d}=e;function f(C){const E=qb("Toastify__toast-container",`Toastify__toast-container--${C}`,{"Toastify__toast-container--rtl":A});return FB(c)?c({position:C,rtl:A,defaultClassName:E}):qb(E,q7(c))}function m(){t&&(i(!0),hv.play())}return $Jt(()=>{if(t){var C;const E=o.current.querySelectorAll('[data-in="true"]'),_=12,x=(C=e.position)==null?void 0:C.includes("top");let w=0,P=0;Array.from(E).reverse().forEach((L,O)=>{const H=L;H.classList.add("Toastify__toast--stacked"),O>0&&(H.dataset.collapsed=`${n}`),H.dataset.pos||(H.dataset.pos=x?"top":"bot");const K=w*(n?.2:1)+(n?0:_*O);H.style.setProperty("--y",`${x?K:-1*K}px`),H.style.setProperty("--g",`${_}`),H.style.setProperty("--s",""+(1-(n?P:0))),w+=H.offsetHeight,P+=.025})}},[n,l,t]),Jh.createElement("div",{ref:o,className:"Toastify",id:d,onMouseEnter:()=>{t&&(i(!1),hv.pause())},onMouseLeave:m},a((C,E)=>{const _=E.length?{...u}:{...u,pointerEvents:"none"};return Jh.createElement("div",{className:f(C),style:_,key:`container-${C}`},E.map(x=>{let{content:w,props:P}=x;return Jh.createElement(eWt,{...P,stacked:t,collapseAll:m,isIn:s(P.toastId,P.containerId),style:P.style,key:`toast-${P.key}`},w)}))}))}function iWt(){var r=':root{--toastify-color-light:#fff;--toastify-color-dark:#121212;--toastify-color-info:#3498db;--toastify-color-success:#07bc0c;--toastify-color-warning:#f1c40f;--toastify-color-error:#e74c3c;--toastify-color-transparent:hsla(0,0%,100%,.7);--toastify-icon-color-info:var(--toastify-color-info);--toastify-icon-color-success:var(--toastify-color-success);--toastify-icon-color-warning:var(--toastify-color-warning);--toastify-icon-color-error:var(--toastify-color-error);--toastify-toast-width:320px;--toastify-toast-offset:16px;--toastify-toast-top:max(var(--toastify-toast-offset),env(safe-area-inset-top));--toastify-toast-right:max(var(--toastify-toast-offset),env(safe-area-inset-right));--toastify-toast-left:max(var(--toastify-toast-offset),env(safe-area-inset-left));--toastify-toast-bottom:max(var(--toastify-toast-offset),env(safe-area-inset-bottom));--toastify-toast-background:#fff;--toastify-toast-min-height:64px;--toastify-toast-max-height:800px;--toastify-toast-bd-radius:6px;--toastify-font-family:sans-serif;--toastify-z-index:9999;--toastify-text-color-light:#757575;--toastify-text-color-dark:#fff;--toastify-text-color-info:#fff;--toastify-text-color-success:#fff;--toastify-text-color-warning:#fff;--toastify-text-color-error:#fff;--toastify-spinner-color:#616161;--toastify-spinner-color-empty-area:#e0e0e0;--toastify-color-progress-light:linear-gradient(90deg,#4cd964,#5ac8fa,#007aff,#34aadc,#5856d6,#ff2d55);--toastify-color-progress-dark:#bb86fc;--toastify-color-progress-info:var(--toastify-color-info);--toastify-color-progress-success:var(--toastify-color-success);--toastify-color-progress-warning:var(--toastify-color-warning);--toastify-color-progress-error:var(--toastify-color-error);--toastify-color-progress-bgo:0.2}.Toastify__toast-container{z-index:var(--toastify-z-index);-webkit-transform:translateZ(var(--toastify-z-index));position:fixed;padding:4px;width:var(--toastify-toast-width);box-sizing:border-box;color:#fff}.Toastify__toast-container--top-left{top:var(--toastify-toast-top);left:var(--toastify-toast-left)}.Toastify__toast-container--top-center{top:var(--toastify-toast-top);left:50%;transform:translateX(-50%)}.Toastify__toast-container--top-right{top:var(--toastify-toast-top);right:var(--toastify-toast-right)}.Toastify__toast-container--bottom-left{bottom:var(--toastify-toast-bottom);left:var(--toastify-toast-left)}.Toastify__toast-container--bottom-center{bottom:var(--toastify-toast-bottom);left:50%;transform:translateX(-50%)}.Toastify__toast-container--bottom-right{bottom:var(--toastify-toast-bottom);right:var(--toastify-toast-right)}@media only screen and (max-width:480px){.Toastify__toast-container{width:100vw;padding:0;left:env(safe-area-inset-left);margin:0}.Toastify__toast-container--top-center,.Toastify__toast-container--top-left,.Toastify__toast-container--top-right{top:env(safe-area-inset-top);transform:translateX(0)}.Toastify__toast-container--bottom-center,.Toastify__toast-container--bottom-left,.Toastify__toast-container--bottom-right{bottom:env(safe-area-inset-bottom);transform:translateX(0)}.Toastify__toast-container--rtl{right:env(safe-area-inset-right);left:auto}}.Toastify__toast{--y:0;position:relative;-ms-touch-action:none;touch-action:none;min-height:var(--toastify-toast-min-height);box-sizing:border-box;margin-bottom:1rem;padding:8px;border-radius:var(--toastify-toast-bd-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;max-height:var(--toastify-toast-max-height);font-family:var(--toastify-font-family);cursor:default;direction:ltr;z-index:0;overflow:hidden}.Toastify__toast--stacked{position:absolute;width:100%;transform:translate3d(0,var(--y),0) scale(var(--s));transition:transform .3s}.Toastify__toast--stacked[data-collapsed] .Toastify__close-button,.Toastify__toast--stacked[data-collapsed] .Toastify__toast-body{transition:opacity .1s}.Toastify__toast--stacked[data-collapsed=false]{overflow:visible}.Toastify__toast--stacked[data-collapsed=true]:not(:last-child)>*{opacity:0}.Toastify__toast--stacked:after{content:"";position:absolute;left:0;right:0;height:calc(var(--g) * 1px);bottom:100%}.Toastify__toast--stacked[data-pos=top]{top:0}.Toastify__toast--stacked[data-pos=bot]{bottom:0}.Toastify__toast--stacked[data-pos=bot].Toastify__toast--stacked:before{transform-origin:top}.Toastify__toast--stacked[data-pos=top].Toastify__toast--stacked:before{transform-origin:bottom}.Toastify__toast--stacked:before{content:"";position:absolute;left:0;right:0;bottom:0;height:100%;transform:scaleY(3);z-index:-1}.Toastify__toast--rtl{direction:rtl}.Toastify__toast--close-on-click{cursor:pointer}.Toastify__toast-body{margin:auto 0;-ms-flex:1 1 auto;flex:1 1 auto;padding:6px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.Toastify__toast-body>div:last-child{word-break:break-word;-ms-flex:1;flex:1}.Toastify__toast-icon{-webkit-margin-end:10px;margin-inline-end:10px;width:20px;-ms-flex-negative:0;flex-shrink:0;display:-ms-flexbox;display:flex}.Toastify--animate{animation-fill-mode:both;animation-duration:.5s}.Toastify--animate-icon{animation-fill-mode:both;animation-duration:.3s}@media only screen and (max-width:480px){.Toastify__toast{margin-bottom:0;border-radius:0}}.Toastify__toast-theme--dark{background:var(--toastify-color-dark);color:var(--toastify-text-color-dark)}.Toastify__toast-theme--colored.Toastify__toast--default,.Toastify__toast-theme--light{background:var(--toastify-color-light);color:var(--toastify-text-color-light)}.Toastify__toast-theme--colored.Toastify__toast--info{color:var(--toastify-text-color-info);background:var(--toastify-color-info)}.Toastify__toast-theme--colored.Toastify__toast--success{color:var(--toastify-text-color-success);background:var(--toastify-color-success)}.Toastify__toast-theme--colored.Toastify__toast--warning{color:var(--toastify-text-color-warning);background:var(--toastify-color-warning)}.Toastify__toast-theme--colored.Toastify__toast--error{color:var(--toastify-text-color-error);background:var(--toastify-color-error)}.Toastify__progress-bar-theme--light{background:var(--toastify-color-progress-light)}.Toastify__progress-bar-theme--dark{background:var(--toastify-color-progress-dark)}.Toastify__progress-bar--info{background:var(--toastify-color-progress-info)}.Toastify__progress-bar--success{background:var(--toastify-color-progress-success)}.Toastify__progress-bar--warning{background:var(--toastify-color-progress-warning)}.Toastify__progress-bar--error{background:var(--toastify-color-progress-error)}.Toastify__progress-bar-theme--colored.Toastify__progress-bar--error,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--info,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--success,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--warning{background:var(--toastify-color-transparent)}.Toastify__close-button{color:#fff;background:transparent;outline:none;border:none;padding:0;cursor:pointer;opacity:.7;transition:.3s ease;-ms-flex-item-align:start;align-self:flex-start;z-index:1}.Toastify__close-button--light{color:#000;opacity:.3}.Toastify__close-button>svg{fill:currentColor;height:16px;width:14px}.Toastify__close-button:focus,.Toastify__close-button:hover{opacity:1}@keyframes Toastify__trackProgress{0%{transform:scaleX(1)}to{transform:scaleX(0)}}.Toastify__progress-bar{position:absolute;bottom:0;left:0;width:100%;height:100%;z-index:var(--toastify-z-index);opacity:.7;transform-origin:left;border-bottom-left-radius:var(--toastify-toast-bd-radius)}.Toastify__progress-bar--animated{animation:Toastify__trackProgress linear 1 forwards}.Toastify__progress-bar--controlled{transition:transform .2s}.Toastify__progress-bar--rtl{right:0;left:auto;transform-origin:right;border-bottom-left-radius:0;border-bottom-right-radius:var(--toastify-toast-bd-radius)}.Toastify__progress-bar--wrp{position:absolute;bottom:0;left:0;width:100%;height:5px;border-bottom-left-radius:var(--toastify-toast-bd-radius)}.Toastify__progress-bar--wrp[data-hidden=true]{opacity:0}.Toastify__progress-bar--bg{opacity:var(--toastify-color-progress-bgo);width:100%;height:100%}.Toastify__spinner{width:20px;height:20px;box-sizing:border-box;border:2px solid;border-radius:100%;border-color:var(--toastify-spinner-color-empty-area);border-right-color:var(--toastify-spinner-color);animation:Toastify__spin .65s linear infinite}@keyframes Toastify__bounceInRight{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(3000px,0,0)}60%{opacity:1;transform:translate3d(-25px,0,0)}75%{transform:translate3d(10px,0,0)}90%{transform:translate3d(-5px,0,0)}to{transform:none}}@keyframes Toastify__bounceOutRight{20%{opacity:1;transform:translate3d(-20px,var(--y),0)}to{opacity:0;transform:translate3d(2000px,var(--y),0)}}@keyframes Toastify__bounceInLeft{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(-3000px,0,0)}60%{opacity:1;transform:translate3d(25px,0,0)}75%{transform:translate3d(-10px,0,0)}90%{transform:translate3d(5px,0,0)}to{transform:none}}@keyframes Toastify__bounceOutLeft{20%{opacity:1;transform:translate3d(20px,var(--y),0)}to{opacity:0;transform:translate3d(-2000px,var(--y),0)}}@keyframes Toastify__bounceInUp{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(0,3000px,0)}60%{opacity:1;transform:translate3d(0,-20px,0)}75%{transform:translate3d(0,10px,0)}90%{transform:translate3d(0,-5px,0)}to{transform:translateZ(0)}}@keyframes Toastify__bounceOutUp{20%{transform:translate3d(0,calc(var(--y) - 10px),0)}40%,45%{opacity:1;transform:translate3d(0,calc(var(--y) + 20px),0)}to{opacity:0;transform:translate3d(0,-2000px,0)}}@keyframes Toastify__bounceInDown{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(0,-3000px,0)}60%{opacity:1;transform:translate3d(0,25px,0)}75%{transform:translate3d(0,-10px,0)}90%{transform:translate3d(0,5px,0)}to{transform:none}}@keyframes Toastify__bounceOutDown{20%{transform:translate3d(0,calc(var(--y) - 10px),0)}40%,45%{opacity:1;transform:translate3d(0,calc(var(--y) + 20px),0)}to{opacity:0;transform:translate3d(0,2000px,0)}}.Toastify__bounce-enter--bottom-left,.Toastify__bounce-enter--top-left{animation-name:Toastify__bounceInLeft}.Toastify__bounce-enter--bottom-right,.Toastify__bounce-enter--top-right{animation-name:Toastify__bounceInRight}.Toastify__bounce-enter--top-center{animation-name:Toastify__bounceInDown}.Toastify__bounce-enter--bottom-center{animation-name:Toastify__bounceInUp}.Toastify__bounce-exit--bottom-left,.Toastify__bounce-exit--top-left{animation-name:Toastify__bounceOutLeft}.Toastify__bounce-exit--bottom-right,.Toastify__bounce-exit--top-right{animation-name:Toastify__bounceOutRight}.Toastify__bounce-exit--top-center{animation-name:Toastify__bounceOutUp}.Toastify__bounce-exit--bottom-center{animation-name:Toastify__bounceOutDown}@keyframes Toastify__zoomIn{0%{opacity:0;transform:scale3d(.3,.3,.3)}50%{opacity:1}}@keyframes Toastify__zoomOut{0%{opacity:1}50%{opacity:0;transform:translate3d(0,var(--y),0) scale3d(.3,.3,.3)}to{opacity:0}}.Toastify__zoom-enter{animation-name:Toastify__zoomIn}.Toastify__zoom-exit{animation-name:Toastify__zoomOut}@keyframes Toastify__flipIn{0%{transform:perspective(400px) rotateX(90deg);animation-timing-function:ease-in;opacity:0}40%{transform:perspective(400px) rotateX(-20deg);animation-timing-function:ease-in}60%{transform:perspective(400px) rotateX(10deg);opacity:1}80%{transform:perspective(400px) rotateX(-5deg)}to{transform:perspective(400px)}}@keyframes Toastify__flipOut{0%{transform:translate3d(0,var(--y),0) perspective(400px)}30%{transform:translate3d(0,var(--y),0) perspective(400px) rotateX(-20deg);opacity:1}to{transform:translate3d(0,var(--y),0) perspective(400px) rotateX(90deg);opacity:0}}.Toastify__flip-enter{animation-name:Toastify__flipIn}.Toastify__flip-exit{animation-name:Toastify__flipOut}@keyframes Toastify__slideInRight{0%{transform:translate3d(110%,0,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInLeft{0%{transform:translate3d(-110%,0,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInUp{0%{transform:translate3d(0,110%,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInDown{0%{transform:translate3d(0,-110%,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideOutRight{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(110%,var(--y),0)}}@keyframes Toastify__slideOutLeft{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(-110%,var(--y),0)}}@keyframes Toastify__slideOutDown{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(0,500px,0)}}@keyframes Toastify__slideOutUp{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(0,-500px,0)}}.Toastify__slide-enter--bottom-left,.Toastify__slide-enter--top-left{animation-name:Toastify__slideInLeft}.Toastify__slide-enter--bottom-right,.Toastify__slide-enter--top-right{animation-name:Toastify__slideInRight}.Toastify__slide-enter--top-center{animation-name:Toastify__slideInDown}.Toastify__slide-enter--bottom-center{animation-name:Toastify__slideInUp}.Toastify__slide-exit--bottom-left,.Toastify__slide-exit--top-left{animation-name:Toastify__slideOutLeft;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--bottom-right,.Toastify__slide-exit--top-right{animation-name:Toastify__slideOutRight;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--top-center{animation-name:Toastify__slideOutUp;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--bottom-center{animation-name:Toastify__slideOutDown;animation-timing-function:ease-in;animation-duration:.3s}@keyframes Toastify__spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}',e=document.createElement("style");e.innerText=r,document.head.appendChild(e)}const oWt=gKe(DZe);var Mce,S7e;function aWt(){if(S7e)return Mce;S7e=1;var r=Object.defineProperty,e=Object.getOwnPropertyDescriptor,t=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,i=(E,_)=>{for(var x in _)r(E,x,{get:_[x],enumerable:!0})},o=(E,_,x,w)=>{if(_&&typeof _=="object"||typeof _=="function")for(let P of t(_))!n.call(E,P)&&P!==x&&r(E,P,{get:()=>_[P],enumerable:!(w=e(_,P))||w.enumerable});return E},a=E=>o(r({},"__esModule",{value:!0}),E),s={};i(s,{SuperGrid:()=>C,toMMSI:()=>m,toMeterSI:()=>f}),Mce=a(s);var l=ZE(),c=oWt,u=ude(),A=(E,_,x)=>{const w=[];if(_<E)for(let P=E;P>=_;P-=Math.abs(x))w.push(P);else for(let P=E;P<=_;P+=Math.abs(x))w.push(P);return w};function d(E,_){return{x:Math.round(_.x/E)*E,y:Math.round(_.y/E)*E}}function f(E,_=1){return E<0?"-"+f(-E):E<1e-6?"0m":E>1e3?Math.floor(E/1e3)+"km":E>1&&_>1?Math.round(E)+"m":E>1&&_<=1?E.toFixed(Math.ceil(-Math.log10(_)))+"m":E<1&&_>=1/1e3?Math.round(E*1e3)+"mm":E<1&&_<1/1e3?(E*1e3).toFixed(Math.ceil(-Math.log10(_*1e3)))+"mm":""}function m(E,_=1){return f(E/1e3,_/1e3)}var C=E=>{var _;const x=(0,l.useRef)(null),[w,P]=(0,l.useState)({x:0,y:0}),{majorColor:L="rgba(0,0,0,0.2)",minorColor:O="rgba(0,0,0,0.1)",textColor:H=(_=E.majorColor)!=null?_:"rgba(0,0,0,0.5)",width:K,height:q,screenSpaceCellSize:Y=200,stringifyCoord:se=(xe,fe,Ie)=>`${f(xe,Ie)}, ${f(fe,Ie)}`}=E,ie=Math.ceil(K/Y)+2,de=Math.ceil(q/Y)+2;(0,l.useEffect)(()=>{if(!x.current)return;const xe=x.current.getContext("2d");if(!xe)return;const fe=Y/10**Math.floor(Math.log10(E.transform.a)),Ie=E.transform.d<0?-1:1,Qe=Y/10**Math.log10(E.transform.a)/fe;function De(xt,vt,Ht){const en=xt;let kt,qn,cn;for(kt=vt.x;kt<=Ht.x;kt+=en)qn=(0,c.applyToPoint)(E.transform,{x:kt,y:vt.y}),cn=(0,c.applyToPoint)(E.transform,{x:kt,y:Ht.y}),xe.beginPath(),xe.moveTo(qn.x,qn.y),xe.lineTo(cn.x,cn.y),xe.stroke();const Wt=A(vt.y,Ht.y,en*Ie);for(const tr of Wt)qn=(0,c.applyToPoint)(E.transform,{x:vt.x,y:tr}),cn=(0,c.applyToPoint)(E.transform,{x:Ht.x,y:tr}),xe.beginPath(),xe.moveTo(qn.x,qn.y),xe.lineTo(cn.x,cn.y),xe.stroke()}function Fe(xt,vt,Ht){const en=xt;let kt;for(kt=vt.x;kt<=Ht.x;kt+=en)for(const qn of A(vt.y,Ht.y,en*Ie)){const cn=(0,c.applyToPoint)(E.transform,{x:kt,y:qn});xe.fillStyle=H,xe.font="12px sans-serif",xe.fillText(se(kt,qn,xt),cn.x+2,cn.y-2)}}xe.clearRect(0,0,K,q);const Ne=(0,c.applyToPoint)((0,c.inverse)(E.transform),{x:0,y:0}),rt={x:Math.floor((Ne.x-fe)/fe)*fe,y:Math.floor((Ne.y-fe)/fe+(Ie==-1?2:0))*fe},et={x:rt.x+fe*ie,y:rt.y+fe*de*Ie},_t=fe*5,Ft={x:Math.floor((Ne.x-_t)/_t)*_t,y:Math.floor((Ne.y-_t)/_t+(Ie==-1?2:0))*_t},Lt={x:Ft.x+_t*ie,y:Ft.y+_t*de*Ie};xe.globalAlpha=1,xe.strokeStyle=L,De(fe,rt,et),Fe(_t,Ft,Lt),xe.globalAlpha=1-Qe,De(_t/10,Ft,Lt),xe.globalAlpha=1-Qe,xe.strokeStyle=O,De(fe/10,rt,et),xe.globalAlpha=Math.max(((1-Qe)*10-5)/5,0),Fe(_t/10,Ft,Lt),xe.globalAlpha=1;const tt=(0,c.applyToPoint)(E.transform,w);xe.font="12px sans-serif",xe.fillStyle=H,xe.fillText(se(w.x,w.y,fe),tt.x+2,tt.y-2),xe.strokeStyle=L,xe.strokeRect(tt.x-5,tt.y-5,10,10)},[x,E.transform,w,K,q]);const Ce=xe=>{if(!x.current)return;const fe=Y/10/10**Math.floor(Math.log10(E.transform.a)),Ie=x.current.getBoundingClientRect(),ve=(0,c.applyToPoint)((0,c.inverse)(E.transform),{x:xe.clientX-Ie.left,y:xe.clientY-Ie.top}),Qe=d(fe,ve);P(Qe)};return(0,u.jsx)("canvas",{onMouseUp:xe=>{xe.button===1&&Ce(xe)},onDoubleClick:Ce,ref:x,width:E.width,height:E.height})};return Mce}var Dce=aWt(),Rce={exports:{}},n4={},nO={exports:{}},Nce={},Tce={},w7e;function Pce(){if(w7e)return Tce;w7e=1;function r(n){this.__parent=n,this.__character_count=0,this.__indent_count=-1,this.__alignment_count=0,this.__wrap_point_index=0,this.__wrap_point_character_count=0,this.__wrap_point_indent_count=-1,this.__wrap_point_alignment_count=0,this.__items=[]}r.prototype.clone_empty=function(){var n=new r(this.__parent);return n.set_indent(this.__indent_count,this.__alignment_count),n},r.prototype.item=function(n){return n<0?this.__items[this.__items.length+n]:this.__items[n]},r.prototype.has_match=function(n){for(var i=this.__items.length-1;i>=0;i--)if(this.__items[i].match(n))return!0;return!1},r.prototype.set_indent=function(n,i){this.is_empty()&&(this.__indent_count=n||0,this.__alignment_count=i||0,this.__character_count=this.__parent.get_indent_size(this.__indent_count,this.__alignment_count))},r.prototype._set_wrap_point=function(){this.__parent.wrap_line_length&&(this.__wrap_point_index=this.__items.length,this.__wrap_point_character_count=this.__character_count,this.__wrap_point_indent_count=this.__parent.next_line.__indent_count,this.__wrap_point_alignment_count=this.__parent.next_line.__alignment_count)},r.prototype._should_wrap=function(){return this.__wrap_point_index&&this.__character_count>this.__parent.wrap_line_length&&this.__wrap_point_character_count>this.__parent.next_line.__character_count},r.prototype._allow_wrap=function(){if(this._should_wrap()){this.__parent.add_new_line();var n=this.__parent.current_line;return n.set_indent(this.__wrap_point_indent_count,this.__wrap_point_alignment_count),n.__items=this.__items.slice(this.__wrap_point_index),this.__items=this.__items.slice(0,this.__wrap_point_index),n.__character_count+=this.__character_count-this.__wrap_point_character_count,this.__character_count=this.__wrap_point_character_count,n.__items[0]===" "&&(n.__items.splice(0,1),n.__character_count-=1),!0}return!1},r.prototype.is_empty=function(){return this.__items.length===0},r.prototype.last=function(){return this.is_empty()?null:this.__items[this.__items.length-1]},r.prototype.push=function(n){this.__items.push(n);var i=n.lastIndexOf(`
|
|
13312
13312
|
`);i!==-1?this.__character_count=n.length-i:this.__character_count+=n.length},r.prototype.pop=function(){var n=null;return this.is_empty()||(n=this.__items.pop(),this.__character_count-=n.length),n},r.prototype._remove_indent=function(){this.__indent_count>0&&(this.__indent_count-=1,this.__character_count-=this.__parent.indent_size)},r.prototype._remove_wrap_indent=function(){this.__wrap_point_indent_count>0&&(this.__wrap_point_indent_count-=1)},r.prototype.trim=function(){for(;this.last()===" ";)this.__items.pop(),this.__character_count-=1},r.prototype.toString=function(){var n="";return this.is_empty()?this.__parent.indent_empty_lines&&(n=this.__parent.get_indent_string(this.__indent_count)):(n=this.__parent.get_indent_string(this.__indent_count,this.__alignment_count),n+=this.__items.join("")),n};function e(n,i){this.__cache=[""],this.__indent_size=n.indent_size,this.__indent_string=n.indent_char,n.indent_with_tabs||(this.__indent_string=new Array(n.indent_size+1).join(n.indent_char)),i=i||"",n.indent_level>0&&(i=new Array(n.indent_level+1).join(this.__indent_string)),this.__base_string=i,this.__base_string_length=i.length}e.prototype.get_indent_size=function(n,i){var o=this.__base_string_length;return i=i||0,n<0&&(o=0),o+=n*this.__indent_size,o+=i,o},e.prototype.get_indent_string=function(n,i){var o=this.__base_string;return i=i||0,n<0&&(n=0,o=""),i+=n*this.__indent_size,this.__ensure_cache(i),o+=this.__cache[i],o},e.prototype.__ensure_cache=function(n){for(;n>=this.__cache.length;)this.__add_column()},e.prototype.__add_column=function(){var n=this.__cache.length,i=0,o="";this.__indent_size&&n>=this.__indent_size&&(i=Math.floor(n/this.__indent_size),n-=i*this.__indent_size,o=new Array(i+1).join(this.__indent_string)),n&&(o+=new Array(n+1).join(" ")),this.__cache.push(o)};function t(n,i){this.__indent_cache=new e(n,i),this.raw=!1,this._end_with_newline=n.end_with_newline,this.indent_size=n.indent_size,this.wrap_line_length=n.wrap_line_length,this.indent_empty_lines=n.indent_empty_lines,this.__lines=[],this.previous_line=null,this.current_line=null,this.next_line=new r(this),this.space_before_token=!1,this.non_breaking_space=!1,this.previous_token_wrapped=!1,this.__add_outputline()}return t.prototype.__add_outputline=function(){this.previous_line=this.current_line,this.current_line=this.next_line.clone_empty(),this.__lines.push(this.current_line)},t.prototype.get_line_number=function(){return this.__lines.length},t.prototype.get_indent_string=function(n,i){return this.__indent_cache.get_indent_string(n,i)},t.prototype.get_indent_size=function(n,i){return this.__indent_cache.get_indent_size(n,i)},t.prototype.is_empty=function(){return!this.previous_line&&this.current_line.is_empty()},t.prototype.add_new_line=function(n){return this.is_empty()||!n&&this.just_added_newline()?!1:(this.raw||this.__add_outputline(),!0)},t.prototype.get_code=function(n){this.trim(!0);var i=this.current_line.pop();i&&(i[i.length-1]===`
|
|
@@ -13478,8 +13478,8 @@ $1`).replace(/>(\s*)(?=<!--\s*\/)/g,"> ")}return nue}IWt();function AOe(r,e,t,n=
|
|
|
13478
13478
|
&:hover {
|
|
13479
13479
|
background-color: rgba(255, 255, 255, 0.1);
|
|
13480
13480
|
}
|
|
13481
|
-
`,onClick:n=>{n.stopPropagation(),t()},children:[ut.jsx("input",{type:"checkbox",checked:e}),ut.jsx("span",{style:{color:"#eee"},children:r})]}),jXt=({children:r,elements:e})=>{const[t,n]=O1(K=>[K.is_mouse_over_container,K.setIsMouseOverContainer]),[i,o]=pt.useState(!1),[a,s]=pt.useState(!1),[l,c]=pt.useState(!1),[u,A]=O1(K=>[K.selected_layer,K.selectLayer]),[d,f,m,C,E,_]=O1(K=>[K.in_move_footprint_mode,K.in_draw_trace_mode,K.is_showing_rats_nest,K.is_showing_multiple_traces_length,K.is_showing_autorouting,K.is_showing_drc_errors]),x=O1(K=>K.setEditMode),w=O1(K=>K.setIsShowingRatsNest),P=O1(K=>K.setIsShowingMultipleTracesLength),L=O1(K=>K.setIsShowingAutorouting),O=O1(K=>K.setIsShowingDrcErrors);s2("1",()=>A("top")),s2("2",()=>A("bottom")),s2("3",()=>A("inner1")),s2("4",()=>A("inner2")),s2("5",()=>A("inner3")),s2("6",()=>A("inner4")),s2("7",()=>A("inner5")),s2("8",()=>A("inner6"));const H=(e==null?void 0:e.filter(K=>K.type.includes("error")).length)??0;return ut.jsxs("div",{style:{position:"relative"},onMouseEnter:()=>{n(!0)},onMouseLeave:K=>{n(!1),s(!1)},children:[r,ut.jsxs("div",{style:{position:"absolute",bottom:4,right:8,pointerEvents:"none",color:"white",fontSize:11,opacity:t?.5:0,transition:"opacity 1s",transitionDelay:"2s",fontFamily:"sans-serif"},children:["@tscircuit/pcb-viewer@",VXt.version]}),ut.jsxs("div",{style:{position:"absolute",opacity:t?1:0,top:16,left:16,transition:t?"opacity 100ms linear":"opacity 1s linear",zIndex:hx.toolbarOverlay,color:"red",display:"flex",fontSize:12,height:100,fontFamily:"sans-serif"},children:[ut.jsxs(qR,{onClick:()=>{s(!a)},onMouseLeave:()=>{a&&s(!1)},children:[ut.jsxs("div",{children:["layer:"," ",ut.jsx("span",{style:{marginLeft:2,fontWeight:500,color:WR[u]},children:u})]}),a&&ut.jsx("div",{style:{marginTop:4,minWidth:120},children:Uue.map(K=>K.replace(/-/g,"")).map(K=>ut.jsx(KXt,{name:K,selected:K===u,onClick:()=>{A(K.replace(/-/,""))}},K))})]}),ut.jsxs(qR,{style:H>0?{color:"red"}:{},onClick:()=>c(!l),onMouseLeave:()=>c(!1),children:[ut.jsxs("div",{children:[H," errors"]}),l&&ut.jsx("div",{style:{display:"grid",gridTemplateColumns:"100px 300px"},children:e==null?void 0:e.filter(K=>K.type.includes("error")).map((K,q)=>ut.jsxs(pt.Fragment,{children:[ut.jsx("div",{children:K.error_type}),ut.jsx("div",{children:K.message})]},q))})]}),ut.jsx(qR,{style:{},onClick:()=>{x(f?"off":"draw_trace")},children:ut.jsxs("div",{children:[f?"✖ ":"","Edit Traces"]})}),ut.jsx(qR,{style:{},onClick:()=>{x(d?"off":"move_footprint")},children:ut.jsxs("div",{children:[d?"✖ ":"","Move Components"]})}),ut.jsx(qR,{style:{},onClick:()=>{w(!m)},children:ut.jsxs("div",{children:[m?"✖ ":"","Rats Nest"]})}),ut.jsx(qR,{onClick:()=>{o(!i)},children:ut.jsxs("div",{children:[ut.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:["View"," ",ut.jsx("span",{style:{fontSize:"8px",transform:i?"rotate(180deg)":"rotate(0)",transition:"transform 0.1s ease",display:"inline-block"},children:"▼"})]}),i&&ut.jsxs("div",{style:{marginTop:4,minWidth:120},children:[ut.jsx(Hue,{label:"Show All Trace Lengths",checked:C,onClick:()=>{P(!C)}}),ut.jsx(Hue,{label:"Show Autorouting Animation",checked:E,onClick:()=>{L(!E)}}),ut.jsx(Hue,{label:"Show DRC Errors",checked:_,onClick:()=>{O(!_)}})]})]})})]})]})},JXt=r=>{const{transform:e,elements:t}=r,[n,i]=pt.useMemo(()=>{const c=r.elements.flatMap(A=>oXt(A,r.elements)),u=Tw(r.elements);return[c,u]},[r.elements]),[o,a]=pt.useState({drawingObjectIdsWithMouseOver:new Set,primitiveIdsInMousedOverNet:[]}),s=pt.useMemo(()=>rXt({primitivesWithoutInteractionMetadata:n,drawingObjectIdsWithMouseOver:o.drawingObjectIdsWithMouseOver,primitiveIdsInMousedOverNet:o.primitiveIdsInMousedOverNet}),[n,o]),l=pt.useCallback(c=>{var d,f;const u=[];for(const m of c)if(m._element){const C=i.getNetConnectedToId("pcb_port_id"in m._element?(d=m._element)==null?void 0:d.pcb_port_id:"pcb_trace_id"in m._element?(f=m._element)==null?void 0:f.pcb_trace_id:"");u.push(...i.getIdsConnectedToNet(C))}const A=new Set(c.map(m=>m._pcb_drawing_object_id));a({drawingObjectIdsWithMouseOver:A,primitiveIdsInMousedOverNet:u})},[i]);return ut.jsx(HXt,{elements:t,transform:e,primitives:n,onMouseHoverOverPrimitives:l,children:ut.jsx(bXt,{disabled:!r.allowEditing,transform:e,soup:t,cancelPanDrag:r.cancelPanDrag,onCreateEditEvent:r.onCreateEditEvent,onModifyEditEvent:r.onModifyEditEvent,children:ut.jsx(MXt,{disabled:!r.allowEditing,transform:e,soup:t,cancelPanDrag:r.cancelPanDrag,onCreateEditEvent:r.onCreateEditEvent,onModifyEditEvent:r.onModifyEditEvent,children:ut.jsx(xXt,{transform:e,focusOnHover:r.focusOnHover,children:ut.jsx(jXt,{elements:t,children:ut.jsx(NXt,{transform:e,elements:t,children:ut.jsx(YXt,{transform:e,soup:t,children:ut.jsx(EXt,{transform:e,debugGraphics:r.debugGraphics,children:ut.jsx(_Xt,{transform:e,elements:t,children:ut.jsx(CXt,{transform:e,primitives:s,width:r.width,height:r.height,grid:r.grid})})})})})})})})})})},WXt=Ku($d(400,300),oE(40,-40)),qXt=({circuitJson:r,debugGraphics:e,height:t=600,initialState:n,allowEditing:i=!0,editEvents:o,onEditEventsChanged:a,focusOnHover:s=!1,clickToInteractEnabled:l=!1})=>{const[c,u]=pt.useState(!l),[A,d]=Oue(),[f,m]=pt.useState(WXt),{ref:C,setTransform:E,cancelDrag:_}=nXt({transform:f,onSetTransform:m,enabled:c});let[x,w]=pt.useState([]);x=o??x;const P=pt.useRef(!1),L=pt.useRef(null),O=`${(r==null?void 0:r.length)||0}_${(r==null?void 0:r.editCount)||0}`,H=()=>{const ie=(d==null?void 0:d.width)>0?d:{width:500,height:500},{center:de,width:Ce,height:xe}=q.some(ve=>ve.type.startsWith("pcb_"))?KZt(q.filter(ve=>ve.type.startsWith("pcb_"))):{center:{x:0,y:0},width:.001,height:.001},fe=Math.min((ie.width??0)/Ce,(ie.height??0)/xe,100)*.75,Ie=Ku($d((ie.width??0)/2,(ie.height??0)/2),oE(fe,-fe,0,0),$d(-de.x,-de.y));E(Ie)};pt.useEffect(()=>{d!=null&&d.width&&r&&r.length!==0&&(P.current||(H(),P.current=!0))},[r,d]);const K=pt.useMemo(()=>(r==null?void 0:r.filter(ie=>ie.type.startsWith("pcb_")||ie.type.startsWith("source_")))??[],[O]),q=pt.useMemo(()=>oJt({circuitJson:K,editEvents:x}),[K,x]),Y=ie=>{w([...x,ie]),a==null||a([...x,ie])},se=ie=>{const de=x.map(Ce=>Ce.edit_event_id===ie.edit_event_id?{...Ce,...ie}:Ce);w(de),a==null||a(de)};return ut.jsxs("div",{ref:C,style:{position:"relative"},children:[ut.jsx("div",{ref:A,children:ut.jsxs(JZt,{initialState:n,children:[ut.jsx(JXt,{transform:f,height:t,width:d.width,allowEditing:i,focusOnHover:s,cancelPanDrag:_,onCreateEditEvent:Y,onModifyEditEvent:se,grid:{spacing:1,view_window:{left:0,right:d.width||500,top:t,bottom:0}},elements:q,debugGraphics:e},d.width),ut.jsx(qZt,{})]})}),l&&!c&&ut.jsx("div",{onClick:()=>{u(!0),H()},onTouchStart:ie=>{const de=ie.touches[0];L.current={x:de.clientX,y:de.clientY}},onTouchEnd:ie=>{const de=ie.changedTouches[0],Ce=L.current;if(!Ce)return;const xe=Math.abs(de.clientX-Ce.x),fe=Math.abs(de.clientY-Ce.y);xe<10&&fe<10&&(ie.preventDefault(),u(!0),H()),L.current=null},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:hx.clickToInteractOverlay,display:"flex",alignItems:"center",justifyContent:"center",touchAction:"pan-x pan-y pinch-zoom"},children:ut.jsx("div",{style:{backgroundColor:"rgba(0, 0, 0, 0.8)",color:"white",padding:"12px 24px",borderRadius:"8px",fontSize:"16px",pointerEvents:"none"},children:typeof window<"u"&&("ontouchstart"in window||navigator.maxTouchPoints>0)?"Touch to Interact":"Click to Interact"})})]})};const ZXt=({containerClassName:r,...e})=>{const t=pt.useRef(null),[n,i]=pt.useState(620);return pt.useLayoutEffect(()=>{const o=()=>{if(t.current){const s=t.current.clientHeight,l=window.innerHeight;i(Math.min(Math.max(s,620),l))}};o();const a=new ResizeObserver(o);return t.current&&a.observe(t.current),window.addEventListener("resize",o),()=>{a.disconnect(),window.removeEventListener("resize",o)}},[]),ut.jsx("div",{ref:t,className:r||"rf-w-full rf-h-full",children:ut.jsx(qXt,{...e,height:n})})},XXt='*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com*/*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{color:inherit;font-family:inherit;font-feature-settings:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#9ca3af;opacity:1}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]:where(:not([hidden=until-found])){display:none}:root{--radius:0.5rem}.rf-pointer-events-none{pointer-events:none}.rf-invisible{visibility:hidden}.rf-fixed{position:fixed}.rf-absolute{position:absolute}.rf-relative{position:relative}.rf-inset-0{inset:0}.-rf-left-2{left:-.5rem}.-rf-right-10{right:-2.5rem}.-rf-right-2{right:-.5rem}.-rf-right-4{right:-1rem}.-rf-right-6{right:-1.5rem}.-rf-right-7{right:-1.75rem}.-rf-right-8{right:-2rem}.-rf-right-9{right:-2.25rem}.rf-bottom-full{bottom:100%}.rf-left-0{left:0}.rf-left-1{left:.25rem}.rf-left-1\\/2{left:50%}.rf-left-2{left:.5rem}.rf-left-\\[50\\%\\]{left:50%}.rf-right-0{right:0}.rf-right-1{right:.25rem}.rf-right-4{right:1rem}.rf-right-\\[4px\\]{right:4px}.rf-top-0{top:0}.rf-top-1{top:.25rem}.rf-top-2{top:.5rem}.rf-top-2\\.5{top:.625rem}.rf-top-\\[50\\%\\]{top:50%}.rf-top-\\[6px\\]{top:6px}.\\!rf-z-\\[101\\]{z-index:101!important}.rf-z-10{z-index:10}.rf-z-50{z-index:50}.rf-z-\\[100\\]{z-index:100}.rf-order-1{order:1}.rf-order-2{order:2}.rf-order-3{order:3}.rf-m-1{margin:.25rem}.rf-m-6{margin:1.5rem}.-rf-mx-1,.rf--mx-1{margin-left:-.25rem;margin-right:-.25rem}.rf-mx-1{margin-left:.25rem;margin-right:.25rem}.rf-mx-2{margin-left:.5rem;margin-right:.5rem}.rf-mx-4{margin-left:1rem;margin-right:1rem}.rf-mx-auto{margin-left:auto;margin-right:auto}.rf-my-1{margin-bottom:.25rem;margin-top:.25rem}.rf-my-12{margin-bottom:3rem;margin-top:3rem}.rf-my-4{margin-bottom:1rem;margin-top:1rem}.rf-my-auto{margin-bottom:auto;margin-top:auto}.rf-mb-1{margin-bottom:.25rem}.rf-mb-12{margin-bottom:3rem}.rf-mb-2{margin-bottom:.5rem}.rf-mb-3{margin-bottom:.75rem}.rf-mb-4{margin-bottom:1rem}.rf-mb-6{margin-bottom:1.5rem}.rf-mb-8{margin-bottom:2rem}.rf-ml-1{margin-left:.25rem}.rf-ml-2{margin-left:.5rem}.rf-ml-auto{margin-left:auto}.rf-mr-1{margin-right:.25rem}.rf-mr-2{margin-right:.5rem}.rf-mt-0{margin-top:0}.rf-mt-0\\.5{margin-top:.125rem}.rf-mt-1{margin-top:.25rem}.rf-mt-2{margin-top:.5rem}.rf-mt-3{margin-top:.75rem}.rf-mt-4{margin-top:1rem}.rf-mt-5{margin-top:1.25rem}.rf-mt-auto{margin-top:auto}.rf-block{display:block}.rf-inline-block{display:inline-block}.rf-inline{display:inline}.rf-flex{display:flex}.rf-inline-flex{display:inline-flex}.rf-grid{display:grid}.rf-hidden{display:none}.rf-aspect-square{aspect-ratio:1/1}.rf-aspect-video{aspect-ratio:16/9}.rf-size-14{height:3.5rem;width:3.5rem}.rf-size-4{height:1rem;width:1rem}.\\!rf-h-2{height:.5rem!important}.\\!rf-h-2\\.5{height:.625rem!important}.\\!rf-h-3{height:.75rem!important}.\\!rf-h-full{height:100%!important}.rf-h-1{height:.25rem}.rf-h-10{height:2.5rem}.rf-h-12{height:3rem}.rf-h-2{height:.5rem}.rf-h-2\\.5{height:.625rem}.rf-h-3{height:.75rem}.rf-h-3\\.5{height:.875rem}.rf-h-4{height:1rem}.rf-h-5{height:1.25rem}.rf-h-6{height:1.5rem}.rf-h-60{height:15rem}.rf-h-64{height:16rem}.rf-h-8{height:2rem}.rf-h-9{height:2.25rem}.rf-h-\\[400px\\]{height:400px}.rf-h-\\[calc\\(100vh-52px\\)\\]{height:calc(100vh - 52px)}.rf-h-\\[var\\(--radix-select-trigger-height\\)\\]{height:var(--radix-select-trigger-height)}.rf-h-auto{height:auto}.rf-h-fit{height:-moz-fit-content;height:fit-content}.rf-h-full{height:100%}.rf-h-px{height:1px}.rf-h-screen{height:100vh}.\\!rf-max-h-\\[40vh\\]{max-height:40vh!important}.rf-max-h-32{max-height:8rem}.rf-max-h-96{max-height:24rem}.rf-max-h-\\[300px\\]{max-height:300px}.rf-max-h-\\[500px\\]{max-height:500px}.rf-max-h-\\[90vh\\]{max-height:90vh}.rf-max-h-full{max-height:100%}.rf-min-h-0{min-height:0}.rf-min-h-\\[200px\\]{min-height:200px}.rf-min-h-\\[300px\\]{min-height:300px}.rf-min-h-\\[620px\\]{min-height:620px}.rf-min-h-\\[calc\\(100vh-240px\\)\\]{min-height:calc(100vh - 240px)}.\\!rf-w-2{width:.5rem!important}.\\!rf-w-2\\.5{width:.625rem!important}.rf-w-1{width:.25rem}.rf-w-1\\/2{width:50%}.rf-w-11{width:2.75rem}.rf-w-11\\/12{width:91.666667%}.rf-w-12{width:3rem}.rf-w-16{width:4rem}.rf-w-2{width:.5rem}.rf-w-2\\.5{width:.625rem}.rf-w-20{width:5rem}.rf-w-28{width:7rem}.rf-w-3{width:.75rem}.rf-w-3\\.5{width:.875rem}.rf-w-32{width:8rem}.rf-w-4{width:1rem}.rf-w-48{width:12rem}.rf-w-5{width:1.25rem}.rf-w-6{width:1.5rem}.rf-w-64{width:16rem}.rf-w-72{width:18rem}.rf-w-8{width:2rem}.rf-w-9{width:2.25rem}.rf-w-96{width:24rem}.rf-w-\\[95\\%\\]{width:95%}.rf-w-fit{width:-moz-fit-content;width:fit-content}.rf-w-full{width:100%}.rf-w-screen{width:100vw}.rf-min-w-0{min-width:0}.rf-min-w-10{min-width:2.5rem}.rf-min-w-16{min-width:4rem}.rf-min-w-\\[148px\\]{min-width:148px}.rf-min-w-\\[8rem\\]{min-width:8rem}.rf-min-w-\\[var\\(--radix-select-trigger-width\\)\\]{min-width:var(--radix-select-trigger-width)}.\\!rf-max-w-\\[660px\\]{max-width:660px!important}.rf-max-w-2xl{max-width:42rem}.rf-max-w-3xl{max-width:48rem}.rf-max-w-4xl{max-width:56rem}.rf-max-w-5xl{max-width:64rem}.rf-max-w-full{max-width:100%}.rf-max-w-lg{max-width:32rem}.rf-max-w-md{max-width:28rem}.rf-max-w-none{max-width:none}.rf-max-w-xl{max-width:36rem}.rf-flex-1{flex:1 1 0%}.rf-flex-shrink-0,.rf-shrink-0{flex-shrink:0}.rf-flex-grow{flex-grow:1}.rf-table-auto{table-layout:auto}.rf-origin-\\[--radix-popover-content-transform-origin\\]{transform-origin:var(--radix-popover-content-transform-origin)}.-rf-translate-x-1{--tw-translate-x:-0.25rem}.-rf-translate-x-1,.-rf-translate-x-1\\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-rf-translate-x-1\\/2{--tw-translate-x:-50%}.-rf-translate-y-1{--tw-translate-y:-0.25rem}.-rf-translate-y-1,.rf--translate-x-1{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf--translate-x-1{--tw-translate-x:-0.25rem}.rf--translate-x-1\\/2{--tw-translate-x:-50%}.rf--translate-x-1\\/2,.rf--translate-y-1{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf--translate-y-1{--tw-translate-y:-0.25rem}.rf-translate-x-\\[-50\\%\\]{--tw-translate-x:-50%}.rf-translate-x-\\[-50\\%\\],.rf-translate-y-\\[-50\\%\\]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf-translate-y-\\[-50\\%\\]{--tw-translate-y:-50%}.rf-transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes rf-pulse{50%{opacity:.5}}.rf-animate-pulse{animation:rf-pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes rf-spin{to{transform:rotate(1turn)}}.rf-animate-spin{animation:rf-spin 1s linear infinite}.rf-cursor-default{cursor:default}.rf-cursor-not-allowed{cursor:not-allowed}.rf-cursor-pointer{cursor:pointer}.rf-select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.rf-grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.rf-flex-row{flex-direction:row}.rf-flex-col{flex-direction:column}.rf-flex-col-reverse{flex-direction:column-reverse}.rf-flex-wrap{flex-wrap:wrap}.rf-place-items-center{place-items:center}.rf-items-start{align-items:flex-start}.rf-items-end{align-items:flex-end}.rf-items-center{align-items:center}.rf-items-stretch{align-items:stretch}.rf-justify-end{justify-content:flex-end}.rf-justify-center{justify-content:center}.rf-justify-between{justify-content:space-between}.rf-gap-0{gap:0}.rf-gap-1{gap:.25rem}.rf-gap-2{gap:.5rem}.rf-gap-3{gap:.75rem}.rf-gap-4{gap:1rem}.rf-gap-5{gap:1.25rem}.rf-gap-6{gap:1.5rem}.rf-gap-8{gap:2rem}.rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.rf-space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.5rem*var(--tw-space-y-reverse));margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.75rem*var(--tw-space-y-reverse));margin-top:calc(.75rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1rem*var(--tw-space-y-reverse));margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1.5rem*var(--tw-space-y-reverse));margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)))}.rf-divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse:0;border-bottom-width:calc(1px*var(--tw-divide-y-reverse));border-top-width:calc(1px*(1 - var(--tw-divide-y-reverse)))}.rf-overflow-auto{overflow:auto}.rf-overflow-hidden{overflow:hidden}.rf-overflow-visible{overflow:visible}.rf-overflow-x-auto{overflow-x:auto}.\\!rf-overflow-y-auto{overflow-y:auto!important}.rf-overflow-y-auto{overflow-y:auto}.rf-overflow-x-hidden{overflow-x:hidden}.rf-overflow-x-clip{overflow-x:clip}.rf-truncate{overflow:hidden;text-overflow:ellipsis}.rf-truncate,.rf-whitespace-nowrap{white-space:nowrap}.rf-whitespace-pre-wrap{white-space:pre-wrap}.rf-break-words{overflow-wrap:break-word}.rf-rounded{border-radius:.25rem}.rf-rounded-2xl{border-radius:1rem}.rf-rounded-full{border-radius:9999px}.rf-rounded-lg{border-radius:var(--radius)}.rf-rounded-md{border-radius:calc(var(--radius) - 2px)}.rf-rounded-sm{border-radius:calc(var(--radius) - 4px)}.rf-rounded-xl{border-radius:.75rem}.rf-border{border-width:1px}.rf-border-2{border-width:2px}.rf-border-b{border-bottom-width:1px}.rf-border-t{border-top-width:1px}.rf-border-blue-200{--tw-border-opacity:1;border-color:rgb(191 219 254/var(--tw-border-opacity,1))}.rf-border-blue-400{--tw-border-opacity:1;border-color:rgb(96 165 250/var(--tw-border-opacity,1))}.rf-border-blue-500{--tw-border-opacity:1;border-color:rgb(59 130 246/var(--tw-border-opacity,1))}.rf-border-blue-600{--tw-border-opacity:1;border-color:rgb(37 99 235/var(--tw-border-opacity,1))}.rf-border-gray-200{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity,1))}.rf-border-gray-300{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity,1))}.rf-border-green-200{--tw-border-opacity:1;border-color:rgb(187 247 208/var(--tw-border-opacity,1))}.rf-border-input{border-color:hsl(var(--input))}.rf-border-neutral-200{--tw-border-opacity:1;border-color:rgb(229 229 229/var(--tw-border-opacity,1))}.rf-border-orange-200{--tw-border-opacity:1;border-color:rgb(254 215 170/var(--tw-border-opacity,1))}.rf-border-primary{border-color:hsl(var(--primary))}.rf-border-red-200{--tw-border-opacity:1;border-color:rgb(254 202 202/var(--tw-border-opacity,1))}.rf-border-red-400{--tw-border-opacity:1;border-color:rgb(248 113 113/var(--tw-border-opacity,1))}.rf-border-red-500{--tw-border-opacity:1;border-color:rgb(239 68 68/var(--tw-border-opacity,1))}.rf-border-zinc-200{--tw-border-opacity:1;border-color:rgb(228 228 231/var(--tw-border-opacity,1))}.rf-border-zinc-900{--tw-border-opacity:1;border-color:rgb(24 24 27/var(--tw-border-opacity,1))}.rf-bg-background{background-color:hsl(var(--background))}.rf-bg-black{--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity,1))}.rf-bg-black\\/80{background-color:rgba(0,0,0,.8)}.rf-bg-blue-100{--tw-bg-opacity:1;background-color:rgb(219 234 254/var(--tw-bg-opacity,1))}.rf-bg-blue-50{--tw-bg-opacity:1;background-color:rgb(239 246 255/var(--tw-bg-opacity,1))}.rf-bg-blue-500{--tw-bg-opacity:1;background-color:rgb(59 130 246/var(--tw-bg-opacity,1))}.rf-bg-blue-600{--tw-bg-opacity:1;background-color:rgb(37 99 235/var(--tw-bg-opacity,1))}.rf-bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.rf-bg-gray-200{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity,1))}.rf-bg-gray-300{--tw-bg-opacity:1;background-color:rgb(209 213 219/var(--tw-bg-opacity,1))}.rf-bg-gray-400{--tw-bg-opacity:1;background-color:rgb(156 163 175/var(--tw-bg-opacity,1))}.rf-bg-gray-50{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity,1))}.rf-bg-gray-500{--tw-bg-opacity:1;background-color:rgb(107 114 128/var(--tw-bg-opacity,1))}.rf-bg-gray-700{--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity,1))}.rf-bg-gray-800{--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity,1))}.rf-bg-gray-900{--tw-bg-opacity:1;background-color:rgb(17 24 39/var(--tw-bg-opacity,1))}.rf-bg-green-100{--tw-bg-opacity:1;background-color:rgb(220 252 231/var(--tw-bg-opacity,1))}.rf-bg-green-50{--tw-bg-opacity:1;background-color:rgb(240 253 244/var(--tw-bg-opacity,1))}.rf-bg-muted{background-color:hsl(var(--muted))}.rf-bg-neutral-100{--tw-bg-opacity:1;background-color:rgb(245 245 245/var(--tw-bg-opacity,1))}.rf-bg-neutral-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-neutral-800{--tw-bg-opacity:1;background-color:rgb(38 38 38/var(--tw-bg-opacity,1))}.rf-bg-neutral-900{--tw-bg-opacity:1;background-color:rgb(23 23 23/var(--tw-bg-opacity,1))}.rf-bg-orange-400{--tw-bg-opacity:1;background-color:rgb(251 146 60/var(--tw-bg-opacity,1))}.rf-bg-orange-50{--tw-bg-opacity:1;background-color:rgb(255 247 237/var(--tw-bg-opacity,1))}.rf-bg-popover{background-color:hsl(var(--popover))}.rf-bg-red-100{--tw-bg-opacity:1;background-color:rgb(254 226 226/var(--tw-bg-opacity,1))}.rf-bg-red-50{--tw-bg-opacity:1;background-color:rgb(254 242 242/var(--tw-bg-opacity,1))}.rf-bg-red-500{--tw-bg-opacity:1;background-color:rgb(239 68 68/var(--tw-bg-opacity,1))}.rf-bg-red-900{--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.rf-bg-transparent{background-color:transparent}.rf-bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.rf-bg-yellow-100{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity,1))}.rf-bg-zinc-100{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.rf-bg-zinc-200{--tw-bg-opacity:1;background-color:rgb(228 228 231/var(--tw-bg-opacity,1))}.rf-bg-zinc-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-zinc-800{--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.rf-bg-zinc-900{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.rf-bg-opacity-50{--tw-bg-opacity:0.5}.rf-fill-current{fill:currentColor}.rf-object-contain{-o-object-fit:contain;object-fit:contain}.rf-object-cover{-o-object-fit:cover;object-fit:cover}.\\!rf-p-0{padding:0!important}.rf-p-0{padding:0}.rf-p-1{padding:.25rem}.rf-p-2{padding:.5rem}.rf-p-3{padding:.75rem}.rf-p-4{padding:1rem}.rf-p-5{padding:1.25rem}.rf-p-6{padding:1.5rem}.rf-p-8{padding:2rem}.rf-px-1{padding-left:.25rem;padding-right:.25rem}.rf-px-2{padding-left:.5rem;padding-right:.5rem}.rf-px-3{padding-left:.75rem;padding-right:.75rem}.rf-px-4{padding-left:1rem;padding-right:1rem}.rf-px-6{padding-left:1.5rem;padding-right:1.5rem}.rf-px-8{padding-left:2rem;padding-right:2rem}.rf-py-0{padding-bottom:0;padding-top:0}.rf-py-0\\.5{padding-bottom:.125rem;padding-top:.125rem}.rf-py-1{padding-bottom:.25rem;padding-top:.25rem}.rf-py-1\\.5{padding-bottom:.375rem;padding-top:.375rem}.rf-py-10{padding-bottom:2.5rem;padding-top:2.5rem}.rf-py-12{padding-bottom:3rem;padding-top:3rem}.rf-py-2{padding-bottom:.5rem;padding-top:.5rem}.rf-py-3{padding-bottom:.75rem;padding-top:.75rem}.rf-py-4{padding-bottom:1rem;padding-top:1rem}.rf-py-6{padding-bottom:1.5rem;padding-top:1.5rem}.rf-py-8{padding-bottom:2rem;padding-top:2rem}.rf-pb-0{padding-bottom:0}.rf-pb-2{padding-bottom:.5rem}.rf-pb-3{padding-bottom:.75rem}.rf-pb-4{padding-bottom:1rem}.rf-pl-2{padding-left:.5rem}.rf-pl-4{padding-left:1rem}.rf-pl-8{padding-left:2rem}.rf-pr-2{padding-right:.5rem}.rf-pt-0{padding-top:0}.rf-pt-2{padding-top:.5rem}.rf-pt-4{padding-top:1rem}.rf-text-left{text-align:left}.rf-text-center{text-align:center}.rf-text-right{text-align:right}.rf-font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.rf-text-2xl{font-size:1.5rem;line-height:2rem}.rf-text-3xl{font-size:1.875rem;line-height:2.25rem}.rf-text-\\[8px\\]{font-size:8px}.rf-text-base{font-size:1rem;line-height:1.5rem}.rf-text-lg{font-size:1.125rem;line-height:1.75rem}.rf-text-sm{font-size:.875rem;line-height:1.25rem}.rf-text-xl{font-size:1.25rem;line-height:1.75rem}.rf-text-xs{font-size:.75rem;line-height:1rem}.\\!rf-font-normal{font-weight:400!important}.rf-font-bold{font-weight:700}.rf-font-medium{font-weight:500}.rf-font-semibold{font-weight:600}.rf-uppercase{text-transform:uppercase}.rf-capitalize{text-transform:capitalize}.rf-tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.rf-leading-5{line-height:1.25rem}.rf-leading-none{line-height:1}.rf-leading-relaxed{line-height:1.625}.rf-leading-tight{line-height:1.25}.rf-tracking-wide{letter-spacing:.025em}.rf-tracking-widest{letter-spacing:.1em}.rf-text-black{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity,1))}.rf-text-blue-500{--tw-text-opacity:1;color:rgb(59 130 246/var(--tw-text-opacity,1))}.rf-text-blue-600{--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity,1))}.rf-text-blue-700{--tw-text-opacity:1;color:rgb(29 78 216/var(--tw-text-opacity,1))}.rf-text-blue-800{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity,1))}.rf-text-blue-900{--tw-text-opacity:1;color:rgb(30 58 138/var(--tw-text-opacity,1))}.rf-text-current{color:currentColor}.rf-text-gray-400{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity,1))}.rf-text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.rf-text-gray-600{--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity,1))}.rf-text-gray-700{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity,1))}.rf-text-gray-800{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity,1))}.rf-text-gray-900{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.rf-text-green-500{--tw-text-opacity:1;color:rgb(34 197 94/var(--tw-text-opacity,1))}.rf-text-green-600{--tw-text-opacity:1;color:rgb(22 163 74/var(--tw-text-opacity,1))}.rf-text-green-700{--tw-text-opacity:1;color:rgb(21 128 61/var(--tw-text-opacity,1))}.rf-text-green-800{--tw-text-opacity:1;color:rgb(22 101 52/var(--tw-text-opacity,1))}.rf-text-green-900{--tw-text-opacity:1;color:rgb(20 83 45/var(--tw-text-opacity,1))}.rf-text-muted-foreground{color:hsl(var(--muted-foreground))}.rf-text-neutral-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-neutral-500{--tw-text-opacity:1;color:rgb(115 115 115/var(--tw-text-opacity,1))}.rf-text-neutral-900{--tw-text-opacity:1;color:rgb(23 23 23/var(--tw-text-opacity,1))}.rf-text-neutral-950{--tw-text-opacity:1;color:rgb(10 10 10/var(--tw-text-opacity,1))}.rf-text-orange-500{--tw-text-opacity:1;color:rgb(249 115 22/var(--tw-text-opacity,1))}.rf-text-orange-600{--tw-text-opacity:1;color:rgb(234 88 12/var(--tw-text-opacity,1))}.rf-text-orange-800{--tw-text-opacity:1;color:rgb(154 52 18/var(--tw-text-opacity,1))}.rf-text-popover-foreground{color:hsl(var(--popover-foreground))}.rf-text-red-200{--tw-text-opacity:1;color:rgb(254 202 202/var(--tw-text-opacity,1))}.rf-text-red-300{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.rf-text-red-400{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.rf-text-red-500{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity,1))}.rf-text-red-600{--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity,1))}.rf-text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.rf-text-red-800{--tw-text-opacity:1;color:rgb(153 27 27/var(--tw-text-opacity,1))}.rf-text-red-900{--tw-text-opacity:1;color:rgb(127 29 29/var(--tw-text-opacity,1))}.rf-text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.rf-text-yellow-400{--tw-text-opacity:1;color:rgb(250 204 21/var(--tw-text-opacity,1))}.rf-text-yellow-500{--tw-text-opacity:1;color:rgb(234 179 8/var(--tw-text-opacity,1))}.rf-text-yellow-900{--tw-text-opacity:1;color:rgb(113 63 18/var(--tw-text-opacity,1))}.rf-text-zinc-200{--tw-text-opacity:1;color:rgb(228 228 231/var(--tw-text-opacity,1))}.rf-text-zinc-300{--tw-text-opacity:1;color:rgb(212 212 216/var(--tw-text-opacity,1))}.rf-text-zinc-400{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.rf-text-zinc-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-zinc-500{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.rf-text-zinc-900{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.rf-text-zinc-950{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.rf-underline{text-decoration-line:underline}.rf-line-through{text-decoration-line:line-through}.rf-underline-offset-4{text-underline-offset:4px}.rf-opacity-0{opacity:0}.rf-opacity-100{opacity:1}.rf-opacity-25{opacity:.25}.rf-opacity-30{opacity:.3}.rf-opacity-50{opacity:.5}.rf-opacity-60{opacity:.6}.rf-opacity-75{opacity:.75}.rf-shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.rf-shadow,.rf-shadow-lg{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.rf-shadow-md{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color)}.rf-shadow-md,.rf-shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.rf-outline-none{outline:2px solid transparent;outline-offset:2px}.rf-ring-2{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.rf-ring-blue-500{--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246/var(--tw-ring-opacity,1))}.rf-ring-primary{--tw-ring-color:hsl(var(--primary))}.rf-ring-offset-background{--tw-ring-offset-color:hsl(var(--background))}.rf-ring-offset-white{--tw-ring-offset-color:#fff}.rf-transition{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-colors{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-opacity{transition-duration:.15s;transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-duration-200{transition-duration:.2s}.rf-ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}@keyframes enter{0%{opacity:var(--tw-enter-opacity,1);transform:translate3d(var(--tw-enter-translate-x,0),var(--tw-enter-translate-y,0),0) scale3d(var(--tw-enter-scale,1),var(--tw-enter-scale,1),var(--tw-enter-scale,1)) rotate(var(--tw-enter-rotate,0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity,1);transform:translate3d(var(--tw-exit-translate-x,0),var(--tw-exit-translate-y,0),0) scale3d(var(--tw-exit-scale,1),var(--tw-exit-scale,1),var(--tw-exit-scale,1)) rotate(var(--tw-exit-rotate,0))}}.rf-slide-in-from-left-1{--tw-enter-translate-x:-0.25rem}.rf-slide-out-to-left-1{--tw-exit-translate-x:-0.25rem}.rf-duration-200{animation-duration:.2s}.rf-ease-in-out{animation-timing-function:cubic-bezier(.4,0,.2,1)}.file\\:rf-border-0::file-selector-button{border-width:0}.file\\:rf-bg-transparent::file-selector-button{background-color:transparent}.file\\:rf-text-sm::file-selector-button{font-size:.875rem;line-height:1.25rem}.file\\:rf-font-medium::file-selector-button{font-weight:500}.placeholder\\:rf-text-zinc-500::-moz-placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.placeholder\\:rf-text-zinc-500::placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.hover\\:rf-border-blue-300:hover{--tw-border-opacity:1;border-color:rgb(147 197 253/var(--tw-border-opacity,1))}.hover\\:\\!rf-bg-transparent:hover{background-color:transparent!important}.hover\\:rf-bg-blue-700:hover{--tw-bg-opacity:1;background-color:rgb(29 78 216/var(--tw-bg-opacity,1))}.hover\\:rf-bg-red-500\\/90:hover{background-color:rgba(239,68,68,.9)}.hover\\:rf-bg-zinc-100:hover{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.hover\\:rf-bg-zinc-100\\/80:hover{background-color:hsla(240,5%,96%,.8)}.hover\\:rf-bg-zinc-900\\/90:hover{background-color:rgba(24,24,27,.9)}.hover\\:rf-text-red-400:hover{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.hover\\:rf-text-zinc-900:hover{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.hover\\:rf-underline:hover{text-decoration-line:underline}.focus\\:rf-bg-gray-100:focus{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.focus\\:rf-bg-zinc-100:focus{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.focus\\:rf-text-gray-900:focus{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.focus\\:rf-text-zinc-900:focus{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.focus\\:rf-outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\\:rf-ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus\\:rf-ring-ring:focus{--tw-ring-color:hsl(var(--ring))}.focus\\:rf-ring-offset-2:focus{--tw-ring-offset-width:2px}.focus-visible\\:rf-outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px}.focus-visible\\:rf-ring-1:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-2:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-zinc-950:focus-visible{--tw-ring-opacity:1;--tw-ring-color:rgb(9 9 11/var(--tw-ring-opacity,1))}.focus-visible\\:rf-ring-offset-2:focus-visible{--tw-ring-offset-width:2px}.disabled\\:rf-pointer-events-none:disabled{pointer-events:none}.disabled\\:rf-cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:rf-opacity-50:disabled{opacity:.5}.rf-group\\/bar:hover .group-hover\\/bar\\:rf-opacity-100{opacity:1}.data-\\[disabled\\=true\\]\\:rf-pointer-events-none[data-disabled=true],.data-\\[disabled\\]\\:rf-pointer-events-none[data-disabled]{pointer-events:none}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom]{--tw-translate-y:0.25rem}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom],.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{--tw-translate-x:-0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right]{--tw-translate-x:0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right],.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{--tw-translate-y:-0.25rem}.data-\\[selected\\=true\\]\\:rf-bg-zinc-100[data-selected=true]{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.data-\\[state\\=active\\]\\:rf-bg-white[data-state=active]{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.data-\\[state\\=checked\\]\\:rf-bg-zinc-900[data-state=checked]{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.data-\\[state\\=open\\]\\:rf-bg-zinc-100[data-state=open]{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.data-\\[selected\\=true\\]\\:rf-text-zinc-900[data-selected=true]{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.data-\\[state\\=active\\]\\:rf-text-zinc-950[data-state=active]{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.data-\\[state\\=checked\\]\\:rf-text-zinc-50[data-state=checked]{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.data-\\[disabled\\=true\\]\\:rf-opacity-50[data-disabled=true],.data-\\[disabled\\]\\:rf-opacity-50[data-disabled]{opacity:.5}.data-\\[state\\=active\\]\\:rf-shadow[data-state=active]{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.data-\\[state\\=open\\]\\:rf-animate-in[data-state=open]{animation-duration:.15s;animation-name:enter;--tw-enter-opacity:initial;--tw-enter-scale:initial;--tw-enter-rotate:initial;--tw-enter-translate-x:initial;--tw-enter-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-animate-out[data-state=closed]{animation-duration:.15s;animation-name:exit;--tw-exit-opacity:initial;--tw-exit-scale:initial;--tw-exit-rotate:initial;--tw-exit-translate-x:initial;--tw-exit-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-fade-out-0[data-state=closed]{--tw-exit-opacity:0}.data-\\[state\\=open\\]\\:rf-fade-in-0[data-state=open]{--tw-enter-opacity:0}.data-\\[state\\=closed\\]\\:rf-zoom-out-95[data-state=closed]{--tw-exit-scale:.95}.data-\\[state\\=open\\]\\:rf-zoom-in-95[data-state=open]{--tw-enter-scale:.95}.data-\\[side\\=bottom\\]\\:rf-slide-in-from-top-2[data-side=bottom]{--tw-enter-translate-y:-0.5rem}.data-\\[side\\=left\\]\\:rf-slide-in-from-right-2[data-side=left]{--tw-enter-translate-x:0.5rem}.data-\\[side\\=right\\]\\:rf-slide-in-from-left-2[data-side=right]{--tw-enter-translate-x:-0.5rem}.data-\\[side\\=top\\]\\:rf-slide-in-from-bottom-2[data-side=top]{--tw-enter-translate-y:0.5rem}.data-\\[state\\=closed\\]\\:rf-slide-out-to-left-1\\/2[data-state=closed]{--tw-exit-translate-x:-50%}.data-\\[state\\=closed\\]\\:rf-slide-out-to-top-\\[48\\%\\][data-state=closed]{--tw-exit-translate-y:-48%}.data-\\[state\\=open\\]\\:rf-slide-in-from-left-1\\/2[data-state=open]{--tw-enter-translate-x:-50%}.data-\\[state\\=open\\]\\:rf-slide-in-from-top-\\[48\\%\\][data-state=open]{--tw-enter-translate-y:-48%}.dark\\:rf-border-zinc-50:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(250 250 250/var(--tw-border-opacity,1))}.dark\\:rf-border-zinc-800:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(39 39 42/var(--tw-border-opacity,1))}.dark\\:rf-bg-red-900:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-50:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-800:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-950:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:rf-text-zinc-400:is(.rf-dark *){--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-50:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-900:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::-moz-placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-ring-offset-zinc-950:is(.rf-dark *){--tw-ring-offset-color:#09090b}.dark\\:placeholder\\:rf-text-zinc-400:is(.rf-dark *)::-moz-placeholder{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:placeholder\\:rf-text-zinc-400:is(.rf-dark *)::placeholder{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:hover\\:rf-bg-red-900\\/90:hover:is(.rf-dark *){background-color:rgba(127,29,29,.9)}.dark\\:hover\\:rf-bg-zinc-50\\/90:hover:is(.rf-dark *){background-color:hsla(0,0%,98%,.9)}.dark\\:hover\\:rf-bg-zinc-800:hover:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:hover\\:rf-bg-zinc-800\\/80:hover:is(.rf-dark *){background-color:rgba(39,39,42,.8)}.dark\\:hover\\:rf-text-zinc-50:hover:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus\\:rf-bg-zinc-800:focus:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:focus\\:rf-text-zinc-50:focus:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus-visible\\:rf-ring-zinc-300:focus-visible:is(.rf-dark *){--tw-ring-opacity:1;--tw-ring-color:rgb(212 212 216/var(--tw-ring-opacity,1))}.dark\\:data-\\[selected\\=true\\]\\:rf-bg-zinc-800[data-selected=true]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-bg-zinc-950[data-state=active]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-bg-zinc-50[data-state=checked]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=open\\]\\:rf-bg-zinc-800[data-state=open]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:data-\\[selected\\=true\\]\\:rf-text-zinc-50[data-selected=true]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-text-zinc-50[data-state=active]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-text-zinc-900[data-state=checked]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}@media (min-width:640px){.sm\\:rf-order-1{order:1}.sm\\:rf-order-2{order:2}.sm\\:rf-mt-0{margin-top:0}.sm\\:rf-inline{display:inline}.sm\\:rf-hidden{display:none}.sm\\:rf-w-auto{width:auto}.sm\\:rf-flex-row{flex-direction:row}.sm\\:rf-items-center{align-items:center}.sm\\:rf-justify-end{justify-content:flex-end}.sm\\:rf-gap-3{gap:.75rem}.sm\\:rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.sm\\:rf-rounded-lg{border-radius:var(--radius)}.sm\\:rf-px-4{padding-left:1rem;padding-right:1rem}.sm\\:rf-text-left{text-align:left}.sm\\:rf-text-sm{font-size:.875rem;line-height:1.25rem}.sm\\:rf-text-xl{font-size:1.25rem;line-height:1.75rem}}@media (min-width:768px){.md\\:rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}.\\[\\&\\>span\\]\\:rf-line-clamp-1>span{display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:1}.\\[\\&\\>svg\\]\\:rf-size-4>svg{height:1rem;width:1rem}.\\[\\&\\>svg\\]\\:rf-shrink-0>svg{flex-shrink:0}.\\[\\&\\>svg\\]\\:rf-text-red-300>svg{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.\\[\\&\\>svg\\]\\:hover\\:rf-text-red-400:hover>svg{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-px-2 [cmdk-group-heading]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-py-1\\.5 [cmdk-group-heading]{padding-bottom:.375rem;padding-top:.375rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-xs [cmdk-group-heading]{font-size:.75rem;line-height:1rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-font-medium [cmdk-group-heading]{font-weight:500}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-zinc-500 [cmdk-group-heading]{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.dark\\:\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-zinc-400 [cmdk-group-heading]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.\\[\\&_\\[cmdk-group\\]\\:not\\(\\[hidden\\]\\)_\\~\\[cmdk-group\\]\\]\\:rf-pt-0 [cmdk-group]:not([hidden])~[cmdk-group]{padding-top:0}.\\[\\&_\\[cmdk-group\\]\\]\\:rf-px-2 [cmdk-group]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-input-wrapper\\]_svg\\]\\:rf-h-5 [cmdk-input-wrapper] svg{height:1.25rem}.\\[\\&_\\[cmdk-input-wrapper\\]_svg\\]\\:rf-w-5 [cmdk-input-wrapper] svg{width:1.25rem}.\\[\\&_\\[cmdk-input\\]\\]\\:rf-h-12 [cmdk-input]{height:3rem}.\\[\\&_\\[cmdk-item\\]\\]\\:rf-px-2 [cmdk-item]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-item\\]\\]\\:rf-py-3 [cmdk-item]{padding-bottom:.75rem;padding-top:.75rem}.\\[\\&_\\[cmdk-item\\]_svg\\]\\:rf-h-5 [cmdk-item] svg{height:1.25rem}.\\[\\&_\\[cmdk-item\\]_svg\\]\\:rf-w-5 [cmdk-item] svg{width:1.25rem}.\\[\\&_svg\\]\\:rf-pointer-events-none svg{pointer-events:none}.\\[\\&_svg\\]\\:rf-size-4 svg{height:1rem;width:1rem}.\\[\\&_svg\\]\\:rf-shrink-0 svg{flex-shrink:0}',$Xt=()=>{pt.useEffect(()=>{if(document.querySelector('style[data-styles="tscircuit-runframe"]'))return;const e=document.createElement("style");e.setAttribute("data-styles","tscircuit-runframe"),e.textContent=XXt,document.head.appendChild(e)},[])},e$t=r=>{pt.useEffect(()=>(r?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[r])},bHe=r=>`hsl(${ub.indexOf(r)*137.5%360}, 70%, 50%)`,t$t=({phaseTimings:r})=>{if(!r)return null;const e=Object.values(r).reduce((t,n)=>t+n,0);return ut.jsxs("div",{className:"rf-space-y-2 rf-w-full rf-px-4",children:[ut.jsx("div",{className:"rf-relative rf-h-8 rf-flex rf-rounded-sm",children:ub.map(t=>{const n=r[t]||0,i=n/e*100;return ut.jsx("div",{className:"rf-group/bar rf-relative rf-overflow-visible",style:{width:`${i}%`,backgroundColor:bHe(t)},children:ut.jsxs("div",{className:"rf-opacity-0 group-hover/bar:rf-opacity-100 rf-transition-opacity rf-absolute rf-bottom-full rf-left-1/2 rf-transform -rf-translate-x-1/2 rf-mb-2 rf-px-2 rf-py-1 rf-text-xs rf-whitespace-nowrap rf-rounded rf-bg-gray-900 rf-text-white rf-pointer-events-none",children:[t,": ",n.toFixed(1),"ms"]})},t)})}),ut.jsxs("div",{className:"rf-text-xs rf-text-gray-500",children:["Total: ",e.toFixed(2),"ms"]})]})},n$t=({renderLog:r})=>{const[e,t]=pt.useState("chronological");if(!r)return ut.jsx("div",{className:"rf-p-4 rf-bg-gray-100 rf-rounded-md",children:"No render log, make sure this tab is open when you render (TODO add a rerender button here)"});const n=Object.entries((r==null?void 0:r.phaseTimings)??{});e==="chronological"?n.sort((o,a)=>ub.indexOf(o[0])-ub.indexOf(a[0])):n.sort((o,a)=>a[1]-o[1]);const i=n.reduce((o,[a,s])=>o+s,0);return ut.jsxs("div",{className:"rf-bg-white",children:[ut.jsxs("div",{className:"rf-flex rf-justify-between rf-items-center",children:[ut.jsx("div",{children:"Render Logs"}),ut.jsxs("div",{className:"rf-mb-4 rf-pr-2 rf-flex rf-text-xs rf-items-center",children:[ut.jsx("div",{className:"rf-mr-2",children:"Sort by:"}),ut.jsxs("select",{value:e,onChange:o=>t(o.target.value),className:"rf-px-2 rf-py-1 rf-border rf-rounded rf-text-xs",children:[ut.jsx("option",{value:"chronological",children:"Phase Order"}),ut.jsx("option",{value:"longest",children:"Duration"})]})]})]}),ut.jsx(t$t,{phaseTimings:r.phaseTimings}),ut.jsxs("table",{className:"rf-w-full rf-text-xs",children:[ut.jsx("thead",{children:ut.jsxs("tr",{children:[ut.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase Order"}),ut.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase"}),ut.jsx("th",{className:"rf-text-left rf-p-2",children:"Duration (ms)"})]})}),ut.jsx("tbody",{children:n.map(([o,a])=>ut.jsxs("tr",{children:[ut.jsx("td",{className:"rf-p-2",children:ub.indexOf(o)}),ut.jsx("td",{className:"rf-p-2",children:o}),ut.jsx("td",{className:"rf-p-2",children:ut.jsx("div",{className:"rf-w-8",children:ut.jsx("div",{className:"rf-h-2 rf-rounded-sm",style:{backgroundColor:bHe(o),width:`${a/i*100}%`}})})}),ut.jsx("td",{className:"rf-p-2",children:ut.jsxs("div",{className:"rf-flex w-full",children:[ut.jsxs("span",{className:"rf-flex-grow",children:[a,"ms"]}),ut.jsxs("span",{className:"rf-text-gray-500 rf-pr-2",children:[(a/i*100).toFixed(1),"%"]})]})})]},o))})]})]})},r$t=({errorMessage:r,errorStack:e,circuitJsonErrors:t})=>{pt.useEffect(()=>{if(r){const n=new Error(r);e&&(n.stack=e);try{GP.captureException(n)}catch{}}},[r,e]),pt.useEffect(()=>{if(t&&t.length>0)for(const n of t){const i=new Error(n.message||"Circuit JSON Error");n.stack&&(i.stack=n.stack);try{GP.captureException(i,{error_type:n.type})}catch{}}},[t])},i$t="0.0.723",Yue={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},Vue=new Map,DO=r=>{const e=Vue.get(r);return e?Object.fromEntries(Object.entries(e.stores).map(([t,n])=>[t,n.getState()])):{}},o$t=(r,e,t)=>{if(r===void 0)return{type:"untracked",connection:e.connect(t)};const n=Vue.get(t.name);if(n)return{type:"tracked",store:r,...n};const i={connection:e.connect(t),stores:{}};return Vue.set(t.name,i),{type:"tracked",store:r,...i}},a$t=(r,e={})=>(t,n,i)=>{const{enabled:o,anonymousActionType:a,store:s,...l}=e;let c;try{c=(o??(Yue?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!c)return(Yue?"production":void 0)!=="production"&&o&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),r(t,n,i);const{connection:u,...A}=o$t(s,c,l);let d=!0;i.setState=(C,E,_)=>{const x=t(C,E);if(!d)return x;const w=_===void 0?{type:a||"anonymous"}:typeof _=="string"?{type:_}:_;return s===void 0?(u==null||u.send(w,n()),x):(u==null||u.send({...w,type:`${s}/${w.type}`},{...DO(l.name),[s]:i.getState()}),x)};const f=(...C)=>{const E=d;d=!1,t(...C),d=E},m=r(i.setState,n,i);if(A.type==="untracked"?u==null||u.init(m):(A.stores[A.store]=i,u==null||u.init(Object.fromEntries(Object.entries(A.stores).map(([C,E])=>[C,C===A.store?m:E.getState()])))),i.dispatchFromDevtools&&typeof i.dispatch=="function"){let C=!1;const E=i.dispatch;i.dispatch=(..._)=>{(Yue?"production":void 0)!=="production"&&_[0].type==="__setState"&&!C&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),C=!0),E(..._)}}return u.subscribe(C=>{var E;switch(C.type){case"ACTION":if(typeof C.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return Kue(C.payload,_=>{if(_.type==="__setState"){if(s===void 0){f(_.state);return}Object.keys(_.state).length!==1&&console.error(`
|
|
13481
|
+
`,onClick:n=>{n.stopPropagation(),t()},children:[ut.jsx("input",{type:"checkbox",checked:e}),ut.jsx("span",{style:{color:"#eee"},children:r})]}),jXt=({children:r,elements:e})=>{const[t,n]=O1(K=>[K.is_mouse_over_container,K.setIsMouseOverContainer]),[i,o]=pt.useState(!1),[a,s]=pt.useState(!1),[l,c]=pt.useState(!1),[u,A]=O1(K=>[K.selected_layer,K.selectLayer]),[d,f,m,C,E,_]=O1(K=>[K.in_move_footprint_mode,K.in_draw_trace_mode,K.is_showing_rats_nest,K.is_showing_multiple_traces_length,K.is_showing_autorouting,K.is_showing_drc_errors]),x=O1(K=>K.setEditMode),w=O1(K=>K.setIsShowingRatsNest),P=O1(K=>K.setIsShowingMultipleTracesLength),L=O1(K=>K.setIsShowingAutorouting),O=O1(K=>K.setIsShowingDrcErrors);s2("1",()=>A("top")),s2("2",()=>A("bottom")),s2("3",()=>A("inner1")),s2("4",()=>A("inner2")),s2("5",()=>A("inner3")),s2("6",()=>A("inner4")),s2("7",()=>A("inner5")),s2("8",()=>A("inner6"));const H=(e==null?void 0:e.filter(K=>K.type.includes("error")).length)??0;return ut.jsxs("div",{style:{position:"relative"},onMouseEnter:()=>{n(!0)},onMouseLeave:K=>{n(!1),s(!1)},children:[r,ut.jsxs("div",{style:{position:"absolute",bottom:4,right:8,pointerEvents:"none",color:"white",fontSize:11,opacity:t?.5:0,transition:"opacity 1s",transitionDelay:"2s",fontFamily:"sans-serif"},children:["@tscircuit/pcb-viewer@",VXt.version]}),ut.jsxs("div",{style:{position:"absolute",opacity:t?1:0,top:16,left:16,transition:t?"opacity 100ms linear":"opacity 1s linear",zIndex:hx.toolbarOverlay,color:"red",display:"flex",fontSize:12,height:100,fontFamily:"sans-serif"},children:[ut.jsxs(qR,{onClick:()=>{s(!a)},onMouseLeave:()=>{a&&s(!1)},children:[ut.jsxs("div",{children:["layer:"," ",ut.jsx("span",{style:{marginLeft:2,fontWeight:500,color:WR[u]},children:u})]}),a&&ut.jsx("div",{style:{marginTop:4,minWidth:120},children:Uue.map(K=>K.replace(/-/g,"")).map(K=>ut.jsx(KXt,{name:K,selected:K===u,onClick:()=>{A(K.replace(/-/,""))}},K))})]}),ut.jsxs(qR,{style:H>0?{color:"red"}:{},onClick:()=>c(!l),onMouseLeave:()=>c(!1),children:[ut.jsxs("div",{children:[H," errors"]}),l&&ut.jsx("div",{style:{display:"grid",gridTemplateColumns:"100px 300px"},children:e==null?void 0:e.filter(K=>K.type.includes("error")).map((K,q)=>ut.jsxs(pt.Fragment,{children:[ut.jsx("div",{children:K.error_type}),ut.jsx("div",{children:K.message})]},q))})]}),ut.jsx(qR,{style:{},onClick:()=>{x(f?"off":"draw_trace")},children:ut.jsxs("div",{children:[f?"✖ ":"","Edit Traces"]})}),ut.jsx(qR,{style:{},onClick:()=>{x(d?"off":"move_footprint")},children:ut.jsxs("div",{children:[d?"✖ ":"","Move Components"]})}),ut.jsx(qR,{style:{},onClick:()=>{w(!m)},children:ut.jsxs("div",{children:[m?"✖ ":"","Rats Nest"]})}),ut.jsx(qR,{onClick:()=>{o(!i)},children:ut.jsxs("div",{children:[ut.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:["View"," ",ut.jsx("span",{style:{fontSize:"8px",transform:i?"rotate(180deg)":"rotate(0)",transition:"transform 0.1s ease",display:"inline-block"},children:"▼"})]}),i&&ut.jsxs("div",{style:{marginTop:4,minWidth:120},children:[ut.jsx(Hue,{label:"Show All Trace Lengths",checked:C,onClick:()=>{P(!C)}}),ut.jsx(Hue,{label:"Show Autorouting Animation",checked:E,onClick:()=>{L(!E)}}),ut.jsx(Hue,{label:"Show DRC Errors",checked:_,onClick:()=>{O(!_)}})]})]})})]})]})},JXt=r=>{const{transform:e,elements:t}=r,[n,i]=pt.useMemo(()=>{const c=r.elements.flatMap(A=>oXt(A,r.elements)),u=Tw(r.elements);return[c,u]},[r.elements]),[o,a]=pt.useState({drawingObjectIdsWithMouseOver:new Set,primitiveIdsInMousedOverNet:[]}),s=pt.useMemo(()=>rXt({primitivesWithoutInteractionMetadata:n,drawingObjectIdsWithMouseOver:o.drawingObjectIdsWithMouseOver,primitiveIdsInMousedOverNet:o.primitiveIdsInMousedOverNet}),[n,o]),l=pt.useCallback(c=>{var d,f;const u=[];for(const m of c)if(m._element){const C=i.getNetConnectedToId("pcb_port_id"in m._element?(d=m._element)==null?void 0:d.pcb_port_id:"pcb_trace_id"in m._element?(f=m._element)==null?void 0:f.pcb_trace_id:"");u.push(...i.getIdsConnectedToNet(C))}const A=new Set(c.map(m=>m._pcb_drawing_object_id));a({drawingObjectIdsWithMouseOver:A,primitiveIdsInMousedOverNet:u})},[i]);return ut.jsx(HXt,{elements:t,transform:e,primitives:n,onMouseHoverOverPrimitives:l,children:ut.jsx(bXt,{disabled:!r.allowEditing,transform:e,soup:t,cancelPanDrag:r.cancelPanDrag,onCreateEditEvent:r.onCreateEditEvent,onModifyEditEvent:r.onModifyEditEvent,children:ut.jsx(MXt,{disabled:!r.allowEditing,transform:e,soup:t,cancelPanDrag:r.cancelPanDrag,onCreateEditEvent:r.onCreateEditEvent,onModifyEditEvent:r.onModifyEditEvent,children:ut.jsx(xXt,{transform:e,focusOnHover:r.focusOnHover,children:ut.jsx(jXt,{elements:t,children:ut.jsx(NXt,{transform:e,elements:t,children:ut.jsx(YXt,{transform:e,soup:t,children:ut.jsx(EXt,{transform:e,debugGraphics:r.debugGraphics,children:ut.jsx(_Xt,{transform:e,elements:t,children:ut.jsx(CXt,{transform:e,primitives:s,width:r.width,height:r.height,grid:r.grid})})})})})})})})})})},WXt=Ku($d(400,300),oE(40,-40)),qXt=({circuitJson:r,debugGraphics:e,height:t=600,initialState:n,allowEditing:i=!0,editEvents:o,onEditEventsChanged:a,focusOnHover:s=!1,clickToInteractEnabled:l=!1})=>{const[c,u]=pt.useState(!l),[A,d]=Oue(),[f,m]=pt.useState(WXt),{ref:C,setTransform:E,cancelDrag:_}=nXt({transform:f,onSetTransform:m,enabled:c});let[x,w]=pt.useState([]);x=o??x;const P=pt.useRef(!1),L=pt.useRef(null),O=`${(r==null?void 0:r.length)||0}_${(r==null?void 0:r.editCount)||0}`,H=()=>{const ie=(d==null?void 0:d.width)>0?d:{width:500,height:500},{center:de,width:Ce,height:xe}=q.some(ve=>ve.type.startsWith("pcb_"))?KZt(q.filter(ve=>ve.type.startsWith("pcb_"))):{center:{x:0,y:0},width:.001,height:.001},fe=Math.min((ie.width??0)/Ce,(ie.height??0)/xe,100)*.75,Ie=Ku($d((ie.width??0)/2,(ie.height??0)/2),oE(fe,-fe,0,0),$d(-de.x,-de.y));E(Ie)};pt.useEffect(()=>{d!=null&&d.width&&r&&r.length!==0&&(P.current||(H(),P.current=!0))},[r,d]);const K=pt.useMemo(()=>(r==null?void 0:r.filter(ie=>ie.type.startsWith("pcb_")||ie.type.startsWith("source_")))??[],[O]),q=pt.useMemo(()=>oJt({circuitJson:K,editEvents:x}),[K,x]),Y=ie=>{w([...x,ie]),a==null||a([...x,ie])},se=ie=>{const de=x.map(Ce=>Ce.edit_event_id===ie.edit_event_id?{...Ce,...ie}:Ce);w(de),a==null||a(de)};return ut.jsxs("div",{ref:C,style:{position:"relative"},children:[ut.jsx("div",{ref:A,children:ut.jsxs(JZt,{initialState:n,children:[ut.jsx(JXt,{transform:f,height:t,width:d.width,allowEditing:i,focusOnHover:s,cancelPanDrag:_,onCreateEditEvent:Y,onModifyEditEvent:se,grid:{spacing:1,view_window:{left:0,right:d.width||500,top:t,bottom:0}},elements:q,debugGraphics:e},d.width),ut.jsx(qZt,{})]})}),l&&!c&&ut.jsx("div",{onClick:()=>{u(!0),H()},onTouchStart:ie=>{const de=ie.touches[0];L.current={x:de.clientX,y:de.clientY}},onTouchEnd:ie=>{const de=ie.changedTouches[0],Ce=L.current;if(!Ce)return;const xe=Math.abs(de.clientX-Ce.x),fe=Math.abs(de.clientY-Ce.y);xe<10&&fe<10&&(ie.preventDefault(),u(!0),H()),L.current=null},style:{position:"absolute",inset:0,cursor:"pointer",zIndex:hx.clickToInteractOverlay,display:"flex",alignItems:"center",justifyContent:"center",touchAction:"pan-x pan-y pinch-zoom"},children:ut.jsx("div",{style:{backgroundColor:"rgba(0, 0, 0, 0.8)",color:"white",padding:"12px 24px",borderRadius:"8px",fontSize:"16px",pointerEvents:"none"},children:typeof window<"u"&&("ontouchstart"in window||navigator.maxTouchPoints>0)?"Touch to Interact":"Click to Interact"})})]})};const ZXt=({containerClassName:r,...e})=>{const t=pt.useRef(null),[n,i]=pt.useState(620);return pt.useLayoutEffect(()=>{const o=()=>{if(t.current){const s=t.current.clientHeight,l=window.innerHeight;i(Math.min(Math.max(s,620),l))}};o();const a=new ResizeObserver(o);return t.current&&a.observe(t.current),window.addEventListener("resize",o),()=>{a.disconnect(),window.removeEventListener("resize",o)}},[]),ut.jsx("div",{ref:t,className:r||"rf-w-full rf-h-full",children:ut.jsx(qXt,{...e,height:n})})},XXt='*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com*/*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{color:inherit;font-family:inherit;font-feature-settings:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#9ca3af;opacity:1}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]:where(:not([hidden=until-found])){display:none}:root{--radius:0.5rem}.rf-pointer-events-none{pointer-events:none}.rf-invisible{visibility:hidden}.rf-fixed{position:fixed}.rf-absolute{position:absolute}.rf-relative{position:relative}.rf-inset-0{inset:0}.-rf-left-2{left:-.5rem}.-rf-right-10{right:-2.5rem}.-rf-right-2{right:-.5rem}.-rf-right-4{right:-1rem}.-rf-right-6{right:-1.5rem}.-rf-right-7{right:-1.75rem}.-rf-right-8{right:-2rem}.-rf-right-9{right:-2.25rem}.rf-bottom-full{bottom:100%}.rf-left-0{left:0}.rf-left-1{left:.25rem}.rf-left-1\\/2{left:50%}.rf-left-2{left:.5rem}.rf-left-\\[50\\%\\]{left:50%}.rf-right-0{right:0}.rf-right-1{right:.25rem}.rf-right-4{right:1rem}.rf-right-\\[4px\\]{right:4px}.rf-top-0{top:0}.rf-top-1{top:.25rem}.rf-top-2{top:.5rem}.rf-top-2\\.5{top:.625rem}.rf-top-\\[50\\%\\]{top:50%}.rf-top-\\[6px\\]{top:6px}.\\!rf-z-\\[101\\]{z-index:101!important}.rf-z-10{z-index:10}.rf-z-50{z-index:50}.rf-z-\\[100\\]{z-index:100}.rf-order-1{order:1}.rf-order-2{order:2}.rf-order-3{order:3}.rf-m-1{margin:.25rem}.rf-m-6{margin:1.5rem}.-rf-mx-1,.rf--mx-1{margin-left:-.25rem;margin-right:-.25rem}.rf-mx-1{margin-left:.25rem;margin-right:.25rem}.rf-mx-2{margin-left:.5rem;margin-right:.5rem}.rf-mx-4{margin-left:1rem;margin-right:1rem}.rf-mx-auto{margin-left:auto;margin-right:auto}.rf-my-1{margin-bottom:.25rem;margin-top:.25rem}.rf-my-12{margin-bottom:3rem;margin-top:3rem}.rf-my-4{margin-bottom:1rem;margin-top:1rem}.rf-my-auto{margin-bottom:auto;margin-top:auto}.rf-mb-1{margin-bottom:.25rem}.rf-mb-12{margin-bottom:3rem}.rf-mb-2{margin-bottom:.5rem}.rf-mb-3{margin-bottom:.75rem}.rf-mb-4{margin-bottom:1rem}.rf-mb-6{margin-bottom:1.5rem}.rf-mb-8{margin-bottom:2rem}.rf-ml-1{margin-left:.25rem}.rf-ml-2{margin-left:.5rem}.rf-ml-auto{margin-left:auto}.rf-mr-1{margin-right:.25rem}.rf-mr-2{margin-right:.5rem}.rf-mt-0{margin-top:0}.rf-mt-0\\.5{margin-top:.125rem}.rf-mt-1{margin-top:.25rem}.rf-mt-2{margin-top:.5rem}.rf-mt-3{margin-top:.75rem}.rf-mt-4{margin-top:1rem}.rf-mt-5{margin-top:1.25rem}.rf-mt-auto{margin-top:auto}.rf-block{display:block}.rf-inline-block{display:inline-block}.rf-inline{display:inline}.rf-flex{display:flex}.rf-inline-flex{display:inline-flex}.rf-grid{display:grid}.rf-hidden{display:none}.rf-aspect-square{aspect-ratio:1/1}.rf-aspect-video{aspect-ratio:16/9}.rf-size-14{height:3.5rem;width:3.5rem}.rf-size-4{height:1rem;width:1rem}.\\!rf-h-2{height:.5rem!important}.\\!rf-h-2\\.5{height:.625rem!important}.\\!rf-h-3{height:.75rem!important}.\\!rf-h-full{height:100%!important}.rf-h-1{height:.25rem}.rf-h-10{height:2.5rem}.rf-h-12{height:3rem}.rf-h-2{height:.5rem}.rf-h-2\\.5{height:.625rem}.rf-h-3{height:.75rem}.rf-h-3\\.5{height:.875rem}.rf-h-4{height:1rem}.rf-h-5{height:1.25rem}.rf-h-6{height:1.5rem}.rf-h-60{height:15rem}.rf-h-64{height:16rem}.rf-h-8{height:2rem}.rf-h-9{height:2.25rem}.rf-h-\\[400px\\]{height:400px}.rf-h-\\[calc\\(100vh-52px\\)\\]{height:calc(100vh - 52px)}.rf-h-\\[var\\(--radix-select-trigger-height\\)\\]{height:var(--radix-select-trigger-height)}.rf-h-auto{height:auto}.rf-h-fit{height:-moz-fit-content;height:fit-content}.rf-h-full{height:100%}.rf-h-px{height:1px}.rf-h-screen{height:100vh}.\\!rf-max-h-\\[40vh\\]{max-height:40vh!important}.rf-max-h-32{max-height:8rem}.rf-max-h-96{max-height:24rem}.rf-max-h-\\[300px\\]{max-height:300px}.rf-max-h-\\[500px\\]{max-height:500px}.rf-max-h-\\[90vh\\]{max-height:90vh}.rf-max-h-full{max-height:100%}.rf-min-h-0{min-height:0}.rf-min-h-\\[200px\\]{min-height:200px}.rf-min-h-\\[300px\\]{min-height:300px}.rf-min-h-\\[620px\\]{min-height:620px}.rf-min-h-\\[calc\\(100vh-240px\\)\\]{min-height:calc(100vh - 240px)}.\\!rf-w-2{width:.5rem!important}.\\!rf-w-2\\.5{width:.625rem!important}.rf-w-1{width:.25rem}.rf-w-1\\/2{width:50%}.rf-w-11{width:2.75rem}.rf-w-11\\/12{width:91.666667%}.rf-w-12{width:3rem}.rf-w-16{width:4rem}.rf-w-2{width:.5rem}.rf-w-2\\.5{width:.625rem}.rf-w-20{width:5rem}.rf-w-28{width:7rem}.rf-w-3{width:.75rem}.rf-w-3\\.5{width:.875rem}.rf-w-32{width:8rem}.rf-w-4{width:1rem}.rf-w-48{width:12rem}.rf-w-5{width:1.25rem}.rf-w-6{width:1.5rem}.rf-w-64{width:16rem}.rf-w-72{width:18rem}.rf-w-8{width:2rem}.rf-w-9{width:2.25rem}.rf-w-96{width:24rem}.rf-w-\\[95\\%\\]{width:95%}.rf-w-fit{width:-moz-fit-content;width:fit-content}.rf-w-full{width:100%}.rf-w-screen{width:100vw}.rf-min-w-0{min-width:0}.rf-min-w-10{min-width:2.5rem}.rf-min-w-16{min-width:4rem}.rf-min-w-\\[148px\\]{min-width:148px}.rf-min-w-\\[8rem\\]{min-width:8rem}.rf-min-w-\\[var\\(--radix-select-trigger-width\\)\\]{min-width:var(--radix-select-trigger-width)}.\\!rf-max-w-\\[660px\\]{max-width:660px!important}.rf-max-w-2xl{max-width:42rem}.rf-max-w-3xl{max-width:48rem}.rf-max-w-4xl{max-width:56rem}.rf-max-w-5xl{max-width:64rem}.rf-max-w-full{max-width:100%}.rf-max-w-lg{max-width:32rem}.rf-max-w-md{max-width:28rem}.rf-max-w-none{max-width:none}.rf-max-w-xl{max-width:36rem}.rf-flex-1{flex:1 1 0%}.rf-flex-shrink-0,.rf-shrink-0{flex-shrink:0}.rf-flex-grow{flex-grow:1}.rf-table-auto{table-layout:auto}.rf-origin-\\[--radix-popover-content-transform-origin\\]{transform-origin:var(--radix-popover-content-transform-origin)}.-rf-translate-x-1{--tw-translate-x:-0.25rem}.-rf-translate-x-1,.-rf-translate-x-1\\/2{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-rf-translate-x-1\\/2{--tw-translate-x:-50%}.-rf-translate-y-1{--tw-translate-y:-0.25rem}.-rf-translate-y-1,.rf--translate-x-1{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf--translate-x-1{--tw-translate-x:-0.25rem}.rf--translate-x-1\\/2{--tw-translate-x:-50%}.rf--translate-x-1\\/2,.rf--translate-y-1{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf--translate-y-1{--tw-translate-y:-0.25rem}.rf-translate-x-\\[-50\\%\\]{--tw-translate-x:-50%}.rf-translate-x-\\[-50\\%\\],.rf-translate-y-\\[-50\\%\\]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rf-translate-y-\\[-50\\%\\]{--tw-translate-y:-50%}.rf-transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes rf-pulse{50%{opacity:.5}}.rf-animate-pulse{animation:rf-pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes rf-spin{to{transform:rotate(1turn)}}.rf-animate-spin{animation:rf-spin 1s linear infinite}.rf-cursor-default{cursor:default}.rf-cursor-not-allowed{cursor:not-allowed}.rf-cursor-pointer{cursor:pointer}.rf-select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.rf-grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.rf-flex-row{flex-direction:row}.rf-flex-col{flex-direction:column}.rf-flex-col-reverse{flex-direction:column-reverse}.rf-flex-wrap{flex-wrap:wrap}.rf-place-items-center{place-items:center}.rf-items-start{align-items:flex-start}.rf-items-end{align-items:flex-end}.rf-items-center{align-items:center}.rf-items-stretch{align-items:stretch}.rf-justify-end{justify-content:flex-end}.rf-justify-center{justify-content:center}.rf-justify-between{justify-content:space-between}.rf-gap-0{gap:0}.rf-gap-1{gap:.25rem}.rf-gap-2{gap:.5rem}.rf-gap-3{gap:.75rem}.rf-gap-4{gap:1rem}.rf-gap-5{gap:1.25rem}.rf-gap-6{gap:1.5rem}.rf-gap-8{gap:2rem}.rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.rf-space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.5rem*var(--tw-space-y-reverse));margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.75rem*var(--tw-space-y-reverse));margin-top:calc(.75rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1rem*var(--tw-space-y-reverse));margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)))}.rf-space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(1.5rem*var(--tw-space-y-reverse));margin-top:calc(1.5rem*(1 - var(--tw-space-y-reverse)))}.rf-divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse:0;border-bottom-width:calc(1px*var(--tw-divide-y-reverse));border-top-width:calc(1px*(1 - var(--tw-divide-y-reverse)))}.rf-overflow-auto{overflow:auto}.rf-overflow-hidden{overflow:hidden}.rf-overflow-visible{overflow:visible}.rf-overflow-x-auto{overflow-x:auto}.\\!rf-overflow-y-auto{overflow-y:auto!important}.rf-overflow-y-auto{overflow-y:auto}.rf-overflow-x-hidden{overflow-x:hidden}.rf-overflow-x-clip{overflow-x:clip}.rf-truncate{overflow:hidden;text-overflow:ellipsis}.rf-truncate,.rf-whitespace-nowrap{white-space:nowrap}.rf-whitespace-pre-wrap{white-space:pre-wrap}.rf-break-words{overflow-wrap:break-word}.rf-rounded{border-radius:.25rem}.rf-rounded-2xl{border-radius:1rem}.rf-rounded-full{border-radius:9999px}.rf-rounded-lg{border-radius:var(--radius)}.rf-rounded-md{border-radius:calc(var(--radius) - 2px)}.rf-rounded-sm{border-radius:calc(var(--radius) - 4px)}.rf-rounded-xl{border-radius:.75rem}.rf-border{border-width:1px}.rf-border-2{border-width:2px}.rf-border-b{border-bottom-width:1px}.rf-border-t{border-top-width:1px}.rf-border-blue-200{--tw-border-opacity:1;border-color:rgb(191 219 254/var(--tw-border-opacity,1))}.rf-border-blue-400{--tw-border-opacity:1;border-color:rgb(96 165 250/var(--tw-border-opacity,1))}.rf-border-blue-500{--tw-border-opacity:1;border-color:rgb(59 130 246/var(--tw-border-opacity,1))}.rf-border-blue-600{--tw-border-opacity:1;border-color:rgb(37 99 235/var(--tw-border-opacity,1))}.rf-border-gray-200{--tw-border-opacity:1;border-color:rgb(229 231 235/var(--tw-border-opacity,1))}.rf-border-gray-300{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity,1))}.rf-border-green-200{--tw-border-opacity:1;border-color:rgb(187 247 208/var(--tw-border-opacity,1))}.rf-border-input{border-color:hsl(var(--input))}.rf-border-neutral-200{--tw-border-opacity:1;border-color:rgb(229 229 229/var(--tw-border-opacity,1))}.rf-border-orange-200{--tw-border-opacity:1;border-color:rgb(254 215 170/var(--tw-border-opacity,1))}.rf-border-primary{border-color:hsl(var(--primary))}.rf-border-red-200{--tw-border-opacity:1;border-color:rgb(254 202 202/var(--tw-border-opacity,1))}.rf-border-red-400{--tw-border-opacity:1;border-color:rgb(248 113 113/var(--tw-border-opacity,1))}.rf-border-red-500{--tw-border-opacity:1;border-color:rgb(239 68 68/var(--tw-border-opacity,1))}.rf-border-zinc-200{--tw-border-opacity:1;border-color:rgb(228 228 231/var(--tw-border-opacity,1))}.rf-border-zinc-900{--tw-border-opacity:1;border-color:rgb(24 24 27/var(--tw-border-opacity,1))}.rf-bg-background{background-color:hsl(var(--background))}.rf-bg-black{--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity,1))}.rf-bg-black\\/80{background-color:rgba(0,0,0,.8)}.rf-bg-blue-100{--tw-bg-opacity:1;background-color:rgb(219 234 254/var(--tw-bg-opacity,1))}.rf-bg-blue-50{--tw-bg-opacity:1;background-color:rgb(239 246 255/var(--tw-bg-opacity,1))}.rf-bg-blue-500{--tw-bg-opacity:1;background-color:rgb(59 130 246/var(--tw-bg-opacity,1))}.rf-bg-blue-600{--tw-bg-opacity:1;background-color:rgb(37 99 235/var(--tw-bg-opacity,1))}.rf-bg-gray-100{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.rf-bg-gray-200{--tw-bg-opacity:1;background-color:rgb(229 231 235/var(--tw-bg-opacity,1))}.rf-bg-gray-300{--tw-bg-opacity:1;background-color:rgb(209 213 219/var(--tw-bg-opacity,1))}.rf-bg-gray-400{--tw-bg-opacity:1;background-color:rgb(156 163 175/var(--tw-bg-opacity,1))}.rf-bg-gray-50{--tw-bg-opacity:1;background-color:rgb(249 250 251/var(--tw-bg-opacity,1))}.rf-bg-gray-500{--tw-bg-opacity:1;background-color:rgb(107 114 128/var(--tw-bg-opacity,1))}.rf-bg-gray-700{--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity,1))}.rf-bg-gray-800{--tw-bg-opacity:1;background-color:rgb(31 41 55/var(--tw-bg-opacity,1))}.rf-bg-gray-900{--tw-bg-opacity:1;background-color:rgb(17 24 39/var(--tw-bg-opacity,1))}.rf-bg-green-100{--tw-bg-opacity:1;background-color:rgb(220 252 231/var(--tw-bg-opacity,1))}.rf-bg-green-50{--tw-bg-opacity:1;background-color:rgb(240 253 244/var(--tw-bg-opacity,1))}.rf-bg-muted{background-color:hsl(var(--muted))}.rf-bg-neutral-100{--tw-bg-opacity:1;background-color:rgb(245 245 245/var(--tw-bg-opacity,1))}.rf-bg-neutral-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-neutral-800{--tw-bg-opacity:1;background-color:rgb(38 38 38/var(--tw-bg-opacity,1))}.rf-bg-neutral-900{--tw-bg-opacity:1;background-color:rgb(23 23 23/var(--tw-bg-opacity,1))}.rf-bg-orange-400{--tw-bg-opacity:1;background-color:rgb(251 146 60/var(--tw-bg-opacity,1))}.rf-bg-orange-50{--tw-bg-opacity:1;background-color:rgb(255 247 237/var(--tw-bg-opacity,1))}.rf-bg-popover{background-color:hsl(var(--popover))}.rf-bg-red-100{--tw-bg-opacity:1;background-color:rgb(254 226 226/var(--tw-bg-opacity,1))}.rf-bg-red-50{--tw-bg-opacity:1;background-color:rgb(254 242 242/var(--tw-bg-opacity,1))}.rf-bg-red-500{--tw-bg-opacity:1;background-color:rgb(239 68 68/var(--tw-bg-opacity,1))}.rf-bg-red-900{--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.rf-bg-transparent{background-color:transparent}.rf-bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.rf-bg-yellow-100{--tw-bg-opacity:1;background-color:rgb(254 249 195/var(--tw-bg-opacity,1))}.rf-bg-zinc-100{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.rf-bg-zinc-200{--tw-bg-opacity:1;background-color:rgb(228 228 231/var(--tw-bg-opacity,1))}.rf-bg-zinc-50{--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.rf-bg-zinc-800{--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.rf-bg-zinc-900{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.rf-bg-opacity-50{--tw-bg-opacity:0.5}.rf-fill-current{fill:currentColor}.rf-object-contain{-o-object-fit:contain;object-fit:contain}.rf-object-cover{-o-object-fit:cover;object-fit:cover}.\\!rf-p-0{padding:0!important}.rf-p-0{padding:0}.rf-p-1{padding:.25rem}.rf-p-2{padding:.5rem}.rf-p-3{padding:.75rem}.rf-p-4{padding:1rem}.rf-p-5{padding:1.25rem}.rf-p-6{padding:1.5rem}.rf-p-8{padding:2rem}.rf-px-1{padding-left:.25rem;padding-right:.25rem}.rf-px-2{padding-left:.5rem;padding-right:.5rem}.rf-px-3{padding-left:.75rem;padding-right:.75rem}.rf-px-4{padding-left:1rem;padding-right:1rem}.rf-px-6{padding-left:1.5rem;padding-right:1.5rem}.rf-px-8{padding-left:2rem;padding-right:2rem}.rf-py-0{padding-bottom:0;padding-top:0}.rf-py-0\\.5{padding-bottom:.125rem;padding-top:.125rem}.rf-py-1{padding-bottom:.25rem;padding-top:.25rem}.rf-py-1\\.5{padding-bottom:.375rem;padding-top:.375rem}.rf-py-10{padding-bottom:2.5rem;padding-top:2.5rem}.rf-py-12{padding-bottom:3rem;padding-top:3rem}.rf-py-2{padding-bottom:.5rem;padding-top:.5rem}.rf-py-3{padding-bottom:.75rem;padding-top:.75rem}.rf-py-4{padding-bottom:1rem;padding-top:1rem}.rf-py-6{padding-bottom:1.5rem;padding-top:1.5rem}.rf-py-8{padding-bottom:2rem;padding-top:2rem}.rf-pb-0{padding-bottom:0}.rf-pb-2{padding-bottom:.5rem}.rf-pb-3{padding-bottom:.75rem}.rf-pb-4{padding-bottom:1rem}.rf-pl-2{padding-left:.5rem}.rf-pl-4{padding-left:1rem}.rf-pl-8{padding-left:2rem}.rf-pr-2{padding-right:.5rem}.rf-pt-0{padding-top:0}.rf-pt-2{padding-top:.5rem}.rf-pt-4{padding-top:1rem}.rf-text-left{text-align:left}.rf-text-center{text-align:center}.rf-text-right{text-align:right}.rf-font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.rf-text-2xl{font-size:1.5rem;line-height:2rem}.rf-text-3xl{font-size:1.875rem;line-height:2.25rem}.rf-text-\\[8px\\]{font-size:8px}.rf-text-base{font-size:1rem;line-height:1.5rem}.rf-text-lg{font-size:1.125rem;line-height:1.75rem}.rf-text-sm{font-size:.875rem;line-height:1.25rem}.rf-text-xl{font-size:1.25rem;line-height:1.75rem}.rf-text-xs{font-size:.75rem;line-height:1rem}.\\!rf-font-normal{font-weight:400!important}.rf-font-bold{font-weight:700}.rf-font-medium{font-weight:500}.rf-font-semibold{font-weight:600}.rf-uppercase{text-transform:uppercase}.rf-capitalize{text-transform:capitalize}.rf-tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.rf-leading-5{line-height:1.25rem}.rf-leading-none{line-height:1}.rf-leading-relaxed{line-height:1.625}.rf-leading-tight{line-height:1.25}.rf-tracking-wide{letter-spacing:.025em}.rf-tracking-widest{letter-spacing:.1em}.rf-text-black{--tw-text-opacity:1;color:rgb(0 0 0/var(--tw-text-opacity,1))}.rf-text-blue-500{--tw-text-opacity:1;color:rgb(59 130 246/var(--tw-text-opacity,1))}.rf-text-blue-600{--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity,1))}.rf-text-blue-700{--tw-text-opacity:1;color:rgb(29 78 216/var(--tw-text-opacity,1))}.rf-text-blue-800{--tw-text-opacity:1;color:rgb(30 64 175/var(--tw-text-opacity,1))}.rf-text-blue-900{--tw-text-opacity:1;color:rgb(30 58 138/var(--tw-text-opacity,1))}.rf-text-current{color:currentColor}.rf-text-gray-400{--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity,1))}.rf-text-gray-500{--tw-text-opacity:1;color:rgb(107 114 128/var(--tw-text-opacity,1))}.rf-text-gray-600{--tw-text-opacity:1;color:rgb(75 85 99/var(--tw-text-opacity,1))}.rf-text-gray-700{--tw-text-opacity:1;color:rgb(55 65 81/var(--tw-text-opacity,1))}.rf-text-gray-800{--tw-text-opacity:1;color:rgb(31 41 55/var(--tw-text-opacity,1))}.rf-text-gray-900{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.rf-text-green-500{--tw-text-opacity:1;color:rgb(34 197 94/var(--tw-text-opacity,1))}.rf-text-green-600{--tw-text-opacity:1;color:rgb(22 163 74/var(--tw-text-opacity,1))}.rf-text-green-700{--tw-text-opacity:1;color:rgb(21 128 61/var(--tw-text-opacity,1))}.rf-text-green-800{--tw-text-opacity:1;color:rgb(22 101 52/var(--tw-text-opacity,1))}.rf-text-green-900{--tw-text-opacity:1;color:rgb(20 83 45/var(--tw-text-opacity,1))}.rf-text-muted-foreground{color:hsl(var(--muted-foreground))}.rf-text-neutral-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-neutral-500{--tw-text-opacity:1;color:rgb(115 115 115/var(--tw-text-opacity,1))}.rf-text-neutral-900{--tw-text-opacity:1;color:rgb(23 23 23/var(--tw-text-opacity,1))}.rf-text-neutral-950{--tw-text-opacity:1;color:rgb(10 10 10/var(--tw-text-opacity,1))}.rf-text-orange-500{--tw-text-opacity:1;color:rgb(249 115 22/var(--tw-text-opacity,1))}.rf-text-orange-600{--tw-text-opacity:1;color:rgb(234 88 12/var(--tw-text-opacity,1))}.rf-text-orange-800{--tw-text-opacity:1;color:rgb(154 52 18/var(--tw-text-opacity,1))}.rf-text-popover-foreground{color:hsl(var(--popover-foreground))}.rf-text-red-200{--tw-text-opacity:1;color:rgb(254 202 202/var(--tw-text-opacity,1))}.rf-text-red-300{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.rf-text-red-400{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.rf-text-red-500{--tw-text-opacity:1;color:rgb(239 68 68/var(--tw-text-opacity,1))}.rf-text-red-600{--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity,1))}.rf-text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.rf-text-red-800{--tw-text-opacity:1;color:rgb(153 27 27/var(--tw-text-opacity,1))}.rf-text-red-900{--tw-text-opacity:1;color:rgb(127 29 29/var(--tw-text-opacity,1))}.rf-text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.rf-text-yellow-400{--tw-text-opacity:1;color:rgb(250 204 21/var(--tw-text-opacity,1))}.rf-text-yellow-500{--tw-text-opacity:1;color:rgb(234 179 8/var(--tw-text-opacity,1))}.rf-text-yellow-900{--tw-text-opacity:1;color:rgb(113 63 18/var(--tw-text-opacity,1))}.rf-text-zinc-200{--tw-text-opacity:1;color:rgb(228 228 231/var(--tw-text-opacity,1))}.rf-text-zinc-300{--tw-text-opacity:1;color:rgb(212 212 216/var(--tw-text-opacity,1))}.rf-text-zinc-400{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.rf-text-zinc-50{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.rf-text-zinc-500{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.rf-text-zinc-900{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.rf-text-zinc-950{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.rf-underline{text-decoration-line:underline}.rf-line-through{text-decoration-line:line-through}.rf-underline-offset-4{text-underline-offset:4px}.rf-opacity-0{opacity:0}.rf-opacity-100{opacity:1}.rf-opacity-25{opacity:.25}.rf-opacity-30{opacity:.3}.rf-opacity-50{opacity:.5}.rf-opacity-60{opacity:.6}.rf-opacity-75{opacity:.75}.rf-shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color)}.rf-shadow,.rf-shadow-lg{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-lg{--tw-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1);--tw-shadow-colored:0 10px 15px -3px var(--tw-shadow-color),0 4px 6px -4px var(--tw-shadow-color)}.rf-shadow-md{--tw-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color)}.rf-shadow-md,.rf-shadow-sm{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.rf-shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color)}.rf-outline-none{outline:2px solid transparent;outline-offset:2px}.rf-ring-2{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.rf-ring-blue-500{--tw-ring-opacity:1;--tw-ring-color:rgb(59 130 246/var(--tw-ring-opacity,1))}.rf-ring-primary{--tw-ring-color:hsl(var(--primary))}.rf-ring-offset-background{--tw-ring-offset-color:hsl(var(--background))}.rf-ring-offset-white{--tw-ring-offset-color:#fff}.rf-transition{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-colors{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-transition-opacity{transition-duration:.15s;transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1)}.rf-duration-200{transition-duration:.2s}.rf-ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}@keyframes enter{0%{opacity:var(--tw-enter-opacity,1);transform:translate3d(var(--tw-enter-translate-x,0),var(--tw-enter-translate-y,0),0) scale3d(var(--tw-enter-scale,1),var(--tw-enter-scale,1),var(--tw-enter-scale,1)) rotate(var(--tw-enter-rotate,0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity,1);transform:translate3d(var(--tw-exit-translate-x,0),var(--tw-exit-translate-y,0),0) scale3d(var(--tw-exit-scale,1),var(--tw-exit-scale,1),var(--tw-exit-scale,1)) rotate(var(--tw-exit-rotate,0))}}.rf-slide-in-from-left-1{--tw-enter-translate-x:-0.25rem}.rf-slide-out-to-left-1{--tw-exit-translate-x:-0.25rem}.rf-duration-200{animation-duration:.2s}.rf-ease-in-out{animation-timing-function:cubic-bezier(.4,0,.2,1)}.file\\:rf-border-0::file-selector-button{border-width:0}.file\\:rf-bg-transparent::file-selector-button{background-color:transparent}.file\\:rf-text-sm::file-selector-button{font-size:.875rem;line-height:1.25rem}.file\\:rf-font-medium::file-selector-button{font-weight:500}.placeholder\\:rf-text-zinc-500::-moz-placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.placeholder\\:rf-text-zinc-500::placeholder{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.hover\\:rf-border-blue-300:hover{--tw-border-opacity:1;border-color:rgb(147 197 253/var(--tw-border-opacity,1))}.hover\\:\\!rf-bg-transparent:hover{background-color:transparent!important}.hover\\:rf-bg-blue-700:hover{--tw-bg-opacity:1;background-color:rgb(29 78 216/var(--tw-bg-opacity,1))}.hover\\:rf-bg-red-500\\/90:hover{background-color:rgba(239,68,68,.9)}.hover\\:rf-bg-zinc-100:hover{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.hover\\:rf-bg-zinc-100\\/80:hover{background-color:hsla(240,5%,96%,.8)}.hover\\:rf-bg-zinc-900\\/90:hover{background-color:rgba(24,24,27,.9)}.hover\\:rf-text-red-400:hover{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.hover\\:rf-text-zinc-900:hover{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.hover\\:rf-underline:hover{text-decoration-line:underline}.focus\\:rf-bg-gray-100:focus{--tw-bg-opacity:1;background-color:rgb(243 244 246/var(--tw-bg-opacity,1))}.focus\\:rf-bg-zinc-100:focus{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.focus\\:rf-text-gray-900:focus{--tw-text-opacity:1;color:rgb(17 24 39/var(--tw-text-opacity,1))}.focus\\:rf-text-zinc-900:focus{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.focus\\:rf-outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\\:rf-ring-2:focus{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus\\:rf-ring-ring:focus{--tw-ring-color:hsl(var(--ring))}.focus\\:rf-ring-offset-2:focus{--tw-ring-offset-width:2px}.focus-visible\\:rf-outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px}.focus-visible\\:rf-ring-1:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-2:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.focus-visible\\:rf-ring-zinc-950:focus-visible{--tw-ring-opacity:1;--tw-ring-color:rgb(9 9 11/var(--tw-ring-opacity,1))}.focus-visible\\:rf-ring-offset-2:focus-visible{--tw-ring-offset-width:2px}.disabled\\:rf-pointer-events-none:disabled{pointer-events:none}.disabled\\:rf-cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:rf-opacity-50:disabled{opacity:.5}.rf-group\\/bar:hover .group-hover\\/bar\\:rf-opacity-100{opacity:1}.data-\\[disabled\\=true\\]\\:rf-pointer-events-none[data-disabled=true],.data-\\[disabled\\]\\:rf-pointer-events-none[data-disabled]{pointer-events:none}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom]{--tw-translate-y:0.25rem}.data-\\[side\\=bottom\\]\\:rf-translate-y-1[data-side=bottom],.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=left\\]\\:-rf-translate-x-1[data-side=left]{--tw-translate-x:-0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right]{--tw-translate-x:0.25rem}.data-\\[side\\=right\\]\\:rf-translate-x-1[data-side=right],.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.data-\\[side\\=top\\]\\:-rf-translate-y-1[data-side=top]{--tw-translate-y:-0.25rem}.data-\\[selected\\=true\\]\\:rf-bg-zinc-100[data-selected=true]{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.data-\\[state\\=active\\]\\:rf-bg-white[data-state=active]{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.data-\\[state\\=checked\\]\\:rf-bg-zinc-900[data-state=checked]{--tw-bg-opacity:1;background-color:rgb(24 24 27/var(--tw-bg-opacity,1))}.data-\\[state\\=open\\]\\:rf-bg-zinc-100[data-state=open]{--tw-bg-opacity:1;background-color:rgb(244 244 245/var(--tw-bg-opacity,1))}.data-\\[selected\\=true\\]\\:rf-text-zinc-900[data-selected=true]{--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.data-\\[state\\=active\\]\\:rf-text-zinc-950[data-state=active]{--tw-text-opacity:1;color:rgb(9 9 11/var(--tw-text-opacity,1))}.data-\\[state\\=checked\\]\\:rf-text-zinc-50[data-state=checked]{--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.data-\\[disabled\\=true\\]\\:rf-opacity-50[data-disabled=true],.data-\\[disabled\\]\\:rf-opacity-50[data-disabled]{opacity:.5}.data-\\[state\\=active\\]\\:rf-shadow[data-state=active]{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.data-\\[state\\=open\\]\\:rf-animate-in[data-state=open]{animation-duration:.15s;animation-name:enter;--tw-enter-opacity:initial;--tw-enter-scale:initial;--tw-enter-rotate:initial;--tw-enter-translate-x:initial;--tw-enter-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-animate-out[data-state=closed]{animation-duration:.15s;animation-name:exit;--tw-exit-opacity:initial;--tw-exit-scale:initial;--tw-exit-rotate:initial;--tw-exit-translate-x:initial;--tw-exit-translate-y:initial}.data-\\[state\\=closed\\]\\:rf-fade-out-0[data-state=closed]{--tw-exit-opacity:0}.data-\\[state\\=open\\]\\:rf-fade-in-0[data-state=open]{--tw-enter-opacity:0}.data-\\[state\\=closed\\]\\:rf-zoom-out-95[data-state=closed]{--tw-exit-scale:.95}.data-\\[state\\=open\\]\\:rf-zoom-in-95[data-state=open]{--tw-enter-scale:.95}.data-\\[side\\=bottom\\]\\:rf-slide-in-from-top-2[data-side=bottom]{--tw-enter-translate-y:-0.5rem}.data-\\[side\\=left\\]\\:rf-slide-in-from-right-2[data-side=left]{--tw-enter-translate-x:0.5rem}.data-\\[side\\=right\\]\\:rf-slide-in-from-left-2[data-side=right]{--tw-enter-translate-x:-0.5rem}.data-\\[side\\=top\\]\\:rf-slide-in-from-bottom-2[data-side=top]{--tw-enter-translate-y:0.5rem}.data-\\[state\\=closed\\]\\:rf-slide-out-to-left-1\\/2[data-state=closed]{--tw-exit-translate-x:-50%}.data-\\[state\\=closed\\]\\:rf-slide-out-to-top-\\[48\\%\\][data-state=closed]{--tw-exit-translate-y:-48%}.data-\\[state\\=open\\]\\:rf-slide-in-from-left-1\\/2[data-state=open]{--tw-enter-translate-x:-50%}.data-\\[state\\=open\\]\\:rf-slide-in-from-top-\\[48\\%\\][data-state=open]{--tw-enter-translate-y:-48%}.dark\\:rf-border-zinc-50:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(250 250 250/var(--tw-border-opacity,1))}.dark\\:rf-border-zinc-800:is(.rf-dark *){--tw-border-opacity:1;border-color:rgb(39 39 42/var(--tw-border-opacity,1))}.dark\\:rf-bg-red-900:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(127 29 29/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-50:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-800:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:rf-bg-zinc-950:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:rf-text-zinc-400:is(.rf-dark *){--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-50:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:rf-text-zinc-900:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::-moz-placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-placeholder-zinc-400:is(.rf-dark *)::placeholder{--tw-placeholder-opacity:1;color:rgb(161 161 170/var(--tw-placeholder-opacity,1))}.dark\\:rf-ring-offset-zinc-950:is(.rf-dark *){--tw-ring-offset-color:#09090b}.dark\\:placeholder\\:rf-text-zinc-400:is(.rf-dark *)::-moz-placeholder{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:placeholder\\:rf-text-zinc-400:is(.rf-dark *)::placeholder{--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.dark\\:hover\\:rf-bg-red-900\\/90:hover:is(.rf-dark *){background-color:rgba(127,29,29,.9)}.dark\\:hover\\:rf-bg-zinc-50\\/90:hover:is(.rf-dark *){background-color:hsla(0,0%,98%,.9)}.dark\\:hover\\:rf-bg-zinc-800:hover:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:hover\\:rf-bg-zinc-800\\/80:hover:is(.rf-dark *){background-color:rgba(39,39,42,.8)}.dark\\:hover\\:rf-text-zinc-50:hover:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus\\:rf-bg-zinc-800:focus:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:focus\\:rf-text-zinc-50:focus:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:focus-visible\\:rf-ring-zinc-300:focus-visible:is(.rf-dark *){--tw-ring-opacity:1;--tw-ring-color:rgb(212 212 216/var(--tw-ring-opacity,1))}.dark\\:data-\\[selected\\=true\\]\\:rf-bg-zinc-800[data-selected=true]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-bg-zinc-950[data-state=active]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(9 9 11/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-bg-zinc-50[data-state=checked]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(250 250 250/var(--tw-bg-opacity,1))}.dark\\:data-\\[state\\=open\\]\\:rf-bg-zinc-800[data-state=open]:is(.rf-dark *){--tw-bg-opacity:1;background-color:rgb(39 39 42/var(--tw-bg-opacity,1))}.dark\\:data-\\[selected\\=true\\]\\:rf-text-zinc-50[data-selected=true]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:data-\\[state\\=active\\]\\:rf-text-zinc-50[data-state=active]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(250 250 250/var(--tw-text-opacity,1))}.dark\\:data-\\[state\\=checked\\]\\:rf-text-zinc-900[data-state=checked]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(24 24 27/var(--tw-text-opacity,1))}@media (min-width:640px){.sm\\:rf-order-1{order:1}.sm\\:rf-order-2{order:2}.sm\\:rf-mt-0{margin-top:0}.sm\\:rf-inline{display:inline}.sm\\:rf-hidden{display:none}.sm\\:rf-w-auto{width:auto}.sm\\:rf-flex-row{flex-direction:row}.sm\\:rf-items-center{align-items:center}.sm\\:rf-justify-end{justify-content:flex-end}.sm\\:rf-gap-3{gap:.75rem}.sm\\:rf-space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-left:calc(.5rem*(1 - var(--tw-space-x-reverse)));margin-right:calc(.5rem*var(--tw-space-x-reverse))}.sm\\:rf-rounded-lg{border-radius:var(--radius)}.sm\\:rf-px-4{padding-left:1rem;padding-right:1rem}.sm\\:rf-text-left{text-align:left}.sm\\:rf-text-sm{font-size:.875rem;line-height:1.25rem}.sm\\:rf-text-xl{font-size:1.25rem;line-height:1.75rem}}@media (min-width:768px){.md\\:rf-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}.\\[\\&\\>span\\]\\:rf-line-clamp-1>span{display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:1}.\\[\\&\\>svg\\]\\:rf-size-4>svg{height:1rem;width:1rem}.\\[\\&\\>svg\\]\\:rf-shrink-0>svg{flex-shrink:0}.\\[\\&\\>svg\\]\\:rf-text-red-300>svg{--tw-text-opacity:1;color:rgb(252 165 165/var(--tw-text-opacity,1))}.\\[\\&\\>svg\\]\\:hover\\:rf-text-red-400:hover>svg{--tw-text-opacity:1;color:rgb(248 113 113/var(--tw-text-opacity,1))}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-px-2 [cmdk-group-heading]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-py-1\\.5 [cmdk-group-heading]{padding-bottom:.375rem;padding-top:.375rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-xs [cmdk-group-heading]{font-size:.75rem;line-height:1rem}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-font-medium [cmdk-group-heading]{font-weight:500}.\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-zinc-500 [cmdk-group-heading]{--tw-text-opacity:1;color:rgb(113 113 122/var(--tw-text-opacity,1))}.dark\\:\\[\\&_\\[cmdk-group-heading\\]\\]\\:rf-text-zinc-400 [cmdk-group-heading]:is(.rf-dark *){--tw-text-opacity:1;color:rgb(161 161 170/var(--tw-text-opacity,1))}.\\[\\&_\\[cmdk-group\\]\\:not\\(\\[hidden\\]\\)_\\~\\[cmdk-group\\]\\]\\:rf-pt-0 [cmdk-group]:not([hidden])~[cmdk-group]{padding-top:0}.\\[\\&_\\[cmdk-group\\]\\]\\:rf-px-2 [cmdk-group]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-input-wrapper\\]_svg\\]\\:rf-h-5 [cmdk-input-wrapper] svg{height:1.25rem}.\\[\\&_\\[cmdk-input-wrapper\\]_svg\\]\\:rf-w-5 [cmdk-input-wrapper] svg{width:1.25rem}.\\[\\&_\\[cmdk-input\\]\\]\\:rf-h-12 [cmdk-input]{height:3rem}.\\[\\&_\\[cmdk-item\\]\\]\\:rf-px-2 [cmdk-item]{padding-left:.5rem;padding-right:.5rem}.\\[\\&_\\[cmdk-item\\]\\]\\:rf-py-3 [cmdk-item]{padding-bottom:.75rem;padding-top:.75rem}.\\[\\&_\\[cmdk-item\\]_svg\\]\\:rf-h-5 [cmdk-item] svg{height:1.25rem}.\\[\\&_\\[cmdk-item\\]_svg\\]\\:rf-w-5 [cmdk-item] svg{width:1.25rem}.\\[\\&_svg\\]\\:rf-pointer-events-none svg{pointer-events:none}.\\[\\&_svg\\]\\:rf-size-4 svg{height:1rem;width:1rem}.\\[\\&_svg\\]\\:rf-shrink-0 svg{flex-shrink:0}',$Xt=()=>{pt.useEffect(()=>{if(document.querySelector('style[data-styles="tscircuit-runframe"]'))return;const e=document.createElement("style");e.setAttribute("data-styles","tscircuit-runframe"),e.textContent=XXt,document.head.appendChild(e)},[])},e$t=r=>{pt.useEffect(()=>(r?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[r])},bHe=r=>`hsl(${ub.indexOf(r)*137.5%360}, 70%, 50%)`,t$t=({phaseTimings:r})=>{if(!r)return null;const e=Object.values(r).reduce((t,n)=>t+n,0);return ut.jsxs("div",{className:"rf-space-y-2 rf-w-full rf-px-4",children:[ut.jsx("div",{className:"rf-relative rf-h-8 rf-flex rf-rounded-sm",children:ub.map(t=>{const n=r[t]||0,i=n/e*100;return ut.jsx("div",{className:"rf-group/bar rf-relative rf-overflow-visible",style:{width:`${i}%`,backgroundColor:bHe(t)},children:ut.jsxs("div",{className:"rf-opacity-0 group-hover/bar:rf-opacity-100 rf-transition-opacity rf-absolute rf-bottom-full rf-left-1/2 rf-transform -rf-translate-x-1/2 rf-mb-2 rf-px-2 rf-py-1 rf-text-xs rf-whitespace-nowrap rf-rounded rf-bg-gray-900 rf-text-white rf-pointer-events-none",children:[t,": ",n.toFixed(1),"ms"]})},t)})}),ut.jsxs("div",{className:"rf-text-xs rf-text-gray-500",children:["Total: ",e.toFixed(2),"ms"]})]})},n$t=({renderLog:r})=>{const[e,t]=pt.useState("chronological");if(!r)return ut.jsx("div",{className:"rf-p-4 rf-bg-gray-100 rf-rounded-md",children:"No render log, make sure this tab is open when you render (TODO add a rerender button here)"});const n=Object.entries((r==null?void 0:r.phaseTimings)??{});e==="chronological"?n.sort((o,a)=>ub.indexOf(o[0])-ub.indexOf(a[0])):n.sort((o,a)=>a[1]-o[1]);const i=n.reduce((o,[a,s])=>o+s,0);return ut.jsxs("div",{className:"rf-bg-white",children:[ut.jsxs("div",{className:"rf-flex rf-justify-between rf-items-center",children:[ut.jsx("div",{children:"Render Logs"}),ut.jsxs("div",{className:"rf-mb-4 rf-pr-2 rf-flex rf-text-xs rf-items-center",children:[ut.jsx("div",{className:"rf-mr-2",children:"Sort by:"}),ut.jsxs("select",{value:e,onChange:o=>t(o.target.value),className:"rf-px-2 rf-py-1 rf-border rf-rounded rf-text-xs",children:[ut.jsx("option",{value:"chronological",children:"Phase Order"}),ut.jsx("option",{value:"longest",children:"Duration"})]})]})]}),ut.jsx(t$t,{phaseTimings:r.phaseTimings}),ut.jsxs("table",{className:"rf-w-full rf-text-xs",children:[ut.jsx("thead",{children:ut.jsxs("tr",{children:[ut.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase Order"}),ut.jsx("th",{className:"rf-text-left rf-p-2",children:"Phase"}),ut.jsx("th",{className:"rf-text-left rf-p-2",children:"Duration (ms)"})]})}),ut.jsx("tbody",{children:n.map(([o,a])=>ut.jsxs("tr",{children:[ut.jsx("td",{className:"rf-p-2",children:ub.indexOf(o)}),ut.jsx("td",{className:"rf-p-2",children:o}),ut.jsx("td",{className:"rf-p-2",children:ut.jsx("div",{className:"rf-w-8",children:ut.jsx("div",{className:"rf-h-2 rf-rounded-sm",style:{backgroundColor:bHe(o),width:`${a/i*100}%`}})})}),ut.jsx("td",{className:"rf-p-2",children:ut.jsxs("div",{className:"rf-flex w-full",children:[ut.jsxs("span",{className:"rf-flex-grow",children:[a,"ms"]}),ut.jsxs("span",{className:"rf-text-gray-500 rf-pr-2",children:[(a/i*100).toFixed(1),"%"]})]})})]},o))})]})]})},r$t=({errorMessage:r,errorStack:e,circuitJsonErrors:t})=>{pt.useEffect(()=>{if(r){const n=new Error(r);e&&(n.stack=e);try{GP.captureException(n)}catch{}}},[r,e]),pt.useEffect(()=>{if(t&&t.length>0)for(const n of t){const i=new Error(n.message||"Circuit JSON Error");n.stack&&(i.stack=n.stack);try{GP.captureException(i,{error_type:n.type})}catch{}}},[t])},i$t="0.0.725",Yue={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},Vue=new Map,DO=r=>{const e=Vue.get(r);return e?Object.fromEntries(Object.entries(e.stores).map(([t,n])=>[t,n.getState()])):{}},o$t=(r,e,t)=>{if(r===void 0)return{type:"untracked",connection:e.connect(t)};const n=Vue.get(t.name);if(n)return{type:"tracked",store:r,...n};const i={connection:e.connect(t),stores:{}};return Vue.set(t.name,i),{type:"tracked",store:r,...i}},a$t=(r,e={})=>(t,n,i)=>{const{enabled:o,anonymousActionType:a,store:s,...l}=e;let c;try{c=(o??(Yue?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!c)return(Yue?"production":void 0)!=="production"&&o&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),r(t,n,i);const{connection:u,...A}=o$t(s,c,l);let d=!0;i.setState=(C,E,_)=>{const x=t(C,E);if(!d)return x;const w=_===void 0?{type:a||"anonymous"}:typeof _=="string"?{type:_}:_;return s===void 0?(u==null||u.send(w,n()),x):(u==null||u.send({...w,type:`${s}/${w.type}`},{...DO(l.name),[s]:i.getState()}),x)};const f=(...C)=>{const E=d;d=!1,t(...C),d=E},m=r(i.setState,n,i);if(A.type==="untracked"?u==null||u.init(m):(A.stores[A.store]=i,u==null||u.init(Object.fromEntries(Object.entries(A.stores).map(([C,E])=>[C,C===A.store?m:E.getState()])))),i.dispatchFromDevtools&&typeof i.dispatch=="function"){let C=!1;const E=i.dispatch;i.dispatch=(..._)=>{(Yue?"production":void 0)!=="production"&&_[0].type==="__setState"&&!C&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),C=!0),E(..._)}}return u.subscribe(C=>{var E;switch(C.type){case"ACTION":if(typeof C.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return Kue(C.payload,_=>{if(_.type==="__setState"){if(s===void 0){f(_.state);return}Object.keys(_.state).length!==1&&console.error(`
|
|
13482
13482
|
[zustand devtools middleware] Unsupported __setState action format.
|
|
13483
13483
|
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
|
|
13484
13484
|
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
|
|
13485
|
-
`);const x=_.state[s];if(x==null)return;JSON.stringify(i.getState())!==JSON.stringify(x)&&f(x);return}i.dispatchFromDevtools&&typeof i.dispatch=="function"&&i.dispatch(_)});case"DISPATCH":switch(C.payload.type){case"RESET":return f(m),s===void 0?u==null?void 0:u.init(i.getState()):u==null?void 0:u.init(DO(l.name));case"COMMIT":if(s===void 0){u==null||u.init(i.getState());return}return u==null?void 0:u.init(DO(l.name));case"ROLLBACK":return Kue(C.state,_=>{if(s===void 0){f(_),u==null||u.init(i.getState());return}f(_[s]),u==null||u.init(DO(l.name))});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return Kue(C.state,_=>{if(s===void 0){f(_);return}JSON.stringify(i.getState())!==JSON.stringify(_[s])&&f(_[s])});case"IMPORT_STATE":{const{nextLiftedState:_}=C.payload,x=(E=_.computedStates.slice(-1)[0])==null?void 0:E.state;if(!x)return;f(s===void 0?x:x[s]),u==null||u.send(null,_);return}case"PAUSE_RECORDING":return d=!d}return}}),m},Kue=(r,e)=>{let t;try{t=JSON.parse(r)}catch(n){console.error("[zustand devtools middleware] Could not parse the received json",n)}t!==void 0&&e(t)},s$t=w1t()(a$t(r=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{r({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),l$t=["assembly","bom","circuit_json","errors","render_log"],c$t=({code:r,fsMap:e,onRunClicked:t=void 0,errorMessage:n,errorStack:i,circuitJson:o,autoroutingGraphics:a,showRightHeaderContent:s=!0,showCodeTab:l=!1,codeTabContent:c,showJsonTab:u=!0,showRenderLogTab:A=!0,onActiveTabChange:d,renderLog:f,showImportAndFormatButtons:m=!0,className:C,headerClassName:E,leftHeaderContent:_,readOnly:x,isStreaming:w,autoroutingLog:P,onReportAutoroutingLog:L,isRunningCode:O,hasCodeChangedSinceLastRun:H,onEditEvent:K,editEvents:q,defaultActiveTab:Y,defaultTab:se,availableTabs:ie,autoRotate3dViewerDisabled:de,showSchematicDebugGrid:Ce=!1,showToggleFullScreen:xe=!0,defaultToFullScreen:fe=!1,activeEffectName:Ie})=>{var xt;$Xt();const ve=s$t(vt=>vt.lastRunEvalVersion),Qe=pt.useMemo(()=>o?o.filter(vt=>vt&&"error_type"in vt||vt.type.includes("error")):null,[o]),De=pt.useMemo(()=>o?o.filter(vt=>vt&&"warning_type"in vt||vt.type.includes("warning")):null,[o]);r$t({errorMessage:n,errorStack:i,circuitJsonErrors:Qe});const[Fe,Ne]=pt.useState(Y??se??(ie==null?void 0:ie[0])??"pcb"),[rt,et]=pt.useState(null),[ft,_t]=pt.useState(fe);e$t(ft);const Ft=pt.useCallback(vt=>{Ne(vt),d==null||d(vt)},[d]),Lt=()=>{_t(!ft)};pt.useEffect(()=>{n&&(Fe!=="errors"&&et(Fe),Ft("errors"))},[n]),pt.useEffect(()=>{(Fe==="code"||Fe==="errors")&&o&&!n&&Ft(rt??Y??se??(ie==null?void 0:ie[0])??"pcb")},[o]);const tt=pt.useCallback(vt=>{window.TSCIRCUIT_3D_OBJECT_REF=vt===null?void 0:vt},[]);return ut.jsx("div",{className:nI("flex flex-col relative rf-overflow-x-hidden rf-h-full",C),children:ut.jsx("div",{className:nI("rf-md:sticky rf-md:top-2 rf-h-full",ft&&"rf-fixed rf-top-0 rf-left-0 rf-w-full rf-h-full rf-bg-white rf-overflow-hidden"),children:ut.jsxs(pqe,{value:Fe,onValueChange:Ft,className:"rf-flex-grow rf-flex rf-flex-col rf-h-full",children:[ut.jsxs("div",{className:nI("rf-flex rf-items-center rf-gap-2 rf-p-2 rf-pb-0",E),children:[_,_&&ut.jsx("div",{className:"rf-flex-grow"}),!_&&O&&ut.jsx(vLe,{className:"rf-w-4 rf-h-4 rf-animate-spin"}),!_&&ut.jsx("div",{className:"rf-flex-grow"}),f&&f.progress!==1&&!n&&ut.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[Ie?ut.jsx("div",{className:"rf-text-xs rf-text-gray-500",children:Ie}):f.lastRenderEvent&&ut.jsx("div",{className:"rf-text-xs rf-text-gray-500",children:((xt=f.lastRenderEvent)==null?void 0:xt.phase)??""}),ut.jsx("div",{className:"rf-w-4 rf-h-4 rf-bg-blue-500 rf-opacity-50 rf-rounded-full rf-text-white",children:ut.jsx(vLe,{className:"rf-w-4 rf-h-4 rf-animate-spin"})}),ut.jsxs("div",{className:"rf-text-xs rf-font-bold rf-text-gray-700 rf-tabular-nums",children:[((f.progress??0)*100).toFixed(1),"%"]})]}),s&&ut.jsxs(Bpe,{children:[l&&ut.jsx(NM,{value:"code",children:"Code"}),!ie||ie.includes("pcb")?ut.jsxs(NM,{value:"pcb",className:"rf-whitespace-nowrap",children:[o&&ut.jsx("span",{className:nI("rf-inline-flex rf-items-center rf-justify-center rf-w-2 rf-h-2 rf-mr-1 rf-text-xs rf-font-bold rf-text-white rf-rounded-full",H?"rf-bg-gray-500":"rf-bg-blue-500")}),"PCB"]}):null,!ie||ie.includes("schematic")?ut.jsxs(NM,{value:"schematic",className:"rf-whitespace-nowrap",children:[o&&ut.jsx("span",{className:nI("rf-inline-flex rf-items-center rf-justify-center rf-w-2 rf-h-2 rf-mr-1 rf-text-xs rf-font-bold rf-text-white rf-rounded-full",H?"rf-bg-gray-500":"rf-bg-blue-500")}),"Schematic"]}):null,!ie||ie.includes("cad")?ut.jsxs(NM,{value:"cad",children:[o&&ut.jsx("span",{className:nI("inline-flex items-center justify-center w-2 h-2 mr-1 text-xs font-bold text-white rounded-full",H?"rf-bg-gray-500":"rf-bg-blue-500")}),"3D"]}):null,!["pcb","cad","schematic"].includes(Fe)&&ut.jsx(NM,{value:Fe,children:xpe(Fe)}),ut.jsxs(C6e,{children:[ut.jsx(E6e,{asChild:!0,children:ut.jsxs("div",{className:"rf-whitespace-nowrap rf-p-2 rf-mr-1 rf-cursor-pointer rf-relative",children:[ut.jsx(vOt,{className:"rf-w-4 rf-h-4"}),(Qe&&Qe.length>0||n)&&ut.jsx("span",{className:"rf-inline-flex rf-absolute rf-top-[6px] rf-right-[4px] rf-items-center rf-justify-center rf-w-1 rf-h-1 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-red-500 rf-rounded-full"})]})}),ut.jsxs($le,{className:"rf-*:text-xs",children:[l$t.filter(vt=>!ie||ie.includes(vt)).map(vt=>ut.jsxs(VT,{onSelect:()=>Ft(vt),children:[Fe!==vt&&ut.jsx(yLe,{className:"rf-w-3 rf-h-3 rf-opacity-30"}),Fe===vt&&ut.jsx(gLe,{className:"rf-w-3 rf-h-3"}),ut.jsx("div",{className:"rf-pr-2",children:xpe(vt)}),vt==="errors"&&(Qe&&Qe.length>0||n)&&ut.jsx("span",{className:"rf-inline-flex rf-items-center rf-justify-center rf-w-3 rf-h-3 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-red-500 rf-rounded-full",children:n?1:Qe==null?void 0:Qe.length})]},vt)),ut.jsx(VT,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:ut.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/runframe@",i$t.split(".").map((vt,Ht)=>Ht===2?parseInt(vt)+1:vt).join(".")]})}),ve&&ut.jsx(VT,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:ut.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/eval@",ve]})})]})]})]}),xe&&ut.jsx(ZQ,{onClick:Lt,variant:"ghost",children:ft?ut.jsx(EOt,{size:16}):ut.jsx(IOt,{size:16})})]}),l&&ut.jsx(rS,{value:"code",className:"rf-flex-grow rf-overflow-hidden",children:ut.jsx("div",{className:"rf-h-full",children:c})}),(!ie||ie.includes("pcb"))&&ut.jsx(rS,{value:"pcb",children:ut.jsx("div",{className:nI("rf-overflow-hidden",ft?"rf-h-[calc(100vh-52px)]":"rf-h-full"),children:ut.jsx(_R,{fallbackRender:({error:vt})=>ut.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:ut.jsxs("div",{className:"rf-p-4",children:[ut.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading PCB viewer"}),ut.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:(vt==null?void 0:vt.message)||"An unknown error occurred"})]})}),children:o?ut.jsx(ZXt,{focusOnHover:!1,circuitJson:o,debugGraphics:a,containerClassName:nI("rf-h-full rf-w-full",ft?"rf-min-h-[calc(100vh-240px)]":"rf-min-h-[620px]"),onEditEventsChanged:vt=>{K&&vt.forEach(Ht=>K(Ht))}}):ut.jsx(X9,{onRunClicked:t})})})}),(!ie||ie.includes("assembly"))&&ut.jsx(rS,{value:"assembly",children:ut.jsx("div",{className:nI("rf-overflow-auto",ft?"rf-h-screen":"rf-h-full rf-min-h-[620px]"),children:ut.jsx(_R,{fallback:ut.jsx("div",{children:"Error loading Assembly"}),children:o?ut.jsx(ojt,{circuitJson:o,containerStyle:{height:"100%"},editingEnabled:!0,debugGrid:!0}):ut.jsx(X9,{onRunClicked:t})})})}),(!ie||ie.includes("schematic"))&&ut.jsx(rS,{value:"schematic",children:ut.jsx("div",{className:nI("rf-overflow-auto rf-bg-white",ft?"rf-h-screen":"rf-h-full rf-min-h-[620px]"),children:ut.jsx(_R,{fallbackRender:({error:vt})=>ut.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:ut.jsxs("div",{className:"rf-p-4",children:[ut.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Schematic"}),ut.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:(vt==null?void 0:vt.message)||"An unknown error occurred"})]})}),children:o?ut.jsx(njt,{circuitJson:o,containerStyle:{height:"100%"},editingEnabled:!0,onEditEvent:vt=>{K==null||K(vt)},debugGrid:Ce}):ut.jsx(X9,{onRunClicked:t})})})}),(!ie||ie.includes("cad"))&&ut.jsx(rS,{value:"cad",children:ut.jsx("div",{className:nI("rf-overflow-auto",ft?"rf-h-screen":"rf-h-full rf-min-h-[620px]"),children:ut.jsx(_R,{FallbackComponent:aOt,children:o?ut.jsx(iOt,{ref:tt,circuitJson:o,autoRotateDisabled:de}):ut.jsx(X9,{onRunClicked:t})})})}),(!ie||ie.includes("bom"))&&ut.jsx(rS,{value:"bom",children:ut.jsx("div",{className:nI("rf-overflow-auto",ft?"rf-h-screen":"rf-h-full rf-min-h-[620px]"),children:ut.jsx(_R,{fallbackRender:({error:vt})=>ut.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:ut.jsxs("div",{className:"rf-p-4",children:[ut.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Bill of Materials"}),ut.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:(vt==null?void 0:vt.message)||"An unknown error occurred"})]})}),children:o?ut.jsx(ujt,{circuitJson:o}):ut.jsx(X9,{onRunClicked:t})})})}),(!ie||ie.includes("circuit_json"))&&ut.jsx(rS,{value:"circuit_json",children:ut.jsx("div",{className:nI("rf-overflow-auto",ft?"rf-h-screen":"rf-h-full rf-min-h-[620px]"),children:ut.jsx(_R,{fallback:ut.jsx("div",{children:"Error loading JSON viewer"}),children:o?ut.jsx(ljt,{elements:o}):ut.jsx(X9,{onRunClicked:t})})})}),(!ie||ie.includes("errors"))&&ut.jsx(rS,{value:"errors",children:ut.jsx("div",{className:nI("rf-overflow-auto",ft?"rf-h-screen":"rf-h-full rf-min-h-[620px]"),children:n||Qe&&Qe.length>0||o?ut.jsx(mVt,{code:r,fsMap:e,circuitJsonErrors:Qe,circuitJsonWarnings:De,errorMessage:n,errorStack:i,circuitJson:o,evalVersion:ve,autoroutingLog:P,onReportAutoroutingLog:L}):ut.jsx(X9,{onRunClicked:t})})}),A&&(!ie||ie.includes("render_log"))&&ut.jsx(rS,{value:"render_log",children:ut.jsx(n$t,{renderLog:f})})]})})})};vde.createRoot(document.getElementById("root")).render(ut.jsx("div",{style:{height:"100vh"},children:ut.jsx(c$t,{defaultActiveTab:"cad",autoRotate3dViewerDisabled:!0,showRightHeaderContent:!1,circuitJson:window.CIRCUIT_JSON||{},...window.CIRCUIT_JSON_PREVIEW_PROPS||{}})}));const u$t=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}))});
|
|
13485
|
+
`);const x=_.state[s];if(x==null)return;JSON.stringify(i.getState())!==JSON.stringify(x)&&f(x);return}i.dispatchFromDevtools&&typeof i.dispatch=="function"&&i.dispatch(_)});case"DISPATCH":switch(C.payload.type){case"RESET":return f(m),s===void 0?u==null?void 0:u.init(i.getState()):u==null?void 0:u.init(DO(l.name));case"COMMIT":if(s===void 0){u==null||u.init(i.getState());return}return u==null?void 0:u.init(DO(l.name));case"ROLLBACK":return Kue(C.state,_=>{if(s===void 0){f(_),u==null||u.init(i.getState());return}f(_[s]),u==null||u.init(DO(l.name))});case"JUMP_TO_STATE":case"JUMP_TO_ACTION":return Kue(C.state,_=>{if(s===void 0){f(_);return}JSON.stringify(i.getState())!==JSON.stringify(_[s])&&f(_[s])});case"IMPORT_STATE":{const{nextLiftedState:_}=C.payload,x=(E=_.computedStates.slice(-1)[0])==null?void 0:E.state;if(!x)return;f(s===void 0?x:x[s]),u==null||u.send(null,_);return}case"PAUSE_RECORDING":return d=!d}return}}),m},Kue=(r,e)=>{let t;try{t=JSON.parse(r)}catch(n){console.error("[zustand devtools middleware] Could not parse the received json",n)}t!==void 0&&e(t)},s$t=w1t()(a$t(r=>({lastRunEvalVersion:void 0,setLastRunEvalVersion:e=>{r({lastRunEvalVersion:e})}}),{name:"runframe-runner-store"})),l$t=["assembly","bom","circuit_json","errors","render_log"],c$t=({code:r,fsMap:e,onRunClicked:t=void 0,errorMessage:n,errorStack:i,circuitJson:o,autoroutingGraphics:a,showRightHeaderContent:s=!0,showCodeTab:l=!1,codeTabContent:c,showJsonTab:u=!0,showRenderLogTab:A=!0,onActiveTabChange:d,renderLog:f,showImportAndFormatButtons:m=!0,className:C,headerClassName:E,leftHeaderContent:_,readOnly:x,isStreaming:w,autoroutingLog:P,onReportAutoroutingLog:L,isRunningCode:O,hasCodeChangedSinceLastRun:H,onEditEvent:K,editEvents:q,defaultActiveTab:Y,defaultTab:se,availableTabs:ie,autoRotate3dViewerDisabled:de,showSchematicDebugGrid:Ce=!1,showToggleFullScreen:xe=!0,defaultToFullScreen:fe=!1,activeEffectName:Ie})=>{var xt;$Xt();const ve=s$t(vt=>vt.lastRunEvalVersion),Qe=pt.useMemo(()=>o?o.filter(vt=>vt&&"error_type"in vt||vt.type.includes("error")):null,[o]),De=pt.useMemo(()=>o?o.filter(vt=>vt&&"warning_type"in vt||vt.type.includes("warning")):null,[o]);r$t({errorMessage:n,errorStack:i,circuitJsonErrors:Qe});const[Fe,Ne]=pt.useState(Y??se??(ie==null?void 0:ie[0])??"pcb"),[rt,et]=pt.useState(null),[ft,_t]=pt.useState(fe);e$t(ft);const Ft=pt.useCallback(vt=>{Ne(vt),d==null||d(vt)},[d]),Lt=()=>{_t(!ft)};pt.useEffect(()=>{n&&(Fe!=="errors"&&et(Fe),Ft("errors"))},[n]),pt.useEffect(()=>{(Fe==="code"||Fe==="errors")&&o&&!n&&Ft(rt??Y??se??(ie==null?void 0:ie[0])??"pcb")},[o]);const tt=pt.useCallback(vt=>{window.TSCIRCUIT_3D_OBJECT_REF=vt===null?void 0:vt},[]);return ut.jsx("div",{className:nI("flex flex-col relative rf-overflow-x-hidden rf-h-full",C),children:ut.jsx("div",{className:nI("rf-md:sticky rf-md:top-2 rf-h-full",ft&&"rf-fixed rf-top-0 rf-left-0 rf-w-full rf-h-full rf-bg-white rf-overflow-hidden"),children:ut.jsxs(pqe,{value:Fe,onValueChange:Ft,className:"rf-flex-grow rf-flex rf-flex-col rf-h-full",children:[ut.jsxs("div",{className:nI("rf-flex rf-items-center rf-gap-2 rf-p-2 rf-pb-0",E),children:[_,_&&ut.jsx("div",{className:"rf-flex-grow"}),!_&&O&&ut.jsx(vLe,{className:"rf-w-4 rf-h-4 rf-animate-spin"}),!_&&ut.jsx("div",{className:"rf-flex-grow"}),f&&f.progress!==1&&!n&&ut.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[Ie?ut.jsx("div",{className:"rf-text-xs rf-text-gray-500",children:Ie}):f.lastRenderEvent&&ut.jsx("div",{className:"rf-text-xs rf-text-gray-500",children:((xt=f.lastRenderEvent)==null?void 0:xt.phase)??""}),ut.jsx("div",{className:"rf-w-4 rf-h-4 rf-bg-blue-500 rf-opacity-50 rf-rounded-full rf-text-white",children:ut.jsx(vLe,{className:"rf-w-4 rf-h-4 rf-animate-spin"})}),ut.jsxs("div",{className:"rf-text-xs rf-font-bold rf-text-gray-700 rf-tabular-nums",children:[((f.progress??0)*100).toFixed(1),"%"]})]}),s&&ut.jsxs(Bpe,{children:[l&&ut.jsx(NM,{value:"code",children:"Code"}),!ie||ie.includes("pcb")?ut.jsxs(NM,{value:"pcb",className:"rf-whitespace-nowrap",children:[o&&ut.jsx("span",{className:nI("rf-inline-flex rf-items-center rf-justify-center rf-w-2 rf-h-2 rf-mr-1 rf-text-xs rf-font-bold rf-text-white rf-rounded-full",H?"rf-bg-gray-500":"rf-bg-blue-500")}),"PCB"]}):null,!ie||ie.includes("schematic")?ut.jsxs(NM,{value:"schematic",className:"rf-whitespace-nowrap",children:[o&&ut.jsx("span",{className:nI("rf-inline-flex rf-items-center rf-justify-center rf-w-2 rf-h-2 rf-mr-1 rf-text-xs rf-font-bold rf-text-white rf-rounded-full",H?"rf-bg-gray-500":"rf-bg-blue-500")}),"Schematic"]}):null,!ie||ie.includes("cad")?ut.jsxs(NM,{value:"cad",children:[o&&ut.jsx("span",{className:nI("inline-flex items-center justify-center w-2 h-2 mr-1 text-xs font-bold text-white rounded-full",H?"rf-bg-gray-500":"rf-bg-blue-500")}),"3D"]}):null,!["pcb","cad","schematic"].includes(Fe)&&ut.jsx(NM,{value:Fe,children:xpe(Fe)}),ut.jsxs(C6e,{children:[ut.jsx(E6e,{asChild:!0,children:ut.jsxs("div",{className:"rf-whitespace-nowrap rf-p-2 rf-mr-1 rf-cursor-pointer rf-relative",children:[ut.jsx(vOt,{className:"rf-w-4 rf-h-4"}),(Qe&&Qe.length>0||n)&&ut.jsx("span",{className:"rf-inline-flex rf-absolute rf-top-[6px] rf-right-[4px] rf-items-center rf-justify-center rf-w-1 rf-h-1 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-red-500 rf-rounded-full"})]})}),ut.jsxs($le,{className:"rf-*:text-xs",children:[l$t.filter(vt=>!ie||ie.includes(vt)).map(vt=>ut.jsxs(VT,{onSelect:()=>Ft(vt),children:[Fe!==vt&&ut.jsx(yLe,{className:"rf-w-3 rf-h-3 rf-opacity-30"}),Fe===vt&&ut.jsx(gLe,{className:"rf-w-3 rf-h-3"}),ut.jsx("div",{className:"rf-pr-2",children:xpe(vt)}),vt==="errors"&&(Qe&&Qe.length>0||n)&&ut.jsx("span",{className:"rf-inline-flex rf-items-center rf-justify-center rf-w-3 rf-h-3 rf-ml-2 rf-text-[8px] rf-font-bold rf-text-white rf-bg-red-500 rf-rounded-full",children:n?1:Qe==null?void 0:Qe.length})]},vt)),ut.jsx(VT,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:ut.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/runframe@",i$t.split(".").map((vt,Ht)=>Ht===2?parseInt(vt)+1:vt).join(".")]})}),ve&&ut.jsx(VT,{disabled:!0,className:"rf-opacity-60 rf-cursor-default rf-select-none",children:ut.jsxs("div",{className:"rf-pr-2 rf-text-xs rf-text-gray-500",children:["@tscircuit/eval@",ve]})})]})]})]}),xe&&ut.jsx(ZQ,{onClick:Lt,variant:"ghost",children:ft?ut.jsx(EOt,{size:16}):ut.jsx(IOt,{size:16})})]}),l&&ut.jsx(rS,{value:"code",className:"rf-flex-grow rf-overflow-hidden",children:ut.jsx("div",{className:"rf-h-full",children:c})}),(!ie||ie.includes("pcb"))&&ut.jsx(rS,{value:"pcb",children:ut.jsx("div",{className:nI("rf-overflow-hidden",ft?"rf-h-[calc(100vh-52px)]":"rf-h-full"),children:ut.jsx(_R,{fallbackRender:({error:vt})=>ut.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:ut.jsxs("div",{className:"rf-p-4",children:[ut.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading PCB viewer"}),ut.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:(vt==null?void 0:vt.message)||"An unknown error occurred"})]})}),children:o?ut.jsx(ZXt,{focusOnHover:!1,circuitJson:o,debugGraphics:a,containerClassName:nI("rf-h-full rf-w-full",ft?"rf-min-h-[calc(100vh-240px)]":"rf-min-h-[620px]"),onEditEventsChanged:vt=>{if(K)for(const Ht of vt)K(Ht)}}):ut.jsx(X9,{onRunClicked:t})})})}),(!ie||ie.includes("assembly"))&&ut.jsx(rS,{value:"assembly",children:ut.jsx("div",{className:nI("rf-overflow-auto",ft?"rf-h-screen":"rf-h-full rf-min-h-[620px]"),children:ut.jsx(_R,{fallback:ut.jsx("div",{children:"Error loading Assembly"}),children:o?ut.jsx(ojt,{circuitJson:o,containerStyle:{height:"100%"},editingEnabled:!0,debugGrid:!0}):ut.jsx(X9,{onRunClicked:t})})})}),(!ie||ie.includes("schematic"))&&ut.jsx(rS,{value:"schematic",children:ut.jsx("div",{className:nI("rf-overflow-auto rf-bg-white",ft?"rf-h-screen":"rf-h-full rf-min-h-[620px]"),children:ut.jsx(_R,{fallbackRender:({error:vt})=>ut.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:ut.jsxs("div",{className:"rf-p-4",children:[ut.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Schematic"}),ut.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:(vt==null?void 0:vt.message)||"An unknown error occurred"})]})}),children:o?ut.jsx(njt,{circuitJson:o,containerStyle:{height:"100%"},editingEnabled:!0,onEditEvent:vt=>{K==null||K(vt)},debugGrid:Ce}):ut.jsx(X9,{onRunClicked:t})})})}),(!ie||ie.includes("cad"))&&ut.jsx(rS,{value:"cad",children:ut.jsx("div",{className:nI("rf-overflow-auto",ft?"rf-h-screen":"rf-h-full rf-min-h-[620px]"),children:ut.jsx(_R,{FallbackComponent:aOt,children:o?ut.jsx(iOt,{ref:tt,circuitJson:o,autoRotateDisabled:de}):ut.jsx(X9,{onRunClicked:t})})})}),(!ie||ie.includes("bom"))&&ut.jsx(rS,{value:"bom",children:ut.jsx("div",{className:nI("rf-overflow-auto",ft?"rf-h-screen":"rf-h-full rf-min-h-[620px]"),children:ut.jsx(_R,{fallbackRender:({error:vt})=>ut.jsx("div",{className:"rf-mt-4 rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200",children:ut.jsxs("div",{className:"rf-p-4",children:[ut.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-3",children:"Error loading Bill of Materials"}),ut.jsx("p",{className:"rf-text-xs rf-font-mono rf-whitespace-pre-wrap rf-text-red-600 rf-mt-2",children:(vt==null?void 0:vt.message)||"An unknown error occurred"})]})}),children:o?ut.jsx(ujt,{circuitJson:o}):ut.jsx(X9,{onRunClicked:t})})})}),(!ie||ie.includes("circuit_json"))&&ut.jsx(rS,{value:"circuit_json",children:ut.jsx("div",{className:nI("rf-overflow-auto",ft?"rf-h-screen":"rf-h-full rf-min-h-[620px]"),children:ut.jsx(_R,{fallback:ut.jsx("div",{children:"Error loading JSON viewer"}),children:o?ut.jsx(ljt,{elements:o}):ut.jsx(X9,{onRunClicked:t})})})}),(!ie||ie.includes("errors"))&&ut.jsx(rS,{value:"errors",children:ut.jsx("div",{className:nI("rf-overflow-auto",ft?"rf-h-screen":"rf-h-full rf-min-h-[620px]"),children:n||Qe&&Qe.length>0||o?ut.jsx(mVt,{code:r,fsMap:e,circuitJsonErrors:Qe,circuitJsonWarnings:De,errorMessage:n,errorStack:i,circuitJson:o,evalVersion:ve,autoroutingLog:P,onReportAutoroutingLog:L}):ut.jsx(X9,{onRunClicked:t})})}),A&&(!ie||ie.includes("render_log"))&&ut.jsx(rS,{value:"render_log",children:ut.jsx(n$t,{renderLog:f})})]})})})};vde.createRoot(document.getElementById("root")).render(ut.jsx("div",{style:{height:"100vh"},children:ut.jsx(c$t,{defaultActiveTab:"cad",autoRotate3dViewerDisabled:!0,showRightHeaderContent:!1,circuitJson:window.CIRCUIT_JSON||{},...window.CIRCUIT_JSON_PREVIEW_PROPS||{}})}));const u$t=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}))});
|