PageSourceSearch

https://protarded-aiost.hf.space/assets/js/index.e76aa45d.js

js protarded-aiost.hf.space collected 2026-10-03 17:14:34 UTC 1,091,523 bytes, 63 lines download raw bytes

1(()=>{"use strict";var e,t,s,a,r,n,l={1932(e,t,s){var a,r=s(9793);s(5261),s(8760),s(7267),s(5222);var n=s(405),l=s(7541),i=s(3135),o=s(1650),d=s(1172),c=s(8348),u=s(1265),m=s(9435),p=s(9342),h=s(5445),x=s(1531),g=s(851),f=s(3455);function b(){for(var e=arguments.length,t=Array(e),s=0;s<e;s++)t[s]=arguments[s];return(0,f.QP)((0,g.$)(t))}let v={toaster:(0,h.F)(["group toaster z-[150]"]),toast:(0,h.F)(["group/toast","select-none cursor-default","group-[.toaster]:py-4 group-[.toaster]:px-6 group-[.toaster]:gap-3","group-[.toaster]:text-sm group-[.toaster]:font-medium","group-[.toaster]:rounded-xl group-[.toaster]:border group-[.toaster]:backdrop-blur-sm","group-[.toaster]:transition-all group-[.toaster]:duration-200","group-[.toaster]:text-[--foreground] group-[.toaster]:border-[--border]","group-[.toaster]:ring-[--border]","group-[.toaster]:data-[type=success]:bg-gradient-to-br","group-[.toaster]:data-[type=success]:from-emerald-950/95 group-[.toaster]:data-[type=success]:to-emerald-900/60","group-[.toaster]:data-[type=success]:text-emerald-100","group-[.toaster]:data-[type=success]:border-emerald-800/50","group-[.toaster]:data-[type=success]:ring-emerald-700/40","group-[.toaster]:data-[type=warning]:bg-gradient-to-br","group-[.toaster]:data-[type=warning]:from-amber-950/95 group-[.toaster]:data-[type=warning]:to-amber-900/60","group-[.toaster]:data-[type=warning]:text-amber-100","group-[.toaster]:data-[type=warning]:border-amber-800/50","group-[.toaster]:data-[type=warning]:ring-amber-700/40","group-[.toaster]:data-[type=error]:bg-gradient-to-br","group-[.toaster]:data-[type=error]:from-red-950/95 group-[.toaster]:data-[type=error]:to-red-900/60","group-[.toaster]:data-[type=error]:text-red-100","group-[.toaster]:data-[type=error]:border-red-800/50","group-[.toaster]:data-[type=error]:ring-red-700/40","group-[.toaster]:data-[type=info]:bg-gradient-to-br","group-[.toaster]:data-[type=info]:from-blue-950/95 group-[.toaster]:data-[type=info]:to-blue-900/60","group-[.toaster]:data-[type=info]:text-blue-100","group-[.toaster]:data-[type=info]:border-blue-800/50","group-[.toaster]:data-[type=info]:ring-blue-700/40"]),description:(0,h.F)(["group/toast:text-xs group/toast:font-normal group/toast:mt-1","group/toast:opacity-80","group-data-[type=success]/toast:text-emerald-300","group-data-[type=warning]/toast:text-amber-300","group-data-[type=error]/toast:text-red-300","group-data-[type=info]/toast:text-blue-300","cursor-default"]),actionButton:(0,h.F)(["group/toast:bg-[--subtle] group/toast:text-[--foreground]","group/toast:rounded-lg group/toast:px-3 group/toast:py-1.5","group/toast:text-xs group/toast:font-medium","group/toast:transition-colors group/toast:hover:bg-[--subtle-hover]","group/toast:ring-1 group/toast:ring-[--border]/20"]),cancelButton:(0,h.F)(["group/toast:bg-transparent group/toast:text-[--muted]","group/toast:rounded-lg group/toast:px-3 group/toast:py-1.5","group/toast:text-xs group/toast:font-medium","group/toast:transition-colors group/toast:hover:bg-[--subtle]","group/toast:ring-1 group/toast:ring-transparent group/toast:hover:ring-[--border]/20"])},y=e=>{let{position:t="top-center",...s}=e,a=n.useMemo(()=>({position:t,visibleToasts:4,className:b(v.toaster()),toastOptions:{classNames:{toast:b(v.toast()),description:b(v.description()),actionButton:b(v.actionButton()),cancelButton:b(v.cancelButton())}},...s}),[]);return(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(x.l$,{theme:"dark",...a})})};y.displayName="Toaster";let j={root:(0,h.F)(["UI-Button_root","shadow-sm whitespace-nowrap font-semibold rounded-[--radius]","inline-flex items-center text-white transition ease-in text-center text-base justify-center","focus-visible:outline-none focus-visible:ring-2 ring-offset-1 ring-offset-[--background] focus-visible:ring-[--ring]","disabled:opacity-50 disabled:pointer-events-none"],{variants:{intent:{primary:"bg-brand-500 hover:bg-brand-600 active:bg-brand-700 border border-transparent","primary-outline":"text-[--brand] border border-[--brand] bg-transparent hover:bg-brand-500 active:bg-brand-600 active:border-transparent hover:text-white dark:hover:border-brand-500 dark:active:bg-brand-600 dark:hover:text-white dark:active:border-transparent dark:active:text-white","primary-subtle":"shadow-none text-[--brand] border bg-brand-50 border-transparent hover:bg-brand-100 active:bg-brand-200 dark:bg-opacity-10 dark:hover:bg-opacity-20","primary-link":"shadow-none text-[--brand] border border-transparent bg-transparent hover:underline active:text-brand-700 dark:active:text-brand-300","primary-basic":"shadow-none text-[--brand] border border-transparent bg-transparent hover:bg-brand-100 active:bg-brand-200 dark:hover:bg-opacity-10 dark:active:text-brand-300",warning:"bg-orange-500 hover:bg-orange-600 active:bg-orange-700 border border-transparent","warning-outline":"text-[--orange] border border-[--orange] bg-transparent hover:bg-orange-500 active:bg-orange-600 active:border-transparent hover:text-white dark:hover:border-orange-500 dark:active:bg-orange-600 dar
1k:hover:text-white dark:active:border-transparent dark:active:text-white","warning-subtle":"shadow-none text-[--orange] border bg-orange-50 border-transparent hover:bg-orange-100 active:bg-orange-200 dark:bg-opacity-10 dark:hover:bg-opacity-20","warning-link":"shadow-none text-[--orange] border border-transparent bg-transparent hover:underline active:text-orange-700 dark:active:text-orange-300","warning-basic":"shadow-none text-[--orange] border border-transparent bg-transparent hover:bg-orange-100 active:bg-orange-200 dark:hover:bg-opacity-10 dark:active:text-orange-300",success:"bg-green-500 hover:bg-green-600 active:bg-green-700 border border-transparent","success-outline":"text-[--green] border border-[--green] bg-transparent hover:bg-green-500 active:bg-green-600 active:border-transparent hover:text-white dark:hover:border-green-500 dark:active:bg-green-600 dark:hover:text-white dark:active:border-transparent dark:active:text-white","success-subtle":"shadow-none text-[--green] border bg-green-50 border-transparent hover:bg-green-100 active:bg-green-200 dark:bg-opacity-10 dark:hover:bg-opacity-20","success-link":"shadow-none text-[--green] border border-transparent bg-transparent hover:underline active:text-green-700 dark:active:text-green-300","success-basic":"shadow-none text-[--green] border border-transparent bg-transparent hover:bg-green-100 active:bg-green-200 dark:hover:bg-opacity-10 dark:active:text-green-300",alert:"bg-red-500 hover:bg-red-600 active:bg-red-700 border border-transparent","alert-outline":"text-[--red] border border-[--red] bg-transparent hover:bg-red-500 active:bg-red-600 active:border-transparent hover:text-white dark:hover:border-red-500 dark:active:bg-red-600 dark:hover:text-white dark:active:border-transparent dark:active:text-white","alert-subtle":"shadow-none text-[--red] border bg-red-50 border-transparent hover:bg-red-100 active:bg-red-200 dark:bg-opacity-10 dark:hover:bg-opacity-20","alert-link":"shadow-none text-[--red] border border-transparent bg-transparent hover:underline active:text-red-700 dark:active:text-red-300","alert-basic":"shadow-none text-[--red] border border-transparent bg-transparent hover:bg-red-100 active:bg-red-200 dark:hover:bg-opacity-10 dark:active:text-red-300",gray:"bg-gray-500 hover:bg-gray-600 active:bg-gray-700 border border-transparent","gray-outline":"text-gray-600 border  bg-transparent hover:bg-gray-100 active:border-transparent active:bg-gray-200 dark:text-gray-300 dark: dark:hover:bg-gray-800 dark:hover:bg-opacity-50 dark:active:bg-gray-700 dark:active:border-transparent dark:hover:text-gray-100","gray-subtle":"shadow-none text-[--gray] border bg-gray-100 border-transparent hover:bg-gray-200 active:bg-gray-300 dark:text-gray-300 dark:bg-opacity-10 dark:hover:bg-opacity-20","gray-link":"shadow-none text-[--gray] border border-transparent bg-transparent hover:underline active:text-gray-700 dark:text-gray-300 dark:active:text-gray-200","gray-basic":"shadow-none text-[--gray] border border-transparent bg-transparent hover:bg-gray-100 active:bg-gray-200 dark:active:bg-opacity-20 dark:text-gray-200 dark:hover:bg-opacity-10 dark:active:text-gray-200",white:"text-[#000] bg-white hover:bg-gray-200 active:bg-gray-300 border border-transparent","white-outline":"text-white border border-gray-200 bg-transparent hover:bg-white hover:text-black active:bg-gray-100 active:text-[#000]","white-subtle":"shadow-none text-white bg-white bg-opacity-15 hover:bg-opacity-20 border border-transparent active:bg-opacity-25","white-link":"shadow-none text-white border border-transparent bg-transparent hover:underline active:text-gray-200","white-basic":"shadow-none text-white border border-transparent bg-transparent hover:bg-white hover:bg-opacity-15 active:bg-opacity-20 active:text-white-300"},rounded:{true:"rounded-full",false:null},contentWidth:{true:"w-fit",false:null},size:{xs:"text-sm h-6 px-2",sm:"text-sm h-8 px-3",md:"text-sm h-10 px-4",lg:"h-12 px-6 text-lg",xl:"text-2xl h-14 px-8"}},defaultVariants:{intent:"primary",size:"md"}}),icon:(0,h.F)(["UI-Button__icon","inline-flex self-center flex-shrink-0"])},w=n.forwardRef((e,t)=>
1{let{children:s,size:a,className:n,rounded:l=!1,contentWidth:i=!1,intent:o,leftIcon:d,rightIcon:c,iconSpacing:u="0.5rem",loading:m,iconClass:p,disabled:h,hideTextOnSmallScreen:x,hideTextOnLargeScreen:g,...f}=e;return(0,r.jsx)("button",{type:"button",className:b(j.root({size:a,intent:o,rounded:l,contentWidth:i}),n),disabled:h||m,"aria-disabled":h,...f,ref:t,children:m?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("svg",{width:"15",height:"15",fill:"currentColor",className:"animate-spin",viewBox:"0 0 1792 1792",xmlns:"http://www.w3.org/2000/svg",style:{marginInlineEnd:x?0:u},children:(0,r.jsx)("path",{d:"M526 1394q0 53-37.5 90.5t-90.5 37.5q-52 0-90-38t-38-90q0-53 37.5-90.5t90.5-37.5 90.5 37.5 37.5 90.5zm498 206q0 53-37.5 90.5t-90.5 37.5-90.5-37.5-37.5-90.5 37.5-90.5 90.5-37.5 90.5 37.5 37.5 90.5zm-704-704q0 53-37.5 90.5t-90.5 37.5-90.5-37.5-37.5-90.5 37.5-90.5 90.5-37.5 90.5 37.5 37.5 90.5zm1202 498q0 52-38 90t-90 38q-53 0-90.5-37.5t-37.5-90.5 37.5-90.5 90.5-37.5 90.5 37.5 37.5 90.5zm-964-996q0 66-47 113t-113 47-113-47-47-113 47-113 113-47 113 47 47 113zm1170 498q0 53-37.5 90.5t-90.5 37.5-90.5-37.5-37.5-90.5 37.5-90.5 90.5-37.5 90.5 37.5 37.5 90.5zm-640-704q0 80-56 136t-136 56-136-56-56-136 56-136 136-56 136 56 56 136zm530 206q0 93-66 158.5t-158 65.5q-93 0-158.5-65.5t-65.5-158.5q0-92 65.5-158t158.5-66q92 0 158 66t66 158z"})}),s]}):(0,r.jsxs)(r.Fragment,{children:[d&&(0,r.jsx)("span",{className:b(j.icon(),p),style:{marginInlineEnd:x?0:u},children:d}),(0,r.jsx)("span",{className:b(x&&b("hidden",d&&"pl-[0.5rem]",c&&"pr-[0.5rem]"),g?"inline-block lg:hidden":"md:inline-block"),children:s}),c&&(0,r.jsx)("span",{className:b(j.icon(),p),style:{marginInlineStart:x?0:u},children:c})]})})});w.displayName="Button";let N=e=>{let{children:t,reset:s,className:a,title:n="Oops!",showRefreshButton:l=!1,...i}=e;return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{"data-luffy-error":!0,className:b("w-full flex flex-col items-center mt-10 space-y-4",a),children:[(0,r.jsx)("div",{"data-luffy-error-image-container":!0,className:"size-[8rem] mx-auto flex-none rounded-[--radius-md] object-cover object-center relative overflow-hidden",children:(0,r.jsx)("img",{"data-luffy-error-image":!0,src:"/logo.png",alt:"",className:"absolute inset-0 w-full h-full object-contain object-top"})}),(0,r.jsxs)("div",{"data-luffy-error-content":!0,className:"text-center space-y-4",children:[!!n&&(0,r.jsx)("h3",{"data-luffy-error-title":!0,children:n}),(0,r.jsx)("div",{"data-luffy-error-content-children":!0,children:t}),(0,r.jsxs)("div",{"data-luffy-error-content-buttons":!0,children:[l&&!s&&(0,r.jsx)(w,{"data-luffy-error-content-button-refresh":!0,intent:"warning-subtle",onClick:()=>window.location.reload(),children:"Retry"}),!!s&&(0,r.jsx)(w,{"data-luffy-error-content-button-reset":!0,intent:"warning-subtle",onClick:s,children:"Retry"})]})]})]})})},k={container:(0,h.F)(["UI-LoadingSpinner__container","flex flex-col w-full items-center h-24 justify-center"]),icon:(0,h.F)(["UI-LoadingSpinner__icon","inline w-10 h-10 mr-2 animate-spin","text-gray-200 dark:text-gray-600 fill-brand-500"]),title:(0,h.F)(["UI-LoadingSpinner__title","text-base font-medium text-[--foreground] py-2"])},S=n.forwardRef((e,t)=>{let{children:s,className:a,containerClass:n,iconClass:l,spinner:i,title:o,...d}=e;return(0,r.jsxs)("div",{className:b(k.container(),n),...d,ref:t,children:[i||(0,r.jsx)(C,{className:l}),o&&(0,r.jsx)("p",{className:k.title(),children:o})]})});S.displayName="LoadingSpinner";let C=n.forwardRef((e,t)=>{let{children:s,className:a,...n}=e;return(0,r.jsxs)("svg",{"aria-hidden":"true",className:b(k.icon(),a),viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",ref:t,...n,children:[(0,r.jsx)("path",{d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"currentColor"}),(0,r.jsx)("path",{d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.
11071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentFill"})]})}),_={overlay:(0,h.F)(["UI-LoadingOverlay__overlay","absolute bg-[--background]/50 w-full h-full z-10 inset-0 pt-4 flex flex-col items-center justify-center backdrop-blur-sm","!mt-0"])},R=n.forwardRef((e,t)=>{let{children:s,hide:a=!1,showSpinner:n=!0,className:l,...i}=e;return a?null:(0,r.jsxs)("div",{ref:t,className:b(_.overlay(),l),...i,children:[n&&(0,r.jsx)(S,{className:"justify-auto"}),s]})});R.displayName="LoadingOverlay";let A=(0,d.hy)()({component:function(){return(0,r.jsxs)(p.N,{attribute:"class",defaultTheme:"dark",forcedTheme:"dark",children:[(0,r.jsx)(y,{swipeDirections:["top","right"]}),(0,r.jsx)(m.s,{}),null]})},notFoundComponent:function(){return(0,r.jsx)(R,{showSpinner:!1,children:(0,r.jsx)(N,{title:"Page not found",showRefreshButton:!1,children:(0,r.jsx)("p",{children:"The page you are looking for does not exist."})})})}}),T=n.forwardRef((e,t)=>{let{className:s,icon:a,...n}=e;return(0,r.jsx)(E,{type:"button",intent:"gray-basic",size:"sm",className:b("rounded-full text-2xl flex-none",s),icon:a||(0,r.jsx)("span",{children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"16",height:"16",fill:"currentColor",children:(0,r.jsx)("path",{d:"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"})})}),...n,ref:t})});T.displayName="CloseButton";let I={root:(0,h.F)("UI-IconButton_root p-0 flex-none",{variants:{size:{xs:"text-xl h-6 w-6",sm:"text-xl h-8 w-8",md:"text-2xl h-10 w-10",lg:"text-3xl h-12 w-12",xl:"text-4xl h-14 w-14"}},defaultVariants:{size:"md"}})},E=n.forwardRef((e,t)=>{let{className:s,icon:a,size:n,loading:l,...i}=e;return(0,r.jsx)(w,{className:b(I.root({size:n}),s),loading:l,iconSpacing:"0",...i,ref:t,children:!l&&a})});E.displayName="IconButton";var M=s(4121),P=s(5989),D=s(8427);let L={root:(0,h.F)(["UI-Popover__root","z-50 w-72 rounded-[--radius] border bg-[--background] p-4 text-base shadow-sm outline-none","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0","data-[state=open]:fade-in-50 data-[state=closed]:zoom-out-100 data-[state=open]:zoom-in-95","data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2","data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"])},U=n.forwardRef((e,t)=>{let{trigger:s,triggerProps:a,defaultOpen:n,open:l,onOpenChange:i,modal:o=!0,className:d,align:c="center",sideOffset:u=8,...m}=e;return(0,r.jsxs)(D.bL,{defaultOpen:n,open:l,onOpenChange:i,modal:o,children:[(0,r.jsx)(D.l9,{asChild:!0,...a,children:s}),(0,r.jsx)(D.ZL,{children:(0,r.jsx)(D.UC,{ref:t,align:c,sideOffset:u,className:b(L.root(),d),onOpenAutoFocus:e=>e.preventDefault(),...m})})]})});U.displayName="Popover";let $={fieldLabel:(0,h.F)(["UI-BasicField__fieldLabel","text-base w-fit font-semibold self-start","data-[error=true]:text-red-500"]),fieldAsterisk:(0,h.F)("UI-BasicField__fieldAsterisk ml-1 text-red-500 text-sm"),fieldDetails:(0,h.F)("UI-BasicField__fieldDetails"),field:(0,h.F)("UI-BasicField__field relative w-full space-y-1"),fieldHelpText:(0,h.F)("UI-BasicField__fieldHelpText text-sm text-[--muted]"),fieldErrorText:(0,h.F)("UI-BasicField__fieldErrorText text-sm text-red-500")};function O(e,t){let{name:s,label:a,labelProps:r,help:n,moreHelp:l,error:i,required:o,disabled:d=!1,readonly:c=!1,fieldDetailsClass:u,fieldLabelClass:m,fieldAsteriskClass:p,fieldClass:h,fieldErrorTextClass:x,fieldHelpTextClass:g,id:f,...b}=e;return[b,{id:f||t,name:s,label:a,help:n,moreHelp:l,error:i,disabled:d,required:o,readonly:c,fieldAsteriskClass:p,fieldErrorTextClass:x,fieldHelpTextClass:g,fieldDetailsClass:u,fieldLabelClass:m,fieldClass:h,labelProps:r}]}let F=n.memo(n.forwardRef((e,t)=>
1{let{children:s,className:a,labelProps:n,id:l,label:i,error:o,help:d,moreHelp:c,disabled:u,readonly:m,required:p,fieldClass:h,fieldDetailsClass:x,fieldLabelClass:g,fieldAsteriskClass:f,fieldErrorTextClass:v,fieldHelpTextClass:y,...j}=e;return(0,r.jsxs)("div",{className:b($.field(),a,h),...j,ref:t,children:[!!i&&(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsxs)("label",{htmlFor:u?void 0:l,className:b($.fieldLabel(),g),"data-error":!!o,...n,children:[i,p&&(0,r.jsx)("span",{className:b($.fieldAsterisk(),f),children:"*"})]}),!!c&&(0,r.jsx)(U,{className:"text-sm",trigger:(0,r.jsx)(P.ExT,{className:"transition-opacity opacity-45 hover:opacity-90"}),children:c})]}),s,(!!d||!!o)&&(0,r.jsxs)("div",{className:b($.fieldDetails(),x),children:[!!d&&(0,r.jsx)("div",{className:b($.fieldHelpText(),y),children:d}),!!o&&(0,r.jsx)("div",{className:b($.fieldErrorText(),v),children:o})]})]})}));F.displayName="BasicField";let z={root:(0,h.F)(["UI-Input__root","flex items-center","w-full rounded-[--radius]","bg-[--paper] border border-[--border] placeholder-gray-400 dark:placeholder-gray-500","disabled:cursor-not-allowed","data-[disable=true]:shadow-none data-[disable=true]:opacity-50","focus:border-brand focus:ring-1 focus:ring-[--ring]","outline-0","transition duration-150","shadow-sm"],{variants:{size:{sm:"h-8 px-2 py-1 text-sm",md:"h-10 px-3",lg:"h-12 px-4 py-3 text-md"},intent:{basic:"hover:border-gray-300 dark:hover:border-gray-600",filled:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-800 dark:hover:bg-gray-700 border-transparent focus:bg-white dark:focus:bg-gray-900 shadow-none",unstyled:"bg-transparent hover:bg-transparent border-0 shadow-none focus:ring-0 rounded-none p-0 text-base"},hasError:{false:null,true:"border-red-500 hover:border-red-200 dark:border-red-500"},isDisabled:{false:null,true:"shadow-none pointer-events-none opacity-50 cursor-not-allowed bg-gray-50 dark:bg-gray-800"},isReadonly:{false:null,true:"pointer-events-none cursor-not-allowed shadow-sm"},hasLeftAddon:{true:null,false:null},hasRightAddon:{true:null,false:null},hasLeftIcon:{true:null,false:null},hasRightIcon:{true:null,false:null}},compoundVariants:[{hasLeftAddon:!0,className:"border-l-transparent hover:border-l-transparent rounded-l-none"},{hasRightAddon:!0,className:"border-r-transparent hover:border-r-transparent rounded-r-none"},{hasLeftAddon:!1,hasLeftIcon:!0,size:"sm",className:"pl-10"},{hasLeftAddon:!1,hasLeftIcon:!0,size:"md",className:"pl-10"},{hasLeftAddon:!1,hasLeftIcon:!0,size:"lg",className:"pl-12"},{hasRightAddon:!1,hasRightIcon:!0,size:"sm",className:"pr-10"},{hasRightAddon:!1,hasRightIcon:!0,size:"md",className:"pr-10"},{hasRightAddon:!1,hasRightIcon:!0,size:"lg",className:"pr-12"}],defaultVariants:{size:"md",intent:"basic",hasError:!1,isDisabled:!1,hasLeftIcon:!1,hasRightIcon:!1,hasLeftAddon:!1,hasRightAddon:!1}})},V=b("appearance-none absolute bottom-0 border-0 w-px h-px p-0 -m-px overflow-hidden whitespace-nowrap [clip:rect(0px,0px,0px,0px)] [overflow-wrap:normal]");(0,h.F)(["UI-Input__inputContainer","flex relative"]);let q=e=>{let{className:t,children:s}=e;return(0,r.jsx)("div",{className:b("UI-Input__inputContainer flex relative",t),children:s})},B={icon:(0,h.F)(["UI-Input__addons--icon","pointer-events-none absolute inset-y-0 grid place-content-center text-gray-500","dark:text-gray-300 !z-[1]"],{variants:{size:{sm:"w-10 text-md",md:"w-12 text-lg",lg:"w-14 text-2xl"},isLeftIcon:{true:"left-0",false:null},isRightIcon:{true:"right-0",false:null}},defaultVariants:{size:"md",isLeftIcon:!1,isRightIcon:!1}}),addon:(0,h.F)(["UI-Input__addons--addon","bg-gray-50 inline-flex items-center flex-none px-3 border border-gray-300 text-gray-800 shadow-sm text-sm sm:text-md","dark:bg-[--paper] dark:border-[--border] dark:text-gray-300"],{variants:{size:{sm:"text-sm",md:"text-md",lg:"text-lg"},isLeftAddon:{true:"rounded-l-md border-r-0",false:null},isRightAddon:{true:"rounded-r-md border-l-0",false:null},hasLeftIcon:{true:null,false:null},hasRightIcon:{true:null,false:null}},compoundVariants:[{size:"sm",hasLeftIcon:!0,isLeftAddon:!0,className:"pl-10"},{size:"sm",hasRightIcon:!0,isRightAddon:!0,className:"pr-10"},{size:"md",hasLeftIcon:!0,isLeftAddon:!0,className:"pl-10"},{size:"md",hasRightIcon:!0,isRightAddon:!0,className:"pr-10"},{size:"lg",hasLeftIcon:!0,isLeftAddon:!0,className:"pl-12"},{size:"lg",hasRightIcon:!0,isRightAddon:!0,className:"pr-12"}],defaultVariants:{size:"md",isLeftAddon:!1,isRightAddon:!1,hasLeftIcon:!1,hasRightIcon:!1}})},K=e=>{let{icon:t,size:s="md",side:a,props:n,className:l}=e;return t?(0,r.jsx)("span",{className:b(B.icon({isRightIcon:"right"===a,isLeftIcon:"left"===a,size:s}),l),...n,children:t}):null},H=e=>{let{addon:t,leftIcon:s,rightIcon:a,size:n="md",side:l,props:i,className:o}=e;return t?(0,r.jsx)("span",{className:b(B.addon({isRightAddon:"right"===l,isLeftAddon:"left"===l,hasRightIcon:!!a,hasLeftIcon:!!s,size:n}),o),...i,children:t}):null};function G(e){let{size:t,leftAddon:s,leftIcon:a,rightAddon:r,rightIcon:n,inputContainerClass:l,iconClass:i,addonClass:o,...d}=e;return[{size:t,leftAddon:s,leftIcon:a,rightAddon:r,rightIcon:n,...d},{inputContainerProps:{className:l}
1,leftAddonProps:{addon:s,leftIcon:a,rightIcon:n,size:t,side:"left",className:o},rightAddonProps:{addon:r,leftIcon:a,rightIcon:n,size:t,side:"right",className:o},leftIconProps:{icon:a,size:t,side:"left",className:i},rightIconProps:{icon:n,size:t,side:"right",className:i}}]}let W=n.forwardRef((e,t)=>{let[s,a]=O(e,n.useId()),[{size:l,intent:i,leftAddon:o,leftIcon:d,rightAddon:c,rightIcon:u,className:m,onValueChange:p,onChange:h,...x},{inputContainerProps:g,leftAddonProps:f,leftIconProps:v,rightAddonProps:y,rightIconProps:j}]=G({...s,size:s.size??"md",intent:s.intent??"basic",leftAddon:s.leftAddon,leftIcon:s.leftIcon,rightAddon:s.rightAddon,rightIcon:s.rightIcon}),w=n.useCallback(e=>{null==p||p(e.target.value),null==h||h(e)},[p,h]);return(0,r.jsx)(F,{...a,children:(0,r.jsxs)(q,{...g,children:[(0,r.jsx)(H,{...f}),(0,r.jsx)(K,{...v}),(0,r.jsx)("input",{id:a.id,name:a.name,className:b("form-input",z.root({size:l,intent:i,hasError:!!a.error,isDisabled:!!a.disabled,isReadonly:!!a.readonly,hasRightAddon:!!c,hasRightIcon:!!u,hasLeftAddon:!!o,hasLeftIcon:!!d}),m),disabled:a.disabled||a.readonly,"data-disabled":a.disabled,"data-readonly":a.readonly,"aria-readonly":a.readonly,required:a.required,onChange:w,...x,ref:t}),(0,r.jsx)(H,{...y}),(0,r.jsx)(K,{...j})]})})});W.displayName="TextInput";var Y=s(6603),J=s(4038);let Z=n.forwardRef((e,t)=>{let[s,a]=O(e,n.useId()),[{size:l,intent:i,leftAddon:o,leftIcon:d,rightAddon:c,rightIcon:u,className:m,onValueChange:p,onChange:h,autoComplete:x="current-password",...g},{inputContainerProps:f,leftAddonProps:v,leftIconProps:y,rightAddonProps:j,rightIconProps:w}]=G({...s,size:s.size??"md",intent:s.intent??"basic",leftAddon:s.leftAddon,leftIcon:s.leftIcon,rightAddon:s.rightAddon,rightIcon:s.rightIcon}),N=n.useCallback(e=>{null==p||p(e.target.value),null==h||h(e)},[p,h]);return(0,r.jsx)(F,{...a,children:(0,r.jsxs)(q,{...f,children:[(0,r.jsx)(H,{...v}),(0,r.jsx)(K,{...y}),(0,r.jsx)("div",{className:"relative flex-1",children:(0,r.jsxs)(Y.bL,{children:[(0,r.jsx)(Y.pd,{id:a.id,name:a.name,className:b("form-input",z.root({size:l,intent:i,hasError:!!a.error,
1isDisabled:!!a.disabled,isReadonly:!!a.readonly,hasRightAddon:!!c,hasRightIcon:!!u,hasLeftAddon:!!o,hasLeftIcon:!!d}),m),disabled:a.disabled||a.readonly,"data-disabled":a.disabled,"data-readonly":a.readonly,"aria-readonly":a.readonly,required:a.required,onChange:N,autoComplete:x,...g,ref:t}),(0,r.jsx)(Y.lM,{className:b("absolute right-0 top-0 h-full px-3","text-muted-foreground hover:text-foreground","focus:outline-none focus:ring-0","disabled:opacity-50 disabled:pointer-events-none","bg-transparent"),children:(0,r.jsx)(Y.In,{visible:(0,r.jsx)(J.ZT8,{className:"h-6 w-6"}),hidden:(0,r.jsx)(J.Fnz,{className:"h-6 w-6"})})})]})}),(0,r.jsx)(H,{...j}),(0,r.jsx)(K,{...w})]})})});Z.displayName="PasswordInput";let Q={root:(0,h.F)(["UI-Card__root","rounded-[--radius] border bg-[--paper] shadow-sm"]),header:(0,h.F)(["UI-Card__header","flex flex-col space-y-1.5 p-4"]),title:(0,h.F)(["UI-Card__title","text-2xl font-semibold leading-none tracking-tight"]),description:(0,h.F)(["UI-Card__description","text-sm text-[--muted]"]),content:(0,h.F)(["UI-Card__content","p-4 pt-0"]),footer:(0,h.F)(["UI-Card__footer","flex items-center p-4 pt-0"])},X=n.forwardRef((e,t)=>{let{className:s,...a}=e;return(0,r.jsx)("div",{ref:t,className:b(Q.root(),s),...a})});X.displayName="Card";let ee=n.forwardRef((e,t)=>{let{className:s,...a}=e;return(0,r.jsx)("div",{ref:t,className:b(Q.header(),s),...a})});ee.displayName="CardHeader";let et=n.forwardRef((e,t)=>{let{className:s,...a}=e;return(0,r.jsx)("h3",{ref:t,className:b(Q.title(),s),...a})});et.displayName="CardTitle";let es=n.forwardRef((e,t)=>{let{className:s,...a}=e;return(0,r.jsx)("div",{ref:t,className:b(Q.description(),s),...a})});es.displayName="CardDescription";let ea=n.forwardRef((e,t)=>{let{className:s,...a}=e;return(0,r.jsx)("div",{ref:t,className:b(Q.content(),s),...a})});ea.displayName="CardContent";let er=n.forwardRef((e,t)=>{let{className:s,...a}=e;return(0,r.jsx)("div",{ref:t,className:b(Q.footer(),s),...a})});er.displayName="CardFooter";var en=s(7215);class el extends Error{is(e){return this.code===e}constructor(e,t,s,a=null,r){super(s),(0,en._)(this,"status",void 0),(0,en._)(this,"code",void 0),(0,en._)(this,"detail",void 0),(0,en._)(this,"issues",void 0),this.name="APIError",this.status=e,this.code=t,this.detail=a,this.issues=r}}async function ei(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{body:s,...a}=t,[r,n]=e.includes(" /")?e.split(" /"):["GET",e.slice(1)],l=`/api/v1/${n}`,i=new Headers(a.headers),o={method:r,credentials:"include",...a,headers:i};void 0!==s&&(s instanceof FormData||"string"==typeof s?o.body=s:(i.set("Content-Type","application/json"),o.body=JSON.stringify(s)));let d=await fetch(l,o);if(204===d.status)return null;let c=d.headers.get("Content-Type")??"";if(!c.includes("application/json")){if(d.url.includes("/login")){let e=encodeURIComponent(window.location.pathname+window.location.search);window.location.href=`/login?next=${e}`,await new Promise(()=>{})}throw Error(`Expected JSON response but got ${c} response of ${d.status} ${d.statusText}`)}let u=await d.json();if(!u.success){var m,p,h;let e=(null==(m=u.error)?void 0:m.code)||"UNKNOWN_ERROR",t=(null==(p=u.error)?void 0:p.message)||"An unknown error occurred",s=u.detail,a=null==(h=u.error)?void 0:h.issues;throw new el(d.status,e,t,s,a)}return u.data}async function eo(e,t){return ei("POST /auth/login",{body:{username:e,password:t}})}async function ed(){return ei("POST /auth/logout")}async function ec(){return ei("/auth/me")}function eu(e,t){let s=new TextEncoder().encode(`${e}:${t}`),a="";for(let e of s)a+=String.fromCharCode(e);return`Basic ${btoa(a)}`}async function em(e,t){return ei("GET /user?raw=true",{headers:{Authorization:eu(e,t)}})}async function ep(e,t){return ei("POST /user",{body:{config:e,password:t}})}async function eh(e,t,s){return ei("PUT /user",{body:{config:t},headers:{Authorization:eu(e,s)}})}async function ex(e,t){return ei("POST /user/verify",{headers:{Authorization:eu(e,t)}})}async function eg(e,t){return ei("DELETE /user",{headers:{Authorization:eu(e,t)}})}async function ef(e,t,s){return ei("POST /user/password",{body:{newPassword:s},headers:{Authorization:eu(e,t)}})}async function eb(){return ei("/profiles")}
1async function ev(e,t,s){return ei("POST /profiles",{body:{uuid:e,password:t,label:s}})}async function ey(e,t){return ei(`PATCH /profiles/${e}`,{body:t})}async function ej(e){return ei(`DELETE /profiles/${e}`)}async function ew(e){return ei(`POST /profiles/${e}/open`)}async function eN(e,t){return ei("POST /sync/resolve",{body:{regexUrls:e.regexUrls,selUrls:e.selUrls,uuid:null==t?void 0:t.uuid,password:null==t?void 0:t.password}})}async function ek(e,t){let s=await eN({regexUrls:e},t);return{patterns:s.patterns||[],errors:s.errors}}async function eS(e,t){let s=await eN({selUrls:e},t);return{expressions:s.expressions||[],errors:s.errors}}async function eC(e,t){return ei("POST /format",{body:{stream:e,context:t}})}async function e_(e){return ei("POST /catalogs",{body:{userData:e}})}async function eR(e){return ei("POST /oauth/exchange/gdrive",{body:{code:e}})}async function eA(){return ei("GET /templates")}async function eT(e,t,s){return ei(`GET /user/analytics?range=${s}`,{headers:{Authorization:eu(e,t)}})}async function eI(e){let t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch manifest: ${t.status} ${t.statusText}`);return t.json()}var eE=s(9217),eM=s(3620);let eP=(0,eM.j)({queryKey:["session"],queryFn:ec,staleTime:6e4,retry:!1}),eD=(0,eM.j)({queryKey:["status"],queryFn:()=>ei("/status"),staleTime:6e4,retry:!1}),eL=(0,eM.j)({queryKey:["config-profiles"],queryFn:eb,staleTime:3e4,retry:!1});var eU=s(8949);function e$(){let{data:e,isLoading:t,error:s}=(0,eU.I)(eD);return{status:e??null,loading:t,error:s?s.message:null}}function eO(e){if(!e)return"/dashboard/";try{let t=decodeURIComponent(e);if(t.startsWith("/")&&!t.startsWith("//")&&!t.startsWith("/\\"))return t}catch{}return"/dashboard/"}let eF={forbidden:{title:"Your account does not have admin access.",description:"Sign in with an admin account to continue."},oidc_disabled:{title:"SSO login is not enabled on this instance."},oidc_not_configured:{title:"SSO is not fully configured.",description:"The instance owner needs to set the issuer and client ID."},oidc_discovery_failed:{title:"Could not reach the SSO provider.",description:"It may be down or the issuer URL may be wrong."},oidc_state_invalid:{title:"That login attempt expired.",description:"Please try signing in again."},oidc_denied:{title:"The SSO provider denied the login request."},oidc_exchange_failed:{title:"The SSO provider rejected the login.",description:"Check the client ID, secret, and redirect URI."},oidc_claims_invalid:{title:"The SSO provider did not return the expected user details.",description:"Check the configured username claim."},oidc_username_conflict:{title:"That SSO username collides with a local account.",description:"The instance owner needs to set an SSO username prefix."},oidc_no_permissions:{title:"Your account is not mapped to any permissions.",description:"Ask the instance owner to map one of your groups."}};var ez=s(6505);let eV={root:(0,h.F)(["UI-AppLayout__root appLayout","flex w-full group/appLayout"],{variants:{withSidebar:{true:"flex-row with-sidebar",false:"flex-col"},sidebarSize:{slim:"sidebar-slim",sm:"sidebar-sm",md:"sidebar-md",lg:"sidebar-lg",xl:"sidebar-xl"}},defaultVariants:{withSidebar:!1,sidebarSize:"md"},compoundVariants:[{withSidebar:!0,sidebarSize:"slim",className:"lg:[&>.appLayout]:pl-20"},{withSidebar:!0,sidebarSize:"sm",className:"lg:[&>.appLayout]:pl-48"},{withSidebar:!0,sidebarSize:"md",className:"lg:[&>.appLayout]:pl-64"},{withSidebar:!0,sidebarSize:"lg",className:"lg:[&>.appLayout]:pl-[20rem]"},{withSidebar:!0,sidebarSize:"xl",className:"lg:[&>.appLayout]:pl-[25rem]"}]})},eq={root:(0,h.F)(["UI-AppLayoutHeader__root","relative w-full"])},eB={root:(0,h.F)(["UI-AppLayoutSidebar__root z-50","hidden lg:fixed lg:inset-y-0 lg:flex lg:flex-col grow-0 shrink-0 basis-0","group-[.sidebar-slim]/appLayout:w-20","group-[.sidebar-sm]/appLayout:w-48","group-[.sidebar-md]/appLayout:w-64","group-[.sidebar-lg]/appLayout:w-[20rem]","group-[.sidebar-xl]/appLayout:w-[25rem]"])},eK={root:(0,h.F)(["UI-AppLayoutContent__root","relative"])},eH={root:(0,h.F)(["UI-AppLayoutFooter__root","relative"])},eG={root:(0,h.F)(["UI-AppLayoutStack__root","relative"],{variants:{spacing:{sm:"space-y-2",md:"space-y-4",lg:"space-y-8",xl:"space-y-10"}},defaultVariants:{spacing:"md"}})},eW={root:(0,h.F)(["UI-AppLayoutGrid__root","relative flex flex-col"],{variants:{breakBelow:{sm:"sm:grid sm:space-y-0",md:"md:grid md:space-y-0",lg:"lg:grid lg:space-y-0",xl:"xl:grid xl:space-y-0"},spacing:{sm:"gap-2",md:"gap-4",lg:"gap-8",xl:"gap-10"},cols:{1:null,2:null,3:null,4:null,5:null,6:null}},defaultVariants:{breakBelow:"xl",spacing:"md",cols:3},compoundVariants:[{breakBelow:"sm",cols:1,className:"sm:grid-cols-1"},{breakBelow:"sm",cols:2,className:"sm:grid-cols-2"},{breakBelow:"sm",cols:3,className:"sm:grid-cols-3"},{breakBelow:"sm",cols:4,className:"sm:grid-cols-4"},{breakBelow:"sm",cols:5,className:"sm:grid-cols-5"},{breakBelow:"sm",cols:6,className:"sm:grid-cols-6"},{breakBelow:"md",cols:1,className:"md:grid-cols-1"},{breakBelow:"md",cols:2,className:"md:grid-cols-2"},{breakBelow:"md",cols:3,className:"md:grid-cols-3"},{breakBelow:"md",cols:4,className:"md:grid-cols-4"},{breakBelow:"md",cols:5,className:"md:grid-cols-5"},{breakBelow:"md",cols:6,className:"md:grid-cols-6"},{breakBelow:"lg",cols:1,className:"lg:grid-cols-1"},{breakBelow:"lg",cols:2,className:"lg:grid-cols-2"},{breakBelow:"lg",cols:3,className:"lg:grid-cols-3"},{breakBelow:"lg",cols:4,className:"lg:grid-cols-4"},{breakBelow:"lg",cols:5,className:"lg:grid-cols-5"},{breakBelow:"lg",cols:6,className:"lg:grid-cols-6"},{breakBelow:"xl",cols:1,className:"xl:grid-cols-1"},{breakBelow:"xl",cols:2,className:"xl:grid-cols-2"},{breakBelow:"xl",cols:3,className:"xl:grid-cols-3"},{breakBelow:"xl",cols:4,className:"xl:grid-cols-4"},{breakBelow:"xl",cols:5,className:"xl:grid-cols-5"},{breakBelow:"xl",cols:6,className:"xl:grid-cols-6"}]})},eY=n.forwardRef((e,t)=>
1{let{children:s,className:a,withSidebar:l=!1,sidebarSize:i,...o}=e,d=n.useContext(e2);return(0,r.jsx)("div",{ref:t,className:b(eV.root({withSidebar:l,sidebarSize:d.size||i}),!1,a),...o,children:s})});eY.displayName="AppLayout",n.forwardRef((e,t)=>{let{children:s,className:a,...n}=e;return(0,r.jsx)("header",{ref:t,className:b(eq.root(),a),...n,children:s})}).displayName="AppLayoutHeader";let eJ=n.forwardRef((e,t)=>{let{children:s,className:a,...n}=e;return(0,r.jsx)("aside",{ref:t,className:b(eB.root(),a),...n,children:s})});eJ.displayName="AppLayoutSidebar";let eZ=n.forwardRef((e,t)=>{let{children:s,className:a,...n}=e;return(0,r.jsx)("main",{ref:t,className:b(eK.root(),a),...n,children:s})});eZ.displayName="AppLayoutContent",n.forwardRef((e,t)=>{let{children:s,className:a,breakBelow:n,cols:l,spacing:i,...o}=e;return(0,r.jsx)("section",{ref:t,className:b(eW.root({breakBelow:n,cols:l,spacing:i}),a),...o,children:s})}).displayName="AppLayoutGrid",n.forwardRef((e,t)=>{let{children:s,className:a,...n}=e;return(0,r.jsx)("footer",{ref:t,className:b(eH.root(),a),...n,children:s})}).displayName="AppLayoutFooter",n.forwardRef((e,t)=>{let{children:s,className:a,spacing:n,...l}=e;return(0,r.jsx)("div",{ref:t,className:b(eG.root({spacing:n}),a),...l,children:s})}).displayName="AppLayoutStack";var eQ=s(5045),eX=s(9484);let e0={overlay:(0,h.F)(["UI-Drawer__overlay","fixed inset-0 z-[50] bg-black/80","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"]),content:(0,h.F)(["UI-Drawer__content","fixed z-50 w-full gap-4 bg-[--background] p-6 shadow-lg overflow-y-auto","transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-500 data-[state=open]:duration-500","focus:outline-none focus-visible:outline-none",!1],{variants:{side:{mangaReader:"w-full inset-x-0 top-0 border data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",top:"w-full lg:w-[calc(100%_-_20px)] inset-x-0 top-0 border data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"w-full lg:w-[calc(100%_-_20px)] inset-x-0 bottom-0 border data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full lg:h-[calc(100%_-_20px)] border data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left",right:"inset-y-0 right-0 h-full lg:h-[calc(100%_-_20px)] border data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right"},size:{sm:null,md:null,lg:null,xl:null,full:null}},defaultVariants:{side:"right",size:"md"},compoundVariants:[{size:"sm",side:"left",className:"sm:max-w-sm"},{size:"sm",side:"right",className:"sm:max-w-sm"},{size:"md",side:"left",className:"sm:max-w-md"},{size:"md",side:"right",className:"sm:max-w-md"},{size:"lg",side:"left",className:"sm:max-w-2xl"},{size:"lg",side:"right",className:"sm:max-w-2xl"},{size:"xl",side:"left",className:"sm:max-w-5xl"},{size:"xl",side:"right",className:"sm:max-w-5xl"},{size:"full",side:"top",className:"h-dvh"},{size:"full",side:"bottom",className:"h-dvh"}]}),close:(0,h.F)(["UI-Drawer__close","absolute right-4 top-4"]),header:(0,h.F)(["UI-Drawer__header","flex flex-col space-y-1.5 text-center sm:text-left"]),footer:(0,h.F)(["UI-Drawer__footer","flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2"]),title:(0,h.F)(["UI-Drawer__title","text-xl font-semibold leading-none tracking-tight"]),description:(0,h.F)(["UI-Drawer__description","text-sm text-[--muted]"])};function e1(e){let{allowOutsideInteraction:t=!1,trigger:s,title:a,footer:l,description:i,children:o,closeButton:d,overlayClass:c,contentClass:u,closeClass:m,headerClass:p,footerClass:h,titleClass:x,descriptionClass:g,hideCloseButton:f,side:v="right",size:y,open:j,onOpenAutoFocus:w,onCloseAutoFocus:N,onEscapeKeyDown:k,onPointerDownCapture:S,onInteractOutside:C,portalContainer:_,mangaReader:R,...A}=e;return!function(e,t){let[s,a]=(0,n.useState)([]);n.useEffect(()=>{if(document.querySelector("body"))return t?a(t=>[...t,e]):a(t=>t.filter(t=>t!==e)),()=>{a(t=>t.filter(t=>t!==e))}},[t])}(n.useId(),j),(0,r.jsxs)(eQ.bL,{modal:!t,open:j,...A,children:[s&&(0,r.jsx)(eQ.l9,{asChild:!0,children:s}),(0,r.jsxs)(eQ.ZL,{container:_,children:[(0,r.jsx)(eQ.hJ,{className:b(e0.overlay(),c)}),(0,r.jsxs)(eQ.UC,{className:b(e0.content({size:y,side:R?"mangaReader":v}),!R&&"lg:m-[10px] rounded-[--radius]",u),style:{marginTop:void 0,height:void 0},onOpenAutoFocus:w,onCloseAutoFocus:N,onEscapeKeyDown:k,onPointerDownCapture:S,onInteractOutside:C,tabIndex:-1,
1children:[a||i?(0,r.jsxs)("div",{className:b(e0.header(),p),children:[(0,r.jsx)(eQ.hE,{className:b(e0.title(),!1,x),children:a}),i&&(0,r.jsx)(eQ.VY,{className:b(e0.description(),g),children:i})]}):(0,r.jsx)(eX.s6,{children:(0,r.jsx)(eQ.hE,{children:"Drawer"})}),o,l&&(0,r.jsx)("div",{className:b(e0.footer(),h),children:l}),!f&&(0,r.jsx)(eQ.bm,{className:b(e0.close(),m),asChild:!0,children:d||(0,r.jsx)(T,{})})]})]})]})}e1.displayName="Drawer";let e2=n.createContext({open:!1,setOpen:()=>{},setSize:()=>{},size:"md",isBelowBreakpoint:!1});function e3(){let e=n.useContext(e2);if(!e)throw Error("useAppSidebarContext must be used within a AppSidebarProvider");return e}let e6={sidebar:(0,h.F)(["UI-AppSidebar__sidebar","flex flex-grow flex-col overflow-y-auto border-r border-transparent bg-[--background]"])},e5={trigger:(0,h.F)(["UI-AppSidebarTrigger__trigger","block lg:hidden","items-center justify-center rounded-[--radius] p-2 text-[--muted] hover:bg-[--subtle] hover:text-[--foreground] transition-colors","focus:outline-none focus:ring-2 focus:ring-inset focus:ring-[--ring]"])},e4=n.forwardRef((e,t)=>{let{children:s,className:a,...l}=e,i=n.useContext(e2);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{ref:t,className:b(e6.sidebar(),a),...l,children:s}),(0,r.jsx)(e1,{open:i.open,onOpenChange:e=>i.setOpen(e),side:"left",children:s})]})});e4.displayName="AppSidebar";let e9=n.forwardRef((e,t)=>{let{children:s,className:a,...l}=e,i=n.useContext(e2);return(0,r.jsxs)("button",{ref:t,className:b(e5.trigger(),a),onClick:()=>i.setOpen(!i.open),...l,children:[(0,r.jsx)("span",{className:"sr-only",children:"Open main menu"}),i.open?(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"block h-6 w-6",children:[(0,r.jsx)("line",{x1:"18",x2:"6",y1:"6",y2:"18"}),(0,r.jsx)("line",{x1:"6",x2:"18",y1:"6",y2:"18"})]}):(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"block h-6 w-6",children:[(0,r.jsx)("line",{x1:"4",x2:"20",y1:"12",y2:"12"}),(0,r.jsx)("line",{x1:"4",x2:"20",y1:"6",y2:"6"}),(0,r.jsx)("line",{x1:"4",x2:"20",y1:"18",y2:"18"})]})]})});e9.displayName="AppSidebarTrigger";let e8=e=>{let{children:t,onOpenChange:s,onSizeChange:a}=e,[l,i]=n.useState(!1),[o,d]=n.useState(void 0),[c,u]=n.useState(!1);return n.useEffect(()=>{let e=()=>u(window.innerWidth<1024);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[c]),(0,r.jsx)(e2.Provider,{value:{open:l,setOpen:e=>{null==s||s(e),i(e)},setSize:e=>{null==a||a(e),d(e)},size:o,isBelowBreakpoint:c},children:t})};e8.displayName="AppSidebarProvider";var e7=s(5976);let te={item:(0,h.F)(["UI-Disclosure__item"]),contentContainer:(0,h.F)(["UI-Disclosure__contentContainer","overflow-hidden transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"]),content:(0,h.F)(["UI-Disclosure__content"])},tt=n.createContext({}),ts=n.forwardRef((e,t)=>{let{contentContainerClass:s,contentClass:a,itemClass:n,...l}=e;return(0,r.jsx)(tt.Provider,{value:{itemClass:n,contentContainerClass:s,contentClass:a},children:(0,r.jsx)(e7.bL,{ref:t,...l})})});ts.displayName="Disclosure";let ta=n.forwardRef((e,t)=>{let{className:s,...a}=e,{itemClass:l}=n.useContext(tt);return(0,r.jsx)(e7.q7,{ref:t,className:b(te.item(),l,s),...a})});ta.displayName="DisclosureItem";let tr=n.forwardRef((e,t)=>(0,r.jsx)(e7.Y9,{asChild:!0,children:(0,r.jsx)(e7.l9,{ref:t,asChild:!0,...e})}));tr.displayName="DisclosureTrigger";let tn=n.forwardRef((e,t)=>{let{className:s,contentContainerClass:a,children:l,...i}=e,{contentContainerClass:o,contentClass:d}=n.useContext(tt);return(0,r.jsx)(e7.UC,{ref:t,className:b(te.contentContainer(),o,a),...i,children:(0,r.jsx)("div",{className:b(te.content(),d,s),children:l})})});tn.displayName="DisclosureContent";var tl=s(5191);let ti={root:(0,h.F)(["UI-Tooltip__root","z-50 overflow-hidden rounded-[--radius] px-3 py-1.5 text-sm shadow-md animate-in fade-in-50","bg-gray-800 text-white","data-[side=bottom]:slide-in-from-top-1 data-[side=left]:slide-in-from-right-1","data-[side=right]:sli
1de-in-from-left-1 data-[side=top]:slide-in-from-bottom-1"])},to=n.forwardRef((e,t)=>{let{children:s,className:a,trigger:n,delayDuration:l=50,disableHoverableContent:i,defaultOpen:o,open:d,onOpenChange:c,...u}=e;return(0,r.jsx)(td,{children:(0,r.jsxs)(tl.bL,{delayDuration:l,disableHoverableContent:i,defaultOpen:o,open:d,onOpenChange:c,children:[(0,r.jsx)(tl.l9,{asChild:!0,children:n}),(0,r.jsx)(tl.ZL,{children:(0,r.jsx)(tl.UC,{ref:t,className:b(ti.root(),a),...u,children:s})})]})})});to.displayName="Tooltip";let td=tl.Kq;var tc=s(2248);let tu={root:(0,h.F)(["UI-HoverCard__root","z-50 w-64 rounded-xl text-sm border bg-[--paper] p-4 shadow-sm outline-none","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0","data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-100 data-[state=open]:zoom-in-95","data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2","data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"])},tm=n.forwardRef((e,t)=>{let{className:s,align:a="center",sideOffset:n=8,openDelay:l=1e3,closeDelay:i=0,trigger:o,...d}=e;return(0,r.jsxs)(tc.bL,{openDelay:l,closeDelay:i,children:[(0,r.jsx)(tc.l9,{asChild:!0,children:o}),(0,r.jsx)(tc.ZL,{children:(0,r.jsx)(tc.UC,{ref:t,align:a,sideOffset:n,className:b(tu.root(),s),...d})})]})});tm.displayName="HoverCard";var tp=s(5591),th=s(8364);let tx={root:(0,h.F)(["UI-VerticalMenu__root","flex flex-col gap-1"]),item:(0,h.F)(["UI-VerticalMenu__item","group/verticalMenu_item relative flex flex-none truncate items-center w-full font-medium rounded-[--radius] transition cursor-pointer","hover:text-[--foreground]","focus-visible:bg-[--subtle] outline-none text-[--muted]","data-[current=true]:bg-[--subtle] data-[current=true]:text-[--foreground]"],{variants:{collapsed:{true:"justify-center",false:null},isSidebar:{true:"rounded-full",false:"hover:bg-[--subtle]"}},defaultVariants:{collapsed:!1,isSidebar:!1}}),itemContent:(0,h.F)(["UI-VerticalMenu__itemContent","w-full flex items-center relative"],{variants:{size:{sm:"px-3 h-8 text-sm",md:"px-3 h-10 text-sm",lg:"px-3 h-12 text-base"},collapsed:{true:"justify-center",false:null},isSidebar:{true:"",false:null}},defaultVariants:{size:"md",collapsed:!1,isSidebar:!1}}),parentItem:(0,h.F)(["UI-VerticalMenu__parentItem","group/verticalMenu_parentItem","cursor-pointer w-full"]),itemChevron:(0,h.F)(["UI-VerticalMenu__itemChevron","size-4 absolute transition-transform group-data-[state=open]/verticalMenu_parentItem:rotate-90"],{variants:{size:{sm:"right-3",md:"right-3",lg:"right-3"},collapsed:{true:"top-1 left-1 size-3",false:null}},defaultVariants:{size:"md",collapsed:!1}}),itemIcon:(0,h.F)(["UI-VerticalMenu__itemIcon","flex-shrink-0 mr-3 transition","text-[--muted] text-xl","group-hover/verticalMenu_item:text-[--foreground]","group-data-[current=true]/verticalMenu_item:text-[--foreground]"],{variants:{size:{sm:"size-5",md:"size-6",lg:"size-7"},collapsed:{true:"mr-0",false:null},isSidebar:{true:"group-hover/verticalMenu_item:scale-[1.05] group-hover/verticalMenu_item:-rotate-2",false:null}},defaultVariants:{size:"md",isSidebar:!1}}),subContent:(0,h.F)(["UI-VerticalMenu__subContent","border-b py-1"])},tg=n.createContext({}),tf=n.forwardRef((e,t)=>{let{children:s,size:a="md",collapsed:l,onItemSelect:i,itemClass:o,itemIconClass:d,parentItemClass:c,subContentClass:u,itemChevronClass:m,itemContentClass:p,itemTooltipProps:h,className:x,items:g,isSidebar:f,...v}=e,{onItemSelect:y,collapsed:j,isSidebar:w}=(0,n.useContext)(tg),N=l??j??!1,k=f??w??!1,S=e=>t=>{var s;null==i||i(e),null==y||y(e),null==(s=e.onClick)||s.call(e,t)},C=n.useCallback(e=>N?e.flyout?(0,r.jsx)(tm,{trigger:e.children,side:"right",align:"center",openDelay:120,closeDelay:120,className:"w-auto border-0 bg-transparent p-0 shadow-none",children:e.flyout}):(0,r.jsx)(to,{trigger:e.children,side:"right",...h,children:e.name}):e.children,[N,h]),_=n.useCallback(e=>(0,r.jsx)(C,{name:e.name,flyout:e.flyout,children:(0,r.jsxs)("div",{"data-vertical-menu-item":e.name,className:b(tx.itemContent({size:a,c
1ollapsed:N,isSidebar:k}),p),children:[e.iconType&&(0,r.jsx)(e.iconType,{className:b(tx.itemIcon({size:a,collapsed:N,isSidebar:k}),d),"aria-hidden":"true","data-current":e.isCurrent}),!N&&(0,r.jsx)("span",{children:e.name}),e.addon]})}),[N,a,p,d,k]);return(0,r.jsx)("nav",{ref:t,className:b(tx.root(),x),role:"navigation",...v,children:(0,r.jsx)(tg.Provider,{value:{onItemSelect:i,collapsed:l??!1,isSidebar:f??!1},children:g.map((e,t)=>(0,r.jsx)(n.Fragment,{children:e.subItems&&e.subItems.length>0?(0,r.jsxs)("div",{className:b("flex flex-col",k&&e.expanded&&"gap-1 rounded-3xl border border-[--border] bg-[--paper] p-1 shadow-sm"),children:[(0,r.jsx)("button",{className:b(tx.item({collapsed:N,isSidebar:k}),o),"data-current":e.isCurrent,onClick:S(e),"data-vertical-menu-item-button":e.name,children:(0,r.jsx)(_,{...e})}),(0,r.jsx)(tp.N,{initial:!1,children:e.expanded&&(0,r.jsx)(th.P.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeOut"},className:"flex flex-col gap-1 overflow-hidden",children:e.subItems.map((e,t)=>(0,r.jsx)("button",{className:b(tx.item({collapsed:N,isSidebar:k}),o),"data-current":e.isCurrent,onClick:S(e),"data-vertical-menu-item-button":e.name,children:(0,r.jsx)(_,{...e})},e.name+t))},"subitems")})]}):e.subContent?(0,r.jsx)(ts,{type:"multiple",children:(0,r.jsxs)(ta,{value:e.name,children:[(0,r.jsx)(tr,{children:(0,r.jsxs)("button",{className:b(tx.item({collapsed:N,isSidebar:k}),o,tx.parentItem(),c),"aria-current":e.isCurrent?"page":void 0,"data-current":e.isCurrent,onClick:S(e),children:[(0,r.jsx)(_,{...e}),(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:b(tx.itemChevron({size:a,collapsed:N}),m),children:(0,r.jsx)("polyline",{points:"9 18 15 12 9 6"})})]})}),(0,r.jsx)(tn,{className:b(tx.subContent(),u),children:e.subContent})]})}):(0,r.jsx)("button",{className:b(tx.item({collapsed:N,isSidebar:k}),o),"data-current":e.isCurrent,onClick:S(e),"data-vertical-menu-item-button":e.name,children:(0,r.jsx)(_,{...e})})},e.name+t))})})});function tb(e){let{header:t,items:s,footerItems:a,footer:n,onItemSelect:l,onFooterItemSelect:i,className:o}=e,d=e3(),c=!d.isBelowBreakpoint;return(0,r.jsxs)(e4,{className:b("h-full flex flex-col justify-between w-full",!d.isBelowBreakpoint&&"bg-transparent",o),children:[(0,r.jsxs)("div",{children:[t,(0,r.jsx)(tf,{className:"px-4",collapsed:c,isSidebar:!0,itemClass:"relative",items:s,onItemSelect:e=>{null==l||l(e),d.setOpen(!1)}})]}),((null==a?void 0:a.length)||n)&&(0,r.jsxs)("div",{className:"p-4 gap-2 flex flex-col",children:[a&&a.length>0&&(0,r.jsx)(tf,{collapsed:c,isSidebar:!0,itemClass:"relative",items:a,onItemSelect:e=>{null==i||i(e),d.setOpen(!1)}}),n]})]})}tf.displayName="VerticalMenu";let tv={overlay:(0,h.F)(["UI-Modal__overlay","fixed inset-0 z-50 bg-black/80","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"]),content:(0,h.F)(["UI-Modal__content","z-50 grid relative w-full w-full shadow-xl border border-[rgb(255_255_255_/_5%)] max-w-lg gap-4 bg-[--background] p-6 shadow-xl duration-200","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95","sm:rounded-xl"]),close:(0,h.F)(["UI-Modal__close","absolute right-4 top-4 !mt-0"]),header:(0,h.F)(["UI-Modal__header","flex flex-col space-y-1.5 text-center sm:text-left"]),footer:(0,h.F)(["UI-Modal__footer","flex flex-col-reverse gap-2 sm:flex-row sm:justify-end"]),title:(0,h.F)(["UI-Modal__title","text-xl font-semibold leading-none tracking-tight"]),description:(0,h.F)(["UI-Modal__description","text-sm text-[--muted]"])};function ty(e){let{allowOutsideInteraction:t=!1,trigger:s,title:a,footer:l,description:i,children:o,closeButton:d,overlayClass:c,contentClass:u,closeClass:m,headerClass:p,footerClass:h,titleClass:x,descriptionClass:g,hideCloseButton:f,onOpenAutoFocus:v,onCloseAutoFocus:y,onEscapeKeyDown:j,onPointerDownCapture:w,onInteractOutside:N,...k}=e,S=n.useRef(!1);return(0,r.jsxs)(eQ.bL,{modal:!t,...k,children:[s&&(0,r.jsx)(eQ.l9,{asChild:!0,children:s}
1),(0,r.jsxs)(eQ.ZL,{children:[(0,r.jsx)(tj,{targetRef:S}),(0,r.jsx)(eQ.hJ,{className:b(tv.overlay(),c),children:(0,r.jsx)("div",{className:b("overflow-y-auto absolute inset-0 grid place-items-center p-0 md:p-4",!1),children:(0,r.jsxs)(eQ.UC,{className:b(tv.content(),u),onOpenAutoFocus:v,onCloseAutoFocus:y,onEscapeKeyDown:j,onPointerDownCapture:w,onInteractOutside:e=>{if(S.current){S.current=!1,e.preventDefault();return}null==N||N(e)},children:[a||i?(0,r.jsxs)("div",{className:b(tv.header(),p),children:[(0,r.jsx)(eQ.hE,{className:b(tv.title(),x),children:a}),i&&(0,r.jsx)(eQ.VY,{className:b(tv.description(),g),children:i})]}):(0,r.jsx)(eX.s6,{children:(0,r.jsx)(eQ.hE,{children:"Dialog"})}),o,l&&(0,r.jsx)("div",{className:b(tv.footer(),h),children:l}),!f&&(0,r.jsx)(eQ.bm,{className:b(tv.close(),m),asChild:!0,children:d||(0,r.jsx)(T,{})})]})})})]})]})}function tj(e){let{targetRef:t}=e;return n.useEffect(()=>{let e=()=>{t.current=!!document.querySelector('[role="listbox"][data-state="open"],[role="menu"][data-state="open"],[data-radix-popper-content-wrapper]:not(:has([role="tooltip"]))')};return document.addEventListener("pointerdown",e,!0),()=>document.removeEventListener("pointerdown",e,!0)},[t]),null}function tw(e,t){let[s,a]=(0,n.useState)(e),r=()=>{if(!s){var e;a(!0),null==t||null==(e=t.onOpen)||e.call(t)}},l=()=>{if(s){var e;a(!1),null==t||null==(e=t.onClose)||e.call(t)}};return{isOpen:s,open:r,close:l,toggle:()=>{s?l():r()}}}function tN(e){return{...tw(!1),...e}}ty.displayName="Modal";let tk=e=>{let{isOpen:t,close:s,onConfirm:a,title:n,description:l="Are you sure you want to continue?",actionText:i="Confirm",actionIntent:o="alert-subtle"}=e;return(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(ty,{title:n,titleClass:"text-center",open:t,onOpenChange:s,children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("p",{className:"text-center break-words",children:l}),(0,r.jsxs)("div",{className:"flex gap-2 justify-center items-center",children:[(0,r.jsx)(w,{intent:o,onClick:()=>{a(),s()},children:i}),(0,r.jsx)(w,{intent:"white",onClick:s,children:"Cancel"})]})]})})})};function tS(){let e=(0,o.jE)(),{data:t,isLoading:s}=(0,eU.I)(eP),a=(0,n.useCallback)(async()=>{await e.invalidateQueries({queryKey:eP.queryKey})},[e]),{mutateAsync:r}=(0,eE.n)({mutationFn:ed,onSettled:()=>{e.removeQueries({queryKey:eP.queryKey})}});return{user:t??null,loading:s,refresh:a,signOut:(0,n.useCallback)(async()=>{await r()},[r])}}var tC=s(8368);function t_(){return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{"data-layout-header-background":!0,className:b("bg-[#000] opacity-50 bg-contain bg-center bg-repeat z-[-2] w-full h-[20rem] absolute bottom-0")}),(0,r.jsx)("div",{"data-layout-header-background-gradient":!0,className:"w-full absolute bottom-0 h-[8rem] bg-gradient-to-t from-[--background] to-transparent z-[-2]"})]})}let tR=[{id:"library",label:"Library",icon:tC.X6x},{id:"stats",label:"Stats",icon:tC.yWU},{id:"providers",label:"Providers",icon:tC.nmg},{id:"settings",label:"Settings",icon:tC.nMM}],tA=[{id:"sources",label:"Sources",icon:tC.Azn},{id:"publishing",label:"Publishing",icon:tC.K0Y},{id:"entries",label:"Entries",icon:tC.XfR}],tT=[{id:"active",label:"Active",icon:tC.U2S},{id:"history",label:"History",icon:tC.grf},{id:"bandwidth",label:"Bandwidth",icon:tC.yWU},{id:"bans",label:"Blocks",icon:tC.PLI}],tI=[{label:"Overview",href:"/dashboard",icon:tC.fiy},{label:"Analytics",href:"/dashboard/analytics",icon:tC.yWU},{label:"Logs",href:"/dashboard/logs",icon:tC.XfR},{label:"System",href:"/dashboard/system",icon:tC.nmg},{label:"Users",href:"/dashboard/users",icon:tC.hTi},{label:"Tasks",href:"/dashboard/tasks",icon:tC.bZV},{label:"Cache",href:"/dashboard/cache",icon:tC.Wwx},{label:"Streams",href:"/dashboard/streams",icon:tC.U2S},{label:"Usenet",href:"/dashboard/usenet",icon:tC.hQe},{label:"Blocklists",href:"/dashboard/blocklist",icon:tC.PLI},{label:"Settings",href:"/dashboard/settings",icon:tC.nMM}],tE={"/dashboard/streams":tT,"/dashboard/usenet":tR,"/dashboard/blocklist":tA};function tM(){let[e,t]=(0,n.useState)(!1),s=(0,n.useCallback)(()=>t(!0),[]),a=(0,n.useCallback)(()=>t(!1),[]),r=(0,n.useCallback)(()=>t(e=>!e),[]);return(0,n.useEffect)(()=>{let e=e=>
1{(e.ctrlKey||e.metaKey)&&("k"===e.key||"K"===e.key)&&(e.preventDefault(),t(e=>!e))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]),{isOpen:e,open:s,close:a,toggle:r}}let tP=(0,n.createContext)({isOpen:!1,open:()=>{},close:()=>{},toggle:()=>{}});function tD(e){let{children:t}=e,s=tM();return(0,r.jsx)(tP.Provider,{value:s,children:t})}let tL=()=>(0,n.useContext)(tP);var tU=s(988);let t$={root:(0,h.F)(["UI-Command__root","flex h-full w-full flex-col overflow-hidden rounded-[--radius-md] bg-[--paper] text-[--foreground]"]),inputContainer:(0,h.F)(["UI-Command__input","flex items-center px-3 py-2","cmdk-input-wrapper"]),inputIcon:(0,h.F)(["UI-Command__inputIcon","mr-2 h-5 w-5 shrink-0 opacity-50"]),list:(0,h.F)(["UI-Command__list","max-h-[300px] overflow-y-auto overflow-x-hidden"]),empty:(0,h.F)(["UI-Command__empty","py-6 text-center text-base text-[--muted]"]),group:(0,h.F)(["UI-Command__group","overflow-hidden p-1 text-[--foreground]","[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-sm [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-[--muted]"]),separator:(0,h.F)(["UI-Command__separator","-mx-1 h-px bg-[--border]"]),item:(0,h.F)(["UI-Command__item","relative flex cursor-default select-none items-center rounded-[--radius] px-2 py-1.5 text-base outline-none","aria-selected:bg-[--subtle] data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50","[&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0"]),itemIconContainer:(0,h.F)(["UI-Command__itemIconContainer","mr-2 text-base shrink-0 w-4"]),shortcut:(0,h.F)(["UI-Command__shortcut","ml-auto text-xs tracking-widest text-[--muted]"])},tO={content:(0,h.F)(["UI-CommandDialog__content","overflow-hidden p-0"]),command:(0,h.F)(["UI-CommandDialog__command","[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-[--muted]","[&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pb-2 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5","[&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-2 [&_[cmdk-item]_svg]:h-4 [&_[cmdk-item]_svg]:w-5"])},tF=n.createContext({}),tz=n.forwardRef((e,t)=>{let{className:s,inputContainerClass:a,inputIconClass:n,listClass:l,emptyClass:i,groupClass:o,separatorClass:d,itemClass:c,itemIconContainerClass:u,shortcutClass:m,loop:p=!0,...h}=e;return(0,r.jsx)(tF.Provider,{value:{inputContainerClass:a,inputIconClass:n,listClass:l,emptyClass:i,groupClass:o,separatorClass:d,itemClass:c,itemIconContainerClass:u,shortcutClass:m},children:(0,r.jsx)(tU.uB,{ref:t,className:b(t$.root(),s),loop:p,...h})})});tz.displayName=tU.uB.displayName;let tV=n.forwardRef((e,t)=>{let{className:s,inputContainerClass:a,inputIconClass:l,...i}=e,{inputContainerClass:o,inputIconClass:d}=n.useContext(tF);return(0,r.jsxs)("div",{className:b(t$.inputContainer(),o,a),"cmdk-input-wrapper":"",children:[(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:b(t$.inputIcon(),d,l),children:[(0,r.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,r.jsx)("path",{d:"m21 21-4.3-4.3"})]}),(0,r.jsx)(tU.uB.Input,{ref:t,className:b(z.root({intent:"unstyled",size:"sm",isDisabled:i.disabled}),s),...i})]})});tV.displayName="CommandInput";let tq=n.forwardRef((e,t)=>{let{className:s,...a}=e,{listClass:l}=n.useContext(tF);return(0,r.jsx)(tU.uB.List,{ref:t,className:b(t$.list(),l,s),...a})});tq.displayName="CommandList";let tB=n.forwardRef((e,t)=>{let{className:s,...a}=e,{emptyClass:l}=n.useContext(tF);return(0,r.jsx)(tU.uB.Empty,{ref:t,className:b(t$.empty(),l,s),...a})});tB.displayName="CommandEmpty";let tK=n.forwardRef((e,t)=>{let{className:s,...a}=e,{groupClass:l}=n.useContext(tF);return(0,r.jsx)(tU.uB.Group,{ref:t,className:b(t$.group(),l,s),...a})});tK.displayName="CommandGroup",n.forwardRef((e,t)=>{let{className:s,...a}=e,{separatorClass:l}=n.useContext(tF);return(0,r.jsx)(tU.uB.Separator,{ref:t,className:b(t$.separator(),l,s),...a}
1)}).displayName="CommandSeparator";let tH=n.forwardRef((e,t)=>{let{className:s,itemIconContainerClass:a,leftIcon:l,children:i,...o}=e,{itemClass:d,itemIconContainerClass:c}=n.useContext(tF),u=n.useRef(null);n.useEffect(()=>{let e=u.current;if(!e)return;let t=new MutationObserver(t=>{t.forEach(t=>{"aria-selected"===t.attributeName&&"true"===e.getAttribute("aria-selected")&&e.scrollIntoView({block:"nearest"})})});return t.observe(e,{attributes:!0}),()=>t.disconnect()},[]);let m=n.useCallback(e=>{u.current=e,t&&"function"==typeof t&&t(e)},[t]);return(0,r.jsxs)(tU.uB.Item,{ref:m,className:b(t$.item(),d,s),...o,"data-cmdkvalue":o.id,children:[l&&(0,r.jsx)("span",{className:b(t$.itemIconContainer(),c,a),children:l}),i]})});tH.displayName="CommandItem";let tG=n.forwardRef((e,t)=>{let{className:s,...a}=e,{shortcutClass:l}=n.useContext(tF);return(0,r.jsx)("span",{ref:t,className:b(t$.shortcut(),l,s),...a})});tG.displayName="CommandShortcut";let tW=e=>{let{children:t,commandClass:s,contentClass:a,commandProps:n,...l}=e;return(0,r.jsx)(ty,{...l,contentClass:b(tO.content(),a),children:(0,r.jsx)(tz,{shouldFilter:!1,className:b(tO.command(),s),...n,children:t})})};tW.displayName="CommandDialog";let tY=n.createContext(void 0),tJ="aiostreams-mode",tZ="aiostreams-first-time";function tQ(e){let{children:t}=e,[s,a]=n.useState(()=>"u">typeof window&&localStorage.getItem(tJ)||"noob"),[l,i]=n.useState(()=>!("u">typeof window)||null===localStorage.getItem(tZ)),o=n.useCallback(e=>{a(e),"u">typeof window&&localStorage.setItem(tJ,e)},[]),d=n.useCallback(e=>{i(e),"u">typeof window&&!e&&localStorage.setItem(tZ,"false")},[]);return(0,r.jsx)(tY.Provider,{value:{mode:s,setMode:o,isFirstTime:l,setIsFirstTime:d},children:t})}function tX(){let e=n.useContext(tY);if(void 0===e)throw Error("useMode must be used within a ModeProvider");return e}let t0={excludedResolutions:{label:"Excluded Resolutions",group:"filters",type:"list",menu:"filters",subTab:"resolution"},includedResolutions:{label:"Included Resolutions",group:"filters",type:"list",menu:"filters",subTab:"resolution"},requiredResolutions:{label:"Required Resolutions",group:"filters",type:"list",menu:"filters",subTab:"resolution"},preferredResolutions:{label:"Preferred Resolutions",group:"filters",type:"list",menu:"filters",subTab:"resolution"},excludedQualities:{label:"Excluded Qualities",group:"filters",type:"list",menu:"filters",subTab:"qual
1ity"},includedQualities:{label:"Included Qualities",group:"filters",type:"list",menu:"filters",subTab:"quality"},requiredQualities:{label:"Required Qualities",group:"filters",type:"list",menu:"filters",subTab:"quality"},preferredQualities:{label:"Preferred Qualities",group:"filters",type:"list",menu:"filters",subTab:"quality"},excludedLanguages:{label:"Excluded Languages",group:"filters",type:"list",menu:"filters",subTab:"language"},includedLanguages:{label:"Included Languages",group:"filters",type:"list",menu:"filters",subTab:"language"},requiredLanguages:{label:"Required Languages",group:"filters",type:"list",menu:"filters",subTab:"language"},preferredLanguages:{label:"Preferred Languages",group:"filters",type:"list",menu:"filters",subTab:"language"},excludedSubtitles:{label:"Excluded Subtitles",group:"filters",type:"list",menu:"filters",subTab:"subtitle",keywords:["subs"]},includedSubtitles:{label:"Included Subtitles",group:"filters",type:"list",menu:"filters",subTab:"subtitle",keywords:["subs"]},requiredSubtitles:{label:"Required Subtitles",group:"filters",type:"list",menu:"filters",subTab:"subtitle",keywords:["subs"]},preferredSubtitles:{label:"Preferred Subtitles",group:"filters",type:"list",menu:"filters",subTab:"subtitle",keywords:["subs"]},excludedVisualTags:{label:"Excluded Visual Tags",group:"filters",type:"list",menu:"filters",subTab:"visual-tag",keywords:["hdr","dolby vision","dv"]},includedVisualTags:{label:"Included Visual Tags",group:"filters",type:"list",menu:"filters",subTab:"visual-tag",keywords:["hdr","dolby vision","dv"]},requiredVisualTags:{label:"Required Visual Tags",group:"filters",type:"list",menu:"filters",subTab:"visual-tag",keywords:["hdr","dolby vision","dv"]},preferredVisualTags:{label:"Preferred Visual Tags",group:"filters",type:"list",menu:"filters",subTab:"visual-tag",keywords:["hdr","dolby vision","dv"]},excludedAudioTags:{label:"Excluded Audio Tags",group:"filters",type:"list",menu:"filters",subTab:"audio-tag",keywords:["atmos","dts","truehd"]},includedAudioTags:{label:"Included Audio Tags",group:"filters",type:"list",menu:"filters",subTab:"audio-tag",keywords:["atmos","dts","truehd"]},requiredAudioTags:{label:"Required Audio Tags",group:"filters",type:"list",menu:"filters",subTab:"audio-tag",keywords:["atmos","dts","truehd"]},preferredAudioTags:{label:"Preferred Audio Tags",group:"filters",type:"list",menu:"filters",subTab:"audio-tag",keywords:["atmos","dts","truehd"]},excludedAudioChannels:{label:"Excluded Audio Channels",group:"filters",type:"list",menu:"filters",subTab:"audio-channel"},includedAudioChannels:{label:"Included Audio Channels",group:"filters",type:"list",menu:"filters",subTab:"audio-channel"},requiredAudioChannels:{label:"Required Audio Channels",group:"filters",type:"list",menu:"filters",subTab:"audio-channel"},preferredAudioChannels:{label:"Preferred Audio Channels",group:"filters",type:"list",menu:"filters",subTab:"audio-channel"},excludedStreamTypes:{label:"Excluded Stream Types",group:"filters",type:"list",menu:"filters",subTab:"stream-type"},includedStreamTypes:{label:"Included Stream Types",group:"filters",type:"list",menu:"filters",subTab:"stream-type"},requiredStreamTypes:{label:"Required Stream Types",group:"filters",type:"list",menu:"filters",subTab:"stream-type"},preferredStreamTypes:{label:"Preferred Stream Types",group:"filters",type:"list",menu:"filters",subTab:"stream-type"},excludedEncodes:{label:"Excluded Encodes",group:"filters",type:"list",menu:"filters",subTab:"encode"},includedEncodes:{label:"Included Encodes",group:"filters",type:"list",menu:"filters",subTab:"encode"},requiredEncodes:{label:"Required Encodes",group:"filters",type:"list",menu:"filters",subTab:"encode"},preferredEncodes:{label:"Preferred Encodes",group:"filters",type:"list",menu:"filters",subTab:"encode"},excludedKeywords:{label:"Excluded Keywords",group:"filters",type:"list",menu:"filters",subTab:"keyword"},includedKeywords:{label:"Included Keywords",group:"filters",type:"list",menu:"filters",subTab:"keyword"},requiredKeywords:{label:"Required Keywords",group:"filters",type:"list",menu:"filters",subTab:"keyword"},preferredKeywords:{label:"Preferred Keywords",group:"filters",type:"list",menu:"filters",subTab:"keyword"},excludedReleaseGroups:{label:"Excluded Release Groups",group:"filters",type:"list",menu:"filters",subTab:"release-group"},includedReleaseGroups:{label:"Included Release Groups",group:"filters",type:"list",menu:"filters",subTab:"release-group"},requiredReleaseGroups:{label:"Required Release Groups",group:"filters",type:"list",menu:"filters",subTab:"release-group"},preferredReleaseGroups:{label:"Preferred Release Groups",group:"filters",type:"list",menu:"filters",subTab:"release-group"},excludedRegexPatterns:{label:"Excluded Regex Patterns",group:"filters",type:"list",menu:"filters",subTab:"regex"},includedRegexPatterns:{label:"Included Regex Patterns",group:"filters",type:"list",menu:"filters",subTab:"regex"},requiredRegexPatterns:{label:"Required Regex Patterns",group:"filters",type:"list",menu:"filters",subTab:"regex"},preferredRegexPatterns:{label:"Preferred Regex Patterns",group:"filters",type:"list",identityKey:"pattern",menu:"filters",subTab:"regex"},rankedRegexPatterns:{label:"Ranked Regex Patterns",group:"filters",type:"list",identityKey:"pattern",menu:"filters",subTab:"regex"},regexOverrides:{label:"Regex Overrides",group:"filters",type:"list",identityKey:"pattern",menu:"filters",subTab:"regex"},syncedExcludedRegexUrls:{label:"Synced Excluded Regex URLs",group:"filters",type:"list",menu:"filters",subTab:"regex"},syncedIncludedRegexUrls:{label:"Synced Included Regex URLs",group:"filters",type:"list",menu:"filters",subTab:"regex"},syncedRequiredRegexUrls:{label:"Synced Required Regex URLs",group:"filters",type:"list",menu:"filters",subTab:"regex"},syncedPreferredRegexUrls:{label:"Synced Preferred Regex URLs",group:"filters",type:"list",menu:"filters",subTab:"regex"},syncedRankedRegexUrls:{label:"Synced Ranked Regex URLs",group:"filters",type:"list",menu:"filters",subTab:"regex"},excludedStreamExpressions:{label:"Excluded Stream Expressions",group:"filters",type:"list",identityKey:"expression",menu:"filters",subTab:"stream-expression",keywords:["sel"]},includedStreamExpressions:{label:"Included Stream Expressions",group:"filters",type:"list",identityKey:"expression",menu:"filters",subTab:"stream-expression",keywords:["sel"]},requiredStreamExpressions:{label:"Required Stream Expressions",group:"filters",type:"list",identityKey:"expression",menu:"filters",subTab:"stream-expression",keywords:["sel"]},preferredStreamExpressions:{label:"Preferred Stream Expressions",group:"filters",type:"list",identityKey:"expression",menu:"filters",subTab:"stream-expression",keywords:["sel"]},rankedStreamExpressions:{label:"Ranked Stream Expressions",group:"filters",type:"list",identityKey:"expression",menu:"filters",subTab:"stream-expression",keywords:["sel"]},selOverrides:{label:"Stream Expression Overrides",group:"filters",type:"list",identityKey:"expression",menu:"filters",subTab:"stream-expression"},syncedExcludedStreamExpressionUrls:{label:"Synced Excluded Expression URLs",group:"filters",type:"list",menu:"filters",subTab:"stream-expression"},syncedIncludedStreamExpressionUrls:{label:"Synced Included Expression URLs",group:"filters",type:"list",menu:"filters",subTab:"stream-expression"},syncedRequiredStreamExpressionUrls:{label:"Synced Required Expression URLs",group:"filters",type:"list",menu:"filters",subTab:"stream-expression"},syncedPreferredStreamExpressionUrls:{label:"Synced Preferred Expression URLs",group:"filters",type:"list",menu:"filters",subTab:"stream-expression"},syncedRankedStreamExpressionUrls:{label:"Synced Ranked Expression URLs",group:"filters",type:"list",menu:"filters",subTab:"stream-expression"},enableSeadex:{label:"SeaDex",group:"filters",type:"scalar",menu:"filters",subTab:"miscellaneous",keywords:["anime","releases.moe"]},excludeSeasonPacks:{label:"Exclude Season Packs",group:"filters",type:"scalar",menu:"filters",subTab:"miscellaneous",
1ignoreForCommandPalette:!0},excludeCached:{label:"Exclude Cached Streams",group:"filters",type:"scalar",menu:"filters",subTab:"cache"},excludeCachedFromAddons:{label:"Exclude Cached — From Addons",group:"filters",type:"list",menu:"filters",subTab:"cache",sectionId:"excludeCached"},excludeCachedFromServices:{label:"Exclude Cached — From Services",group:"filters",type:"list",menu:"filters",subTab:"cache",sectionId:"excludeCached"},excludeCachedFromStreamTypes:{label:"Exclude Cached — Stream Types",group:"filters",type:"list",menu:"filters",subTab:"cache",sectionId:"excludeCached"},excludeCachedMode:{label:"Exclude Cached Mode",group:"filters",type:"scalar",menu:"filters",subTab:"cache",sectionId:"excludeCached"},excludeUncached:{label:"Exclude Uncached Streams",group:"filters",type:"scalar",menu:"filters",subTab:"cache"},excludeUncachedFromAddons:{label:"Exclude Uncached — From Addons",group:"filters",type:"list",menu:"filters",subTab:"cache",sectionId:"excludeUncached"},excludeUncachedFromServices:{label:"Exclude Uncached — From Services",group:"filters",type:"list",menu:"filters",subTab:"cache",sectionId:"excludeUncached"},excludeUncachedFromStreamTypes:{label:"Exclude Uncached — Stream Types",group:"filters",type:"list",menu:"filters",subTab:"cache",sectionId:"excludeUncached"},excludeUncachedMode:{label:"Exclude Uncached Mode",group:"filters",type:"scalar",menu:"filters",subTab:"cache",sectionId:"excludeUncached"},excludeSeederRange:{label:"Exclude Seeder Range",group:"filters",type:"scalar",menu:"filters",subTab:"seeders"},includeSeederRange:{label:"Include Seeder Range",group:"filters",type:"scalar",menu:"filters",subTab:"seeders"},requiredSeederRange:{label:"Required Seeder Range",group:"filters",type:"scalar",menu:"filters",subTab:"seeders"},seederRangeTypes:{label:"Seeder Range Types",group:"filters",type:"list",menu:"filters",subTab:"seeders"},excludeAgeRange:{label:"Exclude Age Range",group:"filters",type:"scalar",menu:"filters",subTab:"age"},includeAgeRange:{label:"Include Age Range",group:"filters",type:"scalar",menu:"filters",subTab:"age"},requiredAgeRange:{label:"Required Age Range",group:"filters",type:"scalar",menu:"filters",subTab:"age"},ageRangeTypes:{label:"Age Range Types",group:"filters",type:"list",menu:"filters",subTab:"age"},digitalReleaseFilter:{label:"Digital Release Filter",group:"filters",type:"scalar",menu:"filters",subTab:"miscellaneous"},size:{label:"Size Filter",group:"filters",type:"scalar",menu:"filters",subTab:"size"},bitrate:{label:"Bitrate Filter",group:"filters",type:"scalar",menu:"filters",subTab:"bitrate"},titleMatching:{label:"Title Matching",group:"filters",type:"scalar",menu:"filters",subTab:"matching"},yearMatching:{label:"Year Matching",group:"filters",type:"scalar",menu:"filters",subTab:"matching"},seasonEpisodeMatching:{label:"Season/Episode Matching",group:"filters",type:"scalar",menu:"filters",subTab:"matching"},episodeTitleMatching:{label:"Episode Title Matching",group:"filters",type:"scalar",menu:"filters",subTab:"matching"},languageInference:{label:"Language Inference",group:"filters",type:"scalar",menu:"filters",subTab:"matching"},sortCriteria:{label:"Sort Criteria",group:"sorting",type:"scalar",menu:"sorting"},deduplicator:{label:"Deduplicator",group:"sorting",type:"scalar",menu:"filters",subTab:"deduplicator"},resultLimits:{label:"Result Limits",group:"sorting",type:"scalar",menu:"filters",subTab:"limit"},formatter:{label:"Formatter",group:"formatter",type:"scalar",menu:"formatter"},proxy:{label:"Proxy",group:"proxy",type:"scalar",menu:"proxy"},tmdbApiKey:{label:"TMDB API Key",group:"metadata",type:"scalar",menu:"services",subTab:"metadata",sectionId:"tmdb"},tmdbAccessToken:{label:"TMDB Access Token",group:"metadata",type:"scalar",menu:"services",subTab:"metadata",sectionId:"tmdb"},tvdbApiKey:{label:"TVDB API Key",group:"metadata",type:"scalar",menu:"services",subTab:"metadata"},rpdbApiKey:{label:"RPDB API Key",group:"metadata",type:"scalar",menu:"services",subTab:"posters"},topPosterApiKey:{label:"TopPoster API Key",group:"metadata",type:"scalar",menu:"services",subTab:"posters"},aioratingsApiKey:{label:"AIOratings API Key",group:"metadata",type:"scalar",menu:"services",subTab:"posters"},aioratingsProfileId:{label:"AIOratings Profile ID",group:"metadata",type:"scalar",menu:"services",subTab:"posters"},openposterdbApiKey:{label:"OpenPosterDB API Key",group:"metadata",type:"scalar",menu:"services",subTab:"posters"},openposterdbUrl:{label:"OpenPosterDB URL",group:"metadata",type:"scalar",menu:"services",subTab:"posters"},openposterdbParameters:{label:"OpenPosterDB Custom Parameters",group:"metadata",type:"scalar",menu:"services",subTab:"posters"},posterService:{label:"Poster Service",group:"metadata",type:"scalar",menu:"services",subTab:"posters"},usePosterRedirectApi:{label:"Use Poster Redirect API",group:"metadata",type:"scalar",menu:"services",subTab:"posters"},usePosterServiceForMeta:{label:"Use Poster Service for Meta",group:"metadata",type:"scalar",menu:"services",subTab:"posters"},autoPlay:{label:"Auto Play",group:"misc",type:"scalar",menu:"miscellaneous",subTab:"playback"},areYouStillThere:{label:"Are You Still There?",group:"misc",type:"scalar",menu:"miscellaneous",subTab:"playback"},statistics:{label:"Statistics",group:"misc",type:"scalar",menu:"miscellaneous",subTab:"display"},hideErrors:{label:"Hide Errors",group:"misc",type:"scalar",menu:"miscellaneous",subTab:"display"},hideErrorsForResources:{label:"Hide Errors for Resources",group:"misc",type:"list",menu:"miscellaneous",subTab:"display",sectionId:"hideErrors"},externalDownloads:{label:"External Downloads",group:"misc",type:"scalar",menu:"miscellaneous",subTab:"display"},preloadStreams:{label:"Preload Streams",group:"misc",type:"scalar",menu:"miscellaneous",subTab:"background"},precacheSelector:{label:"Precache Selector",group:"misc",type:"scalar",menu:"miscellaneous",subTab:"background"},precacheSingleStream:{label:"Precache Single Stream",group:"misc",type:"scalar",menu:"miscellaneous",subTab:"background"},dynamicAddonFetching:{label:"Dynamic Addon Fetching",group:"misc",type:"scalar",menu:"addons",subTab:"addons",sectionId:"fetchStrategy",keywords:["exit condition","dynamic fetching","fetch strategy"]},addonCategoryColors:{label:"Addon Category Colors",group:"misc",type:"scalar",menu:"addons",subTab:"addons"},catalogModifications:{label:"Catalog Modifications",group:"misc",type:"scalar",menu:"addons",subTab:"catalogs"},mergedCatalogs:{label:"Merged Catalogs",group:"misc",type:"scalar",menu:"addons",subTab:"catalogs"},failover:{label:"Failover",group:"misc",type:"scalar",menu:"services",subTab:"builtin"},serviceWrap:{label:"Service Wrap",group:"misc",type:"scalar",menu:"services",subTab:"builtin"},cacheAndPlay:{label:"Cache and Play",group:"misc",type:"scalar",menu:"services",subTab:"builtin"},autoRemoveDownloads:{label:"Auto Remove Downloads",group:"misc",type:"scalar",menu:"services",subTab:"builtin"},checkOwned:{label:"Check Owned",group:"misc",type:"scalar",menu:"services",subTab:"builtin"},accessKey:{label:"Config Access Key",group:"misc",type:"scalar",menu:"save-install"},showChanges:{label:"Show Changes",group:"misc",type:"scalar",menu:"save-install"},addonName:{label:"Addon Name",group:"branding",type:"scalar",menu:"about",keywords:["branding"]},addonLogo:{label:"Addon Logo",group:"branding",type:"scalar",menu:"about",keywords:["branding"]}
1,addonBackground:{label:"Addon Background",group:"branding",type:"scalar",menu:"about",keywords:["branding"]},addonDescription:{label:"Addon Description",group:"branding",type:"scalar",menu:"about",keywords:["branding"]},presets:{label:"Addons",group:"misc",type:"list",identityKey:"instanceId",menu:"addons",subTab:"addons",keywords:["addons","presets"],ignoreForParentConfig:!0},services:{label:"Services",group:"misc",type:"list",identityKey:"id",menu:"services",subTab:"services",ignoreForParentConfig:!0},parentConfig:{label:"Parent Config",group:"misc",type:"scalar",menu:"miscellaneous",subTab:"parent",sectionId:"parentConfig",keywords:["inherit","link","parent"],ignoreForParentConfig:!0},variants:{label:"Variants",group:"misc",type:"list",identityKey:"id",menu:"miscellaneous",subTab:"variants",sectionId:"variants",keywords:["variant","sub-profile","cel","config expression","override"],ignoreForParentConfig:!0},groups:{label:"Groups",group:"misc",type:"scalar",menu:"addons",subTab:"addons",keywords:["groupings"],ignoreForParentConfig:!0,sectionId:"fetchStrategy"}};s(8963).Buffer.from("WC1BSU9TdHJlYW1zLUludGVybmFsLVNlY3JldA==","base64").toString("utf8");let t1="count(cached(streams)) == 0 ? uncached(streams) : []",t2=["usenet"],t3=["languages","subtitles","library","seadex","sizes","idMatched"],t6="gdrive",t5="lightgdrive",t4="minimalisticgdrive",t9="torrentio",t8="torbox",t7="prism",se="tamtaro",st="custom",ss="realdebrid",sa="debridlink",sr="premiumize",sn="alldebrid",sl="torbox",si="easydebrid",so="debrider",sd="putio",sc="pikpak",su="offcloud",sm="seedr",sp="easynews",sh="nzbdav",sx="altmount",sg="stremio_nntp",sf="stremthru_newz",sb="aiostreams",sv="torrin",sy=[ss,sa,sr,sn,sl,si,so,sd,sc,su,sm,sp,sh,sx,sg,sf,sb,sv],sj=[ss,sa,sr,sn,sl,si,so,sc,su,sh,sx,sg,sp,sf,sb,sv],sw="mediaflow",sN="stremthru",sk="builtin",sS={[sk]:{id:sk,name:"Builtin Proxy",description:"A proxy service that is built into the core of AIOStreams",credentialDescription:"A valid username:password pair for this AIOStreams instance, defined in the `AIOSTREAMS_AUTH` environment variable."},[sN]:{id:sN,name:"StremThru",description:"[StremThru](https://github.com/MunifTanjim/stremthru) is a feature packed companion to Stremio which also offers a HTTP proxy, written in Go.",credentialDescription:"A valid username:password pair for your StremThru instance, defined in the `STREMTHRU_PROXY_AUTH` environment variable."},[sw]:{id:sw,name:"MediaFlow Proxy",description:"[MediaFlow Proxy](https://github.com/mhdzumair/mediaflow-proxy) is a high performance proxy server which supports HTTP, HLS, and more.",credentialDescription:"The value of your MediaFlow Proxy instance `API_PASSWORD` environment variable."}},sC={[ss]:{id:ss,name:"Real-Debrid",shortName:"RD",knownNames:["RD","Real Debrid","RealDebrid","Real-Debrid"],signUpText:"Don't have an account? [Sign up here](https://real-debrid.com/?id=9483829)",credentials:[{id:"apiKey",name:"API Key",description:"The API key for the Real-Debrid service. Obtain it from [here](https://real-debrid.com/apitoken)",type:"password",required:!0}]},[sn]:{id:sn,name:"AllDebrid",shortName:"AD",knownNames:["AD","All Debrid","AllDebrid","All-Debrid"],signUpText:"Don't have an account? [Sign up here](https://alldebrid.com/?uid=3n8qa&lang=en)",credentials:[{id:"apiKey",name:"API Key",description:"The API key for the All-Debrid service. Create one [here](https://alldebrid.com/apikeys)",type:"password",required:!0}]},[sr]:{id:sr,name:"Premiumize",shortName:"PM",knownNames:["PM","Premiumize"],signUpText:"Don't have an account? [Sign up here](https://www.premiumize.me/register)",credentials:[{id:"apiKey",name:"API Key",description:"Your Premiumize API key. Obtain it from [here](https://www.premiumize.me/account)",type:"password",required:!0}]},[sa]:{id:sa,name:"Debrid-Link",shortName:"DL",knownNames:["DL","Debrid Link","DebridLink","Debrid-Link"],signUpText:"Don't have an account? [Sign up here](https://debrid-link.com/id/EY0JO)",credentials:[{id:"apiKey",name:"API Key",description:"Your Debrid-Link API key. Obtain it from [here](https://debrid-link.com/webapp/apikey)",type:"password",required:!0}]},[sl]:{id:sl,name:"TorBox",shortName:"TB",knownNames:["TB","TorBox","Torbox","TRB"],signUpText:"Don't have an account? [Sign up here](https://torbox.app/subscription?referral=9ca21adb-dbcb-4fb0-9195-412a5f3519bc) or use my referral code `9ca21adb-dbcb-4fb0-9195-412a5f3519bc`.",credentials:[{id:"apiKey",name:"API Key",description:"Your Torbox API key. Obtain it from [here](https://torbox.app/settings)",type:"password",required:!0}]},[sg]:{id:sg,name:"Stremio NNTP",shortName:"SN",knownNames:["SN","Stremio NNTP","StremioNntp","Stremio-NNTP"],signUpText:"Stream usenet directly from your provider via Stremio's NNTP client.",credentials:[{id:"note",name:"",description:"This is a new Stremio feature that allows Stremio to connect directly to Usenet NNTP servers you provide. It is currently [only supported on Stremio V5 Desktop](https://blog.stremio.com/stremio-new-stream-sources-usenet-rar-zip-ftp-and-more/).",type:"alert",intent:"warning"},{id:"servers",name:"NNTP Servers",description:"Provide your Usenet NNTP server addresses",type:"custom-nntp-servers",required:!0}]},[sh]:{id:sh,name:"NzbDAV",shortName:"ND",knownNames:["ND"],signUpText:"Stream usenet directly from your provider via Nzb DAV.",credentials:[{id:"note",name:"Configuration Help",description:`**URL:** Use internal URL for local setups (e.g., http://nzbdav:3000), otherwise use a public URL.
2
3**Public URL:** Only needed if URL is local but streams need to be publicly accessible. Leave blank if URL is public or using a proxy.
4
5**Security Note:** WebDAV credentials are exposed in stream URLs unless proxied. To proxy, provide the Auth Token below (built-in proxy only).
6
7For detailed setup instructions, see the [Usenet guide](https://docs.aiostreams.viren070.me/guides/usenet#nzbdav-altmount-and-stremthru-newz).`,type:"alert",intent:"info",required:!1},{id:"url",name:"NzbDAV URL",description:"The base URL of your NZB DAV instance. E.g., http://nzbdav:3000",type:"string",required:!0},{id:"publicUrl",name:"Public NzbDAV URL (Optional)",description:"The public URL of your NzbDAV instance. Optional, see note above for details.",type:"string",required:!1},{id:"apiKey",name:"NzbDAV API Key",description:"Your Nzb DAV API Key, found in the SABnzbd section in settings.",type:"password",required:!0},{id:"username",name:"NzbDAV WebDAV Username",description:"Your Nzb DAV WebDAV Username. Found in the WebDAV section in settings.",type:"string",required:!1},{id:"password",name:"NzbDAV WebDAV Password",description:"Your NzbDAV WebDAV Password. Found in the WebDAV section in settings.",type:"password",required:!1}
7,{id:"aiostreamsAuth",name:"AIOStreams Auth Token (Optional)",description:"If you would like to proxy your NzbDAV streams, you will need to provide a username:password pair for your AIOStreams instance, defined in the `AIOSTREAMS_AUTH` environment variable. **Other proxies will not work and you must define it here only**",type:"password",required:!1}]},[sb]:{id:sb,name:"AIOStreams",shortName:"AIO",knownNames:["AIO","AIO Usenet","NZB","Usenet","Native Usenet"],signUpText:"Stream directly from your own NNTP providers via the built-in usenet engine. Providers are configured globally by the administrator.",credentials:[{id:"note",name:"Configuration Help",description:"NNTP providers for this engine are configured **globally by the administrator** (Settings → Usenet), not here.\n\nTo authorise streaming through the built-in engine, provide an AIOStreams Auth Token below: a `username:password` pair defined in the `AIOSTREAMS_AUTH` environment variable.",type:"alert",intent:"info",required:!1},{id:"aiostreamsAuth",name:"AIOStreams Auth Token",description:"A `username:password` pair for your AIOStreams instance, defined in the `AIOSTREAMS_AUTH` environment variable. Required to authorise streaming through the built-in usenet engine.",type:"password",required:!0}]},[sx]:{id:sx,name:"AltMount",shortName:"AM",knownNames:["AM"],signUpText:"Stream usenet directly from your provider via AltMount.",credentials:[{id:"note",name:"Configuration Help",description:`**URL:** Use internal URL for local setups (e.g., http://altmount:8000), otherwise use a public URL.
8
9**Public URL:** Only needed if URL is local but streams need to be publicly accessible. Leave blank if URL is public or using a proxy.
10
11**Security Note:** WebDAV credentials are exposed in stream URLs unless proxied. To proxy, provide the Auth Token below (built-in proxy only).
12
13For detailed setup instructions, see the [Usenet guide](https://docs.aiostreams.viren070.me/guides/usenet#nzbdav-altmount-and-stremthru-newz).`,type:"alert",intent:"info",required:!1},{id:"url",name:"Altmount URL",description:"The base URL of your AltMount instance used for requests. e.g., http://altmount:8080",type:"string",required:!0},{id:"publicUrl",name:"Public Altmount URL",description:"The public URL of your AltMount instance. Optional, see note above for details.",type:"string",required:!1},{id:"apiKey",name:"AltMount API Key",description:"Your AltMount API Key, found at `Configuration -> System` in the AltMount Web UI.",type:"password",required:!0},{id:"username",name:"AltMount WebDAV Username",description:"Your AltMount WebDAV Username, found at `Configuration -> WebDAV Server` in the AltMount Web UI.",type:"string",required:!0},{id:"password",name:"AltMount WebDAV Password",description:"Your AltMount WebDAV Password, found at `Configuration -> WebDAV Server` in the AltMount Web UI.",type:"password",required:!0},{id:"aiostreamsAuth",name:"AIOStreams Auth Token (Optional)",description:"If you would like to proxy your AltMount streams, you will need to provide a username:password pair for your AIOStreams instance, defined in the `AIOSTREAMS_AUTH` environment variable. **Other proxies will not work and you must define it here only**",type:"password",required:!1}]},[su]:{id:su,name:"Offcloud",shortName:"OC",knownNames:["OC","Offcloud"],signUpText:"Don't have an account? [Sign up here](https://offcloud.com/?=06202a3d)",credentials:[{id:"apiKey",name:"API Key",description:"Your Offcloud API key. Obtain it from [here](https://offcloud.com/#/account) on the `API Key` tab. ",type:"password",required:!0},{id:"email",name:"Email",description:"Your Offcloud email. (These credentials are necessary for some addons)",type:"password",required:!0},{id:"password",name:"Password",description:"Your Offcloud password. (These credentials are necessary for some addons)",type:"password",required:!0}]},[sd]:{id:sd,name:"put.io",shortName:"P.IO",knownNames:["PO","put.io","putio"],signUpText:"Don't have an account? [Sign up here](https://put.io/)",credentials:[{id:"clientId",name:"Client ID",description:"Your put.io Client ID. Obtain it from [here](https://app.put.io/oauth)",type:"password",required:!0},{id:"token",name:"Token",description:"Your put.io Token. Obtain it from [here](https://app.put.io/oauth)",type:"password",required:!0}]}
13,[sp]:{id:sp,name:"Easynews",shortName:"EN",knownNames:["EN","Easynews"],signUpText:"Don't have an account? [Sign up here](https://www.easynews.com/)",credentials:[{id:"username",name:"Username",description:"Your Easynews username",type:"password",required:!0},{id:"password",name:"Password",description:"Your Easynews password",type:"password",required:!0}]},[si]:{id:si,name:"EasyDebrid",shortName:"ED",knownNames:["ED","EasyDebrid"],signUpText:"Don't have an account? [Sign up here](https://paradise-cloud.com/products/easydebrid)",credentials:[{id:"apiKey",name:"API Key",description:"Your EasyDebrid API key. Obtain it from [here](https://paradise-cloud.com/dashboard/)",type:"password",required:!0}]},[so]:{id:so,name:"Debrider",shortName:"DR",knownNames:["DBD","DR","DER","DB","Debrider"],signUpText:"Don't have an account? [Sign up here](https://debrider.app/)",credentials:[{id:"apiKey",name:"API Key",description:"Your Debrider API key. Obtain it from [here](https://debrider.app/dashboard/account)",type:"password",required:!0}]},[sc]:{id:sc,name:"PikPak",shortName:"PKP",knownNames:["PP","PikPak","PKP"],signUpText:"Don't have an account? [Sign up here](https://mypikpak.com/drive/activity/invited?invitation-code=72822731)",credentials:[{id:"email",name:"Email",description:"Your PikPak email address",type:"password",required:!0},{id:"password",name:"Password",description:"Your PikPak password",type:"password",required:!0}]},[sm]:{id:sm,name:"Seedr",shortName:"SDR",knownNames:["SR","Seedr","SDR"],signUpText:"Don't have an account? [Sign up here](https://www.seedr.cc/?r=6542079)",credentials:[{id:"encodedToken",name:"Encoded Token",description:"Please authorise at MediaFusion and copy the token into here.",type:"password",required:!0}]},[sf]:{id:sf,name:"StremThru Newz",shortName:"ST",knownNames:["ST","StremThru Newz","StremThruNewz"],signUpText:"Stream usenet content via [StremThru](https://github.com/MunifTanjim/stremthru).",credentials:[{id:"url",name:"StremThru URL",description:"The base URL of your StremThru instance used for requests e.g. http://stremthru:8080 or https://stremthru.mydomain.com",type:"string",required:!0},{id:"authToken",name:"Auth Token",description:"Your StremThru authentication token from `STREMTHRU_AUTH`",type:"password",required:!0},{id:"note",name:"Tip",description:"If you are self-hosting both StremThru and AIOStreams, consider using the internal URL of StremThru (e.g., http://stremthru:8080) to avoid potential network issues. Your playback URLs generated by StremThru will use the `STREMTHRU_BASE_URL` environment variable.",type:"alert",intent:"info"}]},[sv]:{id:sv,name:"Torrin",shortName:"TR",knownNames:["TR","TI","Torrin"],signUpText:"Don't have an account? [Sign up here](https://torrin.app). Torrin is an open-source debrid service.",credentials:[{id:"apiKey",name:"API Key",description:"Your Torrin API key (begins with `tr_`). Obtain it from [torrin.app/app/settings](https://torrin.app/app/settings).",type:"password",required:!0}]}},s_={tmdbApiKey:{name:"TMDB API Key",description:"Get your free API key from [here](https://www.themoviedb.org/settings/api). Make sure to copy the 32 character API Key and not the Read Access Token."},tmdbAccessToken:{name:"TMDB Access Token",description:"Get your free access token from [here](https://www.themoviedb.org/settings/api). Make sure to copy the Read Access Token and not the 32 character API Key."},rpdbApiKey:{name:"RPDB API Key",description:"Get your free API key from [here](https://ratingposterdb.com/api-key/) for posters with ratings."},topPosterApiKey:{name:"TOP Posters API Key",description:"Get your free API key from [here](https://api.top-posters.com/user/register) for posters with ratings."},tvdbApiKey:{name:"TVDB API Key",description:"Sign up for a free API Key at [TVDB](https://www.thetvdb.com/api-information) and then get it from your [dashboard](https://www.thetvdb.com/dashboard/account/apikeys)."},aioratingsApiKey:{name:"AIOratings API Key",description:"Get your API key from [here](https://aioratings.com) for custom posters with ratings."},aioratingsProfileId:{name:"AIOratings Profile ID",description:'Use "default" for the default profile, or enter a custom profile UUID from your AIOratings dashboard.'},openposterdbApiKey:{name:"OpenPosterDB API Key",description:"Get your API key from [here](https://
13openposterdb.com) for posters with ratings. Use `t0-free-rpdb` for the free public instance."},openposterdbUrl:{name:"OpenPosterDB URL",description:"Custom base URL for a self-hosted OpenPosterDB instance. Leave empty to use the default public instance."},openposterdbParameters:{name:"OpenPosterDB Custom Parameters",description:"Optional query string (without the leading `?`) appended to every poster to customise it, e.g. `ratings_limit=2&badge_size=l&position=br`."}},sR=["filename","infoHash","smartDetect"],sA=["torrent_seeders","usenet_age"],sT=["size","bitrate","resolution","quality","encode","releaseGroup","edition","remastered","network","container","visualTags","audioTags","audioChannels","languages","repack","proper","country"],sI=["size","resolution","quality","visualTags","audioTags","audioChannels","languages","encode","edition","network","remastered","releaseGroup"],sE=["service","addon","proxied","resolution","quality","encode","audioTags","visualTags","languages","releaseGroup","type","infoHash","size"],sM=["resolution","quality","releaseGroup"],sP=["matchingFile","matchingIndex","firstFile"],sD={matchingFile:{name:"Matching File",description:"Auto-play the stream that matches the (customisable) attributes of the previous episode."},matchingIndex:{name:"Matching Index",description:"Auto-play the stream in the same position in the result list (assuming it exists) i.e. if you play the second stream, the second stream for the next episode will also be played."},firstFile:{name:"First File",description:"Always auto-play the first stream in the result list."}},sL=["2160p","1440p","1080p","720p","576p","480p","360p","240p","144p","Unknown"],sU=["BluRay REMUX","BluRay","WEB-DL","WEBRip","HDRip","HC HD-Rip","DVD REMUX","DVDRip","HDTV","CAM","TS","TC","SCR","Unknown"],s$=["HDR+DV","DV Only","HDR Only","HDR10+","HDR10","DV","HDR","HLG","10bit","3D","IMAX","AI","Upscaled","SDR","H-OU","H-SBS","Unknown"],sO=["Atmos","DD+","DD","DTS:X","DTS-HD MA","DTS-HD","DTS-ES","DTS","TrueHD","OPUS","FLAC","AAC","Unknown"],sF=["2.0","5.1","6.1","7.1","Unknown"],sz=["AV1","HEVC","AVC","VC-1","XviD","DivX","Unknown"],sV=["quality","resolution","language","subtitle","visualTag","audioTag","audioChannel","streamType","encode","size","service","seeders","private","age","addon","regexPatterns","cached","library","keyword","streamExpressionMatched","streamExpressionScore","regexScore","seadex","bitrate","releaseGroup"],sq={quality:{name:"Quality",description:"Sort by the quality of the stream",defaultDirection:"desc",ascendingDescription:"Streams that are not in your preferred quality list are preferred",descendingDescription:"Streams that are in your preferred quality list are preferred"},resolution:{name:"Resolution",description:"Sort by the resolution of the stream",defaultDirection:"desc",ascendingDescription:"Streams that are not in your preferred resolution list are preferred",descendingDescription:"Streams that are in your preferred resolution list are preferred"},language:{name:"Language",description:"Sort by the language of the stream",defaultDirection:"desc",ascendingDescription:"Streams that are not in your preferred language list are preferred",descendingDescription:"Streams that are in your preferred language list are preferred"},subtitle:{name:"Subtitle",description:"Sort by the subtitle of the stream",defaultDirection:"desc",ascendingDescription:"Streams that are not in your preferred subtitle list are preferred",descendingDescription:"Streams that are in your preferred subtitle list are preferred"},visualTag:{name:"Visual Tag",description:"Sort by the visual tags of the stream",defaultDirection:"desc",ascendingDescription:"Streams that are not in your preferred visual tag list are preferred",descendingDescription:"Streams that are in your preferred visual tag list are preferred"},audioTag:{name:"Audio Tag",description:"Sort by the audio tags of the stream",defaultDirection:"desc",ascendingDescription:"Streams that are not in your preferred audio tag list are preferred",descendingDescription:"Streams that are in your preferred audio tag list are preferred"},audioChannel:{name:"Audio Channel",description:"Sort by the audio channels of the stream",defaultDirection:"desc",ascendingDescription:"Streams that are not in your preferred audio channel list are preferred",descendingDescription:"Streams that are in y
13our preferred audio channel list are preferred"},streamType:{name:"Stream Type",description:"Whether the stream is of a preferred stream type",defaultDirection:"desc",ascendingDescription:"Streams that are not in your preferred stream type list are preferred",descendingDescription:"Streams that are in your preferred stream type list are preferred"},encode:{name:"Encode",description:"Whether the stream is of a preferred encode",defaultDirection:"desc",ascendingDescription:"Streams that are not in your preferred encode list are preferred",descendingDescription:"Streams that are in your preferred encode list are preferred"},size:{name:"Size",description:"Sort by the size of the stream",defaultDirection:"desc",ascendingDescription:"Streams that are smaller are sorted first",descendingDescription:"Streams that are larger are sorted first"},service:{name:"Service",description:"Sort by the service order",defaultDirection:"desc",ascendingDescription:"Streams without a service are preferred",descendingDescription:"Streams are ordered by the order of your service list, with non-service streams at the bottom"},seeders:{name:"Seeders",description:"Sort by the number of seeders",defaultDirection:"desc",ascendingDescription:"Streams with fewer seeders are preferred",descendingDescription:"Streams with more seeders are preferred"},private:{name:"Private",description:"Whether the stream is from a private tracker or not",defaultDirection:"desc",ascendingDescription:"Streams that are not from private trackers are preferred",descendingDescription:"Streams that are from private trackers are preferred"},age:{name:"Age",description:"Sort by the age of the stream",defaultDirection:"desc",ascendingDescription:"Newer streams are preferred",descendingDescription:"Older streams are preferred"},addon:{name:"Addon",description:"Sort by the addon order",defaultDirection:"desc",ascendingDescription:"Streams are sorted by the order of your addon list",descendingDescription:"Streams are sorted by the order of your addon list"},regexPatterns:{name:"Regex Patterns",description:"Whether the stream matches any of your preferred regex patterns",defaultDirection:"desc",ascendingDescription:"Streams that do not match your preferred regex patterns are preferred",descendingDescription:"Streams that match your preferred regex patterns are preferred"},cached:{name:"Cached",defaultDirection:"desc",description:"Whether the stream is cached or not",ascendingDescription:"Streams that are not cached are preferred",descendingDescription:"Streams that are cached are preferred"},library:{name:"Library",defaultDirection:"desc",description:"Whether the stream is in your library (e.g. debrid account) or not",ascendingDescription:"Streams that are not in your library are preferred",descendingDescription:"Streams that are in your library are preferred"},keyword:{name:"Keyword",defaultDirection:"desc",description:"Sort by the keyword of the stream",ascendingDescription:"Streams that do not match any of your keywords are preferred",descendingDescription:"Streams that match any of your keywords are preferred"},streamExpressionMatched:{name:"Stream Expressions",defaultDirection:"desc",description:"Whether the stream matches any of your preferred stream expressions",ascendingDescription:"Streams that do not match your preferred stream expressions are preferred while the ones that do are ranked by the order of your preferred stream expressions",descendingDescription:"Streams that match your preferred stream expressions are preferred and ranked by the order of your preferred stream expressions"},seadex:{name:"SeaDex",defaultDirection:"desc",description:"Whether the stream is a SeaDex release (curated best anime releases from releases.moe)",ascendingDescription:"Streams that are not listed on SeaDex are preferred",descendingDescription:"Streams that are marked as the Best release on SeaDex are preferred, followed by the Alternative release"},bitrate:{name:"Bitrate (Estimate)",defaultDirection:"desc",description:"Sort by the bitrate of the stream",ascendingDescription:"Streams with lower bitrate are preferred",descendingDescription:"Streams with higher bitrate are preferred"},regexScore:{name:"Ranked Regex Score",defaultDirection:"desc",description:"Sort by the computed score from ranked regex patterns",ascendingDescription:"Streams with lower regex scores are preferred",descendingDescription:"Streams with higher regex scores are preferred"},streamExpressionScore:{name:"Stream Expression Score",defaultDirection:"desc",description:"Sort by the computed score from ranked stream expressions",ascendingDescription:"Streams with lower expression scores are preferred",descendingDescription:"Streams with higher expression scores are preferred"},releaseGroup:{name:"Release Group",defaultDirection:"desc",description:"Sort by the release group of the stream",ascendingDescription:"Streams that are not in your preferred release group list are preferred",descendingDescription:"Streams that are in y
13our preferred release group list are preferred"}},sB=["p2p","live","stremio-usenet","archive","usenet","debrid","http","external","youtube","error","statistic","info"],sK="movie",sH="series",sG="channel",sW="anime",sY=[sK,sH,sG,"tv",sW],sJ={[sK]:"Movie",[sH]:"Series",[sG]:"Channel",tv:"TV",[sW]:"Anime"},sZ=["stream","subtitles","catalog","meta","addon_catalog"],sQ=["English","Japanese","Chinese","Russian","Arabic","Portuguese","Portuguese (Brazil)","Spanish","French","German","Italian","Korean","Hindi","Bengali","Punjabi","Marathi","Gujarati","Tamil","Telugu","Kannada","Malayalam","Thai","Vietnamese","Indonesian","Turkish","Hebrew","Persian","Ukrainian","Greek","Lithuanian","Latvian","Estonian","Polish","Czech","Slovak","Hungarian","Romanian","Bulgarian","Serbian","Croatian","Slovenian","Dutch","Danish","Finnish","Swedish","Norwegian","Malay","Latino","Dual Audio","Dubbed","Multi","Original","Unknown"],sX=[{name:"Resolution",description:'The resolution, falling back to "Unknown" when unavailable.',value:"{stream.resolution::default('Unknown')}"},{name:"Title & Year",description:"Title in Title Case, with the year in brackets when known.",value:"{stream.title::title}{? ({stream.year})?}"},{name:"Season & Episode",description:"Season and episode (S01 E05). Hidden for movies.",value:"{?{stream.seasonEpisode::join(' ')}?}"},{name:"Quality",description:"Source quality (BluRay, WEB-DL, …). Hidden when unknown.",value:"{?\uD83C\uDFA5 {stream.quality}?}"},{name:"File Size",description:"File size, with the folder size appended when present.",value:"{?\uD83D\uDCE6 {stream.size::sbytes}?}{? / {stream.folderSize::sbytes}?}"},{name:"Bitrate",description:"Bitrate. Hidden when unavailable.",value:"{?\uD83D\uDCCA {stream.bitrate::sbitrate}?}"},{name:"Duration",description:"Runtime.",value:"{?⏱️ {stream.duration::time}?}"},{name:"Seeders",description:"Seeder count. Hidden for non-torrents.",value:"{?\uD83D\uDC64 {stream.seeders}?}"},{name:"Age",description:"How long ago the release was posted.",value:"{?\uD83D\uDCC5 {stream.age}?}"},{name:"HDR / Visual Tags",description:"Visual tags such as HDR, DV and IMAX.",value:"{?\uD83D\uDCFA {stream.visualTags::join(' | ')}?}"},{name:"Audio",description:"Audio codecs and channel layouts.",value:"{?\uD83D\uDD0A {stream.audioTags::join(' | ')}?}{?\uD83C\uDF9A️ {stream.audioChannels::join(' | ')}?}"},{name:"Languages",description:"Language flags. Tip: use stream.languageCodes for text codes instead.",value:"{?\uD83C\uDF10 {stream.languageEmojis::join(' / ')}?}"},{name:"Subtitles",description:"Subtitle language flags.",value:"{?\uD83D\uDCDD {stream.subtitleEmojis::join(' / ')}?}"},{name:"Encode / Codec",description:"Video codec (x265, AV1, …).",value:"{?\uD83C\uDF9E️ {stream.encode}?}"},{name:"Release Group",description:"The release group.",value:"{?\uD83C\uDFF7️ {stream.releaseGroup}?}"},{name:"Episode Title",description:"The episode title parsed from the release name.",value:"{?\uD83D\uDCFA {stream.episodeTitle}?}"},{name:"Indexer",description:"The indexer or tracker the result came from.",value:"{?⚙️ {stream.indexer}?}"},{name:"Service & Cached",description:"Debrid service, with a cached (⚡) / uncached (⏳) badge.",value:'{?[{service.shortName}]?}{service.cached[" ⚡"||" ⏳"||""]}'},{name:"P2P Marker",description:"Adds a [P2P] marker for torrent streams.",value:'{stream.type::=p2p["[P2P] "||""]}'},{name:"Message",description:"Any status message on the stream.",value:"{?ℹ️ {stream.message}?}"},{name:"New Line",description:"Forces a line break. Useful inside modifier arguments.",value:"{tools.newLine}"}],s0="aiostreams-user-data";function s1(e){var t,s,a,r;if(e&&void 0!==e.addonPassword&&void 0===e.accessToken&&(e.accessToken=e.addonPassword),e&&void 0!==e.addonPassword&&delete e.addonPassword,e&&void 0!==e.accessToken&&void 0===e.accessKey&&(e.accessKey=e.accessToken),e&&void 0!==e.accessToken&&delete e.accessToken,e.deduplicator&&"string"==typeof e.deduplicator.multiGroupBehaviour)switch(e.deduplicator.multiGroupBehaviour){case"remove_uncached":e.deduplicator.multiGroupBehaviour="aggressive";break;case"remove_uncached_same_service":e.deduplicator.multiGroupBehaviour="conservative";break;case"remove_nothing":e.deduplicator.multiGroupBehaviour="keep_all"}if("boolean"==typeof e.digitalReleaseFilter){let t=e.digitalReleaseFilter;e.digitalReleaseFilter={enabled:t,tolerance:0,requestTypes:["movie","series","anime"],addons:[]}}(null==(t=e.titleMatching)?void 0:t.matchYear)&&(e.yearMatching={enabled:!0,tolerance:e.titleMatching.yearTolerance?e.titleMatching.yearTolerance:1,requestTypes:e.titleMatching.requestTypes??[],addons:e.titleMatching.addons??[]},delete e.titleMatching.matchYear),Array.isArray(e.groups)&&(e.groups={enabled:!e.disableGroups,groupings:e.groups,behaviour:"parallel"}),(e.showStatistics||e.statisticsPosition)&&(e.statistics={enabled:e.showStatistics??!1,position:e.statisticsPosition??"bottom",statsToShow:["addon","filter","timing"],...e.statistics??{}},delete e.showStatistics,delete e.statisticsPosition);let n=t=>{Array.isArray(e[t+"Encodes"])&&(e[t+"Encodes"]=e[t+"Encodes"].filter(s=>"H-OU"!==s&&"H-SBS"!==s||(e[t+"VisualTags"]=[...e[t+"VisualTags"]??[],s],!1)))};n("preferred"),n("required"),n("excluded"),n("included");let l=e=>{if("string"!=typeof e)return e;
13let t=e.replace(/queryType\s*==\s*(["'])anime\1/g,"(queryType == 'anime.series' or queryType == 'anime.movie')");return(t=(t=t.replace(/(["'])anime\1\s*==\s*queryType/g,"(queryType == 'anime.series' or queryType == 'anime.movie')")).replace(/queryType\s*!=\s*(["'])anime\1/g,"(queryType != 'anime.series' and queryType != 'anime.movie')")).replace(/(["'])anime\1\s*!=\s*queryType/g,"(queryType != 'anime.series' and queryType != 'anime.movie')")};for(let t of["excludedStreamExpressions","requiredStreamExpressions","includedStreamExpressions","preferredStreamExpressions"])Array.isArray(e[t])&&(e[t]=e[t].map(e=>"string"==typeof e?l(e):"object"==typeof e&&null!==e&&"expression"in e?{...e,expression:l(e.expression)}:e));if((null==(s=e.dynamicAddonFetching)?void 0:s.condition)&&(e.dynamicAddonFetching.condition=l(e.dynamicAddonFetching.condition)),(null==(a=e.groups)?void 0:a.groupings)&&(e.groups.groupings=e.groups.groupings.map(e=>({...e,condition:l(e.condition)}))),void 0!==e.rpdbUseRedirectApi&&void 0===e.usePosterRedirectApi&&(e.usePosterRedirectApi=e.rpdbUseRedirectApi,delete e.rpdbUseRedirectApi),Array.isArray(e.catalogModifications))for(let t of e.catalogModifications)void 0===t.usePosterService&&!0===t.rpdb&&(t.usePosterService=!0),delete t.rpdb;for(let t of(void 0===e.precacheSelector&&e.precacheNextEpisode&&(void 0!==e.precacheCondition?e.precacheSelector=`${e.precacheCondition} ? uncached(streams) : []`:e.precacheSelector=!0===e.alwaysPrecache?"true ? uncached(streams) : []":t1),delete e.alwaysPrecache,delete e.precacheCondition,void 0!==e.p2pWrap&&void 0===e.serviceWrap&&(e.serviceWrap=e.p2pWrap,delete e.p2pWrap),void 0===e.failover&&void 0!==e.nzbFailover&&(e.failover={enabled:e.nzbFailover.enabled,maxAttempts:e.nzbFailover.count,position:e.nzbFailover.position,contentTypes:[...t2],allowCrossType:!1,parallel:1}),delete e.nzbFailover,e.failover&&void 0!==e.failover.count&&((r=e.failover).maxAttempts??(r.maxAttempts=e.failover.count),delete e.failover.count),["excludedStreamExpressions","requiredStreamExpressions","preferredStreamExpressions","includedStreamExpressions"]))Array.isArray(e[t])&&e[t].some(e=>"string"==typeof e)&&(e[t]=e[t].map(e=>"string"==typeof e?{expression:e,enabled:!0}:e));if(e.presets&&Array.isArray(e.presets)&&(e.presets=e.presets.map(e=>{var t;return(null==(t=e.options)?void 0:t.forceToTop)===!0&&void 0===e.options.pinPosition?(delete e.options.forceToTop,{...e,options:{...e.options,pinPosition:"top"}}):e})),e.presets&&Array.isArray(e.presets)){let t={newznab:["newznabUrl","apiKey"],torznab:["torznabUrl","apiKey"],nzbhydra:["nzbhydraUrl","nzbhydraApiKey",!0]};e.presets=e.presets.map(e=>{let s=t[e.type];if(!s||!e.options||void 0!==e.options.api)return e;let[a,r,n]=s,{[a]:l,[r]:i,apiPath:o,...d}=e.options;if(void 0===l&&void 0===i&&void 0===o)return e;let c={};if("string"==typeof l&&l.trim()){let e=l.trim().replace(/\/+$/,"");if(n)c.url=e;else{let t=(void 0===o?"/api":String(o).trim()).replace(/^\/+|\/+$/g,"");c.url=e+(t?`/${t}`:"")}}return void 0!==i&&(c.apiKey=i),{...e,options:{...d,api:c}}})}return e.formatter&&e.formatter.definition&&(e.formatter.definitions={...e.formatter.definitions??{},custom:e.formatter.definition},delete e.formatter.definition),e}function s2(e){var t,s,a,r,n,l,i,o;let d=null==(t=e.presets)?void 0:t.map(e=>e.instanceId);return e.proxy&&(e.proxy.proxiedAddons=null==(r=e.proxy.proxiedAddons)?void 0:r.filter(e=>null==d?void 0:d.includes(e))),e.yearMatching&&(e.yearMatching.addons=null==(n=e.yearMatching.addons)?void 0:n.filter(e=>null==d?void 0:d.includes(e))),e.titleMatching&&(e.titleMatching.addons=null==(l=e.titleMatching.addons)?void 0:l.filter(e=>null==d?void 0:d.includes(e))),e.seasonEpisodeMatching&&(e.seasonEpisodeMatching.addons=null==(i=e.seasonEpisodeMatching.addons)?void 0:i.filter(e=>null==d?void 0:d.includes(e))),e.episodeTitleMatching&&(e.episodeTitleMatching.addons=null==(o=e.episodeTitleMatching.addons)?void 0:o.filter(e=>null==d?void 0:d.includes(e))),(null==(s=e.groups)?void 0:s.groupings)&&(e.groups.groupings=e.groups.groupings.map(e=>{var t;return{...e,addons:null==(t=e.addons)?void 0:t.filter(e=>null==d?void 0:d.includes(e))}}
13)),(null==(a=e.serviceWrap)?void 0:a.presets)&&(e.serviceWrap.presets=e.serviceWrap.presets.filter(e=>null==d?void 0:d.includes(e))),e}let s3={services:Object.values(sC).map(e=>({id:e.id,enabled:!1,credentials:{}})),presets:[],formatter:{id:"gdrive"},preferredQualities:Object.values(sU),preferredResolutions:Object.values(sL),excludedQualities:["CAM","SCR","TS","TC"],excludedVisualTags:["3D"],sortCriteria:{global:[{key:"cached",direction:"desc"},{key:"library",direction:"desc"},{key:"resolution",direction:"desc"},{key:"quality",direction:"desc"},{key:"streamExpressionScore",direction:"desc"},{key:"regexPatterns",direction:"desc"},{key:"streamType",direction:"desc"},{key:"visualTag",direction:"desc"},{key:"audioTag",direction:"desc"},{key:"audioChannel",direction:"desc"},{key:"encode",direction:"desc"},{key:"language",direction:"desc"},{key:"subtitle",direction:"desc"},{key:"size",direction:"desc"}]},posterService:"rpdb",deduplicator:{enabled:!0,keys:["filename","infoHash"],multiGroupBehaviour:"aggressive",cached:"single_result",uncached:"per_service",p2p:"single_result",http:"disabled",live:"disabled",youtube:"disabled",external:"disabled",smartDetectAttributes:sI,smartDetectRounding:10,libraryBehaviour:"ignore"},autoPlay:{enabled:!0,method:"matchingFile",attributes:["resolution","quality","releaseGroup"]},cacheAndPlay:{enabled:!1,streamTypes:["usenet"]},statistics:{enabled:!1,position:"bottom",statsToShow:["addon","filter","timing"],showFilterStatsOnNoStreams:!0},digitalReleaseFilter:{enabled:!1,tolerance:0,requestTypes:[],addons:[],showInfoOnFilter:!0},ageRangeTypes:["usenet"],seasonEpisodeMatching:{addons:[],requestTypes:[]},episodeTitleMatching:{addons:[],requestTypes:[]},languageInference:{enabled:!0,sources:[]},yearMatching:{addons:[],requestTypes:[]},titleMatching:{addons:[],requestTypes:[]},precacheNextEpisode:!1,precacheSingleStream:!0,precacheSelector:t1,enableSeadex:!0,regexOverrides:[],checkOwned:!0},s6=n.createContext(void 0);function s5(e){let{children:t}=e,{status:s}=e$(),[a,l]=n.useState(()=>{try{let e=localStorage.getItem(s0),t=e?JSON.parse(e):s3;return s1(t)}catch{return s3}}),[i,o]=n.useState(null),[d,c]=n.useState(null),[u,m]=n.useState(null);n.useEffect(()=>{localStorage.setItem(s0,JSON.stringify(a))},[a]);let p=n.useRef(!1);return n.useEffect(()=>{if(!s||p.current)return;p.current=!0;let e=s.settings.forced,t=s.settings.defaults,a=s.settings.services;l(s=>{var r,n,l,i,o,d,c;let u={...s};return u.proxy={...u.proxy,enabled:e.proxy.enabled??(null==(r=t.proxy)?void 0:r.enabled)??void 0,id:e.proxy.id??(null==(n=t.proxy)?void 0:n.id)??"builtin",url:e.proxy.url??(null==(l=t.proxy)?void 0:l.url)??void 0,publicUrl:e.proxy.publicUrl??(null==(i=t.proxy)?void 0:i.publicUrl)??void 0,publicIp:e.proxy.publicIp??(null==(o=t.proxy)?void 0:o.publicIp)??void 0,credentials:e.proxy.credentials??(null==(d=t.proxy)?void 0:d.credentials)??void 0,proxiedServices:e.proxy.proxiedServices??(null==(c=t.proxy)?void 0:c.proxiedServices)??[]},u.services=(u.services??[]).map(e=>{let t=a[e.id];return t&&(t.credentials.forEach(t=>{t.forced?e.credentials[t.id]=t.forced:t.default&&(e.credentials[t.id]=t.default)}),e.enabled=t.credentials.every(t=>t.forced||t.default||void 0!==e.credentials[t.id])),e}),u})},[s]),(0,r.jsx)(s6.Provider,{value:{userData:a,setUserData:e=>{null===e?l(s3):l(t=>{let s=e(t);return null===s?s3:s})},uuid:i,setUuid:o,password:d,setPassword:c,encryptedPassword:u,setEncryptedPassword:m},children:t})}function s4(){let e=n.useContext(s6);if(void 0===e)throw Error("useUserData must be used within a UserDataProvider");return e}function s9(){let{userData:e}=s4(),t=null==e?void 0:e.parentConfig,s=null==t?void 0:t.mergeStrategies;return{hasParent:!!t,parentUuid:null==t?void 0:t.uuid,isInherited:function(e){return!!t&&"inherit"===((null==s?void 0:s[e])??"inherit")}}}let s8=["about","services","addons","filters","sorting","formatter","proxy","miscellaneous","stats","save-install"],s7=["sorting"],ae=(0,n.createContext)({selectedMenu:"about",setSelectedMenu:()=>{},nextMenu:()=>{},previousMenu:()=>{},firstMenu:"about",lastMenu:"save-install"});function at(e){let{children:t}=e,{mode:s}=tX(),{status:a}=e$(),l=s4(),i=(null==a?void 0:a.settings.userAnalyticsEnabled)===!0&&!!(l.uuid&&l.password),o=(0,n.useMemo)(()=>{let e=s8;return"noob"===s&&(e=e.filter(e=>!s7.includes(e))),i||(e=e.filter(e=>"stats"!==e)),e},[s,i]),d=(()=>
13{if("u">typeof window){let e=new URL(window.location.href).searchParams.get("menu");if(e&&o.includes(e))return e}return"about"})(),[c,u]=(0,n.useState)(d),m=e=>{window.scrollTo(0,0),u(e)},p=o[0],h=o[o.length-1];return(0,n.useEffect)(()=>{let e=new URL(window.location.href);"about"!==c?e.searchParams.set("menu",c):e.searchParams.delete("menu"),window.history.replaceState({},"",e.toString())},[c]),(0,r.jsx)(ae.Provider,{value:{selectedMenu:c,setSelectedMenu:m,nextMenu:()=>{let e=(o.indexOf(c)+1)%o.length;m(o[e])},previousMenu:()=>{let e=(o.indexOf(c)-1+o.length)%o.length;m(o[e])},firstMenu:p,lastMenu:h},children:t})}let as=()=>(0,n.useContext)(ae),aa={filters:"filter",miscellaneous:"misc-tab",services:"service-tab",addons:"addons-tab"},ar={filters:"cache",miscellaneous:"background",services:"services",addons:"addons"},an=(0,n.createContext)({subTabs:{},setSubTab:()=>{},getUrlKey:()=>void 0});function al(){let e={...ar};if("u"<typeof window)return e;let t=new URL(window.location.href);for(let[s,a]of Object.entries(aa)){let r=t.searchParams.get(a);r&&(e[s]=r)}return e}function ai(e){let{children:t}=e,[s,a]=(0,n.useState)(al),l=(0,n.useCallback)((e,t)=>{if(a(s=>({...s,[e]:t})),"u">typeof window){let s=aa[e];if(s){let e=new URL(window.location.href);e.searchParams.set(s,t),window.history.replaceState({},"",e.toString())}}},[]),i=(0,n.useCallback)(e=>aa[e],[]);(0,n.useEffect)(()=>{let e=()=>a(al());return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)},[]);let o=(0,n.useMemo)(()=>({subTabs:s,setSubTab:l,getUrlKey:i}),[s,l,i]);return(0,r.jsx)(an.Provider,{value:o,children:t})}function ao(e){let t=(0,n.useContext)(an);return{tab:t.subTabs[e]??ar[e]??"",setTab:(0,n.useCallback)(s=>t.setSubTab(e,s),[t,e])}}let ad=null,ac=null;function au(e){let t=performance.now(),s=null,a=0,r=-1,n=-1,l=0,i=()=>{var o,d;let c=performance.now();if(!s){if(!(s=function(e){for(let t of e)for(let e of document.querySelectorAll(`#${CSS.escape(t)}`))if(null!==e.offsetParent&&!e.closest("[inert]"))return e;return null}(e))){c-t<3e3&&requestAnimationFrame(i);return}a=c,o=s,ad&&ad.removeAttribute("data-command-target"),null!==ac&&window.clearTimeout(ac),o.setAttribute("data-command-target","true"),ad=o,ac=window.setTimeout(()=>{o.removeAttribute("data-command-target"),ad=null,ac=null},1600)}let u=document.documentElement.scrollHeight;u!==n?(n=u,l=0):l++;let m=Math.min(Math.max(0,function(e){let t=0,s=e;for(;s;)t+=s.offsetTop,s=s.offsetParent;return t}(d=s)-Math.max(0,(window.innerHeight-d.offsetHeight)/2)),Math.max(0,u-window.innerHeight));Math.abs(m-r)>1&&(r=m,window.scrollTo({top:m,behavior:"smooth"}));let p=c-a;!(l>=3&&p>=120)&&p<1500&&requestAnimationFrame(i)};requestAnimationFrame(i)}let am=(0,n.createContext)({isOpen:!1,open:()=>{},close:()=>{},toggle:()=>{},navigate:()=>{}});function ap(e){let{children:t}=e,{isOpen:s,open:a,close:l,toggle:i}=tM(),{selectedMenu:o,setSelectedMenu:d}=as(),{setSubTab:c}=(0,n.useContext)(an),u=(0,n.useCallback)(e=>{e.subTab&&c(e.menu,e.subTab),o!==e.menu&&d(e.menu),l();let t=[e.sectionId,...e.fallbackSectionIds??[]].filter(e=>!!e);t.length>0&&au(t)},[o,d,c,l]);return(0,r.jsx)(am.Provider,{value:{isOpen:s,open:a,close:l,toggle:i,navigate:u},children:t})}let ah=()=>(0,n.useContext)(am),ax=(0,n.createContext)({actions:[],register:()=>()=>{}});function ag(e){let{children:t}=e,[,s]=(0,n.useState)(0),a=(0,n.useRef)(new Map),l=(0,n.useCallback)(e=>(a.current.set(e.id,e),s(e=>e+1),()=>{a.current.delete(e.id),s(e=>e+1)}),[]),i=(0,n.useMemo)(()=>({actions:Array.from(a.current.values()),register:l}),[l,a.current.size,...Array.from(a.current.keys())]);return(0,r.jsx)(ax.Provider,{value:i,children:t})}let af=()=>(0,n.useContext)(ax);function ab(e,t){let{register:s}=af();(0,n.useEffect)(()=>{if(e)return s(e)},t)}function av(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().replace(/[^a-z0-9]+/g," ").trim()}function ay(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],s=e=>{let t=[];for(let s of e){if(!s)continue;let e=av(s);e&&t.push(e)}return t};return{primary:s(e),secondary:s(t)}}function aj(e){let t=av(e);return{phrase:t,terms:t?t.split(" "):[]}}function aw(e,t,s){let a=0;for(let r of e){let e=function(e,t,s){if(!t||!e)return 0;if(e===t)return 100;if(e.startsWith(t))return 90;if(e.includes(t))return 75;let a=e.split(" ");if(a.some(e=>e.startsWith(t)))return 65;if(a.some(e=>e.includes(t)))return 55;if(!s)return 0;let r=0;for(let s=0;s<e.length&&r<t.length;s++)e[s]===t[r]&&r++;return r===t.length?10+Math.floor(t.length/e.length*30):0}(r,t,s);e>a&&(a=e)}return a}function aN(e,t){let{phrase:s,terms:a}=t;if(!a.length)return 0;let r=1===a.length&&s.length>=3,n=t=>Math.max(aw(e.primary,t,r),.5*aw(e.secondary,t,!1)),l=0;for(let e of a){let t=n(e);if(0===t)return 0;l+=t}return Math.max(l/a.length,a.length>1?n(s):0)}function ak(e){let{open:t,onClose:s,label:a,placeholder:n,emptyHint:l,query:i,onQueryChange:o,isIdle:d,results:c,idleGroup:u}=e;return(0,r.jsxs)(tW,{open:t,onOpenChange:e=>{e||s()}
13,hideCloseButton:!0,contentClass:"max-w-2xl p-0",commandProps:{shouldFilter:!1,label:a},children:[(0,r.jsx)(tV,{placeholder:n,autoFocus:!0,value:i,onValueChange:o}),(0,r.jsxs)(tq,{className:"max-h-[60vh]",children:[(0,r.jsx)(tB,{children:d?l:"No matches."}),d?u:c.length>0&&(0,r.jsx)(tK,{children:c.slice(0,50).map(e=>(0,r.jsxs)(tH,{value:e.id,leftIcon:e.icon,onSelect:e.onSelect,children:[(0,r.jsx)("span",{children:e.label}),(0,r.jsx)("span",{className:"ml-auto text-xs text-[--muted] capitalize",children:e.trail}),e.shortcut&&(0,r.jsx)(tG,{children:e.shortcut})]},e.id))})]})]})}let aS=[{id:"about",label:"About",icon:(0,r.jsx)(tC.wfp,{})},{id:"services",label:"Services",icon:(0,r.jsx)(tC.V0M,{})},{id:"addons",label:"Addons",icon:(0,r.jsx)(tC.DT2,{})},{id:"filters",label:"Filters",icon:(0,r.jsx)(tC.Jw7,{})},{id:"sorting",label:"Sorting",icon:(0,r.jsx)(tC.MFA,{}),proOnly:!0},{id:"formatter",label:"Formatter",icon:(0,r.jsx)(tC.fSy,{})},{id:"proxy",label:"Proxy",icon:(0,r.jsx)(tC.nmg,{})},{id:"miscellaneous",label:"Miscellaneous",icon:(0,r.jsx)(tC.nMM,{})},{id:"stats",label:"Stats",icon:(0,r.jsx)(tC.yWU,{}),requiresStats:!0},{id:"save-install",label:"Save & Install",icon:(0,r.jsx)(tC.Ruw,{})}],aC={about:"About",services:"Services",addons:"Addons",filters:"Filters",sorting:"Sorting",stats:"Stats",formatter:"Formatter",proxy:"Proxy",miscellaneous:"Miscellaneous","save-install":"Save & Install"};function a_(e){return e.replace(/-/g," ")}let aR=Object.entries(t0).filter(e=>{let[,t]=e;return!t.ignoreForCommandPalette}).map(e=>{let[t,s]=e,a=void 0!==s.subTab?`${a_(s.menu)} → ${a_(s.subTab)}`:aC[s.menu]??a_(s.menu),r="filters"===s.menu&&s.subTab?[`filter-tab-${s.subTab}`]:void 0;return{key:t,label:s.label,trail:a,sectionId:s.sectionId??t,menu:s.menu,subTab:s.subTab,fallbackSectionIds:r,haystack:ay([s.label,t,s.menu,s.subTab,...s.keywords??[]])}}),aA=[{id:"cache",label:"Cache"},{id:"resolution",label:"Resolution"},{id:"quality",label:"Quality"},{id:"encode",label:"Encode"},{id:"stream-type",label:"Stream Type"},{id:"visual-tag",label:"Visual Tag"},{id:"audio-tag",label:"Audio Tag"},{id:"audio-channel",label:"Audio Channel"},{id:"language",label:"Language"},{id:"subtitle",label:"Subtitle"},{id:"seeders",label:"Seeders"},{id:"age",label:"Age"},{id:"matching",label:"Matching"},{id:"keyword",label:"Keyword"},{id:"release-group",label:"Release Group"},{id:"stream-expression",label:"Stream Expression"},{id:"regex",label:"Regex"},{id:"size",label:"Size"},{id:"bitrate",label:"Bitrate"},{id:"limit",label:"Result Limits"},{id:"deduplicator",label:"Deduplicator"},{id:"miscellaneous",label:"Miscellaneous (Filters)"}].map(e=>({...e,haystack:ay(["filter tab",e.label,e.id])}));function aT(){let{isOpen:e,close:t,navigate:s}=ah(),{actions:a}=af(),{mode:l}=tX(),{status:i}=e$(),o=s4(),d=(null==i?void 0:i.settings.userAnalyticsEnabled)===!0&&!!(o.uuid&&o.password),[c,u]=(0,n.use
13State)(""),m=(0,n.useDeferredValue)(c),p=0===m.trim().length,h=(0,n.useMemo)(()=>aS.filter(e=>("pro"===l||!e.proOnly)&&(!e.requiresStats||d)).map(e=>({...e,haystack:ay([e.label,e.id])})),[l,d]),x=(0,n.useMemo)(()=>a.map(e=>({action:e,haystack:ay([e.label,...e.keywords??[]],[e.description])})),[a]),g=(0,n.useMemo)(()=>{if(p)return[];let e=aj(m),a=[];for(let{action:s,haystack:r}of x){let n=aN(r,e);n>0&&a.push({id:`action-${s.id}`,label:s.label,trail:"Action",icon:s.icon,score:n,shortcut:s.shortcut,onSelect:()=>{t(),u(""),s.onSelect()}})}for(let t of h){let r=aN(t.haystack,e);r>0&&a.push({id:`menu-${t.id}`,label:t.label,trail:"Page",icon:t.icon,score:r,onSelect:()=>{u(""),s({menu:t.id})}})}for(let t of aA){let n=aN(t.haystack,e);n>0&&a.push({id:`filter-tab-${t.id}`,label:`Filters → ${t.label}`,trail:"Filter Tab",icon:(0,r.jsx)(tC.Jw7,{}),score:n,onSelect:()=>{u(""),s({menu:"filters",subTab:t.id,sectionId:`filter-tab-${t.id}`})}})}for(let t of aR){let r=aN(t.haystack,e);r>0&&a.push({id:t.key,label:t.label,trail:t.trail,score:r,onSelect:()=>{u(""),s({menu:t.menu,subTab:t.subTab,sectionId:t.sectionId,fallbackSectionIds:t.fallbackSectionIds})}})}return a.sort((e,t)=>t.score-e.score)},[m,p,x,h,s,t]);return(0,r.jsx)(ak,{open:e,onClose:()=>{t(),u("")},label:"Settings search",placeholder:"Search settings, pages, actions…",emptyHint:"Enter a setting to search for…",query:c,onQueryChange:u,isIdle:p,results:g,idleGroup:a.length>0&&(0,r.jsx)(tK,{heading:"Quick actions",children:a.map(e=>(0,r.jsxs)(tH,{value:`action-${e.id}`,leftIcon:e.icon,onSelect:()=>{t(),u(""),e.onSelect()},children:[(0,r.jsx)("span",{children:e.label}),e.shortcut&&(0,r.jsx)(tG,{children:e.shortcut})]},e.id))})})}let aI={general:{label:"General",icon:tC.nMM,group:"General",order:10,sections:["api","templates"]},branding:{label:"Branding",icon:tC.pFm,group:"General",order:20},logging:{label:"Logging",icon:tC.XfR,group:"General",order:30},oidc:{label:"SSO / OIDC",icon:tC.$_m,group:"General",order:35},retention:{label:"Data & Retention",icon:tC.Wwx,group:"General",order:40,sections:["tasks","analytics"]},presets:{label:"Presets",icon:tC.Z_P,group:"Core",order:110},builtins:{label:"Built-ins",icon:tC.oNA,group:"Core",order:120},resources:{label:"Addon Resources",icon:tC.z2t,group:"Core",order:130},metadata:{label:"Metadata",icon:tC.wfp,group:"Core",order:140,sections:["metadata","poster"]},releaseBlocklist:{label:"Blocklists",icon:tC.PLI,group:"Core",order:150},userDefaults:{label:"User Defaults",icon:tC.jlq,group:"Users",order:210,sections:["services","proxy.default","proxy.force"]},userLimits:{label:"User Limits",icon:tC.hTi,group:"Users",order:220},rateLimits:{label:"Rate Limits",icon:tC.I2B,group:"Users",order:230,sections:["rateLimits","recursion"]},http:{label:"Outbound Requests",icon:tC.IS1,group:"Traffic",order:310},proxy:{label:"Proxy",icon:tC.koG,group:"Traffic",order:320,sections:["proxy.encryption","proxy.ip"]},streams:{label:"Streams",icon:tC.U2S,group:"Traffic",order:330}},aE=new Map(Object.entries(aI).flatMap(e=>{let[t,s]=e;return(s.sections??[t]).map(e=>[e,t])}));function aM(e){let t=e.split(".");for(let e=t.length-1;e>=1;e--){let s=aE.get(t.slice(0,e).join("."));if(s)return s}return t[0]}function aP(e,t){var s;let a=null==(s=aI[e])?void 0:s.sections;if(!a)return 0;let r=t.split(".");for(let e=r.length-1;e>=1;e--){let t=a.indexOf(r.slice(0,e).join("."));if(-1!==t)return t}return a.length}let aD=tC.Wwx,aL={api:"API",url:"URL",uri:"URI",id:"ID",ip:"IP",ui:"UI",ux:"UX",sel:"SEL",ssl:"SSL",tls:"TLS",tcp:"TCP",udp:"UDP",http:"HTTP",https:"HTTPS",nzb:"NZB",rd:"RD",ad:"AD",pm:"PM",dl:"DL",tb:"TB",bitmagnet:"Bitmagnet",jackett:"Jackett",zilean:"Zilean",prowlarr:"Prowlarr",torrentio:"Torrentio",mediafusion:"MediaFusion",comet:"Comet",seadex:"SeaDex",stremthru:"StremThru",easynews:"Easynews",debridio:"Debridio",torbox:"TorBox",putio:"Put.io",offcloud:"Offcloud",tmdb:"TMDB",rpdb:"RPDB",oauth:"OAuth",oidc:"OIDC",sso:"SSO",gdrive:"GDrive",sqlite:"SQLite",postgres:"Postgres",redis:"Redis"};function aU(e){return e?e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[\s\-_]+/).filter(
13Boolean).map(e=>{let t=e.toLowerCase();return aL[t]?aL[t]:t.charAt(0).toUpperCase()+t.slice(1)}).join(" "):""}let a$=["dashboard","settings"],aO=["dashboard"];function aF(e){return(0,eU.I)({queryKey:a$,queryFn:()=>ei("/dashboard/settings"),staleTime:1e4,enabled:(null==e?void 0:e.enabled)??!0})}async function az(){return ei("GET /dashboard/settings/export")}var aV=s(1482);function aq(e){let t=[];return e.releaseKey&&t.push(e.releaseKey),/^[0-9a-f]{40}$/.test(e.nzbHash)&&t.push(`nh1:${e.nzbHash}`),t}let aB=["dashboard","usenet"],aK=[...aB,"settings"],aH=[...aB,"live"],aG=null,aW=0;function aY(e){return(0,eU.I)({queryKey:aK,queryFn:()=>ei("/dashboard/usenet/settings"),staleTime:1e4,enabled:(null==e?void 0:e.enabled)??!0})}function aJ(){return(0,eE.n)({mutationFn:e=>{let t=e.download?"download":"play",s=e.fileSel?`/${encodeURIComponent(e.fileSel)}`:"";return ei(`/dashboard/usenet/library/${encodeURIComponent(e.hash)}/${t}${s}`)}})}let aZ=[...tI.map(e=>({id:`page-${e.href}`,label:e.label,trail:"Page",icon:n.createElement(e.icon),target:{kind:"page",href:e.href},haystack:ay([e.label,e.href])})),...Object.entries(tE).flatMap(e=>{let[t,s]=e,a=tI.find(e=>e.href===t);return s.map(e=>({id:`section-${t}-${e.id}`,label:e.label,trail:(null==a?void 0:a.label)??t,icon:n.createElement(e.icon),target:{kind:"page",href:`${t}/${e.id}`},haystack:ay([e.label,e.id,null==a?void 0:a.label,`${null==a?void 0:a.label} ${e.label}`])}))}),...Object.entries(aI).map(e=>{let[t,s]=e;return{id:`settings-${t}`,label:s.label,trail:`Settings → ${s.group}`,icon:n.createElement(s.icon),target:{kind:"settings",tab:t},haystack:ay([s.label,t,s.group])}})];function aQ(){let{isOpen:e,close:t}
13=tL(),s=(0,M.Z)(),[a,l]=(0,n.useState)(""),i=(0,n.useDeferredValue)(a),o=0===i.trim().length,{data:d}=aF({enabled:e}),{data:c}=aY({enabled:e}),u=(0,n.useMemo)(()=>[...(null==d?void 0:d.keys)??[],...(null==c?void 0:c.keys)??[]].map(e=>{let t=e.key.split("."),s=t[0],a="usenet"===s,r=aM(e.key),l=aI[r],i=(null==l?void 0:l.label)??aU(s),o=t.slice(1,-1).map(aU).join(" → "),d=a?"Usenet → Settings":`Settings → ${i}`;return{id:`field-${e.key}`,label:e.label,trail:o?`${d} → ${o}`:d,icon:n.createElement(a?tC.hQe:(null==l?void 0:l.icon)??tC.nMM),target:a?{kind:"usenet-settings",field:e.key}:{kind:"settings",tab:r,field:e.key},haystack:ay([e.label,e.key,e.env,i,o,`${i} ${e.label}`,...t.slice(1)],[e.description])}}),[null==d?void 0:d.keys,null==c?void 0:c.keys]),m=e=>{switch(t(),l(""),e.kind){case"page":s({to:e.href});break;case"settings":s({to:"/dashboard/settings",search:{tab:e.tab,field:e.field},resetScroll:!1});break;case"usenet-settings":s({to:"/dashboard/usenet/settings",search:{field:e.field},resetScroll:!1})}},p=(0,n.useMemo)(()=>{if(o)return[];let e=aj(i),t=[];for(let s of[...aZ,...u]){let a=aN(s.haystack,e);a>0&&t.push({id:s.id,label:s.label,trail:s.trail,icon:s.icon,score:a,onSelect:()=>m(s.target)})}return t.sort((e,t)=>t.score-e.score)},[i,o,u]);return(0,r.jsx)(ak,{open:e,onClose:()=>{t(),l("")},label:"Dashboard search",placeholder:"Search dashboard pages, sections, settings…",emptyHint:"Enter a page or section to search for…",query:a,onQueryChange:l,isIdle:o,results:p})}let aX="u"<typeof navigator?"":(null==(a=navigator.userAgentData)?void 0:a.platform)||navigator.platform||"",a0=/mac|ios|iphone|ipad|ipod/i.test(aX)?"⌘K":"Ctrl K",a1="flex items-center rounded-md border border-[--border] bg-[--subtle]/50 hover:bg-[--subtle] text-[--muted] hover:text-[--foreground] transition-colors";function a2(e){let{label:t,onOpen:s}=e,a=e3(),n=!a.isBelowBreakpoint,l=()=>{s(),a.setOpen(!1)};return(0,r.jsx)("div",{className:b("mb-3",n?"flex justify-center":"px-4"),children:n?(0,r.jsxs)(to,{side:"right",trigger:(0,r.jsx)("button",{type:"button",onClick:l,"aria-label":t,className:b(a1,"w-11 h-10 justify-center"),children:(0,r.jsx)(tC.iyI,{className:"text-base shrink-0"})}),children:[t," (",a0,")"]}):(0,r.jsxs)("button",{type:"button",onClick:l,"aria-label":t,className:b(a1,"w-full h-9 gap-2 px-3 text-sm"),children:[(0,r.jsx)(tC.iyI,{className:"text-base shrink-0"}),(0,r.jsxs)("span",{className:"flex-1 text-left",children:[t,"…"]}),(0,r.jsx)("kbd",{className:"font-mono text-xs px-1.5 py-0.5 rounded border border-[--border] bg-[--background] text-[--muted] leading-none",children:a0})]})})}function a3(e){let{label:t,onOpen:s}=e;return(0,r.jsxs)("button",{type:"button",onClick:s,"aria-label":t,className:b(a1,"flex-1 h-9 gap-2 px-3 text-sm truncate"),children:[(0,r.jsx)(tC.iyI,{className:"text-base shrink-0"}),(0,r.jsxs)("span",{className:"flex-1 text-left",children:[t,"…"]})]})}function a6(e,t,s){let a=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(!e){a.current=null;return}t&&a.current!==e&&(a.current=e,s(),au([`setting-${e}`]))},[e,t,s])}function a5(){let{open:e}=tL();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"mb-4 p-4 pb-0 flex flex-col items-center w-full",children:[(0,r.jsx)("img",{src:"/logo.png",alt:"AIOStreams",className:"max-w-[90px] max-h-[60px] object-contain p-4"}),(0,r.jsx)("span",{className:"text-xs text-gray-500 mb-3",children:"Dashboard"})]}),(0,r.jsx)(a2,{label:"Search dashboard",onOpen:e})]})}function a4(){let{open:e}=tL();return(0,r.jsx)(a3,{label:"Search dashboard",onOpen:e})}var a9=s(9620),a8=s(9877);function a7(e){return t=>{e.forEach(e=>{"function"==typeof e?e(t):null!=e&&(e.current=t)})}}let re=e=>[Object,Array].includes((e||{}).constructor)&&!Object.entries(e||{}).length,rt={root:(0,h.F)(["UI-Switch__root","peer inline-flex shrink-0 cursor-pointer items-center rounded-full border border-transparent transition-colors","disabled:cursor-not-allowed data-[disabled=true]:opacity-50","outline-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[--ring] focus-visible:ring-offset-1","data-[state=unchecked]:bg-gray-200 dark:data-[state=unchecked]:bg-gray-700","data-[state=unchecked]:hover:bg-gray-300 dark:data-[state=unchecked]:hover:bg-gray-600","data-[state=checked]:bg-brand","data-[error=true]:border-red-500"],{variants:{size:{sm:"h-5 w-9",md:"h-6 w-11",lg:"h-7 w-14"}},defaultVariants:{size:"md"}}),container:(0,h.F)(["UI-Switch__container","inline-flex gap-2 items-center"],{variants:{side:{left:"",right:"w-full flex-row-reverse"}},defaultVariants:{side:"left"}}),thumb:(0,h.F)(["UI-Switch__thumb","pointer-events-none block rounded-full bg-white shadow-lg ring-0 transition-transform","data-[state=unchecked]:translate-x-1"],{variants:{size:{sm:"h-3 w-3 data-[state=checked]:translate-x-[1.1rem]",md:"h-4 w-4 data-[state=checked]:translate-x-[1.4rem]",lg:"h-5 w-5 data-[state=checked]:translate-x-[1.9rem]"}},defaultVariants:{size:"md"}}),label:(0,h.F)(["UI-Switch__label","relative font-normal","data-[disabled=true]:text-gray-300 cursor-pointer user-select-none select-none"])},rs=n.forwardRef((e,t)=>
13{let[{size:s,value:a,className:l,onValueChange:i,labelClass:o,containerClass:d,thumbClass:c,defaultValue:u,inputRef:m,side:p,...h},{label:x,moreHelp:g,...f}]=O(e,n.useId()),v=n.useRef(!0),y=n.useRef(null),[j,w]=n.useState(a??u??!1),N=n.useCallback(e=>{w(e),null==i||i(e)},[]);return n.useEffect(()=>{u&&v.current||w(a),v.current=!1},[a]),(0,r.jsx)(F,{...f,id:f.id,fieldClass:b("w-fit","right"===p&&"w-full group/switch hover:bg-white/5 rounded-[--radius] p-2 w-[calc(100%_+_1rem)] -ml-2"),fieldHelpTextClass:b(""),children:(0,r.jsxs)("div",{className:b(rt.container({side:p}),d),children:[(0,r.jsx)(a8.bL,{ref:a7([y,t]),id:f.id,className:b(rt.root({size:s}),l),disabled:f.disabled||f.readonly,"data-disabled":f.disabled,"data-readonly":f.readonly,"data-error":!!f.error,checked:j,onCheckedChange:N,defaultChecked:u,...h,children:(0,r.jsx)(a8.zi,{className:b(rt.thumb({size:s}),c)})}),(0,r.jsx)("div",{className:"flex flex-1"}),!!x&&(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("label",{className:b(rt.label(),o,"right"===p&&"font-semibold transition-transform __group-hover/switch:-translate-y-0.5"),htmlFor:f.id,"data-disabled":f.disabled,children:x}),g&&(0,r.jsx)(U,{className:"text-sm",trigger:(0,r.jsx)(P.ExT,{className:"transition-opacity opacity-45 hover:opacity-90"}),children:g})]}),(0,r.jsx)("input",{ref:m,type:"checkbox",name:f.name,className:V,value:j?"on":"off",checked:!f.required||j,"aria-hidden":"true",required:void 0===a&&f.required,tabIndex:-1,onChange:()=>{},onFocusCapture:()=>{var e;return null==(e=y.current)?void 0:e.focus()}})]})})});rs.displayName="Switch";var ra=s(5748);let rr={root:(0,h.F)(["UI-Select__root","inline-flex items-center justify-between relative whitespace-nowrap truncate"]),chevronIcon:(0,h.F)(["UI-Combobox__chevronIcon","ml-2 h-4 w-4 shrink-0 opacity-50"]),scrollButton:(0,h.F)(["UI-Select__scrollButton","flex items-center justify-center h-[25px] bg-[--paper] text-base cursor-default"]),content:(0,h.F)(["UI-Select__content","w-full overflow-hidden rounded-[--radius] shadow-md bg-[--paper] border leading-none z-50"]),viewport:(0,h.F)(["UI-Select__viewport","p-1 z-10"]),item:(0,h.F)(["UI-Select__item","text-base leading-none rounded-[--radius] flex items-center h-8 pr-2 pl-8 relative","select-none disabled:opacity-50 disabled:pointer-events-none","data-highlighted:outline-none data-highlighted:bg-[--subtle]","data-[disabled=true]:opacity-50 data-[disabled=true]:pointer-events-none"]),checkIcon:(0,h.F)(["UI-Select__checkIcon","absolute left-2 w-4 inline-flex items-center justify-center"])},rn=n.forwardRef((e,t)=>{let[s,a]=O(e,n.useId()),[{size:l,intent:i,leftAddon:o,leftIcon:d,rightAddon:c,rightIcon:u,className:m,placeholder:p,options:h,chevronIconClass:x,scrollButtonClass:g,contentClass:f,viewportClass:v,checkIconClass:y,itemClass:j,dir:w,value:N,onValueChange:k,onOpenChange:S,defaultValue:C,inputRef:_,...R},{inputContainerProps:A,leftAddonProps:T,leftIconProps:I,rightAddonProps:E,rightIconProps:M}]=G({...s,size:s.size??"md",intent:s.intent??"basic",leftAddon:s.leftAddon,leftIcon:s.leftIcon,rightAddon:s.rightAddon,rightIcon:s.rightIcon}),P=n.useRef(!0),D=n.useRef(null),[L,U]=n.useState(N??C),$=n.useCallback(e=>{if("__placeholder__"===e){U(""),null==k||k("");return}U(e),null==k||k(e)},[]);return n.useEffect(()=>{C&&P.current||U(N),P.current=!1},[N]),(0,r.jsx)(F,{...a,children:(0,r.jsxs)(q,{...A,children:[(0,r.jsx)(H,{...T}),(0,r.jsx)(K,{...I}),(0,r.jsxs)(ra.bL,{dir:w,value:L,onValueChange:$,onOpenChange:S,defaultValue:C,children:[(0,r.jsxs)(ra.l9,{ref:a7([D,t]),id:a.id,className:b(z.root({size:l,intent:i,hasError:!!a.error,
13isDisabled:!!a.disabled,isReadonly:!!a.readonly,hasRightAddon:!!c,hasRightIcon:!!u,hasLeftAddon:!!o,hasLeftIcon:!!d}),rr.root(),m),"aria-label":a.name||"Select",...R,children:[(0,r.jsx)(ra.WT,{placeholder:p}),(0,r.jsx)(ra.In,{className:b(!!u&&"hidden"),children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:b(rr.chevronIcon(),x),children:(0,r.jsx)("path",{d:"m6 9 6 6 6-6"})})})]}),(0,r.jsx)(ra.ZL,{children:(0,r.jsxs)(ra.UC,{className:b(rr.content(),f),children:[(0,r.jsx)(ra.PP,{className:b(rr.scrollButton(),g),children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:b(rr.chevronIcon(),"rotate-180",x),children:(0,r.jsx)("path",{d:"m6 9 6 6 6-6"})})}),(0,r.jsxs)(ra.LM,{className:b(rr.viewport(),v),children:[!!p&&!a.required&&(0,r.jsx)(ra.q7,{className:b(rr.item(),j),value:"__placeholder__",children:(0,r.jsx)(ra.p4,{className:"flex-none whitespace-nowrap truncate",children:p})}),null==h?void 0:h.map(e=>(0,r.jsxs)(ra.q7,{className:b(rr.item(),j),value:e.value,disabled:e.disabled,"data-disabled":e.disabled,children:[(0,r.jsx)(ra.p4,{className:"flex-none whitespace-nowrap truncate",children:e.label}),(0,r.jsx)(ra.VF,{asChild:!0,children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:b(rr.checkIcon(),y),children:(0,r.jsx)("path",{d:"M20 6 9 17l-5-5"})})})]},e.value))]}),(0,r.jsx)(ra.wn,{className:b(rr.scrollButton(),g),children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:b(rr.chevronIcon(),x),children:(0,r.jsx)("path",{d:"m6 9 6 6 6-6"})})})]})})]}),(0,r.jsxs)("select",{ref:_,name:a.name,className:V,"aria-hidden":"true",required:a.required,disabled:a.disabled,value:L,tabIndex:-1,onChange:()=>{},onFocusCapture:()=>{var e;return null==(e=D.current)?void 0:e.focus()},children:[(0,r.jsx)("option",{value:""}),null==h?void 0:h.map(e=>(0,r.jsx)("option",{value:e.value,disabled:e.disabled},e.value))]}),(0,r.jsx)(H,{...E}),(0,r.jsx)(K,{...M})]})})});function rl(e,t){let s={};try{s=JSON.parse(t)}catch{return{seq:e,time:"",level:"info",msg:t,raw:t,obj:{}}}let{level:a,time:r,module:n,msg:l,...i}=s;return{seq:e,time:"string"==typeof r?r:"",level:"string"==typeof a?a:"info",module:"string"==typeof n?n:void 0,msg:"string"==typeof l?l:"",raw:t,obj:i}}function ri(e){let t=new URLSearchParams;return e.q.trim()&&t.set("q",e.q.trim()),e.q.trim()&&e.regex&&t.set("regex","true"),e.levels.length&&t.set("level",e.levels.join(",")),e.module&&t.set("module",e.module),t.toString()}function ro(e,t){let s=ri(e);return`/api/v1/dashboard/logs/export?format=${t}${s?`&${s}`:""}`}function rd(e,t){let[s,a]=(0,n.useState)(e);return(0,n.useEffect)(()=>{let s=setTimeout(()=>a(e),t||500);return()=>{clearTimeout(s)}},[e,t]),s}rn.displayName="Select";let rc={initial:{opacity:0,y:60},animate:{opacity:1,y:0},exit:{opacity:0,y:60},transition:{type:"spring",damping:20,stiffness:100}};function ru(e){let{children:t,className:s,...a}=e;return(0,r.jsx)("div",{"data-page-wrapper-container":!0,children:(0,r.jsx)(th.P.div,{"data-page-wrapper":!0,...rc,...a,className:b("z-[5] relative",s),children:t})})}async function rm(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{onSuccess:s,onError:a}=t;if(navigator.clipboard&&navigator.clipboard.writeText)try{await navigator.clipboard.writeText(e),null==s||s();return}catch(e){}let r=null,n=null,l=null,i=null;try{if(r=function(){var e;let t=document.getSelection();if(!t||0===t.rangeCount)return()=>{};let s=document.activeElement,a=[];for(let e=0;e<t.rangeCount;e++)a.push(t.getRangeAt(e));switch(null==s||null==(e=s.tagName)?void 0:e.toUpperCase()){case"INPUT":case"TEXTAREA":s.blur();break;default:s=null}return t.removeAllRanges(),()=>{"Caret"===t.type&&t.removeAllRanges(),0===t.rangeCount&&a.forEach(e
13=>t.addRange(e)),s&&s.focus()}}(),n=document.createRange(),!(l=document.getSelection()))throw Error("Unable to get document selection");if((i=document.createElement("span")).textContent=e,i.setAttribute("aria-hidden","true"),i.style.all="unset",i.style.position="fixed",i.style.top="0",i.style.clip="rect(0, 0, 0, 0)",i.style.whiteSpace="pre",i.style.userSelect="text",i.style.MozUserSelect="text",i.style.msUserSelect="text",i.style.userSelect="text",i.addEventListener("copy",e=>{e.stopPropagation()}),document.body.appendChild(i),n.selectNodeContents(i),l.addRange(n),!document.execCommand("copy"))throw Error("copy command was unsuccessful")}catch(t){try{window.clipboardData.setData("text",e)}catch(r){let t=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";window.prompt(`Copy to clipboard: ${t}, Enter`,e);let s=Error("Copy failed - user prompt shown");null==a||a(s);return}}finally{l&&("function"==typeof l.removeRange&&n?l.removeRange(n):l.removeAllRanges()),i&&document.body.removeChild(i),null==r||r()}null==s||s()}let rp=["B","KB","MB","GB","TB","PB"],rh=["bps","Kbps","Mbps","Gbps","Tbps"];function rx(e){let{placeholder:t="—"}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(null==e||!Number.isFinite(e))return t;if(0===e)return"0 B";let s=Math.min(rp.length-1,Math.max(0,Math.floor(Math.log(Math.abs(e))/Math.log(1e3))));return`${(e/1e3**s).toFixed(+(0!==s))} ${rp[s]}`}function rg(e,t){return null!=e&&Number.isFinite(e)?`${rx(e,t)}/s`:rx(e,t)}function rf(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!Number.isFinite(e)||e<=0)return"0 bps";let s=Math.min(rh.length-1,Math.max(0,Math.floor(Math.log(e)/Math.log(1e3)))),a=e/1e3**s,r=t?Math.round(a):parseFloat(a.toFixed(1));return`${r} ${rh[s]}`}function rb(e){return Number.isFinite(e)?`${(100*e).toFixed(e>0&&e<.001?2:1)}%`:"0%"}let rv=[["w",604800],["d",86400],["h",3600],["m",60],["s",1]];function ry(e){if(!Number.isFinite(e))return"0s";let t=Math.max(0,Math.round(e));if(t<1)return"0s";if(t<60)return`${t}s`;for(let e=0;e<rv.length;e++){let[s,a]=rv[e],r=Math.floor(t/a);if(r>0){let n=t-r*a,l=rv[e+1];if(l&&n>0){let e=Math.floor(n/l[1]);if(e>0)return`${r}${s} ${e}${l[0]}`}return`${r}${s}`}}return"0s"}let rj={ms:1,s:1e3,m:6e4,h:36e5,d:864e5,w:6048e5};function rw(e){let t,s=e.trim();if(""===s)return null;if(/^-?\d+(\.\d+)?$/.test(s)){let e=Number(s);return Number.isFinite(e)&&e>=0?Math.round(e):null}let a=s.replace(/\s+/g,"").toLowerCase(),r=/(\d+(?:\.\d+)?)(ms|w|d|h|m|s)/g,n=0,l=0;for(;null!==(t=r.exec(a));)n+=parseFloat(t[1])*rj[t[2]],l+=t[0].length;return 0===l||l!==a.length?null:Math.round(n)}function rN(e){if(!Number.isFinite(e)||e<0)return"";if(0===e)return"0ms";if(e<1e3)return`${Math.round(e)}ms`;let t=e/1e3;if(t<60)return`${parseFloat(t.toFixed(2))}s`;let s=Math.round(t),a=[];for(let[e,t]of[["w",604800],["d",86400],["h",3600],["m",60],["s",1]])s>=t&&(a.push(`${Math.floor(s/t)}${e}`),s%=t);return a.slice(0,2).join(" ")}function rk(e){let t=Math.max(0,Math.floor(e/1e3)),s=Math.floor(t/3600),a=Math.floor(t%3600/60),r=t%60,n=e=>String(e).padStart(2,"0");return s>0?`${s}:${n(a)}:${n(r)}`:`${a}:${n(r)}`}function rS(e){if(!Number.isFinite(e))return"0";let t=Math.abs(e);if(t<1e3)return e.toLocaleString();for(let s of[{v:1e9,s:"B"},{v:1e6,s:"M"},{v:1e3,s:"K"}])if(t>=s.v){let t=e/s.v,a=+(100>Math.abs(t)),r=t.toFixed(a);return r.endsWith(".0")&&(r=r.slice(0,-2)),r+s.s}return e.toLocaleString()}function rC(e){if(!e)return"";let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}let r_=["trace","debug","info","warn","error","fatal"],rR={trace:"text-[--muted]",debug:"text-sky-500",info:"text-emerald-500",warn:"text-amber-500",error:"text-red-500",fatal:"text-red-600 font-bold"},rA={trace:"bg-gray-400",debug:"bg-sky-500",info:"bg-emerald-500",warn:"bg-amber-500",error:"bg-red-500",fatal:"bg-red-600"},rT="__all__",rI="aiostreams.logs.prefs";function rE(){try{let e=localStorage.getItem(rI);if(e)return{...rM,...JSON.parse(e)}}catch{}return rM}let rM={autoscroll:!0,wrap:!1,levels:[]};function rP(e){let{row:t,wrap:s,expanded:a,onToggle:l}=e,i=rC(t.time),o=Object.keys(t.obj).length>
130,[d,c]=(0,n.useState)(!1),u=a?JSON.stringify(JSON.parse(t.raw)):[i,t.level,t.module?`[${t.module}]`:"",t.msg,o?Object.entries(t.obj).map(e=>{let[t,s]=e;return`${t}=${"object"==typeof s?JSON.stringify(s):s}`}).join(" "):""].filter(Boolean).join(" ");return(0,r.jsxs)("div",{className:b("relative px-3 py-1.5 border-b border-[--border] cursor-pointer hover:bg-[--subtle] font-mono text-xs leading-relaxed group",s?"whitespace-pre-wrap break-words":"whitespace-pre"),onClick:l,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[(0,r.jsx)("span",{className:"inline-block px-2 py-0.5 rounded-full bg-brand/15 text-brand font-medium tabular-nums",children:i})," ",(0,r.jsx)("span",{className:b("inline-block w-2 h-2 rounded-full align-middle",rA[t.level]??"bg-[--muted]"),title:t.level})," ",t.module&&(0,r.jsxs)("span",{className:"text-[--muted-highlight]",children:["[",t.module,"]"]})," ",(0,r.jsx)("span",{className:"text-[--foreground]",children:t.msg}),o&&!a&&(0,r.jsxs)("span",{className:"text-[--muted]",children:[" ",Object.entries(t.obj).map(e=>{let[t,s]=e;return`${t}=${"object"==typeof s?"{…}":s}`}).join(" ")]}),a&&(0,r.jsx)("pre",{className:"mt-1 p-2 rounded bg-[--subtle] text-[--foreground] whitespace-pre-wrap break-all",children:JSON.stringify(JSON.parse(t.raw),null,2)}),d&&(0,r.jsx)("button",{type:"button","aria-label":"Copy log line",className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 rounded text-[--muted] hover:text-[--foreground] hover:bg-[--paper] transition-colors",onClick:e=>{e.stopPropagation(),rm(u,{onSuccess:()=>x.oR.success("Copied log line"),onError(e){x.oR.error("Failed to copy: "+e),console.error("Failed to copy log line:",e)}})},children:(0,r.jsx)(tC.Xpf,{className:"text-sm"})})]})}var rD=s(730),rL=s(9623),rU=s(3366);let r$={root:(0,h.F)(["UI-Tabs__root"]),list:(0,h.F)(["UI-Tabs__list","inline-flex h-12 items-center justify-center w-full"]),trigger:(0,h.F)(["UI-Tabs__trigger appearance-none shadow-none","inline-flex h-full items-center justify-center whitespace-nowrap px-3 py-1.5 text-sm text-[--muted] font-medium ring-offset-[--background]","transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","disabled:pointer-events-none disabled:opacity-50","border-transparent border-b-2 -mb-px","data-[state=active]:border-[--brand] data-[state=active]:text-[--foreground]"]),content:(0,h.F)(["UI-Tabs__content","ring-offset-[--background]","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[--ring] focus-visible:ring-offset-2"])},rO=n.createContext({}),rF=n.forwardRef((e,t)=>{let{className:s,listClass:a,triggerClass:n,contentClass:l,...i}=e;return(0,r.jsx)(rO.Provider,{value:{listClass:a,triggerClass:n,contentClass:l},children:(0,r.jsx)(rU.bL,{ref:t,className:b(r$.root(),s),...i})})});rF.displayName="Tabs";let rz=n.forwardRef((e,t)=>{let{className:s,...a}=e,{listClass:l}=n.useContext(rO);return(0,r.jsx)(rU.B8,{ref:t,className:b(r$.list(),l,s),...a})});rz.displayName="TabsList";let rV=n.forwardRef((e,t)=>{let{className:s,...a}=e,{triggerClass:l}=n.useContext(rO);return(0,r.jsx)(rU.l9,{ref:t,className:b(r$.trigger(),l,s),...a})});rV.displayName="TabsTrigger";let rq=n.forwardRef((e,t)=>{let{className:s,...a}=e,{contentClass:l}=n.useContext(rO);return(0,r.jsx)(rU.UC,{ref:t,className:b(r$.content(),l,s),...a})});rq.displayName="TabsContent";let rB={root:(0,h.F)(["UI-StaticTabs__root","flex w-full overflow-hidden overflow-x-auto"]),trigger:(0,h.F)(["UI-StaticTabs__trigger","group/staticTabs__trigger inline-flex flex-none shrink-0 basis-auto items-center font-medium text-sm transition outline-none min-w-0 justify-center","text-[--muted] hover:text-[--foreground]","h-10 px-4 rounded-full","data-[current=true]:bg-[--subtle] data-[current=true]:font-semibold data-[current=true]:text-[--foreground]","focus-visible:bg-[--subtle]"]),icon:(0,h.F)(["UI-StaticTabs__icon","-ml-0.5 mr-2 h-4 w-4"])},rK=n.forwardRef((e,t)=>{let{children:s,className:a,triggerClass:n,iconClass:l,items:i,...o}=e;return(0,r.jsx)("nav",{ref:t,className:b(rB.root(),a),role:"navigation",...o,children:i.map(e=>e.href?(0,r.jsxs)("a",{href:e.href??"#",className:b("cursor-pointer",rB.trigger(),n),"aria-current":e.isCurrent?"page":void 0,"data-current":e.isCurrent,children:[e.iconType&&(0,r.jsx)(e.iconType,{className:b(rB.icon(),l),"aria-hidden":"true","data-current":e.isCurrent}),(0,r.jsx)("span",{children:e.name})]},e.name):(0,r.jsxs)("div",{className:b(rB.trigger(),"cursor-pointer",n),"aria-current":e.isCurrent?"page":void 0,"data-current":e.isCurrent,onClick:e.onClick,children:[e.iconType&&(0,r.jsx)(e.iconType,{className:b(rB.icon(),l),"aria-hidden":"true","data-current":e.isCurrent}),(0,r.jsx)("span",{children:e.name})]},e.name))})});rK.displayName="StaticTabs";var rH=s(2979),rG=s(2436);function rW(e){return Object.fromEntries(Object.entries(e.shape).map(e=>{let[t,s]=e;return s instanceof rL.Xi?[t,s.parse(void 0)]:[t,void 0]}))}let rY=n.createContext(void 0),rJ=e=>{let{mode:t="onSubmit",resolver:s,reValidateMode:a,shouldFocusError:l,shouldUnregister:i,shouldUseNativeValidation:o,criteriaMode:d,delayError:c,schema:u,defaultValues:m,onChange:p,onSubmit:h,onError:x,formRef:g,children:f,mRef:v,stackClass:y,...j}=e,w=n.useMemo(()=>
13{if(!(re(rW(u))&&re(m)))return{...rW(u),...m}},[]),N=(0,rG.mN)({mode:t,resolver:(0,rH.u)(u),defaultValues:w,reValidateMode:a,shouldFocusError:l,shouldUnregister:i,shouldUseNativeValidation:o,criteriaMode:d,delayError:c}),{handleSubmit:k}=N;return n.useImperativeHandle(v,()=>N,[v,N]),n.useEffect(()=>{let e;return p&&(e=N.watch(p)),()=>null==e?void 0:e.unsubscribe()},[N,p]),(0,r.jsx)(rG.Op,{...N,children:(0,r.jsx)(rY.Provider,{value:{schema:u,shape:u.shape},children:(0,r.jsx)("form",{ref:g,onSubmit:k(h,x),...j,children:(0,r.jsx)("div",{className:b("w-full space-y-3",y),children:function(e){for(var t=arguments.length,s=Array(t>1?t-1:0),a=1;a<t;a++)s[a-1]=arguments[a];return"function"==typeof e?e(...s):e}(f,N)})})})})};rJ.displayName="Form";var rZ=s(5070),rQ=s(7680),rX=s(5807);let r0={root:(0,h.F)(["UI-Autocomplete__root"]),popover:(0,h.F)(["UI-Autocomplete__popover","w-[--radix-popover-trigger-width] p-0"]),checkIcon:(0,h.F)(["UI-Autocomplete__checkIcon","h-4 w-4","data-[selected=true]:opacity-100 data-[selected=false]:opacity-0"]),container:(0,h.F)(["UI-Autocomplete__container","relative w-full"]),command:(0,h.F)(["UI-Autocomplete__command","focus-within:ring-2 ring-[--ring] transition"])},r1=n.forwardRef((e,t)=>{let[s,a]=O(e,n.useId()),[{size:l,intent:i,leftAddon:o,leftIcon:d,rightAddon:c,rightIcon:u,className:m,popoverClass:p,checkIconClass:h,containerClass:x,commandClass:g,commandProps:f,options:v,emptyMessage:y,placeholder:j,value:w,onValueChange:N,onTextChange:k,onChange:S,defaultValue:C,autoFilter:_=!0,isFetching:R,type:A,...T},{inputContainerProps:I,leftAddonProps:E,leftIconProps:M,rightAddonProps:P,rightIconProps:D}]=G({...s,size:s.size??"md",intent:s.intent??"basic",leftAddon:s.leftAddon,leftIcon:s.leftIcon,rightAddon:s.rightAddon,rightIcon:s.rightIcon}),L=n.useRef(!0),$=n.useRef(!1),B=n.useRef((null==w?void 0:w.label)||(null==C?void 0:C.label)||""),[W,Y]=n.useState((null==w?void 0:w.label)||(null==C?void 0:C.label)||""),J=n.useDeferredValue(W);B.current=W;let Z=n.useRef(w||C||void 0),[Q,X]=n.useState(w||C||void 0),[ee,et]=n.useState(!1),es=n.useMemo(()=>_?v.filter(e=>e.label.toLowerCase().includes(J.toLowerCase())):v,[_,v,J]),ea=!!y||v.length>0&&es.length>0,er=n.useCallback((e,t)=>e.toLowerCase()===t.toLowerCase(),[]),en=n.useRef(null),el=n.useRef(null);n.useEffect(()=>{$.current||(C&&L.current||(Y((null==w?void 0:w.label)??""),X(w),eu(w)),L.current=!1)},[w]);let ei=n.useCallback(e=>{a.disabled||a.readonly||0===v.length&&e||(B.current!==W||!e||0!==es.length)&&(et(e),e||n.startTransition(()=>{var e;null==(e=en.current)||e.focus()}))},[v,W,a.disabled,a.readonly]),eo=n.useCallback(e=>{$.current=!0,null==S||S(e),Y(e.target.value),_&&es.length>0&&et(!0)},[es]);n.useEffect(()=>{let e=v.find(e=>er(e.label,J));e?ed(e):J.length>0?ed({value:null,label:J}):0===J.length&&ed(void 0),$.current=!1},[J,_]);let ed=n.useCallback(e=>{X(e),null==N||N(e),null==k||k((null==e?void 0:e.label)??""),eu(e)},[]),ec=n.useCallback(e=>{if(ee||et(!0),"ArrowDown"===e.key){var t;e.preventDefault(),null==(t=el.current)||t.focus()}},[ee]),eu=n.useCallback(e=>{((null==e?void 0:e.value)||void 0===e)&&(Z.current=e)},[]),em=n.useCallback(()=>{"options"===A&&n.startTransition(()=>{Z.current?Y(Z.current.label):Y("")})},[]);return(0,r.jsx)(F,{...a,children:(0,r.jsxs)(q,{...I,children:[(0,r.jsx)(H,{...E}),(0,r.jsx)(K,{...M}),(0,r.jsx)(U,{open:ee&&ea,onOpenChange:ei,className:b(r0.popover(),p),onOpenAutoFocus:e=>e.preventDefault(),trigger:(0,r.jsx)("div",{className:b(r0.container(),x),children:(0,r.jsx)("input",{ref:a7([en,t]),id:a.id,name:a.name,value:W,onChange:eo,onBlur:em,placeholder:j,className:b(z.root({size:l,intent:i,hasError:!!a.error,
13isDisabled:!!a.disabled,isReadonly:!!a.readonly,hasRightAddon:!!c,hasRightIcon:!!u,hasLeftAddon:!!o,hasLeftIcon:!!d}),r0.root()),disabled:a.disabled||a.readonly,"data-disabled":a.disabled,"data-error":!!a.error,"aria-readonly":a.readonly,"data-readonly":a.readonly,onKeyDown:ec,required:a.required,...T})}),children:(0,r.jsxs)(tz,{className:b(r0.command(),g),inputContainerClass:"py-1",shouldFilter:_,...f,children:[R&&W.length>0&&(0,r.jsx)("div",{className:"w-full absolute top-0 left-0 px-1",children:(0,r.jsx)("div",{className:"h-1 w-full bg-[--subtle] overflow-hidden relative rounded-full",children:(0,r.jsx)("div",{className:"animate-indeterminate-progress absolute left-0 w-full h-full bg-brand origin-left-right"})})}),(0,r.jsx)(tV,{value:W,onValueChange:Y,inputContainerClass:V,"aria-hidden":"true",ref:el}),(0,r.jsxs)(tq,{children:[!!y&&(0,r.jsx)(tB,{children:y}),(0,r.jsx)(tK,{children:v.map(e=>(0,r.jsx)(tH,{value:e.label,onSelect:e=>{let t=v.find(t=>er(t.label,e));t&&((null==Q?void 0:Q.value)===t.value?(ed(void 0),Y("")):(ed(t),Y(t.label))),n.startTransition(()=>{var e;null==(e=en.current)||e.focus()})},leftIcon:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:b(r0.checkIcon(),h),"data-selected":er(e.label,W),children:(0,r.jsx)("path",{d:"M20 6 9 17l-5-5"})}),children:e.label},e.value))})]})]})}),(0,r.jsx)(H,{...P}),(0,r.jsx)(K,{...D})]})})});r1.displayName="Autocomplete";var r2=s(251);let r3={container:(0,h.F)("UI-Checkbox__container inline-flex gap-2 items-center"),root:(0,h.F)(["UI-Checkbox__root","appearance-none peer block relative overflow-hidden transition h-5 w-5 shrink-0 text-white rounded-[--radius-md] ring-offset-1 border ring-offset-[--background]","border-gray-300 dark:border-gray-700","outline-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[--ring] disabled:cursor-not-allowed data-[disabled=true]:opacity-50","data-[state=unchecked]:bg-white dark:data-[state=unchecked]:bg-gray-700","data-[state=unchecked]:hover:bg-gray-100 dark:data-[state=unchecked]:hover:bg-gray-600","data-[state=checked]:bg-brand dark:data-[state=checked]:bg-brand data-[state=checked]:border-brand","data-[state=indeterminate]:bg-[--muted] dark:data-[state=indeterminate]:bg-gray-700 data-[state=indeterminate]:text-white data-[state=indeterminate]:border-transparent","data-[error=true]:border-red-500 data-[error=true]:dark:border-red-500 data-[error=true]:data-[state=checked]:border-red-500 data-[error=true]:dark:data-[state=checked]:border-red-500"],{variants:{size:{sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6"}},defaultVariants:{size:"md"}}),label:(0,h.F)(["UI-Checkbox_label","font-normal","data-[disabled=true]:opacity-50"],{variants:{size:{sm:"text-sm",md:"text-md",lg:"text-lg"}},defaultVariants:{size:"md"}}),indicator:(0,h.F)(["UI-Checkbox__indicator","flex h-full w-full items-center justify-center relative"]),checkIcon:(0,h.F)("UI-Checkbox__checkIcon absolute",{variants:{size:{sm:"h-3 w-3",md:"h-4 w-4",lg:"h-5 w-5"}},defaultVariants:{size:"md"}})},r6=n.forwardRef((e,t)=>{let[{className:s,hideError:a,containerClass:l,checkIconClass:i,labelClass:o,indicatorClass:d,onValueChange:c,defaultValue:u,value:m,size:p,inputRef:h,...x},{label:g,...f}]=O(e,n.useId()),v=n.useContext(r5),y=(null==v?void 0:v.group_size)??p,j=n.useRef(!0),w=n.useRef(null),[N,k]=n.useState(m??u??!1),S=n.useCallback(e=>{k(e),null==c||c(e)},[c]);return n.useEffect(()=>{u&&j.current||k(m??!1),j.current=!1},[m]),(0,r.jsx)(F,{fieldClass:"flex gap-2",...f,error:a?void 0:f.error,children:(0,r.jsxs)("label",{className:b(r3.container(),l),htmlFor:f.id,children:[(0,r.jsx)(r2.bL,{ref:a7([w,t]),id:f.id,className:b(r3.root({size:y}),s),disabled:f.disabled||f.readonly,"data-error":!!f.error,"data-disabled":f.disabled,"aria-readonly":f.readonly,"data-readonly":f.readonly,checked:N,onCheckedChange:S,...x,children:(0,r.jsxs)(r2.P7,{className:b(r3.indicator(),d),children:["indeterminate"!==N&&(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",stroke:"currentColor",fill:"
13currentColor",className:b(r3.checkIcon({size:y}),i),children:(0,r.jsx)("path",{d:"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"})}),"indeterminate"===N&&(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",className:b(r3.checkIcon({size:y}),i),children:(0,r.jsx)("line",{x1:"5",x2:"19",y1:"12",y2:"12"})})]})}),!!g&&(0,r.jsx)("label",{className:b(r3.label({size:y}),o),htmlFor:f.id,"data-disabled":f.disabled,"data-checked":!0===N,children:g}),(0,r.jsx)("input",{ref:h,type:"checkbox",name:f.name,className:V,value:"indeterminate"===N?"indeterminate":N?"on":"off",checked:!f.required||!0===N,"aria-hidden":"true",required:void 0===m&&f.required,tabIndex:-1,onChange:()=>{},onFocusCapture:()=>{var e;return null==(e=w.current)?void 0:e.focus()}})]})})});r6.displayName="Checkbox";let r5=n.createContext(null),r4=n.forwardRef((e,t)=>{let[{value:s,defaultValue:a=[],onValueChange:l,stackClass:i,itemLabelClass:o,itemClass:d,itemContainerClass:c,itemCheckIconClass:u,options:m,size:p},h]=O(e,n.useId()),[x,g]=n.useState(s??a),f=n.useCallback(e=>t=>{g(s=>{let a=!0===t?[...s,...s.includes(e)?[]:[e]]:!1===t?s.filter(t=>t!==e):[...s];return null==l||l(a),a})},[]);return n.useEffect(()=>{void 0!==s&&g(s)},[s]),(0,r.jsx)(r5.Provider,{value:{group_size:p},children:(0,r.jsxs)(F,{...h,children:[(0,r.jsx)("div",{className:b("UI-CheckboxGroup__stack space-y-1",i),children:m.map(e=>(0,r.jsx)(r6,{label:e.label,value:x.includes(e.value),onValueChange:f(e.value),hideError:!0,error:h.error,className:d,labelClass:o,containerClass:c,checkIconClass:u,disabled:h.disabled||e.disabled,readonly:h.readonly||e.readonly,tabIndex:0},e.value))}),(0,r.jsx)("input",{ref:t,type:"text",id:h.name,name:h.name,className:V,value:h.required?x.length?JSON.stringify(x):"":JSON.stringify(x),"aria-hidden":"true",required:h.required,tabIndex:-1,onChange:()=>{}})]})})});r4.displayName="CheckboxGroup";var r9=s(7371),r8=s.n(r9);let r7={root:(0,h.F)(["UI-Combobox__root","justify-between h-auto"],{variants:{size:{sm:"min-h-8 px-2 py-1 text-sm",md:"min-h-10 px-3 py-2 ",lg:"min-h-12 px-4 py-3 text-md"}},defaultVariants:{size:"md"}}),popover:(0,h.F)(["UI-Combobox__popover","w-[--radix-popover-trigger-width] p-0"]),checkIcon:(0,h.F)(["UI-Combobox__checkIcon","h-4 w-4","data-[selected=true]:opacity-100 data-[selected=false]:opacity-0"]),item:(0,h.F)(["UI-Combobox__item","flex gap-1 items-center flex-none truncate bg-gray-100 dark:bg-gray-800 px-2 pr-1 rounded-[--radius] max-w-96"]),placeholder:(0,h.F)(["UI-Combobox__placeholder","text-[--muted] truncate"]),inputValuesContainer:(0,h.F)(["UI-Combobox__inputValuesContainer","grow flex overflow-hidden gap-2 flex-wrap"]),chevronIcon:(0,h.F)(["UI-Combobox__chevronIcon","ml-2 h-4 w-4 shrink-0 opacity-50"]),removeItemButton:(0,h.F)(["UI-Badge__removeItemButton","text-lg cursor-pointer transition ease-in hover:opacity-60"])},ne=n.forwardRef((e,t)=>{let[s,a]=O(e,n.useId()),[{size:l,intent:i,leftAddon:o,leftIcon:d,rightAddon:c,rightIcon:u,className:m,popoverClass:p,checkIconClass:h,itemClass:x,placeholderClass:g,inputValuesContainerClass:f,chevronIconClass:v,removeItemButtonClass:y,commandProps:j,options:w,emptyMessage:N,placeholder:k,value:S,onValueChange:C,onTextChange:_,multiple:R=!1,defaultValue:A,inputRef:T,keepOpenOnSelect:I=!0,maxItems:E,...M},{inputContainerProps:P,leftAddonProps:D,leftIconProps:L,rightAddonProps:$,rightIconProps:B}]=G({...s,size:s.size??"md",intent:s.intent??"basic",leftAddon:s.leftAddon,leftIcon:s.leftIcon,rightAddon:s.rightAddon,rightIcon:s.rightIcon}),W=n.useRef(null),Y=n.useRef(S||A||[]),[J,Z]=n.useState(S||A||[]),[Q,X]=n.useState(!1),ee=n.useCallback(e=>{Z(e),Y.current=e},[]);n.useEffect(()=>{void 0===S||r8()(S,Y.current)||ee(S)},[S]),n.useEffect(()=>{null==C||C(J)},[J]);let et={},es=w.map(e=>{var t,s;let a=(null==(t=e.textValue||e.value)?void 0:t.trim())||"Unnamed",r="string"==typeof e.label?(null==(s=e.label)?void 0:s.trim())||"Unnamed":e.label;return et[a]=(et[a]||0)+1,{...e,label:et[a]>1?`${r} (${et[a]})`:r,textValue:et[a]>1?`${a} (${et[a]})`:a}}),ea=es.filter(e=>J.includes(e.value)),er=R&&"number"==typeof E&&J.length>=E,en=J.length&&ea.length?R?ea.map(e=>(0,r.jsxs)("div",{className:b(r7.item(),x),children:[(0,r.jsx)("span",{className:"truncate",children:e.textValue||e.value}),(0,r.jsx)("span",{className:b(r7.removeItemButton(),"rounded-full",y),onClick:t=>{t.preventDefault(),ee(J.filter(t=>t!==e.value)),X(!1)},children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"16",height:"16",fill:"currentColor",children:(0,r.jsx)("path",{d:"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"})})})]},e.value)):(0,r.jsx)("span",{className:"truncate",children:ea[0].label}):(0,r.jsx)("span",{className:b(r7.placeholder(),g),children:k});return(0,r.jsx)(F,{...a,children:(0,r.jsxs)(q,{...P,children:[(0,r.jsx)(H,{...D}),(0,r.jsx)(K,{...L}
13),(0,r.jsx)(U,{open:Q,onOpenChange:X,className:b(r7.popover(),p),trigger:(0,r.jsxs)("button",{ref:a7([W,t]),id:a.id,role:"combobox","aria-expanded":Q,className:b(z.root({size:l,intent:i,hasError:!!a.error,isDisabled:!!a.disabled,isReadonly:!!a.readonly,hasRightAddon:!!c,hasRightIcon:!!u,hasLeftAddon:!!o,hasLeftIcon:!!d}),r7.root({size:l})),...M,children:[(0,r.jsx)("div",{className:b(r7.inputValuesContainer()),children:en}),(0,r.jsxs)("div",{className:"flex items-center",children:[!!J.length&&!!ea.length&&!R&&(0,r.jsx)("span",{className:b(r7.removeItemButton(),y),onClick:e=>{e.preventDefault(),ee([]),X(I)},children:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"16",height:"16",fill:"currentColor",children:(0,r.jsx)("path",{d:"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"})})}),(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:b(r7.chevronIcon(),v),children:[(0,r.jsx)("path",{d:"m7 15 5 5 5-5"}),(0,r.jsx)("path",{d:"m7 9 5-5 5 5"})]})]})]}),children:(0,r.jsxs)(tz,{inputContainerClass:"py-1",...j,children:[(0,r.jsx)(tV,{placeholder:k,onValueChange:_}),(0,r.jsxs)(tq,{children:[(0,r.jsx)(tB,{children:N}),(0,r.jsx)(tK,{children:es.map(e=>{let t=er&&!J.includes(e.value);return(0,r.jsx)(tH,{value:e.textValue||e.value,disabled:t,className:b(t&&"opacity-50 cursor-not-allowed pointer-events-none"),onSelect:e=>{let t=es.find(t=>(t.textValue||t.value).toLowerCase()===e.toLowerCase());t&&(R?ee(J.includes(t.value)?J.filter(e=>e!==t.value):[...J,t.value]):ee(J.includes(t.value)?[]:[t.value])),X(I)},leftIcon:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:b(r7.checkIcon(),h),"data-selected":J.includes(e.value),children:(0,r.jsx)("path",{d:"M20 6 9 17l-5-5"})}),children:e.label},e.value)})})]})]})}),(0,r.jsx)("input",{ref:T,type:"text",name:a.name,className:V,value:a.required?J.length?JSON.stringify(J):"":JSON.stringify(J),"aria-hidden":"true",required:a.required,tabIndex:-1,onChange:()=>{},onFocusCapture:()=>{var e;return null==(e=W.current)?void 0:e.focus()}}),(0,r.jsx)(H,{...$}),(0,r.jsx)(K,{...B})]})})});ne.displayName="Combobox";let nt=n.forwardRef((e,t)=>{let[s,a]=O(e,n.useId()),[{size:l,intent:i,leftAddon:o,leftIcon:d,rightAddon:c,rightIcon:u,className:m,placeholder:p,options:h,...x},{inputContainerProps:g,leftAddonProps:f,leftIconProps:v,rightAddonProps:y,rightIconProps:j}]=G({...s,size:s.size??"md",intent:s.intent??"basic",leftAddon:s.leftAddon,leftIcon:s.leftIcon,rightAddon:s.rightAddon,rightIcon:s.rightIcon});return(0,r.jsx)(F,{...a,children:(0,r.jsxs)(q,{...g,children:[(0,r.jsx)(H,{...f}),(0,r.jsx)(K,{...v}),(0,r.jsxs)("select",{id:a.id,name:a.name,className:b("form-select",z.root({size:l,intent:i,hasError:!!a.error,
13isDisabled:!!a.disabled,isReadonly:!!a.readonly,hasRightAddon:!!c,hasRightIcon:!!u,hasLeftAddon:!!o,hasLeftIcon:!!d}),m),disabled:a.disabled||a.readonly,"data-disabled":a.disabled,"data-readonly":a.readonly,"aria-readonly":a.readonly,required:a.required,...x,ref:t,children:[p&&(0,r.jsx)("option",{value:"",children:p}),null==h?void 0:h.map(e=>(0,r.jsx)("option",{value:e.value,children:e.label??e.value},e.value))]}),(0,r.jsx)(H,{...y}),(0,r.jsx)(K,{...j,className:b(j.className,c?null:"mr-8")})]})})});nt.displayName="NativeSelect";var ns=s(3121),na=s(2523);let nr={root:(0,h.F)(["UI-NumberInput__root","z-[2]"],{variants:{hideControls:{true:!1,false:"border-r border-r-transparent hover:border-r-[--border]"},size:{sm:null,md:null,lg:null},intent:{basic:null,filled:null,unstyled:"border-r-0 hover:border-r-transparent"}},defaultVariants:{hideControls:!1}}),control:(0,h.F)(["UI-NumberInput__control","rounded-none h-[50%] ring-inset"]),controlsContainer:(0,h.F)(["UI-NumberInput__controlsContainer","form-input w-auto p-0 flex flex-col items-stretch justify-center overflow-hidden max-h-full","border-l-0 relative z-[1]","shadow-xs"],{variants:{size:{sm:"h-8",md:"h-10",lg:"h-12"},intent:{basic:null,filled:"hover:bg-gray-100",unstyled:null},hasRightAddon:{true:"border-r-0",false:null}}}),chevronIcon:(0,h.F)(["UI-Combobox__chevronIcon","h-4 w-4 shrink-0"])},nn=n.forwardRef((e,t)=>{let[s,a]=O(e,n.useId()),[{controlClass:l,controlsContainerClass:i,chevronIconClass:o,className:d,children:c,size:u,intent:m,leftAddon:p,leftIcon:h,rightAddon:x,rightIcon:g,placeholder:f,onValueChange:v,hideControls:y,value:j,min:w=0,max:N,step:k,allowMouseWheel:S=!0,formatOptions:C={maximumFractionDigits:2},clampValueOnBlur:_=!0,allowEmpty:R=!1,translations:A,locale:T,dir:I,defaultValue:M,...P},{inputContainerProps:D,leftAddonProps:L,leftIconProps:U,rightAddonProps:$,rightIconProps:V}]=G({...s,size:s.size??"md",intent:s.intent??"basic",leftAddon:s.leftAddon,leftIcon:s.leftIcon,rightAddon:s.rightAddon,rightIcon:s.rightIcon}),B=null==j||""===j,W=(0,na.zl)(ns.Aq,{id:a.id,name:a.name,disabled:a.disabled,readOnly:a.readonly,value:R&&B?"":null!=j?String(j):null!=M?String(M):void 0,min:w,max:N,step:k,allowMouseWheel:S,formatOptions:C,clampValueOnBlur:!R&&_,translations:A,locale:T,dir:I,onValueChange:e=>{null==v||v(e.valueAsNumber,e.value)}}),Y=ns.Ng(W,na._B),J=n.useRef(!0);return n.useEffect(()=>{J.current||(R&&B?Y.clearValue():"string"!=typeof j||isNaN(Number(j))?"number"==typeof j?Y.setValue(j):void 0===j&&Y.setValue(w):Y.setValue(Number(j))),J.current=!1},[j]),(0,r.jsx)(F,{...a,id:Y.getInputProps().id,children:(0,r.jsxs)(q,{...D,children:[(0,r.jsx)(H,{...L}),(0,r.jsx)(K,{...U}),(0,r.jsx)("input",{ref:t,type:"number",name:a.name,className:b("form-input",z.root({size:u,intent:m,hasError:!!a.error,
13isDisabled:!!a.disabled,hasRightAddon:!!x||!y,hasRightIcon:!!g,hasLeftAddon:!!p,hasLeftIcon:!!h}),nr.root({hideControls:y,intent:m,size:u}),d),disabled:a.disabled||a.readonly,"data-disabled":a.disabled,"data-readonly":a.readonly,"aria-readonly":a.readonly,required:a.required,...Y.getInputProps(),...P,placeholder:f}),!y&&(0,r.jsxs)("div",{className:b(z.root({size:u,intent:m,hasError:!!a.error,isDisabled:!!a.disabled,hasRightAddon:!!x,hasRightIcon:!!g,hasLeftAddon:!0}),nr.controlsContainer({size:u,intent:m,hasRightAddon:!!x}),i),children:[(0,r.jsx)(E,{intent:"gray-basic",size:"sm",className:b(nr.control(),l),...Y.getIncrementTriggerProps(),"data-readonly":a.readonly,"data-disabled":a.disabled||Y.getIncrementTriggerProps().disabled,disabled:a.disabled||a.readonly||Y.getIncrementTriggerProps().disabled,tabIndex:0,icon:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:b(nr.chevronIcon(),"rotate-180",o),children:(0,r.jsx)("path",{d:"m6 9 6 6 6-6"})})}),(0,r.jsx)(E,{intent:"gray-basic",size:"sm",className:b(nr.control(),l),...Y.getDecrementTriggerProps(),"data-readonly":a.readonly,"data-disabled":a.disabled||Y.getDecrementTriggerProps().disabled,disabled:a.disabled||a.readonly||Y.getDecrementTriggerProps().disabled,tabIndex:0,icon:(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:b(nr.chevronIcon(),o),children:(0,r.jsx)("path",{d:"m6 9 6 6 6-6"})})})]}),(0,r.jsx)(H,{...$}),(0,r.jsx)(K,{...V,className:b("z-3",V.className,x?null:"mr-6")})]})})});nn.displayName="NumberInput";var nl=s(7403);let ni={root:(0,h.F)(["UI-RadioGroup__root"]),item:(0,h.F)(["UI-RadioGroup__item","block aspect-square rounded-full border text-brand ring-offset-1 ring-offset-[--background]","focus:outline-none focus-visible:ring-2 focus-visible:ring-[--ring] focus-visible:ring-offset-2","disabled:cursor-not-allowed data-[disabled=true]:opacity-50 data-[readonly=true]:cursor-not-allowed","data-[state=unchecked]:bg-white dark:data-[state=unchecked]:bg-gray-700","data-[state=unchecked]:hover:bg-gray-100 dark:data-[state=unchecked]:hover:bg-gray-600","data-[state=checked]:bg-brand data-[state=checked]:border-transparent","data-[error=true]:border-red-500 data-[error=true]:dark:border-red-500 data-[error=true]:data-[state=checked]:border-red-500 data-[error=true]:dark:data-[state=checked]:border-red-500"],{variants:{size:{sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6"}},defaultVariants:{size:"md"}}),itemIndicator:(0,h.F)(["UI-RadioGroup__itemIndicator","flex items-center justify-center"]),itemLabel:(0,h.F)(["UI-Checkbox_itemLabel","font-normal block","data-[disabled=true]:opacity-50"],{variants:{size:{md:"text-md",lg:"text-lg"}},defaultVariants:{size:"md"}}),itemContainer:(0,h.F)(["UI-RadioGroup__itemContainer","flex gap-2 items-center relative"]),itemCheckIcon:(0,h.F)(["UI-RadioGroup__itemCheckIcon","text-white"],{variants:{size:{sm:"h-4 w-4",md:"h-4 w-4",lg:"h-5 w-5"}},defaultVariants:{size:"md"}})},no=n.forwardRef((e,t)=>{let s=n.useId(),[{size:a,className:l,stackClass:i,value:o,onValueChange:d,options:c,inputRef:u,defaultValue:m,itemClass:p,itemIndicatorClass:h,itemLabelClass:x,itemContainerClass:g,itemCheckIcon:f,itemCheckIconClass:v},y]=O(e,s),j=n.useRef(!0),w=n.useRef(null),[N,k]=n.useState(o??m),S=n.useCallback(e=>{k(e),null==d||d(e)},[]);return n.useEffect(()=>{m&&j.current||k(o),j.current=!1},[o]),(0,r.jsxs)(F,{...y,children:[(0,r.jsx)(nl.bL,{value:N,onValueChange:S,defaultValue:m,className:b(ni.root(),l),disabled:y.disabled||y.readonly,"data-error":!!y.error,"data-disabled":y.disabled,"data-readonly":y.readonly,"aria-readonly":y.readonly,loop:!0,children:(0,r.jsx)("div",{className:b("UI-RadioGroup__stack space-y-1",i),children:c.map(e=>(0,r.jsxs)("label",{className:b(ni.itemContainer(),g),htmlFor:s+e.value,"data-error":!!y.error,"data-disabled":y.disabled||e.disabled,"data-readonly":y.readonly||e.readonly,"data-state":N===e.value?"checked":"unchecked",children:[(0,r.jsx)(nl.q7,{ref:a7([w,t]),id:s+e.value,value:e.value,disabled:y.disabled||y.readonly||e.disabled||e.readonly,"data-error":!!y.error,"data-disabled":y.disabled||e.disabled,"data-readonly":y.readonly||e.readonly,className:b(ni.item({size:a}),p),children:(0,r.jsx)(nl.C1,{className:b(ni.itemIndicator(),h),"data-error":!!y.error,"data-disabled":y.disabled||e.disabled,"data-readonly":y.readonly||e.readonly,children:f||(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"16",height:"16",stroke:"currentColor",fill:"
13currentColor",className:b(ni.itemCheckIcon({size:a}),v),children:(0,r.jsx)("path",{d:"M8 4a4 4 0 1 1 0 8 4 4 0 0 1 0-8Z"})})})},e.value),(0,r.jsx)("label",{className:b(ni.itemLabel(),x),htmlFor:s+e.value,"aria-disabled":e.disabled,"data-error":!!y.error,"data-disabled":y.disabled||e.disabled||e.disabled,"data-readonly":y.readonly||e.readonly,"data-state":N===e.value?"checked":"unchecked",children:e.label??e.value})]},e.value))})}),(0,r.jsx)("input",{ref:u,type:"radio",name:y.name,className:V,value:N??"",checked:!!N,"aria-hidden":"true",required:y.required,tabIndex:-1,onChange:()=>{},onFocusCapture:()=>{var e;return null==(e=w.current)?void 0:e.focus()}})]})});no.displayName="RadioGroup";var nd=s(1628);let nc={root:(0,h.F)(["UI-SimpleDropzone__root","appearance-none w-full mb-2 cursor-pointer hover:text-[--foreground] flex items-center justify-center p-4 border rounded-[--radius] border-dashed","gap-3 text-sm sm:text-base","outline-none ring-[--ring] focus-visible:ring-2","text-[--muted] transition ease-in-out hover:border-[--foreground]","data-[drag-active=true]:border-brand-500","data-[drag-reject=true]:border-[--red]"]),list:(0,h.F)(["UI-SimpleDropzone__list","flex rounded-[--radius-md] flex-wrap divide-y divide-[--border]"]),listItem:(0,h.F)(["UI-SimpleDropzone__listItem","flex items-center justify-space-between relative p-1 hover:bg-[--subtle] w-full overflow-hidden"]),listItemDetailsContainer:(0,h.F)(["UI-SimpleDropzone__listItemDetailsContainer","flex items-center gap-2 truncate w-full"]),listItemTitle:(0,h.F)(["UI-SimpleDropzone__listItemTitle","truncate max-w-[180px] text-[.9rem]"]),listItemSize:(0,h.F)(["UI-SimpleDropzone__listItemSize","text-xs uppercase text-center font-semibold align-center text-[--muted]"]),listItemRemoveButton:(0,h.F)(["UI-SimpleDropzone__listItemRemoveButton","ml-2 rounded-full"]),imagePreviewGrid:(0,h.F)(["UI-SimpleDropzone__imagePreviewGrid","flex gap-2 flex-wrap place-content-center pt-4"]),imagePreviewContainer:(0,h.F)(["UI-SimpleDropzone__imagePreviewContainer","col-span-1 row-span-1 aspect-square w-36 h-auto"]),imagePreview:(0,h.F)(["UI-SimpleDropzone__imagePreview","relative bg-transparent border h-full bg-center bg-no-repeat bg-contain rounded-[--radius-md] overflow-hidden","col-span-1 row-span-1"]),imagePreviewRemoveButton:(0,h.F)(["UI-SimpleDropzone__imagePreviewRemoveButton","absolute top-1 right-1"]),fileIcon:(0,h.F)(["UI-SimpleDropzone__fileIcon","w-5 h-5 flex-none"]),maxSizeText:(0,h.F)(["UI-SimpleDropzone__maxSizeText","text-sm text-[--muted] font-medium"])},nu=n.forwardRef((e,t)=>{let[{children:s,className:a,listClass:l,listItemClass:i,listItemDetailsContainerClass:o,listItemRemoveButtonClass:d,listItemSizeClass:c,listItemTitleClass:u,imagePreviewGridClass:m,imagePreviewContainerClass:p,imagePreviewRemoveButtonClass:h,imagePreviewClass:x,maxSizeTextClass:g,fileIconClass:f,onValueChange:v,withImagePreview:y,dropzoneText:j,accept:w,minSize:N,maxSize:k,maxFiles:S,preventDropOnDocument:C,noClick:_,noDrag:R,onError:A,onDropRejected:I,validator:M,multiple:P,value:D,...L},U]=O(e,n.useId()),$=n.useRef(null),[z,q]=n.useState([]),B=n.useCallback(e=>{q(e.map(e=>Object.assign(e,{preview:URL.createObjectURL(e)})))},[]),K=n.useCallback(e=>{q(t=>t.toSpliced(e,1))},[]);n.useEffect(()=>{null==v||v(z)},[z]),n.useEffect(()=>()=>{z.forEach(e=>URL.revokeObjectURL(e.preview))},[z]);let{getRootProps:H,getInputProps:G,isDragActive:W,isDragReject:Y}=(0,nd.VB)({onDrop:B,multiple:P,minSize:N,maxSize:k,maxFiles:S,preventDropOnDocument:C,noClick:_,noDrag:R,validator:M,accept:w,onError:A,onDropRejected:I});return(0,r.jsxs)(F,{...U,children:[(0,r.jsxs)("button",{ref:$,className:b(nc.root(),a),"data-drag-active":W,"data-drag-reject":Y,...H(),tabIndex:0,children:[(0,r.jsx)("input",{ref:t,id:U.id,name:U.name??"files",value:"",onFocusCapture:()=>{var e;return null==(e=$.current)?void 0:e.focus()},"aria-hidden":"true",...G(),...L,className:b("block",V),style:{display:"block"}}),(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"w-5 h-5",children:[(0,r.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,r.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,r.jsx)("line",{x1:"12",x2:"12",y1:"15",y2:"3"})]}),(0,r.jsx)("span",{children:j??"Click or drag file to this area to upload"})]}
13),k&&(0,r.jsxs)("div",{className:b(nc.maxSizeText(),g),children:["≤"," ",rx(k)]}),!y&&(0,r.jsx)("div",{className:b(nc.list(),l),children:null==z?void 0:z.map((e,t)=>{let s;return s=["image/jpeg","image/png","image/jpg","image/webm"].includes(e.type)?(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:b(nc.fileIcon(),f),children:[(0,r.jsx)("path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"}),(0,r.jsx)("polyline",{points:"14 2 14 8 20 8"}),(0,r.jsx)("circle",{cx:"10",cy:"13",r:"2"}),(0,r.jsx)("path",{d:"m20 17-1.09-1.09a2 2 0 0 0-2.82 0L10 22"})]}):e.type.includes("video")?(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:b(nc.fileIcon(),f),children:[(0,r.jsx)("path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"}),(0,r.jsx)("polyline",{points:"14 2 14 8 20 8"}),(0,r.jsx)("path",{d:"m10 11 5 3-5 3v-6Z"})]}):e.type.includes("audio")?(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:b(nc.fileIcon(),f),children:[(0,r.jsx)("path",{d:"M17.5 22h.5c.5 0 1-.2 1.4-.6.4-.4.6-.9.6-1.4V7.5L14.5 2H6c-.5 0-1 .2-1.4.6C4.2 3 4 3.5 4 4v3"}),(0,r.jsx)("polyline",{points:"14 2 14 8 20 8"}),(0,r.jsx)("path",{d:"M10 20v-1a2 2 0 1 1 4 0v1a2 2 0 1 1-4 0Z"}),(0,r.jsx)("path",{d:"M6 20v-1a2 2 0 1 0-4 0v1a2 2 0 1 0 4 0Z"}),(0,r.jsx)("path",{d:"M2 19v-3a6 6 0 0 1 12 0v3"})]}):e.type.includes("pdf")||e.type.includes("document")||e.type.includes("txt")||e.type.includes("text")?(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:b(nc.fileIcon(),f),children:[(0,r.jsx)("path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"}),(0,r.jsx)("polyline",{points:"14 2 14 8 20 8"}),(0,r.jsx)("line",{x1:"16",x2:"8",y1:"13",y2:"13"}),(0,r.jsx)("line",{x1:"16",x2:"8",y1:"17",y2:"17"}),(0,r.jsx)("line",{x1:"10",x2:"8",y1:"9",y2:"9"})]}):e.type.includes("compressed")||e.type.includes("zip")||e.type.includes("archive")?(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:b(nc.fileIcon(),f),children:[(0,r.jsx)("path",{d:"M22 20V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2h6"}),(0,r.jsx)("circle",{cx:"16",cy:"19",r:"2"}),(0,r.jsx)("path",{d:"M16 11v-1"}),(0,r.jsx)("path",{d:"M16 17v-2"})]}):(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:b(nc.fileIcon(),f),children:[(0,r.jsx)("path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"}),(0,r.jsx)("polyline",{points:"14 2 14 8 20 8"})]}),(0,r.jsxs)("div",{className:b(nc.listItem(),i),children:[(0,r.jsxs)("div",{className:b(nc.listItemDetailsContainer(),o),children:[s,(0,r.jsx)("p",{className:b(nc.listItemTitle(),u),children:e.name}),(0,r.jsx)("p",{className:b(nc.listItemSize(),c),children:rx(e.size)})]}),(0,r.jsx)(E,{size:"xs",intent:"gray-basic",icon:(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"w-4 h-4",children:[(0,r.jsx)("path",{d:"M3 6h18"}),(0,r.jsx)("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),(0,r.jsx)("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"}),(0,r.jsx)("line",{x1:"10",x2:"10",y1:"11",y2:"17"}),(0,r.jsx)("line",{x1:"14",x2:"14",y1:"11",y2:"17"})]}),className:b(nc.listItemRemoveButton(),d),onClick:()=>K(t)})]},e.name)})}),y&&!!z.length&&(0,r.jsx)("div",{className:b(nc.imagePreviewGrid(),m),
13children:null==z?void 0:z.map((e,t)=>(0,r.jsxs)("div",{className:b(nc.imagePreviewContainer(),p),children:[(0,r.jsx)("div",{className:b(nc.imagePreview(),x),style:{backgroundImage:e?`url(${e.preview})`:void 0},children:(0,r.jsx)(T,{intent:"alert",size:"xs",className:b(nc.imagePreviewRemoveButton(),h),onClick:()=>K(t)})}),(0,r.jsxs)("div",{className:b(nc.listItemDetailsContainer(),o),children:[(0,r.jsx)("p",{className:b(nc.listItemTitle(),u),children:e.name}),(0,r.jsx)("p",{className:b(nc.listItemSize(),c),children:rx(e.size)})]})]},e.name))})]})});nu.displayName="SimpleDropzone";let nm={root:(0,h.F)(["UI-Textarea__root","w-full p-2"],{variants:{size:{sm:"h-20",md:"h-32",lg:"h-64"}},defaultVariants:{size:"md"}})},np=n.forwardRef((e,t)=>{let[s,a]=O(e,n.useId()),[{size:l,intent:i,leftAddon:o,leftIcon:d,rightAddon:c,rightIcon:u,className:m,onValueChange:p,onChange:h,...x},{inputContainerProps:g,leftAddonProps:f,leftIconProps:v,rightAddonProps:y,rightIconProps:j}]=G({...s,size:s.size??"md",intent:s.intent??"basic",leftAddon:s.leftAddon,leftIcon:s.leftIcon,rightAddon:s.rightAddon,rightIcon:s.rightIcon}),w=n.useCallback(e=>{null==p||p(e.target.value),null==h||h(e)},[]);return(0,r.jsx)(F,{...a,children:(0,r.jsxs)(q,{...g,children:[(0,r.jsx)(H,{...f}),(0,r.jsx)(K,{...v}),(0,r.jsx)("textarea",{id:a.id,name:a.name,className:b("form-textarea",z.root({size:l,intent:i,hasError:!!a.error,
13isDisabled:!!a.disabled,isReadonly:!!a.readonly,hasRightAddon:!!c,hasRightIcon:!!u,hasLeftAddon:!!o,hasLeftIcon:!!d}),nm.root({size:l}),m),disabled:a.disabled||a.readonly,"data-disabled":a.disabled,onChange:w,...x,ref:t}),(0,r.jsx)(H,{...y}),(0,r.jsx)(K,{...j})]})})});np.displayName="Textarea";let nh=n.forwardRef((e,t)=>{let{children:s,loading:a,disabled:n,role:l="save",disableOnSuccess:i="create"===l,disableIfInvalid:o=!1,showLoadingOverlayOnSuccess:d=!1,showLoadingOverlayOnCreate:c=!0,loadingOverlay:u,...m}=e,{formState:p}=(0,rG.xW)(),h=!!i&&p.isSubmitSuccessful,x=!!o&&!p.isValid;return(0,r.jsxs)(r.Fragment,{children:[d&&u&&(0,r.jsx)(R,{hide:!p.isSubmitSuccessful}),"create"===l&&u&&(0,r.jsx)(R,{hide:!p.isSubmitSuccessful}),(0,r.jsx)(w,{type:"submit",loading:p.isSubmitting||a,disabled:x||n||h,ref:t,...m,children:s})]})});function nx(e){return(0,n.forwardRef)((t,s)=>{let{control:a,formState:l,...i}=(0,rG.xW)(),{shape:o}=n.useContext(rY);return(0,n.useMemo)(()=>{var e,s;return!!(0,rG.Jt)(o,t.name)&&!(null==(e=(0,rG.Jt)(o,t.name))?void 0:e.isOptional())&&!(null==(s=(0,rG.Jt)(o,t.name))?void 0:s.isNullable())},[o]),(0,r.jsx)(rG.xI,{name:t.name,control:a,rules:{required:t.required},render:a=>{var i;let{field:{ref:o,...d}}=a;return(0,r.jsx)(e,{value:d.value,onChange:nI(t.onChange,d.onChange),onBlur:nI(t.onBlur,d.onBlur),...t,error:null==(i=nT(d.name,l))?void 0:i.message,ref:function(){for(var e=arguments.length,t=Array(e),s=0;s<e;s++)t[s]=arguments[s];return(0,n.useMemo)(()=>(function(){for(var e=arguments.length,t=Array(e),s=0;s<e;s++)t[s]=arguments[s];return e=>{t.forEach(t=>{!function(e,t){if(null!=e){if("function"==typeof e)return e(t);try{e.current=t}catch(s){throw Error(`Cannot assign value '${t}' to ref '${e}'`)}}}(t,e)})}})(...t),t)}(s,o)})}})})}let ng=n.memo(nx((0,n.forwardRef)((e,t)=>(0,r.jsx)(W,{...e,value:e.value??"",ref:t})))),nf=n.memo(nx((0,n.forwardRef)((e,t)=>(0,r.jsx)(Z,{...e,value:e.value??"",ref:t})))),nb=n.memo(nx((0,n.forwardRef)((e,t)=>(0,r.jsx)(np,{...e,value:e.value??"",ref:t})))),nv=n.memo(nx((0,n.forwardRef)((e,t)=>{let s=(0,rG.xW)(),a=(0,rG.as)({name:e.name});return n.useEffect(()=>{if(!(0,rG.Jt)(s.formState.defaultValues,e.name)&&!a.field.value&&!e.placeholder){var t,r;a.field.onChange(null==(r=e.options)||null==(t=r[0])?void 0:t.value)}},[]),(0,r.jsx)(nt,{...e,ref:t})}))),ny=n.memo(nx((0,n.forwardRef)((e,t)=>{let s=(0,rG.xW)(),a=(0,rG.as)({name:e.name}),l=n.useRef("#000"),[i,o]=n.useState((0,rG.Jt)(s.formState.defaultValues,e.name)||"#000"),d=rd(i,200),c=n.useRef(i);n.useEffect(()=>{a.field.onChange(d),(0,rZ.Mj)(d).isValid()&&(l.current=d)},[d]);let u=n.useCallback(()=>{(0,rZ.Mj)(i).isValid()?o(i):o(l.current),c.current=i},[l.current,i]);return(0,rX.A)(()=>{a.field.value!==c.current&&(o(a.field.value),c.current=a.field.value)},[a.field.value]),(0,r.jsx)(W,{...e,ref:t,value:i,onValueChange:o,onBlur:u,rightAddon:(0,r.jsx)(U,{className:"flex justify-center",trigger:(0,r.jsx)("div",{className:"cursor-pointer size-7 rounded-[--radius-md]",style:{backgroundColor:i}}),children:(0,r.jsx)(rQ.jI,{color:i,onChange:e=>{o(e)}})}),className:"w-full"})}))),nj=n.memo(nx((0,n.forwardRef)((e,t)=>{let{onChange:s,...a}=e;return(0,r.jsx)(rn,{...a,onValueChange:s,ref:t})}))),nw=n.memo(nx((0,n.forwardRef)((e,t)=>{let{onChange:s,...a}=e;return(0,r.jsx)(nn,{...a,onValueChange:s,ref:t})}))),nN=n.memo(nx((0,n.forwardRef)((e,t)=>{let{onChange:s,...a}=e;return(0,r.jsx)(ne,{...a,onValueChange:s,ref:t})}))),nk=n.memo(nx((0,n.forwardRef)((e,t)=>{let{onChange:s,...a}=e;return(0,r.jsx)(rs,{...a,onValueChange:s,ref:t})}))),nS=n.memo(nx((0,n.forwardRef)((e,t)=>{let{onChange:s,...a}=e;return(0,r.jsx)(r6,{...a,onValueChange:s,ref:t})}))),nC=n.memo(nx((0,n.forwardRef)((e,t)=>{let{onChange:s,...a}=e;return(0,r.jsx)(r4,{...a,onValueChange:s,ref:t})}))),n_=n.memo(nx((0,n.forwardRef)((e,t)=>{let{onChange:s,...a}=e;return(0,r.jsx)(no,{...a,onValueChange:s,ref:t})}))),nR=n.memo(nx((0,n.forwardRef)((e,t)=>{let{onChange:s,itemContainerClass:a,itemClass:n,radioGroupStackClass:l,...i}=e;return(0,r.jsx)(no,{itemContainerClass:b("items-start cursor-pointer transition border-transparent roun
13ded-[--radius] p-3 w-full md:w-fit","bg-transparent dark:hover:bg-gray-900 dark:bg-transparent","data-[state=checked]:bg-brand-500/5 dark:data-[state=checked]:bg-gray-900","focus:ring-2 ring-brand-100 dark:ring-brand-900 ring-offset-1 ring-offset-[--background] focus-within:ring-transparent transition","dark:border dark:data-[state=checked]:border-[--border] data-[state=checked]:ring-offset-0",a),itemClass:b("border-transparent absolute top-2 right-2 bg-transparent dark:bg-transparent dark:data-[state=unchecked]:bg-transparent","data-[state=unchecked]:bg-transparent data-[state=unchecked]:hover:bg-transparent dark:data-[state=unchecked]:hover:bg-transparent","focus-visible:ring-0 focus-visible:ring-offset-0 focus-visible:ring-offset-transparent",n),itemIndicatorClass:"hidden",itemLabelClass:"font-medium flex flex-col items-center data-[state=unchecked]:hover:text-[--foreground] data-[state=checked]:text-[--brand] text-[--muted] cursor-pointer",...i,onValueChange:s,stackClass:b("flex flex-col md:flex-row gap-2 space-y-0",l),ref:t})}))),nA={Text:ng,Password:nf,Textarea:nb,Select:nj,NativeSelect:nv,Switch:nk,Checkbox:nS,CheckboxGroup:nC,RadioGroup:n_,Number:nw,Combobox:nN,Autocomplete:n.memo(nx((0,n.forwardRef)((e,t)=>{let{onChange:s,...a}=e;return(0,r.jsx)(r1,{...a,onValueChange:s,ref:t})}))),SimpleDropzone:n.memo(nx((0,n.forwardRef)((e,t)=>{let{onChange:s,value:a,...l}=e,i=(0,rG.as)({name:l.name});return n.useEffect(()=>{i.field.onChange([])},[]),(0,r.jsx)(nu,{...l,onValueChange:s,ref:t})}))),ColorPicker:ny,RadioCards:nR,Submit:nh};nA.displayName="Field";let nT=(e,t)=>(0,rG.Jt)(t.errors,e);function nI(){for(var e=arguments.length,t=Array(e),s=0;s<e;s++)t[s]=arguments[s];return function(e){t.some(t=>(null==t||t(e),null==e?void 0:e.defaultPrevented))}}function nE(e){let{children:t}=e;return(0,r.jsx)("div",{className:"pb-4",children:t})}function nM(e){let{title:t,description:s,children:a,className:n}=e;return(0,r.jsxs)(X,{className:b("group/settings-card relative lg:bg-gray-950/5 dark:lg:bg-gray-950/40 rounded-xl transition-colors",n),children:[t&&(0,r.jsxs)("div",{className:"p-0 pb-2 flex flex-col lg:flex-row items-start lg:items-center gap-0 mx-3 mt-3 space-y-0",children:[(0,r.jsx)("span",{className:b("font-semibold text-[1rem] tracking-wide px-4 py-1 border w-fit rounded-xl flex-none","bg-gray-800/10 dark:bg-gray-800/40 transition-colors duration-300","group-hover/settings-card:bg-brand-500/10 group-hover/settings-card:text-white"),children:t}),s&&(0,r.jsx)("span",{className:"px-4 py-2 lg:py-0 w-fit text-sm text-[--muted]",children:s})]}),(0,r.jsx)("div",{className:b(!t&&"pt-4","p-4 space-y-4"),children:a})]})}function nP(e){let{title:t,description:s,icon:a,size:n="lg"}=e,l="lg"===n;return(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("div",{className:"p-2 rounded-lg bg-gradient-to-br from-brand-500/10 to-purple-500/10 border border-brand-500/15",children:(0,r.jsx)(a,{className:b("text-brand-600 dark:text-brand-400",l?"text-2xl":"text-xl")})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:b("font-semibold",l?"text-xl":"text-lg"),children:t}),(0,r.jsx)("p",{className:b("text-[--muted]",l?"text-base":"text-sm"),children:s})]})]})}rL.Yj().min(2).trim(),rL.Yj().min(1),rL.YO(rL.Yj()),rL.YO(rL.Yj()),rL.Ik({label:rL.Yj(),value:rL.Yj().nullable()}),rL.Ik({label:rL.Yj(),value:rL.Yj({error:"Invalid address"})}),rL.Ik({hour:rL.ai().min(0).max(23),minute:rL.ai().min(0).max(59)}),rL.Yj().min(10,"Invalid phone number"),rL.YO(rL.Ie()).refine(e=>e.every(e=>e instanceof File),{message:"Expected a file"}),rL.YO(rL.Ie()).min(0).refine(e=>e.every(e=>e instanceof File),{message:"Expected a file"}),rL.Ik({from:rL.p6(),to:rL.p6()}),rL.p6(),(0,h.F)(["UI-DangerZone__root","p-4 flex flex-col sm:flex-row gap-2 text-center sm:text-left rounded-[--radius-md] border border-dashed"]),(0,h.F)(["UI-DangerZone__icon","place-self-center sm:place-self-start text-[--red] w-4 mt-2"]),(0,h.F)(["UI-DangerZone__title","text-lg text-[--red] font-semibold"]),(0,h.F)(["UI-DangerZone__dialogTitle","text-lg font-medium leading-6"]),(0,h.F)(["UI-DangerZone__dialogBody","mt-2 text-base text-[--muted]"]),(0,h.F)(["UI-DangerZone__dialogAction","mt-2 flex gap-2 justify-end"]);var nD=s(3356);let nL={root:(0,h.F)(["UI-Alert__root","py-3 px-4 flex justify-between rounded-[--radius]"],{variants:{intent:{info:"bg-blue-50 text-blue-500 dark:bg-opacity-10 dark:text-blue-200",success:"bg-green-50 text-green-500 dark:bg-opacity-10 dark:text-green-200",warning:"bg-orange-50 text-orange-500 dark:bg-opacity-10 dark:text-orange-200",alert:"bg-red-50 text-red-500 dark:bg-opacity-10 dark:text-red-200","info-basic":"bg-white text-gray-800 border dark:bg-gray-800 dark:text-gray-200","success-basic":"bg-white text-gray-800 border dark:bg-gray-800 dark:text-gray-200","warning-basic":"bg-white text-gray-800 border dark:bg-gray-800 dark:text-gray-200","alert-basic":"bg-white text-gray-800 border dark:bg-gray-800 dark:text-gray-200"}},defaultVariants:{intent:"info"}}),detailsContainer:(0,h.F)(["UI-Alert__detailsContainer","flex"]),textContainer:(0,h.F)(["UI-Alert__textContainer","flex flex-col self-center ml-3 gap-.5"]),title:(0,h.F)(["UI-Alert__title","font-bold"]),description:(0,h.F)(["UI-Alert__description"]),icon:(0,h.F)(["UI-Alert__icon","text-2xl content-evenly"],{variants:{intent:{"info-basic":"text-blue-500","success-basic":"text-green-500","warning-basic":"text-orange-500","alert-basic":"text-red-500",info:"text-blue-500",success:"text-green-500",warning:"text-orange-500",alert:"text-red-500"}},defaultVariants:{intent:"info-basic"}}),closeButton:(0,h.F)(["UI-Alert__closeButton","flex-none self-start text-2xl hover:opacity-50 transition ease-in cursor-pointer h-5 w-5"])},nU=n.forwardRef((e,t)=>
13{let{children:s,className:a,title:n,description:l,isClosable:i,onClose:o,intent:d="info-basic",iconClass:c,detailsContainerClass:u,textContainerClass:m,titleClass:p,descriptionClass:h,closeButtonClass:x,icon:g,...f}=e,v=null;return"info-basic"===d||"info"===d?v=(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("path",{d:"M12 16v-4"}),(0,r.jsx)("path",{d:"M12 8h.01"})]}):"alert-basic"===d||"alert"===d?v=(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,r.jsx)("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),(0,r.jsx)("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]}):"warning-basic"===d||"warning"===d?v=(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"}),(0,r.jsx)("line",{x1:"12",x2:"12",y1:"9",y2:"13"}),(0,r.jsx)("line",{x1:"12",x2:"12.01",y1:"17",y2:"17"})]}):("success-basic"===d||"success"===d)&&(v=(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("path",{d:"M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10z"}),(0,r.jsx)("path",{d:"m9 12 2 2 4-4"})]})),(0,r.jsxs)("div",{className:b(nL.root({intent:d}),a),...f,ref:t,children:[(0,r.jsxs)("div",{className:b(nL.detailsContainer(),u),children:[g||(0,r.jsx)("div",{className:b(nL.icon({intent:d}),c),children:v&&v}),(0,r.jsxs)("div",{className:b(nL.textContainer(),m),children:[(0,r.jsx)("span",{className:b(nL.title(),p),children:n}),!!(l||s)&&(0,r.jsx)("div",{className:b(nL.description(),h),children:l||s})]})]}),o&&(0,r.jsx)("button",{className:b(nL.closeButton(),x),onClick:o,children:(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,r.jsx)("line",{x1:"18",x2:"6",y1:"6",y2:"18"}),(0,r.jsx)("line",{x1:"6",x2:"18",y1:"6",y2:"18"})]})})]})});function n$(e){let{isPending:t}=e,{isDirty:s}=(0,rG.lN)();return(0,r.jsx)(nA.Submit,{role:"save",size:"md",className:b("text-md group",s&&"animate-pulse"),intent:"primary",rounded:!0,loading:t,leftIcon:(0,r.jsx)(nD.Bc_,{}),children:"Save"})}function nO(e){let{isPending:t,className:s}=e,{isDirty:a,isSubmitting:n,isValidating:l}=(0,rG.lN)(),{reset:i}=(0,rG.xW)();return a?(0,r.jsx)(nU,{intent:"info",className:b("fixed z-[50] h-auto p-4 !mt-0 rounded-xl bg-[--background] border shadow-2xl","inset-x-4 bottom-4 w-auto animate-in slide-in-from-bottom-4 duration-300","lg:inset-x-auto lg:bottom-auto lg:right-4 lg:top-[2rem] lg:w-fit","lg:slide-in-from-top-2",s),children:(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{className:"flex-1 text-sm lg:flex-none",children:"You have unsaved changes."}),(0,r.jsx)(w,{size:"sm",intent:"gray-link",onClick:()=>i(),leftIcon:(0,r.jsx)(nD.cO3,{}),children:"Reset"}),(0,r.jsx)(nA.Submit,{role:"save",size:"sm",intent:"primary-link",disabled:n||l,loading:t,leftIcon:(0,r.jsx)(nD.Bc_,{}),children:"Save"})]})}):null}function nF(e,t){let s=/(\*\*[^*]+\*\*|\*[^*]+\*|`[^`]+`|\[[^\]]+\]\([^\)]+\))/g,a=e.split(s),n=e.match(s)||[],l=0;return a.map((e,s)=>{if(s===a.length-1&&""===e)return null;if(s%2==0)return e;{let e=n[l++];if(!e)return null;if(e.startsWith("**")&&e.endsWith("**"))return(0,r.jsx)("strong",{className:"font-semibold",children:e.slice(2,-2)},s);{if(e.startsWith("*")&&e.endsWith("*")&&!e.startsWith("**"))return(0,r.jsx)("em",{className:"italic",children:e.slice(1,-1)},s);if(e.startsWith("`")&&e.endsWith("`"))return(0,r.jsx)("code",{onClick:async s=>{t&&s.stopPropagation(),await rm(e.slice(1,-1),{onSuccess:()=>x.oR.success("Copied to clipboard"),onError:()=>x.oR.error("Failed to copy to clipboard")})},className:"bg-muted px-1 py-0.5 rounded text-[--brand] font-mono text-xs break-all cursor-pointer",children:e.slice(1,-1)},s);let a=e.match(/\[([^\]]+)\]\(([^\)]+)\)/);if(a){let[,e,n]=a;return(0,r.jsx)("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",onClick:e=>t&&e.stopPropagation(),children:e},s)}}return e}})}nU.displayName="Alert";let nz=e=>{let t,{children:s,className:a,stopPropagation:l=!1}=e;if(!s)return null;t=s.includes("\\n")?s.split("\\n"):s.split("\n");let i=[],o=0;for(;o<t.length;){let e=t[o],s=e.trim(),a=s.match(/^(#{1,3})\s+(.+)$/),d=s.startsWith("* ")&&!s.startsWith("**");if(a){let e=a[1].length,t=a[2],s=["text-base font-bold mt-3 mb-1","text-sm font-semibold mt-2.5 mb-1","text-sm font-medium mt
13-2 mb-0.5"],r=1===e?"h1":2===e?"h2":"h3";i.push(n.createElement(r,{key:`h-${o}`,className:s[e-1]},nF(t,l))),o++}else if(d){let e=[];for(;o<t.length&&t[o].trim().startsWith("* ")&&!t[o].trim().startsWith("**");)e.push(t[o]),o++;i.push((0,r.jsx)("ul",{className:"list-none space-y-1 mt-2 mb-1",children:e.map((e,t)=>(0,r.jsxs)("li",{className:"flex items-start gap-2",children:[(0,r.jsx)("span",{className:"text-gray-400",children:"•"}),(0,r.jsx)("span",{children:nF(e.slice(2),l)})]},t))},`bullets-${o}`))}else o>0&&i.push((0,r.jsx)("br",{},`br-${o}`)),i.push(nF(e,l)),o++}return(0,r.jsx)("span",{className:a,children:i})},nV="\0CLEAR\0",nq=e=>e?(0,r.jsx)(nz,{children:e}):void 0;function nB(e){let{value:t,disabled:s,onValueChange:a}=e,l="number"==typeof t?t:Number(t??0)||0,[i,o]=n.useState(()=>nX(l)),[d,c]=n.useState(!1);return n.useEffect(()=>{n0(i)!==l&&(o(nX(l)),c(!1))},[l]),(0,r.jsx)(W,{value:i,disabled:s,placeholder:'e.g. "500GB"',error:d?"Invalid size":void 0,onValueChange:e=>{o(e);let t=n0(e);c(null==t),null!=t&&a(t)}})}function nK(e){let{name:t,label:s,help:a,disabled:l,valueKind:i="string",width:o="equal",min:d=0}=e,{control:c}=(0,rG.xW)(),{field:u}=(0,rG.as)({name:t,control:c}),m=n.useCallback(()=>{let e=u.value;return e&&"object"==typeof e&&!Array.isArray(e)?Object.entries(e):[]},[u.value]),[p,h]=n.useState(m);n.useEffect(()=>{let e=m(),t={};for(let[e,s]of p)e&&(t[e]=s);let s=Object.fromEntries(e);JSON.stringify(t)!==JSON.stringify(s)&&h(e)},[u.value]);let x=e=>{h(e);let t={};for(let[s,a]of e)s&&(t[s]=a);u.onChange(t)},g=(e,t,s)=>{x(p.map((a,r)=>r===e?[t,s]:a))},f="wide-key"===o?"basis-2/3 grow shrink-0":"wide-value"===o?"basis-1/3 grow shrink-0":"basis-1/2 grow shrink-0",b="wide-value"===o?"basis-2/3 grow shrink-0":"wide-key"===o?"basis-1/3 grow shrink-0":"basis-1/2 grow shrink-0";return(0,r.jsx)(F,{label:s,help:nq(a),children:(0,r.jsxs)("div",{className:"space-y-2",children:[0===p.length&&(0,r.jsx)("p",{className:"text-xs text-[--muted] italic",children:"No entries."}),p.map((e,t)=>{let[s,a]=e;return(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(W,{placeholder:"key",value:s,disabled:l,onValueChange:e=>g(t,e,a),className:f}),(0,r.jsx)("span",{className:"text-[--muted]",children:"="}),(0,r.jsx)("div",{className:b,children:"boolean"===i?(0,r.jsx)(rs,{value:!!a,disabled:l,onValueChange:e=>g(t,s,e)}):"size"===i?(0,r.jsx)(nB,{value:a,disabled:l,onValueChange:e=>g(t,s,e)}):"number"===i?(0,r.jsx)(nn,{value:"number"==typeof a?a:Number(a)||0,disabled:l,onValueChange:e=>g(t,s,e),min:d}):(0,r.jsx)(W,{placeholder:"value",value:null==a?"":String(a),disabled:l,onValueChange:e=>{let a=e;"numberOrBool"===i&&("true"===e?a=!0:"false"===e?a=!1:/^\d+$/.test(e)&&(a=Number(e))),g(t,s,a)}})}),(0,r.jsx)(E,{size:"sm",intent:"alert-subtle",icon:(0,r.jsx)(tC.id1,{}),disabled:l,onClick:()=>x(p.filter((e,s)=>s!==t)),"aria-label":"Remove entry"})]},t)}),(0,r.jsx)(E,{size:"sm",intent:"primary-subtle",rounded:!0,icon:(0,r.jsx)(tC.Ca6,{}),disabled:l,onClick:()=>x([...p,["","boolean"!==i&&("number"===i||"size"===i?0:"")]]),"aria-label":"Add entry"})]})})}function nH(e){let{name:t,label:s,help:a,disabled:l}=e,{control:i}=(0,rG.xW)(),{field:o}=(0,rG.as)({name:t,control:i}),d=n.useCallback(()=>Array.isArray(o.value)?[...o.value]:[],[o.value]),[c,u]=n.useState(d);n.useEffect(()=>{let e=d();JSON.stringify(c)!==JSON.stringify(e)&&u(e)},[o.value]);let m=e=>{u(e),o.onChange(e)};return(0,r.jsx)(F,{label:s,help:nq(a),children:(0,r.jsxs)("div",{className:"space-y-2",children:[0===c.length&&(0,r.jsx)("p",{className:"text-xs text-[--muted] italic",children:"No entries."}),c.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(W,{value:e,disabled:l,onValueChange:e=>m(c.map((s,a)=>a===t?e:s)),className:"flex-1"}),(0,r.jsx)(E,{size:"sm",intent:"alert-subtle",icon:(0,r.jsx)(tC.id1,{}),disabled:l,onClick:()=>m(c.filter((e,s)=>s!==t)),"aria-label":"Remove"})]},t)),(0,r.jsx)(E,{size:"sm",intent:"primary-subtle",rounded:!0,icon:(0,r.jsx)(tC.Ca6,{}),disabled:l,onClick:()=>m([...c,""]),"aria-label":"Add"})]})})}function nG(e){let{name:t,label:s,help:a,disabled:l}=e,{control:i}=(0,rG.xW)(),{field:o}=(0,rG.as)({name:t,control:i}),d=o.value,c=Array.isArray(d),u="boolean"==typeof d,[m,p]=n.useState(c);return n.useEffect(()=>{c&&p(!0)},[c]),(0,r.jsx)(F,{label:s,help:nq(a),children:(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(rs,{value:!!c||!!d,disabled:l,onValueChange:e=>{m?o.onChange(!!e&&(c?d:[])):o.onChange(e)}}),(0,r.jsx)("button",{type:"button",disabled:l,className:"text-xs text-[--muted] underline-offset-2 hover:underline",onClick:()=>{let e=!m;p(e),e&&!c&&o.onChange([]),!e&&c&&o.onChange(d.length>0)},children:m?"Use simple toggle":"Use allow-list"})]}),m&&(0,r.jsx)(nH,{name:t,label:"",help:void 0,disabled:l||!Array.isArray(o.value)}),!m&&u&&(0,r.jsx)("p",{className:"text-xs text-[--muted]",children:d?"Enabled for everything.":"Disabled."})]})})}function nW(e){return!Number.isFinite(e)||e<0?"":0===e?"0s":rN(1e3*Math.round(e))}function nY(e){let t=e.trim();if(""===t)return null;if(/^-?\d+$/.test(t))return Number(t);if(!/[a-z]/i.test(t))return null;let s=rw(t);return null==s?null:Math.round(s/1e3)}function nJ(e){let{name:t,label:s,help:a,disabled:l}=e,{control:i}=(0,rG.xW)(),{field:o}=(0,rG.as)({name:t,control:i}),d="number"==typeof o.value?o.value:Number(o.value??0)||0,[c,u]=n.useState(()=>nW(d)),[m,p]=n.useState(null);return n.useEffect(()=>{nY(c)!==d&&(u(nW(d)),p(null))},[d]),(0,r.jsx)(F,{label:s,help:nq(a),error:m??void 0,children:(0,r.jsx)(W,{value:c,disabled:l,placeholder:'e.g. "30m", "1h", "1d"',onValueChange:e=>{u(e);let t=nY(e);null==t?p("Invalid duration. Use e.g. 30s, 5m, 1h, 1d, 2w."):(p(null),o.onChange(t))}})})}function nZ(e){let{name:t,label:s,help:a,disabled:n,secretSet:l}=e,{control:i}=(0,rG.xW)(),{field:o}=(0,rG.as)({name:t,control:i}),d=o.value===nV,c=d?`${a?a+" \xb7 ":""}Will be cleared on save.`:a;return(0,r.jsxs)(F,{label:s,help:nq(c),children:[l&&(0,r.jsx)("div",{className:"flex justify-end mb-1",children:(0,r.jsx)(w,{size:"sm",intent:d?"gray-subtle":"alert-subtle",leftIcon:(0,r.jsx)(tC.id1,{}),onClick:()=>o.onChange(d?"":nV),disabled:n,children:d?"Cancel clear":"Clear value"})}),(0,r.jsx)(np,{value:d||null==o.value?"":String(o.value),disabled:n||d,placeholder:d?"(will be cleared on save)":l?"(value set — type to replace)":void 0,rows:6,className:"font-mono text-xs",onValueChange:e=>o.onChange(e)}
13)]})}let nQ=[["TB",1e12],["GB",1e9],["MB",1e6],["KB",1e3],["B",1]];function nX(e){if(!Number.isFinite(e)||e<0)return"";if(0===e)return"0B";for(let[t,s]of nQ)if(e>=s){let a=e/s;return`${Number.isInteger(a)?a:a.toFixed(1)}${t}`}return`${e}B`}function n0(e){let t=e.trim();if(""===t)return null;if(/^\d+$/.test(t))return Number(t);let s=t.match(/^(\d+(?:\.\d+)?)\s*([kmgt]?b)?$/i);return s?Math.floor(Number(s[1])*({b:1,kb:1e3,mb:1e6,gb:1e9,tb:1e12})[(s[2]||"b").toLowerCase()]):null}function n1(e){let{name:t,label:s,help:a,disabled:l}=e,{control:i}=(0,rG.xW)(),{field:o}=(0,rG.as)({name:t,control:i}),d="number"==typeof o.value?o.value:Number(o.value??0)||0,[c,u]=n.useState(()=>nX(d)),[m,p]=n.useState(null);return n.useEffect(()=>{n0(c)!==d&&(u(nX(d)),p(null))},[d]),(0,r.jsx)(F,{label:s,help:nq(a),error:m??void 0,children:(0,r.jsx)(W,{value:c,disabled:l,placeholder:'e.g. "20MB", "1GB", "500KB"',onValueChange:e=>{u(e);let t=n0(e);null==t?p("Invalid size. Use e.g. 500KB, 20MB, 1GB."):(p(null),o.onChange(t))}})})}function n2(e){let{name:t,label:s,help:a,disabled:l}=e,{control:i}=(0,rG.xW)(),{field:o}=(0,rG.as)({name:t,control:i}),[d,c]=n.useState(()=>JSON.stringify(o.value??null,null,2)),[u,m]=n.useState(null);return n.useEffect(()=>{c(JSON.stringify(o.value??null,null,2)),m(null)},[o.value]),(0,r.jsx)(F,{label:s,help:nq(a),error:u??void 0,children:(0,r.jsx)(np,{value:d,disabled:l,rows:4,className:"font-mono text-xs",onValueChange:e=>{c(e);try{o.onChange(JSON.parse(e)),m(null)}catch{m("Invalid JSON")}}})})}let n3=e=>e.replace(/\./g,"--");function n6(e){let{name:t,label:s,help:a,secretSet:n,disabled:l}=e,{setValue:i,watch:o}=(0,rG.xW)(),d=o(t),c=d===nV;return(0,r.jsx)(F,{label:s,help:nq(c?`${a?a+" \xb7 ":""}Will be cleared on save.`:a),children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(Z,{autoComplete:"new-password",value:c?"":d??"",placeholder:c?"(will be cleared)":n?"•••••••• (unchanged)":"",disabled:l||c,onValueChange:e=>i(t,e,{shouldDirty:!0})})}),n&&!l&&(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"sm",intent:c?"alert-subtle":"gray-subtle",icon:(0,r.jsx)(tC.id1,{}),"aria-label":c?"Cancel clear":"Clear secret value",onClick:()=>i(t,c?"":nV,{shouldDirty:!0})}),children:c?"Cancel — keep current value":"Clear saved value"})]})})}function n5(e){let{env:t}=e;return(0,r.jsxs)(to,{trigger:(0,r.jsx)(tC.E2M,{className:"inline text-[--muted]"}),children:["Set by environment variable: ",(0,r.jsx)("code",{children:t})]})}function n4(e){let{k:t}=e,s=(0,r.jsx)(n9,{k:t});return void 0===t.deprecated?s:(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(nU,{intent:"warning-basic",title:"Deprecated",description:nq(t.deprecated)}),s]})}function n9(e){let{k:t}=e,s=n3(t.key),a="environment"===t.source,n=(0,r.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[t.label,a&&t.env&&(0,r.jsx)(n5,{env:t.env})]}),l=t.description||void 0;if(t.secret){let e=t.secretSet?`${l?l+" \xb7 ":""}A value is set. Type to replace it, or clear it.`:l;return t.ui.multiline?(0,r.jsx)(nZ,{name:s,label:t.label,help:e,disabled:a,secretSet:t.secretSet}):(0,r.jsx)(n6,{name:s,label:n,help:e,secretSet:t.secretSet,disabled:a})}switch(t.ui.kind){case"boolean":return(0,r.jsx)(nA.Switch,{name:s,label:n,help:nq(l),side:"right",disabled:a});case"number":return(0,r.jsx)(nA.Number,{name:s,label:n,help:nq(l),disabled:a,min:t.ui.min,max:t.ui.max,step:t.ui.step});case"enum":return(0,r.jsx)(nA.Select,{name:s,label:n,help:nq(l),disabled:a,options:(t.ui.options??[]).map(e=>({label:e,value:e}))});case"list":return(0,r.jsx)(nH,{name:s,label:t.label,help:l,disabled:a});case"map":return(0,r.jsx)(nK,{name:s,label:t.label,help:l,disabled:a,valueKind:t.ui.mapValueKind??"string",width:t.ui.mapWidth??"equal",min:t.ui.min});case"duration":return(0,r.jsx)(nJ,{name:s,label:t.label,help:l,disabled:a});case"size":return(0,r.jsx)(n1,{name:s,label:t.label,help:l,disabled:a});case"boolOrList":return(0,r.jsx)(nG,{name:s,label:t.label,help:l,disabled:a});case"json":return(0,r.jsx)(n2,{name:s,label:t.label,help:l,disabled:a});default:if(t.ui.multiline)return(0,r.jsx)(nZ,{name:s,label:t.label,help:l,disabled:a});return(0,r.jsx)(nA.Text,{name:s,label:n,help:nq(l),disabled:a})}}var n8=s(1400);let n7={subTrigger:(0,h.F)(["UI-DropdownMenu__subTrigger","focus:bg-[--subtle] data-[state=open]:bg-[--subtle]"]),subContent:(0,h.F)(["UI-DropdownMenu__subContent","z-50 min-w-[12rem] overflow-hidden rounded-[--radius] border bg-[--background] p-2 text-[--foreground] shadow-sm","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-100 data-[state=open]:zoom-in-95","data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2","data-[side=right]:sli
13de-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"]),root:(0,h.F)(["UI-DropdownMenu__root","z-50 min-w-[15rem] overflow-hidden rounded-[--radius] border bg-[--background] p-2 text-[--foreground] shadow-sm","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-100 data-[state=open]:zoom-in-95","data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2","data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"]),item:(0,h.F)(["UI-DropdownMenu__item","relative flex cursor-default select-none items-center rounded-[--radius] cursor-pointer px-2 py-2 text-sm outline-none transition-colors","focus:bg-[--subtle] data-[disabled]:pointer-events-none","data-[disabled]:opacity-50","[&>svg]:mr-2 [&>svg]:text-lg"]),group:(0,h.F)(["UI-DropdownMenu__group"]),label:(0,h.F)(["UI-DropdownMenu__label","px-2 py-1.5 text-sm font-semibold text-[--muted]"]),separator:(0,h.F)(["UI-DropdownMenu__separator","-mx-1 my-2 h-px bg-[--border]"]),shortcut:(0,h.F)(["UI-DropdownMenu__shortcut","ml-auto text-xs tracking-widest opacity-60"])},le=n.createContext({}),lt=n.forwardRef((e,t)=>{let{children:s,trigger:a,defaultOpen:n,open:l,onOpenChange:i,dir:o,allowOutsideInteraction:d,sideOffset:c=4,className:u,subContentClass:m,subTriggerClass:p,shortcutClass:h,itemClass:x,labelClass:g,separatorClass:f,groupClass:v,...y}=e;return(0,r.jsx)(le.Provider,{value:{subContentClass:m,subTriggerClass:p,shortcutClass:h,itemClass:x,labelClass:g,separatorClass:f,groupClass:v},children:(0,r.jsxs)(n8.bL,{defaultOpen:n,open:l,onOpenChange:i,dir:o,modal:!d,...y,children:[(0,r.jsx)(n8.l9,{asChild:!0,children:a}),(0,r.jsx)(n8.ZL,{children:(0,r.jsx)(n8.UC,{ref:t,sideOffset:c,className:b(n7.root(),u),...y,children:s})})]})})});lt.displayName="DropdownMenu",n.forwardRef((e,t)=>{let{className:s,...a}=e,{groupClass:l}=n.useContext(le);return(0,r.jsx)(n8.YJ,{ref:t,className:b(n7.group(),l,s),...a})}).displayName="DropdownMenuGroup",n.forwardRef((e,t)=>{let{children:s,triggerContent:a,triggerProps:l,triggerInset:i,defaultOpen:o,open:d,onOpenChange:c,sideOffset:u=8,className:m,subTriggerClass:p,...h}=e,{subTriggerClass:x,subContentClass:g}=n.useContext(le);return(0,r.jsxs)(n8.Pb,{...h,children:[(0,r.jsxs)(n8.ZP,{className:b(n7.item(),n7.subTrigger(),i&&"pl-8",x,p,m),...l,children:[a,(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:b(n7.shortcut(),"w-4 h-4 ml-auto"),children:(0,r.jsx)("path",{d:"m9 18 6-6-6-6"})})]}),(0,r.jsx)(n8.ZL,{children:(0,r.jsx)(n8.G5,{ref:t,sideOffset:u,className:b(n7.subContent(),g,m),...h,children:s})})]})}).displayName="DropdownMenuSub";let ls=n.forwardRef((e,t)=>{let{className:s,inset:a,...l}=e,{itemClass:i}=n.useContext(le);return(0,r.jsx)(n8.q7,{ref:t,className:b(n7.item(),a&&"pl-8",i,s),...l})});ls.displayName="DropdownMenuItem";let la=n.forwardRef((e,t)=>{let{className:s,inset:a,...l}=e,{labelClass:i}=n.useContext(le);return(0,r.jsx)(n8.JU,{ref:t,className:b(n7.label(),a&&"pl-8",i,s),...l})});la.displayName="DropdownMenuLabel";let lr=n.forwardRef((e,t)=>{let{className:s,...a}=e,{separatorClass:l}=n.useContext(le);return(0,r.jsx)(n8.wv,{ref:t,className:b(n7.separator(),l,s),...a})});function ln(e,t){if(t)return"••••••";if(null===e)return"null";if(void 0===e)return"—";if("string"==typeof e)return""===e?'""':e;if("number"==typeof e||"boolean"==typeof e)return String(e);try{let t=JSON.stringify(e);return t.length>60?t.slice(0,57)+"…":t}catch{return String(e)}}function ll(e){let{open:t,onOpenChange:s,scope:a,scopeLabel:l,keys:i,invalidate:d}=e,{mutateAsync:c,isPending:u}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[aO],t=(0,o.jE)();return(0,eE.n)({mutationFn:e=>ei("POST /dashboard/settings/reset",{body:{keys:e}}),onSuccess:()=>e.forEach(e=>t.invalidateQueries({queryKey:e}))})}(d),m=n.useMemo(()=>i.filter(e=>"database"===e.source),[i]),p=n.useMemo(()=>i.filter(e=>"environment"===e.source).length,[i]),[h,g]=n.useState(new Set);n.useEffect(()=>{t&&g(new Set(m.map(e=>e.key)))},[t,m]);let f=n.useMemo(()=>(function(e){let t=new Map;for(let s of e){let e=s.key.split("."),a=e[0],r=e.slice(1,-1).join(".");t.has(a)||t.set(a,new Map);let n=t.get(a);n.has(r)||n.set(r,[]),n.get(r).push(s)}let s=[];for(let[e,a]of t)for(let[t,r]of a){let a=(t?`${e}.${t}`:e).split(".").map(aU).join(" › ");s.push({subsection:a,keys:r})}return s})(m),[m]),b=h.size===m.length&&m.length>0,v=h.size>0&&!b,y=e=>{g(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})},j=async()=>
13{if(0!==h.size)try{let e=await c([...h]);x.oR.success(`Reset ${e.reset.length} setting${1===e.reset.length?"":"s"}.`);let t=e.skipped.filter(e=>"already-default"===e.reason);t.length&&x.oR.info(`${t.length} were already at default and skipped.`);let a=e.skipped.filter(e=>"already-default"!==e.reason);a.length&&x.oR.warning(`${a.length} could not be reset (env-locked or unknown).`),e.requiresRestart&&x.oR.warning("Some changes require a restart to take effect.",{duration:8e3}),s(!1)}catch(e){x.oR.error((null==e?void 0:e.message)??"Failed to reset settings")}};return(0,r.jsx)(ty,{open:t,onOpenChange:s,title:"all"===a?"Reset all settings":`Reset settings in ${l}`,description:0===m.length?"Nothing to reset - every key in this scope is already at its default or pinned by an env variable.":"Selected keys will revert to their environment value (if set) or built-in default. This cannot be undone.",contentClass:"max-w-2xl",footer:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(w,{intent:"gray-outline",onClick:()=>s(!1),disabled:u,children:"Cancel"}),(0,r.jsx)(w,{intent:"alert-subtle",onClick:j,loading:u,disabled:u||0===h.size,children:0===h.size?"Nothing selected":`Reset ${h.size} ${1===h.size?"key":"keys"}`})]}),children:m.length>0&&(0,r.jsxs)("div",{className:"space-y-3",children:[p>0&&(0,r.jsx)(nU,{intent:"info",description:(0,r.jsxs)(r.Fragment,{children:[p," key",1===p?"":"s"," in this scope ",1===p?"is":"are"," pinned by environment variables and won't change."]}),isClosable:!1}),(0,r.jsx)("div",{className:"flex items-center justify-between border-b border-[--border] pb-2",children:(0,r.jsx)(r6,{label:b?`All ${m.length} selected`:v?`${h.size} of ${m.length} selected`:"Select all",value:!!b||!!v&&"indeterminate",onValueChange:()=>{g(e=>e.size===m.length?new Set:new Set(m.map(e=>e.key)))}})}),(0,r.jsx)("div",{className:"max-h-[50vh] overflow-y-auto space-y-4 pr-1",children:f.map(e=>(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-[--muted] uppercase tracking-wide mb-1.5",children:e.subsection}),(0,r.jsx)("ul",{className:"space-y-1",children:e.keys.map(e=>{let t=h.has(e.key);return(0,r.jsxs)("li",{className:"flex items-start gap-3 py-1.5 px-2 rounded-md hover:bg-[--subtle] transition-colors",children:[(0,r.jsx)("div",{className:"pt-0.5",children:(0,r.jsx)(r6,{value:t,onValueChange:()=>y(e.key)})}),(0,r.jsxs)("button",{type:"button",className:"flex-1 text-left min-w-0",onClick:()=>y(e.key),children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-0.5 min-w-0",children:[(0,r.jsx)("span",{className:"font-medium break-words",children:e.label}),(0,r.jsx)("code",{className:"text-xs text-[--muted] break-all min-w-0",children:e.key})]}),(0,r.jsxs)("div",{className:"text-xs text-[--muted] break-all mt-0.5 min-w-0",children:[(0,r.jsx)("span",{className:"font-mono",children:ln(e.value,e.secret)}),(0,r.jsx)("span",{className:"mx-1.5",children:"→"}),(0,r.jsx)("span",{className:"font-mono",children:ln(e.default,e.secret)})]})]}),e.requiresRestart&&(0,r.jsx)(to,{trigger:(0,r.jsx)("span",{className:"text-[10px] uppercase tracking-wide text-orange-500 font-semibold mt-0.5",children:"restart"}),children:"Requires a restart to take effect"})]},e.key)})})]},e.subsection))})]})})}function li(e){let t,{open:s,onOpenChange:a,envKeys:l}=e,{mutateAsync:i,isPending:d}=(t=(0,o.jE)(),(0,eE.n)({mutationFn:()=>ei("POST /dashboard/settings/import/env"),onSuccess:()=>t.invalidateQueries({queryKey:aO})})),c=n.useMemo(()=>{let e=new Map;for(let t of l){let s=t.key.split(".")[0];e.has(s)||e.set(s,[]),e.get(s).push(t)}return[...e.entries()].sort((e,t)=>{let[s]=e,[a]=t;return s.localeCompare(a)})},[l]),u=async()=>{try{let e=await i();x.oR.success(`Imported ${e.imported.length} setting${1===e.imported.length?"":"s"} into the database.`),e.skippedAsDefault.length&&x.oR.info(`Skipped ${e.skippedAsDefault.length} that already match the default.`),e.failed.length&&x.oR.warning(`${e.failed.length} could not be imported. Check logs.`),e.imported.length&&x.oR.warning("Remove the corresponding env vars and restart for these to take effect.",{duration:1e4}),a(!1)}catch(e){x.oR.error((null==e?void 0:e.message)??"Failed to import env settings")}};return(0,r.jsx)(ty,{open:s,onOpenChange:a,title:"Import environment variables into the database",description:0===l.length?"No environment-pinned settings found.":"Copies the current value of every env-set setting into the database. Values that already match the schema default are skipped automatically.",contentClass:"max-w-2xl",footer:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(w,{intent:"gray-basic",onClick:()=>a(!1),disabled:d,children:"Cancel"}),(0,r.jsxs)(w,{intent:"primary-subtle",onClick:u,loading:d,disabled:d||0===l.length,children:["Import ",l.length," ",1===l.length?"key":"keys"]})]}),children:l.length>0&&(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(nU,{intent:"info",description:(0,r.jsxs)(r.Fragment,{children:["Environment variables always override database values. After importing, you must remove the matching env vars from your deployment ",(0,r.jsx)("em",{children:"and restart"})," for the persisted values to take effect - otherwise the env still overrides."]}),isClosable:!1}),(0,r.jsx)("div",{className:"max-h-[50vh] overflow-y-auto space-y-4 pr-1",children:c.map(e=>{let[t,s]=e;return(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-[--muted] uppercase tracking-wide mb-1.5",children:aU(t)}),(0,r.jsx)("ul",{className:"space-y-1",children:s.map(e=>(0,r.jsx)("li",{className:"flex items-start justify-between gap-3 py-1.5 px-2 rounded-md hover:bg-[--subtle] transition-colors",children:(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-0.5 min-w-0",children:[(0,r.jsx)("span",{className:"font-medium break-words",children:e.label}),e.env&&(0,r.jsx)("code",{className:"text-xs text-[--muted] break-all min-w-0",children:e.env})]}),(0,r.jsx)("div",{className:"text-xs text-[--muted] break-all mt-0.5 font-mono min-w-0",children:function(e,t){if(t)return"••••••";if(null===e)return"null";if(void 0===e)return"—";if("string"==typeof e)return""===e?'""':e;if("number"==typeof e||"boolean"==typeof e)return String(e);try{let t=JSON.stringify(e);return t.length>60?t.slice(0,57)+"…":t}catch{return String(e)}}(e.value,e.secret)})]})},e.key))})]},t)})})]})})}lr.displayName="DropdownMenuSeparator",n.forwardRef((e,t)=>
13{let{className:s,...a}=e,{shortcutClass:l}=n.useContext(le);return(0,r.jsx)("span",{ref:t,className:b(n7.shortcut(),l,s),...a})}).displayName="DropdownMenuShortcut";let lo={initial:{opacity:0,x:12},animate:{opacity:1,x:0},exit:{opacity:0,x:-12},transition:{duration:.18,ease:"easeOut"}};function ld(e){let{open:t,onOpenChange:s,restrict:a,invalidate:l}=e,{mutateAsync:i,isPending:d}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[aO],t=(0,o.jE)();return(0,eE.n)({mutationFn:e=>ei("POST /dashboard/settings/import/json",{body:{settings:e}}),onSuccess:()=>e.forEach(e=>t.invalidateQueries({queryKey:e}))})}(l),[c,u]=n.useState("pick"),[m,p]=n.useState(null),[h,g]=n.useState(null);n.useEffect(()=>{t||(u("pick"),p(null),g(null))},[t]);let f=async e=>{let t=e[0];if(t){g(null);try{let e=await t.text(),s=function(e,t,s){let a=JSON.parse(e);if(!a.settings||"object"!=typeof a.settings||Array.isArray(a.settings))throw Error("File is missing a `settings` object.");let r=new Set(Array.isArray(a.maskedSecretKeys)?a.maskedSecretKeys.filter(e=>"string"==typeof e):[]),n=a.settings,l={},i=[],o=[];for(let[e,t]of Object.entries(n)){if(s&&!s(e)){o.push(e);continue}if(r.has(e)&&null===t){i.push(e);continue}l[e]=t}return{settings:l,maskedSecrets:i,outOfScope:o,totalEntries:Object.keys(n).length,exportedAt:"string"==typeof a.exportedAt?a.exportedAt:void 0,version:"number"==typeof a.version?a.version:void 0,fileName:t}}(e,t.name,a);p(s),u("review")}catch(e){g((null==e?void 0:e.message)??"Failed to parse JSON file.")}}},b=n.useMemo(()=>{if(!m)return[];let e=new Map;for(let[t,s]of Object.entries(m.settings)){let a=t.split(".")[0];e.has(a)||e.set(a,[]),e.get(a).push([t,s])}return[...e.entries()].sort((e,t)=>{let[s]=e,[a]=t;return s.localeCompare(a)})},[m]),v=async()=>{if(m)try{let e=await i(m.settings);x.oR.success(`Imported ${e.imported.length} setting${1===e.imported.length?"":"s"}.`),e.skipped.length&&x.oR.info(`Skipped ${e.skipped.length} (unknown or env-locked keys).`),e.failed.length&&x.oR.warning(`${e.failed.length} failed validation. Check logs for details.`),e.requiresRestart&&x.oR.warning("Some changes require a restart to take effect.",{duration:8e3}),s(!1)}catch(e){x.oR.error((null==e?void 0:e.message)??"Failed to import settings")}},y=m?Object.keys(m.settings).length:0;return(0,r.jsx)(ty,{open:t,onOpenChange:s,title:"Import settings from JSON",description:"pick"===c?"Choose a settings export file to preview and import.":`Reviewing ${(null==m?void 0:m.fileName)??""}`,contentClass:"max-w-2xl",footer:"pick"===c?(0,r.jsx)(w,{intent:"gray-basic",onClick:()=>s(!1),disabled:d,children:"Cancel"}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(w,{intent:"gray-basic",leftIcon:(0,r.jsx)(tC.OLK,{}),onClick:()=>{p(null),u("pick")},disabled:d,children:"Back"}),(0,r.jsxs)(w,{intent:"primary-subtle",onClick:v,loading:d,disabled:d||0===y,children:["Import ",y," ",1===y?"key":"keys"]})]}),children:(0,r.jsxs)(tp.N,{mode:"wait",initial:!1,children:["pick"===c&&(0,r.jsxs)(th.P.div,{...lo,className:"space-y-3",children:[(0,r.jsx)(nu,{accept:{"application/json":[".json"]},multiple:!1,maxFiles:1,onValueChange:f,dropzoneText:"Click or drag a settings JSON file here"}),h&&(0,r.jsx)(nU,{intent:"alert",description:h,isClosable:!1}),(0,r.jsx)(nU,{intent:"info",description:"Masked secrets in the file will be skipped automatically - you'll need to re-enter them by hand after the import. Unknown or env-locked keys are reported back.",isClosable:!1})]},"pick"),"review"===c&&m&&(0,r.jsxs)(th.P.div,{...lo,className:"space-y-3",children:[m.exportedAt&&(0,r.jsx)(nU,{intent:"info",description:(0,r.jsxs)("span",{children:["Exported"," ",(0,r.jsx)("span",{className:"font-medium",children:new Date(m.exportedAt).toLocaleString()}),void 0!==m.version&&` \xb7 v${m.version}`," \xb7"," ",m.totalEntries," total entr",1===m.totalEntries?"y":"ies"," in source."]}),isClosable:!1}),m.outOfScope.length>0&&(0,r.jsx)(nU,{intent:"info",title:`${m.outOfScope.length} entr${1===m.outOfScope.length?"y":"ies"} outside this section ignored`,description:"Only keys managed by this page will be imported; everything else in the file is left untouched.",isClosable:!1}),m.maskedSecrets.length>0&&(0,r.jsx)(nU,{intent:"warning",title:`${m.maskedSecrets.length} masked secret${1===m.maskedSecrets.length?"":"s"} skipped`,description:(0,r.jsxs)("span",{children:["You'll need to enter these manually after the import:"," ",(0,r.jsxs)("span",{className:"font-mono text-xs",children:[m.maskedSecrets.slice(0,5).join(", "),m.maskedSecrets.length>5&&` and ${m.maskedSecrets.length-5} more`]})]}),isClosable:!1}),0===y?(0,r.jsx)(nU,{intent:"alert",description:"Nothing to import - the file contains 
13no values that can be applied (everything was either a masked secret or empty).",isClosable:!1}):(0,r.jsx)("div",{className:"max-h-[40vh] overflow-y-auto space-y-4 pr-1",children:b.map(e=>{let[t,s]=e;return(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-[--muted] uppercase tracking-wide mb-1.5",children:aU(t)}),(0,r.jsx)("ul",{className:"space-y-1",children:s.map(e=>{let[t,s]=e;return(0,r.jsx)("li",{className:"flex items-start gap-3 py-1.5 px-2 rounded-md hover:bg-[--subtle] transition-colors",children:(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("code",{className:"text-xs text-[--muted] break-all block",children:t}),(0,r.jsx)("div",{className:"text-xs text-[--foreground] break-all mt-0.5 font-mono min-w-0",children:function(e){if(null===e)return"null";if(void 0===e)return"—";if("string"==typeof e)return""===e?'""':e;if("number"==typeof e||"boolean"==typeof e)return String(e);try{let t=JSON.stringify(e);return t.length>60?t.slice(0,57)+"…":t}catch{return String(e)}}(s)})]})},t)})})]},t)})})]},"review")]})})}function lc(e){let{allKeys:t,sectionKeys:s,sectionLabel:a,invalidate:l,scope:i}=e,[o,d]=n.useState(null),[c,u]=n.useState(!1),[m,p]=n.useState(!1),[h,g]=n.useState(!1),f=n.useMemo(()=>s.filter(e=>"database"===e.source).length,[s]),b=n.useMemo(()=>(t??[]).filter(e=>"database"===e.source).length,[t]),v=n.useMemo(()=>(t??[]).filter(e=>"environment"===e.source).length,[t]),y=async()=>{if(!i)return void window.open("/api/v1/dashboard/settings/export?download=1","_blank");g(!0);try{let e=await az(),t={};for(let[s,a]of Object.entries(e.settings))i.includes(s)&&(t[s]=a);let s={...e,settings:t,maskedSecretKeys:e.maskedSecretKeys.filter(e=>i.includes(e))},a=new Blob([JSON.stringify(s,null,2)],{type:"application/json"}),r=URL.createObjectURL(a),n=new Date().toISOString().replace(/[:.]/g,"-"),l=document.createElement("a");l.href=r,l.download=`${i.fileStem}-${n}.json`,document.body.appendChild(l),l.click(),l.remove(),URL.revokeObjectURL(r)}catch(e){x.oR.error((null==e?void 0:e.message)??"Failed to export settings")}finally{g(!1)}},j=i?i.noun:"database";return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(lt,{align:"end",trigger:(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(tC.voe,{}),"aria-label":"Settings actions"}),children:[(0,r.jsx)(la,{children:"Reset"}),(0,r.jsxs)(ls,{onSelect:()=>d("section"),disabled:0===f,children:[(0,r.jsx)(tC.zOm,{}),"Reset settings in this section…",(0,r.jsx)("span",{className:"ml-auto text-xs text-[--muted]",children:f})]}),t&&(0,r.jsxs)(ls,{onSelect:()=>d("all"),disabled:0===b,children:[(0,r.jsx)(tC.zOm,{}),"Reset all settings…",(0,r.jsx)("span",{className:"ml-auto text-xs text-[--muted]",children:b})]}),!i&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(lr,{}),(0,r.jsx)(la,{children:"Environment"}),(0,r.jsxs)(ls,{onSelect:()=>u(!0),disabled:0===v,children:[(0,r.jsx)(tC.bh6,{}),"Import environment variables…",(0,r.jsx)("span",{className:"ml-auto text-xs text-[--muted]",children:v})]})]}),(0,r.jsx)(lr,{}),(0,r.jsx)(la,{children:"Backup"}),(0,r.jsxs)(ls,{onSelect:()=>p(!0),children:[(0,r.jsx)(tC.Ah9,{}),"Import ",j," settings…"]}),(0,r.jsxs)(ls,{onSelect:y,disabled:h,children:[(0,r.jsx)(tC.tAF,{}),"Export ",j," settings"]})]}),(0,r.jsx)(ll,{open:null!==o,onOpenChange:e=>!e&&d(null),scope:o??"section",scopeLabel:"all"===o?"all settings":a,keys:"all"===o&&t?t:s,invalidate:l}),!i&&(0,r.jsx)(li,{open:c,onOpenChange:u,envKeys:(t??[]).filter(e=>"environment"===e.source)}),(0,r.jsx)(ld,{open:m,onOpenChange:p,restrict:null==i?void 0:i.includes,invalidate:l})]})}function lu(e){let t,{tab:s,allKeys:a}=e,{mutateAsync:l,isPending:i}=(t=(0,o.jE)(),(0,eE.n)({mutationFn:e=>ei("PATCH /dashboard/settings",{body:e}),onSuccess:()=>t.invalidateQueries({queryKey:aO})})),d=n.useRef(null),c=n.useMemo(()=>[...s.groups.values()].flat(),[s]),{schema:u,defaults:m,byName:p}=n.useMemo(()=>{let e={},t={},s=new Map;for(let a of c){let r=n3(a.key);e[r]=rL.bz(),a.secret||null===a.value&&"enum"===a.ui.kind?t[r]="":t[r]=a.value,s.set(r,a)}return{schema:rL.Ik(e),defaults:t,byName:s}},[c]);return(0,r.jsx)(rJ,{schema:u,defaultValues:m,stackClass:"space-y-4 relative",onSubmit:async e=>{var t,s;let a={};for(let[t,s]of Object.entries(e)){let e=p.get(t);if(!e||"environment"===e.source)continue;if(e.secret){s===nV?a[e.key]=null:""!==s&&null!=s&&(a[e.key]=s);continue}let r=(null===e.value||null===e.default)&&""===s?null:s;JSON.stringify(r)!==JSON.stringify(e.value)&&(a[e.key]=r)}if(0===Object.keys(a).length){x.oR.info("No changes to save."),null==(t=d.current)||t.reset(e,{keepValues:!0,keepIsValid:!0});return}try{let t=await l(a);x.oR.success(`Saved ${t.updated.length} setting${1===t.updated.length?"":"s"}.`),null==(s=d.current)||s.reset(e,{keepValues:!0,keepIsValid:!0}),t.requiresRestart&&x.oR.warning("Some changes require a restart to take effect.",{duration:8e3})}catch(t){let e=null==t?void 0:t.issues;if(e)for(let[t,s]of Object.entries(e))x.oR.error(`${t}: ${s}`);else x.oR.error((null==t?void 0:t.message)??"Failed to save settings")}},children:e=>{d.current=e;let t=[...s.groups.keys()],n=t.includes("")?["",...t.filter(e=>""!==e)]:t;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,r.jsx)(nP,{title:s.label,description:`${s.label} configuration`,icon:s.icon}),(0,r.jsx)("div",{className:"pt-1",children:(0,r.jsx)(lc,{allKeys:a,sectionKeys:c,sectionLabel:s.label})})]}),n.map(e=>(0,r.jsx)(nM,{title:e?e.split(".").map(aU).join(" › "):void 0,children:s.groups.get(e).map(e=>(0,r.jsx)("div",{id:`setting-${e.key}`,children:(0,r.jsx)(n4,{k:e})},e.key))},e||"_root")),(0,r.jsx)("div",{className:"flex justify-end pt-2",children:(0,r.jsx)(n$,{isPending:i})}),(0,r.jsx)(nO,{isPending:i})]})}})}function lm(e){let{className:t}=e;return(0,r.jsx)("div",{className:b("p-8 flex items-center justify-center w-full",t),children:(0,r.jsx)(C,{className:"w-6 h-6"})})}function lp(e){let{title:t="Failed to load",message:s,onRetry:a,retrying:n=!1,className:l}=e;return(0,r.jsxs)(X,{className:b("p-6 flex flex-col items-center text-center gap-3",l),children:[(0,r.jsx)(tC.wew,{className:"w-8 h-8 text-red-500"}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("p",{className:"font-medium",children:t}),s&&(0,r.jsx)("p",{className:"text-sm text-[--muted] break-words max-w-md",children:s})]}),a&&(0,r.jsx)(w,{size:"sm",intent:"warning-subtle",leftIcon:(0,r.jsx)(tC.Zxy,{}),loading:n,onClick:a,children:"Retry"})]})}function lh(e){let{query:t,skeleton:s,errorTitle:a,children:n}=e;return t.isPending?(0,r.jsx)(r.Fragment,{children:s??(0,r.jsx)(lm,{})}):t.isError?(0,r.jsx)(lp,{title:a??"Failed to load",message:function(e){if(!e)return"Unknown error";if(e instanceof Error)return e.message;if("string"==typeof e)return e;try{return JSON.stringify(e)}catch{return String(e)}}(t.error),onRetry:()=>
13t.refetch(),retrying:t.isFetching}):(0,r.jsx)(r.Fragment,{children:n(t.data)})}var lx=s(8396),lg=s(9507),lf=s(5321),lb=s(5634),lv=s(3825),ly=s(502),lj=s(2666),lw=s(4097),lN=s(5814),lk=s(1519),lS=s(8810),lC=s(7341),l_=s(3773),lR=s(7444),lA=s(2980);let lT=["var(--brand)","#22c55e","#f59e0b","#06b6d4","#a855f7","#ef4444","#ec4899","#14b8a6"],lI={stroke:"var(--muted)",fontSize:11,tickLine:!1,axisLine:!1},lE={...lI,interval:"preserveStartEnd",minTickGap:24};function lM(e){var t,s;let{active:a,payload:n,label:l,valueFormatter:i,tooltipLabelKey:o}=e;if(!a||!(null==n?void 0:n.length))return null;let d=(o?null==(s=n[0])||null==(t=s.payload)?void 0:t[o]:void 0)??l;return(0,r.jsxs)("div",{className:"rounded-lg border border-[--border] bg-[--paper] px-3 py-2 text-xs shadow-xl",children:[void 0!==d&&(0,r.jsx)("div",{className:"mb-1 font-medium text-[--foreground]",children:d}),n.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center gap-2 tabular-nums",children:[(0,r.jsx)("span",{className:"inline-block h-2 w-2 rounded-full",style:{background:e.color||e.fill}}),(0,r.jsx)("span",{className:"text-[--muted]",children:e.name}),(0,r.jsx)("span",{className:"ml-auto font-medium text-[--foreground]",children:i?i(e.value):e.value})]},t))]})}function lP(e,t){return e.color??lT[t%lT.length]}function lD(e){let{data:t,xKey:s,series:a,height:n=260,className:l,valueFormatter:i,yTickFormatter:o,tooltipLabelKey:d,hideLegend:c,hideGrid:u}=e;return(0,r.jsx)("div",{className:b("w-full",l),children:(0,r.jsx)(lx.u,{width:"100%",height:n,children:(0,r.jsxs)(lg.b,{data:t,margin:{top:8,right:8,bottom:0,left:0},children:[!u&&(0,r.jsx)(lf.d,{strokeDasharray:"3 3",stroke:"var(--border)",vertical:!1}),(0,r.jsx)(lb.W,{dataKey:s,...lE}),(0,r.jsx)(lv.h,{...lI,width:o?60:40,tickFormatter:o}),(0,r.jsx)(ly.m,{content:(0,r.jsx)(lM,{valueFormatter:i,tooltipLabelKey:d}),cursor:{stroke:"var(--border)"}}),!c&&a.length>1&&(0,r.jsx)(lj.s,{wrapperStyle:{fontSize:12}}),a.map((e,t)=>(0,r.jsx)(lw.N1,{type:"monotone",dataKey:e.key,name:e.label??e.key,stroke:lP(e,t),strokeWidth:2,dot:!1,activeDot:{r:4}},e.key))]})})})}function lL(e){let{data:t,xKey:s,series:a,height:n=260,className:l,stacked:i,valueFormatter:o,yTickFormatter:d,tooltipLabelKey:c,hideLegend:u,hideGrid:m}=e;return(0,r.jsx)("div",{className:b("w-full",l),children:(0,r.jsx)(lx.u,{width:"100%",height:n,children:(0,r.jsxs)(lN.Q,{data:t,margin:{top:8,right:8,bottom:0,left:0},children:[(0,r.jsx)("defs",{children:a.map((e,t)=>(0,r.jsxs)("linearGradient",{id:`grad-${e.key}`,x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,r.jsx)("stop",{offset:"5%",stopColor:lP(e,t),stopOpacity:.35}),(0,r.jsx)("stop",{offset:"95%",stopColor:lP(e,t),stopOpacity:0})]},e.key))}),!m&&(0,r.jsx)(lf.d,{strokeDasharray:"3 3",stroke:"var(--border)",vertical:!1}),(0,r.jsx)(lb.W,{dataKey:s,...lE}),(0,r.jsx)(lv.h,{...lI,width:d?60:40,tickFormatter:d}),(0,r.jsx)(ly.m,{content:(0,r.jsx)(lM,{valueFormatter:o,tooltipLabelKey:c}),cursor:{stroke:"var(--border)"}}),!u&&a.length>1&&(0,r.jsx)(lj.s,{wrapperStyle:{fontSize:12}}),a.map((e,t)=>(0,r.jsx)(lk.Gk,{type:"monotone",dataKey:e.key,name:e.label??e.key,stackId:i?"stack":void 0,stroke:lP(e,t),strokeWidth:2,fill:`url(#grad-${e.key})`},e.key))]})})})}function lU(e){let{data:t,xKey:s,series:a,height:n=260,className:l,stacked:i,valueFormatter:o,hideLegend:d,hideGrid:c}=e;return(0,r.jsx)("div",{className:b("w-full",l),children:(0,r.jsx)(lx.u,{width:"100%",height:n,children:(0,r.jsxs)(lS.E,{data:t,margin:{top:8,right:8,bottom:0,left:0},children:[!c&&(0,r.jsx)(lf.d,{strokeDasharray:"3 3",stroke:"var(--border)",vertical:!1}),(0,r.jsx)(lb.W,{dataKey:s,...lI}),(0,r.jsx)(lv.h,{...lI,width:40}),(0,r.jsx)(ly.m,{content:(0,r.jsx)(lM,{valueFormatter:o}),cursor:{fill:"var(--subtle)"}}),!d&&a.length>1&&(0,r.jsx)(lj.s,{wrapperStyle:{fontSize:12}}),a.map((e,t)=>(0,r.jsx)(lC.yP,{dataKey:e.key,name:e.label??e.key,stackId:i?"stack":void 0,fill:lP(e,t),radius:i?0:[4,4,0,0]},e.key))]})})})}function l$(e){let{data:t,height:s=200,className:a,centerLabel:n,centerValue:l,valueFormatter:i}=e;return(0,r.jsxs)("div",{className:b("relative w-full",a),children:[(0,r.jsx)(lx.u,{width:"100%",height:s,children:(0,r.jsxs)(l_.r,{children:[(0,r.jsx)(lR.Fq,{data:t,dataKey:"value",nameKey:"name",innerRadius:"62%",outerRadius:"90%",paddingAngle:2,stroke:"none",children:t.map((e,t)=>(0,r.jsx)(lA.f,{fill:e.color??lT[t%lT.length]},t))}),(0,r.jsx)(ly.m,{content:(0,r.jsx)(lM,{valueFormatter:i})})]})}),(l||n)&&(0,r.jsxs)("div",{className:"pointer-events-none absolute inset-0 flex flex-col items-center justify-center",children:[l&&(0,r.jsx)("span",{className:"text-xl font-bold tabular-nums text-[--foreground]",children:l}),n&&(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:n})]})]})}function lO(e){let{data:t,color:s="var(--brand)",width:a=80,height:n=24,className:l}=e;if(!t.length)return null;let i=Math.min(...t),o=Math.max(...t)-i||1,d=t.map((e,s)=>{let r=s/(t.length-1||1)*a,l=n-(e-i)/o*n;return`${r.toFixed(1)},${l.toFixed(1)}`}).join(" ");
13return(0,r.jsx)("svg",{width:a,height:n,className:b("overflow-visible",l),preserveAspectRatio:"none",children:(0,r.jsx)("polyline",{points:d,fill:"none",stroke:s,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"})})}function lF(e){let{label:t,value:s,hint:a,delta:n,spark:l,className:i}=e;return(0,r.jsxs)("div",{className:b("rounded-xl border border-[--border] bg-[--paper] p-4 flex flex-col gap-1",i),children:[(0,r.jsx)("span",{className:"text-xs uppercase tracking-wide text-[--muted]",children:t}),(0,r.jsxs)("div",{className:"flex items-end justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-2xl font-bold tabular-nums text-[--foreground]",children:s}),l&&(0,r.jsx)(lO,{data:l})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[n&&(0,r.jsx)("span",{className:b("text-xs font-medium",n.positive?"text-emerald-500":"text-red-500"),children:n.value}),a&&(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:a})]})]})}function lz(e){let{value:t}=e,s=rS(t),a=t.toLocaleString();return s===a?(0,r.jsx)("span",{className:"tabular-nums",children:s}):(0,r.jsx)(to,{trigger:(0,r.jsx)("span",{className:"tabular-nums cursor-default border-b border-dotted border-[--muted]/40",children:s}),children:a})}let lV=["24h","7d","30d","all"];function lq(e){let{value:t,onChange:s}=e;return(0,r.jsx)("div",{className:"flex gap-1",children:lV.map(e=>(0,r.jsx)("button",{onClick:()=>s(e),className:b("px-2.5 py-1 rounded-md text-xs font-medium border transition-colors",t===e?"border-brand bg-brand/10 text-brand":"border-[--border] text-[--muted] hover:text-[--foreground]"),children:e},e))})}function lB(e){var t;let{title:s,rows:a}=e,n=a.slice(0,12),l=(null==(t=n[0])?void 0:t.count)??0;return(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{className:"text-xs font-semibold text-[--muted] uppercase tracking-wide mb-2",children:s}),0===n.length?(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"No data for this range."}):(0,r.jsx)("ul",{className:"space-y-1.5",children:n.map(e=>(0,r.jsxs)("li",{className:"text-sm",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"truncate font-medium",children:e.key}),(0,r.jsx)("span",{className:"text-[--muted]",children:(0,r.jsx)(lz,{value:e.count})})]}),(0,r.jsx)("div",{className:"h-1 rounded-full bg-[--subtle] overflow-hidden",children:(0,r.jsx)("div",{className:"h-full bg-brand",style:{width:l?`${e.count/l*100}%`:"0%"}})})]},e.key))})]})}function lK(e){let{uuidHash:t,range:s,onClose:a}=e,n=(0,eU.I)({queryKey:["dashboard","analytics","user-activity",t,s],queryFn:()=>ei(`/dashboard/analytics/users/${t}?range=${s}`),enabled:!!t,staleTime:3e4}),l=n.data,i=l?Math.max(1,...l.resources.map(e=>e.count)):1;return(0,r.jsx)(ty,{open:!!t,onOpenChange:e=>{e||a()},title:"User activity",description:t?`Hashed config ${t.slice(0,16)} \xb7 ${s}`:void 0,contentClass:"max-w-xl",children:n.isLoading?(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"Loading…"}):n.isError?(0,r.jsx)("p",{className:"text-sm text-red-500",children:"Failed to load user activity."}):l?(0,r.jsxs)("div",{className:"space-y-5",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-[--muted]",children:"Requests by resource"}),0===l.resources.length?(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"No requests in this range."}):(0,r.jsx)("ul",{className:"space-y-1.5",children:l.resources.map(e=>(0,r.jsxs)("li",{className:"text-sm",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("span",{className:"font-medium",children:e.resource}),(0,r.jsx)("span",{className:"text-[--muted]",children:(0,r.jsx)(lz,{value:e.count})})]}),(0,r.jsx)("div",{className:"h-1 overflow-hidden rounded-full bg-[--subtle]",children:(0,r.jsx)("div",{className:"h-full bg-brand",style:{width:`${e.count/i*100}%`}})})]},e.resource))})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-[--muted]",children:["IP addresses (",l.ips.length,")"]}),0===l.ips.length?(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"No IP data recorded for this user."}):(0,r.jsx)("div",{className:"max-h-64 overflow-y-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{className:"text-xs uppercase text-[--muted]",children:(0,r.jsxs)("tr",{className:"border-b border-[--border] text-left",children:[(0,r.jsx)("th",{className:"py-1.5 pr-3",children:"Anonymized IP"}),(0,r.jsx)("th",{className:"py-1.5 px-3 text-right",children:"Requests"}),(0,r.jsx)("th",{className:"py-1.5 pl-3 text-right",children:"Last seen"})]})}),(0,r.jsx)("tbody",{children:l.ips.map(e=>(0,r.jsxs)("tr",{className:"border-b border-[--border]/50",children:[(0,r.jsx)("td",{className:"py-1.5 pr-3 font-mono text-xs",children:e.ipPrefix}),(0,r.jsx)("td",{className:"py-1.5 px-3 text-right",children:(0,r.jsx)(lz,{value:e.count})}),(0,r.jsx)("td",{className:"py-1.5 pl-3 text-right whitespace-nowrap text-[--muted]",children:new Date(e.lastSeen).toLocaleStr
13ing()})]},e.ipPrefix))})]})})]})]}):null})}function lH(){let[e,t]=n.useState(null),[s,a]=n.useState(!1),[r,l]=n.useState(null),[i,o]=n.useState(0),d=n.useRef([]),[c,u]=n.useState([]),m=n.useCallback(e=>{let t={ts:e.ts,total:e.cpu.total,process:e.cpu.process,perCore:e.cpu.perCore},s=Date.now()-3e5,a=[...d.current,t].filter(e=>e.ts>=s).slice(-120);d.current=a,u(a)},[]),p=n.useCallback(()=>{l(null),o(e=>e+1)},[]);return n.useEffect(()=>{let e=!1;ei("/dashboard/system").then(s=>{e||(t(s),l(null),m(s))}).catch(t=>{e||l(e=>e??(t instanceof Error?t.message:"Failed to load system metrics"))});let s=new EventSource("/api/v1/dashboard/system/stream",{withCredentials:!0});return s.onopen=()=>{a(!0),l(null)},s.onerror=()=>a(!1),s.onmessage=e=>{try{let s=JSON.parse(e.data);t(e=>({...s,lifecycleEnabled:null==e?void 0:e.lifecycleEnabled})),m(s)}catch{}},()=>{e=!0,s.close()}},[m,i]),{metrics:e,connected:s,history:c,windowMs:3e5,error:r,retry:p}}function lG(e){let{label:t,pct:s,detail:a}=e;return(0,r.jsxs)(X,{className:"p-4 flex flex-col items-center",children:[(0,r.jsx)("span",{className:"text-xs uppercase tracking-wide text-[--muted] mb-2",children:t}),(0,r.jsx)(l$,{height:150,data:[{name:t,value:s,color:s>90?"#ef4444":s>70?"#f59e0b":"var(--brand)"},{name:"free",value:100-s,color:"var(--subtle)"}],centerValue:`${Math.round(s)}%`}),(0,r.jsx)("span",{className:"text-xs text-[--muted] mt-2",children:a})]})}function lW(e){let{value:t,onChange:s,options:a}=e;return(0,r.jsx)("div",{className:"inline-flex rounded-md border border-[--border] bg-[--subtle]/30 p-0.5 text-xs",children:a.map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>!e.disabled&&s(e.value),disabled:e.disabled,title:e.title,className:b("px-2.5 py-1 rounded-[5px] transition-colors",t===e.value?"bg-[--paper] text-[--foreground] shadow-sm":"text-[--muted] hover:text-[--foreground]",e.disabled&&"opacity-40 cursor-not-allowed hover:text-[--muted]"),children:e.label},e.value))})}let lY=["10","25","50","100"],lJ=e=>{if(!e)return"never";let t=(Date.now()-e)/1e3;return t<0?`in ${ry(-t)}`:`${ry(t)} ago`},lZ=e=>null==e?"":"0s"===ry(e/1e3)?`${e}ms`:ry(e/1e3),lQ={memory:"bg-sky-500/10 text-sky-500 border-sky-500/20",sql:"bg-violet-500/10 text-violet-500 border-violet-500/20",redis:"bg-red-500/10 text-red-500 border-red-500/20",disk:"bg-amber-500/10 text-amber-500 border-amber-500/20"};function lX(e){let{sections:t,value:s,onChange:a}=e,[l,i]=n.useState(!1),o=n.useRef(null),d=t.find(e=>e.id===s)??t[0],c=d.icon;return n.useEffect(()=>{if(!l)return;let e=e=>{o.current&&!o.current.contains(e.target)&&i(!1)},t=e=>{"Escape"===e.key&&i(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[l]),(0,r.jsxs)("div",{ref:o,className:"relative sm:hidden",children:[(0,r.jsxs)("button",{type:"button","aria-haspopup":"listbox","aria-expanded":l,onClick:()=>i(e=>!e),className:"flex h-11 w-full items-center gap-2.5 rounded-full border border-[--border] bg-[--subtle]/40 px-4 text-sm font-medium",children:[(0,r.jsx)(c,{className:"shrink-0 text-lg text-[--muted]"}),(0,r.jsx)("span",{className:"flex-1 text-left",children:d.label}),(0,r.jsx)(tC.nwe,{className:b("text-lg text-[--muted] transition-transform",l&&"rotate-180")})]}),(0,r.jsx)(tp.N,{children:l&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(th.P.div,{className:"fixed inset-0 z-40 bg-black/30",initial:{opacity:0}
13,animate:{opacity:1},exit:{opacity:0},onClick:()=>i(!1)}),(0,r.jsx)(th.P.ul,{role:"listbox",initial:{opacity:0,y:-6,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-6,scale:.98},transition:{duration:.15,ease:"easeOut"},className:"absolute inset-x-0 top-full z-50 mt-2 overflow-hidden rounded-xl border border-[--border] bg-[--background] shadow-lg",children:t.map(e=>{let t=e.id===s,n=e.icon;return(0,r.jsx)("li",{children:(0,r.jsxs)("button",{type:"button",role:"option","aria-selected":t,onClick:()=>{a(e.id),i(!1)},className:b("flex w-full items-center gap-3 px-4 py-3 text-sm transition-colors",t?"bg-[--subtle] font-medium text-[--foreground]":"text-[--muted] hover:bg-[--subtle]/40 hover:text-[--foreground]"),children:[(0,r.jsx)(n,{className:"shrink-0 text-lg"}),(0,r.jsx)("span",{className:"flex-1 text-left",children:e.label}),t&&(0,r.jsx)(tC.mmP,{className:"text-lg text-[--muted]"})]})},e.id)})})]})})]})}let l0=["dead","defective","fake","mislabeled"],l1=["full","corroborate","observe"],l2={dead:"bg-red-500/10 text-red-500 border-red-500/20",defective:"bg-amber-500/10 text-amber-500 border-amber-500/20",fake:"bg-fuchsia-500/10 text-fuchsia-500 border-fuchsia-500/20",mislabeled:"bg-sky-500/10 text-sky-500 border-sky-500/20"},l3={usenet:"bg-violet-500/10 text-violet-500 border-violet-500/20",torrent:"bg-emerald-500/10 text-emerald-500 border-emerald-500/20",local:"bg-emerald-500/10 text-emerald-500 border-emerald-500/20",remote:"bg-sky-500/10 text-sky-500 border-sky-500/20",imported:"bg-amber-500/10 text-amber-500 border-amber-500/20"},l6={full:"bg-emerald-500/10 text-emerald-500 border-emerald-500/20",corroborate:"bg-sky-500/10 text-sky-500 border-sky-500/20",observe:"bg-gray-500/10 text-gray-400 border-gray-500/20"};function l5(e){let{className:t,children:s}=e;return(0,r.jsx)("span",{className:b("text-[10px] uppercase px-1.5 py-0.5 rounded border whitespace-nowrap",t),children:s})}function l4(e){return e?new Date(1e3*e).toLocaleString():"—"}function l9(e){return e%86400==0?`${e/86400}d`:e%3600==0?`${e/3600}h`:e%60==0?`${e/60}m`:`${e}s`}function l8(){return(0,eU.I)({queryKey:["dashboard","blocklist","snapshot"],queryFn:()=>ei("/dashboard/blocklist"),refetchInterval:3e4})}function l7(){let e=(0,o.jE)();return()=>e.invalidateQueries({queryKey:["dashboard","blocklist"]})}function ie(e){let{snapshot:t,invalidate:s}=e,[a,l]=n.useState(!1),[i,o]=n.useState(!1),[d,c]=n.useState(!1),[u,m]=n.useState(),[p,h]=n.useState(new Set),[g,f]=n.useState(!1),[v,y]=n.useState(null),j=t.sources,N=j.filter(e=>"local"!==e.id),k=j.length>0&&j.every(e=>p.has(e.id)),S=j.map(e=>e.id).sort().join(",");n.useEffect(()=>{h(new Set)},[S]);let C=(0,eE.n)({mutationFn:e=>ei("POST /dashboard/blocklist/sources/remove",{body:{ids:e}}),onSuccess:e=>{x.oR.success(`Removed ${e.affected} source${1===e.affected?"":"s"}`),s()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Remove failed")}),_=(0,eE.n)({mutationFn:e=>ei("POST /dashboard/blocklist/sources/clear",{body:{ids:e}}),onSuccess:e=>{x.oR.success(`Cleared ${e.affected} source${1===e.affected?"":"s"}`),s()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Clear failed")}),R=(0,eE.n)({mutationFn:e=>ei("POST /dashboard/blocklist/sources/refresh",{body:{ids:e}}),onSuccess:e=>{x.oR.success(`Refreshed ${e.affected} source${1===e.affected?"":"s"}`),s()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Refresh failed")}),A=(0,eE.n)({mutationFn:e=>ei("PATCH /dashboard/blocklist/sources",{body:{ids:e.ids,...e.body}}),onSuccess:()=>s(),onError:e=>x.oR.error((null==e?void 0:e.message)??"Update failed")}),T={onSuccess:()=>h(new Set)},I=tN({title:(null==v?void 0:v.title)??"",description:null==v?void 0:v.description,actionText:null==v?void 0:v.actionText,actionIntent:null==v?void 0:v.actionIntent,onConfirm:()=>null==v?void 0:v.onConfirm()}),M=e=>{y(e),I.open()},P=e=>`${e} source${1===e?"":"s"}`,D=[...p].some(e=>{var t;return(null==(t=j.find(t=>t.id===e))?void 0:t.kind)==="remote"}),L=[...p].some(e=>{var t;return(null==(t=j.find(t=>t.id===e))?void 0:t.kind)==="local"}),U=!L,$=!L,O=!L&&D;return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex gap-2 flex-wrap items-center min-h-9",children:[(0,r.jsx)(w,{size:"sm",intent:"primary-subtle",leftIcon:(0,r.jsx)(tC.Ca6,{}),onClick:()=>l(!0),children:"Subscribe to a list"}),(0,r.jsx)(w,{size:"sm",intent:"gray-outline",leftIcon:(0,r.jsx)(tC.tAF,{}),onClick:()=>o(!0),children:"Import"}),(0,r.jsx)(w,{size:"sm",intent:"gray-outline",leftIcon:(0,r.jsx)(tC.Ah9,{}),onClick:()=>c(!0),children:"Export"}),(0,r.jsxs)("div",{className:"relative flex flex-1 gap-2 items-center",children:[(0,r.jsxs)("div",{className:b("flex flex-1 gap-2 items-center",0===p.size&&"invisible"),children:[(0,r.jsxs)("span",{className:"text-sm font-medium tabular-nums text-[--muted]",children:[p.size," selected"]}),(0,r.jsx)("div",{className:"flex-1"}),(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(tC.Zxy,{}),"aria-label":"Refresh selected",title:O?"Refresh selected":L?"Cannot refresh local sources":"No remote sources selected",loading:R.isPending,onClick:()=>M({title:"Refresh selected sources",description:`${P(p.size)} selected: refetch their lists from their remote URLs now.`,actionText:"Refresh all",actionIntent:"primary-subtle",onConfirm:()=>R.mutate([...p],T)}),disabled:!O}),(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(tC.z$h,{}),"aria-label":"Edit selected",title:U?"Edit selected":"Cannot edit the local source",onClick:()=>f(!0),disabled:!U}),(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(tC.PLI,{}),"aria-label":"Clear entries of selected",title:"Clear entries of selected",loading:_.isPending,onClick:()=>M({title:"Clear entries from selected sources",description:`${P(p.size)} selected: entries are removed but the sources themselves are kept.`,actionText:"Clear all",actionIntent:"alert-subtle",onConfirm:()=>_.mutate([...p],T)})}),(0,r.jsx)(E,{size:"sm",intent:"alert-subtle",icon:(0,r.jsx)(tC.id1,{}),"aria-label":"Remove selected",title:$?"Remove selected":"Cannot remove the local source",loading:C.isPending,onClick:()=>M({title:"Remove selected sources",description:`${P(p.size)} selected: the source and every entry it contributed will be removed. This cannot be undone. The local source is skipped.`,actionText:"Remove all",actionIntent:"alert-subtle",onConfirm:()=>C.mutate([...p],T)}),disabled:!$})]}),0===p.size&&N.length>0&&(0,r.jsx)(w,{size:"sm",intent:"alert-subtle",leftIcon:(0,r.jsx)(tC.id1,{}),title:"Remove all sources except the local one",loading:C.isPending,onClick:()=>M({title:"Remove all non-local sources",description:`Remove every source except this instance's own list (${P(N.length)}). This cannot be undone.`,actionText:"Remove all",actionIntent:"alert-subtle",onConfirm:()=>C.mutate(N.map(e=>e.id),T)}),className:"absolute right-0",children:"Remove all"})]})]}),(0,r.jsx)(X,{className:"p-0 overflow-hidden",children:(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{className:"text-[--muted] text-xs uppercase bg-[--subtle]/40",children:(0,r.jsxs)("tr",{className:"text-left",children:[(0,r.jsx)("th",{className:"p-3 w-10",children:j.length>0&&(0,r.jsx)(r6,{value:k,onValueChange:e=>h(!0===e?new Set(j.map(e=>e.id)):new Set),"aria-label":"Select all"})}),(0,r.jsx)("th",{className:"p-3",children:"Name"}),(0,r.jsx)("th",{className:"p-3",children:"Kind"}),(0,r.jsx)("th",{className:"p-3",children:"Trust"}),(0,r.jsx)("th",{className:"p-3",children:"Refresh"}),(0,r.jsx)("th",{className:"p-3",children:"Status"}),(0,r.jsx)("th",{className:"p-3 text-right",children:"Entries"}),(0,r.jsx)("th",{className:"p-3",children:"Enabled"}),(0,r.jsx)("th",{className:"p-3 text-right",children:"Actions"})]})}),(0,r.jsx)("tbody",{children:t.sources.map(e=>{var t,s,a;return(0,r.jsxs)("tr",{className:b("border-t border-[--border]/50",p.has(e.id)?"bg-[--accent]/5":"hover:bg-[--subtle]/30"),children:[(0,r.jsx)("td",{className:"p-3",children:(0,r.jsx)(r6,{value:p.has(e.id),onValueChange:()=>{var t;return t=e.id,void h(e=>{let s=new Set(e);return s.has(t)?s.delete(t):s.add(t),s})},"aria-label":`Select ${e.name}`})}),(0,r.jsx)("td",{className:"p-3 font-medium",children:e.name}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsx)(l5,{className:l3[e.kind],children:e.kind})}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsx)(l5,{className:l6[e.trust],children:e.trust})}),(0,r.jsx)("td",{className:"p-3 tabular-nums",children:"remote"===e.kind?l9(e.refreshSeconds):"—"}),(0,r.jsx)("td",{className:"p-3 text-xs text-[--muted] max-w-[220px] truncate",title:e.status??void 0,children:e.status??"—"}),(0,r.jsxs)("td",{className:"p-3 text-right tabular-nums",children:[(0,r.jsx)("div",{children:e.count}),e.count>0&&(0,r.jsxs)("div",{className:"text-xs text-[--muted]",title:"Entries no other source lists",children:[e.uniqueCount," unique"]})]}),(0,r.jsx)("td",{className:"p-3",children:"local"===e.kind?"—":(0,r.jsx)(rs,{value:e.enabled,onValueChange:t=>
13A.mutate({ids:[e.id],body:{enabled:t}})})}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsxs)("div",{className:"flex justify-end gap-1",children:["remote"===e.kind&&(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(tC.Zxy,{}),"aria-label":"Refresh now",loading:R.isPending&&(null==(t=R.variables)?void 0:t.length)===1&&R.variables[0]===e.id,onClick:()=>R.mutate([e.id])}),"local"!==e.kind&&(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(tC.z$h,{}),"aria-label":"Edit source",onClick:()=>m(e)}),(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(tC.PLI,{}),"aria-label":"Clear entries",loading:_.isPending&&(null==(s=_.variables)?void 0:s.length)===1&&_.variables[0]===e.id,onClick:()=>M({title:"Clear source entries",description:"This removes every entry this source contributed but keeps the source itself.",actionText:"Clear",actionIntent:"alert-subtle",onConfirm:()=>_.mutate([e.id])})}),"local"!==e.kind&&(0,r.jsx)(E,{size:"sm",intent:"alert-subtle",icon:(0,r.jsx)(tC.id1,{}),"aria-label":"Remove source",loading:C.isPending&&(null==(a=C.variables)?void 0:a.length)===1&&C.variables[0]===e.id,onClick:()=>M({title:"Remove source",description:"This removes the source and every entry it contributed. This cannot be undone.",actionText:"Remove",actionIntent:"alert-subtle",onConfirm:()=>C.mutate([e.id])})})]})})]},e.id)})})]})})}),(0,r.jsx)(is,{open:a,onOpenChange:l,invalidate:s}),(0,r.jsx)(ir,{open:i,onOpenChange:o,invalidate:s}),(0,r.jsx)(il,{open:d,onOpenChange:c}),u&&(0,r.jsx)(it,{source:u,onClose:()=>m(void 0),invalidate:s}),g&&(0,r.jsx)(ii,{selectedIds:[...p],sources:j,onSave:e=>A.mutate({ids:[...p],body:e},{onSuccess:e=>{x.oR.success(`Updated ${e.affected} source${1===e.affected?"":"s"}`),h(new Set),f(!1)}}),loading:A.isPending,onClose:()=>f(!1)}),(0,r.jsx)(tk,{...I})]})}function it(e){let{source:t,onClose:s,invalidate:a}=e,[l,i]=n.useState(t.name),[o,d]=n.useState(""),[c,u]=n.useState(t.trust),[m,p]=n.useState(Math.max(1,Math.round(t.refreshSeconds/3600))),h=(0,eE.n)({mutationFn:()=>{let e={name:l.trim()||t.name,trust:c};return"remote"===t.kind&&(e.refreshSeconds=Math.round(3600*m),o.trim()&&(e.url=o.trim())),ei("PATCH /dashboard/blocklist/sources",{body:{ids:[t.id],...e}})},onSuccess:()=>{x.oR.success("Source updated"),s(),a()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Update failed")});return(0,r.jsx)(ty,{open:!0,onOpenChange:e=>!e&&s(),title:`Edit "${t.name}"`,children:(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(W,{label:"Name",value:l,onValueChange:i}),"remote"===t.kind&&(0,r.jsx)(W,{label:"URL",placeholder:"(unchanged)",value:o,onValueChange:d,help:t.url?`Current: ${t.url}`:"Leave blank to keep the current URL"}),(0,r.jsx)(rn,{label:"Trust",options:l1.map(e=>({label:e,value:e})),value:c,onValueChange:e=>u(e),help:"full filters on its own; corroborate needs the quorum; observe never filters"}),"remote"===t.kind&&(0,r.jsx)(nn,{label:"Refresh (hours)",value:m,min:1,max:720,onValueChange:e=>p(e||24)}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(w,{intent:"gray-outline",onClick:s,children:"Cancel"}),(0,r.jsx)(w,{intent:"primary",loading:h.isPending,onClick:()=>h.mutate(),children:"Save"})]})]})})}function is(e){let{open:t,onOpenChange:s,invalidate:a}=e,[l,i]=n.useState(""),[o,d]=n.useState("full"),[c,u]=n.useState(24),m=l.split("\n").map(e=>e.trim()).filter(e=>e&&!e.startsWith("#")).length,p=(0,eE.n)({mutationFn:()=>ei("POST /dashboard/blocklist/sources/remote",{body:{input:l,trust:o,refreshSeconds:Math.round(3600*c)}}),onSuccess:e=>{let{import:t}=e,r=[`${t.added} added`];t.skipped&&r.push(`${t.skipped} already present`),t.errors.length&&r.push(`${t.errors.length} failed`),x.oR.success(r.join(", ")),s(!1),i(""),a()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Subscribe failed")});return(0,r.jsx)(ty,{open:t,onOpenChange:s,title:"Subscribe to blocklists",description:"Any URL serving a blocklist or Warden NDJSON list, e.g. another instance's /blocklist/export. One URL per line.",children:(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(np,{label:"List URL(s)",placeholder:"https://example.com/blocklist/export",rows:5,value:l,onValueChange:i}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsx)(rn,{label:"Trust",options:l1.map(e=>({label:e,value:e})),value:o,onValueChange:e=>d(e),help:"full filters on its own; corroborate needs the quorum; observe never filters"}),(0,r.jsx)(nn,{label:"Refresh (hours)",value:c,min:1,max:720,onValueChange:e=>u(e||24)})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(w,{intent:"gray-outline",onClick:()=>s(!1),children:"Cancel"}),(0,r.jsx)(w,{intent:"primary",loading:p.isPending,disabled:0===m,onClick:()=>p.mutate(),children:m>1?`Subscribe (${m})`:"Subscribe"})]})]})})}
13let ia={"application/x-ndjson":[".ndjson"],"application/json":[".json"],"application/gzip":[".gz"],"text/plain":[".txt"]};function ir(e){let{open:t,onOpenChange:s,invalidate:a}=e,[l,i]=n.useState(""),[o,d]=n.useState(null),[c,u]=n.useState(!1),m=async()=>{if(o){u(!0);try{let t=await o.arrayBuffer(),r=new URLSearchParams;l.trim()&&r.set("name",l.trim());let n=await fetch(`/api/v1/dashboard/blocklist/import?${r.toString()}`,{method:"POST",headers:{"Content-Type":"application/octet-stream"},body:t}),c=await n.json().catch(()=>void 0);if(!n.ok||(null==c?void 0:c.success)===!1){var e;throw Error((null==c||null==(e=c.error)?void 0:e.message)??`HTTP ${n.status}`)}x.oR.success("List imported"),s(!1),d(null),i(""),a()}catch(e){x.oR.error((null==e?void 0:e.message)??"Import failed")}finally{u(!1)}}};return(0,r.jsx)(ty,{open:t,onOpenChange:s,title:"Import a blocklist",description:"Upload an NDJSON list (native or Warden format, .gz supported). Imports become their own source and never merge into your local list.",children:(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(W,{label:"Name (optional)",placeholder:`Import ${new Date().toISOString().slice(0,10)}`,value:l,onValueChange:i}),(0,r.jsx)(nu,{accept:ia,className:"min-h-[120px] w-full",dropzoneText:"Drop a list file here, or click to choose",onValueChange:e=>d(e[0]??null),onDropRejected:e=>{let t=e.map(e=>e.file.name);x.oR.error(1===t.length?`"${t[0]}" isn't a supported list file`:"Drop a single .ndjson, .json, .gz or .txt file")}}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(w,{intent:"gray-outline",onClick:()=>s(!1),children:"Cancel"}),(0,r.jsx)(w,{intent:"primary",loading:c,disabled:!o,onClick:m,children:"Import"})]})]})})}function il(e){let{open:t,onOpenChange:s}=e,[a,l]=n.useState(!1),[i,o]=n.useState("local");return(0,r.jsx)(ty,{open:t,onOpenChange:s,title:"Export the blocklist",description:"Download the list as NDJSON, ready to be imported or subscribed to by another instance.",children:(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(rn,{label:"Scope",options:[{label:"This instance's own verdicts",value:"local"},{label:"Everything (all sources, deduplicated)",value:"all"}],value:i,onValueChange:e=>o(e)}),(0,r.jsx)(rs,{label:"Warden-compatible format",value:a,onValueChange:l,help:"For davex. Carries only dead usenet fingerprints; content-hash and torrent entries are left out."}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(w,{intent:"gray-outline",onClick:()=>s(!1),children:"Cancel"}),(0,r.jsx)(w,{intent:"primary",leftIcon:(0,r.jsx)(tC.Ah9,{}),onClick:()=>{let e=document.createElement("a");e.href=`/api/v1/dashboard/blocklist/export?format=${a?"warden":"native"}&scope=${i}`,e.download="",document.body.appendChild(e),e.click(),e.remove(),s(!1)},children:"Download"})]})]})})}function ii(e){let{selectedIds:t,sources:s,onSave:a,loading:l,onClose:i}=e,o=s.filter(e=>t.includes(e.id)).some(e=>"remote"===e.kind),[d,c]=n.useState(""),[u,m]=n.useState(24),[p,h]=n.useState(!1),[x,g]=n.useState(""),f=()=>{let e={};return d&&(e.trust=d),o&&p&&u>0&&(e.refreshSeconds=Math.round(3600*u)),""!==x&&(e.enabled=x),e};return(0,r.jsx)(ty,{open:!0,onOpenChange:e=>!e&&i(),title:`Edit ${t.length} source${1===t.length?"":"s"}`,description:"Set common fields for all selected sources. Blank fields are left unchanged.",children:(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(rn,{label:"Trust",options:[{label:"Leave unchanged",value:""},...l1.map(e=>({label:e,value:e}))],value:d,onValueChange:e=>c(e),help:"full filters on its own; corroborate needs the quorum; observe never filters"}),o&&(0,r.jsx)(nn,{label:"Refresh (hours)",value:u,min:1,max:720,onValueChange:e=>{m(e||24),h(!0)},help:"Only applies to remote sources"}),(0,r.jsx)(rn,{label:"Enabled",options:[{label:"Leave unchanged",value:""},{label:"Enable",value:"true"},{label:"Disable",value:"false"}],value:""===x?"":String(x),onValueChange:e=>g(""===e?"":"true"===e),help:"Enable or disable the source. The local source cannot be disabled."}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(w,{intent:"gray-outline",onClick:i,children:"Cancel"}),(0,r.jsx)(w,{intent:"primary",loading:l,disabled:0===Object.keys(f()).length,onClick:()=>a(f()),children:"Save"})]})]})})}let io={root:(0,h.F)(["UI-Pagination__root","flex gap-1 text-xs font-medium"]),item:(0,h.F)(["UI-Pagination__item","bg-transparent dark:bg-transparent text-sm text-[--muted] inline-flex h-8 min-w-8 px-1 tabular-nums items-center justify-center rounded-[--radius] border cursor-pointer","hover:bg-[--subtle] dark:hover:bg-[--subtle] hover:border-[--subtle] select-none","data-[selected=true]:bg-brand-500 data-[selected=true]:border-transparent data-[selected=true]:text-white data-[selected=true]:hover:bg-brand data-[selected=true]:pointer-events-none","data-[disabled=true]:opacity-50 data-[disabled=true]:pointer-events-none data-[disabled=true]:cursor-not-allowed","outline-none ring-[--ring] focus-visible:ring-2"]),ellipsis:(0,h.F)(["UI-Pagination__ellipsis","flex p-2 items-center text-[1.05rem]"])},id=n.createContext({}),ic=n.forwardRef((e,t)=>
13{let{children:s,itemClass:a,className:n,ellipsisClass:l,...i}=e;return(0,r.jsx)(id.Provider,{value:{itemClass:a,ellipsisClass:l},children:(0,r.jsx)("ul",{ref:t,className:b(io.root(),n),role:"navigation",...i,children:s})})});ic.displayName="Pagination";let iu=n.forwardRef((e,t)=>{let{value:s,className:a,...l}=e,{itemClass:i}=n.useContext(id);return(0,r.jsx)("li",{children:(0,r.jsx)("button",{className:b(io.item(),i,a),...l,ref:t,children:s})})});iu.displayName="PaginationItem";let im=n.forwardRef((e,t)=>{let{isChevrons:s=!1,isDisabled:a=!1,direction:l,className:i,...o}=e,{itemClass:d}=n.useContext(id);return(0,r.jsx)("li",{children:(0,r.jsx)("button",{className:b(io.item(),d,i),"data-disabled":a,tabIndex:a?-1:void 0,...o,ref:t,children:"previous"===l?(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"h-4 w-4",children:s?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("polyline",{points:"11 17 6 12 11 7"}),(0,r.jsx)("polyline",{points:"18 17 13 12 18 7"})]}):(0,r.jsx)("polyline",{points:"15 18 9 12 15 6"})}):(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"h-4 w-4",children:s?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("polyline",{points:"13 17 18 12 13 7"}),(0,r.jsx)("polyline",{points:"6 17 11 12 6 7"})]}):(0,r.jsx)("polyline",{points:"9 18 15 12 9 6"})})})})});im.displayName="PaginationTrigger";let ip=n.forwardRef((e,t)=>{let{className:s,...a}=e,{ellipsisClass:l}=n.useContext(id);return(0,r.jsx)("li",{className:b(io.ellipsis(),l,s),children:(0,r.jsx)("span",{...a,ref:t,children:"…"})})});function ih(e,t){let s=[...new Set([1,t,e-1,e,e+1])].filter(e=>e>=1&&e<=t).sort((e,t)=>e-t),a=[],r=0;for(let e of s)r&&e-r>1&&a.push("…"),a.push(e),r=e;return a}function ix(e){let{snapshot:t,invalidate:s}=e,[a,l]=n.useState(""),[i,o]=n.useState(""),[d,c]=n.useState(""),[u,m]=n.useState(""),[p,h]=n.useState(1),[g,f]=n.useState(!1),[v,y]=n.useState(),j=(0,eU.I)({queryKey:["dashboard","blocklist","entries",{search:a,sourceId:i,verdict:d,kind:u,page:p}],queryFn:()=>{let e=new URLSearchParams({page:String(p)});return a.trim()&&e.set("search",a.trim()),i&&e.set("source",i),d&&e.set("verdict",d),u&&e.set("kind",u),ei(`/dashboard/blocklist/entries?${e}`)},placeholderData:aV.rX}),N=(0,eE.n)({mutationFn:e=>ei("POST /dashboard/blocklist/unmark",{body:{releases:[[e]]}}),onSuccess:()=>{x.oR.success("Release allowed on this instance"),s()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Failed")}),k=(0,eE.n)({mutationFn:e=>ei(`DELETE /dashboard/blocklist/entries?key=${encodeURIComponent(e)}`),onSuccess:()=>{x.oR.success("Verdict removed"),s()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Failed")}),S=(0,eE.n)({mutationFn:e=>ei(`DELETE /dashboard/blocklist/overrides${e?`?key=${encodeURIComponent(e)}`:""}`),onSuccess:(e,t)=>{x.oR.success(t?"Override cleared":"All overrides cleared"),s()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Failed")}),C=tN({title:"Clear all overrides",description:`Re-block every release this instance has allowed (${t.counts.overrides} override${1===t.counts.overrides?"":"s"}). Their remote verdicts start filtering again.`,actionText:"Clear all",actionIntent:"alert-subtle",onConfirm:()=>S.mutate(void 0)}),_=j.data,R=_?Math.max(1,Math.ceil(_.total/_.pageSize)):1,A="__any__";return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex gap-2 flex-wrap items-end",children:[(0,r.jsx)(W,{leftIcon:(0,r.jsx)(tC.iyI,{}),placeholder:"Search keys…",value:a,onValueChange:e=>{l(e),h(1)},className:"w-64"}),(0,r.jsx)(rn,{options:[{label:"All sources",value:A},...t.sources.map(e=>({label:e.name,value:e.id}))],value:i||A,onValueChange:e=>{o(e===A?"":e),h(1)}}),(0,r.jsx)(rn,{options:[{label:"All verdicts",value:A},...l0.map(e=>({label:e,value:e}))],value:d||A,onValueChange:e=>{c(e===A?"":e),h(1)}}),(0,r.jsx)(rn,{options:[{label:"All kinds",value:A},{label:"usenet",value:"usenet"},{label:"torrent",value:"torrent"}],value:u||A,onValueChange:e=>{m(e===A?"":e),h(1)}}),(0,r.jsx)("div",{className:"flex-1"}),t.counts.overrides>0&&(0,r.jsxs)(w,{size:"sm",intent:"gray-outline",loading:S.isPending&&void 0===S.variables,onClick:C.open,title:"Overrides suppress remote verdicts for releases this instance proved working",children:["Clear all overrides (",t.counts.overrides,")"]}),(0,r.jsx)(w,{size:"sm",intent:"primary-subtle",leftIcon:(0,r.jsx)(tC.Ca6,{}),onClick:()=>f(!0),children:"Mark a release"})]}),(0,r.jsx)(lh,{query:j,errorTitle:"Failed to load entries",children:e=>(0,r.jsxs)(X,{className:"p-0 overflow-hidden",children:[(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{className:"text-[--muted] text-xs uppercase bg-[--subtle]/40",children:(0,r.jsxs)("tr",{className:"text-left",children:[(0,r.jsx)("th",{className:"p-3",children:"Key"}),(0,r.jsx)("th",{className:"p-3",children:"Kind"}),(0,r.jsx)("th",{className:"p-3",children:"Verdict"}),(0,r.jsx)("th",{className:"p-3",children:"Sources"}),(0,r.jsx)("th",{className:"p-3",children:"Backbones"}),(0,r.jsx)("th",{className:"p-3",children:"Last seen"}),(0,r.jsx)("th",{className:"p-3 text-right",children:"Actions"})]})}),(0,r.jsxs)("tbody",{children:[0===e.entries.length&&(0,r.jsx)("tr",{children:(0,r.jsx)("td",{className:"p-6 text-center text-[--muted]",colSpan:7,children:"No entries"})}),e.entries.map(e=>(0,r.jsxs)("tr",{className:"border-t border-[--border]/50 hover:bg-[--subtle]/30",children:[(0,r.jsx)("td",{className:"p-3 font-mono text-xs max-w-[260px] truncate cursor-pointer",title:`${e.key} (click to copy)`,onClick:()=>void rm(e.key,{onSuccess:()=>x.oR.success("Key copied"),onError:()=>x.oR.error("Copy failed")}),children:e.key}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsx)(l5,{className:l3[e.kind],children:e.kind})}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsxs)("div",{className:"flex gap-1",children:[(0,r.jsx)(l5,{className:l2[e.verdict],children:e.verdict}),e.overridden&&(0,r.jsx)(l5,{className:"bg-emerald-500/10 text-emerald-500 border-emerald-500/20",children:"allowed"})]})}),(0,r.jsx)("td",{className:"p-3 text-xs max-w-[200px] truncate",title:e.sources.map(e=>`${e.name} (${e.verdict}, ${e.trust})`).join("\n"),children:e.sources.map(e=>e.name).join(", ")}),(0,r.jsx)("td",{className:b("p-3 text-xs text-[--muted] max-w-[180px] truncate",e.backbones.length>0&&"cursor-pointer underline decoration-dotted"),title:e.backbones.length>0?"Click for the full backbone scope":void 0,onClick:()=>e.backbones.length>0&&y(e),children:e.backbones.join(", ")||"everywhere"}),(0,r.jsx)("td",{className:"p-3 text-xs tabular-nums whitespace-nowrap",children:l4(e.lastAt)}
13),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsx)("div",{className:"flex justify-end",children:e.overridden?(0,r.jsx)(w,{size:"sm",intent:"gray-subtle",leftIcon:(0,r.jsx)(tC.PLI,{}),loading:S.isPending&&S.variables===e.key,onClick:()=>S.mutate(e.key),title:"Remove the override so these verdicts filter again",children:"Re-block"}):e.sources.some(e=>"local"!==e.id)?(0,r.jsx)(w,{size:"sm",intent:"gray-subtle",leftIcon:(0,r.jsx)(tC.DNZ,{}),loading:N.isPending&&N.variables===e.key,onClick:()=>N.mutate(e.key),title:"Remove any local verdict and suppress the remote ones",children:"Allow"}):(0,r.jsx)(w,{size:"sm",intent:"gray-subtle",leftIcon:(0,r.jsx)(tC.id1,{}),loading:k.isPending&&k.variables===e.key,onClick:()=>k.mutate(e.key),title:"Delete this instance's verdict",children:"Remove"})})})]},e.key))]})]})}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 p-3 border-t border-[--border]/50 text-xs text-[--muted]",children:[(0,r.jsxs)("span",{className:"tabular-nums",children:["Showing"," ",(e.page-1)*e.pageSize+ +(e.entries.length>0),"–",Math.min(e.page*e.pageSize,e.total)," of"," ",e.total]}),R>1&&(0,r.jsxs)(ic,{children:[(0,r.jsx)(im,{direction:"previous",isDisabled:p<=1,onClick:()=>h(e=>Math.max(1,e-1))}),ih(p,R).map((e,t)=>"…"===e?(0,r.jsx)(ip,{},`e${t}`):(0,r.jsx)(iu,{value:e,"data-selected":e===p,onClick:()=>h(e)},e)),(0,r.jsx)(im,{direction:"next",isDisabled:p>=R,onClick:()=>h(e=>Math.min(R,e+1))})]})]})]})}),v&&(0,r.jsx)(ty,{open:!0,onOpenChange:e=>!e&&y(void 0),title:"Backbone scope",description:v.key,children:(0,r.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs uppercase text-[--muted] mb-1",children:"Backbones"}),(0,r.jsx)("div",{children:v.backbones.join(", ")||"everywhere"})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("div",{className:"text-xs uppercase text-[--muted]",children:"As recorded per source"}),v.sources.map(e=>(0,r.jsxs)("div",{className:"text-xs",children:[(0,r.jsx)("span",{className:"font-medium",children:e.name})," ",(0,r.jsxs)("span",{className:"text-[--muted]",children:["(",e.verdict,", seen ",e.n,"\xd7)"]}),(0,r.jsx)("div",{className:"font-mono text-[--muted]",children:e.backbones.join(", ")||"no scope (applies everywhere)"})]},e.id))]})]})}),(0,r.jsx)(ig,{open:g,onOpenChange:f,invalidate:s}),(0,r.jsx)(tk,{...C})]})}function ig(e){let{open:t,onOpenChange:s,invalidate:a}=e,[l,i]=n.useState(""),[o,d]=n.useState("dead"),c=(0,eE.n)({mutationFn:()=>ei("POST /dashboard/blocklist/mark",{body:{releases:[[l.trim()]],verdict:o}}),onSuccess:()=>{x.oR.success("Release marked"),s(!1),i(""),a()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Mark failed")});return(0,r.jsx)(ty,{open:t,onOpenChange:s,title:"Mark a release",description:"Add a verdict to this instance's own list. Torrents are keyed btih:<infohash>, usenet releases wd1:<fingerprint> or nh1:<nzb content hash>.",children:(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(W,{label:"Release key",placeholder:"btih:… or wd1:…",value:l,onValueChange:i}),(0,r.jsx)(rn,{label:"Verdict",options:l0.map(e=>({label:e,value:e})),value:o,onValueChange:e=>d(e)}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(w,{intent:"gray-outline",onClick:()=>s(!1),children:"Cancel"}),(0,r.jsx)(w,{intent:"primary",loading:c.isPending,disabled:!l.trim(),onClick:()=>c.mutate(),children:"Mark"})]})]})})}ip.displayName="PaginationEllipsis";let ib={local:"Own verdicts",all:"Every source"};function iv(e){rm(e,{onSuccess:()=>x.oR.success("Copied to clipboard"),onError:()=>x.oR.error("Failed to copy")})}function iy(e){let{target:t}=e;return t.error?(0,r.jsx)(U,{className:"w-96",align:"start",trigger:(0,r.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1 text-xs text-red-500 hover:underline underline-offset-2",children:["Push failed",(0,r.jsx)(tC.wfp,{className:"h-3.5 w-3.5"})]}),children:(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-sm font-medium",children:"Last push failed"}),(0,r.jsx)("div",{className:"text-xs text-[--muted]",children:l4(t.lastChecked)})]}),(0,r.jsx)(E,{size:"xs",intent:"gray-subtle",icon:(0,r.jsx)(tC.Xpf,{}),"aria-label":"Copy the error",onClick:()=>iv(t.error)})]}),(0,r.jsx)("p",{className:"max-h-48 overflow-y-auto whitespace-pre-wrap break-words text-xs text-[--muted]",children:t.error})]})}):(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:t.status??"—"})}function ij(e){let{title:t,description:s,files:a}
13=e,[l,i]=n.useState(!1),o=n.useMemo(()=>{let e;return e=e=>2*("native"!==e.format)+ +("local"!==e.scope),[...a].sort((t,s)=>e(t)-e(s))},[a]),d=o[0];if(!d)return(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:"—"});let c=o.length-1;return(0,r.jsxs)("div",{className:"space-y-1",children:[d.url?(0,r.jsxs)("button",{type:"button",className:"group flex items-center gap-1.5 text-xs font-mono max-w-[260px]",title:d.url,"aria-label":`Copy the URL for ${d.label}`,onClick:()=>iv(d.url),children:[(0,r.jsx)(tC.Xpf,{className:"h-3.5 w-3.5 shrink-0 text-[--muted] group-hover:text-[--brand]"}),(0,r.jsx)("span",{className:"truncate group-hover:text-[--brand]",children:d.label})]}):(0,r.jsx)("span",{className:"flex items-center gap-1.5 text-xs font-mono text-[--muted] max-w-[260px]",title:"The URL appears once the file has been pushed",children:(0,r.jsx)("span",{className:"truncate",children:d.label})}),c>0&&(0,r.jsxs)("button",{type:"button",className:"ml-5 text-xs text-[--muted] hover:text-[--foreground] hover:underline underline-offset-2",onClick:()=>i(!0),children:[c," more ",1===c?"file":"files"]}),l&&(0,r.jsx)(iw,{title:t,description:s,files:o,onClose:()=>i(!1)})]})}function iw(e){let{title:t,description:s,files:a,onClose:n}=e;return(0,r.jsx)(ty,{open:!0,onOpenChange:e=>!e&&n(),title:t,description:s,children:(0,r.jsx)("div",{className:"space-y-2 min-w-0",children:a.map(e=>{let t;return(0,r.jsxs)("div",{className:"rounded-[--radius] border border-[--border]/60 bg-[--subtle]/30 p-3 space-y-1.5",children:[(0,r.jsx)("div",{className:"text-sm font-mono break-all",children:e.label}),(0,r.jsx)("div",{className:"text-xs text-[--muted]",children:(t=[ib[e.scope]],"warden"===e.format&&t.push("Warden format"),e.gzip&&t.push("gzip"),e.pushedAt&&t.push(`pushed ${l4(e.pushedAt)}`),t.join(" \xb7 "))}),e.url?(0,r.jsxs)("div",{className:"flex items-start gap-1",children:[(0,r.jsx)("span",{className:"flex-1 min-w-0 break-all text-xs font-mono text-[--muted]",title:e.url,children:e.url}),(0,r.jsx)(E,{size:"xs",intent:"gray-subtle",icon:(0,r.jsx)(tC.Xpf,{}),"aria-label":`Copy the URL for ${e.label}`,onClick:()=>iv(e.url)})]}):(0,r.jsx)("div",{className:"text-xs text-[--muted]",children:"The URL appears once the file has been pushed."})]},e.key)})})})}function iN(e){let{snapshot:t,invalidate:s}=e,[a,l]=n.useState(!1),[i,o]=n.useState(!1),[d,c]=n.useState(),[u,m]=n.useState(),p=(0,eE.n)({mutationFn:e=>ei(`PATCH /dashboard/blocklist/targets/${e.id}`,{body:e.body}),onSuccess:s,onError:e=>x.oR.error((null==e?void 0:e.message)??"Update failed")}),h=(0,eE.n)({mutationFn:e=>ei(`POST /dashboard/blocklist/targets/${e}/publish`,{body:{}}),onSuccess:(e,t)=>{let a=e.targets.find(e=>e.id===t);(null==a?void 0:a.error)?x.oR.error(a.error):x.oR.success((null==a?void 0:a.status)??"Pushed"),s()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Push failed")}),g=(0,eE.n)({mutationFn:e=>ei(`DELETE /dashboard/blocklist/targets/${e}`),onSuccess:()=>{x.oR.success("Target removed"),s()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Delete failed")}),f=tN({title:"Remove publish target",description:"This stops pushing to this destination. Files already uploaded there are not deleted.",actionText:"Remove",actionIntent:"alert-subtle",onConfirm:()=>u&&g.mutate(u.id)});return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex gap-2 flex-wrap items-center",children:[(0,r.jsx)(w,{size:"sm",intent:"primary-subtle",leftIcon:(0,r.jsx)(tC.Ca6,{}),onClick:()=>{c(void 0),l(!0)},children:"Add target"}),(0,r.jsx)("p",{className:"text-xs text-[--muted]",children:"Push this instance's blocklist to remote destinations so others can subscribe without reaching your instance."})]}),(0,r.jsx)(X,{className:"p-0 overflow-hidden",children:(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{className:"text-[--muted] text-xs uppercase bg-[--subtle]/40",children:(0,r.jsxs)("tr",{className:"text-left",children:[(0,r.jsx)("th",{className:"p-3",children:"Name"}),(0,r.jsx)("th",{className:"p-3",children:"Provider"}),(0,r.jsx)("th",{className:"p-3",children:"Files"}),(0,r.jsx)("th",{className:"p-3",children:"Interval"}),(0,r.jsx)("th",{className:"p-3",children:"Last push"}),(0,r.jsx)("th",{className:"p-3",children:"Status"}),(0,r.jsx)("th",{className:"p-3",children:"Enabled"}),(0,r.jsx)("th",{className:"p-3 text-right",children:"Actions"})]})}
13),(0,r.jsxs)("tbody",{children:[(0,r.jsx)(iS,{snapshot:t,invalidate:s,onEdit:()=>o(!0)}),t.targets.map(e=>{var t;let s;return(0,r.jsxs)("tr",{className:"border-t border-[--border]/50 hover:bg-[--subtle]/30",children:[(0,r.jsxs)("td",{className:"p-3 font-medium",children:[e.name,e.configUnreadable&&(0,r.jsx)("div",{className:"text-xs text-red-500",children:"config unreadable — re-enter it"})]}),(0,r.jsxs)("td",{className:"p-3",children:[(0,r.jsx)(l5,{className:"bg-sky-500/10 text-sky-500 border-sky-500/20",children:e.providerLabel}),(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(s=(t=e).summary)&&"github-gist"===t.provider?s.gistId?`gist ${s.gistId}`:"creates a gist on first push":""})]}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsx)(ij,{title:`Files pushed to "${e.name}"`,description:"Hand these URLs to anyone who wants to subscribe to this list.",files:e.artifacts.map(e=>({key:`${e.format}:${e.scope}`,format:e.format,scope:e.scope,gzip:e.gzip,label:e.filename,url:e.url,pushedAt:e.pushedAt}))})}),(0,r.jsx)("td",{className:"p-3 tabular-nums",children:l9(e.intervalSeconds)}),(0,r.jsx)("td",{className:"p-3 text-xs text-[--muted] whitespace-nowrap",children:l4(e.lastPushed)}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsx)(iy,{target:e})}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsx)(rs,{value:e.enabled,onValueChange:t=>p.mutate({id:e.id,body:{enabled:t}})})}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsxs)("div",{className:"flex justify-end gap-1",children:[(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(tC.tAF,{}),"aria-label":"Push now",loading:h.isPending&&h.variables===e.id,onClick:()=>h.mutate(e.id)}),(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(tC.z$h,{}),"aria-label":"Edit target",onClick:()=>{c(e),l(!0)}}),(0,r.jsx)(E,{size:"sm",intent:"alert-subtle",icon:(0,r.jsx)(tC.id1,{}),"aria-label":"Remove target",onClick:()=>{m(e),f.open()}})]})})]},e.id)})]})]})})}),a&&(0,r.jsx)(iA,{providers:t.providers,target:d,onClose:()=>l(!1),invalidate:s}),i&&(0,r.jsx)(iC,{snapshot:t,onClose:()=>o(!1),invalidate:s}),(0,r.jsx)(tk,{...f})]})}function ik(e){return e?`Set by ${e}; change it in the environment.`:void 0}function iS(e){var t;let{snapshot:s,invalidate:a,onEdit:n}=e,{status:l}=e$(),i=(null==l||null==(t=l.settings)?void 0:t.baseUrl)||window.location.origin,{settings:o,publicExportEnv:d}=s,c=(0,eE.n)({mutationFn:e=>ei("PATCH /dashboard/blocklist/settings",{body:{publicExport:e}}),onSuccess:a,onError:e=>x.oR.error((null==e?void 0:e.message)??"Update failed")});return(0,r.jsxs)("tr",{className:"border-t border-[--border]/50 bg-[--subtle]/20",children:[(0,r.jsx)("td",{className:"p-3 font-medium",children:"This instance"}),(0,r.jsxs)("td",{className:"p-3",children:[(0,r.jsx)(l5,{className:"bg-emerald-500/10 text-emerald-500 border-emerald-500/20",children:"public export"}),(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:"served live, nothing is pushed"})]}),(0,r.jsx)("td",{className:"p-3",children:o.publicExport?(0,r.jsx)(ij,{title:"Files served by this instance",description:"Hand these URLs to anyone who wants to subscribe to this list.",files:function(e,t){let s=[];for(let a of"all"===e.publicExportScope?["local","all"]:["local"])for(let r of["native","warden"]){let n=new URLSearchParams;"all"===a&&n.set("scope","all"),"warden"===r&&n.set("format","warden");let l=new URLSearchParams(n);e.publicExportPassword&&l.set("key",e.publicExportPassword);let i=e=>{let t=e.toString();return t?`?${t}`:""};s.push({key:`${r}:${a}`,format:r,scope:a,gzip:!1,label:`/blocklist/export${i(n)}`,url:`${t}/blocklist/export${i(l)}`,pushedAt:null})}return s}(o,i)}):(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:"—"})}),(0,r.jsx)("td",{className:"p-3 tabular-nums",children:"—"}),(0,r.jsx)("td",{className:"p-3 text-xs text-[--muted]",children:"—"}),(0,r.jsx)("td",{className:"p-3 text-xs text-[--muted]",children:o.publicExport?"subscribers fetch it directly":"disabled"}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsx)("span",{title:ik(d.publicExport),children:(0,r.jsx)(rs,{value:o.publicExport,disabled:!!d.publicExport||c.isPending,onValueChange:e=>c.mutate(e)}
13)})}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsx)("div",{className:"flex justify-end gap-1",children:(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(tC.z$h,{}),"aria-label":"Edit the public export",onClick:n})})})]})}function iC(e){let{snapshot:t,onClose:s,invalidate:a}=e,{settings:l,publicExportEnv:i}=t,[o,d]=n.useState(l.publicExport),[c,u]=n.useState(l.publicExportScope),[m,p]=n.useState(l.publicExportPassword),h=(0,eE.n)({mutationFn:e=>ei("PATCH /dashboard/blocklist/settings",{body:e}),onSuccess:()=>{x.oR.success("Public export updated"),s(),a()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Save failed")});return(0,r.jsx)(ty,{open:!0,onOpenChange:e=>!e&&s(),title:"Public export",description:"Serve this instance's blocklist at /blocklist/export so others can subscribe to it directly.",children:(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(rs,{side:"right",label:"Serve the public export",value:o,disabled:!!i.publicExport,onValueChange:d,help:ik(i.publicExport)??"The list contains only release digests and backbone root domains."}),(0,r.jsx)(rn,{label:"Scope",options:[{label:"local (own verdicts)",value:"local"},{label:"all (every source)",value:"all"}],value:c,disabled:!!i.publicExportScope,onValueChange:e=>u(e),help:ik(i.publicExportScope)??"The most a subscriber may ask for. With local, only verdicts this instance recorded first-hand are ever served."}),(0,r.jsx)(W,{type:"password",label:"Password",autoComplete:"new-password",placeholder:"No password",value:m,disabled:!!i.publicExportPassword,onValueChange:p,help:ik(i.publicExportPassword)??"When set, subscribers must pass ?key=<value>. A missing or wrong key gets the same 404 as a disabled export, so the endpoint stays invisible."}),"all"===c&&(0,r.jsx)(nU,{intent:"warning",children:'Serving the "all" scope rebroadcasts lists you subscribe to: one upstream verdict can then look independently corroborated to anyone consuming both lists. Prefer "local" unless you are deliberately aggregating.'}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(w,{intent:"gray-outline",onClick:s,children:"Cancel"}),(0,r.jsx)(w,{intent:"primary",loading:h.isPending,onClick:()=>{let e={};if(i.publicExport||o===l.publicExport||(e.publicExport=o),i.publicExportScope||c===l.publicExportScope||(e.publicExportScope=c),i.publicExportPassword||m===l.publicExportPassword||(e.publicExportPassword=m),0===Object.keys(e).length)return s();h.mutate(e)},children:"Save"})]})]})})}function i_(e,t,s){let a={};for(let r of e)if("switch"===r.type){let e=s?t[r.key]:void 0;a[r.key]=!!(e??r.default)}else if(r.secret)a[r.key]="";else{let e=s?t[r.key]:void 0;a[r.key]=null!=e?String(e):String(r.default??"")}return a}function iR(e){let{field:t,value:s,editing:a,onChange:n}=e,l=a&&t.editHelp||t.help,i=a&&t.editPlaceholder||t.placeholder;return"switch"===t.type?(0,r.jsx)(rs,{side:"right",label:t.label,value:!!s,onValueChange:n,help:l}):"select"===t.type?(0,r.jsx)(rn,{label:t.label,options:t.options??[],value:String(s),onValueChange:n,help:l}):"textarea"===t.type?(0,r.jsx)(np,{label:t.label,rows:3,placeholder:i,value:String(s),onValueChange:n,help:l}):(0,r.jsx)(W,{type:"password"===t.type?"password":"text",label:t.label,placeholder:i,value:String(s),onValueChange:n,help:l})}function iA(e){var t;let{providers:s,target:a,onClose:l,invalidate:i}=e,o=!!a,d=(null==a?void 0:a.summary)??{},[c,u]=n.useState((null==a?void 0:a.provider)??(null==(t=s[0])?void 0:t.id)??"github-gist"),m=s.find(e=>e.id===c),[p,h]=n.useState((null==a?void 0:a.name)??""),[g,f]=n.useState(a?Math.max(1,Math.round(a.intervalSeconds/3600)):6),[b,v]=n.useState(a?a.artifacts.map(e=>({format:e.format,scope:e.scope,gzip:e.gzip})):[{format:"native",scope:"local",gzip:!!(null==m?void 0:m.capabilities.binary)}]),[y,j]=n.useState(()=>i_((null==m?void 0:m.fields)??[],d,o)),N=(0,eE.n)({mutationFn:()=>{let e={name:p.trim(),intervalSeconds:Math.round(3600*g),artifacts:b.map(e=>({format:e.format,scope:e.scope,gzip:null!=m&&!!m.capabilities.binary&&e.gzip})),config:(()=>{let e={};for(let t of(null==m?void 0:m.fields)??[]){let s=y[t.key];if("switch"===t.type){e[t.key]=!!s;continue}let a=String(s??"").trim();t.secret?a&&(e[t.key]=a):e[t.key]=a}return e})()};return o?ei(`PATCH /dashboard/blocklist/targets/${a.id}`,{body:e}):ei("POST /dashboard/blocklist/targets",{body:{...e,provider:c}})},onSuccess:()=>
13{x.oR.success(o?"Target updated":"Target added"),l(),i()},onError:e=>x.oR.error((null==e?void 0:e.message)??"Save failed")}),k=b.some(e=>"all"===e.scope);return(0,r.jsx)(ty,{open:!0,onOpenChange:e=>!e&&l(),title:o?`Edit "${a.name}"`:"Add publish target",children:(0,r.jsxs)("div",{className:"space-y-3",children:[!o&&(0,r.jsx)(rn,{label:"Provider",options:s.map(e=>({label:e.label,value:e.id})),value:c,onValueChange:e=>{let t=s.find(t=>t.id===e);u(e),j(i_((null==t?void 0:t.fields)??[],{},!1)),v(e=>e.map(e=>({...e,gzip:!!(null==t?void 0:t.capabilities.binary)&&e.gzip})))}}),(0,r.jsx)(W,{label:"Name",value:p,onValueChange:h}),(0,r.jsx)(nn,{label:"Push interval (hours)",value:g,min:1,max:720,onValueChange:e=>f(e||6)}),((null==m?void 0:m.fields)??[]).map(e=>(0,r.jsx)(iR,{field:e,value:y[e.key]??("switch"!==e.type&&""),editing:o,onChange:t=>j(s=>({...s,[e.key]:t}))},`${c}:${e.key}`)),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"text-xs font-medium text-[--muted] ml-1",children:"Files to push"}),b.map((e,t)=>(0,r.jsxs)("div",{className:"rounded-[--radius] border border-[--border]/60 bg-[--subtle]/30 p-3 space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-xs font-mono text-[--muted]",children:`blocklist-${e.scope}${"warden"===e.format?"-warden":""}.ndjson${e.gzip?".gz":""}`}),b.length>1&&(0,r.jsx)(E,{size:"xs",rounded:!0,intent:"alert-subtle",icon:(0,r.jsx)(tC.id1,{}),"aria-label":"Remove file",onClick:()=>v(e=>e.filter((e,s)=>s!==t))})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsx)(rn,{label:"Format",options:[{label:"native",value:"native"},{label:"warden",value:"warden"}],value:e.format,onValueChange:e=>v(s=>s.map((s,a)=>a===t?{...s,format:e}:s))}),(0,r.jsx)(rn,{label:"Scope",options:[{label:"local (own verdicts)",value:"local"},{label:"all (every source)",value:"all"}],value:e.scope,onValueChange:e=>v(s=>s.map((s,a)=>a===t?{...s,scope:e}:s))})]}),(null==m?void 0:m.capabilities.binary)&&(0,r.jsx)(rs,{side:"right",label:"Compress (gzip)",value:e.gzip,onValueChange:e=>v(s=>s.map((s,a)=>a===t?{...s,gzip:e}:s))})]},t)),b.length<4&&(0,r.jsx)("div",{className:"flex justify-center",children:(0,r.jsx)(E,{size:"sm",rounded:!0,intent:"primary-subtle",icon:(0,r.jsx)(tC.Ca6,{}),"aria-label":"Add file",onClick:()=>v(e=>[...e,{format:"warden",scope:"local",gzip:!!(null==m?void 0:m.capabilities.binary)}])})}),k&&(0,r.jsx)(nU,{intent:"warning",children:'Publishing the "all" scope rebroadcasts lists you subscribe to: one upstream verdict can then look independently corroborated to anyone consuming both lists. Prefer "local" unless you are deliberately aggregating.'})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(w,{intent:"gray-outline",onClick:l,children:"Cancel"}),(0,r.jsx)(w,{intent:"primary",loading:N.isPending,onClick:()=>{if(!p.trim())return x.oR.error("a name is required");if(new Set(b.map(e=>`${e.format}:${e.scope}`)).size!==b.length)return x.oR.error("duplicate format/scope file");for(let e of(null==m?void 0:m.fields)??[]){let t=y[e.key];if(e.required&&"switch"!==e.type&&!String(t??"").trim()&&!(o&&e.secret))return x.oR.error(`${e.label} is required`)}N.mutate()},children:o?"Save":"Add target"})]})]})})}var iT=s(3017),iI=s(4422),iE=s(8390),iM=s(883);function iP(e){let{value:t,format:s,durationSec:a=.35,ease:l="easeOut"}=e,i=(0,iT.I)(),o=(0,iI.d)(t),d=(0,iE.G)(o,s),c=n.useRef(!1);return n.useEffect(()=>{let e=o.get(),s=Math.max(Math.abs(e),Math.abs(t)),r=s>0&&Math.abs(t-e)/s>.5;if(!c.current||i||r){c.current=!0,o.set(t);return}let n=(0,iM.i)(o,t,{duration:a,ease:l});return()=>n.stop()},[t,a,l,i,o]),(0,r.jsx)(th.P.span,{children:d})}let iD=["dashboard","streams"],iL=[...iD,"live"],iU=[...iD,"bans"];function i$(e){return(null==e?void 0:e.tickMs)??500}let iO=null,iF=0;function iz(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],t=(0,o.jE)();return n.useEffect(()=>{if(e)return iF++,iO||((iO=new EventSource("/api/v1/dashboard/streams/live/stream",{withCredentials:!0})).onmessage=e=>{try{t.setQueryData(iL,JSON.parse(e.data))}catch{}}),()=>{--iF>0||(null==iO||iO.close(),iO=null)}},[t,e]),(0,eU.I)({queryKey:iL,queryFn:()=>ei("/dashboard/streams/live"),staleTime:1/0,enabled:e})}function iV(){let e=(0,o.jE)();return(0,eE.n)({mutationFn:e=>ei("POST /dashboard/streams/bans",{body:e}),onSuccess:()=>
13{e.invalidateQueries({queryKey:iU}),e.invalidateQueries({queryKey:iL})}})}let iq="aiostreams.proxy.generated",iB=rL.Ik({url:rL.Yj(),filename:rL.bz(),requestHeaders:rL.bz(),responseHeaders:rL.bz(),type:rL.bz(),encrypt:rL.bz()});function iK(e){rm(e,{onSuccess:()=>x.oR.success("Copied to clipboard"),onError:()=>x.oR.error("Failed to copy to clipboard")})}function iH(){let[e,t]=n.useState(!1),[s,a]=n.useState(null),l=(0,eE.n)({mutationFn:async e=>{let t=await fetch("/api/v1/proxy/generate",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json().catch(()=>({}));if(!t.ok){var a;throw Error((null==s||null==(a=s.error)?void 0:a.message)??(null==s?void 0:s.detail)??`Request failed (${t.status})`)}return s}}),[i,o]=n.useState(()=>{try{return JSON.parse(localStorage.getItem(iq)||"[]")}catch{return[]}});return(0,r.jsxs)(ty,{open:e,onOpenChange:e=>{t(e),e||a(null)},title:"Generate proxy link",trigger:(0,r.jsx)(w,{intent:"primary-subtle",size:"sm",leftIcon:(0,r.jsx)(tC.Jty,{}),children:"Generate proxy link"}),children:[(0,r.jsx)(rJ,{schema:iB,defaultValues:{url:"",filename:"",requestHeaders:{},responseHeaders:{},type:"stream",encrypt:!0},onSubmit:async e=>{var t;if(!(null==(t=e.url)?void 0:t.trim()))return void x.oR.error("URL is required");try{let t=await l.mutateAsync({url:e.url.trim(),filename:e.filename||void 0,requestHeaders:Object.keys(e.requestHeaders||{}).length?e.requestHeaders:void 0,responseHeaders:Object.keys(e.responseHeaders||{}).length?e.responseHeaders:void 0,type:e.type||"stream",encrypt:!1!==e.encrypt});a(t.proxified_url);let s=[t.proxified_url,...i].slice(0,20);o(s),localStorage.setItem(iq,JSON.stringify(s))}catch(e){x.oR.error((null==e?void 0:e.message)??"Failed to generate")}},children:()=>(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(nA.Text,{name:"url",label:"URL",placeholder:"https://…"}),(0,r.jsx)(nA.Text,{name:"filename",label:"Filename (optional)"}),(0,r.jsx)(nK,{name:"requestHeaders",label:"Request headers",valueKind:"string"}),(0,r.jsx)(nK,{name:"responseHeaders",label:"Response headers",valueKind:"string"}),(0,r.jsx)(nA.Select,{name:"type",label:"Type",options:[{label:"Stream",value:"stream"},{label:"NZB",value:"nzb"}]}),(0,r.jsx)(nA.Switch,{name:"encrypt",label:"Encrypt payload",side:"right"}),(0,r.jsx)(nA.Submit,{loading:l.isPending,children:"Generate"})]})}),s&&(0,r.jsxs)("div",{className:"mt-4 flex items-center gap-2 rounded-lg bg-[--subtle] p-3",children:[(0,r.jsx)("code",{className:"flex-1 break-all text-xs",children:s}),(0,r.jsx)(w,{size:"sm",intent:"gray-outline",leftIcon:(0,r.jsx)(tC.Xpf,{}),onClick:()=>iK(s),children:"Copy"})]}),i.length>0&&(0,r.jsxs)("div",{className:"mt-4",children:[(0,r.jsx)("p",{className:"mb-1 text-xs text-[--muted]",children:"Recent (this browser)"}),(0,r.jsx)("ul",{className:"max-h-40 space-y-1 overflow-auto",children:i.map((e,t)=>(0,r.jsxs)("li",{className:"flex items-center gap-2",children:[(0,r.jsx)("code",{className:"flex-1 break-all text-[10px] text-[--muted]",children:e}),(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(tC.Xpf,{}),"aria-label":"Copy link",onClick:()=>iK(e)})]},t))})]})]})}let iG={usenet:{label:"Usenet",icon:tC.hQe,className:"border-indigo-500/40 bg-indigo-500/10 text-indigo-300"},proxy:{label:"Proxy",icon:tC.IS1,className:"border-teal-500/40 bg-teal-500/10 text-teal-300"}};function iW(e){let{transport:t,className:s}=e,a=iG[t]??iG.proxy,n=a.icon;return(0,r.jsxs)("span",{className:b("inline-flex shrink-0 items-center gap-1 rounded-md border px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide",a.className,s),children:[(0,r.jsx)(n,{className:"text-xs"}),a.label]})}let iY="inline-flex shrink-0 items-center gap-1 rounded-md border border-[--border] px-1.5 py-0.5 text-[10px] font-medium text-[--muted]";function iJ(e){let{children:t,className:s}=e;return(0,r.jsx)("span",{className:b(iY,s),children:t})}function iZ(e){let{reads:t}=e;return(0,r.jsxs)(to,{trigger:(0,r.jsxs)(iJ,{className:"border-amber-500/40 bg-amber-500/10 text-amber-300",children:[(0,r.jsx)(tC.P$d,{}),t]}),children:[t," range requests open at once — a player normally holds one."]})}function iQ(e){let{ip:t}=e,[s,a]=n.useState(!1),l=function(e){if(e.endsWith(".x")||e.endsWith("::/48"))return e;let t=e.replace(/^::ffff:/i,"");if(t.includes(".")){let e=t.split(".");return 4===e.length?`${e[0]}.•••.•.•`:"•••"}
13if(t.includes(":")){let e=t.split(":").filter(Boolean)[0];return e?`${e}:•••`:"•••"}return"•••"}(t);if(l===t)return(0,r.jsx)(iJ,{className:"font-mono",children:t});let i=s?"Hide client IP":"Reveal client IP";return(0,r.jsx)("button",{type:"button",onClick:()=>a(e=>!e),"aria-label":i,"aria-pressed":s,title:i,className:b(iY,"font-mono transition-colors hover:border-[--muted] hover:text-[--foreground]"),children:s?t:l})}function iX(e){let{value:t,onChange:s,options:a,className:n}=e;return(0,r.jsx)("div",{role:"tablist",className:b("inline-flex items-center gap-0.5 rounded-lg border border-[--border] bg-[--subtle]/50 p-0.5",n),children:a.map(e=>{let a=e.value===t;return(0,r.jsx)("button",{role:"tab","aria-selected":a,onClick:()=>s(e.value),className:b("rounded-[6px] px-2.5 py-1 text-xs font-medium transition-colors",a?"bg-[--paper] text-[--foreground] shadow-sm":"text-[--muted] hover:text-[--foreground]"),children:e.label},e.value)})})}function i0(e){return e||"unidentified"}function i1(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now(),s=Math.max(0,Math.round((t-e)/1e3));return s<60?`${s}s ago`:s<3600?`${Math.round(s/60)}m ago`:s<86400?`${Math.round(s/3600)}h ago`:`${Math.round(s/86400)}d ago`}let i2=[{label:"15 minutes",ms:9e5},{label:"1 hour",ms:36e5},{label:"24 hours",ms:864e5},{label:"7 days",ms:6048e5},{label:"Until lifted"}];function i3(e){return e.filename||e.displayUrl||e.targetKey}function i6(e){let t,s,{stream:a,now:n,frameMs:l,onBlock:i}=e,d=a.size?Math.min(1,Math.max(0,(a.start+a.currentBytes)/a.size)):0,c="streaming"===a.activity,u=(t=(0,o.jE)(),(0,eE.n)({mutationFn:e=>ei(`DELETE /dashboard/streams/sessions/${encodeURIComponent(e)}`),onSuccess:()=>t.invalidateQueries({queryKey:iL})})),m=(s=(0,o.jE)(),(0,eE.n)({mutationFn:e=>ei(`POST /dashboard/streams/users/${encodeURIComponent(e)}/kill`),onSuccess:()=>s.invalidateQueries({queryKey:iL})})),p=!!a.username,h=(e,t)=>e.then(()=>x.oR.success(t)).catch(e=>x.oR.error((null==e?void 0:e.message)??"Action failed")),g=tN({title:"Stop this stream",description:(0,r.jsxs)(r.Fragment,{children:["End ",(0,r.jsx)("span",{className:"break-all",children:i3(a)})," for"," ",i0(a.username),". Their player will drop, and nothing prevents it reconnecting — use a block for that."]}),actionText:"Stop",actionIntent:"alert-subtle",onConfirm:()=>void h(u.mutateAsync(a.id),"Stream stopped")}),f=tN({title:`Stop all streams for ${i0(a.username)}`,description:"End every stream this user currently has open, across the proxy and the usenet engine. They can start new ones immediately unless you also block them.",actionText:"Stop all",actionIntent:"alert-subtle",onConfirm:()=>void h(m.mutateAsync(a.username),"Stopped all their streams")});return(0,r.jsxs)("div",{className:"space-y-1.5 rounded-lg border border-[--border] bg-[--paper] p-3",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1.5",children:[(0,r.jsx)(iW,{transport:a.transport}),a.activeReads>1&&(0,r.jsx)(iZ,{reads:a.activeReads}),(0,r.jsx)("span",{className:"order-last w-full min-w-0 truncate text-sm font-medium sm:order-none sm:w-auto sm:flex-1",title:i3(a),children:i3(a)}),(0,r.jsx)("span",{className:"ml-auto shrink-0 text-xs tabular-nums text-[--muted]",children:c?(0,r.jsx)(iP,{value:a.bytesPerSec,format:rg,durationSec:l/1e3}):(0,r.jsxs)("span",{className:"inline-flex items-center gap-1",title:`No bytes for ${rk(a.idleMs)}`,children:[(0,r.jsx)(tC._5G,{}),"paused"===a.activity?"paused":"idle"]})}),(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"sm",intent:"alert-subtle",icon:(0,r.jsx)(tC._6i,{}),"aria-label":"Stop stream",disabled:u.isPending,onClick:g.open}),children:"Stop this stream"}),(0,r.jsxs)(lt,{align:"end",trigger:(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(tC.voe,{}),"aria-label":"More actions"}),children:[(0,r.jsx)(la,{children:p?i0(a.username):"Unidentified stream"}),(0,r.jsxs)(ls,{disabled:!p,onSelect:()=>i({scope:"target",username:a.username,targetKey:a.targetKey,label:i3(a)}),children:[(0,r.jsx)(tC.PLI,{}),"Block this title…"]}),(0,r.jsx)(lr,{}),(0,r.jsxs)(ls,{disabled:!p||m.isPending,onSelect:f.open,children:[(0,r.jsx)(tC._6i,{}),"Stop all their streams"]}
13),(0,r.jsxs)(ls,{disabled:!p,onSelect:()=>i({scope:"user",username:a.username}),children:[(0,r.jsx)(tC.Jg2,{}),"Block this user…"]})]})]}),(0,r.jsx)("div",{className:"h-1.5 w-full overflow-hidden rounded-full bg-[--subtle]",children:(0,r.jsx)("div",{className:b("h-full bg-brand transition-[width] ease-linear motion-reduce:transition-none",c&&"animate-pulse"),style:{width:`${100*d}%`,transitionDuration:`${l}ms`}})}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs tabular-nums text-[--muted]",children:[(0,r.jsx)(iJ,{children:i0(a.username)}),a.clientIp&&(0,r.jsx)(iQ,{ip:a.clientIp}),a.size>0&&(0,r.jsx)("span",{children:(0,r.jsx)(iP,{value:100*d,format:e=>`${Math.round(e)}%`,durationSec:l/1e3,ease:"linear"})}),(0,r.jsxs)("span",{children:[(0,r.jsx)(iP,{value:a.bytesServed,format:rx,durationSec:l/1e3,ease:"linear"}),a.size>0?` of ${rx(a.size)}`:""," served"]}),(0,r.jsxs)("span",{children:[a.requests," request",1===a.requests?"":"s"]}),(0,r.jsxs)("span",{children:[rk(n-a.startedAt)," elapsed"]})]}),(0,r.jsx)(tk,{...g}),(0,r.jsx)(tk,{...f})]})}function i5(e){let{target:t,onClose:s}=e,a=iV(),[l,i]=n.useState("0"),[o,d]=n.useState("");if(n.useEffect(()=>{t&&(i("0"),d(""))},[t]),!t)return null;let c="user"===t.scope,u=async()=>{try{var e;let r=await a.mutateAsync({scope:t.scope,username:t.username,targetKey:t.targetKey,reason:o.trim()||void 0,durationMs:null==(e=i2[Number(l)])?void 0:e.ms});x.oR.success(r.stopped>0?`Blocked — stopped ${r.stopped} stream${1===r.stopped?"":"s"}`:"Blocked"),s()}catch(e){x.oR.error((null==e?void 0:e.message)??"Failed to block")}};return(0,r.jsx)(ty,{open:!0,onOpenChange:e=>!e&&s(),title:c?`Block ${t.username}`:"Block this stream",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:c?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-[--foreground]",children:t.username})," ","will not be able to start any stream, and everything they have open now will be stopped."]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-[--foreground]",children:t.username})," ","will not be able to reopen"," ",(0,r.jsx)("span",{className:"break-all text-[--foreground]",children:t.label||"this title"}),". Their other streams keep working."]})}),(0,r.jsx)(F,{label:"Duration",children:(0,r.jsx)(rn,{value:l,onValueChange:i,options:i2.map((e,t)=>({label:e.label,value:String(t)}))})}),(0,r.jsx)(F,{label:"Reason (optional)",children:(0,r.jsx)(W,{value:o,onValueChange:d,placeholder:"Shown on the Blocks list"})}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(w,{intent:"gray-outline",size:"sm",onClick:s,children:"Cancel"}),(0,r.jsx)(w,{intent:"alert",size:"sm",loading:a.isPending,onClick:u,children:"Block"})]})]})})}let i4={idle:{label:"Finished"},stopped:{label:"Stopped",className:"border-orange-500/40 bg-orange-500/10 text-orange-300"},banned:{label:"Blocked",className:"border-red-500/40 bg-red-500/10 text-red-300"},limit:{label:"Limit reached",className:"border-red-500/40 bg-red-500/10 text-red-300"},error:{label:"Error",className:"border-red-500/40 bg-red-500/10 text-red-300"},stale:{label:"Interrupted",className:"border-amber-500/40 bg-amber-500/10 text-amber-300"}},i9=[{label:"All types",value:"all"},{label:"Usenet",value:"usenet"},{label:"Proxy",value:"proxy"}],i8=[{value:"total",label:"Total"},{value:"user",label:"By user"}],i7=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",timeZone:"UTC"}),oe=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeZone:"UTC"}),ot=new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"});function os(e){let{used:t,limit:s}=e;if(s<=0)return(0,r.jsx)("span",{className:"tabular-nums",children:rx(t)});let a=Math.min(1,t/s);return(0,r.jsxs)("div",{className:"flex min-w-[160px] items-center gap-2",children:[(0,r.jsx)("div",{className:"h-1.5 flex-1 overflow-hidden rounded-full bg-[--subtle]",children:(0,r.jsx)("div",{className:b("h-full",a>=1?"bg-red-500":a>=.85?"bg-amber-500":"bg-brand"),style:{width:`${100*a}%`}})}),(0,r.jsxs)("span",{className:"shrink-0 text-xs tabular-nums text-[--muted]",children:[rx(t)," / ",rx(s)]})]})}function oa(){let[e,t]=n.useState(!1),[s,a]=n.useState(""),[l,i]=n.useState("0"),[o,d]=n.useState(""),c=iV(),u=async()=>
13{if(!s.trim())return void x.oR.error("Username is required");try{var e;await c.mutateAsync({scope:"user",username:s.trim(),reason:o.trim()||void 0,durationMs:null==(e=i2[Number(l)])?void 0:e.ms}),x.oR.success("Blocked"),t(!1),a(""),d("")}catch(e){x.oR.error((null==e?void 0:e.message)??"Failed to block")}};return(0,r.jsx)(ty,{open:e,onOpenChange:t,title:"Block a user",trigger:(0,r.jsx)(w,{intent:"alert-subtle",size:"sm",leftIcon:(0,r.jsx)(tC.Ca6,{}),children:"Block a user"}),children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(F,{label:"Username",help:"Must match a username in AIOSTREAMS_AUTH.",children:(0,r.jsx)(W,{value:s,onValueChange:a,placeholder:"alice"})}),(0,r.jsx)(F,{label:"Duration",children:(0,r.jsx)(rn,{value:l,onValueChange:i,options:i2.map((e,t)=>({label:e.label,value:String(t)}))})}),(0,r.jsx)(F,{label:"Reason (optional)",children:(0,r.jsx)(W,{value:o,onValueChange:d})}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(w,{intent:"gray-outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),(0,r.jsx)(w,{intent:"alert",size:"sm",loading:c.isPending,onClick:u,children:"Block"})]})]})})}function or(e){if(e.name)return e.name;let t=e.path??"",s=t.lastIndexOf("/");return -1===s?t:t.slice(s+1)}function on(e){var t;let{hash:s,name:a,open:n,onOpenChange:l}=e,i=(t=n?s:null,(0,eU.I)({queryKey:[...aB,"library","files",t],enabled:!!t,queryFn:()=>ei(`/dashboard/usenet/library/${encodeURIComponent(t)}/files`)})),o=aJ(),d=e=>e.path??(null!=e.index?String(e.index):e.name),c=(e,t)=>{s&&o.mutateAsync({hash:s,fileSel:d(e),download:t}).then(e=>window.open(e.url,"_blank")).catch(e=>x.oR.error((null==e?void 0:e.message)??"No playable source"))},u=i.data?function(e){let t={};for(let s of e){let e=s.path??s.name??"",a=e.lastIndexOf("/"),r=-1===a?"":e.slice(0,a);(t[r]||(t[r]=[])).push(s)}return t}(i.data.files):{},m=Object.keys(u).sort();return(0,r.jsx)(ty,{open:n,onOpenChange:l,title:a||"Browse NZB",description:"Files in this NZB (including stored archive contents).",contentClass:"max-w-4xl",children:(0,r.jsx)("div",{className:"max-h-[72vh] overflow-y-auto space-y-4",children:i.isLoading?(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"Loading…"}):i.isError?(0,r.jsx)("p",{className:"text-sm text-red-500",children:"Failed to load files."}):0===m.length?(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"No files."}):m.map(e=>{var t;let a;return(0,r.jsxs)("div",{children:[e&&(0,r.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-[--muted] mb-1",children:[(0,r.jsx)(tC.gNt,{})," ",e]}),(0,r.jsx)("div",{className:"space-y-1",children:(t=u[e],a=e=>+("video"!==e.category),[...t].sort((e,t)=>a(e)-a(t)||(e.category??"").localeCompare(t.category??"")||or(e).localeCompare(or(t)))).map((t,a)=>{let n=!1!==t.streamable;return(0,r.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-[--border]/60 px-2.5 py-1.5",children:[(0,r.jsx)(tC.MG2,{className:"text-[--muted] shrink-0"}),(0,r.jsx)("span",{className:"flex-1 text-sm break-all",children:or(t)}),t.category&&(0,r.jsx)("span",{className:"text-xs text-[--muted] shrink-0",children:t.category}),(0,r.jsx)("span",{className:"text-xs tabular-nums text-[--muted] w-20 text-right shrink-0",children:rx(t.size)}),(0,r.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"sm",intent:"primary-subtle",icon:(0,r.jsx)(tC.UIR,{}),"aria-label":"Preview",disabled:!n,className:b(!n&&"opacity-40"),onClick:()=>c(t,!1)}),children:n?"Preview":"Not individually streamable"}),(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(tC.Ah9,{}),"aria-label":"Download",disabled:!n,className:b(!n&&"opacity-40"),onClick:()=>c(t,!0)}),children:n?"Download":"Not individually streamable"}),(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(tC.o9J,{}),"aria-label":"Copy download link",disabled:!n,className:b(!n&&"opacity-40"),onClick:()=>{s&&o.mutateAsync({hash:s,fileSel:d(t),download:!0}).then(e=>rm(window.location.origin+e.url,{onSuccess:()=>x.oR.success("Download link copied"),onError:()=>x.oR.error("Failed to copy link")})).catch(e=>x.oR.error((null==e?void 0:e.message)??"No downloadable source"))}}),children:"Copy download link"})]})]},`${e}-${a}`)})})]},e||"root")})})})}function ol(e,t){rm(e,{onSuccess:()=>x.oR.success(`${t} copied`),onError:()=>x.oR.error("Copy failed")})}function oi(e){let{label:t,value:s,onCopy:a,children:n}=e;return null!=s||n?(0,r.jsxs)("div",{className:"flex items-start gap-3 py-1.5 border-b border-[--border]/40 last:border-0",children:[(0,r.jsx)("span",{className:"w-28 shrink-0 text-xs font-medium text-[--muted] pt-0.5",children:t}),(0,r.jsxs)("div",{className:"min-w-0 flex-1 text-sm flex items-center gap-2",children:[n??(0,r.jsx)("span",{className:"break-all",children:s}),a&&(0,r.jsx)(E,{size:"xs",intent:"gray-subtle",icon:(0,r.jsx)(tC.Xpf,{}),"aria-label":`Copy ${t}`,className:"shrink-0 ml-auto",onClick:a})]})]}):null}function oo(e){let{label:t,secret:s}=e,[a,l]=n.useState(!1);return(0,r.jsxs)(oi,{label:t,children:[(0,r.jsx)("span",{className:"font-mono break-all",children:a?s:"•".repeat(Math.min(s.length,12))}),(0,r.jsx)(E,{size:"xs",intent:"gray-subtle",icon:a?(0,r.jsx)(tC.MXC,{}):(0,r.jsx)(tC.Nyy,{}),"aria-label":a?`Hide ${t}`:`Show ${t}`,className:"shrink-0 ml-auto",onClick:()=>l(e=>!e)}),(0,r.jsx)(E,{size:"xs",intent:"gray-subtle",icon:(0,r.jsx)(tC.Xpf,{}),"aria-label":`Copy ${t}`,className:"shrink-0",onClick:()=>ol(s,t)})]})}function od(e){let{url:t}=e;if(t.startsWith("local-nzb://"))return null;let s=t;try{s=new URL(t).hostname}catch{}
13return(0,r.jsxs)(oi,{label:"NZB URL",children:[(0,r.jsx)(to,{trigger:(0,r.jsx)("span",{className:"font-mono break-all cursor-default",children:s}),className:"max-w-md break-all",children:t}),(0,r.jsx)(E,{size:"xs",intent:"gray-subtle",icon:(0,r.jsx)(tC.Xpf,{}),"aria-label":"Copy NZB URL",className:"shrink-0 ml-auto",onClick:()=>ol(t,"NZB URL")})]})}let oc={wd1:"Portable release fingerprint based on indexer metadata (size, poster, date)",nh1:"Exact NZB content hash"};function ou(e){let{entry:t}=e,s=aq(t);return 0===s.length?null:(0,r.jsx)(oi,{label:1===s.length?"Release key":"Release keys",children:(0,r.jsx)("div",{className:"min-w-0 flex-1 flex flex-col gap-1",children:s.map(e=>(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(to,{side:"left",trigger:(0,r.jsx)("span",{className:"font-mono text-xs break-all cursor-default",children:e}),children:oc[e.split(":")[0]]??"Blocklist key"}),(0,r.jsx)(E,{size:"xs",intent:"gray-subtle",icon:(0,r.jsx)(tC.Xpf,{}),"aria-label":"Copy release key",className:"shrink-0 ml-auto",onClick:()=>ol(e,"Release key")})]},e))})})}function om(e){let{entry:t,open:s,onOpenChange:a}=e;return t?(0,r.jsx)(ty,{open:s,onOpenChange:a,title:"NZB details",contentClass:"max-w-lg",children:(0,r.jsxs)("div",{className:b("mt-1"),children:[(0,r.jsx)(oi,{label:"Name",value:t.name||t.nzbHash,onCopy:()=>ol(t.name||t.nzbHash,"Name")}),(0,r.jsx)(oi,{label:"Status",value:t.status}),"failed"===t.status&&t.failReason&&(0,r.jsx)(oi,{label:"Error",value:t.failReason}),(0,r.jsx)(oi,{label:"Size",value:rx(t.size)}),(0,r.jsx)(oi,{label:"Files",value:`${t.files.length} file${1===t.files.length?"":"s"}`}),(0,r.jsx)(oi,{label:"Source",value:t.source}),t.owner&&(0,r.jsx)(oi,{label:"Added by",value:t.owner}),(0,r.jsx)(oi,{label:"Added",value:rC(t.addedAt)}),(0,r.jsx)(oi,{label:"Last used",value:rC(t.lastUsedAt)}),null!=t.importMs&&(0,r.jsx)(oi,{label:"Import time",value:function(e){if(null==e||!Number.isFinite(e))return"—";if(e<1e3)return`${Math.round(e)} ms`;let t=e/1e3;return t<60?`${t.toFixed(1)} s`:`${Math.floor(t/60)}m ${Math.round(t%60)}s`}(t.importMs)}),t.password&&(0,r.jsx)(oo,{label:"Password",secret:t.password}),t.nzbUrl&&(0,r.jsx)(od,{url:t.nzbUrl}),(0,r.jsx)(oi,{label:"Hash",value:(0,r.jsx)("span",{className:"font-mono text-xs break-all",children:t.nzbHash}),onCopy:()=>ol(t.nzbHash,"Hash")}),(0,r.jsx)(ou,{entry:t})]})}):null}let op={queued:"bg-[--subtle] text-[--muted]",inspecting:"bg-amber-500/15 text-amber-500",available:"bg-emerald-500/15 text-emerald-500",degraded:"bg-orange-500/15 text-orange-500",failed:"bg-red-500/15 text-red-500"},oh=[{value:"all",label:"All statuses"},{value:"queued",label:"Queued"},{value:"inspecting",label:"Inspecting"},{value:"available",label:"Available"},{value:"degraded",label:"Degraded"},{value:"failed",label:"Failed"}],ox=[{value:"activity",label:"Recent activity"},{value:"added",label:"Date added"},{value:"name",label:"Name"},{value:"size",label:"Size"}],og={activity:"desc",added:"desc",name:"asc",size:"desc"},of=[15,30,50,100],ob=of.map(e=>({value:String(e),label:`${e} / page`})),ov="usenet.library.view",oy="usenet.library.pageSize";function oj(){try{return"list"===localStorage.getItem(ov)?"list":"grid"}catch{return"grid"}}function ow(){try{let e=Number(localStorage.getItem(oy));return of.includes(e)?e:15}catch{return 15}}function oN(e){let{value:t,onChange:s}=e,a=(e,a,n)=>(0,r.jsx)("button",{type:"button","aria-label":n,"aria-pressed":t===e,onClick:()=>s(e),className:b("flex h-9 w-9 items-center justify-center rounded text-lg transition-colors",t===e?"bg-brand/10 text-brand":"text-[--muted] hover:text-[--foreground]"),children:a});return(0,r.jsxs)("div",{className:"flex h-10 items-center gap-0.5 rounded-md border border-[--border] p-0.5",children:[a("grid",(0,r.jsx)(tC.fiy,{}),"Grid view"),a("list",(0,r.jsx)(tC.XfR,{}),"List view")]})}function ok(e){let{status:t}=e;return(0,r.jsx)("span",{className:b("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium",op[t]),children:t})}let oS={"application/x-nzb":[".nzb"],"application/xml":[".nzb"],"text/xml":[".nzb"]}
13;function oC(){let e,t,[s,a]=n.useState(""),[l,i]=n.useState(null),d=(e=(0,o.jE)(),(0,eE.n)({mutationFn:e=>ei("POST /dashboard/usenet/library",{body:e}),onSuccess:()=>e.invalidateQueries({queryKey:[...aB,"library"]})})),c=(t=(0,o.jE)(),(0,eE.n)({mutationFn:e=>{let t=new FormData;return t.append("file",e.file,e.file.name),e.name&&t.append("name",e.name),ei("POST /dashboard/usenet/library/upload",{body:t})},onSuccess:()=>t.invalidateQueries({queryKey:[...aB,"library"]})})),u=e=>{"failed"===e.status?x.oR.error(e.failReason??"Import failed"):x.oR.success("NZB queued")},m=async e=>{i({done:0,total:e.length});let t=0;await Promise.all(e.map(async s=>{try{let e=await c.mutateAsync({file:s,name:s.name});u(e)}catch(e){x.oR.error(`${s.name}: ${(null==e?void 0:e.message)??"upload failed"}`)}finally{i({done:t+=1,total:e.length})}})),i(null)},p=()=>{let e=s.trim();e&&d.mutateAsync({url:e}).then(e=>{u(e),"failed"!==e.status&&a("")}).catch(e=>x.oR.error((null==e?void 0:e.message)??"Failed to add NZB"))};return(0,r.jsxs)(X,{className:"p-4 space-y-3",children:[(0,r.jsx)(nP,{title:"Add NZB",description:"Import .nzb files or paste a URL",icon:tC.K0Y,size:"md"}),(0,r.jsx)(nu,{accept:oS,multiple:!0,className:"min-h-[120px] w-full",dropzoneText:"Drop .nzb files here, or click to choose",onValueChange:e=>{e.length&&m(e)},onDropRejected:e=>{let t=e.map(e=>e.file.name);x.oR.error(1===t.length?`"${t[0]}" isn't a .nzb file`:`${t.length} files skipped, only .nzb files are supported`)}}),l&&(0,r.jsxs)("p",{className:"text-xs text-[--muted]",children:["Importing ",l.done,"/",l.total,"…"]}),(0,r.jsxs)("div",{className:"flex items-stretch",children:[(0,r.jsx)(W,{leftIcon:(0,r.jsx)(tC.Jty,{}),placeholder:"…or add by URL: https://…/file.nzb",value:s,onValueChange:a,onKeyDown:e=>"Enter"===e.key&&p(),className:"flex-1 rounded-r-none"}),(0,r.jsx)(w,{intent:"primary",leftIcon:(0,r.jsx)(tC.Ca6,{}),loading:d.isPending,onClick:p,disabled:!s.trim(),className:"rounded-l-none shrink-0",children:"Add"})]})]})}function o_(e){let{entry:t,onBrowse:s,onInfo:a,onBlock:n,onUnblock:l,onRequeue:i,onDelete:o}=e,d=aJ(),c="available"===t.status||"degraded"===t.status,u=t.files.length>1,m=c&&!u,p=e=>{d.mutateAsync({hash:t.nzbHash,download:e}).then(e=>window.open(e.url,"_blank")).catch(e=>x.oR.error((null==e?void 0:e.message)??"No playable source"))},h=aq(t);return(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(w,{size:"sm",intent:"gray-outline",leftIcon:(0,r.jsx)(tC.uwC,{}),onClick:()=>s(t),children:"Browse"}),(0,r.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"sm",intent:"primary-subtle",icon:(0,r.jsx)(tC.UIR,{}),"aria-label":"Preview",disabled:!m,onClick:()=>p(!1)}),children:u?"Browse to pick a file":"Preview"}),(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(tC.Ah9,{}),"aria-label":"Download",disabled:!m,onClick:()=>p(!0)}),children:u?"Browse to pick a file":"Download"}),(0,r.jsxs)(lt,{align:"end",trigger:(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(tC.voe,{}),"aria-label":"More actions"}),children:[(0,r.jsxs)(ls,{onSelect:()=>a(t),children:[(0,r.jsx)(tC.wfp,{}),"Details"]}),(0,r.jsxs)(ls,{onSelect:()=>i([t.nzbHash]),disabled:!t.nzbUrl,children:[(0,r.jsx)(tC.Zxy,{}),t.nzbUrl?"Requeue import":"No source NZB to re-import"]}),(0,r.jsxs)(ls,{onSelect:()=>{var e;let s=document.createElement("a");e=t.nzbHash,s.href=`/api/v1/dashboard/usenet/library/${encodeURIComponent(e)}/nzb`,s.rel="noopener",document.body.appendChild(s),s.click(),s.remove()},children:[(0,r.jsx)(tC.w4m,{}),"Export NZB"]}),h.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(lr,{}),(0,r.jsxs)(ls,{onSelect:()=>t.blocked?l(t):n(t),children:[t.blocked?(0,r.jsx)(tC.DNZ,{}):(0,r.jsx)(tC.PLI,{}),t.blocked?"Unblock release":"Block release"]})]})]}),(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"sm",intent:"alert-subtle",icon:(0,r.jsx)(tC.id1,{}),"aria-label":"Delete entry",onClick:()=>o(t.nzbHash)}),children:"Delete"})]})]})}function oR(e){let{entry:t,view:s,selectMode:a,selected:n,onToggleSelect:l,onBrowse:i,onInfo:o,onBlock:d,onUnblock:c,onRequeue:u,onDelete:m}=e,p=t.name||t.nzbHash,h=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{children:rx(t.size)}),(0,r.jsxs)("span",{children:[t.files.length," file",1===t.files.length?"":"s"]})]}),x=b("transition-[background-color,box-shadow] duration-200",a&&"cursor-pointer hover:bg-[--subtle]/30",n&&"ring-1 ring-inset ring-brand/60 bg-brand/[0.06]"),g=a?()=>l(t,!n):void 0;return"list"===s?(0,r.jsx)(X,{className:b(x,"p-3"),onClick:g,children:(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("span",{className:"block font-medium text-sm break-all line-clamp-1",children:p}),(0,r.jsxs)("div",{className:"mt-0.5 flex flex-wrap gap-x-3 gap-y-0.5 text-xs text-[--muted]",children:[h,"failed"===t.status&&t.failReason&&(0,r.jsx)("span",{className:"text-red-500",title:t.errorCode,children:t.failReason})]})]}),(0,r.jsx)(ok,{status:t.status}),!a&&(0,r.jsx)("div",{className:"shrink-0",children:(0,r.jsx)(o_,{entry:t,onBrowse:i,onInfo:o,onBlock:d,onUnblock:c,onRequeue:u,onDelete:m})})]})}):(0,r.jsxs)(X,{className:b(x,"flex flex-col h-full p-3 sm:p-4"),onClick:g,children:[(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)(to,{trigger:(0,r.jsx)("span",{className:"min-w-0 flex-1 font-medium text-sm break-all line-clamp-2",children:p}),children:p}),(0,r.jsx)(ok,{status:t.status})]}),"failed"===t.status&&t.failReason&&(0,r.jsx)("p",{className:"text-xs text-red-500 mt-0.5",title:t.errorCode,children:t.failReason}),(0,r.jsx)("div",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-0.5 text-xs text-[--muted]",children:h})]}),!a&&(0,r.jsx)("div",{className:"mt-auto pt-3",children:(0,r.jsx)(o_,{entry:t,onBrowse:i,onInfo:o,onBlock:d,onUnblock:c,onRequeue:u,onDelete:m})})]})}let oA=["24h","7d","30d","all"];function oT(e){let{value:t,onChange:s}=e;return(0,r.jsx)("div",{className:"flex gap-1",children:oA.map(e=>(0,r.jsx)("button",{onClick:()=>s(e),className:b("px-2.5 py-1 rounded-md text-xs font-medium border transition-colors",t===e?"border-brand bg-brand/10 text-brand":"border-[--border] text-[--muted] hover:text-[--foreground]"),children:e},e))})}let oI={online:"bg-emerald-500",connecting:"bg-amber-500",offline:"bg-[--muted]",auth_failed:"bg-red-500",disabled:"bg-[--muted]/40"};function oE(e){let t=Date.now()-e;return t<1e3?"just now":`${rN(t)} ago`}function oM(e){let{p:t,health:s}=e;return(0,r.jsx)(U,{modal:!1,align:"start",className:"w-80",trigger:(0,r.jsx)("button",{type:"button","aria-label":`${t.name||t.id}: ${s.label}. Show details`,className:b("shrink-0 -my-1 p-1 rounded-full transition-opacity hover:opacity-70","bad"===s.tone?"text-red-500":"text-amber-500"),
13children:(0,r.jsx)(tC.wew,{className:"w-4 h-4"})}),children:(0,r.jsxs)("div",{className:"space-y-2.5",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:b("w-2 h-2 rounded-full shrink-0",s.cls)}),(0,r.jsx)("span",{className:"text-sm font-semibold",children:s.label})]}),s.hint&&(0,r.jsx)("p",{className:"text-xs text-[--muted]",children:s.hint}),t.lastDialError&&(0,r.jsxs)("div",{className:"rounded-[--radius] bg-[--subtle] p-2 space-y-1",children:[(0,r.jsxs)("div",{className:"flex items-baseline justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-xs font-medium",children:t.lastDialError.kind}),(0,r.jsx)("span",{className:"text-xs text-[--muted] shrink-0",children:oE(t.lastDialError.at)})]}),(0,r.jsx)("p",{className:"text-xs text-[--muted] break-words",children:t.lastDialError.message})]}),(0,r.jsxs)("p",{className:"text-xs text-[--muted]",children:[t.lastDialOkAt?`Last successful connection ${oE(t.lastDialOkAt)}`:"No successful connection recorded",t.queued>0&&` \xb7 ${t.queued} queued in pool`]})]})})}function oP(e){let t=Math.max(0,e.globalDownloadsInUse-e.globalDownloadsOnWire);return`${e.globalDownloadsOnWire} downloading \xb7 ${t} queued of ${e.globalDownloadMax} budget`+(e.globalDownloadsWaiting>0?` \xb7 +${e.globalDownloadsWaiting} waiting`:"")}function oD(){let e=function(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],t=(0,o.jE)();return n.useEffect(()=>{if(e)return aW++,aG||((aG=new EventSource("/api/v1/dashboard/usenet/live/stream",{withCredentials:!0})).onmessage=e=>{try{t.setQueryData(aH,JSON.parse(e.data))}catch{}}),()=>{--aW>0||(null==aG||aG.close(),aG=null)}},[t,e]),(0,eU.I)({queryKey:aH,queryFn:()=>ei("/dashboard/usenet/live"),staleTime:1/0,enabled:e})}().data,t=null==e?void 0:e.live,s=null==e?void 0:e.pool,a=function(e){let[t,s]=n.useState(!1),a=n.useRef(null),r=(null==e?void 0:e.providers.reduce((e,t)=>e+t.queued,0))??0,l=(null==e?void 0:e.globalDownloadsOnWire)??0;return n.useEffect(()=>{r>0&&0===l?(a.current??(a.current=Date.now()),s(Date.now()-a.current>6e4)):(a.current=null,s(!1))},[r,l,e]),t}(s),l=(null==s?void 0:s.providers.some(e=>e.isBackup))??!1,i=(null==e?void 0:e.tickMs)??500;return(0,r.jsxs)("div",{className:"space-y-4",children:[a&&(0,r.jsx)(nU,{intent:"warning",title:"Downloads are queued but no connections are transferring",description:"Fetches have been parked for over a minute with no wire activity. If this persists, check provider reachability or re-save the provider settings to rebuild the connection pools."}),(0,r.jsxs)("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[(0,r.jsx)(lF,{label:"Active streams",value:t?String(t.activeStreams):"—",hint:s?oP(s):""}),(0,r.jsx)(lF,{label:"Download speed",value:t?(0,r.jsx)(iP,{value:t.currentBytesPerSec,format:rg,durationSec:i/1e3}):"—",hint:t?`peak ${rg(t.peakBytesPerSec)}`:""}),(0,r.jsx)(lF,{label:"Articles / min",value:t?(0,r.jsx)(iP,{value:t.articlesLastMinute,format:e=>rS(Math.round(e)),durationSec:i/1e3}):"—",hint:t?`${t.errorsLastMinute} errors`:""}),(0,r.jsx)(lF,{label:"Cache hit rate",value:e?(0,r.jsx)(iP,{value:e.cache.hitRate,format:rb,durationSec:i/1e3}):"—",hint:e?`${rx(e.cache.diskBytes)} on disk`:""})]}),(0,r.jsxs)(X,{className:"p-4",children:[(0,r.jsxs)("div",{className:"flex items-baseline justify-between mb-3",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold",children:"Live connections"}),(0,r.jsxs)("span",{className:"text-xs text-[--muted]",children:[s?oP(s):"0 downloading \xb7 0 queued",l?" \xb7 includes backup capacity":""]})]}),s&&0!==s.providers.length?(0,r.jsx)("div",{className:"space-y-2.5",children:s.providers.map(e=>{let t=function(e){if("disabled"===e.state)return{tone:"off",cls:"bg-[--muted]/40",label:"Disabled"};if("auth_failed"===e.state)return{tone:"bad",cls:"bg-red-500",label:"Authentication failed",hint:"The provider rejected the username or password. Update the credentials on the Providers page."};let t=(e,t)=>({tone:"warn",cls:"bg-amber-500",label:e,hint:t});return e.tripped?t("Circuit breaker tripped","Too many failures in a row, so new requests ski
13p this provider and fail over to the others. It retries automatically."):e.throttled?t("Connection-limit throttled","The provider refused another connection, usually because the account is at its connection limit. The pool has backed off and is running below its configured maximum."):"connecting"===e.state?t("Connecting"):e.lastDialError&&e.lastDialError.at>(e.lastDialOkAt??0)?t(`Last dial failed (${e.lastDialError.kind})`,"The most recent connection attempt did not succeed. If this persists, check the host, port and TLS settings."):e.acquired>0||e.total>0||e.lastDialOkAt&&Date.now()-e.lastDialOkAt<9e4?{tone:"ok",cls:"bg-emerald-500",label:"Reachable"}:{tone:"idle",cls:"bg-[--muted]",label:"Idle (no recent connections)"}}(e),s="warn"===t.tone||"bad"===t.tone,a=t=>e.max?`${Math.min(100,t/e.max*100)}%`:"0%";return(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(to,{trigger:(0,r.jsx)("span",{className:b("w-2 h-2 rounded-full shrink-0",t.cls)}),children:t.label}),(0,r.jsxs)("span",{className:"text-sm font-medium w-40 truncate flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:"truncate",children:e.name||e.id}),e.isBackup&&(0,r.jsx)("span",{className:"text-xs text-[--muted] shrink-0",children:"backup"}),s&&(0,r.jsx)(oM,{p:e,health:t})]}),(0,r.jsxs)("div",{className:"relative flex-1 h-1.5 rounded-full bg-[--subtle] overflow-hidden",children:[(0,r.jsx)("div",{className:b("absolute inset-y-0 left-0","transition-[width] ease-out motion-reduce:transition-none",e.tripped?"bg-red-500/30":"bg-brand/30"),style:{width:a(e.total),transitionDuration:`${i}ms`}}),(0,r.jsx)("div",{className:b("absolute inset-y-0 left-0","transition-[width] ease-out motion-reduce:transition-none",e.tripped?"bg-red-500":"bg-brand"),style:{width:a(e.acquired),transitionDuration:`${i}ms`}})]}),(0,r.jsx)("span",{className:"text-xs tabular-nums w-24 text-right text-[--foreground]",title:`per-connection download-rate EWMA the load-balancer splits group traffic by \xb7 ${e.freeSlots} free pipeline slots \xb7 aggregate ≈ this \xd7 active connections (see the windowed table for total speed)`,children:e.throughput?
13(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(iP,{value:e.throughput,format:rg,durationSec:i/1e3}),"/conn"]}):"—"}),(0,r.jsxs)("span",{className:"text-xs text-[--muted] tabular-nums w-40 text-right",title:`${e.queued} queued in pool`,children:[e.acquired," active \xb7 ",e.total," open \xb7 max ",e.max]})]},e.id)})}):(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"No active provider pools. Connections open on demand when streaming."})]})]})}function oL(e){let{providers:t}=e;return 0===t.length?(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"No provider activity recorded in this window yet."}):(0,r.jsx)("div",{className:"overflow-x-auto -mx-4 px-4 lg:mx-0 lg:px-0",children:(0,r.jsxs)("table",{className:"w-full text-sm min-w-[720px]",children:[(0,r.jsx)("thead",{className:"text-[--muted] text-xs uppercase",children:(0,r.jsxs)("tr",{className:"text-left border-b border-[--border]",children:[(0,r.jsx)("th",{className:"py-2 pr-3",children:"Provider"}),(0,r.jsx)("th",{className:"py-2 px-3 text-right",children:"Share"}),(0,r.jsx)("th",{className:"py-2 px-3 text-right",children:"Data"}),(0,r.jsx)("th",{className:"py-2 px-3 text-right",children:"Avg speed"}),(0,r.jsx)("th",{className:"py-2 px-3 text-right",children:"Articles"}),(0,r.jsx)("th",{className:"py-2 px-3 text-right",title:"How long the provider takes to answer a request for an article, before it starts sending it. Unlike the time to fetch a whole article, this does not grow when your bandwidth is shared across more streams, so it is comparable between providers.",children:"Avg latency"}),(0,r.jsx)("th",{className:"py-2 px-3 text-right",children:"Errors"}),(0,r.jsx)("th",{className:"py-2 pl-3 text-right",children:"Missing"})]})}),(0,r.jsx)("tbody",{children:t.map(e=>(0,r.jsxs)("tr",{className:"border-b border-[--border]/50",children:[(0,r.jsx)("td",{className:"py-2 pr-3",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:b("w-2 h-2 rounded-full shrink-0",oI[e.live.state]),title:e.live.state}),(0,r.jsx)("span",{className:"font-medium",children:e.name||e.host}),e.isBackup&&(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:"backup"}),!e.enabled&&(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:"(disabled)"})]})}),(0,r.jsx)("td",{className:"py-2 px-3 text-right",children:(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,r.jsx)("div",{className:"w-16 h-1 rounded-full bg-[--subtle] overflow-hidden",children:(0,r.jsx)("div",{className:"h-full bg-brand",style:{width:`${100*e.articleShare}%`}})}),(0,r.jsx)("span",{className:"tabular-nums w-10 text-right",children:rb(e.articleShare)})]})}),(0,r.jsx)("td",{className:"py-2 px-3 text-right tabular-nums",children:rx(e.bytes)}),(0,r.jsx)("td",{className:"py-2 px-3 text-right tabular-nums",title:e.avgArticleMs?`${e.avgArticleMs}ms to fetch a whole article on average`:void 0,children:e.avgBytesPerSec?rg(e.avgBytesPerSec):"—"}),(0,r.jsx)("td",{className:"py-2 px-3 text-right tabular-nums",children:rS(e.articles)}),(0,r.jsx)("td",{className:"py-2 px-3 text-right tabular-nums",title:null==e.avgLatencyMs&&e.articles>0?"Latency is only measured on fetches that had a connection to themselves, so a provider running with pipelining enabled may report none.":void 0,children:null==e.avgLatencyMs?"—":`${e.avgLatencyMs}ms`}),(0,r.jsx)("td",{className:b("py-2 px-3 text-right tabular-nums",e.errorRate>.1&&"text-red-500"),children:rb(e.errorRate)}),(0,r.jsx)("td",{className:"py-2 pl-3 text-right tabular-nums text-[--muted]",children:rb(e.missRate)})]},e.id))})]})})}function oU(e){let t=e.failedFetch-e.fetchAuth-e.fetchLimited,s=e.failed-e.failedMissing-e.failedFetch;return[e.failedMissing>0&&`${e.failedMissing} missing on providers`,e.fetchAuth>0&&`${e.fetchAuth} blocked (401/403)`,e.fetchLimited>0&&`${e.fetchLimited} rate-limited (429)`,t>0&&`${t} fetch failed`,s>0&&`${s} other`].filter(Boolean).join(" \xb7 ")}function o$(e){let{indexer:t,error:s,breakdown:a}=e,n=401===s.status||403===s.status?{tone:"bad",label:`Blocked by indexer (HTTP ${s.status})`,hint:"The indexer refused the NZB download. Check that the API key is valid and the account is in good standing."}:429===s.status?{tone:"warn",label:"Rate-limited (HTTP 429)",hint:"The indexer is rate-limiting NZB downloads, usually because the account hit its daily API or grab limit. This normally clears on its own."}:{tone:"warn",label:s.status?`Grab failed (HTTP ${s.status})`:"Grab failed",hint:"The most recent NZB download from this indexer did not succeed. If this persists, check the indexer URL and its status page."};return(0,r.jsx)(U,{modal:!1,align:"start",className:"w-80",trigger:(0,r.jsx)("button",{type:"button","aria-label":`${t}: ${n.label}. Show details`,className:b("shrink-0 -my-1 p-1 rounded-full transition-opacity hover:opacity-70","bad"===n.tone?"text-red-500":"text-amber-500"),
13children:(0,r.jsx)(tC.wew,{className:"w-4 h-4"})}),children:(0,r.jsxs)("div",{className:"space-y-2.5",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:b("w-2 h-2 rounded-full shrink-0","bad"===n.tone?"bg-red-500":"bg-amber-500")}),(0,r.jsx)("span",{className:"text-sm font-semibold",children:n.label})]}),(0,r.jsx)("p",{className:"text-xs text-[--muted]",children:n.hint}),(0,r.jsxs)("div",{className:"rounded-[--radius] bg-[--subtle] p-2 space-y-1",children:[(0,r.jsxs)("div",{className:"flex items-baseline justify-between gap-2",children:[(0,r.jsx)("span",{className:"text-xs font-medium",children:"Last grab error"}),(0,r.jsx)("span",{className:"text-xs text-[--muted] shrink-0",children:oE(s.atMs)})]}),(0,r.jsx)("p",{className:"text-xs text-[--muted] break-words",children:s.message})]}),a&&(0,r.jsxs)("p",{className:"text-xs text-[--muted]",children:["Failed in this window: ",a]})]})})}function oO(e){let{indexers:t}=e;return 0===t.length?(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"No grabs recorded in this window yet."}):(0,r.jsx)("div",{className:"overflow-x-auto -mx-4 px-4 lg:mx-0 lg:px-0",children:(0,r.jsxs)("table",{className:"w-full text-sm min-w-[720px]",children:[(0,r.jsx)("thead",{className:"text-[--muted] text-xs uppercase",children:(0,r.jsxs)("tr",{className:"text-left border-b border-[--border]",children:[(0,r.jsx)("th",{className:"py-2 pr-3",children:"Indexer"}),(0,r.jsx)("th",{className:"py-2 px-3 text-right",children:"Share"}),(0,r.jsx)("th",{className:"py-2 px-3 text-right",children:"Grabs"}),(0,r.jsx)("th",{className:"py-2 px-3 text-right",title:"Grabs whose import produced a streamable entry (degraded included).",children:"Success"}),(0,r.jsx)("th",{className:"py-2 px-3 text-right",children:"Failed"}),(0,r.jsx)("th",{className:"py-2 px-3 text-right",title:"How long the indexer takes to 
13serve the .nzb file itself.",children:"Avg grab"}),(0,r.jsx)("th",{className:"py-2 pl-3 text-right",title:"How long the import/inspection of the release took after the grab.",children:"Avg import"})]})}),(0,r.jsx)("tbody",{children:t.map(e=>(0,r.jsxs)("tr",{className:"border-b border-[--border]/50",children:[(0,r.jsx)("td",{className:"py-2 pr-3",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"font-medium",children:e.indexer}),e.lastError&&Date.now()-e.lastError.atMs<864e5&&(0,r.jsx)(o$,{indexer:e.indexer,error:e.lastError,breakdown:e.failed>0?oU(e):void 0})]})}),(0,r.jsx)("td",{className:"py-2 px-3 text-right",children:(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,r.jsx)("div",{className:"w-16 h-1 rounded-full bg-[--subtle] overflow-hidden",children:(0,r.jsx)("div",{className:"h-full bg-brand",style:{width:`${100*e.grabShare}%`}})}),(0,r.jsx)("span",{className:"tabular-nums w-10 text-right",children:rb(e.grabShare)})]})}),(0,r.jsx)("td",{className:"py-2 px-3 text-right tabular-nums",children:rS(e.grabs)}),(0,r.jsx)("td",{className:b("py-2 px-3 text-right tabular-nums",e.grabs>0&&1-e.successRate>.1&&"text-red-500"),title:e.degraded>0?`includes ${e.degraded} degraded import${1===e.degraded?"":"s"}`:void 0,children:rb(e.successRate)}),(0,r.jsx)("td",{className:"py-2 px-3 text-right tabular-nums",title:e.failed>0?oU(e):void 0,children:rS(e.failed)}),(0,r.jsx)("td",{className:"py-2 px-3 text-right tabular-nums",children:null==e.avgGrabMs?"—":rN(e.avgGrabMs)}),(0,r.jsx)("td",{className:"py-2 pl-3 text-right tabular-nums",children:null==e.avgImportMs?"—":rN(e.avgImportMs)})]},e.indexer))})]})})}function oF(e){let{data:t}=e,s=t.throughput.map(e=>{var s,a;let r,n;return{t:(s=e.bucketMs,a=t.window,r=new Date(s),n=e=>String(e).padStart(2,"0"),"24h"===a?`${n(r.getHours())}:00`:"7d"===a?`${n(r.getMonth()+1)}/${n(r.getDate())} ${n(r.getHours())}h`:`${n(r.getMonth()+1)}/${n(r.getDate())}`),bytes:e.bytes}}),a=t.providers.filter(e=>e.articles>0).slice(0,6).map(e=>({name:e.name||e.host,value:e.articles})),n=t.indexers.reduce((e,t)=>e+t.grabs,0),l=t.indexers.filter(e=>e.grabs>0).slice(0,6).map(e=>({name:e.indexer,value:e.grabs}));return(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsxs)("div",{className:"grid grid-cols-2 lg:grid-cols-5 gap-3",children:[(0,r.jsx)(lF,{label:"Data downloaded",value:rx(t.totals.bytes)}),(0,r.jsx)(lF,{label:"Avg download speed",value:t.totals.avgBytesPerSec?rg(t.totals.avgBytesPerSec):"—",hint:`avg while streaming \xb7 ${t.window}`}),(0,r.jsx)(lF,{label:"Articles",value:rS(t.totals.articles)}),(0,r.jsx)(lF,{label:"Avg latency",value:null==t.totals.avgLatencyMs?"—":`${t.totals.avgLatencyMs}ms`,hint:t.totals.avgArticleMs?`${t.totals.avgArticleMs}ms per whole article`:""}),(0,r.jsx)(lF,{label:"Error rate",value:rb(t.totals.articles+t.totals.errors>0?t.totals.errors/(t.totals.articles+t.totals.errors):0)})]}),(0,r.jsxs)(X,{className:"p-4",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold mb-3",children:"Data downloaded"}),0===s.length?(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"No data for this window yet."}):(0,r.jsx)(lL,{data:s,xKey:"t",series:[{key:"bytes",label:"Downloaded",color:"var(--brand)"}],height:240,valueFormatter:e=>rx(Number(e)),yTickFormatter:e=>rx(Number(e))})]}),(0,r.jsxs)(X,{className:"p-4",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold mb-3",children:"Provider performance"}),a.length>0?(0,r.jsxs)("div",{className:"grid lg:grid-cols-[1fr,240px] gap-6 items-center",children:[(0,r.jsx)(oL,{providers:t.providers}),(0,r.jsx)("div",{className:"mx-auto w-full max-w-[240px] aspect-square",children:(0,r.jsx)(l$,{data:a,centerLabel:"articles",centerValue:rS(t.totals.articles),height:240})})]}):(0,r.jsx)(oL,{providers:t.providers})]}),(0,r.jsxs)(X,{className:"p-4",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold mb-3",children:"Indexer performance"}),l.length>0?(0,r.jsxs)("div",{className:"grid lg:grid-cols-[1fr,240px] gap-6 items-center",children:[(0,r.jsx)(oO,{indexers:t.indexers}),(0,r.jsx)("div",{className:"mx-auto w-full max-w-[240px] aspect-square",children:(0,r.jsx)(l$,{data:l,centerLabel:"grabs",centerValue:rS(n),height:240})})]}):(0,r.jsx)(oO,{indexers:t.indexers})]})]})}function oz(e){let{intent:t,children:s}=e;return(0,r.jsx)("span",{className:b("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium",{success:"bg-emerald-500/15 text-emerald-500",alert:"bg-red-500/15 text-red-500",warning:"bg-orange-500/15 text-orange-500"}[t]),children:s})}function oV(e){return{id:e.id,name:e.name??"",host:e.host,port:e.port,tls:e.tls,tlsSkipVerify:e.tlsSkipVerify??!1,username:e.username??"",password:"",hasPassword:e.hasPassword,maxConnections:e.maxConnections,pipelineDepth:e.pipelineDepth??1,isBackup:e.isBackup??
13!1,enabled:!1!==e.enabled,priority:e.priority}}function oq(e){let t=e.map((e,t)=>({d:e,i:t})).sort((e,t)=>{let s=!!e.d.isBackup-!!t.d.isBackup;return 0!==s?s:e.d.priority!==t.d.priority?e.d.priority-t.d.priority:e.i-t.i}).map(e=>{let{d:t}=e;return t}),s=0,a=null,r=null;return t.map(e=>((e.priority!==a||e.isBackup!==r)&&(s++,a=e.priority,r=e.isBackup),{...e,priority:s}))}function oB(e){let t=e.password?e.password:e.hasPassword?"__stored__":void 0;return{id:e.id,name:e.name||void 0,host:e.host.trim(),port:e.port,tls:e.tls,tlsSkipVerify:e.tlsSkipVerify||void 0,username:e.username||void 0,password:t,maxConnections:e.maxConnections,pipelineDepth:e.pipelineDepth>1?e.pipelineDepth:void 0,priority:e.priority,isBackup:e.isBackup||void 0,enabled:e.enabled}}function oK(e){let t,{providers:s}=e,[a,l]=n.useState(()=>oq(s.map(oV))),[i,d]=n.useState({}),[c,u]=n.useState({}),m=(t=(0,o.jE)(),(0,eE.n)({mutationFn:e=>ei("PUT /dashboard/usenet/providers",{body:{providers:e}}),onSuccess:()=>{t.invalidateQueries({queryKey:[...aB,"providers"]}),t.invalidateQueries({queryKey:[...aB,"stats"]})}})),p=(0,eE.n)({mutationFn:e=>ei("POST /dashboard/usenet/providers/test",{body:e})}),h=(0,eE.n)({mutationFn:e=>ei(`POST /dashboard/usenet/providers/${encodeURIComponent(e)}/speedtest`)}),g=n.useMemo(()=>new Set(s.map(e=>e.id)),[s]),f=n.useMemo(()=>JSON.stringify(s),[s]),b=n.useRef(f);n.useEffect(()=>{f!==b.current&&(b.current=f,l(oq(s.map(oV))),d({}),u({}))},[f,s]);let v=async e=>{d(t=>({...t,[e.id]:"pending"}));try{let t=await p.mutateAsync(oB(e));d(s=>({...s,[e.id]:t})),t.ok?x.oR.success(`${e.name||e.host}: connected in ${t.latencyMs}ms`):x.oR.error(`${e.name||e.host}: ${t.error??"failed"}`)}catch(s){let t={ok:!1,error:(null==s?void 0:s.message)??"failed"};d(s=>({...s,[e.id]:t})),x.oR.error(`${e.name||e.host}: ${t.error}`)}},y=async e=>{u(t=>({...t,[e.id]:"pending"}));try{let t=await h.mutateAsync(e.id);u(s=>({...s,[e.id]:t})),t.ok?x.oR.success(`${e.name||e.host}: ${rg(t.bytesPerSec??0)}`):x.oR.error(`${e.name||e.host}: ${t.error??"speed test failed"}`)}catch(s){let t={ok:!1,error:(null==s?void 0:s.message)??"failed"};u(s=>({...s,[e.id]:t})),x.oR.error(`${e.name||e.host}: ${t.error}`)}},j=async()=>{for(let e of a)if(!e.host.trim())return void x.oR.error("Every provider needs a host.");try{await m.mutateAsync(a.map(oB)),x.oR.success("Providers saved.")}catch(e){x.oR.error((null==e?void 0:e.message)??"Failed to save providers")}},N=function(e){let t=[];for(let s of e){let e=t[t.length-1];e&&e[0].priority===s.priority?e.push(s):t.push([s])}return t}(a);return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-sm font-semibold",children:"NNTP providers"}),(0,r.jsx)("p",{className:"text-xs text-[--muted]",children:"Lower priority numbers are tried first. Give two providers the same priority to put them in one load-balanced group (shown bracketed) so they split load by free capacity instead of one sitting idle as failover — the up arrow groups a provider with the one above, the down arrow splits it back out. Mark metered block accounts as backups (the toggle applies to the whole group) so they’re only used when a primary misses an article."})]}),(0,r.jsx)(w,{size:"sm",intent:"primary-subtle",leftIcon:(0,r.jsx)(tC.Ca6,{}),onClick:()=>l(e=>{var t,s;return oq([...e,{...{id:(null==(s=globalThis.crypto)||null==(t=s.randomUUID)?void 0:t.call(s))??`p_${Math.random().toString(36).slice(2)}`,name:"",host:"",port:563,tls:!0,tlsSkipVerify:!1,username:"",password:"",hasPassword:!1,maxConnections:10,pipelineDepth:1,isBackup:!1,enabled:!0,priority:1},priority:(e.length?Math.max(...e.map(e=>e.priority)):0)+1}])}),children:"Add provider"})]}),0===a.length&&(0,r.jsx)(X,{className:"p-6 text-center text-sm text-[--muted]",children:"No providers configured yet. Add your first NNTP account to start streaming."}),(0,r.jsx)("div",{className:"space-y-3",children:N.map(e=>(0,r.jsx)("div",{className:"space-y-px",children:e.map((t,s)=>(0,r.jsx)(oY,{draft:t,grouped:e.length>1,isGroupHead:0===s,isGroupTail:s===e.length-1,canGroupUp:t.priority>1,canUngroup:e.length>1,testResult:i[t.id],speedResult:c[t.id],canSpeedTest:g.has(t.id),onChange:e=>{let s;return s=t.id,l(t=>t.map(t=>
13t.id===s?{...t,...e}:t))},onSetPriority:e=>{let s;return s=t.id,l(t=>{let a=Math.max(1,Math.round(e)||1);return oq(t.map(e=>{var r;if(e.id!==s)return e;let n=null==(r=t.find(e=>e.id!==s&&e.priority===a))?void 0:r.isBackup;return{...e,priority:a,isBackup:n??e.isBackup}}))})},onGroupUp:()=>{let e;return e=t.id,l(t=>{var s;let a=t.find(t=>t.id===e);if(!a||a.priority<=1)return t;let r=a.priority-1,n=(null==(s=t.find(e=>e.priority===r))?void 0:s.isBackup)??a.isBackup;return oq(t.map(t=>t.id===e?{...t,priority:r,isBackup:n}:t))})},onUngroup:()=>{let e;return e=t.id,l(t=>{let s=t.find(t=>t.id===e);return!s||t.filter(e=>e.priority===s.priority).length<=1?t:oq(t.map(t=>t.id===e?{...t,priority:t.priority+.5}:t))})},onSetBackup:e=>{let s;return s=t.id,l(t=>{let a=t.find(e=>e.id===s);return a?oq(t.map(t=>t.priority===a.priority?{...t,isBackup:e}:t)):t})},onRemove:()=>{let e;return e=t.id,l(t=>oq(t.filter(t=>t.id!==e)))},onTest:()=>v(t),onSpeedTest:()=>y(t)},t.id))},e[0].id))}),(0,r.jsx)("div",{className:"flex justify-end",children:(0,r.jsx)(w,{intent:"primary",loading:m.isPending,onClick:j,children:"Save providers"})})]})}function oH(e){let{result:t}=e;return"pending"===t?(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:"testing…"}):t?t.ok?(0,r.jsxs)(oz,{intent:"success",children:[(0,r.jsx)(tC.qGT,{})," ",t.latencyMs,"ms"]}):(0,r.jsxs)(oz,{intent:"alert",children:[(0,r.jsx)(tC.wew,{})," ",t.code??"failed"]}):null}function oG(e){let{result:t}=e;if("pending"===t)return(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:"speed testing…"});if(!t)return null;if(!t.ok)return(0,r.jsxs)(oz,{intent:"warning",children:[(0,r.jsx)(tC.wew,{})," ",t.code??"failed"]});let s=null!=t.connections?`${t.connections} conn${t.pipelineDepth&&t.pipelineDepth>1?` \xd7 depth ${t.pipelineDepth}`:""}`:void 0;return(0,r.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,r.jsxs)(oz,{intent:"success",children:[(0,r.jsx)(tC.I2B,{})," ",rg(t.bytesPerSec??0)]}),s?(0,r.jsx)("span",{className:"text-[10px] text-[--muted]",title:`Fanned out across ${t.connections} connections, pipeline depth ${t.pipelineDepth??1}`,children:s}):null]})}function oW(e){let{value:t,onCommit:s}=e,a=n.useRef(t);return n.useEffect(()=>{a.current=t},[t]),(0,r.jsx)("div",{onBlur:()=>a.current!==t&&s(a.current),children:(0,r.jsx)(nn,{defaultValue:t,min:1,hideControls:!0,size:"sm",className:"w-16 text-center tabular-nums","aria-label":"Priority",onValueChange:e=>{a.current=Number.isFinite(e)&&e>=1?Math.round(e):1}},t)})}function oY(e){let{draft:t,grouped:s,isGroupHead:a,isGroupTail:n,canGroupUp:l,canUngroup:i,testResult:o,speedResult:d,canSpeedTest:c,onChange:u,onSetPriority:m,onGroupUp:p,onUngroup:h,onSetBackup:x,onRemove:g,onTest:f,onSpeedTest:v}=e,y="pending"===o,j="pending"===d,w=tN({title:"Delete provider?",description:(0,r.jsxs)(r.Fragment,{children:["Are you sure you want to remove"," ",(0,r.jsx)("strong",{children:t.name||t.host||"this provider"}),"?"]}),actionText:"Delete",actionIntent:"alert-subtle",onConfirm:g});return(0,r.jsxs)(X,{className:b("p-4 transition-opacity duration-300",!t.enabled&&"opacity-60",s&&"border-l-2 border-l-[--brand]",s&&!a&&"rounded-t-none",s&&!n&&"rounded-b-none"),children:[(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsxs)("div",{className:"flex flex-col items-center gap-1 pt-1",children:[(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"xs",intent:"gray-subtle",icon:(0,r.jsx)(tC.mlL,{}),disabled:!l,onClick:p,"aria-label":"Group with provider above"}),children:"Group with the provider above"}),(0,r.jsx)(oW,{value:t.priority,onCommit:m}),(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"xs",intent:"gray-subtle",icon:(0,r.jsx)(tC.nwe,{}),disabled:!i,onClick:h,"aria-label":"Split out of group"}),children:"Split out into its own priority"})]}),(0,r.jsxs)("div",{className:"flex-1 space-y-3",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2 flex-1 min-w-[180px]",children:[(0,r.jsx)("span",{className:"font-medium text-sm",children:t.name||t.host||"New provider"}),t.isBackup&&(0,r.jsx)(oz,{intent:"warning",children:"backup"}),s&&(0,r.jsx)(oz,{intent:"success",children:"load-balanced"}),(0,r.jsx)(oH,{result:o}),(0,r.jsx)(oG,{result:d})]}),(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(tC.UWw,{}),onClick:f,loading:y,disabled:!t.host||y,"aria-label":"Test provider"}),children:"Test connection"}),(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(tC.I2B,{}),onClick:v,loading:j,disabled:!c||j,"aria-label":"Speed test provider"}),children:c?"Speed test (downloads from your library)":"Save the provider first to speed test"}),(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"sm",intent:t.enabled?"success-subtle":"gray-subtle",icon:t.enabled?(0,r.jsx)(J.lXh,{}):(0,r.jsx)(J.czG,{}),className:"transition-colors duration-300",onClick:()=>u({enabled:!t.enabled}),"aria-label":t.enabled?"Disable provider":"Enable provider"}),children:t.enabled?"Enabled — click to disable":"Disabled — click to enable"}),(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"sm",intent:"alert-subtle",icon:(0,r.jsx)(tC.id1,{}),onClick:w.open,"aria-label":"Remove provider"}),children:"Remove provider"})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:[(0,r.jsx)(F,{label:"Name",children:(0,r.jsx)(W,{value:t.name,placeholder:"Friendly name",onValueChange:e=>u({name:e})})}),(0,r.jsx)(F,{label:"Host",className:"lg:col-span-2",children:(0,r.jsx)(W,{value:t.host,placeholder:"news.example.com",onValueChange:e=>u({host:e})})}),(0,r.jsx)(F,{label:"Port",children:(0,r.jsx)(nn,{value:t.port,min:1,max:65535,hideControls:!0,onValueChange:e=>u({port:e||0})})}),(0,r.jsx)(F,{label:"Max connections",children:(0,r.jsx)(nn,{value:t.maxConnections,min:1,onValueChange:e=>u({maxConnections:e||1})})}),(0,r.jsx)(F,{label:"Pipeline depth",moreHelp:"How many requests can be waiting on each connection at once. 1 (the default) sends one request at a time. Higher values (e.g. 4–8) can reach full speed with far fewer connections — especially useful when the provider's server is far away — and automatically fall back to 1 if the provider doesn't support it.",children:(0,r.jsx)(nn,{value:t.pipelineDepth,min:1,max:20,onValueChange:e=>u({pipelineDepth:Math.min(20,Math.max(1,e||1))})})}),(0,r.jsx)(F,{label:"Username",children:(0,r.jsx)(W,{value:t.username,autoComplete:"off",onValueChange:e=>u({username:e})})}),(0,r.jsx)(F,{label:"Password",className:"lg:col-span-2",children:(0,r.jsx)(Z,{value:t.password,autoComplete:"new-password",placeholder:t.hasPassword?"•••••••• (unchanged)":"",onValueChange:e=>u({password:e})})})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-x-6 gap-y-3 rounded-md border border-[--border]/60 px-3 py-2.5",children:[(0,r.jsx)(rs,{value:t.tls,onValueChange:e=>u({tls:e}),label:"SSL/TLS",side:"right"}),(0,r.jsx)(rs,{value:t.isBackup,onValueChange:x,label:"Backup",moreHelp:s?"Applies to the whole group — backup providers are only used when a download is missing pieces on your main providers.":"Only used when a download is missing pieces on your main providers — ideal for metered block accounts.",side:"right"}),(0,r.jsx)(rs,{value:t.tlsSkipVerify,onValueChange:e=>u({tlsSkipVerify:e}),label:"Skip TLS verify",side:"right"})]})]})]}),(0,r.jsx)(tk,{...w})]})}let oJ=["prefetchSegments","maxConcurrentDownloads","segmentDiskCacheBytes"],oZ="performanceProfile",oQ=e=>`usenet.${e}`,oX={includes:e=>e.startsWith("usenet.")&&"usenet.providers"!==e,fileStem:"aiostreams-usenet-sett
13ings",noun:"usenet"},o0=[{title:"Performance",leaves:[oZ,...oJ],note:"Pick a profile and the values below are filled in for you — that is all most setups need. Editing any of the values switches the profile to **custom**."},{title:"Connections & timeouts",leaves:["streamingPriority","segmentTimeout","segmentStallTimeout","dialTimeout","idleConnection","streamIdleTimeout"]},{title:"Reliability",leaves:["circuitBreakerThreshold","circuitBreakerCooldown"]},{title:"Archive handling",leaves:["lazyRarResolution","strictArchiveMembership"]},{title:"Verification",leaves:["verifyMode","verifyBudgetMs","damagePolicy","matroskaHoleFill","censusShadowConcurrency","censusMaxLifetime"],note:"When something is imported, AIOStreams checks that it can actually be downloaded from your providers — so broken or incomplete releases are caught up front instead of failing mid-playback. The checks run alongside the import, so they normally add no waiting time: badly damaged releases are rejected, slightly damaged ones are recorded as “degraded”, the damage policy below decides whether those are still offered as streams. Any checking that did not finish during the import simply continues in the background. A stream that is already playing is never interrupted by these verdicts; they apply from the next playback onwards. Providers that give unreliable answers are detected and ignored automatically."},{title:"Import & API",leaves:["maxNzbSize","maxConcurrentInspects","sabnzbdApiEnabled"]}];function o1(e){let{profiles:t}=e,{setValue:s,getValues:a}=(0,rG.xW)(),r=n3(oQ(oZ)),l=oJ.map(e=>n3(oQ(e))),i=(0,rG.FH)({name:r}),o=(0,rG.FH)({name:l[0]}),d=(0,rG.FH)({name:l[1]}),c=(0,rG.FH)({name:l[2]}),u=(0,rG.FH)({name:l[3]}),m=n.useRef(!1);return n.useEffect(()=>{let e=i&&"custom"!==i?t[i]:void 0;if(!e||oJ.every((t,s)=>Number(a(l[s]))===e[t]))return;m.current=!0,oJ.forEach((t,a)=>s(l[a],e[t],{shouldDirty:!0}));let r=setTimeout(()=>{m.current=!1},0);return()=>clearTimeout(r)},[i]),n.useEffect(()=>{if(m.current)return;let e=i&&"custom"!==i?t[i]:void 0;if(!e)return;let a=[o,d,c,u];oJ.every((t,s)=>Number(a[s])===e[t])||s(r,"custom",{shouldDirty:!0})},[o,d,c,u]),null}var o2=s(3300);let o3=[{to:"/dashboard/analytics",label:"Analytics",desc:"User & request trends",icon:tC.yWU},{to:"/dashboard/streams",label:"Streams",desc:"Active, history & bandwidth",icon:tC.U2S},{to:"/dashboard/usenet",label:"Usenet",desc:"Library, providers & stats",icon:tC.hQe},{to:"/dashboard/tasks",label:"Tasks",desc:"Scheduled & manual work",icon:tC.bZV},{to:"/dashboard/system",label:"System",desc:"CPU, memory, lifecycle",icon:tC.EYW},{to:"/dashboard/logs",label:"Logs",desc:"Live log stream",icon:tC.m4U},{to:"/dashboard/cache",label:"Cache",desc:"Cache stats & flush",icon:tC.Wwx},{to:"/dashboard/settings",label:"Settings",desc:"Runtime configuration",icon:tC.nMM}];function o6(e){let{label:t,value:s,hint:a,intent:n}=e;return(0,r.jsxs)(X,{className:"p-4",children:[(0,r.jsx)("div",{className:"text-xs uppercase tracking-wide text-[--muted]",children:t}),(0,r.jsx)("div",{className:b("mt-1 text-2xl font-semibold tabular-nums","ok"===n&&"text-emerald-500","warn"===n&&"text-amber-500","err"===n&&"text-red-500"),children:s}),a&&(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-0.5",children:a})]})}function o5(e){let{open:t,onSuccess:s,onOpenChange:a,initialUuid:l}=e,{setUserData:i,setUuid:d,setPassword:c,setEncryptedPassword:u}=s4(),{user:m}=tS(),p=(0,o.jE)(),[h,g]=n.useState(l||""),[f,b]=n.useState(""),[v,y]=n.useState(!1),[j,N]=n.useState(""),[k,C]=n.useState(!1),[_,R]=n.useState(null),[A,T]=n.useState(null),[I,M]=n.useState(null),[P,D]=n.useState(!1),L=n.useRef(null),{data:U,isLoading:$}=(0,eU.I)({...eL,enabled:t&&!!m}),O=(null==U?void 0:U.profiles)??[],F=O.length>0,z=n.useCallback(async(e,t)=>{let a=await em(e,t);i(()=>a.userData),d(e),c(t),u(a.encryptedPassword),s()},[i,d,c,u,s]),V=async e=>{e.preventDefault(),C(!0);try{if(await z(h,f),v&&m)try{await ev(h,f,j.trim()||void 0),p.invalidateQueries({queryKey:eL.queryKey})}catch(e){x.oR.error(e instanceof Error?`Loaded, but not saved: ${e.message}`:"Loaded, but could not be saved as a profile")}}catch(e){x.oR.error(e instanceof Error?e.message:"Failed to load configuration")}finally{C(!1)}},q=n.useCallback(async e=>{R(e.id);try{let t=await ew(e.id);await z(t.uuid,t.password)}catch(t){t instanceof el&&(g(e.uuid),D(!0),p.invalidateQueries({queryKey:eL.queryKey})),x.oR.error(t instanceof Error?t.message:"Failed to open configuration")}finally{R(null)}},[z,p]),B=l?O.find(e=>e.uuid===l&&!e.needsRelink):void 0,K=n.useRef(null);n.useEffect(()=>{t&&B&&K.current!==B.id&&(K.current=B.id,q(B))},[t,B,q]);let H=async e=>{T(e.id);try{await ej(e.id),p.invalidateQueries({queryKey:eL.queryKey}),x.oR.success(`Deleted profile "${e.label}"`)}catch(e){x.oR.error(e instanceof Error?e.message:"Failed to delete profile")}finally{T(null),M(null)}};n.useEffect(()=>{t||(b(""),y(!1),N(""),D(!1),M(null),K.current=null)},[t]),n.useEffect(()=>{l?g(l):g("")},[l]);let G=!$&&(P||!!l&&!B||!F);return(0,r.jsx)(ty,{open:t,onOpenChange:a,title:"Load Configuration",onOpenAutoFocus:l?e=>{var t;
13e.preventDefault(),null==(t=L.current)||t.focus()}:void 0,children:(0,r.jsxs)("div",{className:"space-y-4",children:[m&&$&&(0,r.jsx)("div",{className:"flex justify-center py-2",children:(0,r.jsx)(S,{})}),F&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("p",{className:"text-sm text-[--muted]",children:["Your profiles",m?` (${m.username})`:""]}),(0,r.jsx)("ul",{className:"space-y-1",children:O.map(e=>(null==I?void 0:I.id)===e.id?(0,r.jsxs)("li",{className:"flex flex-wrap items-center gap-2 rounded-[--radius] border border-[--border] px-3 py-2",children:[(0,r.jsxs)("span",{className:"flex-1 min-w-0 text-sm",children:["Delete ",(0,r.jsx)("b",{children:e.label}),"? The configuration itself is kept."]}),(0,r.jsx)(w,{type:"button",intent:"alert-subtle",size:"sm",loading:A===e.id,onClick:()=>H(e),children:"Delete"}),(0,r.jsx)(w,{type:"button",intent:"gray-subtle",size:"sm",disabled:null!==A,onClick:()=>M(null),children:"Cancel"})]},e.id):(0,r.jsxs)("li",{className:"flex items-center gap-2",children:[(0,r.jsxs)(w,{type:"button",intent:"gray-subtle",className:"flex-1 justify-start min-w-0",loading:_===e.id,disabled:null!==_,onClick:()=>q(e),children:[(0,r.jsx)("span",{className:"truncate",children:e.label}),e.alias&&(0,r.jsxs)("span",{className:"ml-2 text-xs text-[--muted] truncate",children:["/u/",e.alias]}),e.needsRelink&&(0,r.jsx)("span",{className:"ml-2 text-xs text-[--red]",children:"needs password"})]}),(0,r.jsx)(E,{type:"button",icon:(0,r.jsx)(tC.id1,{}),intent:"alert-subtle",size:"sm",disabled:null!==_||null!==A,"aria-label":`Delete profile ${e.label}`,onClick:()=>M(e)})]},e.id))}),!G&&(0,r.jsx)(w,{type:"button",intent:"white-link",size:"sm",leftIcon:(0,r.jsx)(tC.zaF,{}),onClick:()=>D(!0),children:"Use a UUID and password"})]}),G&&(0,r.jsxs)("form",{onSubmit:V,className:"space-y-4",children:[(0,r.jsx)(W,{label:"UUID",id:"uuid",name:"username",autoComplete:"username",autoCapitalize:"none",spellCheck:!1,value:h,onValueChange:e=>g(e),placeholder:"Enter your configuration UUID",required:!0,readOnly:!!l,className:l?"opacity-50":void 0}),(0,r.jsx)(Z,{ref:L,label:"Password",id:"password",name:"password",value:f,onValueChange:e=>b(e),placeholder:"Enter your configuration password",required:!0}),m&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(r6,{label:"Save as a profile",value:v,onValueChange:e=>y(!0===e)}),v&&(0,r.jsx)(W,{label:"Name",value:j,onValueChange:N,placeholder:"Optional, defaults to the start of the UUID"})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(w,{type:"button",onClick:()=>{a(!1)},children:"Cancel"}),(0,r.jsx)(w,{type:"submit",loading:k,children:"Load"})]})]})]})})}var o4=s(2447);function o9(e){let{open:t,onOpenChange:s}=e;return(0,r.jsx)(ty,{open:t,onOpenChange:s,title:"Support AIOStreams",children:(0,r.jsxs)("div",{className:"flex flex-col gap-5 items-center text-center p-2",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-2 items-center",children:[(0,r.jsx)("span",{className:"text-3xl",children:"\uD83D\uDC96"}),(0,r.jsx)("h2",{className:"text-xl font-bold",children:"Donate to Me"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground max-w-md",children:"AIOStreams is a solo project built and maintained by me in my free time. If you find it useful, please consider supporting my work. Your donation helps me keep the project alive and improve it for everyone!"})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-3 w-full mt-2",children:[(0,r.jsx)(w,{intent:"alert-subtle",onClick:()=>window.open("https://github.com/sponsors/Viren070","_blank"),leftIcon:(0,r.jsx)(o4.Zak,{}),className:"w-full",children:"GitHub Sponsors"}),(0,r.jsx)(w,{intent:"alert-subtle",onClick:()=>window.open("https://ko-fi.com/Viren070","_blank"),leftIcon:(0,r.jsx)(o4.OnT,{}),className:"w-full",children:"Ko-fi"})]})]})})}function o8(){let e=!e3().isBelowBreakpoint,t=(0,M.Z)(),{selectedMenu:s,setSelectedMenu:a}=as(),l="u">typeof window?window.location.pathname:"",i=tw(!1),o=s4(),d=tw(!1),[c,u]=n.useState(null);n.useEffect(()=>{let e=l.match(/stremio\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\/.*\/configure/);e&&(u(e[1]),d.open())},[l]);let{status:m,error:p,loading:h}=e$(),{mode:g,setMode:f}=tX(),{open:b}=ah(),v=tN({title:"Sign Out",description:"Are you sure you want to sign out?",onConfirm:()=>{o.setUserData(null),o.setUuid(null),o.setPassword(null)}}),y=!!(o.uuid&&o.password);ab(y?{id:"sign-out",label:"Sign Out",icon:(0,r.jsx)(tC.eZR,{}),keywords:["logout","log out"],onSelect:()=>v.open()}:{id:"sign-in",label:"Sign In",icon:(0,r.jsx)(tC.XzR,{}),keywords:["login","log in"],onSelect:()=>d.open()},[y,v,d]),ab({id:"donate",label:"Donate",icon:(0,r.jsx)(tC.uoR,{}),keywords:["support","sponsor"],onSelect:()=>i.open()},[i]),ab({id:"toggle-mode",label:"pro"===g?"Switch to Simple mode":"Switch to Advanced mode",icon:(0,r.jsx)(tC.nMM,{}),keywords:["mode","pro","noob","beginner","advanced"],onSelect:()=>f("pro"===g?"noob":"pro")},[g,f]);let j=[{name:"About",iconType:tC.wfp,isCurrent:"about"===s,id:"about"},{name:"Services",iconType:tC.V0M,isCurrent:"services"===s,id:"services"},{name:"Addons",iconType:tC.DT2,isCurrent:"addons"===s,id:"addons"},{name:"Filters",iconType:tC.Jw7,isCurrent:"filters"===s,id:"filters"},..."pro"===g?[{name:"Sorting",iconType:tC.MFA,isCurrent:"sorting"===s,id:"sorting"}]:[],{name:"Formatter",iconType:tC.fSy,isCurrent:"formatter"===s,id:"formatter"},{name:"Proxy",iconType:tC.nmg,isCurrent:"proxy"===s,id:"proxy"}
13,{name:"Miscellaneous",iconType:tC.nMM,isCurrent:"miscellaneous"===s,id:"miscellaneous"},...(null==m?void 0:m.settings.userAnalyticsEnabled)&&y?[{name:"Stats",iconType:tC.yWU,isCurrent:"stats"===s,id:"stats"}]:[],{name:"Save & Install",iconType:tC.Ruw,isCurrent:"save-install"===s,id:"save-install"}],w=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"mb-4 p-4 pb-0 flex flex-col items-center w-full",children:[(0,r.jsx)("div",{className:"flex items-center gap-2",children:(0,r.jsx)("img",{src:(null==m?void 0:m.settings.alternateDesign)?(null==m?void 0:m.channel)==="nightly"?"/mini-nightly-white.png":"/mini-stable-white.png":o.userData.addonLogo||"/logo.png",alt:"logo",className:"max-w-[90px] max-h-[60px] object-contain p-4"})}),(null==m?void 0:m.settings.alternateDesign)===!1&&(0,r.jsx)("span",{className:"text-xs text-gray-500",children:m?"nightly"===m.channel?"nightly":m.tag:""})]}),(0,r.jsx)(a2,{label:"Search settings",onOpen:b})]}),N=[{name:"Dashboard",iconType:tC.fiy,onClick(e){e.ctrlKey||e.metaKey?window.open("/dashboard","_blank"):t({to:"/dashboard"})}},{name:"Donate",iconType:tC.uoR,onClick:()=>i.open()},...e&&"about"!==s?[{name:y?"Sign Out":"Sign In",iconType:y?tC.eZR:tC.XzR,onClick:()=>y?v.open():d.open()}]:[]];return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(tb,{header:w,items:j,footerItems:N,onItemSelect:e=>{a(e.id)}}),(0,r.jsx)(o5,{open:d.isOpen,onSuccess:()=>{d.close(),x.oR.success("Signed in successfully")},onOpenChange:e=>{e||d.close()},initialUuid:c||void 0}),(0,r.jsx)(tk,{...v}),(0,r.jsx)(o9,{open:i.isOpen,onOpenChange:i.toggle})]})}var o7=s(2780),de=s(8188);let dt=e=>{let{words:t,className:s,style:a,...l}=e,[i,o]=(0,o7.l)(),d=t.split(" ");return(0,n.useEffect)(()=>{o("span",{opacity:1},{duration:2,delay:(0,de.y)(.2)})},[t]),(0,r.jsx)("div",{className:b("font-bold",s),style:a,...l,children:(0,r.jsx)(th.P.div,{ref:i,children:d.map((e,t)=>(0,r.jsxs)(th.P.span,{className:"opacity-0",children:[e," "]},e+t))})})};function ds(e){let{title:t}=e;return(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-[--background]",children:(0,r.jsxs)("div",{className:b("flex flex-col items-center gap-6 transition-opacity duration-300 ease-out","opacity-100"),children:[(0,r.jsx)(C,{className:"w-10 h-10 m-0"}),t&&(0,r.jsx)(dt,{words:t||"Loading...",className:"text-2xl"})]})})}var da=s(8592);function dr(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)}function dn(e){return null==e||Array.isArray(e)&&0===e.length||dr(e)&&0===Object.keys(e).length}function dl(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],a=[],r=new Set(["uuid","trusted","encryptedPassword","showChanges","ip","accessToken"]);if(null==e&&null==t||dn(e)&&dn(t))return a;if(Array.isArray(e)&&Array.isArray(t)){if(e===t)return[];try{if(JSON.stringify(e)===JSON.stringify(t))return[]}catch(e){console.warn("Fast array comparison failed:",e)}let r=s.length>0?s[s.length-1]:"",n="presets"===r,l="catalogModifications"===r,i=e=>{if(!dr(e))return String(e);if(l&&e.id&&e.type)return`${e.id}_${e.type}`;if(e.instanceId)return e.instanceId;if(e.id)return e.id;if(e.pattern)return e.pattern;if(e.condition&&Array.isArray(e.addons))try{return`grouping:${e.condition}:${JSON.stringify(e.addons)}`}catch{return e.condition}if(e.condition)return e.condition;if(e.expression)return e.expression;if(Array.isArray(e.addons))try{return`addons:${JSON.stringify(e.addons)}`}catch{return null}return e.key?e.key:e.name?e.name:null},o=e.map(i),d=t.map(i);if(o.every(e=>null!==e)&&d.every(e=>null!==e)&&new Set(o).size===e.length&&new Set(d).size===t.length){let r=new Map,o=[];e.forEach(e=>{let t=i(e);r.set(t,e),o.push(t)});let d=new Map,c=[];t.forEach(e=>{let t=i(e);d.set(t,e),c.push(t)});let u=e=>{var t;let s=d.get(e)||r.get(e);if((null==s?void 0:s.expression)&&(null==s?void 0:s.score)!==void 0)return`${s.expression} (Score: ${s.score})`;if((null==s?void 0:s.addons)&&Array.isArray(s.addons)){let e=s.addons[0]||"",t=s.addons.length,a=e?` (${e}${t>1?` +${t-1}`:""})`:"";return`Group: ${s.condition||"true"}${a}`}return(null==s?void 0:s.name)?l&&s.type?`${s.name} (${s.type})`:s.name:(null==s||null==(t=s.options)?void 0:t.name)||(null==s?void 0:s.instanceId)||(null==s?void 0:s.id)||e};r.forEach((t,r)=>{if(!d.has(r)){let l=e.findIndex(e=>i(e)===r);a.push({path:[...s,`[${l}]`],type:"REMOVE",oldValue:n?`Deleted: ${u(r)}`:t})}}),d.forEach((e,n)=>{let l=t.findIndex(e=>i(e)===n);if(r.has(n)){let t=r.get(n);a.push(...dl(t,e,[...s,`[${l}]`]))}else a.push({path:[...s,`[${l}]`],type:"ADD",newValue:e})});let m=o.filter(e=>c.includes(e)),p=c.filter(e=>o.includes(e));return(m.length!==p.length||m.some((e,t)=>e!==p[t]))&&a.push({path:[...s],type:"CHANGE",oldValue:o.map(u),newValue:c.map(u)}),a}let c=0,u=0;for(;c<e.length||u<t.length;){if(c>=e.length){a.push({path:[...s,`[${u}]`],type:"ADD",newValue:t[u]}),u++;continue}if(u>=t.length){a.push({path:[...s,`[${c}]`],type:"REMOVE",oldValue:e[c]}),c++;continue}let r=dl(e[c],t[u],[...s,`[${u}]`]);if(0===r.length){c++,u++;continue}let n=!1;c+1<e.length&&0===dl(e[c+1],t[u],[]).length&&(n=!0);let l=!1;u+1<t.length&&0===dl(e[c],t[u+1],[]).length&&(l=!0),n&&!l?(a.push({path:[...s,`[${c}]`],type:"REMOVE",oldValue:e[c]}),c++):(l&&!n?a.push({path:[...s,`[${u}]`],type:"ADD",newValue:t[u]}):(a.push(...r),c++),u++)}return a}if(!dr(e)||!dr(t)){if(e===t)return a;try{if(JSON.stringify(e)===JSON.stringify(t))return a}catch{}return[{path:s,type:"CHANGE",oldValue:e,newValue:t}]}let n=Object.keys(e),l=Object.keys(t);for(let l of n)if(!r.has(l))if(Object.prototype.hasOwnProperty.call(t,l))a.push(...dl(e[l],t[l],[...s,l]));else{if(null==e[l]||dn(e[l]))continue;a.push({path:[...s,l],type:"REMOVE",oldValue:e[l]}
13)}for(let n of l)if(!r.has(n)&&!Object.prototype.hasOwnProperty.call(e,n)){if(null==t[n]||dn(t[n]))continue;a.push({path:[...s,n],type:"ADD",newValue:t[n]})}return a}function di(e){var t;if(!e)return e;let s={...e};return delete s.ip,delete s.uuid,delete s.accessToken,delete s.trusted,delete s.encryptedPassword,delete s.showChanges,(null==(t=s.parentConfig)?void 0:t.password)&&(s.parentConfig={...s.parentConfig,password:"[hidden]"}),function e(t){return Array.isArray(t)?t.map(e):dr(t)?Object.keys(t).sort().reduce((s,a)=>(s[a]=e(t[a]),s),{}):t}(s)}function dd(e,t){if(!e||!e.groups)return e;let s={...e,groups:{...e.groups}};return s.groups.groupings&&(s.groups.groupings=s.groups.groupings.map(e=>Array.isArray(e.addons)?{...e,addons:e.addons.map(e=>{var s;let a=null==t?void 0:t.find(t=>{var s;return t.instanceId===e||(null==(s=t.options)?void 0:s.id)===e});return(null==a||null==(s=a.options)?void 0:s.name)||e})}:e)),s}function dc(e,t){let s=[...(null==e?void 0:e.presets)??[],...(null==t?void 0:t.presets)??[]],a=di(e),r=di(t),n=dd(a,s),l=dd(r,s);return{diffs:dl(n,l),processedOld:n,processedNew:l}}function du(e,t){let s=e.split("\n"),a=t.split("\n");return s.length*a.length>25e5?[{type:"remove",content:`[Content too large to diff: ${s.length} lines]`,oldLineNumber:1,truncated:!0},{type:"add",content:`[Content too large to diff: ${a.length} lines]`,newLineNumber:1,truncated:!0}]:function(e,t){let s=e.length,a=t.length,r=Array(s+1).fill(0).map(()=>Array(a+1).fill(0));for(let n=1;n<=s;n++)for(let s=1;s<=a;s++)e[n-1]===t[s-1]?r[n][s]=r[n-1][s-1]+1:r[n][s]=Math.max(r[n-1][s],r[n][s-1]);let n=[],l=s,i=a;for(;l>0||i>0;)l>0&&i>0&&e[l-1]===t[i-1]?(n.push({type:"same",content:e[l-1],oldLineNumber:l,newLineNumber:i}),l--,i--):i>0&&(0===l||r[l][i-1]>=r[l-1][i])?(n.push({type:"add",content:t[i-1],newLineNumber:i}),i--):l>0&&(0===i||r[l][i-1]<r[l-1][i])&&(n.push({type:"remove",content:e[l-1],oldLineNumber:l}),l--);return n.reverse()}(s,a)}var dm=s(6221),dp=s(440);function dh(e){let{diffs:t,valueFormatter:s,oldValue:a,newValue:l,annotations:i,pathFormatter:o}=e,d=e=>{if(s){let t=s(e);if(null!=t)return t}if(void 0===e)return"(undefined)";if(null===e)return"(null)";if("object"==typeof e&&null!==e)try{return JSON.stringify(e,null,2)}catch{return"[Circular Reference]"}return String(e)},c=(0,n.useMemo)(()=>{if(!a&&!l)return[];try{let e=a?JSON.stringify(a,null,2):"",t=l?JSON.stringify(l,null,2):"";return du(e,t)}catch(e){return console.error("Failed to stringify JSON for diff:",e),du("","")}},[a,l]),u=(0,n.useMemo)(()=>{if(!i||0===i.size)return t;let e={critical:0,warning:1,info:2};return[...t].sort((t,s)=>{let a=t.path.join(".").replace(/\.\[/g,"["),r=s.path.join(".").replace(/\.\[/g,"["),n=i.get(a),l=i.get(r);return n&&!l?-1:!n&&l?1:n&&l?(e[n.severity??"info"]??3)-(e[l.severity??"info"]??3):0})},[t,i]);return 0===t.length?(0,r.jsx)("div",{className:"text-center p-4 text-[--muted]",children:"No changes detected."}):(0,r.jsx)("div",{className:"w-full mt-4",children:(0,r.jsxs)(rF,{defaultValue:"visual",className:"w-full",children:[(0,r.jsxs)(rz,{className:"mb-4 grid w-full grid-cols-2",children:[(0,r.jsx)(rV,{value:"visual",children:"Visual"}),(0,r.jsx)(rV,{value:"json",children:"Raw JSON"})]}),(0,r.jsx)(rq,{value:"visual",className:"max-h-[60vh] overflow-y-auto pr-2 custom-scrollbar",children:(0,r.jsx)("div",{className:"space-y-3",children:u.map((e,t)=>{var s;let a,n=e.path.join(".").replace(/\.\[/g,"["),l=o?o(e.path):n,c=null==i?void 0:i.get(n);return(0,r.jsxs)("div",{className:"p-3 bg-gray-800/50 rounded-lg border border-gray-700 relative group",children:[(0,r.jsx)("div",{className:"flex items-center justify-between mb-2",children:(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,r.jsx)(dg,{type:e.type}),c&&(0,r.jsx)("span",{className:`px-2 py-0.5 text-[10px] font-semibold rounded border ${c.className??"bg-blue-500/10 text-blue-400 border-blue-500/20"}`,children:c.label}),(0,r.jsx)("span",{className:"font-mono text-sm text-gray-300",children:l})]})}),(null==c?void 0:c.description)&&(0,r.jsx)("div",{className:`mb-2 text-xs pl-2 border-l-2 border-current/50 italic ${(a=null==(s=c.className)?void 0:s.match(/\btext-\S+-\d+\b/))?a[0]:"text-gray-400"}`,children:c.description}),(0,r.jsxs)("div",{className:`grid gap-4 text-sm ${"CHANGE"===e.type?"grid-cols-2":"grid-cols-1"}`,children:["ADD"!==e.type&&(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("div",{className:"text-xs text-[--muted] uppercase",children:"Old"}),(0,r.jsx)("div",{className:"p-2 bg-red-900/20 text-red-200 rounded break-all border border-red-900/30 font-mono text-xs whitespace-pre-wrap",children:d(e.oldValue)})]}),"REMOVE"!==e.type&&(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("div",{className:"text-xs text-[--muted] uppercase",children:"New"}),(0,r.jsx)("div",{className:"p-2 bg-green-900/20 text-green-200 rounded break-all border border-green-900/30 font-mono text-xs whitespace-pre-wrap",children:d(e.newValue)})]})]})]},`${e.path.join(".")}-${e.type}-${t}`)})})}),(0,r.jsx)(rq,{value:"json",className:"relative max-h-[60vh] overflow-hidden rounded-md border border-gray-800 bg-gray-950/50 flex flex-col group",children:(0,r.jsx)(dx,{textDiffs:c})})]})})}function dx(e){let{textDiffs:t}
13=e,[s,a]=(0,n.useState)(0),l=(0,n.useRef)(null),i=(0,n.useRef)([]),o=(0,n.useMemo)(()=>{let e=[],s=!1;return t.forEach((t,a)=>{"same"!==t.type?s||(e.push(a),s=!0):s=!1}),e},[t]),d=(0,n.useCallback)(e=>{let t=o[e];void 0!==t&&i.current[t]&&l.current&&i.current[t].scrollIntoView({behavior:"smooth",block:"center"}),a(e)},[o]);return(0,n.useEffect)(()=>{let e;return a(0),i.current=i.current.slice(0,t.length),o.length>0&&(e=setTimeout(()=>d(0),100)),()=>{e&&clearTimeout(e)}},[t,o,d]),(0,n.useEffect)(()=>{t.some(e=>e.truncated)&&x.oR.warning("Large File Detected: Diff simplified for performance.",{id:"large-file-warning"})},[t]),(0,r.jsxs)(r.Fragment,{children:[o.length>0&&(0,r.jsxs)("div",{className:"absolute top-4 right-4 z-10 flex items-center gap-2 bg-gray-900/90 border border-gray-700 rounded-md p-1.5 shadow-lg backdrop-blur-sm opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:[(0,r.jsxs)("span",{className:"text-xs text-gray-400 font-mono px-2 select-none",children:[s+1," / ",o.length]}),(0,r.jsx)("div",{className:"h-4 w-px bg-gray-700 mx-1"}),(0,r.jsx)(w,{className:"h-7 w-7 p-0 hover:bg-gray-800 bg-transparent",onClick:()=>{d((s-1+o.length)%o.length)},title:"Previous Change","aria-label":"Previous Change",children:(0,r.jsx)(dm.A,{className:"h-4 w-4"})}),(0,r.jsx)(w,{className:"h-7 w-7 p-0 hover:bg-gray-800 bg-transparent",onClick:()=>{d((s+1)%o.length)},title:"Next Change","aria-label":"Next Change",children:(0,r.jsx)(dp.A,{className:"h-4 w-4"})})]}),(0,r.jsx)("div",{ref:l,className:"overflow-y-auto custom-scrollbar p-4 flex-1 font-mono text-xs",children:(0,r.jsxs)("div",{className:"flex flex-col",children:[t.map((e,t)=>(0,r.jsxs)("div",{ref:e=>{i.current[t]=e},className:`flex ${"add"===e.type?"bg-green-900/20 text-green-300":"remove"===e.type?"bg-red-900/20 text-red-300":"text-gray-400"} ${t===o[s]?"ring-1 ring-blue-500/50":""}`,children:[(0,r.jsx)("div",{className:"w-8 shrink-0 text-right pr-3 select-none text-gray-600 border-r border-gray-800 mr-2",children:e.oldLineNumber||" "}),(0,r.jsx)("div",{className:"w-8 shrink-0 text-right pr-3 select-none text-gray-600 border-r border-gray-800 mr-2",children:e.newLineNumber||" "}),(0,r.jsxs)("pre",{className:"whitespace-pre-wrap break-all flex-1",children:["add"===e.type?"+":"remove"===e.type?"-":" "," ",e.content]})]},t)),0===t.length&&(0,r.jsx)("div",{className:"text-center p-4 text-[--muted]",children:"No raw JSON available for comparison."})]})})]})}function dg(e){let{type:t}=e,s={CHANGE:"bg-yellow-500/10 text-yellow-500 border-yellow-500/20",ADD:"bg-green-500/10 text-green-500 border-green-500/20",REMOVE:"bg-red-500/10 text-red-500 border-red-500/20"}[t]||"bg-gray-500/10 text-gray-500 border-gray-500/20";return(0,r.jsx)("span",{className:`px-2 py-0.5 text-[10px] font-bold rounded border ${s}`,children:t})}function df(e){let{oldConfig:t,newConfig:s}=e,a=(0,n.useMemo)(()=>[...(null==t?void 0:t.presets)??[],...(null==s?void 0:s.presets)??[]],[null==t?void 0:t.presets,null==s?void 0:s.presets]),l=(0,n.useMemo)(()=>{let e;return e=t=>{if("string"==typeof t){let e=null==a?void 0:a.find(e=>{if(e.instanceId===t)return!0;let s=e.options;return(null==s?void 0:s.id)===t});if(e){let t=e.options;if((null==t?void 0:t.name)&&"string"==typeof t.name)return t.name}return t}return Array.isArray(t)?t.map(e):t&&"object"==typeof t?Object.fromEntries(Object.entries(t).map(t=>{let[s,a]=t;return[s,e(a)]})):t},t=>{let s=e(t);if("object"==typeof s&&null!==s)try{return JSON.stringify(s,null,2)}catch{return"[Circular Reference]"}return String(s)}},[a]),{diffs:i,processedOld:o,processedNew:d}=(0,n.useMemo)(()=>dc(t,s),[t,s]);return(0,r.jsx)(dh,{diffs:i,valueFormatter:l,oldValue:o,newValue:d})}function db(e){return`${e.name} (${e.type})`}function dv(e){if(null==e)return String(e);if(dy(e))return db(e);if(Array.isArray(e)){if(e.every(e=>"string"==typeof e))return e.join("\n");if(e.every(dy))return e.map(db).join("\n")}if("object"==typeof e)try{return JSON.stringify(e,null,2)}catch{return"[object]"}return String(e)}function dy(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)&&"string"==typeof e.type&&"string"==typeof e.id&&"string"==typeof e.name}function dj(e){let{id:t,version:s,description:a,name:r,logo:n,behaviorHints:l,stremioAddonsConfig:i,...o}=e;return o}function dw(e,t){let s=dj(e),a=dj(t),{catalogs:r,...n}=s,{catalogs:l,...i}=a,o=[...function(e){let t=[],s=new Map,a=new Map;for(let r of e){let e=r.path[r.path.length-1]??"",n="idPrefixes"===r.path[r.path.length-2]&&/^\[\d+\]$/.test(e);
13if(n&&"ADD"===r.type){let e=r.path.slice(0,-1),t=e.join("\0");s.has(t)||s.set(t,{parentPath:e,values:[]}),s.get(t).values.push(r.newValue);continue}if(n&&"REMOVE"===r.type){let e=r.path.slice(0,-1),t=e.join("\0");a.has(t)||a.set(t,{parentPath:e,values:[]}),a.get(t).values.push(r.oldValue);continue}"CHANGE"===r.type&&"idPrefixes"===r.path[r.path.length-1]&&Array.isArray(r.oldValue)&&Array.isArray(r.newValue)||t.push(r)}for(let[,{parentPath:e,values:a}]of s)t.push({path:e,type:"ADD",newValue:a});for(let[,{parentPath:e,values:s}]of a)t.push({path:e,type:"REMOVE",oldValue:s});return t}(dl(n,i)),...function(e,t){let s=e=>`${e.type}:${e.id}`,a=e.map(s),r=t.map(s);if(new Set(a).size!==e.length||new Set(r).size!==t.length)return dl({catalogs:e},{catalogs:t}).map(e=>({...e}));let n=new Map(e.map(e=>[s(e),e])),l=new Map(t.map(e=>[s(e),e])),i=[];for(let e of a)if(!l.has(e)){let t=a.indexOf(e);i.push({path:["catalogs",`[${t}]`],type:"REMOVE",oldValue:n.get(e)})}for(let e of r){let t=r.indexOf(e);if(n.has(e))for(let s of dl(n.get(e),l.get(e)))i.push({...s,path:["catalogs",`[${t}]`,...s.path]});else i.push({path:["catalogs",`[${t}]`],type:"ADD",newValue:l.get(e)})}let o=a.filter(e=>l.has(e)),d=r.filter(e=>n.has(e));if(o.some((e,t)=>e!==d[t])){let e=e=>{let t=l.get(e)??n.get(e);return t?db(t):e};i.push({path:["catalogs"],type:"CHANGE",oldValue:a.map(e),newValue:r.map(e)})}return i}(e.catalogs??[],t.catalogs??[])],d=function(e,t,s){let a=new Map;for(let o of e){var r,n,l,i;let e=o.path.join(".").replace(/\.\[/g,"["),d=o.path[0];if("catalogs"===d){let i=1===o.path.length&&"CHANGE"===o.type,d="ADD"===o.type&&2===o.path.length,c="REMOVE"===o.type&&2===o.path.length,u=o.path.length>=3;if(i)a.set(e,{label:"⚑ CATALOG ORDER",className:"bg-amber-500/10 text-amber-400 border-amber-500/20",severity:"warning",description:"Catalog ordering has changed. Stremio will display them in the old order until you reinstall."});else if(d){let t=o.newValue,s=t?db(t):"Unknown";a.set(e,{label:"⚑ NEW CATALOG",className:"bg-green-500/10 text-green-400 border-green-500/20",severity:"critical",description:`"${s}" was added. It won't appear in Stremio until you reinstall.`})}else if(c){let t=o.oldValue,s=t?db(t):"Unknown";a.set(e,{label:"⚑ CATALOG REMOVED",className:"bg-red-500/10 text-red-400 border-red-500/20",severity:"critical",description:`"${s}" was removed. It will appear empty or broken in Stremio until you reinstall.`})}else if(u){let i=null==(r=o.path[1])?void 0:r.match(/\[(\d+)\]/),d=i?parseInt(i[1],10):-1,c=d>=0?(null==(n=s.catalogs)?void 0:n[d])??(null==(l=t.catalogs)?void 0:l[d]):void 0,u=c?db(c):"";o.path.length>=4&&"extra"===o.path[2]&&"isRequired"===o.path[o.path.length-1]?a.set(e,{label:"⚑ EXTRA REQUIRED",className:"bg-amber-500/10 text-amber-400 border-amber-500/20",severity:"warning",description:`An extra parameter's "required" status changed in catalog${u?`: ${u}`:""}.`}):a.set(e,{label:"⚑ CATALOG CHANGED",className:"bg-amber-500/10 text-amber-400 border-amber-500/20",severity:"warning",description:u?`In catalog: ${u}`:void 0})}continue}if("idPrefixes"===d){("ADD"===o.type||"CHANGE"===o.type&&function(e,t){let s=new Set(t??[]);return Array.isArray(e.newValue)?e.newValue.some(e=>!s.has(e)):"string"==typeof e.newValue&&!s.has(e.newValue)}(o,t.idPrefixes))&&a.set(e,{label:"⚑ NEW ID PREFIXES",className:"bg-blue-500/10 text-blue-400 border-blue-500/20",severity:"critical",description:"New ID prefixes were added to the manifest. Stremio won't know that this install supports these new prefixes, so it won't query AIOStreams for matching content until you reinstall."});continue}if("resources"===d&&o.path.some(e=>"idPrefixes"===e)){if("ADD"===o.type||"CHANGE"===o.type){let r=null==(i=o.path[1])?void 0:i.match(/\[(\d+)\]/),n=r?parseInt(r[1],10):-1,l=n>=0?(s.resources??[])[n]??(t.resources??[])[n]:void 0,d="string"==typeof l?l:"string"==typeof(null==l?void 0:l.name)?l.name:"this resource";a.set(e,{label:"⚑ NEW ID PREFIXES",className:"bg-blue-500/10 text-blue-400 border-blue-500/20",severity:"critical",description:`Stremio won't know that this install supports the new ID prefix(es) for the ${d} resource. Until you reinstall, Stremio won't query AIOStreams for ${d} content with these new prefixes.`})}continue}
13if("resources"===d&&"ADD"===o.type&&2===o.path.length){let t=o.newValue,s="string"==typeof t?t:"string"==typeof(null==t?void 0:t.name)?t.name:"Unknown";a.set(e,{label:"⚑ NEW RESOURCE",className:"bg-purple-500/10 text-purple-400 border-purple-500/20",severity:"critical",description:`${s} support was added. Stremio won't request ${s} content from AIOStreams until you reinstall — e.g. if subtitles were added, they won't appear until then.`})}}return a}(o,e,t);return{diffs:o,annotations:d}}function dN(e){let{oldManifest:t,newManifest:s}=e,{diffs:a,annotations:l}=(0,n.useMemo)(()=>dw(t,s),[t,s]),i=(0,n.useMemo)(()=>e=>e.map((a,r)=>{let n=a.match(/^\[(\d+)\]$/);if(!n)return a;let l=parseInt(n[1],10);if("resources"===e[r-1]){let e=((null==s?void 0:s.resources)??[])[l]??((null==t?void 0:t.resources)??[])[l];if(e&&"object"==typeof e&&"string"==typeof e.name)return`["${e.name}"]`}return a}).reduce((e,t,s)=>0===s?t:t.startsWith("[")?e+t:e+"."+t,""),[t,s]);return 0===a.length?(0,r.jsx)("div",{className:"text-center p-4 text-[--muted] text-sm",children:"No meaningful manifest changes detected."}):(0,r.jsx)(dh,{diffs:a,valueFormatter:dv,oldValue:t,newValue:s,annotations:l,pathFormatter:i})}function dk(e){let{oldManifest:t,newManifest:s}=e,{diffs:a,annotations:l}=(0,n.useMemo)(()=>dw(t,s),[t,s]),i=(0,n.useMemo)(()=>{let e={critical:0,warning:1,info:2};return a.map(e=>{let t=e.path.join(".").replace(/\.\[/g,"["),s=l.get(t);return s?{diff:e,annotation:s,pathKey:t}:null}).filter(e=>null!==e).sort((t,s)=>(e[t.annotation.severity??"info"]??3)-(e[s.annotation.severity??"info"]??3))},[a,l]);if(0===a.length)return null;let o=i.some(e=>"critical"===e.annotation.severity),d=!o&&i.some(e=>"warning"===e.annotation.severity);return(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(nU,{intent:o?"alert":d?"warning":"info",isClosable:!1,description:o?"Reinstall required - some changes will not take effect in Stremio until you reinstall.":d?"Reinstall recommended to apply all changes correctly.":"No significant changes - reinstall is not required for expected functionality."}),i.length>0&&(0,r.jsx)("div",{className:"space-y-1.5",children:i.map((e,t)=>(0,r.jsxs)("div",{className:"p-2.5 rounded-lg border border-[--border] bg-gray-800/30 space-y-1",children:[(0,r.jsx)("span",{className:`inline-block px-2 py-0.5 text-[10px] font-semibold rounded border ${e.annotation.className??""}`,children:e.annotation.label}),e.annotation.description&&(0,r.jsx)("p",{className:"text-xs text-[--muted]",children:e.annotation.description})]},t))})]})}let dS=e=>`aiostreams-manifest-all-dismissed-${e}`,dC=e=>`aiostreams-manifest-insignificant-dismissed-${e}`,d_=n.createContext(void 0);function dR(e){var t;let{children:s}=e,{userData:a,setUserData:l,uuid:i,password:o,encryptedPassword:d}=s4(),{status:c}=e$(),{setSelectedMenu:u}=as(),m=(null==c||null==(t=c.settings)?void 0:t.baseUrl)||("u">typeof window?window.location.origin:""),[p,h]=n.useState(!1),[g,f]=n.useState(!1),[b,v]=n.useState(!1),[y,j]=n.useState(!1),[N,k]=n.useState(!1),[S,C]=n.useState(!1),[_,R]=n.useState(!1),[A,T]=n.useState(null),[I,E]=n.useState(null),[M,P]=n.useState(null),[D,L]=n.useState(null),U=n.useRef(!1),$=i&&d?/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(i)?`${m}/stremio/${i}/${d}/manifest.json`:`${m}/stremio/u/${i}/manifest.json`:null;n.useEffect(()=>{$?eI($).then(E).catch(e=>{console.warn("Failed to fetch manifest:",e)}):E(null)}
13,[i,d]);let O=n.useRef(null);O.current=I;let F=n.useCallback(async()=>{if($&&i)try{let e=await eI($),t=dS(i),s=localStorage.getItem(t),a=O.current;if(null!==a&&function(e,t){let{diffs:s}=dw(e,t);return s.length>0}(a,e)&&"true"!==s){let t=function(e,t){let{annotations:s}=dw(e,t);return Array.from(s.values()).some(e=>"critical"===e.severity||"warning"===e.severity)}(a,e),s=dC(i),r="true"===localStorage.getItem(s);if(!t&&r)return void E(e);R(t),P(e),j(!1),k(!1),v(!0)}else E(e)}catch{}},[$,i]),z=n.useCallback(async e=>{let t=((null==e?void 0:e.skipDiff)??!1)||U.current;if(U.current=!1,!i||!o){u("save-install"),x.oR.info("Please create a configuration first");return}let s=!1;if(!t&&(null==a?void 0:a.showChanges)){h(!0);try{let e=(await em(i,o)).userData,{diffs:t}=dc(e,a);if(0===t.length)x.oR.info("No changes detected"),s=!0,h(!1);else{T(e),f(!0),h(!1);return}}catch(e){console.error("Error checking for changes:",e),x.oR.warning("Error checking for changes. Proceeding with save."),h(!1)}}h(!0);try{await eh(i,a,o),s||x.oR.success("Configuration updated successfully"),L(I),await F()}catch(e){x.oR.error(e instanceof Error?e.message:"Failed to save configuration")}finally{h(!1)}},[i,o,a,c,F,u,l]),V=()=>{y&&i&&localStorage.setItem(dS(i),"true"),N&&i&&!_&&localStorage.setItem(dC(i),"true"),E(M),v(!1),C(!1),setTimeout(()=>{P(null),L(null)},300)};return(0,r.jsxs)(d_.Provider,{value:{handleSave:z,loading:p},children:[s,(0,r.jsx)(ty,{open:g,onOpenChange:f,title:"Confirm Changes",description:"Review the changes you are about to make to your configuration.",contentClass:"max-w-4xl",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(df,{oldConfig:A,newConfig:a}),(0,r.jsxs)("div",{className:"flex justify-between pt-4",children:[(0,r.jsx)(w,{intent:"alert",onClick:()=>{A&&(l(e=>({...s3,...A,uuid:e.uuid,encryptedPassword:e.encryptedPassword,trusted:e.trusted,accessKey:e.accessKey,ip:e.ip,showChanges:e.showChanges})),x.oR.success("Changes reverted"),f(!1))},disabled:p,children:"Reset Changes"}),(0,r.jsxs)("div",{className:"flex gap-3",children:[(0,r.jsx)(w,{intent:"gray-outline",onClick:()=>f(!1),disabled:p,children:"Cancel"}),(0,r.jsx)(w,{intent:"white",onClick:()=>{f(!1),z({skipDiff:!0})},loading:p,children:"Confirm & Save"})]})]})]})}),(0,r.jsx)(ty,{open:b,onOpenChange:e=>{e||V()},title:"Manifest Changed",description:"Your addon manifest has changed since your last install.",contentClass:"max-w-xl",children:(0,r.jsxs)("div",{className:"space-y-4",children:[D&&M&&(0,r.jsx)(dk,{oldManifest:D,newManifest:M}),D&&M&&(0,r.jsx)(w,{intent:"primary",className:"w-full text-sm",onClick:()=>C(!0),children:"See what changed →"}),!_&&(0,r.jsxs)("div",{className:"flex items-center justify-between p-3 bg-gray-800/50 rounded-lg",children:[(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("div",{className:"text-sm font-medium text-white",children:"Don't show for insignificant changes"}),(0,r.jsx)("div",{className:"text-xs text-gray-400 mt-1",children:"Skip this notice when there are no significant manifest changes"})]}),(0,r.jsx)(rs,{id:"dont-show-insignificant-again",value:N,onValueChange:k})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between p-3 bg-gray-800/50 rounded-lg",children:[(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("div",{className:"text-sm font-medium text-white",children:"Don't show this again"}),(0,r.jsx)("div",{className:"text-xs text-gray-400 mt-1",children:"Skip this notice for all future manifest changes"})]}),(0,r.jsx)(rs,{id:"dont-show-manifest-again",value:y,onValueChange:j})]}),(0,r.jsx)("div",{className:"flex justify-end",children:(0,r.jsx)(w,{intent:"white",onClick:V,children:"OK"})})]})}),(0,r.jsx)(ty,{open:S,onOpenChange:C,title:"What Changed",description:"Detailed diff of your manifest changes.",contentClass:"max-w-4xl",children:D&&M&&(0,r.jsx)(dN,{oldManifest:D,newManifest:M})})]})}function dA(){let e=n.useContext(d_);if(void 0===e)throw Error("useSave must be used within a SaveProvider");return e}function dT(e){let{middleContent:t}=e,{setSelectedMenu:s,selectedMenu:a,previousMenu:n,nextMenu:l,firstMenu:i,lastMenu:o}=as(),{handleSave:d,loading:c}=dA(),{uuid:u,password:m}=s4();return(0,r.jsxs)("div",{className:"flex flex-1 gap-2 items-center",children:[(0,r.jsx)(w,{leftIcon:(0,r.jsx)(da.QVr,{}),intent:"white",size:"md",hideTextOnSmallScreen:!0,rounded:!0,className:"min-w-[60px] md:min-w-[120px]",onClick:()=>{n()},onMouseDown:e=>{if(0===e.button){let e=setTimeout(()=>{s(i)},500),t=()=>{clearTimeout(e),window.removeEventListener("mouseup",t)};window.addEventListener("mouseup",t)}},disabled:a===i,children:"Previous"}),t,!!(u&&m)&&(0,r.jsx)(E,{icon:(0,r.jsx)(tC.Ruw,{}),intent:"white-outline",rounded:!0,size:"md",loading:c,onClick:()=>d()}),(0,r.jsx)(w,{rightIcon:(0,r.jsx)(da.Z0P,{}),intent:"white",size:"md",hideTextOnSmallScreen:!0,rounded:!0,className:"min-w-[60px] md:min-w-[120px]",onClick:()=>{l()},onMouseDown:e=>{if(0===e.button){let e=setTimeout(()=>{s(o)},500),t=()=>{clearTimeout(e),window.removeEventListener("mouseup",t)};window.addEventListener("mouseup",t)}},disabled:a===o,children:"Next"})]})}let dI={root:(0,h.F)(["UI-Accordion__root"]),header:(0,h.F)(["UI-Accordion__header","flex text-lg"]),trigger:(0,h.F)(["UI-Accordion__trigger","flex flex-1 items-center justify-between px-4 py-2 font-medium transition-all hover:bg-[--subtle] [&[data-state=open]>svg]:rotate-180"]),triggerIcon:(0,h.F)(["UI-Accordion__triggerIcon","h-4 w-4 shrink-0 transition-transform duration-200"]),item:(0,h.F)(["UI-Accordion__item",""]),contentContainer:(0,h.F)(["UI-Accordion__contentContainer","overflow-hidden transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"]),content:(0,h.F)(["UI-Accordion__content","p-4"])},dE=n.createContext({}),dM=n.forwardRef((e,t)=>
13{let{className:s,headerClass:a,triggerClass:n,triggerIconClass:l,contentContainerClass:i,contentClass:o,itemClass:d,...c}=e;return(0,r.jsx)(dE.Provider,{value:{itemClass:d,headerClass:a,triggerClass:n,triggerIconClass:l,contentContainerClass:i,contentClass:o},children:(0,r.jsx)(e7.bL,{ref:t,className:b(dI.root(),s),...c})})});dM.displayName="Accordion";let dP=n.forwardRef((e,t)=>{let{className:s,...a}=e,{itemClass:l}=n.useContext(dE);return(0,r.jsx)(e7.q7,{ref:t,className:b(dI.item(),l,s),...a})});dP.displayName="AccordionItem";let dD=n.forwardRef((e,t)=>{let{className:s,headerClass:a,triggerIconClass:l,children:i,...o}=e,{headerClass:d,triggerClass:c,triggerIconClass:u}=n.useContext(dE);return(0,r.jsx)(e7.Y9,{className:b(dI.header(),d,a),children:(0,r.jsxs)(e7.l9,{ref:t,className:b(dI.trigger(),c,s),...o,children:[i,(0,r.jsx)("svg",{className:b(dI.triggerIcon(),u,l),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M19 9l-7 7-7-7"})})]})})});dD.displayName="AccordionTrigger";let dL=n.forwardRef((e,t)=>{let{className:s,contentContainerClass:a,children:l,...i}=e,{contentContainerClass:o,contentClass:d}=n.useContext(dE);return(0,r.jsx)(e7.UC,{ref:t,className:b(dI.contentContainer(),o,a),...i,children:(0,r.jsx)("div",{className:b(dI.content(),d,s),children:l})})});dL.displayName="AccordionContent";let dU={1:"grid-cols-1",2:"grid-cols-2",3:"grid-cols-3",4:"grid-cols-4",5:"grid-cols-5"},d$={enter:e=>({x:e>=0?40:-40,opacity:0}),center:{x:0,opacity:1},exit:e=>({x:e>=0?-40:40,opacity:0})};function dO(e){let{tabs:t,activeTab:s,onTabChange:a,defaultMobileOpen:l="",revealOnChange:i=!1}=e,o=t.length,d=t.findIndex(e=>e.value===s),c=d>=0?t[d].content:null,u=n.useRef(d),m=d===u.current?0:d>u.current?1:-1;n.useEffect(()=>{u.current=d},[d]);let p=n.useRef(null),h=n.useRef(!1);n.useEffect(()=>{if(!i)return;if(!h.current){h.current=!0;return}let e=p.current;if(!e)return;let t=e.getBoundingClientRect(),s=window.innerHeight;t.height+32<=s&&t.bottom+32>s&&window.scrollBy({top:t.bottom+32-s,behavior:"smooth"})},[s,i]);let[x,g]=n.useState(l||s);return n.useEffect(()=>{g(s)},[s]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"sm:hidden space-y-2",children:(0,r.jsx)(dM,{type:"single",collapsible:!0,value:x,onValueChange:e=>{g(e),e&&a(e)},children:t.map(e=>(0,r.jsxs)(dP,{value:e.value,className:"border border-[--border] rounded-[--radius-md] overflow-hidden mb-2",children:[(0,r.jsx)(dD,{children:(0,r.jsxs)("span",{className:"flex items-center gap-2 text-sm font-medium",children:[e.icon,e.label]})}),(0,r.jsx)(dL,{children:(0,r.jsx)("div",{ref:t=>{t&&(t.inert=x!==e.value)},className:"space-y-4",children:e.content})})]},e.value))})}),(0,r.jsxs)("div",{className:"hidden sm:block",children:[(0,r.jsx)(rF,{value:s,onValueChange:a,className:"w-full",children:(0,r.jsx)(rz,{className:`grid w-full border-b border-[--border] ${dU[o]??"grid-cols-4"}`,children:t.map(e=>(0,r.jsxs)(rV,{value:e.value,className:"flex items-center gap-1.5",children:[e.icon,e.label]},e.value))})}),(0,r.jsx)("div",{ref:p,className:"relative mt-4 overflow-hidden",children:(0,r.jsx)(tp.N,{mode:"popLayout",initial:!1,custom:m,children:(0,r.jsx)(th.P.div,{custom:m,variants:d$,initial:"enter",animate:"center",exit:"exit",transition:{duration:.3,ease:[.32,.72,0,1]},className:"space-y-4 p-1",children:c},s)})})]})]})}function dF(e){let{section:t}=e;return(0,r.jsx)(to,{trigger:(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium bg-brand-500/10 text-[--brand] border border-brand-500/20 cursor-default select-none",children:[(0,r.jsx)(nD.ayE,{className:"w-3 h-3"}),"Inherited"]}),children:"This section is inherited from your parent config. Change the merge strategy in Miscellaneous → Parent Config to override it."})}var dz=s(9788),dV=s(7320),dq=s(5920),dB=s(1627);function dK(e){let{id:t,url:s,className:a,trusted:n=!0}=e,l=(()=>{switch(t){case"github":return"View the addon's GitHub repository";case"discord":return"Join the Developer's Discord";case"github-sponsors":return"Sponsor the Developer on GitHub";case"ko-fi":return"Support the Developer on Ko-fi";case"patreon":return"Support the Developer on Patreon";
13case"buymeacoffee":return"Support the Developer on Buy Me a Coffee";case"donate":return"Support the Developer";default:return null}})(),i=tN({title:"External Link Warning",description:(0,r.jsxs)(r.Fragment,{children:["This link was added by a template creator and is not verified or endorsed by AIOStreams.",(0,r.jsx)("br",{}),(0,r.jsx)("br",{}),"You are being taken to"," ",(0,r.jsx)("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] underline",onClick:e=>e.stopPropagation(),children:(0,r.jsx)("b",{children:s})}),"."]}),actionText:"Continue",onConfirm:()=>{window.open(s,"_blank","noopener,noreferrer")}}),o=n?void 0:e=>{e.preventDefault(),i.open()};return(0,r.jsxs)(r.Fragment,{children:[!n&&(0,r.jsx)(tk,{...i}),l?(0,r.jsx)(to,{side:"top",trigger:(0,r.jsx)(dH,{id:t,url:s,className:a,onClick:o}),children:l}):(0,r.jsx)(dH,{id:t,url:s,className:a,onClick:o})]})}let dH=e=>{let{id:t,url:s,className:a,onClick:n}=e;return(0,r.jsx)("a",{href:s,target:"_blank",rel:"noopener noreferrer",onClick:n,className:b("inline-flex items-center justify-center text-gray-400 transition-colors hover:opacity-80 hover:text-[--brand]",a),children:(()=>{switch(t){case"website":return(0,r.jsx)(da.f35,{className:"w-7 h-7"});case"discord":return(0,r.jsx)(P.fzZ,{className:"w-7 h-7"});case"github":return(0,r.jsx)(nD.BR8,{className:"w-7 h-7"});case"github-sponsors":return(0,r.jsx)(o4.Zak,{className:"w-7 h-7"});case"ko-fi":return(0,r.jsx)(o4.OnT,{className:"w-7 h-7"});case"patreon":return(0,r.jsx)(da.hk0,{className:"w-7 h-7"});case"buymeacoffee":return(0,r.jsx)(o4.Ylh,{className:"w-7 h-7"});case"donate":return(0,r.jsx)(tC.xko,{className:"w-7 h-7"});default:return null}})()})};var dG=s(8963).Buffer;function dW(e){let{subsectionIntent:t,buttonIntent:s,name:a,description:n,onClick:l,disabled:i}=e;return"block"===t?(0,r.jsxs)("button",{type:"button",onClick:l,disabled:i,className:"w-full text-left bg-[--background] border border-[--border] rounded-[--radius] px-4 py-3 hover:bg-[--subtle] transition-colors disabled:opacity-50 disabled:pointer-events-none shadow-sm",children:[(0,r.jsx)("div",{className:"font-semibold text-sm",children:a}),n&&(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(0,r.jsx)(nz,{children:n})})]}):"pill"===t?(0,r.jsxs)("div",{children:[(0,r.jsx)(w,{type:"button",rounded:!0,intent:s??"white-subtle",size:"md",onClick:l,disabled:i,className:"w-full",children:a}),n&&(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-2",children:(0,r.jsx)(nz,{children:n})})]}):"inline"===t?(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("span",{className:"font-medium text-sm",children:a}),n&&(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-0.5",children:(0,r.jsx)(nz,{children:n})})]}),(0,r.jsx)(w,{type:"button",rounded:!0,intent:s??"white",size:"sm",onClick:l,disabled:i,className:"shrink-0",children:"Open"})]}):"link"===t?(0,r.jsxs)("button",{type:"button",onClick:l,disabled:i,className:"group text-left disabled:opacity-50 disabled:pointer-events-none",children:[(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 text-sm font-medium text-[--brand] group-hover:underline",children:[a,(0,r.jsx)(da.X6T,{className:"w-3 h-3 opacity-60 transition-transform group-hover:translate-x-0.5"})]}),n&&(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-0.5",children:(0,r.jsx)(nz,{children:n})})]}):"banner"===t?(0,r.jsx)("button",{type:"button",onClick:l,disabled:i,className:"w-full text-left border-l-4 border-[--brand] bg-[--subtle] px-4 py-3 rounded-r-[--radius] hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors disabled:opacity-50 disabled:pointer-events-none",children:(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"font-semibold text-sm",children:a}),n&&(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-0.5",children:(0,r.jsx)(nz,{children:n})})]}),(0,r.jsx)(da.X6T,{className:"w-3 h-3 text-[--muted] shrink-0"})]})}):(0,r.jsxs)("div",{className:"flex items-center gap-3 bg-gray-100 dark:bg-gray-800 p-4 rounded-lg",children:[(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("h4",{className:"font-medium mb-1",children:a}),n&&(0,r.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:(0,r.jsx)(nz,{children:n})})]}),(0,r.jsx)(E,{icon:(0,r.jsx)(da.XGb,{}),intent:"primary-outline",onClick:l,disabled:i,title:`Configure ${a}`})]})}function dY(e){let{label:t,value:s,onChange:a,options:n,required:l,disabled:i}=e,o=e=>{a("undefined"===e?void 0:e)},d=!(null==n?void 0:n.some(e=>e.value===s)),c=[...(null==n?void 0:n.map(e=>({label:e.label,value:e.value})))??[],{label:"Custom",value:"Custom"}];return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(rn,{label:t,value:d?"Custom"
13:s,onValueChange:e=>{o("Custom"===e?"":e)},options:c,required:l,disabled:i}),d&&(0,r.jsx)(W,{label:"Custom",value:s??"",onValueChange:o,required:l,disabled:i})]})}let dJ=e=>{let{option:t,value:s,trusted:a,onChange:l,disabled:i}=e,{id:o,name:d,description:c,type:u,required:m,options:p,constraints:h,forced:x,default:g,intent:f,subsectionIntent:b,buttonIntent:v,socials:y,oauth:j,emptyIsUndefined:N=!1}=t,k=i||null!=x,S=null!=x?x:void 0;switch(u){case"socials":return(0,r.jsx)("div",{className:"flex items-center justify-center w-full gap-6 mt-2",children:null==y?void 0:y.map(e=>(0,r.jsx)(dK,{id:e.id,url:e.url,trusted:a},e.id))});case"alert":return(0,r.jsx)(nU,{intent:f,title:d,description:(0,r.jsx)(nz,{children:c})});case"password":return(0,r.jsxs)("div",{children:[(0,r.jsx)(Z,{label:d,value:S??s??g??"",onValueChange:e=>l(N?e||void 0:e),required:m,disabled:k,autoComplete:"new-password",minLength:(null==h?void 0:h.forceInUi)!==!1?null==h?void 0:h.min:void 0,maxLength:(null==h?void 0:h.forceInUi)!==!1?null==h?void 0:h.max:void 0}),c&&(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(0,r.jsx)(nz,{children:c})})]});case"string":return(0,r.jsxs)("div",{children:[(0,r.jsx)(W,{label:d,value:S??s??g??"",onValueChange:e=>l(N?e||void 0:e),required:m,minLength:(null==h?void 0:h.forceInUi)!==!1?null==h?void 0:h.min:void 0,maxLength:(null==h?void 0:h.forceInUi)!==!1?null==h?void 0:h.max:void 0,disabled:k}),c&&(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(0,r.jsx)(nz,{children:c})})]});case"number":return(0,r.jsxs)("div",{children:[(0,r.jsx)(nn,{value:S??s??g??void 0,label:d,onValueChange:(e,t)=>
13l(isNaN(e)?void 0:e),required:m,step:(null==h?void 0:h.max)&&Math.floor((null==h?void 0:h.max)/100)>0?Math.floor((null==h?void 0:h.max)/100):1,disabled:k,clampValueOnBlur:!1,min:(null==h?void 0:h.forceInUi)!==!1?null==h?void 0:h.min:void 0,max:(null==h?void 0:h.forceInUi)!==!1?null==h?void 0:h.max:void 0}),c&&(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(0,r.jsx)(nz,{children:c})})]});case"boolean":return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,r.jsx)("span",{className:"font-medium text-sm",children:d}),(0,r.jsx)(rs,{disabled:k,value:!!(S??s??g),onValueChange:l})]}),c&&(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(0,r.jsx)(nz,{children:c})})]});case"select":return(0,r.jsxs)("div",{children:[(0,r.jsx)(rn,{label:d,value:S??s??g,onValueChange:l,options:(null==p?void 0:p.map(e=>({label:e.label,value:e.value})))??[],required:m,disabled:k}),c&&(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(0,r.jsx)(nz,{children:c})})]});case"select-with-custom":return(0,r.jsxs)("div",{children:[(0,r.jsx)(dY,{label:d,value:S??s??g,onChange:l,options:p,required:m,disabled:k}),c&&(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(0,r.jsx)(nz,{children:c})})]});case"multi-select":return(0,r.jsxs)("div",{children:[(0,r.jsx)(ne,{label:d,value:S??Array.isArray(s)?s:g,onValueChange:e=>l(N&&(null==e?void 0:e.length)===0?void 0:e),options:(null==p?void 0:p.map(e=>({label:e.label,value:e.value,textValue:e.label})))??[],multiple:!0,emptyMessage:"No options",disabled:k,required:m,maxItems:(null==h?void 0:h.forceInUi)!==!1?null==h?void 0:h.max:void 0}),c&&(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(0,r.jsx)(nz,{children:c})})]});case"url":return(0,r.jsxs)("div",{children:[(0,r.jsx)(W,{label:d,value:S??s??g??"",onValueChange:e=>l(N?e||void 0:e),required:m,type:"url",disabled:k,minLength:(null==h?void 0:h.forceInUi)!==!1?null==h?void 0:h.min:void 0,maxLength:(null==h?void 0:h.forceInUi)!==!1?null==h?void 0:h.max:void 0}),c&&(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(0,r.jsx)(nz,{children:c})})]});case"oauth":{var C,_;let[e,t]=(0,n.useState)(!!s);if(!e)return(0,r.jsx)("div",{children:(0,r.jsx)("div",{className:"flex flex-col gap-3",children:(0,r.jsxs)("div",{className:"flex items-center gap-3 bg-[--subtle] p-4 rounded-lg",children:[(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("h4",{className:"font-medium mb-1",children:d}),(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:(0,r.jsx)(nz,{children:c})})]}),(0,r.jsx)(E,{icon:(0,r.jsx)(da.pXu,{}),intent:"primary-outline",onClick:()=>{window.open((null==j?void 0:j.authorisationUrl)||"","_blank"),t(!0)},className:"shrink-0"})]})})});return(0,r.jsx)("div",{children:(0,r.jsx)("div",{className:"flex flex-col gap-3",children:(0,r.jsxs)("div",{className:"bg-[--subtle] p-4 rounded-lg",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,r.jsxs)("h4",{className:"font-medium",children:["Enter ",(null==j||null==(C=j.oauthResultField)?void 0:C.name)||"Authorization Code"]}),(0,r.jsx)(E,{icon:(0,r.jsx)(da.QVr,{className:"w-4 h-4"}),intent:"primary-subtle",size:"sm",onClick:()=>t(!1),"aria-label":"Go back to authorization"})]}),(0,r.jsx)(Z,{value:S??s??g,onValueChange:e=>l(N?e||void 0:e),required:m,disabled:k,autoComplete:"new-password"}),(null==j||null==(_=j.oauthResultField)?void 0:_.description)&&(0,r.jsx)("div",{className:"text-sm text-[--muted] mt-2",children:(0,r.jsx)(nz,{children:j.oauthResultField.description})})]})})})}case"subsection":{let[e,a]=(0,n.useState)(!1),i=t.subOptions??[],o=S??s??g??{},u={};for(let e of i)void 0!==e.default&&(u[e.id]=e.default);let m={...u,...o},[p,h]=(0,n.useState)(m);return(0,r.jsxs)("div",{children:[(0,r.jsx)(dW,{subsectionIntent:b,buttonIntent:v,name:d,description:c,onClick:()=>{h(m),a(!0)},disabled:k}),(0,r.jsx)(ty,{open:e,onOpenChange:e=>!e&&void(h(m),a(!1)),title:d,children:(0,r.jsxs)("div",{className:"space-y-4",children:[i.map(e=>(0,r.jsx)(dJ,{option:e,value:p[e.id],onChange:t=>{var s;return s=e.id,void h(e=>({...e,[s]:t}))},disabled:k},e.id)),(0,r.jsx)(w,{type:"button",intent:"primary",className:"w-full",onClick:()=>{l(p),a(!1)},children:"Save"})]})})]})}case"custom-nntp-servers":return(0,r.jsx)(d1,{name:d,description:c,value:S??s??g,onChange:l,disabled:k});case"nab-endpoint":return(0,r.jsx)(dQ,{option:t,value:S??s??g,onChange:l,disabled:k});default:return null}},dZ={caps:"Could not reach a Newznab API here. Check the URL, including its path.",auth:"The endpoint is reachable, but the API key was rejected.",search:"The endpoint is reachable, but the search request failed."};function dQ(e){var t,s,a;let{option:l,value:i,onChange:o,disabled:d}=e,c=l.subOptions??[],u=c.find(e=>"url"===e.id),m=c.find(e=>"apiKey"===e.id),p=i??{}
13,[h,g]=(0,n.useState)(!1),[f,b]=(0,n.useState)(null),v=e=>{b(null),o({...p,...e})},y=null==u||null==(s=u.options)||null==(t=s.find(e=>e.value===p.url))?void 0:t.apiKeyUrl,j=[null==m?void 0:m.description,y&&`[Find your API key](${y})`].filter(Boolean).join(" "),w=async()=>{g(!0),b(null);try{var e,t,s;let a=await fetch(`/builtins/${(null==(e=l.nab)?void 0:e.namespace)??"newznab"}/test`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:p.url,apiKey:p.apiKey,preset:null==(t=l.nab)?void 0:t.preset})}),r=await a.json();if(!r.success)throw Error(r.detail||(null==(s=r.error)?void 0:s.message)||"Could not run the test");b(r.data)}catch(e){x.oR.error(e instanceof Error?e.message:"Could not run the test")}finally{g(!1)}};return(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-end gap-2",children:[(0,r.jsx)("div",{className:"flex-1 min-w-0 space-y-2",children:(null==u||null==(a=u.options)?void 0:a.length)?(0,r.jsx)(dY,{label:u.name,value:p.url,onChange:e=>v({url:e}),options:u.options,required:u.required,disabled:d}):(0,r.jsx)(W,{label:(null==u?void 0:u.name)??"URL",value:p.url??"",onValueChange:e=>v({url:e}),type:"url",required:null==u?void 0:u.required,disabled:d})}),(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{intent:"gray-subtle",icon:(0,r.jsx)(tC.UWw,{}),onClick:w,loading:h,disabled:d||h,"aria-label":"Test endpoint",className:"shrink-0"}),children:"Test connection"})]}),(null==u?void 0:u.description)&&(0,r.jsx)("div",{className:"text-xs text-[--muted]",children:(0,r.jsx)(nz,{children:u.description})}),m&&(0,r.jsxs)("div",{children:[(0,r.jsx)(Z,{label:m.name,value:p.apiKey??"",onValueChange:e=>v({apiKey:e}),required:m.required,disabled:d,autoComplete:"new-password"}),j&&(0,r.jsx)("div",{className:"text-xs text-[--muted] mt-1",children:(0,r.jsx)(nz,{children:j})})]}),f&&(0,r.jsx)(dX,{result:f})]})}function dX(e){var t,s,a,n,l,i;let o,d,{result:c}=e;if(!c.ok){let e=c.stage?dZ[c.stage]:void 0;return(0,r.jsx)(nU,{intent:"alert-basic",title:"Test failed",description:(0,r.jsxs)("span",{children:[e?`${e} `:"",null==(n=c.error)?void 0:n.message,(null==(l=c.error)?void 0:l.code)!==void 0&&` (${c.error.code})`]})})}let u=[(o=(null==(i=c.idSearchParams)?void 0:i.movie)??[],d=(null==i?void 0:i.series)??[],0===o.length&&0===d.length?"No ID search, results are matched by title only":o.length===d.length&&o.every(e=>d.includes(e))?`ID search: ${o.join(", ")}`:`ID search: ${o.length?o.join(", "):"none"} (movies), ${d.length?d.join(", "):"none"} (series)`),void 0!==c.resultCount&&`${c.resultCount} results`,(null==(t=c.limits)?void 0:t.max)!==void 0&&`max ${c.limits.max} per request`,(null==(s=c.searchModes)?void 0:s.length)&&`supports ${c.searchModes.join(", ")}`].filter(Boolean);return(0,r.jsx)(nU,{intent:"success-basic",title:`Connected to ${(null==(a=c.server)?void 0:a.title)||"the indexer"}`,description:u.join(" \xb7 ")})}let d0=e=>{if(!e)return[];try{let t=dG.from(e,"base64").toString("utf-8");return JSON.parse(t)}catch{return[]}};function d1(e){let{name:t,description:s,value:a,onChange:l,disabled:i}
13=e,[o,d]=(0,n.useState)(!1),[c,u]=(0,n.useState)([]);(0,n.useEffect)(()=>{o&&u(d0(a))},[o,a]);let m=d0(a).length,p=(e,t)=>{u(s=>{let a=[...s],r="up"===t?e-1:e+1;return r<0||r>=a.length?s:([a[e],a[r]]=[a[r],a[e]],a)})},h=(e,t,s)=>{u(a=>a.map((a,r)=>r===e?{...a,[t]:s}:a))};return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 bg-[--subtle] p-4 rounded-lg",children:[(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("h4",{className:"font-medium mb-1",children:t}),s&&(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:(0,r.jsx)(nz,{children:s})}),m>0&&(0,r.jsxs)("p",{className:"text-sm text-[--brand] mt-1",children:[m," server",1!==m?"s":""," configured"]})]}),(0,r.jsx)(E,{icon:(0,r.jsx)(da.vwk,{}),intent:"primary-outline",onClick:()=>d(!0),disabled:i,className:"shrink-0"})]}),(0,r.jsxs)(ty,{open:o,onOpenChange:d,title:"Configure NNTP Servers",contentClass:"max-w-4xl",children:[(0,r.jsxs)("div",{className:"space-y-4 max-h-[60vh] overflow-y-auto pr-1",children:[0===c.length?(0,r.jsxs)("div",{className:"text-center py-8 text-[--muted]",children:[(0,r.jsx)(da.vwk,{className:"w-12 h-12 mx-auto mb-3 opacity-50"}),(0,r.jsx)("p",{children:"No servers configured"}),(0,r.jsx)("p",{className:"text-sm",children:"Click the button below to add a server"})]}):c.map((e,t)=>(0,r.jsxs)("div",{className:"border border-[--border] rounded-lg p-4 bg-[--subtle]",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,r.jsxs)("span",{className:"font-medium text-sm",children:["Server ",t+1]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)(E,{icon:(0,r.jsx)(da.Ucs,{className:"w-4 h-4"}),intent:"gray-subtle",size:"sm",onClick:()=>p(t,"up"),disabled:0===t}),(0,r.jsx)(E,{icon:(0,r.jsx)(da.Vr3,{className:"w-4 h-4"}),intent:"gray-subtle",size:"sm",onClick:()=>p(t,"down"),disabled:t===c.length-1}),(0,r.jsx)(E,{icon:(0,r.jsx)(da.G02,{className:"w-4 h-4"}),intent:"alert-subtle",size:"sm",onClick:()=>{u(e=>e.filter((e,s)=>s!==t))}})]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[(0,r.jsx)(W,{label:"Host",value:e.host??"",onValueChange:e=>h(t,"host",e),placeholder:"news.example.com",required:!0}),(0,r.jsx)(nn,{label:"Port",value:e.port,onValueChange:e=>h(t,"port",e),min:1,max:65535,required:!0}),(0,r.jsx)(W,{label:"Username",autoComplete:"off",value:e.username??"",onValueChange:e=>h(t,"username",e),placeholder:"username",required:!0}),(0,r.jsx)(Z,{label:"Password",autoComplete:"new-password",value:e.password??"",onValueChange:e=>h(t,"password",e),placeholder:"password",required:!0}),(0,r.jsx)(nn,{label:"Connections",value:e.connections,onValueChange:e=>h(t,"connections",e),min:1,max:500,required:!0}),(0,r.jsx)("div",{className:"flex items-end pb-1",children:(0,r.jsx)(rs,{label:"Use SSL",value:e.ssl,onValueChange:e=>h(t,"ssl",e),side:"right"})})]})]},t)),(0,r.jsx)(w,{type:"button",intent:"primary-outline",className:"w-full",leftIcon:(0,r.jsx)(da.OiG,{className:"w-4 h-4"}),onClick:()=>{u(e=>[...e,{username:"",password:"",host:"",port:563,ssl:!0,connections:5}])},children:"Add Server"})]}),(0,r.jsxs)("div",{className:"flex gap-2 mt-4 pt-4 border-t border-[--border]",children:[(0,r.jsx)(w,{type:"button",className:"w-full",intent:"primary-outline",onClick:()=>{d(!1)},children:"Cancel"}),(0,r.jsx)(w,{type:"button",className:"w-full",onClick:()=>{l((e=>{if(0!==e.length)return dG.from(JSON.stringify(e)).toString("base64")})(c.filter(e=>""!==e.host.trim()))),d(!1)},children:"Save"})]})]})]})}let d2=[sh,sx,sg,sp,sf,sb],d3=["torbox"];function d6(e){return d2.includes(e)}function d5(e){return d3.includes(e)}let d4={realdebrid:"https://cdn.jsdelivr.net/gh/selfhst/icons/png/real-debrid.png",debridlink:"https://debrid-link.com/img/brand/dl-white-blue.svg",premiumize:"https://www.premiumize.me/icon_normal.svg",alldebrid:"https://cdn.alldebrid.com/lib/images/default/logo_alldebrid.png",torbox:"https://torbox.app/assets/logo-bb7a9579.svg",putio:"https://images.seeklogo.com/logo-png/51/1/put-io-logo-png_seeklogo-516681.png",pikpak:"https://mypikpak.com/apple-touch-icon.png",offcloud:"https://offcloud.com/images/logo-blue-short-lg.png",seedr:"https://static.seedr.cc/images/seed_v2.png",easydebrid:"https://paradise-cloud.com/apple-touch-icon.png",debrider:"https://debrider.app/icon.svg",easynews:"/assets/easynews_logo.png",stremthru_newz:"https://emojiapi.dev/api/v1/sparkles/256.png",stremio_nntp:"https://raw.githubusercontent.com/Stremio/stremio-brand/refs/heads/master/logos/PNG/stremio-logo-800px.png",nzbdav:"https://raw.githubusercontent.com/nzbdav-dev/nzbdav/refs/heads/main/frontend/public/logo.svg",altmount:"https://raw.githubusercontent.com/javi11/altmount/refs/heads/main/docs/static/img/logo.png",aiostreams:"/logo.png",torrin:"https://torrin.app/favicon.png"};function d9(e){let{serviceId:t,shortName:s}=e,a=d4[t];return a?(0,r.jsx)("img",{src:a,alt:s,className:"w-9 h-9 rounded-lg object-contain shrink-0"}):(0,r.jsx)("div",{className:"w-9 h-9 rounded-lg bg-[--subtle] border border-[--border] flex items-center justify-center text-xs font-bold font-mono shrink-0 text-[--muted]",children:s})}function d8(){var e,t,s,a,l;let{status:i}=e$();if(!i)return null;let{setUserData:o,userData:d}
13=s4(),[c,u]=(0,n.useState)(!1),[m,p]=(0,n.useState)(null),[h,x]=(0,n.useState)({}),[g,f]=(0,n.useState)(!1),[v,y]=(0,n.useState)(""),[j,w]=(0,n.useState)("all"),N=e=>{var t;p(e);let s=null==(t=d.services)?void 0:t.find(t=>t.id===e);x((null==s?void 0:s.credentials)||{}),u(!0)},k=()=>{u(!1),p(null),x({})};(0,n.useEffect)(()=>{let e=Object.keys(i.settings.services),t=d.services??[],s=t.filter(t=>e.includes(t.id)),a=e.filter(e=>!s.some(t=>t.id===e));if(a.length>0||s.length!==t.length){let e=a.map(e=>({id:e,enabled:!1,credentials:{}}));o(t=>({...t,services:[...s,...e]}))}},[i.settings.services,d.services]);let S=(0,dB.FR)((0,dB.MS)(dB.AN),(0,dB.MS)(dB.IG,{activationConstraint:{delay:150,tolerance:8}}));(0,n.useEffect)(()=>{function e(e){g&&e.preventDefault()}function t(){f(!1)}return g?(document.body.addEventListener("touchmove",e,{passive:!1}),document.addEventListener("pointerup",t),document.addEventListener("touchend",t)):document.body.removeEventListener("touchmove",e),()=>{document.body.removeEventListener("touchmove",e),document.removeEventListener("pointerup",t),document.removeEventListener("touchend",t)}},[g]);let C=(null==(e=d.services)?void 0:e.filter(e=>{let t=i.settings.services[e.id];return!!t&&e.enabled&&t.credentials.some(t=>{var s;return!(null==(s=e.credentials)?void 0:s[t.id])&&t.required})}).map(e=>{var t;return null==(t=i.settings.services[e.id])?void 0:t.name}))??[],_=(null==(t=d.services)?void 0:t.map(e=>e.id))||[],R=""!==v.trim()||"all"!==j,A=(d.services??[]).filter(e=>{let t=i.settings.services[e.id];if(!t)return!1;if("all"!==j){let t=d5(e.id),s=d6(e.id);if(!t&&("debrid"===j&&s||"usenet"===j&&!s))return!1}if(v.trim()){let e=v.toLowerCase(),s=(t.name??"").toLowerCase(),a=(t.shortName??"").toLowerCase();if(!s.includes(e)&&!a.includes(e))return!1}return!0});return(0,r.jsxs)(r.Fragment,{children:[C.length>0&&(0,r.jsx)(nU,{intent:"alert",title:"Missing Credentials",description:(0,r.jsxs)(r.Fragment,{children:["The following services are missing credentials:",(0,r.jsx)("div",{className:"flex flex-col gap-1 mt-2",children:C.map(e=>(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("div",{className:"w-1.5 h-1.5 rounded-full bg-current mr-2"}),e]},e))})]})}),(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2 items-start sm:items-center",children:[(0,r.jsx)(W,{className:"flex-1 w-full sm:w-auto",placeholder:"Search services...",leftIcon:(0,r.jsx)(nD.CKj,{className:"w-4 h-4 text-[--muted]"}),value:v,onValueChange:y}),(0,r.jsx)("div",{className:"flex gap-1.5 shrink-0",children:["all","debrid","usenet"].map(e=>{let t="debrid"===e?"bg-purple-100 text-purple-700 border-purple-300 dark:bg-purple-900/40 dark:text-purple-300 dark:border-purple-700":"usenet"===e?"bg-blue-100 text-blue-700 border-blue-300 dark:bg-blue-900/40 dark:text-blue-300 dark:border-blue-700":"bg-[--subtle-highlight] text-[--foreground] border-[--border]";return(0,r.jsx)("button",{type:"button",onClick:()=>w(e),className:b("px-3 py-1.5 rounded-full text-xs font-medium border transition-colors capitalize",j===e?t:"border-[--border] text-[--muted] hover:bg-[--subtle]"),children:"all"===e?"All":e.charAt(0).toUpperCase()+e.slice(1)},e)})})]}),R?(0,r.jsxs)("p",{className:"text-sm text-[--muted]",children:["Showing ",A.length," of ",(null==(s=d.services)?void 0:s.length)??0," ","services."," ",(0,r.jsx)("button",{type:"button",className:"underline hover:text-[--foreground] transition-colors",onClick:()=>{y(""),w("all")},children:"Clear filters"})," ","to reorder."]}):(0,r.jsxs)("p",{className:"text-sm text-[--muted]",children:["Drag to reorder by priority. Enable a service and click"," ",(0,r.jsx)("strong",{children:"Configure"})," to enter credentials."]}),R?(0,r.jsx)("ul",{className:"space-y-2",children:0===A.length?(0,r.jsx)("li",{children:(0,r.jsx)("div",{className:"flex flex-col items-center justify-center py-12",children:(0,r.jsx)("span",{className:"text-lg text-[--muted] font-semibold text-center",children:"No services match your search."})})}):A.map(e=>{let t=i.settings.services[e.id];return t?(0,r.jsx)(ce,{service:e,meta:t,onEdit:()=>N(e.id),onToggleEnabled:t=>{o(s=>({...s,services:(s.services??[]).map(s=>s.id===e.id?{...s,enabled:t}:s)}))}},e.id):null})}):(0,r.jsx)(dB.Mp,{modifiers:[dz.FN],onDragEnd:function(e){let{active:t,over:s}=e;s&&(t.id!==s.id&&o(e=>{let a=e.services??[],r=a.findIndex(e=>e.id===t.id),n=a.findIndex(e=>e.id===s.id),l=(0,dV.be)(a,r,n);return{...e,services:l}}),f(!1))},onDragStart:function(){f(!0)},sensors:S,children:(0,r.jsx)(dV.gB,{items:_,strategy:dV._G,children:(0,r.jsx)("ul",{className:"space-y-2",children:((null==(a=d.services)?void 0:a.length)??0)===0?(0,r.jsx)("li",{children:(0,r.jsx)("div",{className:"flex flex-col items-center justify-center py-12",children:(0,r.jsx)("span",{className:"text-lg text-[--muted] font-semibold text-center",children:"No services found."})})}):null==(l=d.services)?void 0:l.map(e=>{let t=i.settings.services[e.id];return t?(0,r.jsx)(ct,{service:e,meta:t,onEdit:()=>N(e.id),onToggleEnabled:t=>{o(s=>({...s,services:(s.services??[]).map(s=>s.id===e.id?{...s,enabled:t}:s)}))}},e.id):null})})})}),(0,r.jsx)(cs,{open:c,onOpenChange:u,serviceId:m,values:h,onSubmit:e=>{o(t=>{let s={...t};return s.services=(s.services??[]).map(t=>
13t.id===m?{...t,enabled:!0,credentials:e}:t),s}),k()},onClose:k})]})}function d7(e){let{service:t,meta:s,onEdit:a,onToggleEnabled:n,dragHandleProps:l}=e,i=s.credentials.every(e=>e.forced),o=d6(t.id),d=d5(t.id);return(0,r.jsxs)("div",{className:"px-3 py-2.5 bg-[var(--background)] rounded-[--radius-md] border flex gap-3 items-center relative",children:[l?(0,r.jsx)("div",{className:"rounded-full w-6 h-auto self-stretch flex-shrink-0 bg-[--muted] md:bg-[--subtle] md:hover:bg-[--subtle-highlight] cursor-move",...l.attributes,...l.listeners}):(0,r.jsx)("div",{className:"w-6 flex-shrink-0"}),(0,r.jsx)(d9,{serviceId:t.id,shortName:s.shortName}),(0,r.jsxs)("div",{className:"flex-1 flex flex-col justify-center min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,r.jsx)("span",{className:"font-semibold text-sm truncate",children:(null==s?void 0:s.name)||t.id}),d?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded-full font-medium shrink-0 bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400",children:"Debrid"}),(0,r.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded-full font-medium shrink-0 bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",children:"Usenet"})]}):o?(0,r.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded-full font-medium shrink-0 bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",children:"Usenet"}):(0,r.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded-full font-medium shrink-0 bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400",children:"Debrid"})]}),(0,r.jsx)("span",{className:"text-xs text-[--muted] font-normal line-clamp-1",children:(0,r.jsx)(nz,{children:null==s?void 0:s.signUpText})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,r.jsx)(rs,{value:!!t.enabled,onValueChange:n,disabled:i}),(0,r.jsx)(E,{intent:"gray-outline",size:"sm",onClick:a,disabled:i,icon:(0,r.jsx)(nD.VSk,{})})]})]})}function ce(e){let{service:t,meta:s,onEdit:a,onToggleEnabled:n}=e;return(0,r.jsx)("li",{children:(0,r.jsx)(d7,{service:t,meta:s,onEdit:a,onToggleEnabled:n,dragHandleProps:null})})}function ct(e){let{service:t,meta:s,onEdit:a,onToggleEnabled:n}=e,{attributes:l,listeners:i,setNodeRef:o,transform:d,transition:c,isDragging:u}=(0,dV.gl)({id:t.id}),m={transform:dq.Ks.Transform.toString(d),transition:c,opacity:u?.5:1};return(0,r.jsx)("li",{ref:o,style:m,children:(0,r.jsx)(d7,{service:t,meta:s,onEdit:a,onToggleEnabled:n,dragHandleProps:{attributes:l,listeners:i}})})}function cs(e){let{open:t,onOpenChange:s,serviceId:a,values:l,onSubmit:i,onClose:o}=e,{status:d}
13=e$(),[c,u]=(0,n.useState)({});if((0,n.useEffect)(()=>{t&&u(l)},[t,l]),!d||!a)return null;let m=d.settings.services[a],p=m.credentials||[];return(0,r.jsx)(ty,{open:t,onOpenChange:s,title:`Configure ${m.name}`,children:(0,r.jsxs)("form",{className:"space-y-4",onSubmit:e=>{e.preventDefault(),i(c)},children:[p.map(e=>(0,r.jsx)(dJ,{option:{...e,required:!1},value:e.forced||e.default||c[e.id],onChange:t=>u(s=>({...s,[e.id]:t||void 0}))},e.id)),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(w,{type:"button",className:"w-full",intent:"primary-outline",onClick:o,children:"Cancel"}),(0,r.jsx)(w,{type:"submit",className:"w-full",children:"Save"})]})]})})}function ca(e){let{title:t,children:s}=e,[a,l]=(0,n.useState)({x:0,y:0}),i=(0,n.useRef)(null);return(0,r.jsx)("div",{className:"pb-4",children:(0,r.jsx)("div",{ref:i,onMouseMove:e=>{if(!i.current)return;let t=i.current.getBoundingClientRect();l({x:e.clientX-t.left,y:e.clientY-t.top})},className:"lg:p-2 lg:border lg:rounded-[--radius] lg:bg-gray-950/70 contents lg:block relative group/settings-nav",children:s})})}function cr(e){let{title:t,description:s,children:a,className:l,titleClassName:i,action:o,id:d}
13=e,[c,u]=(0,n.useState)({x:0,y:0}),[m,p]=(0,n.useState)(!1),h=(0,n.useRef)(null);return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)(X,{ref:h,id:d,"data-settings-card":!0,className:b("group/settings-card relative lg:bg-gray-950/70 scroll-mt-24",l),onMouseMove:e=>{if(!h.current)return;let t=h.current.getBoundingClientRect();u({x:e.clientX-t.left,y:e.clientY-t.top})},children:[t&&(0,r.jsx)(ee,{className:"p-0 pb-4",children:(0,r.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)(et,{className:b("font-bold tracking-widest uppercase text-sm transition-colors duration-300 group-hover/settings-card:text-white group-hover/settings-card:from-brand-500/10 group-hover/settings-card:to-purple-500/5 px-4 py-2 border bg-transparent bg-gradient-to-br bg-[--subtle] border-t-0 border-l-0 w-fit rounded-tl-md rounded-br-md",i),children:t}),s&&(0,r.jsx)(es,{className:"px-4 mt-2",children:s})]}),o&&(0,r.jsx)("div",{className:"flex-shrink-0 px-4 pt-2",children:o})]})}),(0,r.jsx)(ea,{className:b(!t&&"pt-4","space-y-3 flex-wrap"),children:a})]})})}function cn(e){let{label:t,help:s,disabled:a,value:l,onValueChange:i,placeholder:o,min:d=0}=e,[c,u]=n.useState(()=>rN(l)),[m,p]=n.useState(null);return n.useEffect(()=>{rw(c)!==l&&(u(rN(l)),p(null))},[l]),(0,r.jsx)(W,{label:t,help:s,error:m??void 0,disabled:a,value:c,placeholder:o??'e.g. "1.5s", "500ms", "2s"',onValueChange:e=>{u(e);let t=rw(e);null==t||t<d?p("Invalid duration. Use e.g. 500ms, 1.5s, 2s, 1m."):(p(null),i(t))}})}function cl(){var e,t,s,a,n,l,i,o,d,c,u,m,p,h,x,g,f,b,v,y,j,w,N,k,S,C,_,R,A,T,I,E,M,P,D,L,U,$,O,F,z,V,q;let{status:B}=e$(),{userData:K,setUserData:H}=s4();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(cr,{title:"Service Wrap",id:"serviceWrap",description:"Wrap P2P results from external addons through your own debrid services, without sharing your credentials with those addons. Works with P2P-capable marketplace addons and custom addons added via a custom manifest URL.",children:[(0,r.jsx)(rs,{label:"Enable Service Wrap",side:"right",value:(null==(e=K.serviceWrap)?void 0:e.enabled)??!1,onValueChange:e=>{H(t=>({...t,serviceWrap:{...t.serviceWrap,enabled:e}}))},help:"When enabled, AIOStreams configures supported addons to return raw torrents, then resolves them through your debrid services."}),(null==(t=K.serviceWrap)?void 0:t.enabled)&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(rs,{label:"Reconfigure Service",side:"right",value:(null==(s=K.serviceWrap)?void 0:s.reconfigureService)??!1,onValueChange:e=>{H(t=>({...t,serviceWrap:{...t.serviceWrap,reconfigureService:e}}))},help:"Re-processes debrid results from selected addons through your configured services. Useful if the addon doesn't support returning P2P results.",moreHelp:"Only works when the torrent hash can be extracted from the stream - not all debrid results will be eligible."}),(0,r.jsx)(ne,{label:"Wrap Addons",help:"Select which addons to wrap. Leave empty to wrap all applicable addons.",options:(K.presets??[]).filter(e=>{var t;let s=null==B?void 0:B.settings.presets.find(t=>t.ID===e.type);return(null==s||!s.BUILTIN)&&!!((null==s?void 0:s.ID)==="custom"||(null==s?void 0:s.SUPPORTED_STREAM_TYPES.includes("p2p"))||(null==(t=K.serviceWrap)?void 0:t.reconfigureService)&&(null==s?void 0:s.SUPPORTED_STREAM_TYPES.includes("debrid")))}).map(e=>({label:e.options.name||e.type,value:e.instanceId,textValue:e.options.name})),multiple:!0,emptyMessage:"No supported addons found",value:(null==(a=K.serviceWrap)?void 0:a.presets)??[],onValueChange:e=>{H(t=>({...t,serviceWrap:{...t.serviceWrap,presets:e.length>0?e:void 0}}))}}),(0,r.jsx)(ne,{label:"Processing Services",help:"Select which debrid services to use for processing wrapped torrents. Leave empty to use all enabled services.",options:(K.services??[]).filter(e=>e.enabled&&sj.includes(e.id)&&![sh,sx,sg,sp].includes(e.id)).map(e=>{var t,s;return{label:(null==B||null==(t=B.settings.services[e.id])?void 0:t.name)??e.id,value:e.id,textValue:(null==B||null==(s=B.settings.services[e.id])?void 0:s.name)??e.id}}),multiple:!0,emptyMessage:"No supported services found",value:(null==(n=K.serviceWrap)?void 0:n.services)??[],onValueChange:e=>{H(t=>({...t,serviceWrap:{...t.serviceWrap,services:e.length>0?e:void 0}}))}})]})]}),(0,r.jsxs)(cr,{title:"Failover",id:"failover",description:"When a stream fails to play, AIOStreams automatically tries the next best result from your sorted list. Works with built-in Usenet and debrid results (those AIOStreams resolves itself).",children:[(0,r.jsx)(rs,{label:"Enable",side:"right",value:(null==(l=K.failover)?void 0:l.enabled)??!1,onValueChange:e=>{H(t=>({...t,failover:{...t.failover,enabled:e}}))}}),(0,r.jsx)(ne,{label:"Failover Content Types",help:"Which kinds of result may be used as failover targets.",disabled:!(null==(i=K.failover)?void 0:i.enabled),options:[{label:"Usenet",value:"usenet",textValue:"Usenet"},{label:"Debrid",value:"debrid",textValue:"Debrid"}],multiple:!0,emptyMessage:"Select at least one content type",value:(null==(o=K.failover)?void 0:o.contentTypes)??["usenet"],onValueChange:e=>{H(t=>({...t,failover:{...t.failover,contentTypes:e}}))}}),(0,r.jsx)(rs,{label:"Allow Cross-Type Failover",side:"right",disabled:!(null==(d=K.failover)?void 0:d.enabled),help:"Allow a click on one kind (e.g. Usenet) to fall through into a different kind (e.g. debrid) that is next in the ranked list. When off, failover stays within the clicked item's own kind.",value:(null==(c=K.failover)?void 0:c.allowCrossType)??!1,onValueChange:e=>{H(t=>({...t,failover:{...t.failover,allowCrossType:e}}))}}),(0,r.jsx)(rs,{label:"Include External Addon Targets",side:"right",disabled:!(null==(u=K.failover)?void 0:u.enabled),help:"Also use non-owned debrid links from external addons (on the addon's own host) as failover targets. These are resolved by probing: a redirect to the addon's own host is treated as a dead link, a redirect to a CDN as success. A direct click on an external stream still won't fail over.",value:(null==(m=K.failover)?void 0:m.includeExternalFailover)??!1,onValueChange:e=>{H(t=>({...t,failover:{...t.failover,includeExternalFailover:e}}))}}),(0,r.jsx)(nn,{label:"Max Failover Attempts",help:(0,r.jsxs)(r.Fragment,{children:["How many unique fallback results to try before giving up. Maximum is set by ",(0,r.jsx)("code",{children:"MAX_FAILOVER_ATTEMPTS"})," (currently"," ",(null==B||null==(h=B.settings)||null==(p=h.limits)?void 0:p.maxFailoverAttempts)??5,")."]}),min:1,max:(null==B||null==(g=B.settings)||null==(x=g.limits)?void 0:x.maxFailoverAttempts)??5,defaultValue:3,disabled:!(null==(f=K.failover)?void 0:f.enabled),value:(null==(b=K.failover)?void 0:b.maxAttempts)??3,onValueChange:e=>{var t,s;let a=(null==B||null==(s=B.settings)||null==(t=s.limits)?void 0:t.maxFailoverAttempts)??5;H(t=>({...t,failover:{...t.failover,maxAttempts:Math.min(a,Math.max(1,Number(e||3)))}}))}}),(0,r.jsx)(nn,{label:"Same-Release Failover Attempts",help:"How many alternative sources of the SAME release (harvested by deduplicator merging) to try per release before moving to a different release. 0 disables same-release failover. Bounded by the overall Max Failover Attempts.",min:0,max:(null==B||null==(y=B.settings)||null==(v=y.limits)?void 0:v.maxFailoverAttempts)??5,defaultValue:2,disabled:!(null==(j=K.failover)?void 0:j.enabled),value:(null==(w=K.failover)?void 0:w.sameReleaseLimit)??2,onValueChange:e=>{var t,s;let a=(null==B||null==(s=B.settings)||null==(t=s.limits)?void 0:t.maxFailoverAttempts)??5;H(t=>({...t,failover:{...t.failover,sameReleaseLimit:Math.min(a,Math.max(0,Number(e??2)))}}))}}),(0,r.jsx)(nn,{label:"Parallel Attempts",help:(0,r.jsxs)(r.Fragment,{children:["How many attempts to run at once. 1 keeps the classic sequential behaviour (try one, then the next). Higher values race several attempts and take the first that proves healthy; the losing attempts are cancelled and cleaned up (usenet probes are aborted; debrid downloads added by a loser are removed, except private torrents). Maximum is set by ",(0,r.jsx)("code",{children:"MAX_PARALLEL_ATTEMPTS"})," ","(currently ",(null==B||null==(k=B.settings)||null==(N=k.limits)?void 0:N.maxParallelAttempts)??2,")."]}),min:1,max:(null==B||null==(C=B.settings)||null==(S=C.limits)?void 0:S.maxParallelAttempts)??2,defaultValue:1,disabled:!(null==(_=K.failover)?void 0:_.enabled),value:(null==(R=K.failover)?void 0:R.parallel)??1,onValueChange:e=>{var t,s;let a=(null==B||null==(s=B.settings)||null==(t=s.limits)?void 0:t.maxParallelAttempts)??2;H(t=>({...t,failover:{...t.failover,parallel:Math.min(a,Math.max(1,Number(e||1)))}}))}}),((null==(A=K.failover)?void 0:A.parallel)??1)>1&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(cn,{label:"Backup delay",help:"How long the clicked item runs alone before backups start in parallel. A head start that keeps provider load down. Accepts values like 1.5s or 500ms.",disabled:!(null==(T=K.failover)?void 0:T.enabled),value:(null==(I=K.failover)?void 0:I.staggerMs)??1e3,onValueChange:e=>{H(t=>({...t,failover:{...t.failover,staggerMs:e}}))}}),(0,r.jsx)(cn,{label:"Same-release backup delay",help:"Like Backup delay, but between attempts for the SAME release (alternative sources of the clicked release, harvested by deduplicator merging). These are essentially the same release, so no head start is needed — defaults to 0.",disabled:!(null==(E=K.failover)?void 0:E.enabled),value:(null==(M=K.failover)?void 0:M.duplicateStaggerMs)??0,onValueChange:e=>{H(t=>({...t,failover:{...t.failover,duplicateStaggerMs:e}}))}}),(0,r.jsx)(cn,{label:"Preferred-item grace",help:"Once a backup is healthy, how long to wait for the item you actually clicked (or a higher-ranked one still in flight) to catch up before settling for the backup. 0 = take the first healthy result.",disabled:!(null==(P=K.failover)?void 0:P.enabled),value:(null==(D=K.failover)?void 0:D.preferredGraceMs)??2e3,onValueChange:e=>{H(t=>({...t,failover:{...t.failover,preferredGraceMs:e}}))}}),(0,r.jsx)(cn,{label:"Max wait",help:"Overall deadline for the parallel chain before giving up and serving an error.",min:1e3,disabled:!(null==(L=K.failover)?void 0:L.enabled),value:(null==(U=K.failover)?void 0:U.maxWaitMs)??3e4,onValueChange:e=>{H(t=>({...t,failover:{...t.failover,maxWaitMs:e}}))}})]}),(0,r.jsx)(rs,{label:"During Pre-cache",side:"right",disabled:!(null==($=K.failover)?void 0:$.enabled),help:"Also apply failover when pre-caching the next episode's streams in the background. When off, pre-cache requests ski
13p failover entirely.",value:(null==(O=K.failover)?void 0:O.precacheFailover)??!1,onValueChange:e=>{H(t=>({...t,failover:{...t.failover,precacheFailover:e}}))}}),(0,r.jsx)(rn,{label:"Failover Position",disabled:!(null==(F=K.failover)?void 0:F.enabled),help:"Where in the processing pipeline the fallback chain is built. All positions are after sorting. Earlier positions draw from a larger pool of streams but may include streams that would later be removed by SEL filters or limits.",options:[{label:"Before SEL",value:"beforeSEL"},{label:"Before Limiting",value:"beforeLimiting"},{label:"Last (default)",value:"last"}],value:(null==(z=K.failover)?void 0:z.position)??"last",onValueChange:e=>{H(t=>({...t,failover:{...t.failover,position:e}}))}})]}),(0,r.jsx)(cr,{title:"Auto Remove Downloads",id:"autoRemoveDownloads",description:"Automatically removes the torrent/NZB from your debrid dashboard after generating a playback link. Only works for built-in addons and supported services — private torrents are not removed.",children:(0,r.jsx)(rs,{label:"Enable",side:"right",value:K.autoRemoveDownloads??!1,onValueChange:e=>{H(t=>({...t,autoRemoveDownloads:e}))}})}),(0,r.jsx)(cr,{title:"Check Library",id:"checkOwned",description:"When enabled, built-in addons and service wrapped addons will check if search results already exist in your debrid library and mark them accordingly. This applies to both torrent and usenet results.",children:(0,r.jsx)(rs,{label:"Enable",side:"right",value:K.checkOwned??!0,onValueChange:e=>{H(t=>({...t,checkOwned:e}))}})}),(0,r.jsxs)(cr,{title:"Cache and Play",id:"cacheAndPlay",description:"Allows uncached streams to wait for the download to finish before playing, instead of showing a 'try again' message. Only works for built-in addons — recommended for Usenet since downloads typically finish quickly.",children:[(0,r.jsx)(rs,{label:"Enable",side:"right",value:null==(V=K.cacheAndPlay)?void 0:V.enabled,onValueChange:e=>{H(t=>({...t,cacheAndPlay:{...t.cacheAndPlay,enabled:e}}))}}),(0,r.jsx)(ne,{label:"Stream Types",options:["usenet","torrent"].map(e=>({label:e,value:e,textValue:e})),multiple:!0,emptyMessage:"No stream types found",defaultValue:["usenet"],value:(null==(q=K.cacheAndPlay)?void 0:q.streamTypes)??["usenet"],onValueChange:e=>{H(t=>({...t,cacheAndPlay:{...t.cacheAndPlay,streamTypes:e}}))}})]})]})}function ci(){let{status:e}=e$(),{userData:t,setUserData:s}=s4();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(cr,{id:"tmdb",title:"TMDB",description:`Optionally provide your TMDB API Key and Read Access Token here. AIOStreams only needs one of them for title matching and its recommended and precaching to be able to
14           determine when to move to the next season. Some addons in the marketplace will require one or the other too.`,children:[(0,r.jsx)(Z,{autoComplete:"new-password",label:"TMDB Read Access Token",help:(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("p",{children:["You can get it from your"," ",(0,r.jsxs)("a",{href:"https://www.themoviedb.org/settings/api",target:"_blank",className:"text-[--brand] hover:underline",rel:"noopener noreferrer",children:["TMDB Account Settings."," "]}),"Make sure to copy the Read Access Token and not the 32 character API Key."]})}),required:!(null==e?void 0:e.settings.tmdbApiAvailable),value:t.tmdbAccessToken,placeholder:"Enter your TMDB access token",onValueChange:e=>{s(t=>({...t,tmdbAccessToken:e}))}}),(0,r.jsx)(Z,{autoComplete:"new-password",label:"TMDB API Key",help:(0,r.jsxs)("span",{children:["You can get it from your"," ",(0,r.jsxs)("a",{href:"https://www.themoviedb.org/settings/api",target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",children:["TMDB Account Settings."," "]}),"Make sure to copy the 32 character API Key and not the Read Access Token."]}),placeholder:"Enter your TMDB API Key",value:t.tmdbApiKey,onValueChange:e=>{s(t=>({...t,tmdbApiKey:e}))}})]}),(0,r.jsx)(cr,{id:"tvdbApiKey",title:"TVDB",description:"Provide your TVDB API key to also fetch metadata from TVDB.",children:(0,r.jsx)(Z,{autoComplete:"new-password",label:"TVDB API Key",value:t.tvdbApiKey,placeholder:"Enter your TVDB API Key",help:(0,r.jsxs)("span",{children:["Sign up for a ",(0,r.jsx)("b",{children:"free"})," API Key at"," ",(0,r.jsxs)("a",{href:"https://www.thetvdb.com/api-information",target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",children:["TVDB."," "]})]}),onValueChange:e=>{s(t=>({...t,tvdbApiKey:e}))}})})]})}function co(){let{userData:e,setUserData:t}=s4();return(0,r.jsxs)(cr,{title:"Poster Service",description:"Select a poster service to use for catalogs that support it.",children:[(0,r.jsx)(rn,{label:"Poster Service",options:[{label:"None",value:"none"},{label:"RPDB",value:"rpdb"},{label:"TOP Posters",value:"top-poster"},{label:"AIOratings",value:"aioratings"},{label:"OpenPosterDB",value:"openposterdb"}],value:e.posterService||"rpdb",onValueChange:e=>{t(t=>({...t,posterService:e}))},defaultValue:"rpdb"}),(!e.posterService||"rpdb"===e.posterService)&&(0,r.jsx)(Z,{autoComplete:"new-password",label:"RPDB API Key",help:(0,r.jsxs)("span",{children:["Get your API Key from"," ",(0,r.jsx)("a",{href:"https://ratingposterdb.com/api-key/",target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",children:"here"})]}),value:e.rpdbApiKey,onValueChange:e=>{t(t=>({...t,rpdbApiKey:e}))}}),"top-poster"===e.posterService&&(0,r.jsx)(Z,{autoComplete:"new-password",label:"TOP Posters API Key",help:(0,r.jsxs)("span",{children:["Get your API Key from"," ",(0,r.jsx)("a",{href:"https://api.top-posters.com/",target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",children:"TOP Posters"})]}),value:e.topPosterApiKey,onValueChange:e=>{t(t=>({...t,topPosterApiKey:e}))}}),"aioratings"===e.posterService&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Z,{autoComplete:"new-password",label:"AIOratings API Key",help:(0,r.jsxs)("span",{children:["Get your API Key from"," ",(0,r.jsx)("a",{href:"https://aioratings.com",target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",children:"here"})]}),value:e.aioratingsApiKey,onValueChange:e=>{t(t=>({...t,aioratingsApiKey:e}))}}),(0,r.jsx)(W,{label:"AIOratings Profile ID",help:(0,r.jsxs)("span",{children:["Custom profiles are a premium feature that lets you design your own poster layout. Premium users can map their API key and default posters dynamically from the"," ",(0,r.jsx)("a",{href:"https://aioratings.com",target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",children:"AIOratings website"}),'. Free users can leave this as "default".']}),value:e.aioratingsProfileId||"default",placeholder:"default",onValueChange:e=>{t(t=>({...t,aioratingsProfileId:e}))}})]}),"openposterdb"===e.posterService&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Z,{autoComplete:"new-password",label:"OpenPosterDB API Key",help:(0,r.jsxs)("span",{children:["Get your API Key from"," ",(0,r.jsx)("a",{href:"https://openposterdb.com",target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",children:"here"})]}),value:e.openposterdbApiKey,onValueChange:e=>{t(t=>({...t,openposterdbApiKey:e}))}}),(0,r.jsx)(W,{label:"OpenPosterDB URL",help:(0,r.jsx)("span",{children:"Custom base URL for OpenPosterDB. Leave empty to use the default."}),value:e.openposterdbUrl||"",placeholder:"https://openposterdb.com",onValueChange:e=>{t(t=>({...t,openposterdbUrl:e}))}}),(0,r.jsx)(W,{label:"OpenPosterDB Custom Parameters",help:(0,r.jsxs)("span",{children:["Optional query string appended to every poster to customise it (e.g. ratings, badge size and position). Enter it without the leading ",(0,r.jsx)("code",{children:"?"}),", for example"," ",(0,r.jsx)("code",{children:"ratings_limit=2&badge_size=l&position=br"}),". See the"," ",(0,r.jsx)("a",{href:"https://github.com/PNRxA/openposterdb#readme",target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",children:"available parameters"}),"."]}),value:e.openposterdbParameters||"",placeholder:"ratings_limit=2&badge_size=l&position=br",onValueChange:e=>{t(t=>({...t,openposterdbParameters:e}))}})]}),(0,r.jsx)(rs,{label:"Use Poster Service for Library/Continue Watching",side:"right",value:e.usePosterServiceForMeta||!1,onValueChange:e=>{t(t=>({...t,usePosterServiceForMeta:e}))},disabled:"none"===e.posterService||!e.rpdbApiKey&&!e.topPosterApiKey&&!e.aioratingsApiKey&&!e.openposterdbApiKey,help:(0,r.jsx)("span",{children:"If enabled, AIOStreams will use the selected poster service to fetch posters for single meta items — which generally means items in your Library and Continue Watching."})}),(0,r.jsx)(rs,{label:"Use Poster Redirect API",side:"right",disabled:"none"===e.posterService||!e.rpdbApiKey&&!e.topPosterApiKey&&!e.aioratingsApiKey&&!e.openposterdbApiKey,help:(0,r.jsx)("span",{children:"If enabled, poster URLs will first contact AIOStreams and then be redirected to the selected poster service. This allows fallback posters to be used if the selected poster service is down or does not have a poster for that item. It can however cause a minimal slowdown due to having to contact AIOStreams first."}),value:e.usePosterRedirectApi||!1,onValueChange:e=>{t(t=>({...t,usePosterRedirectApi:e}))}})]})}function cd(){return(0,r.jsx)(ru,{className:"space-y-4 p-4 sm:p-8",children:(0,r.jsx)(cc,{})})}function cc(){let{mode:e}=tX(),{isInherited:t,hasParent:s}=s9(),{tab:a,setTab:n}=ao("services");return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center w-full",children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h2",{children:"Services"}),s&&t("services")&&(0,r.jsx)(dF,{section:"services"})]}),(0,r.jsx)("p",{className:"text-[--muted]",children:"Configure your debrid, metadata, and poster services."})]}),(0,r.jsx)("div",{className:"hidden lg:block lg:ml-auto",children:(0,r.jsx)(dT,{})})]}),(0,r.jsx)(dO,{tabs:[{value:"services",label:"Services",icon:(0,r.jsx)(nD.LIi,{className:"w-4 h-4 shrink-0"}),content:(0,r.jsx)(d8,{})},{value:"builtin",label:"Built-in",icon:(0,r.jsx)(nD.VSk,{className:"w-4 h-4 shrink-0"}),content:"pro"===e?(0,r.jsx)(cl,{}):(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center gap-2",children:[(0,r.jsx)(nD.VSk,{className:"w-10 h-10 text-[--muted]"}),(0,r.jsx)("p",{className:"text-lg font-semibold",children:"Advanced Mode Required"}),(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"Built-in addon settings are only available in Advanced mode."})]})},{value:"metadata",label:"Metadata",icon:(0,r.jsx)(nD.Hbo,{className:"w-4 h-4 shrink-0"}),content:(0,r.jsx)(ci,{})},{value:"posters",label:"Posters",icon:(0,r.jsx)(nD.fZZ,{className:"w-4 h-4 shrink-0"}),content:(0,r.jsx)(co,{})}],activeTab:a,onTabChange:n,defaultMobileOpen:"services"})]})}var cu=s(6738),cm=s(254),cp=s(820),ch=s(5008),cx=s(6286);function cg(e){var t,s,a;let{preset:l,onAdd:i}
14=e,[o,d]=(0,n.useState)(!1);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"border border-[rgb(255_255_255_/_5%)] relative overflow-hidden bg-gray-900/70 rounded-xl p-3 flex flex-col h-full",children:[l.BUILTIN&&(0,r.jsx)("div",{className:"absolute -right-[30px] top-[20px] bg-[rgb(var(--color-brand-500))] text-white text-xs font-semibold py-1 w-[120px] text-center transform rotate-45 shadow-md z-[2] cursor-pointer hover:bg-[rgb(var(--color-brand-600))] transition-colors",onClick:()=>d(!0),title:"Click to learn more about built-in addons",children:"Built-in"}),(0,r.jsxs)("div",{className:"z-[1] relative flex flex-col flex-1 gap-3",children:[(0,r.jsxs)("div",{className:"flex gap-3 pr-16",children:["custom"===l.ID?(0,r.jsx)("div",{className:"relative rounded-md size-12 bg-gray-950 overflow-hidden flex items-center justify-center",children:(0,r.jsx)(cx.A,{className:"w-6 h-6 text-[--brand]"})}):l.LOGO?(0,r.jsx)("div",{className:"relative rounded-md size-12 bg-gray-900 overflow-hidden",children:(0,r.jsx)("img",{src:l.LOGO,alt:l.NAME,className:"w-full h-full object-cover"})}):(0,r.jsx)("div",{className:"relative rounded-md size-12 bg-gray-950 overflow-hidden flex items-center justify-center",children:(0,r.jsx)("p",{className:"text-2xl font-bold",children:l.NAME[0].toUpperCase()})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"font-semibold line-clamp-1",children:l.NAME}),(0,r.jsx)("p",{className:"text-xs line-clamp-1 tracking-wide opacity-30",children:l.ID})]})]}),l.DESCRIPTION&&(0,r.jsx)(U,{trigger:(0,r.jsx)("p",{className:"text-sm text-[--muted] line-clamp-2 cursor-pointer",children:(0,r.jsx)(nz,{children:l.DESCRIPTION})}),children:(0,r.jsx)("p",{className:"text-sm",children:(0,r.jsx)(nz,{children:l.DESCRIPTION})})}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[null==(t=l.SUPPORTED_SERVICES)?void 0:t.map(e=>{let t=sC[e];return(0,r.jsx)(to,{side:"top",trigger:(0,r.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-md text-xs font-medium bg-[--brand]/10 text-[--brand] border border-[--brand]/20",children:(null==t?void 0:t.shortName)||e}),children:(null==t?void 0:t.name)||e},e)}),null==(s=l.SUPPORTED_RESOURCES)?void 0:s.map(e=>(0,r.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-md text-xs font-medium bg-blue-500/10 text-blue-400 border border-blue-500/20",children:e},e)),null==(a=l.SUPPORTED_STREAM_TYPES)?void 0:a.map(e=>(0,r.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-md text-xs font-medium bg-green-500/10 text-green-400 border border-green-500/20",children:e},e))]}),(0,r.jsx)("div",{className:"flex-1"}),l.DISABLED?(0,r.jsx)("div",{className:"mt-auto",children:(0,r.jsx)(nU,{intent:"alert",className:"w-full overflow-x-auto whitespace-nowrap",description:(0,r.jsx)(nz,{children:l.DISABLED.reason})})}):(0,r.jsx)("div",{className:"mt-auto",children:(0,r.jsx)(w,{size:"md",className:"w-full",intent:"primary-subtle",onClick:i,children:"Configure"})})]})]}),(0,r.jsx)(ty,{open:o,onOpenChange:d,title:"What are Built-in Addons?",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("p",{className:"text-sm leading-relaxed",children:"Built-in addons are addons whose code lives directly inside AIOStreams. You still install and configure them from the marketplace just like any other addon (such as Comet or Torrentio), but they run locally on this AIOStreams instance."}),(0,r.jsxs)("div",{className:"bg-[--subtle] rounded-lg p-3 space-y-2",children:[(0,r.jsx)("p",{className:"text-sm font-medium",children:"Why does this matter?"}),(0,r.jsxs)("ul",{className:"text-sm text-[--muted] space-y-1.5 list-disc list-inside",children:[(0,r.jsx)("li",{children:"Not affected by rate limits from other addon servers"}),(0,r.jsx)("li",{children:"Faster response times since there's no network delay"}),(0,r.jsx)("li",{children:"Exclusive to AIOStreams and can't be installed directly to Stremio"})]})]}),(0,r.jsx)("p",{className:"text-xs text-[--muted] italic",children:"Think of it like having the addon server built into AIOStreams itself!"})]})})]})}function cf(e){let{open:t,onOpenChange:s,mode:a,presetMetadata:l,initialValues:i={},onSubmit:o}=e,{mode:d}
14=tX(),[c,u]=(0,n.useState)(i);(0,n.useEffect)(()=>{t?u(i):setTimeout(()=>{u(i)},150)},[t,i]);let m=(null==l?void 0:l.OPTIONS)||[];"noob"===d&&(m=m.filter(e=>(null==e?void 0:e.showInSimpleMode)!==!1&&(null==e?void 0:e.advanced)!==!0));let p=m.every(e=>{var t;if(!e.required)return!0;let s=null==(t=c.options)?void 0:t[e.id];return"boolean"===e.type?"boolean"==typeof s:"nab-endpoint"===e.type?!!(null==s?void 0:s.url):null!=s&&""!==s});return(0,r.jsx)(ty,{open:t,description:(0,r.jsx)(nz,{children:null==l?void 0:l.DESCRIPTION}),onOpenChange:s,title:"add"===a?`Install ${null==l?void 0:l.NAME}`:`Edit ${null==l?void 0:l.NAME}`,children:(0,r.jsxs)("form",{className:"space-y-4",onSubmit:function(e){for(let s of(e.preventDefault(),m))if(s.constraints){var t;let e=null==(t=c.options)?void 0:t[s.id];if("string"==typeof e){if(s.constraints.min&&e.length<s.constraints.min)return x.oR.error(`${s.name} must be at least ${s.constraints.min} characters`),!1;if(s.constraints.max&&e.length>s.constraints.max)return x.oR.error(`${s.name} must be at most ${s.constraints.max} characters`),!1}else if("number"==typeof e){if(s.constraints.min&&e<s.constraints.min)return x.oR.error(`${s.name} must be at least ${s.constraints.min}`),!1;if(s.constraints.max&&e>s.constraints.max)return x.oR.error(`${s.name} must be at most ${s.constraints.max}`),!1}else if("multi-select"===s.type){if(s.constraints.max&&e.length>s.constraints.max)return x.oR.error(`${s.name} must be at most ${s.constraints.max} items`),!1;if(s.constraints.min&&e.length<s.constraints.min)return x.oR.error(`${s.name} must be at least ${s.constraints.min} items`),!1}}p?o(c):x.oR.error("Please fill in all required fields")},children:[m.map(e=>{var t;return(0,r.jsx)("div",{className:"mb-2",children:(0,r.jsx)(dJ,{option:e,value:null==(t=c.options)?void 0:t[e.id],onChange:t=>u(s=>({...s,options:{...s.options,[e.id]:t}})),disabled:!1})},e.id)}),(0,r.jsx)(w,{className:"w-full mt-2",type:"submit",disabled:!p,children:"add"===a?"Install":"Update"})]})})}var cb=s(5524);function cv(){var e,t,s,a;let l,{userData:i,setUserData:o}=s4(),[d,c]=(0,n.useState)(()=>{var e,t;return(null==(e=i.dynamicAddonFetching)?void 0:e.enabled)?"dynamic":(null==(t=i.groups)?void 0:t.enabled)?"groups":"default"}),u=(e,t)=>{o(s=>{var a;let r=[...(null==(a=s.groups)?void 0:a.groupings)||[]];return r[e]={...r[e],...t},0===e&&(r[e].condition="true"),{...s,groups:{...s.groups,groupings:r}}})},m=['count(resolution(totalStreams, "2160p")) > 0 or totalTimeTaken > 5000',"queryType == 'anime' ? (count(resolution(totalStreams, '1080p')) > 0 or totalTimeTaken > 5000) : false","'addon' in queriedAddons and (totalTimeTaken >= 6000 or count(totalStreams) >= 5)","count(seeders(size(totalStreams, '5GB', '20GB'), 50)) > 0","queryType == 'movie' ? count(cached(resolution(totalStreams, '2160p'))) > 0 : count(resolution(totalStreams, '1080p')) >= 2","count(cached(quality(totalStreams, 'Bluray REMUX', 'Bluray', 'WEB-DL'))) > 0"];return(0,r.jsxs)(cr,{title:"Addon Fetching Strategy",id:"fetchStrategy",description:"Choose how streams are fetched from your addons",children:[(0,r.jsx)(rn,{label:"Strategy",value:d,onValueChange:e=>{c(e),o(t=>({...t,groups:{...t.groups,enabled:"groups"===e},dynamicAddonFetching:{...t.dynamicAddonFetching,enabled:"dynamic"===e}}))},options:[{label:"Default",value:"default"},{label:"Dynamic",value:"dynamic"},{label:"Groups",value:"groups"}]}),(0,r.jsx)("div",{className:"text-sm text-[--muted] mt-2 mb-4",children:{default:"Fetch from all addons simultaneously and wait for all addons to finish fetching before returning results.",groups:"Organise addons into groups with conditions. Each group can be evaluated based on results from previous groups. Read the [docs](https://docs.aiostreams.viren070.me/guides/groups) for more information.",dynamic:"All addons start fetching at the same time. As soon as any addon returns results, the exit condition is evaluated. If the condition is met, results are returned immediately and any remaining addon results are ignored."}[d]}),"groups"===d&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(rn,{label:"Group Behaviour",value:(null==(e=i.groups)?void 0:e.behaviour)??"parallel",onValueChange:e=>{o(t=>({...t,groups:{...t.groups,behaviour:e}}))},options:[{label:"Parallel",value:"parallel"},{label:"Sequential",value:"sequential"}],help:(null==(t=i.groups)?void 0:t.behaviour)==="sequential"?'Sequential: Start with group 1. Only fetch from group 2 if its condition evaluates to true based on group 1\'s results (e.g., "count(totalStreams) < 4"). Continue this pattern for subsequent groups.':"Parallel: Begin fetching from all groups simultaneously. When group 1's results arrive, evaluate group 2's condition. If true, wait for group 2's results; if false, return results without waiting."}),(l=e=>{let t=[...e];t.length>0&&(t[0]={...t[0],condition:"true"}),o(e=>({...e,groups:{...e.groups,groupings:t}}))},((null==(a=i.groups)?void 0:a.groupings)||[]).map((e,t)=>{var s,a,n;let o;return(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsxs)("div",{className:"flex-1 flex gap-2",children:[(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(ne,{multiple:!0,value:e.addons,options:(o=new Set((null==(n=i.groups)||null==(a=n.groupings)?void 0:a.flatMap((e,s)=>s!==t?e.addons:[]))||[]),i.presets.filter(e=>!o.has(e.instanceId)).map(e=>({label:e.options.name,value:e.instanceId,textValue:e.options.name}))),emptyMessage:"You haven't installed any addons yet or they are already in a group",label:"Addons",placeholder:"Select addons",onValueChange:e=>{u(t,{addons:e})}})}),(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(W,{value:0===t?"true":e.condition,disabled:0===t,label:"Condition",placeholder:"Enter condition",onValueChange:e=>{u(t,{condition:e})}})})]}),(0,r.jsx)(E,{size:"sm",rounded:!0,icon:(0,r.jsx)(cb.uCC,{}),intent:"primary-subtle",disabled:0===t,onClick:()=>{var e;l((0,dV.be)((null==(e=i.groups)?void 0:e.groupings)||[],t,t-1))}}),(0,r.jsx)(E,{size:"sm",rounded:!0,icon:(0,r.jsx)(cb.$TP,{}),intent:"primary-subtle",disabled:t===((null==(s=i.groups)?void 0:s.groupings)||[]).length-1,onClick:()=>{var e;l((0,dV.be)((null==(e=i.groups)?void 0:e.groupings)||[],t,t+1))}}),(0,r.jsx)(E,{size:"sm",rounded:!0,icon:(0,r.jsx)(cb.H8h,{}),intent:"alert-subtle",onClick:()=>{var e;let s=[...(null==(e=i.groups)?void 0:e.groupings)||[]];s.splice(t,1),l(s)}})]},t)})),(0,r.jsx)("div",{className:"mt-2 flex gap-2 items-center",children:(0,r.jsx)(E,{rounded:!0,size:"sm",intent:"primary-subtle",icon:(0,r.jsx)(cb.OiG,{}),onClick:()=>{o(e=>{var t;
14let s=(null==(t=e.groups)?void 0:t.groupings)||[],a={addons:[],condition:0===s.length?"true":""};return{...e,groups:{...e.groups,groupings:[...s,a]}}})}})})]}),"dynamic"===d&&(0,r.jsx)(W,{label:"Exit Condition",placeholder:m[Math.floor(Math.random()*m.length)],value:(null==(s=i.dynamicAddonFetching)?void 0:s.condition)??"",onValueChange:e=>{o(t=>({...t,dynamicAddonFetching:{...t.dynamicAddonFetching,condition:e}}))},help:(0,r.jsxs)("p",{children:["Write the condition using"," ",(0,r.jsx)("a",{href:"https://docs.aiostreams.viren070.me/reference/stream-expressions",target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",children:"Stream Expression Language (SEL)"}),". The following variables are available:",(0,r.jsxs)("ul",{className:"list-disc list-inside space-y-1 ml-2 mt-2",children:[(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{children:"totalStreams"}),": The total number of streams"]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{children:"totalTimeTaken"}),": The total time taken to fetch the streams"]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{children:"queryType"}),": The type of query e.g. 'movie', 'series', or 'anime'"]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{children:"queriedAddons"}),": The addons that have been queried. Tip: use the ",(0,r.jsx)("code",{children:"in"})," operator to check if a specific addon has been queried."]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{children:"allAddons"}),": All addons that were intended to be used for that query."]})]})]})})]})}var cy=s(7737),cj=s(2814);function cw(e){let{catalog:t,onToggleEnabled:s,capitalise:a}=e,{attributes:l,listeners:i,setNodeRef:o,transform:d,transition:c,isDragging:u}=(0,dV.gl)({id:`${t.id}-${t.type}`}),{setUserData:m}=s4(),p=t.id.startsWith("aiostreams.merged."),h={transform:dq.Ks.Transform.toString(d),transition:c,opacity:u?.5:1},g=()=>{m(e=>{if(!e.catalogModifications)return e;let s=e.catalogModifications.findIndex(e=>e.id===t.id&&e.type===t.type);if(s<=0)return e;let a=[...e.catalogModifications],[r]=a.splice(s,1);return a.unshift(r),{...e,catalogModifications:a}})},f=()=>{m(e=>{if(!e.catalogModifications)return e;let s=e.catalogModifications.findIndex(e=>e.id===t.id&&e.type===t.type);if(s===e.catalogModifications.length-1)return e;let a=[...e.catalogModifications],[r]=a.splice(s,1);return a.push(r),{...e,catalogModifications:a}})},b=t.shuffle?"shuffle":t.reverse?"reverse":"default",v=["default","shuffle","reverse"],[y,j]=(0,n.useState)(!1),[N,k]=(0,n.useState)(t.name||""),[S,C]=(0,n.useState)(t.overrideType||t.type||""),_="text-xl h-8 w-8 lg:text-2xl lg:h-10 lg:w-10";return(0,r.jsxs)("li",{ref:o,style:h,children:[(0,r.jsxs)("div",{className:"relative px-2.5 py-2 bg-[var(--background)] rounded-[--radius-md] border overflow-hidden",children:[(0,r.jsx)("div",{className:"absolute top-2 bottom-2 left-2 w-5 bg-[var(--muted)] md:bg-[var(--subtle)] md:hover:bg-[var(--subtle-highlight)] cursor-move flex-shrink-0 rounded-full",...l,...i}),(0,r.jsxs)("div",{className:"pl-8 pr-3 py-3",children:[(0,r.jsxs)("div",{className:"mb-4 md:mb-6 md:pr-40",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,r.jsxs)("h3",{className:"text-sm md:text-base font-medium line-clamp-1 truncate text-ellipsis",children:[t.name??t.id," -"," ",a(t.overrideType??t.type)]}),!p&&(0,r.jsx)(E,{className:"rounded-full h-5 w-5 md:h-6 md:w-6 flex-shrink-0",icon:(0,r.jsx)(tC.u6n,{}),intent:"primary-subtle",onClick:()=>j(!0)})]}),(0,r.jsx)("p",{className:"text-xs md:text-sm text-[var(--muted-foreground)] mb-2 md:mb-0",children:p?"Merged Catalog":t.addonName}),(0,r.jsxs)("div",{className:"flex md:hidden items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)(E,{rounded:!0,className:_,icon:(0,r.jsx)(J.TaX,{}),intent:"primary-subtle",onClick:g,title:"Move to top"}),(0,r.jsx)(E,{rounded:!0,className:_,icon:(0,r.jsx)(J.KVh,{}),intent:"primary-subtle",onClick:f,title:"Move to bottom"})]}),(0,r.jsx)(rs,{value:t.enabled??!0,onValueChange:s,moreHelp:"Enable or disable this catalog from being used"})]}),(0,r.jsxs)("div",{className:"hidden md:flex items-center justify-end gap-2 absolute top-4 right-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)(E,{rounded:!0,icon:(0,r.jsx)(J.TaX,{}),intent:"primary-subtle",onClick:g,title:"Move to top"}),(0,r.jsx)(E,{rounded:!0,icon:(0,r.jsx)(J.KVh,{}),intent:"primary-subtle",onClick:f,title:"Move to bottom"})]}),(0,r.jsx)(rs,{value:t.enabled??!0,onValueChange:s,moreHelp:"Enable or disable this catalog from being used"})]})]})," ",(0,r.jsx)(dM,{type:"single",collapsible:!0,children:(0,r.jsxs)(dP,{value:"settings",children:[(0,r.jsx)(dD,{children:(0,r.jsxs)("div",{className:"flex items-center justify-center md:justify-between w-full",children:[(0,r.jsx)("h4",{className:"text-xs font-medium text-[var(--muted-foreground)] uppercase tracking-wide hidden md:block",children:"Settings"}),(0,r.jsxs)("div",{className:"flex items-center gap-2 mr-2",children:[p&&(0,r.jsx)(to,{trigger:(0,r.jsx)("div",{className:"flex items-center justify-center h-10 w-10 rounded-full bg-[var(--brand-subtle)]",children:(0,r.jsx)(J.dPp,{className:"text-xl text-[var(--brand)]"})}),children:"Merged Catalog"}),(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{className:"text-2xl h-10 w-10",icon:t.shuffle?(0,r.jsx)(da.xAZ,{}):t.reverse?(0,r.jsx)(da.oWm,{}):(0,r.jsx)(da.j6T,{}),intent:"primary-subtle",rounded:!0,onClick:e=>{e.stopPropagation(),m(e=>{var s,a;if(!(null==(s=e.catalogModifications)?void 0:s.find(e=>e.id===t.id&&e.type===t.type)))return e;let r=v[(v.indexOf(b)+1)%v.length];return{...e,catalogModifications:null==(a=e.catalogModifications)?void 0:a.map(e=>e.id===t.id&&e.type===t.type?{...e,shuffle:"shuffle"===r,reverse:"reverse"===r}:e)}})}}),children:b.charAt(0).toUpperCase()+b.slice(1)}),(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{className:"text-2xl h-10 w-10",icon:t.usePosterService?(0,r.jsx)(cj.PYM,{}):(0,r.jsx)(cj.h4A,{}),intent:"primary-subtle",rounded:!0,onClick:e=>{e.stopPropagation(),m(e=>{var s;return{...e,catalogModifications:null==(s=e.catalogModifications)?void 0:s.map(e=>e.id===t.id&&e.type===t.type?{...e,usePosterService:!e.usePosterService}:e)}})}}),children:"Poster Services"}),t.hideable&&(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{className:"text-2xl h-10 w-10",icon:t.onlyOnDiscover?(0,r.jsx)(cy.o$K,{}):(0,r.jsx)(cy.tTb,{}),disabled:t.onlyOnSearch,intent:"primary-subtle",rounded:!0,onClick:e=>{e.stopPropagation(),m(e=>{var s;return{...e,catalogModifications:null==(s=e.catalogModifications)?void 0:s.map(e=>e.id===t.id&&e.type===t.type?{...e,onlyOnDiscover:!e.onlyOnDiscover}:e)}})}}),children:"Discover Only"}),t.searchable&&(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{className:"text-2xl h-10 w-10",icon:t.onlyOnSearch?(0,r.jsx)(cp.TOn,{}):t.disableSearch?(0,r.jsx)(cy.QDx,{}):(0,r.jsx)(cy.PuI,{}),intent:"primary-subtle",rounded:!0,onClick:e=>{e.stopPropagation(),m(e=>{var s;return{...e,catalogModifications:null==(s=e.catalogModifications)?void 0:s.map(e=>e.id!==t.id||e.type!==t.type?e:e.onlyOnSearch||e.disableSearch?e.onlyOnSearch?{...e,onlyOnSearch:!1,disableSearch:!0}:{...e,disableSearch:!1}:{...e,onlyOnSearch:!0,onlyOnDiscover:!1})}})}}),children:t.onlyOnSearch?"Search Only":t.disableSearch?"Search Disabled":"Searchable"})]})]})}),(0,r.jsx)(dL,{children:(0,r.jsx)("div",{className:"space-y-4",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(rs,{label:"Shuffle",help:"Randomize the order of catalog items on each request",side:"right",value:t.shuffle??!1,onValueChange:e=>{m(s=>{var a;return{...s,catalogModifications:null==(a=s.catalogModifications)?void 0:a.map(s=>s.id===t.id&&s.type===t.type?{...s,shuffle:e,reverse:!e&&s.reverse}:s)}})}}),(0,r.jsx)(rs,{label:"Reverse Order",help:"Reverse the order of catalog items",side:"right",value:t.reverse??!1,onValueChange:e=>{m(s=>{var a;return{...s,catalogModifications:null==(a=s.catalogModifications)?void 0:a.map(s=>s.id===t.id&&s.type===t.type?{...s,reverse:e,shuffle:!e&&s.shuffle}:s)}})}}),(0,r.jsxs)("div",{className:"flex flex-col md:flex-row md:items-center gap-2 -mx-2 px-2 hover:bg-[var(--subtle-highlight)] rounded-md",children:[(0,r.jsxs)("div",{className:"flex-1 py-2",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Persist Shuffle For"}),(0,r.jsx)("p",{className:"text-xs text-[--muted]",children:"The amount of hours to keep a given shuffled catalog order before shuffling again. Defaults to 0 (Shuffle on every request)."})]}),(0,r.jsx)("div",{className:"w-full md:w-32 py-2",children:(0,r.jsx)(nn,{value:t.persistShuffleFor??0,min:0,step:1,max:24,onValueChange:e=>{m(s=>{var a;return{...s,catalogModifications:null==(a=s.catalogModifications)?void 0:a.map(s=>s.id===t.id&&s.type===t.type?{...s,persistShuffleFor:e}:s)}})}})})]}),(0,r.jsx)(rs,{label:"Poster Services",help:"Replace movie/show posters with posters from poster services (RPDB or TOP Posters) when supported",side:"right",value:t.usePosterService??!1,onValueChange:e=>{m(s=>{var a;return{...s,catalogModifications:null==(a=s.catalogModifications)?void 0:a.map(s=>s.id===t.id&&s.type===t.type?{...s,usePosterService:e}:s)}})}}),t.hideable&&(0,r.jsx)(rs,{label:"Discover Only",help:"Hide this catalog from the home page and only show it on the Discover page",side:"right",value:t.onlyOnDiscover??!1,disabled:t.onlyOnSearch,onValueChange:e=>{m(s=>{var a;return{...s,catalogModifications:null==(a=s.catalogModifications)?void 0:a.map(s=>s.id===t.id&&s.type===t.type?{...s,onlyOnDiscover:e,onlyOnSearch:!e&&s.onlyOnSearch}:s)}})}}),t.searchable&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(rs,{label:"Search Only",help:"Only show this catalog when searching",side:"right",value:t.onlyOnSearch??!1,disabled:t.disableSearch,onValueChange:e=>{m(s=>{var a;return{...s,catalogModifications:null==(a=s.catalogModifications)?void 0:a.map(s=>s.id===t.id&&s.type===t.type?{...s,onlyOnSearch:e,onlyOnDiscover:!e&&s.onlyOnDiscover}:s)}})}}),(0,r.jsx)(rs,{label:"Disable Search",help:"Disable the search for this catalog",side:"right",value:t.disableSearch??!1,onValueChange:e=>{m(s=>{var a;return{...s,catalogModifications:null==(a=s.catalogModifications)?void 0:a.map(s=>s.id===t.id&&s.type===t.type?{...s,disableSearch:e,onlyOnSearch:!e&&s.onlyOnSearch}:s)}})}})]})]})})})]})})]})]}),(0,r.jsx)(ty,{open:y,onOpenChange:j,title:"Edit Catalog Name",children:(0,r.jsxs)("form",{className:"space-y-4",onSubmit:e=>{e.preventDefault(),S?(m(e=>{var s;return{...e,catalogModifications:null==(s=e.catalogModifications)?void 0:s.map(e=>e.id===t.id&&e.type===t.type?{...e,name:N,overrideType:S}:e)}}),j(!1)):x.oR.error("Type cannot be empty")},children:[(0,r.jsx)(W,{label:"Name",placeholder:"Enter catalog name",value:N,onValueChange:k}),(0,r.jsx)(W,{label:"Type",placeholder:"Enter catalog type",value:S,onValueChange:C}),(0,r.jsx)(w,{className:"w-full",type:"submit",children:"Save Changes"})]})})]})}function cN(e){var t,s,a;let{loading:l,fetchCatalogsData:i}=e,{userData:o,setUserData:d}=s4(),c=(0,n.useRef)((null==(t=o.mergedCatalogs)?void 0:t.length)??0);(0,n.useEffect)(()=>{var e;let t=(null==(e=o.mergedCatalogs)?void 0:e.length)??0;t!==c.current&&(c.current=t,i(!0))},[null==(s=o.mergedCatalogs)?void 0:s.length,i]);let u=e=>e?e.charAt(0).toUpperCase()+e.slice(1):"",m=(0,n.useMemo)(()=>{let e=new Set;for(let t of(o.mergedCatalogs||[]).filter(e=>!1!==e.enabled))for(let s of t.catalogIds){let t=new URLSearchParams(s),a=t.get("id"),r=t.get("type");a&&r&&e.add(`${a}-${r}`)}return e},[o.mergedCatalogs]),p=(0,dB.FR)((0,dB.MS)(dB.AN),(0,dB.MS)(dB.IG,{activationConstraint:{delay:150,tolerance:8}}
14)),[h,x]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{function e(e){h&&e.preventDefault()}function t(){x(!1)}return h?(document.body.addEventListener("touchmove",e,{passive:!1}),document.addEventListener("pointerup",t),document.addEventListener("touchend",t)):document.body.removeEventListener("touchmove",e),()=>{document.body.removeEventListener("touchmove",e),document.removeEventListener("pointerup",t),document.removeEventListener("touchend",t)}},[h]),(0,r.jsxs)(cr,{title:"Catalogs",id:"catalogs",description:"Rename, reorder, and toggle your catalogs, and apply modifications like RPDB posters and shuffling. Adjusting catalogs may require a reinstall - if it does, a pop-up will tell you.",action:(0,r.jsx)(E,{size:"sm",intent:"warning-subtle",icon:(0,r.jsx)(cp.joZ,{}),rounded:!0,onClick:()=>{i()},loading:l}),children:[!(null==(a=o.catalogModifications)?void 0:a.length)&&(0,r.jsx)("p",{className:"text-[--muted] text-base text-center my-8",children:"Your addons don't have any catalogs... or you haven't fetched them yet :/"}),o.catalogModifications&&o.catalogModifications.length>0&&(0,r.jsx)(dB.Mp,{modifiers:[dz.FN],onDragEnd:e=>{let{active:t,over:s}=e;s&&(t.id!==s.id&&d(e=>{var a,r;let n=null==(a=e.catalogModifications)?void 0:a.findIndex(e=>`${e.id}-${e.type}`===t.id),l=null==(r=e.catalogModifications)?void 0:r.findIndex(e=>`${e.id}-${e.type}`===s.id);return void 0!==n&&void 0!==l&&e.catalogModifications?{...e,catalogModifications:(0,dV.be)(e.catalogModifications,n,l)}:e}),x(!1))},onDragStart:()=>{x(!0)},sensors:p,children:(0,r.jsx)(dV.gB,{items:(o.catalogModifications||[]).map(e=>`${e.id}-${e.type}`),strategy:dV._G,children:(0,r.jsx)("ul",{className:"space-y-2",children:(o.catalogModifications||[]).filter(e=>!m.has(`${e.id}-${e.type}`)).map(e=>(0,r.jsx)(cw,{catalog:e,onToggleEnabled:t=>{d(s=>{var a,r;let n={catalogModifications:null==(a=s.catalogModifications)?void 0:a.map(s=>s.id===e.id&&s.type===e.type?{...s,enabled:t}:s)};return e.id.startsWith("aiostreams.merged.")&&(n.mergedCatalogs=null==(r=s.mergedCatalogs)?void 0:r.map(s=>s.id===e.id?{...s,enabled:t}:s)),{...s,...n}})},capitalise:u},`${e.id}-${e.type}`))})})})]})}function ck(){var e,t;let s,{userData:a,setUserData:l}=s4(),{status:i}=e$(),o=(null==i||null==(t=i.settings)||null==(e=t.limits)?void 0:e.maxMergedCatalogSources)??10,[d,c]=(0,n.useState)(!1),[u,m]=(0,n.useState)(null),[p,h]=(0,n.useState)(""),[g,f]=(0,n.useState)("movie"),[b,v]=(0,n.useState)([]),[y,j]=(0,n.useState)(["id"]),[N,k]=(0,n.useState)("sequential"),[S,C]=(0,n.useState)(""),[_,R]=(0,n.useState)(new Set),[A,I]=(0,n.useState)(null),M=tN({title:"Delete Merged Catalog",description:"This is the last catalog in this merged catalog. Removing it will delete the entire merged catalog. Are you sure?",actionText:"Delete Merged Catalog",actionIntent:"alert",onConfirm:()=>{A&&(l(e=>{var t,s;return{...e,mergedCatalogs:null==(t=e.mergedCatalogs)?void 0:t.filter(e=>e.id!==A),catalogModifications:null==(s=e.catalogModifications)?void 0:s.filter(e=>e.id!==A)}}),I(null),x.oR.success("Merged catalog deleted"))}}),P=a.mergedCatalogs||[],D=e=>e?e.charAt(0).toUpperCase()+e.slice(1):"",L=(a.catalogModifications||[]).filter(e=>!e.id.startsWith("aiostreams.merged.")).map(e=>({value:`id=${encodeURIComponent(e.id)}&type=${encodeURIComponent(e.type)}`,name:e.name||e.id,catalogType:e.type,addonName:e.addonName||"Unknown Addon",isDisabled:!1===e.enabled})),U=Object.entries(L.reduce((e,t)=>(e[t.addonName]||(e[t.addonName]=[]),e[t.addonName].push(t),e),{})).reduce((e,t)=>{let[s,a]=t,r=a.filter(e=>e.name.toLowerCase().includes(S.toLowerCase())||e.addonName.toLowerCase().includes(S.toLowerCase())||e.catalogType.toLowerCase().includes(S.toLowerCase()));if(r.length>0){let t=[...r].sort((e,t)=>{let s=e.name.localeCompare(t.name);return 0!==s?s:e.catalogType.localeCompare(t.catalogType)});e[s]=t}return e},{});return(0,r.jsxs)(cr,{title:"Merged Catalogs",id:"mergedCatalogs",description:"Combine multiple catalogs into a single merged catalog. Useful for creating custom collections from different sources.",action:(0,r.jsx)(E,{size:"sm",intent:"primary-subtle",icon:(0,r.jsx)(cb.OiG,{}),rounded:!0,onClick:()=>{m(null),h(""),f("movie"),v([]),j(["id"]),k("sequential"),C(""),R(new Set),c(!0)}}),children:[0===P.length&&(0,r.jsx)("p",{className:"text-[--muted] text-base text-center my-8",children:"No merged catalogs yet. Click the + button to create one."}),P.length>0&&(0,r.jsx)("ul",{className:"space-y-2",children:P.map(e=>(0,r.jsx)("li",{children:(0,r.jsxs)("div",{className:"relative px-4 py-3 bg-[var(--background)] rounded-[--radius-md] border overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[(0,r.jsx)("div",{className:"flex items-center justify-center w-10 h-10 rounded-full bg-[var(--subtle)] flex-shrink-0",children:(0,r.jsx)(J.dPp,{className:"text-xl"})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("h3",{className:"text-sm md:text-base font-medium truncate",children:e.name}),(0,r.jsxs)("p",{className:"text-xs text-[var(--muted-foreground)]",children:[D(e.type)," • ",e.catalogIds.length," catalogs"]})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(E,{className:"h-8 w-8",icon:(0,r.jsx)(tC.u6n,{}),intent:"primary-subtle",rounded:!0,onClick:()=>{m(e),h(e.name),f(e.type),v(e.catalogIds),j(e.deduplicationMethods??["
14id"]),k(e.mergeMethod??"sequential"),C(""),R(new Set),c(!0)}}),(0,r.jsx)(E,{className:"h-8 w-8",icon:(0,r.jsx)(tC.id1,{}),intent:"alert-subtle",rounded:!0,onClick:()=>{var t;return t=e.id,void(l(e=>({...e,mergedCatalogs:(e.mergedCatalogs||[]).filter(e=>e.id!==t),catalogModifications:(e.catalogModifications||[]).filter(e=>e.id!==t)})),x.oR.success("Merged catalog deleted"))}})]})]}),(0,r.jsx)(dM,{type:"single",collapsible:!0,className:"mt-2",children:(0,r.jsxs)(dP,{value:"settings",children:[(0,r.jsx)(dD,{children:(0,r.jsx)("div",{className:"flex items-center justify-center md:justify-between w-full",children:(0,r.jsxs)("h4",{className:"text-xs font-medium text-[var(--muted-foreground)] uppercase tracking-wide hidden md:block",children:["Included Catalogs (",e.catalogIds.length,")"]})})}),(0,r.jsx)(dL,{children:(0,r.jsx)("div",{className:"space-y-4",children:(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5",children:e.catalogIds.map(t=>{let s=L.find(e=>e.value===t),a=!s,n=e.catalogIds.filter(e=>L.find(t=>t.value===e)).length,i=!a&&1===n,o=1===e.catalogIds.length;return(0,r.jsxs)("span",{className:`inline-flex items-center gap-1.5 text-xs px-2 py-1 rounded-md bg-[var(--subtle)] border border-[var(--border)] text-[var(--muted-foreground)] ${(null==s?void 0:s.isDisabled)?"opacity-60":""} ${a?"bg-orange-50 dark:bg-orange-500/10 border border-orange-300 dark:border-orange-500/50":""}`,children:[(0,r.jsx)("span",{className:"font-medium text-[var(--foreground)]",children:s?s.name:"Unavailable Catalog"}),(null==s?void 0:s.isDisabled)&&(0,r.jsx)("span",{className:"text-[10px] px-1 py-0.5 rounded text-[--red]",children:"Disabled"}),s&&(0,r.jsx)("span",{className:"text-[10px] px-1 py-0.5 rounded bg-brand-800/20 border border-[--brand] border-brand-500/50 text-[--muted-foreground]",children:D(s.catalogType)}),(0,r.jsx)(T,{type:"button",className:"ml-0.5",size:"sm",onClick:s=>{if(s.stopPropagation(),i)return void x.oR.error("Cannot remove the last available catalog. Add another catalog first or delete the merged catalog.");if(o&&a){I(e.id),M.open();return}l(s=>{var a;return{...s,mergedCatalogs:null==(a=s.mergedCatalogs)?void 0:a.map(s=>s.id===e.id?{...s,catalogIds:s.catalogIds.filter(e=>e!==t)}:s)}})},title:i?"Cannot remove last available catalog":"Remove catalog"})]},t)})})})})]})})]})},e.id))}),(0,r.jsx)(ty,{open:d,onOpenChange:c,title:u?"Edit Merged Catalog":"Create Merged Catalog",children:(0,r.jsxs)("form",{className:"space-y-4",onSubmit:e=>{e.preventDefault(),(()=>{if(!p.trim())return x.oR.error("Name is required");if(!g.trim())return x.oR.error("Type is required");if(b.length<2)return x.oR.error("Select at least 2 catalogs to merge");if(b.length>o)return x.oR.error(`Maximum ${o} source catalogs allowed per merged catalog`);if(u)l(e=>({...e,catalogModifications:(e.catalogModifications||[]).map(e=>e.id===u.id&&e.type===u.type?{...e,name:p.trim(),type:g.trim()}:e),mergedCatalogs:(e.mergedCatalogs||[]).map(e=>e.id===u.id?{...e,name:p.trim(),type:g.trim(),catalogIds:b,deduplicationMethods:y.length>0?y:void 0,mergeMethod:N??"sequential"}:e)})),x.oR.success("Merged catalog updated");else{let e=`aiostreams.merged.${Date.now()}`;l(t=>({...t,mergedCatalogs:[...t.mergedCatalogs||[],{id:e,name:p.trim(),type:g.trim(),catalogIds:b,enabled:!0,deduplicationMethods:y.length>0?y:void 0,mergeMethod:N??"sequential"}]})),x.oR.success("Merged catalog created")}c(!1)})()},children:[(0,r.jsx)(W,{label:"Name",placeholder:"e.g., My Combined Movies",value:p,onValueChange:h}),(0,r.jsx)(W,{label:"Type",placeholder:"e.g., movie, series, anime",help:"The content type for this merged catalog (e.g., movie, series, anime, tv)",value:g,onValueChange:f}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("label",{className:"text-sm font-medium",children:"Catalogs to Merge"}),(0,r.jsxs)("span",{className:"text-xs text-[--muted]",children:[b.length," selected"]})]}),(0,r.jsx)(W,{placeholder:"Search catalogs...",value:S,onValueChange:C}),(0,r.jsx)("div",{className:"border rounded-[--radius-md] h-64 overflow-y-auto",children:0===Object.keys(U).length?(0,r.jsx)("p",{className:"text-sm text-[--muted] text-center py-8",children:S?"No catalogs match your search":"No catalogs available"}):Object.entries(U).map(e=>{let[t,s]=e,a=_.has(t);return(0,r.jsxs)("div",{className:"border-b last:border-b-0",children:[(0,r.jsxs)("div",{onClick:()=>{R(e=>{let s=new Set(e);return s.has(t)?s.delete(t):s.add(t),s})},className:"px-3 py-2 bg-[var(--subtle)] cursor-pointer hover:bg-[var(--subtle-highlight)] flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("svg",{className:`w-4 h-4 transition-transform ${a?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),(0,r.jsx)("span",{className:"text-xs font-semibold text-[var(--muted-foreground)] uppercase tracking-wide",children:t})]}),(0,r.jsx)("div",{className:"flex items-center gap-2",children:(0,r.jsxs)("span",{className:"text-xs text-[var(--muted-foreground)]",children:[s.length," catalog",1!==s.length?"s":""]})})]}),a&&s.map(e=>{let t=b.includes(e.value);return(0,r.jsxs)("div",{onClick:()=>{var t;return t=e.value,void v(e=>e.includes(t)?e.filter(e=>e!==t):e.length>=o?(x.oR.error(`Maximum ${o} source catalogs allowed`),e):[...e,t])},className:`flex items-center gap-3 px-3 py-2 cursor-pointer transition-colors ${t?"bg-[var(--brand-subtle)] hover:bg-[var(--brand-subtle)]":"hover:bg-[var(--subtle-highlight)]"} ${e.isDisabled?"opacity-60":""}`,children:[(0,r.jsx)("div",{className:`w-4 h-4 rounded border-2 flex items-center justify-center flex-shrink-0 transition-colors ${t?"bg-[var(--brand)] border-[var(--brand)]":"border-[var(--muted)]"}
14`,children:t&&(0,r.jsx)("svg",{className:"w-3 h-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),(0,r.jsx)("div",{className:"flex-1 min-w-0",children:(0,r.jsx)("span",{className:`text-sm font-medium truncate block ${e.isDisabled?"text-[var(--muted-foreground)]":""}`,children:e.name})}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.isDisabled&&(0,r.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-orange-800/20 border border-orange-500/50 text-orange-300",children:"Disabled"}),(0,r.jsx)("span",{className:"text-xs px-2 py-0.5 rounded-full text-[var(--muted-foreground)] bg-brand-800/20 border border-brand-500/50",children:D(e.catalogType)})]})]},e.value)})]},t)})}),b.length>0&&(0,r.jsxs)(r.Fragment,{children:[0===(s=b.filter(e=>!L.find(t=>t.value===e))).length?null:(0,r.jsx)("div",{className:"p-3 rounded-[--radius] bg-orange-50 dark:bg-orange-500/10 border border-orange-300 dark:border-orange-500/50",children:(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsxs)("p",{className:"text-sm text-orange-700 dark:text-orange-300",children:[s.length," unavailable catalog",1!==s.length?"s":""," found"]}),(0,r.jsx)(w,{type:"button",size:"sm",intent:"warning",onClick:()=>v(e=>e.filter(e=>L.find(t=>t.value===e))),children:"Remove All"})]})}),(0,r.jsxs)("div",{className:"text-xs text-[--muted]",children:["Selected (",b.length,"/",o,"):"," ",b.filter(e=>L.find(t=>t.value===e)).slice(0,3).map(e=>{let t=L.find(t=>t.value===e);return(null==t?void 0:t.name)||e}).join(", "),b.filter(e=>L.find(t=>t.value===e)).length>3&&` +${b.filter(e=>L.find(t=>t.value===e)).length-3} more`]})]})]}),(0,r.jsx)(ne,{multiple:!0,label:"Deduplication Methods",help:"Methods to remove duplicate items (applied in order). Leave empty to keep all items.",options:[{value:"id",label:"By ID - Remove items with same ID"},{value:"title",label:"By Title - Remove items with same title"}],value:y,onValueChange:e=>j(e),placeholder:"None - Keep all items",emptyMessage:"No deduplication methods available"}),(0,r.jsx)(rn,{label:"Merge Method",help:"How to combine results from the source catalogs.",options:[{value:"sequential",label:"Sequential"},{value:"interleave",label:"Interleave"},{value:"imdbRating",label:"IMDb Rating"},{value:"releaseDateDesc",label:"Release Date (Newest)"},{value:"releaseDateAsc",label:"Release Date (Oldest)"}],value:N??"sequential",onValueChange:e=>k(e)}),("imdbRating"===N||"releaseDateDesc"===N||"releaseDateAsc"===N)&&(0,r.jsx)(nU,{intent:"alert",description:"Sorting is applied per page only. Items are sorted within each page of results, not globally across all pages. A lower-rated item from page 1 may still appear before a higher-rated item from page 2."}),(0,r.jsx)(w,{className:"w-full",type:"submit",children:u?"Save Changes":"Create Merged Catalog"})]})}),(0,r.jsx)(tk,{...M})]})}function cS(e){let{item:t}=e,{attributes:s,listeners:a,setNodeRef:n,transform:l,transition:i,isDragging:o}=(0,dV.gl)({id:t.instanceId}),d={transform:dq.Ks.Transform.toString(l),transition:i,opacity:o?.6:1,zIndex:10*!!o};return(0,r.jsxs)("li",{ref:n,style:d,className:`flex items-center gap-3 px-3 py-2 rounded-lg border bg-[var(--background)] select-none ${o?"shadow-lg border-[--brand]/50":"border-[--border]"} ${!t.enabled?"opacity-50":""}`,...s,children:[(0,r.jsx)("div",{className:"flex items-center justify-center w-5 text-sm font-mono text-[--muted] flex-shrink-0 cursor-move touch-none",...a,children:(0,r.jsx)("svg",{className:"w-4 h-4 text-[--muted]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{d:"M4 8h16M4 16h16",strokeLinecap:"round"})})}),(0,r.jsx)("div",{className:"relative flex-shrink-0 h-6 w-6",children:t.logo?(0,r.jsx)("img",{src:t.logo,alt:t.name,className:"absolute inset-0 w-full h-full object-contain rounded"}):"custom"===t.type?(0,r.jsx)(cx.A,{className:"w-full h-full text-[--brand]"}):(0,r.jsx)(cm.Yoo,{className:"w-full h-full text-[--brand]"})}),(0,r.jsx)("span",{className:"text-sm font-medium truncate flex-1",children:t.name}),!t.enabled&&(0,r.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-[--subtle] text-[--muted] border border-[--border]",children:"Disabled"})]})}function cC(e){let{open:t,onOpenChange:s,presets:a,presetMetadataMap:l,manifestCache:i,onSave:o}
14=e,[d,c]=(0,n.useState)([]),[u,m]=(0,n.useState)(!1);(0,n.useEffect)(()=>{t&&c([...a])},[t,a]);let p=(0,dB.FR)((0,dB.MS)(dB.AN),(0,dB.MS)(dB.IG,{activationConstraint:{delay:150,tolerance:8}}));(0,n.useEffect)(()=>{function e(e){u&&e.preventDefault()}function t(){m(!1)}return u?(document.body.addEventListener("touchmove",e,{passive:!1}),document.addEventListener("pointerup",t),document.addEventListener("touchend",t)):document.body.removeEventListener("touchmove",e),()=>{document.body.removeEventListener("touchmove",e),document.removeEventListener("pointerup",t),document.removeEventListener("touchend",t)}},[u]);let h=d.map(e=>{var t;let s=l.get(e.type),a=function(e,t){var s,a;if((null==t?void 0:t.ID)==="custom"||(null==t?void 0:t.ID)==="aiostreams")return null==(a=e.options)?void 0:a.manifestUrl;let r=null==(s=e.options)?void 0:s.url;if(r)try{if(new URL(r).pathname.endsWith("/manifest.json"))return r}catch{}}(e,s),r=a?i.get(a.replace(/^stremio:\/\//,"https://").replace(/\/$/,"")):void 0;return{instanceId:e.instanceId,name:(null==(t=e.options)?void 0:t.name)||(null==s?void 0:s.NAME)||e.type,type:(null==s?void 0:s.ID)||e.type,logo:(null==r?void 0:r.logo)||e.logo||(null==s?void 0:s.LOGO),enabled:e.enabled??!0}});return(0,r.jsx)(ty,{open:t,onOpenChange:s,title:"Reorder Addon Priority",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("p",{className:"text-sm text-[--muted]",children:["Drag addons to change their priority. Addons higher in the list have higher priority during deduplication and also controls sorting"," ",(0,r.jsx)("b",{children:"when sorting by the addon criterion"}),"."]}),(0,r.jsx)(dB.Mp,{modifiers:[dz.FN],onDragEnd:function(e){let{active:t,over:s}=e;s&&(t.id!==s.id&&c(e=>{let a=e.findIndex(e=>e.instanceId===t.id),r=e.findIndex(e=>e.instanceId===s.id);return(0,dV.be)(e,a,r)}),m(!1))},onDragStart:()=>m(!0),sensors:p,children:(0,r.jsx)(dV.gB,{items:h.map(e=>e.instanceId),strategy:dV._G,children:(0,r.jsx)("ul",{className:"space-y-1.5 max-h-[60vh] overflow-y-auto pr-1",children:h.map(e=>(0,r.jsx)(cS,{item:e},e.instanceId))})})}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(w,{className:"flex-1",intent:"primary-subtle",onClick:()=>s(!1),children:"Cancel"}),(0,r.jsx)(w,{className:"flex-1",onClick:()=>{o(d),s(!1)},children:"Save Order"})]})]})})}let c_=new Map,cR=[{key:"blue",bg:"bg-blue-500/15",text:"text-blue-400",border:"border-blue-500/40",swatch:"bg-blue-500"},{key:"purple",bg:"bg-purple-500/15",text:"text-purple-400",border:"border-purple-500/40",swatch:"bg-purple-500"},{key:"amber",bg:"bg-amber-500/15",text:"text-amber-400",border:"border-amber-500/40",swatch:"bg-amber-500"},{key:"emerald",bg:"bg-emerald-500/15",text:"text-emerald-400",border:"border-emerald-500/40",swatch:"bg-emerald-500"},{key:"rose",bg:"bg-rose-500/15",text:"text-rose-400",border:"border-rose-500/40",swatch:"bg-rose-500"},{key:"cyan",bg:"bg-cyan-500/15",text:"text-cyan-400",border:"border-cyan-500/40",swatch:"bg-cyan-500"},{key:"orange",bg:"bg-orange-500/15",text:"text-orange-400",border:"border-orange-500/40",swatch:"bg-orange-500"},{key:"pink",bg:"bg-pink-500/15",text:"text-pink-400",border:"border-pink-500/40",swatch:"bg-pink-500"},{key:"teal",bg:"bg-teal-500/15",text:"text-teal-400",border:"border-teal-500/40",swatch:"bg-teal-500"},{key:"indigo",bg:"bg-indigo-500/15",text:"text-indigo-400",border:"border-indigo-500/40",swatch:"bg-indigo-500"},{key:"lime",bg:"bg-lime-500/15",text:"text-lime-400",border:"border-lime-500/40",swatch:"bg-lime-500"},{key:"red",bg:"bg-red-500/15",text:"text-red-400",border:"border-red-500/40",swatch:"bg-red-500"}],cA={streams:cR[0],subtitles:cR[1],meta_catalogs:cR[2],misc:cR[3]},cT={streams:"Streams",subtitles:"Subtitles",meta_catalogs:"Metadata & Catalogs",misc:"Miscellaneous"};function cI(e,t){var s;let a;return e.category||(s=e.type,(null==(a=t.get(s))?void 0:a.CATEGORY)||"streams")}function cE(e,t){if(cA[e])return cA[e];let s=null==t?void 0:t[e];if(s){let e=cR.find(e=>e.key===s);if(e)return e}let a=0;for(let t=0;t<e.length;t++)a=e.charCodeAt(t)+((a<<5)-a);return cR[Math.abs(a)%cR.length]}function cM(e){let{onEdit:t}=e,{userData:s,setUserData:a}=s4(),{status:l}=e$(),{mode:i}
14=tX(),[o,d]=(0,n.useState)(new Set),[c,u]=(0,n.useState)("all"),[m,p]=(0,n.useState)(""),h=tw(!1),g=tw(!1),f=tw(!1),[b,v]=(0,n.useState)("pick"),[y,j]=(0,n.useState)(new Set),[N,k]=(0,n.useState)({}),[S,C]=(0,n.useState)(""),[_,R]=(0,n.useState)("blue"),A=(0,n.useMemo)(()=>{var e;let t=new Map;if(null==l||null==(e=l.settings)?void 0:e.presets)for(let e of l.settings.presets)t.set(e.ID,e);return t},[l]),T=(0,n.useMemo)(()=>{let e=new Map;for(let t of s.presets){let s=cI(t,A);e.set(s,(e.get(s)||0)+1)}return e},[s.presets,A]),I=(0,n.useMemo)(()=>{let e=["streams","subtitles","meta_catalogs","misc"];return[...e.filter(e=>T.has(e)),...[...T.keys()].filter(t=>!e.includes(t)).sort((e,t)=>s.presets.findIndex(t=>cI(t,A)===e)-s.presets.findIndex(e=>cI(e,A)===t))]},[T,s.presets,A]),M=(0,n.useMemo)(()=>{let e=s.presets;if("all"!==c&&(e=e.filter(e=>cI(e,A)===c)),m.trim()){let t=m.toLowerCase();e=e.filter(e=>{var s;return((null==(s=e.options)?void 0:s.name)||"").toLowerCase().includes(t)})}return e},[s.presets,A,c,m]),P=(0,n.useMemo)(()=>{let e={};for(let t of M){let s=cI(t,A);e[s]||(e[s]=[]),e[s].push(t)}return e},[M,A]),D=M.length>0&&M.every(e=>o.has(e.instanceId)),L=o.size>0,U=(0,n.useMemo)(()=>{let e=s.presets.filter(e=>o.has(e.instanceId)),t=e.filter(e=>e.enabled).length;return e.filter(e=>!e.enabled).length>t},[s.presets,o]),$=e=>{d(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})};(0,n.useEffect)(()=>{d(new Set)},[c,m]);let O=(0,n.useMemo)(()=>{if(0===o.size)return[];let e=s.presets.filter(e=>o.has(e.instanceId)),t=new Map;for(let s of e){let e=A.get(s.type);if(null==e?void 0:e.OPTIONS)for(let s of e.OPTIONS){if(["alert","socials","oauth","subsection"].includes(s.type))continue;let e=t.get(s.id);e?e.count++:t.set(s.id,{option:s,count:1})}}return[...t.values()].filter(t=>t.count===e.length).map(e=>e.option)},[o,s.presets,A]),F=tN({title:"Delete Selected Addons",description:`Are you sure you want to delete ${o.size} selected addon(s)? This cannot be undone.`,actionText:"Delete",actionIntent:"alert",onConfirm:()=>{a(e=>{let t=structuredClone(e);return t.presets=t.presets.filter(e=>!o.has(e.instanceId)),s2(t)}),d(new Set)}}),z=e=>{a(t=>({...t,presets:t.presets.map(t=>o.has(t.instanceId)?{...t,category:e}:t)})),x.oR.info(e?`Categorised ${o.size} addon(s) as "${e}"`:`Reset category for ${o.size} addon(s)`),f.close()},V=e=>cT[e]||e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(cr,{title:"My Addons",description:"Manage your installed addons. Reorder, batch edit, or categorise by type.",action:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(E,{rounded:!0,intent:"primary-subtle",icon:(0,r.jsx)(J.CBv,{className:"w-5 h-5"}),onClick:()=>h.open(),disabled:s.presets.length<2,title:"Reorder Priority"}),(0,r.jsx)(E,{rounded:!0,intent:D?"primary":"primary-subtle",icon:(0,r.jsx)(J.hpl,{className:"w-5 h-5"}),onClick:()=>{D?d(new Set):d(new Set(M.map(e=>e.instanceId)))},disabled:0===M.length,title:D?"Deselect All":"Select All"})]}),children:[s.presets.length>0&&(0,r.jsxs)("div",{className:"space-y-3 mb-4",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)("div",{className:"flex-1 min-w-[140px]",children:(0,r.jsx)(W,{value:m,onChange:e=>p(e.target.value),placeholder:"Search addons...",leftIcon:(0,r.jsx)(cu.A,{className:"w-4 h-4"})})}),L&&(0,r.jsxs)("div",{className:"flex items-center gap-1.5 animate-in fade-in duration-150",children:[(0,r.jsxs)("span",{className:"text-xs font-semibold text-[--brand] whitespace-nowrap",children:[o.size," selected"]}),(0,r.jsx)(E,{size:"sm",rounded:!0,intent:"primary-subtle",icon:U?(0,r.jsx)(J.lXh,{className:"w-3.5 h-3.5"}):(0,r.jsx)(J.czG,{className:"w-3.5 h-3.5"}),onClick:()=>{a(e=>({...e,presets:e.presets.map(e=>o.has(e.instanceId)?{...e,enabled:U}:e)}))},title:U?"Enable selected":"Disable selected"}),"pro"===i&&O.length>0&&(0,r.jsx)(E,{size:"sm",rounded:!0,intent:"primary-subtle",icon:(0,r.jsx)(J.H6t,{className:"w-3.5 h-3.5"}),onClick:()=>{v("pick"),j(new Set),k({}),g.open()},title:"Edit common fields"}),(0,r.jsx)(E,{size:"sm",rounded:!0,intent:"primary-subtle",icon:(0,r.jsx)(J.kIN,{className:"w-3.5 h-3.5"}),onClick:()=>f.open(),title:"Set category"}),(0,r.jsx)(E,{size:"sm",rounded:!0,intent:"alert-subtle",icon:(0,r.jsx)(J.Mst,{className:"w-3.5 h-3.5"}),onClick:()=>F.open(),title:"Delete selected"})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[(0,r.jsxs)("button",{onClick:()=>u("all"),className:`px-2.5 py-1 text-xs font-medium rounded-full border transition-colors ${"all"===c?"bg-[--brand]/20 text-[--brand] border-[--brand]/50":"bg-transparent text-[--muted] border-[--border] hover:bg-[--subtle]"}`,children:["All (",s.presets.length,")"]}),I.map(e=>{let t=T.get(e)||0,a=cE(e,s.addonCategoryColors);return(0,r.jsxs)("button",{onClick:()=>u(c===e?"all":e),className:`px-2.5 py-1 text-xs font-medium rounded-full border transition-colors ${c===e?`${a.bg} ${a.text} ${a.border}`:"bg-transparent text-[--muted] border-[--border] hover:bg-[--subtle]"}`,children:[V(e)," (",t,")"]},e)})]})]}),0===s.presets.length?(0,r.jsx)("div",{className:"flex flex-col items-center justify-center py-12",children:(0,r.jsxs)("span",{className:"text-lg text-muted-foreground font-semibold text-center",children:["Looks like you don't have any addons...",(0,r.jsx)("br",{}),"Add some from the marketplace!"]})}):0===M.length?(0,r.jsx)("div",{className:"flex flex-col items-center justify-center py-8",children:(0,r.jsx)("span",{className:"text-sm text-[--muted]",children:"No addons match your search."})}):"all"!==c||m.trim()?(0,r.jsx)("ul",{className:"space-y-1.5",children:M.map(e=>(0,r.jsx)(cP,{preset:e,presetMetadata:A.get(e.type),isSelected:o.has(e.instanceId),onToggleSelect:()=>$(e.instanceId),onEdit:()=>t(e,A.get(e.type)),onRemove:()=>{a(t=>{let s=structuredClone(t);return s.presets=s.presets.filter(t=>t.instanceId!==e.instanceId),s2(s)})},onToggleEnabled:t=>{a(s=>({...s,presets:s.presets.map(s=>s.instanceId===e.instanceId?{...s,enabled:t}:s)}))}},e.instanceId))}):(0,r.jsx)("div",{className:"space-y-4",children:I.map(e=>{let n=P[e];
14if(!n||0===n.length)return null;let l=cE(e,s.addonCategoryColors);return(0,r.jsxs)("div",{children:[(0,r.jsxs)("button",{className:"flex items-center gap-2 mb-2 group cursor-pointer",onClick:()=>{let e=n.map(e=>e.instanceId),t=e.every(e=>o.has(e));d(s=>{let a=new Set(s);for(let s of e)t?a.delete(s):a.add(s);return a})},title:`Select all in ${V(e)}`,children:[(0,r.jsx)("span",{className:`inline-block w-2.5 h-2.5 rounded-full ${l.swatch}`}),(0,r.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wider text-[--muted] group-hover:text-[--foreground] transition-colors",children:V(e)})]}),(0,r.jsx)("ul",{className:"space-y-1.5",children:n.map(e=>(0,r.jsx)(cP,{preset:e,presetMetadata:A.get(e.type),isSelected:o.has(e.instanceId),onToggleSelect:()=>$(e.instanceId),onEdit:()=>t(e,A.get(e.type)),onRemove:()=>{a(t=>{let s=structuredClone(t);return s.presets=s.presets.filter(t=>t.instanceId!==e.instanceId),s2(s)})},onToggleEnabled:t=>{a(s=>({...s,presets:s.presets.map(s=>s.instanceId===e.instanceId?{...s,enabled:t}:s)}))}},e.instanceId))})]},e)})})]}),(0,r.jsx)(cC,{open:h.isOpen,onOpenChange:h.toggle,presets:s.presets,presetMetadataMap:A,manifestCache:c_,onSave:e=>{a(t=>({...t,presets:e}))}}),(0,r.jsx)(ty,{open:g.isOpen,onOpenChange:g.toggle,title:"pick"===b?"Choose Fields to Edit":"Edit Selected Fields",children:"pick"===b?(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("p",{className:"text-sm text-[--muted]",children:["Select which fields to update across ",o.size," selected addon(s). Only fields common to all selected addons are shown."]}),(0,r.jsx)("div",{className:"space-y-1.5 max-h-[50vh] overflow-y-auto",children:O.map(e=>(0,r.jsxs)("button",{onClick:()=>{j(t=>{let s=new Set(t);return s.has(e.id)?s.delete(e.id):s.add(e.id),s})},className:`w-full text-left px-3 py-2.5 rounded-lg border transition-colors flex items-center gap-3 ${y.has(e.id)?"border-[--brand]/50 bg-[--brand]/10":"border-[--border] hover:bg-[--subtle]"}`,children:[(0,r.jsx)("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center flex-shrink-0 transition-colors ${y.has(e.id)?"bg-brand-600 border-brand-600":"border-gray-500"}`,children:y.has(e.id)&&(0,r.jsx)("svg",{className:"w-3 h-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium",children:e.name}),e.description&&(0,r.jsx)("p",{className:"text-xs text-[--muted] line-clamp-1",children:e.description})]})]},e.id))}),(0,r.jsxs)(w,{className:"w-full",disabled:0===y.size,onClick:()=>{let e={};for(let t of y){let s=O.find(e=>e.id===t);s&&(e[t]=s.default??void 0)}k(e),v("edit")},children:["Continue (",y.size," field",1!==y.size?"s":"",")"]})]}):(0,r.jsxs)("form",{className:"space-y-4",onSubmit:e=>{e.preventDefault(),a(e=>({...e,presets:e.presets.map(e=>{if(!o.has(e.instanceId))return e;let t=A.get(e.type),s=new Set(((null==t?void 0:t.OPTIONS)||[]).map(e=>e.id)),a={...e.options};for(let e of y)s.has(e)&&(a[e]=N[e]);return{...e,options:a}})})),g.close()},children:[[...y].map(e=>{let t=O.find(t=>t.id===e);return t?(0,r.jsx)("div",{children:(0,r.jsx)(dJ,{option:t,value:N[e],onChange:t=>k(s=>({...s,[e]:t})),disabled:!1})},e):null}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(E,{rounded:!0,intent:"primary-subtle",icon:(0,r.jsx)(J.wwB,{className:"w-4 h-4"}),onClick:()=>v("pick"),title:"Back",type:"button"}),(0,r.jsxs)(w,{className:"flex-1",type:"submit",children:["Apply to ",o.size," addon(s)"]})]})]})}),(0,r.jsx)(ty,{open:f.isOpen,onOpenChange:f.toggle,title:"Set Category",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("p",{className:"text-sm text-[--muted]",children:["Choose a category for the ",o.size," selected addon(s), or create a new one."]}),(0,r.jsxs)("div",{className:"space-y-1.5 max-h-[40vh] overflow-y-auto",children:[(0,r.jsx)("button",{onClick:()=>z(void 0),className:"w-full text-left px-3 py-2 rounded-lg border border-[--border] hover:bg-[--subtle] transition-colors text-sm",children:"Reset to Default"}),I.map(e=>{let t=cE(e,s.addonCategoryColors);return(0,r.jsxs)("button",{onClick:()=>z(e),className:"w-full text-left px-3 py-2 rounded-lg border border-[--border] hover:bg-[--subtle] transition-colors flex items-center gap-2",children:[(0,r.jsx)("span",{className:`inline-block w-3 h-3 rounded-full ${t.swatch}`}),(0,r.jsx)("span",{className:"text-sm",children:V(e)}),(0,r.jsx)("span",{className:"text-xs text-[--muted] ml-auto",children:T.get(e)||0})]},e)})]}),(0,r.jsxs)("div",{className:"pt-2 border-t border-[--border] space-y-3",children:[(0,r.jsx)("p",{className:"text-xs font-medium text-[--muted] uppercase tracking-wide",children:"New Category"}),(0,r.jsx)(W,{value:S,onValueChange:C,placeholder:"e.g. Usenet, HTTP, Anime..."}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5",children:cR.map(e=>(0,r.jsx)("button",{onClick:()=>
14R(e.key),className:`w-6 h-6 rounded-full ${e.swatch} transition-all ${_===e.key?"ring-2 ring-offset-2 ring-offset-[--background] ring-white/60 scale-110":"hover:scale-110"}`,title:e.key},e.key))}),(0,r.jsx)(w,{className:"w-full",size:"md",disabled:!S.trim(),onClick:()=>{var e;e=S.trim(),a(t=>({...t,presets:t.presets.map(t=>o.has(t.instanceId)?{...t,category:e}:t),addonCategoryColors:{...t.addonCategoryColors||{},[e]:_}})),x.oR.info(`Categorised ${o.size} addon(s) as "${e}"`),f.close(),C(""),C("")},children:"Create & Apply"})]})]})}),(0,r.jsx)(tk,{...F})]})}function cP(e){var t,s,a,l,i,o;let{preset:d,presetMetadata:c,isSelected:u,onToggleSelect:m,onEdit:p,onRemove:h,onToggleEnabled:g}=e,{setUserData:f}=s4(),[b,v]=(0,n.useState)(!1),[y,j]=(0,n.useState)(d.logo||(null==c?void 0:c.LOGO)),[N,k]=(0,n.useState)(1),S=tw(!1),[C,_]=(0,n.useState)(""),[R,A]=(0,n.useState)(!1),T=tN({title:"Delete Addon",description:`Are you sure you want to delete "${(null==(t=d.options)?void 0:t.name)||"this addon"}"?`,actionText:"Delete",actionIntent:"alert",onConfirm:h}),I=e=>e.replace(/^stremio:\/\//,"https://").replace(/\/$/,""),M=()=>{if((null==c?void 0:c.ID)==="custom"||(null==c?void 0:c.ID)==="aiostreams")return d.options.manifestUrl;let e=d.options.url;if(e)try{if(new URL(e).pathname.endsWith("/manifest.json"))return e}catch{}};(0,n.useEffect)(()=>{S.isOpen&&k(1)},[S.isOpen]),(0,n.useEffect)(()=>{let e=!0,t=M();if(t){let a=I(t),r=c_.get(a);if(r){var s;v((null==(s=r.behaviorHints)?void 0:s.configurable)===!0),j(r.logo);return}fetch(a).then(e=>e.json()).then(t=>{if(c_.set(a,t),e){var s;v((null==t||null==(s=t.behaviorHints)?void 0:s.configurable)===!0),j(null==t?void 0:t.logo)}}).catch(()=>{e&&v(!1)})}return()=>{e=!1}},[null==c?void 0:c.ID,d.options.manifestUrl,d.options.url]);let P=async e=>{e.preventDefault();let t=I(C);if(!C)return void x.oR.error("Please enter a new manifest URL");if(!/^(https?|stremio):\/\/.+\/manifest\.json$/.test(t))return void x.oR.error("Please enter a valid manifest URL");try{A(!0);let e=await fetch(t);if(!e.ok)throw Error(`${e.status} ${e.statusText}`);await e.json()}catch(e){x.oR.error(`Failed to fetch or parse manifest: ${e.message}`),A(!1);return}f(e=>{let s=e.presets.find(e=>e.instanceId===d.instanceId);if(!s)return e;let a=(null==c?void 0:c.ID)==="custom"||(null==c?void 0:c.ID)==="aiostreams"?{...s.options,manifestUrl:t}:{...s.options,url:t};return{...e,presets:e.presets.map(e=>e.instanceId===d.instanceId?{...e,options:a}:e)}}),_(""),S.close(),x.oR.success("Manifest URL updated successfully"),A(!1)};return(0,r.jsxs)("li",{children:[(0,r.jsxs)("div",{className:`px-2.5 py-2 rounded-[--radius-md] border flex gap-2 sm:gap-3 items-center transition-colors ${u?"border-brand-500/50 bg-brand-500/10":"bg-[var(--background)] border-[--border]"}`,children:[(0,r.jsx)("button",{onClick:m,className:"flex items-center justify-center flex-shrink-0",children:(0,r.jsx)("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center transition-colors ${u?"bg-brand-600 border-brand-600":"border-gray-500 hover:border-gray-400"}`,children:u&&(0,r.jsx)("svg",{className:"w-3 h-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})})}),(0,r.jsx)("div",{className:"relative flex-shrink-0 h-8 w-8 hidden sm:block",children:y?(0,r.jsx)("img",{src:y,alt:(null==c?void 0:c.NAME)||"",className:"absolute inset-0 w-full h-full object-contain rounded-md"}):(null==c?void 0:c.ID)==="custom"?(0,r.jsx)(cx.A,{className:"w-full h-full object-contain text-[--brand]"}):(null==(a=d.options.name)||null==(s=a.trim())?void 0:s[0])?(0,r.jsx)("div",{className:"w-full h-full flex items-center justify-center rounded-md bg-gray-950",children:(0,r.jsx)("p",{className:"text-lg font-bold",children:(null==(o=d.options.name)||null==(i=o.trim())||null==(l=i[0])?void 0:l.toUpperCase())||"?"})}):(0,r.jsx)(cm.Yoo,{className:"w-full h-full object-contain text-[--brand]"})}),(0,r.jsx)("p",{className:"text-base line-clamp-1 truncate block flex-1 min-w-0",children:d.options.name}),(0,r.jsxs)("div",{className:"flex items-center gap-1 sm:gap-2 flex-shrink-0",children:[(0,r.jsx)(rs,{value:d.enabled??!1,onValueChange:g,className:"h-5 w-9 md:h-6 md:w-11"}),b&&(0,r.jsx)(E,{className:"rounded-full h-8 w-8 md:h-10 md:w-10",icon:(0,r.jsx)(J.xPd,{}),intent:"primary-subtle",onClick:()=>S.open()}),(0,r.jsx)(E,{className:"rounded-full h-8 w-8 md:h-10 md:w-10",icon:(0,r.jsx)(tC.u6n,{}),intent:"primary-subtle",onClick:p}),(0,r.jsx)(E,{className:"rounded-full h-8 w-8 md:h-10 md:w-10",icon:(0,r.jsx)(tC.id1,{}),intent:"alert-subtle",onClick:()=>T.open()})]})]}),(0,r.jsxs)(ty,{open:S.isOpen,onOpenChange:S.toggle,title:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"mr-1.5",children:"Reconfigure"}),(0,r.jsx)("span",{className:"font-semibold truncate overflow-hidden text-ellipsis",children:d.options.name})]}),titleClass:"truncate max-w-sm",children:[1===N&&(0,r.jsxs)("div",{className:"text-center space-y-4",children:[(0,r.jsx)("div",{className:"mx-auto bg-[--subtle] rounded-full h-12 w-12 flex items-center justify-center",children:(0,r.jsx)(J.TdP,{className:"h-6 w-6 text-[--brand]"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold",children:"Reconfigure in a new tab"}),(0,r.jsx)("p",{className:"text-sm text-[var(--muted-foreground)]",children:"You'll be taken to a new tab to adjust your settings. Once finished, you will be given a new manifest URL to paste back here."}),(0,r.jsx)(w,{className:"w-full",onClick:()=>{let e;window.open((e=M())?I(e).replace(/\/manifest\.json$/,"/configure"):"","_blank"),k(2)},children:(0,r.jsx)("span",{className:"truncate",children:"Take me to configuration"})})]}),2===N&&(0,r.jsxs)("div",{className:"space-y-4 max-w-md",children:[(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("div",{className:"mx-auto bg-[--subtle] rounded-full h-12 w-12 flex items-center justify-center",children:(0,r.jsx)(J.GzK,{className:"h-6 w-6 text-[--brand]"})}),(0,r.jsx)("h3",{className:"text-lg font-semibold",children:"Awaiting New URL"}),(0,r.jsx)("p",{className:"text-sm text-[var(--muted-foreground)]",children:"After adjusting your settings, copy the manifest URL and paste it below."})]}),(0,r.jsxs)("form",{onSubmit:P,className:"space-y-4 pt-2",children:[(0,r.jsx)(W,{type:"url",label:"New Manifest URL",placeholder:"Paste your new URL here",value:C,onValueChange:_,required:!0,autoFocus:!0}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(w,{intent:"primary-subtle",onClick:()=>k(1),children:"Back"}),(0,r.jsxs)(w,{loading:R,type:"submit",className:"max-w-sm w-full text-ellipsis whitespace-nowrap overflow-hidden text-left",children:["Update ",d.options.name]})]})]})]})]}),(0,r.jsx)(tk,{...T})]})}function cD(){return(0,r.jsx)(ru,{className:"space-y-4 p-4 sm:p-8",children:(0,r.jsx)(cL,{})})}function cL(){let{status:e}=e$(),{mode:t}=tX(),{userData:s,setUserData:a}=s4(),{isInherited:l,hasParent:i}
14=s9(),[o,d]=(0,n.useState)("installed"),{tab:c,setTab:u}=ao("addons"),{mutate:m,isPending:p}=(0,eE.n)({mutationFn:e=>e_(e),onSuccess:(e,t)=>{a(s=>{let a=s.catalogModifications||[],r=new Set(a.map(e=>`${e.id}-${e.type}`)),n=a.map(t=>{if(t.id.startsWith("aiostreams.merged."))return t;let s=e.find(e=>e.id===t.id&&e.type===t.type);return s?{...t,addonName:s.addonName,type:s.type,hideable:s.hideable,searchable:s.searchable}:t});e.forEach(e=>{r.has(`${e.id}-${e.type}`)||n.push({id:e.id,name:e.name,type:e.type,enabled:!0,shuffle:!1,usePosterService:!!(t.rpdbApiKey||t.topPosterApiKey||t.aioratingsApiKey),hideable:e.hideable,searchable:e.searchable,addonName:e.addonName})});let l=new Set(e.map(e=>`${e.id}-${e.type}`)),i=new Set((s.mergedCatalogs||[]).map(e=>e.id)),o=n.filter(e=>e.id.startsWith("aiostreams.merged.")&&i.has(e.id)||l.has(`${e.id}-${e.type}`));return{...s,catalogModifications:o}})},onError:e=>{console.error("Error fetching catalogs:",e),e instanceof el?x.oR.error(e.message):x.oR.error("Failed to fetch catalogs")}}),h=(0,n.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];m(s,{onSuccess:e?void 0:()=>x.oR.success("Catalogs fetched successfully")})},[m,s]);(0,n.useEffect)(()=>{m(s)},[]);let[g,f]=(0,n.useState)(""),[b,v]=(0,n.useState)("all"),[y,j]=(0,n.useState)("all"),[w,N]=(0,n.useState)("all"),[k,S]=(0,n.useState)(!1),[C,_]=(0,n.use
14State)("add"),[R,A]=(0,n.useState)(null),[T,I]=(0,n.useState)({}),[E,M]=(0,n.useState)(null),P=(0,n.useMemo)(()=>{var t;if(!(null==e||null==(t=e.settings)?void 0:t.presets))return[];let s=[...e.settings.presets.filter(e=>{var t;return!(null==(t=e.DISABLED)?void 0:t.removed)})];return"all"!==b&&(s=s.filter(e=>(e.CATEGORY||"streams")===b)),"all"!==y&&(s=s.filter(e=>e.SUPPORTED_SERVICES&&e.SUPPORTED_SERVICES.includes(y))),"all"!==w&&(s=s.filter(e=>e.SUPPORTED_STREAM_TYPES&&e.SUPPORTED_STREAM_TYPES.includes(w))),g&&(s=s.filter(e=>e.NAME.toLowerCase().includes(g.toLowerCase())||e.DESCRIPTION.toLowerCase().includes(g.toLowerCase()))),s},[e,g,b,y,w]);function D(e){A(e),I({options:Object.fromEntries((e.OPTIONS||[]).map(e=>[e.id,e.forced??e.default??void 0]))}),_("add"),M(null),S(!0)}let L=Object.values(sC).map(e=>({label:e.name,value:e.id})),U={p2p:"P2P",http:"HTTP",usenet:"Usenet",debrid:"Debrid",live:"Live"},$=(sB||[]).filter(e=>!["error","statistic","external","youtube","stremio-usenet","archive"].includes(e)).map(e=>({label:U[e],value:e})),O=P.filter(e=>"streams"===e.CATEGORY||!e.CATEGORY),F=P.filter(e=>"subtitles"===e.CATEGORY),z=P.filter(e=>"meta_catalogs"===e.CATEGORY),V=P.filter(e=>"misc"===e.CATEGORY),q="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 3xl:grid-cols-5 5xl:grid-cols-6 6xl:grid-cols-7 7xl:grid-cols-8 gap-4";return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)(rK,{className:"h-10 w-fit max-w-full border rounded-full",triggerClass:"px-4 py-1 text-md",items:[{name:"Installed",isCurrent:"installed"===o,onClick:()=>d("installed"),iconType:J.Oz0},{name:"Marketplace",isCurrent:"marketplace"===o,onClick:()=>d("marketplace"),iconType:J.LG1}]}),(0,r.jsx)("div",{className:"hidden lg:block lg:ml-auto",children:(0,r.jsx)(dT,{})})]}),(0,r.jsxs)(tp.N,{mode:"wait",children:["installed"===o&&(0,r.jsx)(ru,{initial:{opacity:0,y:60},animate:{opacity:1,y:0},exit:{opacity:0,scale:.99},transition:{duration:.35},className:"pt-0 space-y-6 relative z-[4]",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h2",{children:"Installed"}),i&&l("presets")&&(0,r.jsx)(dF,{section:"presets"})]}),(0,r.jsx)("p",{className:"text-[--muted] text-sm",children:"Manage your installed addons and catalog settings."})]}),(0,r.jsx)(dO,{activeTab:c,onTabChange:e=>u(e),defaultMobileOpen:"addons",tabs:[{value:"addons",label:"Addons",icon:(0,r.jsx)(cm.Yoo,{className:"w-4 h-4"}),content:(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsx)(cM,{onEdit:function(e,t){A(t),I({options:{...e.options}}),_("edit"),M(e.instanceId),S(!0)}}),s.presets.length>0&&"pro"===t&&(0,r.jsx)(cv,{})]})},{value:"catalogs",label:"Catalogs",icon:(0,r.jsx)(cp.S$x,{className:"w-4 h-4"}),content:(0,r.jsx)("div",{className:"space-y-6",children:0===s.presets.length?(0,r.jsx)(X,{className:"p-8 text-center",children:(0,r.jsx)("p",{className:"text-[--muted]",children:"Install some addons first to configure catalogs."})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(cN,{loading:p,fetchCatalogsData:h}),(0,r.jsx)(ck,{})]})})}]})]})},"installed"),"marketplace"===o&&(0,r.jsx)(ru,{initial:{opacity:0,y:60},animate:{opacity:1,y:0},exit:{opacity:0,scale:.99},transition:{duration:.35},className:"pt-0 space-y-6 relative z-[4]",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"Marketplace"}),(0,r.jsx)("p",{className:"text-[--muted] text-sm",children:"Browse and install addons from the marketplace."})]}),(0,r.jsx)(rK,{className:"h-10 w-fit max-w-full border rounded-full",triggerClass:"px-4 py-1 text-sm",items:[{name:"All",isCurrent:"all"===b,onClick:()=>v("all")},{name:"Streams",isCurrent:"streams"===b,onClick:()=>v("streams")},{name:"Subtitles",isCurrent:"subtitles"===b,onClick:()=>v("subtitles")},{name:"Metadata & Catalogs",isCurrent:"meta_catalogs"===b,onClick:()=>v("meta_catalogs")},{name:"Miscellaneous",isCurrent:"misc"===b,onClick:()=>v("misc")}]}),(0,r.jsxs)("div",{className:"flex flex-col lg:flex-row gap-2",children:[(0,r.jsxs)("div",{className:"flex gap-2 flex-1 lg:flex-none",children:[(0,r.jsx)(rn,{value:y,onValueChange:j,options:[{label:"All Services",value:"all"},...L],fieldClass:"lg:w-[200px]"}),(0,r.jsx)(rn,{value:w,onValueChange:N,options:[{label:"All Types",value:"all"},...$],fieldClass:"lg:w-[200px]"})]}),(0,r.jsx)(W,{value:g,onChange:e=>
14f(e.target.value),placeholder:"Search addons...",className:"flex-1",leftIcon:(0,r.jsx)(cu.A,{className:"w-4 h-4"})})]}),0===P.length&&(0,r.jsx)(X,{className:"p-8 text-center",children:(0,r.jsx)("p",{className:"text-[--muted]",children:"No addons found matching your criteria."})}),!!(null==O?void 0:O.length)&&(0,r.jsxs)(X,{className:"p-4 space-y-6",children:[(0,r.jsxs)("h3",{className:"flex gap-3 items-center",children:[(0,r.jsx)(ch.j$e,{})," Streams"]}),(0,r.jsx)("div",{className:q,children:O.map(e=>(0,r.jsx)(cg,{preset:e,onAdd:()=>D(e)},e.ID))})]}),!!(null==F?void 0:F.length)&&(0,r.jsxs)(X,{className:"p-4 space-y-6",children:[(0,r.jsxs)("h3",{className:"flex gap-3 items-center",children:[(0,r.jsx)(cp.zZ_,{})," Subtitles"]}),(0,r.jsx)("div",{className:q,children:F.map(e=>(0,r.jsx)(cg,{preset:e,onAdd:()=>D(e)},e.ID))})]}),!!(null==z?void 0:z.length)&&(0,r.jsxs)(X,{className:"p-4 space-y-6",children:[(0,r.jsxs)("h3",{className:"flex gap-3 items-center",children:[(0,r.jsx)(cp.S$x,{})," Metadata & Catalogs"]}),(0,r.jsx)("div",{className:q,children:z.map(e=>(0,r.jsx)(cg,{preset:e,onAdd:()=>D(e)},e.ID))})]}),!!(null==V?void 0:V.length)&&(0,r.jsxs)(X,{className:"p-4 space-y-6",children:[(0,r.jsxs)("h3",{className:"flex gap-3 items-center",children:[(0,r.jsx)(J.xPd,{})," Miscellaneous"]}),(0,r.jsx)("div",{className:q,children:V.map(e=>(0,r.jsx)(cg,{preset:e,onAdd:()=>D(e)},e.ID))})]})]})},"marketplace")]}),(0,r.jsx)(cf,{open:k,onOpenChange:S,mode:C,presetMetadata:R,initialValues:T,onSubmit:function(e){if("add"===C&&R){let t={type:R.ID,instanceId:function e(){let t=Math.floor(4095*Math.random()).toString(16).padStart(3,"0");return s.presets.some(e=>e.instanceId===t)?e():t}(),enabled:!0,options:e.options},r=cU(t);if(s.presets.some(e=>cU(e)===r)){x.oR.error("You already have an addon with the same options added."),S(!1);return}a(e=>({...e,presets:[...e.presets,t]})),x.oR.info("Addon installed successfully!"),S(!1)}else"edit"===C&&E&&(a(t=>({...t,presets:t.presets.map(t=>t.instanceId===E?{...t,options:e.options}:t)})),x.oR.info("Addon updated successfully!"),S(!1))}})]})}function cU(e){return JSON.stringify({type:e.type,enabled:e.enabled,options:e.options})}var c$=s(3243),cO=s(8468),cF=s(5784),cz=s(8761),cV=s(6408),cq=s(496);let cB={root:(0,h.F)(["UI-Skeleton__root","animate-pulse rounded-[--radius-md] bg-[--subtle] w-full h-12"])},cK=n.forwardRef((e,t)=>{let{className:s,...a}=e;return(0,r.jsx)("div",{ref:t,className:b(cB.root(),s),...a})});function cH(e){let{value:t,onChange:s,size:a="md",className:l}=e,i=n.useRef(null),[o,d]=n.useState({width:"50%",transform:"translateX(0)"});return n.useEffect(()=>{if(i.current){let e=i.current.offsetWidth/2;d({width:`${e}px`,transform:`translateX(${"pro"===t?e:0}px)`})}},[t]),(0,r.jsxs)("div",{ref:i,className:b("relative flex rounded-full bg-gray-800/60 border border-gray-800 overflow-hidden",{sm:"h-10 text-sm",md:"h-12 text-base",lg:"h-14 text-lg"}[a],l),children:[(0,r.jsx)("div",{className:"absolute top-0 bottom-0 bg-white border border-[--brand]/30 rounded-full transition-transform duration-300 ease-in-out",style:o}),(0,r.jsx)("button",{onClick:()=>s("noob"),className:b("relative flex-1 flex items-center justify-center font-medium transition-colors duration-200","noob"===t?"text-black":"text-gray-400 hover:text-gray-300"),children:(0,r.jsx)("div",{className:"text-md",children:(0,r.jsx)("b",{children:"SIMPLE"})})}),(0,r.jsx)("button",{onClick:()=>s("pro"),className:b("relative flex-1 flex items-center justify-center font-medium transition-colors duration-200","pro"===t?"text-black":"text-gray-400 hover:text-gray-300"),children:(0,r.jsx)("b",{children:"ADVANCED"})})]})}function cG(e){let{open:t,onOpenChange:s}=e,{mode:a,setMode:n,setIsFirstTime:l}=tX();return(0,r.jsx)(ty,{open:t,onOpenChange:s,title:"Welcome to AIOStreams!",hideCloseButton:!0,children:(0,r.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("p",{className:"text-gray-300",children:"Choose your preferred mode to customize your experience:"}),(0,r.jsxs)("div",{className:"space-y-4 p-4 rounded-lg bg-gray-900/40 border border-gray-800",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("h3",{className:"text-lg font-semibold text-[--brand]",children:"Simple"}),(0,r.jsx)("p",{className:"text-sm text-gray-400",children:"Perfect for beginners! Essential options only."})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("h3",{className:"text-lg font-semibold text-[--brand]",children:"Advanced"}),(0,r.jsx)("p",{className:"text-sm text-gray-400",children:"For advanced users who want full control. Access all configuration options and advanced features for maximum customisation of your streaming setup."})]})]})]}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(cH,{value:a,onChange:n,size:"lg",className:"w-full"}),(0,r.jsx)("div",{className:"flex justify-center",children:(0,r.jsx)(w,{intent:"primary",onClick:()=>{l(!1),s(!1)},children:"Continue"})}),(0,r.jsx)("p",{className:"text-xs text-center text-gray-500",children:"Don't worry! You can always change this later in the About menu."})]})]})})}cK.displayName="Skeleton";var cW=s(6358);let cY=["string","password","custom-nntp-servers"],cJ=rL.Ik({metadata:rL.Ik({id:rL.Yj().min(1).max(100).optional().transform(e=>e??crypto.randomUUID()),name:rL.Yj().min(1).max(100),description:rL.Yj().min(1).max(1e3),author:rL.Yj().min(1).max(20),source:rL.k5(["builtin","custom","external"]).optional().default("builtin"),version:rL.Np("semver",/^[0-9]+\.[0-9]+\.[0-9]+$/).optional().default("1.0.0"),category:rL.Yj().min(1).max(20),services:rL.YO(rL.k5(sy)).optional(),serviceRequired:rL.zM().optional(),setToSaveInstallMenu:rL.zM().optional().default(!0),sourceUrl:rL.OZ().optional(),inputs:rL.YO(rL.bz()).optional(),changelog:rL.YO(rL.Ik({date:rL.Yj(),version:rL.Yj(),content:rL.Yj()})).optional(),changelogUrl:rL.OZ().optional()}),config:rL.bz()}),cZ=new Map,cQ=()=>{try{let e=localStorage.getItem("aiostreams-custom-templates");if(e)return rL.YO(cJ).parse(JSON.parse(e)).map(e=>({...e,metadata:{...e.metadata,source:"external"}}))}catch(e){console.error("Error loading templates from localStorage:",e)}return[]}
14,cX=e=>{try{localStorage.setItem("aiostreams-custom-templates",JSON.stringify(e))}catch(e){console.error("Error saving templates to localStorage:",e),x.oR.error("Failed to save templates to local storage")}},c0=(e,t)=>{let s=e.split(".").map(Number),a=t.split(".").map(Number);for(let e=0;e<3;e++){let t=s[e]||0,r=a[e]||0;if(t>r)return 1;if(t<r)return -1}return 0},c1=Symbol("aiostreams.remove");function c2(e,t){let s=t.split("."),a=e;for(let e of s){if(null==a)return;a=a[e]}return a}function c3(e,t,s){let a=e.trim(),r=a.split(/ or (?=!?(?:inputs|services)\b)/);if(r.length>1)return r.some(e=>c3(e.trim(),t,s));let n=a.split(/ xor (?=!?(?:inputs|services)\b)/);if(n.length>1)return n.filter(e=>c3(e.trim(),t,s)).length%2==1;let l=a.split(/ and (?=!?(?:inputs|services)\b)/);if(l.length>1)return l.every(e=>c3(e.trim(),t,s));let i=a.startsWith("!"),o=i?a.slice(1).trim():a,d=o.match(/^(\w+)\.(.+?)\s+(>=|<=|>|<)\s+(-?\d+(?:\.\d+)?)$/);if(d){let[,e,s,a,r]=d,n=parseFloat(r),l=!1;if("inputs"===e){let e=c2(t,s),r="number"==typeof e?e:parseFloat(String(e??""));isNaN(r)||(">="===a?l=r>=n:"<="===a?l=r<=n:">"===a?l=r>n:"<"===a&&(l=r<n))}return i?!l:l}let c=o.match(/^(\w+)\.(.+?)\s+(==|!=|includes)\s+(.+)$/);if(c){let[,e,s,a,r]=c,n=r.trim(),l=!1;if("inputs"===e){let e=c2(t,s);"=="===a?l=String(e??"")===n:"!="===a?l=String(e??"")!==n:"includes"===a&&(Array.isArray(e)?l=e.includes(n):"string"==typeof e&&(l=e.includes(n)))}return i?!l:l}let u=o.indexOf(".");if(-1===u)return"services"===o?i?0===s.length:s.length>0:i;let m=o.slice(0,u),p=o.slice(u+1),h=!1;if("inputs"===m){let e=c2(t,p);h=null!=e&&""!==e&&!1!==e&&!(Array.isArray(e)&&0===e.length)}else"services"===m&&(h=s.includes(p));return i?!h:h}function c6(e){return Array.isArray(e)?e:null!==e&&"object"==typeof e&&Array.isArray(e.__value)?e.__value:[]}let c5=new Set(["string","password","number","boolean","select","select-with-custom","multi-select","url","alert","socials","oauth","subsection","custom-nntp-servers","nab-endpoint"]),c4=new Set(["website","github","discord","ko-fi","patreon","buymeacoffee","github-sponsors","donate"]),c9=new Set(["alert","info","success","warning","info-basic","success-basic","warning-basic","alert-basic"]),c8=new Set(["alert","socials","subsection","custom-nntp-servers","nab-endpoint"]);function c7(e,t){var s,a,r,n,l,i,o,d;let c=[],u=[];if(!e.config)return u.push("Template is missing configuration data"),{isValid:!1,warnings:c,errors:u};let m=cJ.safeParse(e);if(!m.success)return u.push((console.log(JSON.stringify(s=m.error,null,2)),cW.S1(s))),{isValid:!1,warnings:c,errors:u};let p=c6(e.config.presets);if(p.length>0&&t){let s=[];p.forEach(e=>{var a,r,n;let l=null==(r=t.settings)||null==(a=r.presets)?void 0:a.find(t=>t.ID===e.type);(!l||(null==(n=l.DISABLED)?void 0:n.disabled))&&(c.push(`"${e.type}" is not available or disabled on this instance.`),s.push(e.type))}),Array.isArray(e.config.presets)&&s.length>0&&(e.config.presets=e.config.presets.filter(e=>!s.includes(e.type)))}if(t){let s=Object.keys((null==(a=t.settings)?void 0:a.services)||{});c6(e.config.services).forEach(e=>{s.includes(e.id)||c.push(`Service "${e.id}" not available on this instance`)});let u=[...c6(e.config.excludedRegexPatterns),...c6(e.config.includedRegexPatterns),...c6(e.config.requiredRegexPatterns),...c6(e.config.preferredRegexPatterns).map(e=>"string"==typeof e?e:e.pattern)];if(u.length>0){let e=(null==(n=t.settings)||null==(r=n.regexAccess)?void 0:r.patterns)||[];if((null==(i=t.settings)||null==(l=i.regexAccess)?void 0:l.level)==="none"&&0===e.length)c.push("Template uses regex patterns but regex access is disabled on this instance");else if((null==(d=t.settings)||null==(o=d.regexAccess)?void 0:o.level)!=="all"){let t=u.filter(t=>!e.includes(t));t.length>0&&c.push(`Template has ${t.length} regex patterns that are not trusted.`)}}}let h=new Set((e.metadata.inputs??[]).map(e=>e.id)),x=new Set,g=(e,t)=>{if(!e||"object"!=typeof e){if("string"==typeof e){for(let[,s,a]of[...e.matchAll(/\{\{(inputs|services)\.([^}]+)\}\}/g)])if("inputs"===s){let e=a.split(".")[0];x.add(e),a.includes(".")&&x.add(a.split(".").slice(0,2).join(".")),h.has(e)||c.push(`${t}: interpolation {{inputs.${a}}} references undeclared input "${e}"`)}}return}if(Array.isArray(e))return void e.forEach((e,s)=>g(e,`${t}[${s}]`));if("__if"in e){let s=e.__if;if("string"==typeof s&&s.trim())for(let e of s.trim().split(/ and | or | xor /)){let s=e.trim().replace(/^!/,"").split(/\s+/)[0],a=s.indexOf(".");if(-1===a)"services"!==s&&u.push(`${t}.__if: "${e.trim()}" is not a valid condition - expected "inputs.<id>" or "services.<id> or "services"`);else{let e=s.slice(0,-1===a?void 0:a),r=s.slice(a+1),n=r.split(".")[0];"inputs"!==e&&"services"!==e?u.push(`${t}.__if: unknown namespace "${e}" - must be "inputs" or "services"`):"inputs"===e&&(x.add(n),r.includes(".")&&x.add(r.split(".").slice(0,2).join(".")),h.has(n)||c.push(`${t}.__if: references undeclared input "${n}"`))}}else u.push(`${t}.__if: condition must be a non-empty string`);let{__if:a,...r}=e;g(r,t);return}if("__switch"in e){let s=e.__switch;if("string"==typeof s&&s.trim()){let e=s.indexOf(".");if(-1===e)"services"!==s.trim()&&u.push(`${t}.__switch: "${s}" is not a valid reference - expected "inputs.<id>" or "services.<id> or "services"`);else{let a=s.slice(0,e),r=s.slice(e+1),n=r.split(".")[0];"inputs"!==a&&"services"!==a?u.push(`${t}.__switch: unknown namespace "${a}" - must be "inputs" or "services"`):"inputs"===a&&(x.add(n),r.includes(".")&&x.add(r.split(".").slice(0,2).join(".")),h.has(n)||c.push(`${t}.__switch: references undeclared input "${n}"`))}}else u.push(`${t}.__switch: value must be a non-empty string`);if(e.cases&&"object"==typeof e.cases)for(let[s,a]of Object.entries(e.cases))g(a,`${t}.__switch.cases.${s}`);else"cases"in e||c.push(`${t}.__switch: missing "cases" object - switch will always resolve to default`);"default"in e&&g(e.default,`${t}.__switch.default`);return}if("__value"in e)return void g(e.__value,`${t}.__value`);if(!("__remove"in e))for(let[s,a]of Object.entries(e))g(a,`${t}.${s}`)},f=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"metadata.inputs",s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Set;Array.isArray(e)?e.forEach((e,a)=>{let r=`${t}[${a}]`;if("object"!=typeof e||null===e)return void u.push(`${r}: must be an object`);if("string"==typeof e.id&&e.id.trim()?s.has(e.id)?u.push(`${r}.id: duplicate input id "${e.id}"`):s.add(e.id):u.push(`${r}.id: must be a non-empty string`),!e.type||!c5.has(e.type))return void u.push(`${r}.type: "${e.type}" is not a valid input type`);switch("socials"===e.type||"alert"===e.type?void 0!==e.name&&"string"!=typeof e.name&&u.push(`${r}.name: must be a string`):("string"!=typeof e.name||!e.name.trim())&&u.push(`${r}.name: must be a non-empty string`),e.type){case"select":case"select-with-custom":case"multi-select":if(void 0===e.default||("multi-select"!==e.type?"string"==typeof e.default&&e.default.trim():"object"==typeof e.default&&Array.isArray(e.default))||u.push(`${r}.default: must be a ${"multi-select"===e.type?"array":"non-empty string"}`),Array.isArray(e.options)&&0!==e.options.length){let t=new Set;e.options.forEach((e,s)=>{let a=`${r}.options[${s}]`;"object"!=typeof e||null===e?u.push(`${a}: must be an object with "label" and "value"`):("string"==typeof e.label&&e.label.trim()||u.push(`${a}.label: must be a non-empty string`),void 0===e.value||null===e.value||""===e.value||"string"!=typeof e.value?u.push(`${a}.value: must be a non-empty string`):t.has(e.value)?c.push(`${a}.value: duplicate option value "${e.value}"`):t.add(e.value))})}else u.push(`${r}.options: "${e.type}" requires a non-empty options array`);break;
14case"socials":Array.isArray(e.socials)&&0!==e.socials.length?e.socials.forEach((e,t)=>{let s=`${r}.socials[${t}]`;if(c4.has(e.id)||u.push(`${s}.id: "${e.id}" is not a valid social id`),"string"==typeof e.url&&e.url.trim())try{new URL(e.url)}catch{u.push(`${s}.url: "${e.url}" is not a valid URL`)}else u.push(`${s}.url: must be a non-empty string`)}):u.push(`${r}.socials: "socials" type requires a non-empty socials array`);break;case"alert":e.intent&&!c9.has(e.intent)&&c.push(`${r}.intent: "${e.intent}" is not a recognised alert intent`);break;case"oauth":if(e.oauth&&"object"==typeof e.oauth){if("string"==typeof e.oauth.authorisationUrl&&e.oauth.authorisationUrl.trim())try{new URL(e.oauth.authorisationUrl)}catch{u.push(`${r}.oauth.authorisationUrl: not a valid URL`)}else u.push(`${r}.oauth.authorisationUrl: must be a non-empty string`);e.oauth.oauthResultField&&"object"==typeof e.oauth.oauthResultField?("string"==typeof e.oauth.oauthResultField.name&&e.oauth.oauthResultField.name.trim()||u.push(`${r}.oauth.oauthResultField.name: must be a non-empty string`),"string"==typeof e.oauth.oauthResultField.description&&e.oauth.oauthResultField.description.trim()||u.push(`${r}.oauth.oauthResultField.description: must be a non-empty string`)):u.push(`${r}.oauth.oauthResultField: must be an object`)}else u.push(`${r}.oauth: "oauth" type requires an oauth config object`);break;case"subsection":case"nab-endpoint":Array.isArray(e.subOptions)?f(e.subOptions,`${r}.subOptions`,new Set):u.push(`${r}.subOptions: "${e.type}" type requires a subOptions array`);break;case"string":case"password":case"url":void 0===e.default||"string"==typeof e.default&&e.default.trim()||u.push(`${r}.default: must be a non-empty string for "${e.type}" type`);break;case"number":if(void 0!==e.default&&"number"!=typeof e.default&&c.push(`${r}.default: expected a number for "number" type, got ${typeof e.default}`),e.constraints){let{min:t,max:s}=e.constraints;void 0!==t&&"number"!=typeof t&&u.push(`${r}.constraints.min: must be a number`),void 0!==s&&"number"!=typeof s&&u.push(`${r}.constraints.max: must be a number`),"number"==typeof t&&"number"==typeof s&&t>s&&u.push(`${r}.constraints: min (${t}) cannot exceed max (${s})`)}}void 0!==e.forced&&null!==e.forced&&!0===e.required&&c.push(`${r}: both "forced" and "required" are set - "required" has no effect when a value is forced`)}):u.push(`${t} must be an array`)};return e.config&&g(e.config,"config"),e.metadata.inputs&&f(e.metadata.inputs),e.metadata.inputs&&e.metadata.inputs.forEach(e=>{!e.id||"string"!=typeof e.type||c8.has(e.type)||x.has(e.id)||c.push(`metadata.inputs: "${e.id}" (${e.type}) is declared but never referenced in config`),("subsection"===e.type||"nab-endpoint"===e.type)&&Array.isArray(e.subOptions)&&e.subOptions.forEach(t=>{!t.id||"string"!=typeof t.type||c8.has(t.type)||x.has(`${e.id}.${t.id}`)||c.push(`metadata.inputs: "${e.id}.${t.id}" (${t.type}) is declared but never referenced in config`)})}),{isValid:0===u.length,warnings:c,errors:u}}function ue(e){let[t,s]=(0,n.useState)([]),[a,r]=(0,n.useState)(!1),[l,i]=(0,n.useState)({}),{userData:o}=s4(),d=(0,n.useMemo)(()=>{let e=null==o?void 0:o.appliedTemplates;if(!e||0===e.length||0===t.length)return[];let s=[];for(let a of e){let e=t.find(e=>e.metadata.id===a.id);if(!e||0>=c0(e.metadata.version,a.version)||a.ignored||a.dismissedVersion&&c0(a.dismissedVersion,e.metadata.version)>=0)continue;let r=(e.metadata.changelog??[]).filter(e=>c0(e.version,a.version)>0);s.push({template:e,appliedVersion:a.version,newChangelog:r})}return s},[t,null==o?void 0:o.appliedTemplates]),c=async e=>{let t=[],s=[];for(let u of e){if(!u.metadata.sourceUrl){t.push(u);continue}try{var a,r,n,l,i,o,d,c;let e=[],m=cZ.get(u.metadata.sourceUrl);if(m)e=m;else{let s=await fetch(u.metadata.sourceUrl);if(!s.ok){console.warn(`Failed to fetch update for template "${u.metadata.name}": ${s.status}
14`),t.push(u);continue}let a=await s.json();e=Array.isArray(a)?a:[a],cZ.set(u.metadata.sourceUrl,e)}let p=e.find(e=>{var t;return((null==(t=e.metadata)?void 0:t.id)||e.id)===u.metadata.id});if(!p){console.warn(`Template "${u.metadata.name}" not found at source URL`),t.push(u);continue}let h={metadata:{...p.metadata,id:u.metadata.id,source:"external",sourceUrl:u.metadata.sourceUrl,setToSaveInstallMenu:(null==(a=p.metadata)?void 0:a.setToSaveInstallMenu)??!0,version:(null==(r=p.metadata)?void 0:r.version)||"1.0.0",name:(null==(n=p.metadata)?void 0:n.name)||u.metadata.name,description:(null==(l=p.metadata)?void 0:l.description)||u.metadata.description,author:(null==(i=p.metadata)?void 0:i.author)||u.metadata.author,category:(null==(o=p.metadata)?void 0:o.category)||u.metadata.category,services:null==(d=p.metadata)?void 0:d.services,serviceRequired:null==(c=p.metadata)?void 0:c.serviceRequired},config:p.config||p},x=h.metadata.version||"1.0.0",g=u.metadata.version||"1.0.0";c0(x,g)>0?(s.push({old:u,new:h}),t.push(h),console.log(`Updated template "${u.metadata.name}" from v${g} to v${x}`)):t.push(u)}catch(e){console.error(`Error checking update for template "${u.metadata.name}":`,e),t.push(u)}}if(s.length>0){let e=s.map(e=>e.new.metadata.name).join(", ");x.oR.success(`Updated ${s.length} template${1!==s.length?"s":""}: ${e}`)}return t},u=async()=>{r(!0);let t=[];try{let a=cZ.get("api_templates");a?t=a:(t=await eA(),cZ.set("api_templates",t));let r=cQ(),n=await c(r);JSON.stringify(n)!==JSON.stringify(r)&&(cX(n),r=n);let l=[...r=r.filter(e=>{let s=t.find(t=>t.metadata.id===e.metadata.id);return!s||1===c0(e.metadata.version,s.metadata.version)}),...t].reduce((e,t)=>(e.some(e=>e.metadata.id===t.metadata.id)||e.push(t),e),[]);if(s(l),e){let t={};l.forEach(s=>{t[s.metadata.id]=c7(s,e)}),i(t)}}catch(e){console.error("Error fetching templates:",e),x.oR.error("Failed to load templates")}finally{r(!1)}};return{templates:t,setTemplates:s,loadingTemplates:a,templateValidations:l,setTemplateValidations:i,loadTemplates:u,appliedTemplateUpdates:d}}let ut=e=>{if("string"!=typeof e)return{isPlaceholder:!1,required:!1};for(let{pattern:t,required:s}of[{pattern:/<required_template_placeholder>/gi,required:!0},{pattern:/<optional_template_placeholder>/gi,required:!1},{pattern:/<template_placeholder>/gi,required:!0}])if(t.test(e))return{isPlaceholder:!0,required:s};return{isPlaceholder:!1,required:!1}},us=(e,t,s)=>{var a,r,n;let l=[],i=Object.keys((null==t||null==(a=t.settings)?void 0:a.services)||{}),o=[],d=!1,c=!1,u=!0!==e.metadata.serviceRequired;if(void 0===e.metadata.services?(c=!0,o=i):Array.isArray(e.metadata.services)&&0===e.metadata.services.length?(d=!0,o=[]):Array.isArray(e.metadata.services)&&(1===(o=e.metadata.services.filter(e=>i.includes(e))).length&&!0===e.metadata.serviceRequired?d=!0:o.length>0?c=!0:d=!0),(null==(r=e.config)?void 0:r.proxy)&&e.config.proxy.id){let t=sS[e.config.proxy.id];["url","publicUrl","credentials","publicIp"].forEach(a=>{var r,n;let i=ut(null==(r=e.config.proxy)?void 0:r[a]);if(i.isPlaceholder){let e={url:`${t.name} URL`,publicUrl:`${t.name} Public URL`,credentials:`${t.name} Credentials`,publicIp:`${t.name} Public IP`},r={url:`The URL of your ${t.name} instance`,publicUrl:`The public URL of your ${t.name} instance (if different from URL)`,credentials:t.credentialDescription,publicIp:`Public IP address of your ${t.name} instance`};l.push({key:`proxy_${a}`,path:`proxy.${a}`,label:e[a]||a,description:r[a],type:"credentials"===a?"password":"string",required:i.required,value:(null==s||null==(n=s.proxy)?void 0:n[a])||""})}})}return["tmdbApiKey","tmdbAccessToken","tvdbApiKey","rpdbApiKey","topPosterApiKey","aioratingsApiKey","aioratingsProfileId","openposterdbApiKey","openposterdbUrl","openposterdbParameters"].forEach(t=>{var a;let r=ut(null==(a=e.config)?void 0:a[t]);if(r.isPlaceholder){let e=null==s_?void 0:s_[t],a="aioratingsProfileId"===t||"openposterdbUrl"===t||"openposterdbParameters"===t?"string":"password";l.push({key:`toplevel_${t}`,path:t,label:(null==e?void 0:e.name)||t,description:null==e?void 0:e.description,type:a,required:r.required,value:(null==s?void 0:s[t])||""})}}
14),c6(null==(n=e.config)?void 0:n.presets).forEach((e,a)=>{var r,n,i;let o=null==t||null==(n=t.settings)||null==(r=n.presets)?void 0:r.find(t=>t.ID===e.type);o&&(null==(i=o.OPTIONS)||i.forEach(t=>{if("string"===t.type||"password"===t.type){var r,n,i,o,d,c,u,m;let p=null==(r=e.options)?void 0:r[t.id],h=ut(p);if(h.isPlaceholder||t.required&&!p)if("debridioApiKey"===t.id){let e=l.find(e=>"debridioApiKey"===e.key);e?Array.isArray(e.path)?e.path.push(`presets.${a}.options.${t.id}`):e.path=[e.path,`presets.${a}.options.${t.id}`]:l.push({key:"debridioApiKey",path:`presets.${a}.options.${t.id}`,label:"Debridio API Key",description:t.description,type:"password",required:!0,value:(null==s||null==(o=s.presets)||null==(i=o[a])||null==(n=i.options)?void 0:n[t.id])||""})}else l.push({key:`preset_${e.instanceId}_${t.id}`,path:`presets.${a}.options.${t.id}`,label:`${(null==(d=e.options)?void 0:d.name)||e.type} - ${t.name||t.id}`,description:t.description,type:"password"===t.type?"password":"string",required:h.required||t.required||!1,value:(null==s||null==(m=s.presets)||null==(u=m[a])||null==(c=u.options)?void 0:c[t.id])||""})}}))}),{template:e,services:o,skipServiceSelection:d,showServiceSelection:c,allowSkipService:u,inputs:l}},ua=(e,t,s,a)=>{let r=[];return t.forEach(e=>{var t,n;let l=null==s||null==(n=s.settings)||null==(t=n.services)?void 0:t[e];(null==l?void 0:l.credentials)&&l.credentials.filter(e=>cY.includes(e.type)).forEach(t=>{var s,n,i;r.push({key:`service_${e}_${t.id}`,path:`services.${e}.${t.id}`,label:`${l.name} - ${t.name||t.id}`,description:t.description,type:t.type,required:t.required??!0,value:(null==a||null==(i=a.services)||null==(n=i.find(t=>t.id===e))||null==(s=n.credentials)?void 0:s[t.id])||""})})}),r},ur=(e,t)=>{var s;if(!Array.isArray(e.presets))return;let a=new Set(((null==t||null==(s=t.settings)?void 0:s.presets)||[]).filter(e=>{var t;return!(null==(t=e.DISABLED)?void 0:t.disabled)}).map(e=>e.ID)),r=e.presets.filter(e=>!a.has(e.type));r.length>0&&(x.oR.warning(`Removed ${r.length} preset${1!==r.length?"s":""} not available on this instance: ${r.map(e=>e.type).join(", ")}`,{duration:5e3}),e.presets=e.presets.filter(e=>a.has(e.type)))},un=(e,t,s)=>{let a=t.split("."),r=e;for(let e=0;e<a.length-1;e++){let t=a[e],s=a[e+1],n=/^\d+$/.test(s);t in r||(r[t]=n?[]:{}),r=r[t]}r[a[a.length-1]]=s},ul=(e,t,s,a)=>t.reduce((t,r)=>{if("noob"===e&&(!0===r.advanced||!1===r.showInSimpleMode)||r.__if&&"string"==typeof r.__if&&!c3(r.__if,s,a))return t;let n={...r};return r.subOptions&&(n.subOptions=ul(e,r.subOptions,s,a)),t.push(n),t},[]);var ui=s(7809),uo=s(7209),ud=s(6995),uc=s(4252);function uu(e){let{open:t,template:s,data:a,onProceed:n,proceedLabel:l,onClose:i}=e;return a&&s?(0,r.jsx)(ty,{open:t,onOpenChange:e=>{e||i()},title:a.errors.length>0?`Template Errors - ${s.metadata.name}`:`Template Warnings - ${s.metadata.name}`,contentClass:"max-w-2xl",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"space-y-4 overflow-y-auto max-h-[60vh] pr-1",children:[a.errors.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,r.jsx)(ui.A,{className:"w-4 h-4 text-red-400 flex-shrink-0"}),(0,r.jsxs)("span",{className:"text-sm font-semibold text-red-400",children:[a.errors.length," error",1!==a.errors.length?"s":""," - template cannot be loaded"]})]}),(0,r.jsx)("ul",{className:"space-y-1.5",children:a.errors.map((e,t)=>(0,r.jsx)("li",{className:"text-xs text-red-300 bg-red-950/40 border border-red-900/50 rounded px-3 py-2 break-words font-mono",children:e},t))})]}),a.warnings.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,r.jsx)(ui.A,{className:"w-4 h-4 text-yellow-400 flex-shrink-0"}),(0,r.jsxs)("span",{className:"text-sm font-semibold text-yellow-400",children:[a.warnings.length," warning",1!==a.warnings.length?"s":"",0===a.errors.length?" - you may still proceed":""]})]}),(0,r.jsx)("ul",{className:"space-y-1.5",children:a.warnings.map((e,t)=>(0,r.jsx)("li",{className:"text-xs text-yellow-300 bg-yellow-950/40 border border-yellow-900/50 rounded px-3 py-2 break-words font-mono",children:e},t))})]})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 pt-2 border-t border-gray-700",children:[(0,r.jsx)(w,{intent:"primary-outline",onClick:i,children:a.errors.length>0?"Close":"Cancel"}),0===a.errors.length&&null!==n&&(0,r.jsx)(w,{intent:"white",rounded:!0,onClick:()=>{i(),n()},children:l})]})]})}):null}function um(e){let{className:t,children:s,glowSize:a="500px",glowOpacity:l=.07,transitionDuration:i="0.5s"}=e,o=(0,n.useRef)(null),d=(0,n.useRef)(null),c=(0,n.useRef)(null);return(0,r.jsxs)("div",{ref:o,onMouseMove:e=>{if(!o.current)return;let t=o.current.getBoundingClientRect(),s=e.clientX-t.left,r=e.clientY-t.top;d.current&&(d.current.style.background=`radial-gradient(${a} circle at ${s}px ${r}px, rgba(139, 92, 246, ${l}), transparent 65%)`),c.current&&(c.current.style.background=`radial-gradient(70% 100% at ${s}px 0px, rgba(139, 92, 246, ${Math.min(1,7*l)}), transparent)`)},onMouseEnter:()=>{d.current&&(d.current.style.opacity="1"),c.current&&(c.current.style.opacity="1")},onMouseLeave:()=>{d.current&&(d.current.style.opacity="0"),c.current&&(c.current.style.opacity="0")},className:b("relative overflow-hidden rounded-xl border border-gray-700/50 bg-gray-800/40",t),children:[(0,r.jsx)("div",{ref:d,className:"pointer-events-none absolute inset-0 rounded-xl",style:{opacity:0,transition:`opacity ${i} ease`}}),(0,r.jsx)("div",{ref:c,className:"pointer-events-none absolute top-0 inset-x-0 h-px rounded-t-xl",style:{opacity:0,transition:`opacity ${i} ease`}}),s]})}let up=new Map;async function uh(e){let t=up.get(e);if(void 0!==t)return t;let s=await fetch(e);if(!s.ok)throw Error(`Failed to fetch changelog from ${e}: HTTP ${s.status}`);let a=function(e){let t,s=[],a=/^## +([^\s(]+)\s*\(([^)]+)\)\s*$/gm,r=[];for(;null!==(t=a.exec(e));)r.push({version:t[1],date:t[2].trim(),headerEnd:t.index+t[0].length,nextStart:t.index});for(let t=0;t<r.length;t++){let a=r[t],n=a.headerEnd,l=t+1<r.length?r[t+1].nextStart:e.length,i=e.slice(n,l).trim();s.push({version:a.version,date:a.date,content:i})}return s}(await s.text());return up.set(e,a),a}function ux(e){let{entry:t}=e;return(0,r.jsxs)("div",{className:"space-y-2.5",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,r.jsxs)("span",{className:"text-sm font-bold text-[--brand]",children:["v",t.version]}),(0,r.jsx)("span",{className:"text-[10px] font-medium px-2.5 py-0.5 rounded-full bg-gray-700/60 text-gray-400 border border-gray-600/40 flex-shrink-0",children:t.date})]}),(0,r.jsx)("div",{className:"prose prose-invert prose-sm max-w-none min-w-0 text-gray-300 [&_p]:leading-relaxed [&_ul]:space-y-0.5 [&_li]:text-sm [&_p]:text-sm [&_h1]:text-base [&_h2]:text-sm [&_h3]:text-sm [&_strong]:text-gray-100 [&_a]:text-[--brand] [&_a:hover]:underline [&_code]:bg-gray-800 [&_code]:px-1 [&_code]:rounded [&_code]:text-[--brand] [&_code]:text-xs [&_*]:break-words [&_pre]:overflow-x-auto [&_pre]:max-w-full",children:(0,r.jsx)(cq.oz,{children:t.content})})]})}function ug(){return(0,r.jsxs)("div",{className:"space-y-3 py-2",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)(cK,{className:"h-4 w-16"}),(0,r.jsx)(cK,{className:"h-4 w-24 rounded-full"})]}),(0,r.jsx)(cK,{className:"h-3 w-full"}),(0,r.jsx)(cK,{className:"h-3 w-5/6"}),(0,r.jsx)(cK,{className:"h-3 w-4/6"})]})}function uf(e){let{entries:t}=e;return(0,r.jsx)("div",{className:"divide-y divide-gray-700/50",children:t.map(e=>(0,r.jsx)("div",{className:"py-4 first:pt-1 last:pb-1",children:(0,r.jsx)(ux,{entry:e})}
14,e.version))})}function ub(e){let{open:t,onOpenChange:s,templateName:a,changelog:l=[],changelogUrl:i}=e,[o,d]=(0,n.useState)(null),[c,u]=(0,n.useState)(!1),[m,p]=(0,n.useState)(null);(0,n.useEffect)(()=>{t&&i&&null===o&&(u(!0),p(null),uh(i).then(d).catch(e=>{console.error("Failed to load changelog:",e),p("Failed to load changelog. Please try again later."),d([])}).finally(()=>u(!1)))},[t,i]);let h=i?o??[]:l;return(0,r.jsx)(ty,{open:t,onOpenChange:s,title:`Changelog — ${a}`,contentClass:"max-w-2xl",children:c?(0,r.jsx)(ug,{}):m?(0,r.jsx)("p",{className:"text-sm text-red-400 italic py-2",children:m}):0===h.length?(0,r.jsx)("p",{className:"text-sm text-gray-500 italic py-2",children:"No changelog available."}):(0,r.jsx)("div",{className:"max-h-[60vh] overflow-y-auto pr-4 -mr-2",children:(0,r.jsx)(uf,{entries:h})})})}function uv(e){let{update:t}=e,[s,a]=(0,n.useState)(null),[l,i]=(0,n.useState)(!1),[o,d]=(0,n.useState)(null),c=t.template.metadata.changelogUrl;return((0,n.useEffect)(()=>{c&&(i(!0),uh(c).then(e=>{a(e.filter(e=>c0(e.version,t.appliedVersion)>0))}).catch(e=>{console.error("Failed to load template changelog:",e),d("Failed to load changelog."),a([])}).finally(()=>i(!1)))},[c,t.appliedVersion]),l)?(0,r.jsx)(ug,{}):o?(0,r.jsx)("p",{className:"text-xs text-red-400 italic",children:o}):s&&0!==s.length?(0,r.jsx)("div",{className:"divide-y divide-gray-700/50",children:s.map(e=>(0,r.jsx)("div",{className:"py-3 first:pt-1 last:pb-1",children:(0,r.jsx)(ux,{entry:e})},e.version))}):(0,r.jsx)("p",{className:"text-xs text-gray-500 italic",children:"No changelog provided for this update."})}function uy(e){var t,s;let{template:a,validation:l,isLoading:i,onLoadTemplate:o,onDeleteRequest:d,onReadMore:c}=e,u=(0,n.useRef)(null),[m,p]=(0,n.useState)(!1),[h,x]=(0,n.useState)(!1),[g,f]=(0,n.useState)(!1),[b,v]=(0,n.useState)(!1),y=((null==(t=a.metadata.changelog)?void 0:t.length)??0)>0||!!a.metadata.changelogUrl,j=l&&l.warnings.length>0,N=l&&l.errors.length>0,k=c6(null==(s=a.config)?void 0:s.presets).map(e=>{var t;return null==(t=e.options)?void 0:t.name}).filter(e=>"string"==typeof e);return(0,n.useEffect)(()=>{let e=u.current;if(!e)return;let t=()=>p(e.scrollHeight>e.clientHeight);t();let s=new ResizeObserver(t);return s.observe(e),()=>s.disconnect()},[a.metadata.description]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(um,{glowSize:"350px",glowOpacity:.08,transitionDuration:"0.3s",className:"flex flex-col bg-gray-900 border-gray-800 hover:border-gray-600 transition-colors duration-200 rounded-lg p-4",children:[(0,r.jsxs)("div",{className:"flex items-start gap-2 mb-2",children:[(0,r.jsx)("div",{className:"flex-1 min-w-0",children:(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,r.jsx)("h3",{className:"text-base font-semibold text-white truncate",children:a.metadata.name}),(0,r.jsxs)("span",{className:"text-[10px] text-gray-400 bg-gray-800 px-1.5 py-0.5 rounded flex-shrink-0",children:["v",a.metadata.version||"1.0.0"]})]})}),(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0",children:["builtin"===a.metadata.source&&(0,r.jsx)("span",{className:"text-xs bg-brand-500/20 text-brand-300 px-2 py-0.5 rounded border border-brand-500/30",children:"Built-in"}),"custom"===a.metadata.source&&(0,r.jsx)("span",{className:"text-xs bg-purple-500/20 text-purple-300 px-2 py-0.5 rounded border border-purple-500/30",children:"Custom"}),"external"===a.metadata.source&&(0,r.jsx)("span",{className:"text-xs bg-emerald-500/20 text-emerald-300 px-2 py-0.5 rounded border border-emerald-500/30",children:"External"}),(j||N)&&(0,r.jsx)("button",{onClick:()=>x(!0),title:"View validation issues",className:`w-6 h-6 flex items-center justify-center rounded transition-colors ${N?"text-red-400 hover:bg-red-950/40":"text-yellow-400 hover:bg-yellow-950/40"}`,children:(0,r.jsx)(ui.A,{className:"w-4 h-4"})})]})]}),(0,r.jsxs)("div",{className:"mb-3",children:[(0,r.jsx)("div",{ref:u,className:"overflow-hidden max-h-[10rem] text-sm text-gray-400",style:m?{WebkitMaskImage:"linear-gradient(to bottom, black 60%, transparent 100%)",maskImage:"linear-gradient(to bottom, black 60%, transparent 100%)"}:void 0,children:(0,r.jsx)(nz,{children:a.metadata.description})}),m&&(0,r.jsx)("button",{onClick:()=>c(a),className:"mt-2 w-full text-center text-xs text-gray-500 hover:text-[--brand] transition-colors font-medium py-1  rounded hover:border-gray-700 hover:bg-gray-900/50",children:"Read full description ↓"})]}),(0,r.jsxs)("div",{className:"flex-1 space-y-3",children:[(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-gray-500 text-xs mb-1.5",children:"Category"}),(0,r.jsx)("span",{className:"text-xs bg-gray-800/60 text-gray-300 px-2 py-1 rounded inline-block",children:a.metadata.category})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-gray-500 text-xs mb-1.5",children:"Author"}),(0,r.jsx)("span",{className:"text-xs text-gray-300",children:a.metadata.author})]})]}),k.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-gray-500 text-xs mb-1.5",children:"Addons"}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[k.slice(0,5).map(e=>(0,r.jsx)("span",{className:"text-xs bg-blue-600/30 text-blue-300 px-2 py-0.5 rounded",children:e},e)),k.length>5&&(0,r.jsxs)("button",{onClick:()=>f(!0),className:"text-xs bg-blue-600/30 text-blue-300 px-2 py-0.5 rounded hover:bg-blue-600/50 transition-colors",children:["+",k.length-5," more"]})]})]}),a.metadata.services&&a.metadata.services.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-gray-500 text-xs mb-1.5",children:"Services"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5",children:a.metadata.services.map(e=>{var t;return(0,r.jsx)("span",{className:"text-xs bg-green-600/30 text-green-300 px-2 py-0.5 rounded",children:(null==(t=sC[e])?void 0:t.name)||e},e)})})]})]}),(0,r.jsxs)("div",{className:"flex gap-2 mt-4 pt-3 border-t border-gray-800/80",children:["external"===a.metadata.source&&(0,r.jsx)(E,{icon:(0,r.jsx)(uo.A,{className:"w-4 h-4"}),intent:"alert-outline",onClick:e=>{e.stopPropagation(),d(a)}}),y&&(0,r.jsx)(E,{icon:(0,r.jsx)(ud.A,{className:"w-4 h-4"}),intent:"gray-outline",onClick:e=>{e.stopPropagation(),v(!0)},title:"View Changelog"}),(0,r.jsx)(w,{intent:"primary",size:"md",leftIcon:(0,r.jsx)(uc.A,{className:"w-4 h-4"}),onClick:()=>o(a),loading:i,className:"flex-1",children:"Load Template"})]})]}),h&&l&&(0,r.jsx)(uu,{open:h,template:a,data:l,onProceed:null,proceedLabel:"",onClose:()=>x(!1)}),(0,r.jsx)(ty,{open:g,onOpenChange:e=>!e&&f(!1),title:`Addons — ${a.metadata.name}`,children:(0,r.jsx)("div",{className:"flex flex-wrap gap-2 py-1",children:k.map(e=>(0,r.jsx)("span",{className:"text-sm bg-blue-600/30 text-blue-300 px-3 py-1 rounded",children:e},e))})}),(0,r.jsx)(ub,{open:b,onOpenChange:e=>!e&&v(!1),templateName:a.metadata.name,changelog:a.metadata.changelog,changelogUrl:a.metadata.changelogUrl})]})}function uj(e){let{searchQuery:t,onSearchChange:s,selectedCategory:a,onCategoryChange:l,selectedSource:i,onSourceChange:o,categories:d,sources:c,filteredTemplates:u,loadingTemplates:m,templateValidations:p,isLoading:h,onLoadTemplate:x,onImportOpen:g,onDeleteRequest:f,totalTemplateCount:v,initialExpandedTemplate:y}
14=e,[j,N]=(0,n.useState)(null);return(0,n.useEffect)(()=>{y&&N(y)},[null==y?void 0:y.metadata.id]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"space-y-3 min-w-0",children:[(0,r.jsx)(W,{placeholder:"Search templates...",value:t,onValueChange:s,leftIcon:(0,r.jsx)(cu.A,{className:"w-4 h-4"})}),(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.jsx)("span",{className:"text-sm text-gray-400 flex-shrink-0",children:"Source:"}),(0,r.jsx)("div",{className:"flex gap-1.5 overflow-x-auto min-w-0 flex-1 pb-2",children:c.map(e=>(0,r.jsx)(to,{className:b("mb-2",{all:"bg-gray-800 text-white border-gray-700",builtin:"bg-brand-600 text-white border-brand-500",custom:"bg-purple-600 text-white border-purple-500",external:"bg-emerald-600 text-white border-emerald-500"}[e]),trigger:(0,r.jsx)("button",{onClick:()=>o(e),className:`px-3 py-1 text-xs font-medium rounded transition-colors whitespace-nowrap flex-shrink-0 ${i===e&&"all"===e?"bg-gray-600 text-white":({all:"bg-gray-700/50 text-gray-300 hover:bg-gray-700",builtin:"builtin"===i?"bg-brand-500/20 text-brand-300 border border-brand-500/30":"bg-brand-500/10 text-brand-400 hover:bg-brand-500/20 border border-brand-500/20",custom:"custom"===i?"bg-purple-500/20 text-purple-300 border border-purple-500/30":"bg-purple-500/10 text-purple-400 hover:bg-purple-500/20 border border-purple-500/20",external:"external"===i?"bg-emerald-500/20 text-emerald-300 border border-emerald-500/30":"bg-emerald-500/10 text-emerald-400 hover:bg-emerald-500/20 border border-emerald-500/20"})[e]}`,children:e.charAt(0).toUpperCase()+e.slice(1)}),children:{all:"All sources",builtin:"Provided with AIOStreams",custom:"Added by the instance hoster",external:"Imported by you"}[e]},e))})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.jsx)("span",{className:"text-sm text-gray-400 flex-shrink-0",children:"Category:"}),(0,r.jsx)("div",{className:"flex gap-1.5 overflow-x-auto min-w-0 flex-1 pb-2",children:d.map(e=>(0,r.jsx)(w,{intent:a===e?"primary":"gray-outline",size:"sm",onClick:()=>l(e),className:"whitespace-nowrap flex-shrink-0",children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]})]}),(0,r.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 max-h-[640px] overflow-y-auto pr-2",children:m?(0,r.jsx)("div",{className:"col-span-2 text-center py-8 text-gray-400",children:"Loading templates..."}):0===u.length?(0,r.jsx)("div",{className:"col-span-2 text-center py-8 text-gray-400",children:"No templates found matching your search"}):u.map(e=>(0,r.jsx)(uy,{template:e,validation:p[e.metadata.id],isLoading:h,onLoadTemplate:x,onDeleteRequest:f,onReadMore:N},e.metadata.id))}),(0,r.jsxs)("div",{className:"flex justify-between items-center pt-2 border-t border-gray-700",children:[(0,r.jsxs)("div",{className:"text-sm text-gray-400",children:[v," template",1!==v?"s":""," available"]}),(0,r.jsx)("div",{className:"flex gap-2",children:(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{intent:"primary-outline",icon:(0,r.jsx)(tC.bh6,{}),onClick:g}),children:"Import Template"})})]}),(0,r.jsx)(ty,{open:null!==j,onOpenChange:e=>{e||N(null)},title:(null==j?void 0:j.metadata.name)??"",contentClass:"max-w-2xl",children:j&&(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsxs)("span",{className:"text-xs bg-gray-800 text-gray-300 px-2 py-1 rounded",children:["v",j.metadata.version||"1.0.0"]}),(0,r.jsxs)("span",{className:"text-xs text-gray-400",children:["by ",j.metadata.author]}),(0,r.jsx)("span",{className:"text-xs bg-gray-800/60 text-gray-300 px-2 py-1 rounded",children:j.metadata.category}),"builtin"===j.metadata.source&&(0,r.jsx)("span",{className:"text-xs bg-brand-500/20 text-brand-300 px-2 py-0.5 rounded border border-brand-500/30",children:"Built-in"}),"custom"===j.metadata.source&&(0,r.jsx)("span",{className:"text-xs bg-purple-500/20 text-purple-300 px-2 py-0.5 rounded border border-purple-500/30",children:"Custom"}),"external"===j.metadata.source&&(0,r.jsx)("span",{className:"text-xs bg-emerald-500/20 text-emerald-300 px-2 py-0.5 rounded border border-emerald-500/30",children:"Exter
14nal"})]}),(0,r.jsx)("div",{className:"max-h-[55vh] overflow-y-auto pr-1",children:(0,r.jsx)(nz,{className:"text-sm text-gray-300 [&_a]:text-[--brand] [&_a:hover]:underline [&_ul]:list-disc [&_ul]:pl-4 [&_li]:mb-0.5",children:j.metadata.description})}),(0,r.jsx)("div",{className:"flex justify-end pt-2 border-t border-gray-700",children:(0,r.jsx)(w,{intent:"primary",leftIcon:(0,r.jsx)(uc.A,{className:"w-4 h-4"}),onClick:()=>{x(j),N(null)},loading:h,children:"Load Template"})})]})})]})}function uw(e){let{processedTemplate:t,selectedServices:s,onServicesChange:a,onBack:n,onSkip:l,onNext:i,status:o}=e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(nU,{intent:"info",description:t.allowSkipService?"Select the services you want to use with this template. You can skip this step if services are not needed.":"Select the services you want to use with this template."}),(0,r.jsx)("div",{className:"space-y-2 flex-1 min-h-0 overflow-y-auto pr-2",children:t.services.map(e=>{var t,n;let l=null==o||null==(n=o.settings)||null==(t=n.services)?void 0:t[e];if(!l)return null;let i=s.includes(e);return(0,r.jsx)("button",{onClick:()=>{a(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},className:`w-full p-3 rounded-lg border-2 text-left transition-colors ${i?"border-[--brand] bg-brand-400/20":"border-gray-700 bg-gray-800/50 hover:border-gray-600"}`,children:(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("div",{className:"font-semibold text-white",children:l.name}),l.signUpText&&(0,r.jsx)(nz,{className:"text-sm text-[--muted] mt-1",stopPropagation:!0,children:l.signUpText})]}),i&&(0,r.jsx)(uc.A,{className:"w-5 h-5 text-[--brand] flex-shrink-0 ml-2"})]})},e)})}),(0,r.jsxs)("div",{className:"flex justify-between gap-2 pt-2 border-t border-gray-700",children:[(0,r.jsx)(w,{intent:"primary-outline",onClick:n,children:"Back"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[t.allowSkipService&&(0,r.jsx)(w,{intent:"gray-outline",onClick:l,children:"Skip"}),(0,r.jsx)(w,{intent:"white",rounded:!0,onClick:i,disabled:!t.allowSkipService&&0===s.length,children:"Next"})]})]})]})}function uN(e){let{mode:t,onModeChange:s,options:a,values:n,onValuesChange:l,trusted:i,selectedServices:o,onBack:d,onNext:c}=e,u=ul(t,a,n,o);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(cH,{value:t,onChange:s,size:"sm",className:"w-full"}),(0,r.jsx)("div",{className:"space-y-3 max-h-[70vh] overflow-y-auto pr-3",children:0===u.length?(0,r.jsx)("div",{className:"text-center py-6 text-gray-400 text-sm",children:"No options available in simple mode. Switch to Advanced to see all options."}):u.map(e=>(0,r.jsx)(dJ,{option:e,value:n[e.id]??e.default,trusted:i,onChange:t=>l(s=>({...s,[e.id]:t}))},e.id))}),(0,r.jsxs)("div",{className:"flex justify-between gap-2 pt-2 border-t border-gray-700",children:[(0,r.jsx)(w,{intent:"primary-outline",onClick:d,children:"Back"}),(0,r.jsx)(w,{intent:"white",rounded:!0,onClick:c,children:"Next"})]})]})}function uk(e){let{processedTemplate:t,inputValues:s,onInputValuesChange:a,isLoading:n,onBack:l,onConfirm:i}=e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(nU,{intent:"info",description:"Enter your API keys and credentials below. Some addons may require additional setup in the Addons section after loading."}),(0,r.jsx)("form",{className:"space-y-3 flex-1 min-h-0 overflow-y-auto pr-2",children:0===t.inputs.length?(0,r.jsx)("div",{className:"text-center py-4 text-gray-400 text-sm",children:"No inputs required for this template"}):t.inputs.map(e=>(0,r.jsx)(uS,{type:e.type,value:s[e.key]||"",onValueChange:t=>{a(s=>({...s,[e.key]:t}))},label:e.label,description:e.description,required:e.required},e.key))}),(0,r.jsxs)("div",{className:"flex justify-between gap-2 pt-2 border-t border-gray-700",children:[(0,r.jsx)(w,{intent:"primary-outline",onClick:l,children:"Back"}),(0,r.jsx)(w,{intent:"white",rounded:!0,onClick:i,loading:n,disabled:t.inputs.some(e=>{var t;return e.required&&!(null==(t=s[e.key])?void 0:t.trim())}),children:"Load Template"})]})]})}function uS(e){let{type:t,value:s,onValueChange:a,label:n,description:l,required:i,placeholder:o}=e;return(0,r.jsxs)(r.Fragment,{children:["string"===t?(0,r.jsx)(W,{value:s,onValueChange:a,label:n,required:i,placeholder:o}):"password"===t?(0,r.jsx)(Z,{value:s,onValueChange:a,label:n,required:i,placeholder:o}):"custom-nntp-servers"===t?(0,r.jsx)(d1,{name:n,description:l,value:s||void 0,onChange:e=>a(e||"")}):null,l&&"custom-nntp-servers"!==t&&(0,r.jsx)(nz,{className:"text-xs text-[--muted] mt-1",children:l})]})}function uC(e){let{showImportModal:t,onImportModalChange:s,importUrl:a,onImportUrlChange:n,isImporting:l,onImportFromUrl:i,onImportFromFile:o,showImportConfirmModal:d,onImportConfirmModalChange:c,pendingImportTemplates:u,selectedPendingTemplateIndex:m,onSelectedIndexChange:p,showDeepLinkWarning:h,onConfirmImport:x,onCancelImport:g,status:f}=e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ty,{open:t,onOpenChange:s,title:"Import Template",description:"Import a template from a URL or local file",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(W,{placeholder:"Enter template URL...",value:a,onValueChange:n,className:"flex-1"}),(0,r.jsx)(w,{intent:"primary",onClick:i,loading:l,disabled:!a.trim(),children:"Go"})]}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("div",{className:"absolute inset-0 flex items-center",children:(0,r.jsx)("div",{className:"w-full border-t border-gray-700"})}),(0,r.jsx)("div",{className:"relative flex justify-center text-xs uppercase",children:(0,r.jsx)("span",{className:"bg-gray-900 px-2 text-gray-400",children:"or"})})]}),(0,r.jsx)(w,{intent:"primary",className:"w-full",leftIcon:(0,r.jsx)(tC.bh6,{className:"w-4 h-4"}),onClick:o,children:"Import from File"})]})}),(0,r.jsx)(ty,{open:d,onOpenChange:c,title:"Confirm Import",description:1===u.length?"Review the template details before importing":`${u.length} templates will be imported`,children:(0,r.jsxs)("div",{className:"space-y-4",children:[h&&(0,r.jsx)(nU,{intent:"warning",isClosable:!1,title:"Externally Linked Template",description:"This template is being loaded from an external URL that was passed via a link. Only proceed if you recognise the source and trust where this link came from. If you did not expect to see this, click Cancel."}),1===u.length?(0,r.jsxs)("div",{className:"bg-gray-800/50 border border-gray-700 rounded-lg p-4 space-y-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs text-gray-400 mb-1",children:"Name"}),(0,r.jsxs)("div",{className:"text-sm font-semibold text-white flex items-center gap-2",children:[u[0].metadata.name,(0,r.jsxs)("span",{className:"text-[10px] text-gray-400 bg-gray-800 px-1.5 py-0.5 rounded",children:["v",u[0].metadata.version||"1.0.0"]})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs text-gray-400 mb-1",children:"Description"}),(0,r.jsx)(nz,{className:"text-sm text-gray-300",children:u[0].metadata.description})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs text-gray-400 mb-1",children:"Author"}),(0,r.jsx)("div",{className:"text-sm text-gray-300",children:u[0].metadata.author})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs text-gray-400 mb-1",children:"Category"}),(0,r.jsx)("div",{className:"text-sm text-gray-300",children:u[0].metadata.category})]})]}),u[0].metadata.services&&u[0].metadata.services.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs text-gray-400 mb-1",children:"Services"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5",children:u[0].metadata.services.map(e=>{var t;return(0,r.jsx)("span",{className:"text-xs bg-green-600/30 text-green-300 px-2 py-0.5 rounded",children:(null==(t=sC[e])?void 0:t.name)||e},e)})})]})]}):(0,r.jsxs)("div",{className:"bg-gray-800/50 border border-gray-700 rounded-lg p-4",children:[(0,r.jsx)("p",{className:"text-xs text-gray-400 mb-3",children:"Click a template to select it, then use “Use Selected Template” to apply it - or import them all at once."}),(0,r.jsx)("div",{className:"space-y-1 max-h-[300px] overflow-y-auto",children:u.map((e,t)=>(0,r.jsxs)("div",{onClick:()=>p(t===m?null:t),className:b("flex items-center gap-3 py-2 px-2 rounded cursor-pointer transition-colors border",m===t?"bg-white/10 border-white/20":"border-transparent hover:bg-gray-700/50"),children:[(0,r.jsx)("div",{className:b("w-3 h-3 rounded-full border-2 flex-shrink-0 transition-colors",m===t?"bg-white border-white":"border-gray-500")}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("div",{className:"text-sm font-medium text-white truncate",children:e.metadata.name}),(0,r.jsxs)("div",{className:"text-xs text-gray-400 truncate",children:[e.metadata.category," • v",e.metadata.version||"1.0.0"]})]})]},t))})]}),(0,r.jsx)(nU,{intent:"info",description:`The template${1!==u.length?"s":""} will be saved to your browser's local storage and added to your templates list.`}),(0,r.jsxs)("div",{className:"flex justify-between gap-2 pt-2 border-t border-gray-700",children:[(0,r.jsx)(w,{intent:"primary-outline",onClick:g,children:"Cancel"}),(0,r.jsx)("div",{className:"flex gap-2",children:1===u.length?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(w,{intent:"gray-outline",onClick:()=>x(!1),children:"OK"}),(0,r.jsx)(w,{intent:"white",rounded:!0,onClick:()=>x(!0),children:"Use This Template Now"})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(w,{intent:"gray-outline",onClick:()=>x(!1),children:"Import All"}),null!==m&&(0,r.jsx)(w,{intent:"white",rounded:!0,onClick:()=>x(!0,m),children:"Use Selected"})]})})]})]})})]})}function u_(e){var t,s;let{open:a,onOpenChange:l,openImportModal:i=!1,deepLinkUrl:o,deepLinkTemplateId:d,initialExpandedTemplateId:c}=e,{setUserData:u,userData:m}=s4(),{status:p}=e$(),{setSelectedMenu:h}=as(),{mode:g,setMode:f}
14=tX(),[b,v]=(0,n.useState)(""),[y,j]=(0,n.useState)("all"),[w,N]=(0,n.useState)("all"),k=n.useRef(null),S=function(){let[e,t]=(0,n.useState)(!1),[s,a]=(0,n.useState)(null),[r,l]=(0,n.useState)(null),[i,o]=(0,n.useState)(null),[d,c]=(0,n.useState)("Proceed");return{show:e,template:s,data:r,onProceed:i,proceedLabel:d,open:e=>{let{template:s,data:r,onProceed:n,proceedLabel:i}=e;a(s),l(r),o(()=>n),c(i),t(!0)},close:()=>{t(!1),a(null),l(null),o(null),c("Proceed")},setOnProceed:o}}(),C=ue(p),_=function(e){let{status:t,userData:s,setUserData:a,validationModal:r,templateValidations:l,setSelectedMenu:i,onOpenChange:o,mode:d}=e,[c,u]=(0,n.useState)("browse"),[m,p]=(0,n.useState)(null),[h,g]=(0,n.useState)([]),[f,b]=(0,n.useState)({}),[v,y]=(0,n.useState)(null),[j,w]=(0,n.useState)([]),[N,k]=(0,n.useState)({}),[S,C]=(0,n.useState)([]),[_,R]=(0,n.useState)(!1),A=()=>{let e={step:c,processedTemplate:m?JSON.parse(JSON.stringify(m)):null,pendingTemplate:v?JSON.parse(JSON.stringify(v)):null,templateInputOptions:JSON.parse(JSON.stringify(j)),templateInputValues:JSON.parse(JSON.stringify(N)),selectedServices:[...h],inputValues:{...f}};C(t=>[...t,e])},T=e=>((null==s?void 0:s.services)??[]).filter(t=>e.includes(t.id)&&t.enabled&&t.credentials&&Object.values(t.credentials).some(e=>e)).map(e=>e.id),I=async e=>{let{config:t,inputs:s,resolvedValues:r,selectedSvcs:n,templateName:l,setToSaveInstallMenu:d,templateId:c,templateVersion:m,templateSourceUrl:h}=e;R(!0);try{let e=s1(JSON.parse(JSON.stringify(t)));if(s.forEach(t=>{let s=r[t.key];if(s||!t.required)for(let a of Array.isArray(t.path)?t.path:[t.path])if(a.startsWith("services.")){let t=a.split("."),r=t[1],n=t[2];e.services||(e.services=[]);let l=e.services.find(e=>e.id===r);l||(l={id:r,enabled:!0,credentials:{}},e.services.push(l)),l.credentials||(l.credentials={}),l.credentials[n]=s||""}else un(e,a,s||"")}),n.length>0){e.services||(e.services=[]);let t=e.services;n.forEach(e=>{let s=t.find(t=>t.id===e);s?s.enabled||(s.enabled=!0):t.push({id:e,enabled:!0,credentials:{}})}),t.forEach(e=>{n.includes(e.id)||(e.enabled=!1)})}!function e(t,s){if("string"==typeof t)return t.replace(/\{\{services\.(\w[\w-]*)\.(\w[\w-]*)\}\}/g,(e,t,a)=>s[`service_${t}_${a}`]??"");if(Array.isArray(t))return t.map(t=>e(t,s));if(t&&"object"==typeof t)for(let a of Object.keys(t))t[a]=e(t[a],s);return t}(e,r),a(t=>({...t,...e})),c&&m&&a(e=>({...e,appliedTemplates:[...(e.appliedTemplates??[]).filter(e=>e.id!==c),{id:c,version:m,...h?{url:h}:{}}]}));let f=(e.presets||[]).filter(e=>["gdrive"].some(t=>e.type.toLowerCase().includes(t))).map(e=>{var t;return(null==(t=e.options)?void 0:t.name)||e.type});x.oR.success(`Template "${l}" loaded successfully`),f.length>0&&setTimeout(()=>{x.oR.info(`Note: ${f.join(", ")} require additional setup. Please configure them in the Addons section.`,{duration:8e3})},1e3),p(null),u("browse"),g([]),b({}),C([]),d&&i("save-install"),o(!1)}catch(e){console.error("Error loading template:",e),x.oR.error("Failed to load template")}finally{R(!1)}},E=e=>{ur(e.config,t);let a=us(e,t,s);if(p(a),a.skipServiceSelection){if(1===a.services.length){let e=ua(a,a.services,t,s);a.inputs=[...e,...a.inputs],g(a.services)}if(0===a.inputs.length)return void I({config:e.config,inputs:[],resolvedValues:{},selectedSvcs:1===a.services.length?a.services:[],templateName:e.metadata.name,setToSaveInstallMenu:e.metadata.setToSaveInstallMenu,templateId:e.metadata.id,templateVersion:e.metadata.version,templateSourceUrl:e.metadata.sourceUrl});b(a.inputs.reduce((e,t)=>({...e,[t.key]:t.value}),{})),u("inputs")}else if(a.showServiceSelection)g(T(a.services)),u("selectService");else{if(0===a.inputs.length)return void I({config:e.config,inputs:[],resolvedValues:{},selectedSvcs:[],templateName:e.metadata.name,setToSaveInstallMenu:e.metadata.setToSaveInstallMenu,templateId:e.metadata.id,templateVersion:e.metadata.version,templateSourceUrl:e.metadata.sourceUrl});b(a.inputs.reduce((e,t)=>({...e,[t.key]:t.value}),{})),u("inputs")}},M=e=>{A();let a=e.metadata.inputs||[];if(a.length>0){let r={};for(let e of a)if(void 0!==e.default?r[e.id]=e.default:"boolean"===e.type&&(r[e.id]=!1),"subsection"===e.type&&Array.isArray(e.subOptions)){let t={};for(let s of e.subOptions)void 0!==s.default?t[s.id]=s.default:"boolean"===s.type&&(t[s.id]=!1);Object.keys(t).length>0&&(r[e.id]={...t,...r[e.id]??{}})}let n=((e,t)=>{let s={...e};for(let a of Object.keys(t))null===t[a]||"object"!=typeof t[a]||Array.isArray(t[a])||"object"!=typeof e[a]||null===e[a]||Array.isArray(e[a])?s[a]=t[a]:s[a]={...e[a],...t[a]};return s})(r,(e=>{try{let t=localStorage.getItem("aiostreams-template-inputs");if(t)return JSON.parse(t)[e]??{}}catch{}return{}})(e.metadata.id)),l=us(e,t,s);if(l.showServiceSelection){p(l),y(e),w(a),k(n),g(T(l.services)),u("selectService");return}p(null),y(e),w(a),k(n),u("templateInputs");return}E(e)},P=async()=>
14{if(!m)return;let e=m.inputs.filter(e=>{var t;return e.required&&!(null==(t=f[e.key])?void 0:t.trim())});e.length>0?x.oR.error(`Please fill in all required fields: ${e.map(e=>e.label).join(", ")}`):await I({config:m.template.config,inputs:m.inputs,resolvedValues:f,selectedSvcs:h,templateName:m.template.metadata.name,setToSaveInstallMenu:m.template.metadata.setToSaveInstallMenu,templateId:m.template.metadata.id,templateVersion:m.template.metadata.version,templateSourceUrl:m.template.metadata.sourceUrl})};return{currentStep:c,processedTemplate:m,selectedServices:h,inputValues:f,pendingTemplate:v,templateInputOptions:j,templateInputValues:N,wizardHistory:S,isLoading:_,setSelectedServices:g,setInputValues:b,setTemplateInputValues:k,setProcessedTemplate:p,executeLoadTemplate:M,handleLoadTemplate:e=>{let t=l[e.metadata.id];t&&(t.errors.length>0||t.warnings.length>0)?r.open({template:e,data:t,proceedLabel:"Load Anyway",onProceed:0===t.errors.length?()=>M(e):null}):M(e)},handleServiceSelectionNext:()=>{if(!m)return;if(!m.allowSkipService&&0===h.length)return void x.oR.error("Please select at least one service");A();let e=[...ua(m,h,t,s),...m.inputs];(m.inputs=e,p(e=>{if(!e)return null;for(let a of h){var t,s;let r=null==(s=e.template.config.services)||null==(t=s.find)?void 0:t.call(s,e=>e.id===a);r&&(r.enabled=!0)}return e}),null!==v)?u("templateInputs"):(b(e.reduce((e,t)=>({...e,[t.key]:t.value}),{})),u("inputs"))},handleServiceSelectionSkip:()=>{if(m){if(!m.allowSkipService)return void x.oR.error("Service selection cannot be skipped for this template");if(A(),g([]),null!==v)return void u("templateInputs");b(m.inputs.reduce((e,t)=>({...e,[t.key]:t.value}),{})),u("inputs")}},handleTemplateInputsNext:()=>{if(!v)return;let e=ul(d,j,N,h).filter(e=>e.required&&(void 0===N[e.id]||null===N[e.id]||""===N[e.id]));if(e.length>0)return void x.oR.error(`Please fill in required fields: ${e.map(e=>e.name||e.id).join(", ")}`);A();let a=function e(t,s,a){if(Array.isArray(t))return t.filter(e=>!e||"object"!=typeof e||!("__if"in e)||c3(e.__if,s,a)).flatMap(t=>{if(t&&"object"==typeof t&&"__if"in t){let{__if:r,...n}=t;if("__value"in n){let t=e(n.__value,s,a);return Array.isArray(t)?t:[t]}return e(n,s,a)}if(t&&"object"==typeof t&&"__value"in t){let r=e(t.__value,s,a);return Array.isArray(r)?r:[r]}let r=e(t,s,a);return Array.isArray(r)?r:[r]});if(t&&"object"==typeof t){if("__switch"in t){let r,n=t.__switch,l=t.cases??{},i=t.default??null,o="services"===(r=n.trim())?a.slice():r.startsWith("inputs.")?c2(s,r.slice(7)):r.startsWith("services.")?a.includes(r.slice(9)):void 0,d=null!=o?String(o):null;return e(null!==d&&d in l?l[d]:i,s,a)}if("__if"in t&&"__value"in t)return c3(t.__if,s,a)?e(t.__value,s,a):c1;if(!0===t.__remove)return c1;let r={};for(let[n,l]of Object.entries(t)){let t=e(l,s,a);t!==c1&&(r[n]=t)}return r}if("string"==typeof t){if("{{services}}"===t)return a.slice();let e=t.match(/^\{\{(inputs|services)\.([^}]+)\}\}$/);if(e){let[,t,r]=e;if("inputs"===t){let e=c2(s,r);return null!=e?e:""}if("services"===t)return r.includes(".")?`{{services.${r}}}`:a.includes(r)}return t.replace(/\{\{services\}\}/g,a.join(",")).replace(/\{\{(inputs|services)\.([^}]+)\}\}/g,(e,t,r)=>{if("inputs"===t){let e=c2(s,r);return null!=e?String(e):""}return"services"===t?r.includes(".")?`{{services.${r}}}`:String(a.includes(r)):""})}return t}(JSON.parse(JSON.stringify(v.config)),N,h);ur(a,t);let r={...v,config:a};var n=v.metadata.id;try{let e=localStorage.getItem("aiostreams-template-inputs"),t=e?JSON.parse(e):{};t[n]=N,localStorage.setItem("aiostreams-template-inputs",JSON.stringify(t))}catch{}if(y(null),w([]),null!==m){let e=us(r,t,s);e.inputs=[...m.inputs.filter(e=>Array.isArray(e.path)?e.path.some(e=>e.startsWith("services.")):e.path.startsWith("services.")),...e.inputs],p(e),b(e.inputs.reduce((e,t)=>({...e,[t.key]:t.value}),{})),u("inputs")}else E(r)},pushHistory:A,handleBack:()=>{if(0===S.length)return;let e=S[S.length-1];C(S.slice(0,-1)),u(e.step),p(e.processedTemplate),y(e.pendingTemplate),w(e.templateInputOptions),k(e.templateInputValues),g(e.selectedServices),b(e.inputValues)},confirmLoadTemplate:P,handleCancel:()=>{p(null),y(null),w([]),k({}),u("browse"),g([]),b({}),C([]),o(!1)}}}({status:p,userData:m,setUserData:u,validationModal:S,templateValidations:C.templateValidations,setSelectedMenu:h,onOpenChange:l,mode:g}),R=function(e){let{status:t,templates:s,setTemplates:a,setTemplateValidations:r,validationModal:l,handleLoadTemplate:i,executeLoadTemplate:o}
14=e,[d,c]=(0,n.useState)(!1),[u,m]=(0,n.useState)(""),[p,h]=(0,n.useState)(!1),[g,f]=(0,n.useState)(!1),[b,v]=(0,n.useState)([]),[y,j]=(0,n.useState)(null),[w,N]=(0,n.useState)(!1),[k,S]=(0,n.useState)(null),C=tN({title:"Delete Template",description:"Are you sure you want to delete this template? This action cannot be undone.",actionText:"Delete",actionIntent:"alert-subtle",onConfirm:()=>{var e;k&&(e=k.metadata.id,a(t=>t.filter(t=>t.metadata.id!==e)),cX(cQ().filter(t=>t.metadata.id!==e)),x.oR.success("Template deleted successfully"))}}),_=(e,a,n)=>{try{let N=Array.isArray(e)?e:[e],k=[],S=[];if(n){let e=function(e){let t=[],s=[],a=[],r=0;for(;r<e.length;){let n=e[r];if("{"===n){let e=a.join("")||"root";s.push({path:e,seen:new Set}),r++;continue}if("}"===n){s.pop(),r++;continue}if('"'===n&&s.length>0){let a=r+1,n="";for(;a<e.length;){if("\\"===e[a]){a+=2;continue}if('"'===e[a])break;n+=e[a],a++}for(a++;a<e.length&&/\s/.test(e[a]);)a++;if(":"===e[a]){let e=s[s.length-1];e.seen.has(n)?t.push(`${e.path}: duplicate key "${n}"`):e.seen.add(n),r=a+1;continue}}r++}return t}(n);S.push(...e)}for(let e of N){var i,o,d,u,p,h,g,b,y,j,w;if(!e.config)return void x.oR.error("Invalid template: missing config field");let n=(null==(i=e.metadata)?void 0:i.id)||`imported-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,f=s.find(e=>e.metadata.id===n);if(f&&("builtin"===f.metadata.source||"custom"===f.metadata.source)&&1!==c0(e.metadata.version,f.metadata.version)){console.log(`Skipping template "${e.metadata.name}" because it is not newer than the existing template`);continue}let v={metadata:{id:n,name:(null==(o=e.metadata)?void 0:o.name)||"Imported Template",description:(null==(d=e.metadata)?void 0:d.description)||"Imported from JSON",author:(null==(u=e.metadata)?void 0:u.author)||"Unknown",version:(null==(p=e.metadata)?void 0:p.version)||"1.0.0",category:(null==(h=e.metadata)?void 0:h.category)||"Custom",services:null==(g=e.metadata)?void 0:g.services,serviceRequired:null==(b=e.metadata)?void 0:b.serviceRequired,source:"external",setToSaveInstallMenu:!0,sourceUrl:a,inputs:null==(y=e.metadata)?void 0:y.inputs,changelog:null==(j=e.metadata)?void 0:j.changelog,changelogUrl:null==(w=e.metadata)?void 0:w.changelogUrl},config:e.config||e};if(t){let e=c7(v,t);if(e.errors.length>0){c(!1),m(""),l.open({template:v,data:e,onProceed:null,proceedLabel:"Import Anyway"});return}if(r(t=>({...t,[v.metadata.id]:e})),e.warnings.length>0){let t=N.length>1?`[${v.metadata.name}] `:"";S.push(...e.warnings.map(e=>`${t}${e}`))}}k.push(v)}if(0===k.length)return void x.oR.info("There were no templates to import as existing templates are newer or the same version.");if(S.length>0){c(!1),m(""),l.open({template:k[0],data:{isValid:!0,errors:[],warnings:S},proceedLabel:"Import Anyway",onProceed:()=>{v(k),f(!0)}});return}c(!1),m(""),v(k),f(!0)}catch(e){x.oR.error("Invalid template format: "+e.message)}},R=async()=>{if(!u.trim())return void x.oR.error("Please enter a URL");h(!0);try{let e=await fetch(u);if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);let t=await e.text(),s=JSON.parse(t);_(s,u,t)}catch(e){x.oR.error("Failed to import template: "+e.message)}finally{h(!1)}};return{showImportModal:d,setShowImportModal:c,importUrl:u,setImportUrl:m,isImporting:p,showImportConfirmModal:g,setShowImportConfirmModal:f,pendingImportTemplates:b,selectedPendingTemplateIndex:y,setSelectedPendingTemplateIndex:j,showDeepLinkWarning:w,setShowDeepLinkWarning:N,templateToDelete:k,setTemplateToDelete:S,processImportedTemplate:_,handleImportFromUrl:R,handleImportFromFile:()=>{let e=document.createElement("input");e.type="file",e.accept=".json",e.onchange=async e=>{var t;let s=null==(t=e.target.files)?void 0:t[0];if(s)try{let e=await s.text(),t=JSON.parse(e);_(t,void 0,e)}catch(e){x.oR.error("Failed to read file: "+e.message)}},e.click()},handleConfirmImport:function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1?arguments[1]:void 0,s=cQ(),r=new Set(b.map(e=>e.metadata.id));cX([...b,...s.filter(e=>!r.has(e.metadata.id))]),a(e=>[...b,...e.filter(e=>!r.has(e.metadata.id))]);let n=s.filter(e=>r.has(e.metadata.id)).length;n>0?x.oR.success(`Successfully imported ${b.length} template${1!==b.length?"s":""} (${n} overwritten)`):x.oR.success(`Successfully imported ${b.length} template${1!==b.length?"s":""}`),e&&(1===b.length||void 0!==t)?(f(!1),o(b[t??0])):f(!1),v([]),j(null),N(!1)},handleCancelImport:()=>{f(!1),v([]),j(null),N(!1)},confirmDeleteTemplate:C}}({status:p,templates:C.templates,setTemplates:C.setTemplates,setTemplateValidations:C.setTemplateValidations,validationModal:S,handleLoadTemplate:_.handleLoadTemplate,executeLoadTemplate:_.executeLoadTemplate});(0,n.useEffect)(()=>
14{if(a)try{C.loadTemplates(),i&&R.setShowImportModal(!0)}catch(t){let e="Failed to load templates";t instanceof el?e+=`: ${t.message}`:console.error("Error loading templates:",t),x.oR.error(e)}},[a]),(0,n.useEffect)(()=>{a&&o&&k.current!==o&&(k.current=o,R.setShowDeepLinkWarning(!0),(async()=>{try{let e=await fetch(o);if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);let t=await e.json();R.processImportedTemplate(t,o)}catch(e){x.oR.error("Failed to load template from link: "+e.message)}})())},[a,o]),(0,n.useEffect)(()=>{if(d&&R.pendingImportTemplates.length>0){let e=R.pendingImportTemplates.findIndex(e=>e.metadata.id===d);-1!==e&&R.setSelectedPendingTemplateIndex(e)}},[R.pendingImportTemplates,d]);let A=(0,n.useMemo)(()=>["all",...Array.from(new Set(C.templates.map(e=>e.metadata.category)))],[C.templates]),T=(0,n.useMemo)(()=>C.templates.filter(e=>{var t;let s=e.metadata.name.toLowerCase().includes(b.toLowerCase())||e.metadata.description.toLowerCase().includes(b.toLowerCase())||(null==(t=e.metadata.services)?void 0:t.some(e=>e.toLowerCase().includes(b.toLowerCase()))),a="all"===y||e.metadata.category===y,r="all"===w||e.metadata.source===w;return s&&a&&r}),[C.templates,b,y,w]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ty,{open:a&&"browse"===_.currentStep,onOpenChange:e=>{e||_.handleCancel()},onOpenAutoFocus:e=>e.preventDefault(),title:"Templates",description:"Browse and load pre-configured templates for your AIOStreams setup",contentClass:"max-w-5xl w-full",children:(0,r.jsx)("div",{className:"space-y-4 min-w-0 overflow-hidden",children:(0,r.jsx)(uj,{searchQuery:b,onSearchChange:v,selectedCategory:y,onCategoryChange:j,selectedSource:w,onSourceChange:N,categories:A,sources:["all","builtin","custom","external"],filteredTemplates:T,loadingTemplates:C.loadingTemplates,templateValidations:C.templateValidations,isLoading:_.isLoading,onLoadTemplate:_.handleLoadTemplate,onImportOpen:()=>R.setShowImportModal(!0),onDeleteRequest:e=>{R.setTemplateToDelete(e),R.confirmDeleteTemplate.open()},totalTemplateCount:C.templates.length,initialExpandedTemplate:c?C.templates.find(e=>e.metadata.id===c)??void 0:void 0})})}),(0,r.jsx)(ty,{open:a&&"templateInputs"===_.currentStep,onOpenChange:e=>{e||_.handleCancel()},title:"Template Options",description:"Customise this template to your needs",contentClass:"max-w-xl max-h-[120vh]",children:(0,r.jsx)("div",{className:"space-y-4",children:(0,r.jsx)(uN,{mode:g,onModeChange:f,options:_.templateInputOptions,values:_.templateInputValues,onValuesChange:_.setTemplateInputValues,trusted:(null==(s=_.pendingTemplate)||null==(t=s.metadata)?void 0:t.source)!=="external",selectedServices:_.selectedServices,onBack:_.handleBack,onNext:_.handleTemplateInputsNext})})}),(0,r.jsx)(ty,{open:a&&"selectService"===_.currentStep,onOpenChange:e=>{e||_.handleCancel()},title:"Select Services",description:"Choose which services you want to use with this template",contentClass:"max-w-xl",children:(0,r.jsx)("div",{className:"flex flex-col gap-4 overflow-hidden max-h-[calc(100svh-8rem)] md:max-h-[calc(100svh-10rem)]",children:_.processedTemplate&&(0,r.jsx)(uw,{processedTemplate:_.processedTemplate,selectedServices:_.selectedServices,onServicesChange:_.setSelectedServices,onBack:_.handleBack,onSkip:_.handleServiceSelectionSkip,onNext:_.handleServiceSelectionNext,status:p})})}),(0,r.jsx)(ty,{open:a&&"inputs"===_.currentStep,onOpenChange:e=>{e||_.handleCancel()},title:"Enter Credentials",description:"Provide your API keys and credentials for the selected services and addons",contentClass:"max-w-xl",children:(0,r.jsx)("div",{className:"flex flex-col gap-4 overflow-hidden max-h-[calc(100svh-8rem)] md:max-h-[calc(100svh-10rem)]",children:_.processedTemplate&&(0,r.jsx)(uk,{processedTemplate:_.processedTemplate,inputValues:_.inputValues,onInputValuesChange:_.setInputValues,isLoading:_.isLoading,onBack:_.handleBack,onConfirm:_.confirmLoadTemplate})})}),(0,r.jsx)(uC,{showImportModal:R.showImportModal,onImportModalChange:R.setShowImportModal,importUrl:R.importUrl,onImportUrlChange:R.setImportUrl,isImporting:R.isImporting,onImportFromUrl:R.handleImportFromUrl,onImportFromFile:R.handleImportFromFile,showImportConfirmModal:R.showImportConfirmModal,onImportConfirmModalChange:R.setShowImportConfirmModal,pendingImportTemplates:R.pendingImportTemplates,selectedPendingTemplateIndex:R.selectedPendingTemplateIndex,onSelectedIndexChange:R.setSelectedPendingTemplateIndex,showDeepLinkWarning:R.showDeepLinkWarning,onConfirmImport:R.handleConfirmImport,onCancelImport:R.handleCancelImport,status:p}),(0,r.jsx)(uu,{open:S.show,template:S.template,data:S.data,onProceed:S.onProceed,proceedLabel:S.proceedLabel,onClose:S.close}
14),(0,r.jsx)(tk,{...R.confirmDeleteTemplate})]})}function uR(e){let{href:t,external:s=!0,onClick:a,icon:n,children:l,className:i}=e;i=b("group relative flex flex-col justify-between p-4 h-32 rounded-lg bg-gray-800/60 hover:bg-gray-800/60 transition-all duration-200 hover:scale-[1.02] hover:shadow-lg border border-transparent hover:border-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:border-white",i);let o=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"text-gray-400 group-hover:text-white transition-colors",children:n}),(0,r.jsx)("span",{className:"font-semibold text-gray-400 text-sm font-bold group-hover:text-white transition-colors text-left",children:l}),(0,r.jsx)(cb.X6T,{className:"absolute bottom-4 right-4 w-4 h-4 text-gray-400 group-hover:text-white transition-colors"})]});return t?(0,r.jsx)("a",{href:t,...s?{target:"_blank",rel:"noopener noreferrer"}:{},className:i,children:o}):(0,r.jsx)("button",{onClick:a,className:i,children:o})}let uA={debrid:"bg-brand-500/20 text-brand-300 border border-brand-500/30",p2p:"bg-emerald-500/20 text-emerald-300 border border-emerald-500/30",custom:"bg-purple-500/20 text-purple-300 border border-purple-500/30"};function uT(e){let{template:t,onOpen:s}=e;return(0,r.jsx)(um,{className:"hover:border-gray-600 transition-colors duration-200 group",children:(0,r.jsxs)("button",{onClick:s,className:"text-left w-full p-4 flex flex-col focus-visible:outline-none",children:[(0,r.jsxs)("div",{className:"flex items-start justify-between gap-2 mb-2",children:[(0,r.jsx)("h4",{className:"text-sm font-semibold text-white group-hover:text-[--brand] transition-colors truncate flex-1",children:t.metadata.name}),(0,r.jsx)("span",{className:`text-[10px] font-medium px-2 py-0.5 rounded flex-shrink-0 ${uA[t.metadata.category.toLowerCase()]??"bg-blue-500/20 text-blue-300 border border-blue-500/30"}`,children:t.metadata.category})]}),(0,r.jsx)("div",{className:"overflow-hidden max-h-[4.5rem] text-xs text-gray-400 mb-1 [&_strong]:text-gray-300 [&_em]:text-gray-400 [&_a]:text-[--brand] [&_ul]:list-disc [&_ul]:pl-4 [&_li]:mb-0.5",style:{WebkitMaskImage:"linear-gradient(to bottom, black 50%, transparent 100%)",maskImage:"linear-gradient(to bottom, black 50%, transparent 100%)"},children:(0,r.jsx)(nz,{children:t.metadata.description})}),(0,r.jsxs)("div",{className:"mt-auto flex items-center justify-between pt-1",children:[(0,r.jsxs)("span",{className:"text-[10px] text-gray-500",children:["by ",t.metadata.author]}),(0,r.jsx)("span",{className:"text-[10px] text-gray-600 group-hover:text-[--brand] transition-colors",children:"View template →"})]})]})})}function uI(){return(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(ru,{className:"space-y-4 p-4 sm:p-8",children:(0,r.jsx)(uE,{})})})}function uE(){var e,t,s;let a,l,{status:i,loading:o,error:d}=e$(),c=ue(i),{nextMenu:u}=as(),[m,p]=n.useState(null),{userData:h,setUserData:g,uuid:f,setUuid:b,password:v,setPassword:y}=s4(),{mode:j,setMode:N,isFirstTime:k}=tX(),S=tw(k),C=h.addonName||(null==i||null==(e=i.settings)?void 0:e.addonName)||"AIOStreams",_=`
15AIOStreams consolidates multiple Stremio addons and debrid services - including its own suite of exclusive built-in addons - into a single, highly customisable super-addon. 
16  `,R=h.addonDescription||_,A=(null==i?void 0:i.tag)||"Unknown",T=(null==i?void 0:i.channel)??(A.startsWith("v")?"stable":"nightly"),I=tw(!1),M=tw(!1),D=tw(!1),L=tw(!1),U=tw(!1),$=tw(!1),[O,F]=n.useState([]),z=n.useRef(!1),V=n.useRef(null),[q,B]=n.useState(0),[K,H]=n.useState(null),G=null==i||null==(t=i.settings)?void 0:t.customHtml,W="u">typeof window?window.location.pathname:"",[Y,J]=n.useState(void 0),[Z,Q]=n.useState(void 0);n.useEffect(()=>{if("u"<typeof window)return;let e=new URL(window.location.href),t=e.searchParams.get("template"),s=e.searchParams.get("templateId")??void 0;t&&(J(t),Q(s),L.open(),e.searchParams.delete("template"),e.searchParams.delete("templateId"),window.history.replaceState({},"",e.toString()))},[]);let X=tN({title:"Sign Out",description:"Are you sure you want to sign out?",onConfirm:()=>{g(null),b(null),y(null)}});n.useEffect(()=>{let e=W.match(/stremio\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\/.*\/configure/);e&&p(e[1])},[W]),n.useEffect(()=>{c.loadTemplates()},[]),n.useEffect(()=>{z.current=!1},[f]),n.useEffect(()=>{f&&v&&!z.current&&0!==c.appliedTemplateUpdates.length&&(z.current=!0,F(c.appliedTemplateUpdates),$.open())},[c.appliedTemplateUpdates,f,v]);let ee=e=>{F(t=>{let s=t.filter(t=>t.template.metadata.id!==e);return 0===s.length&&$.close(),s})};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex flex-col gap-4 w-full",children:[(0,r.jsxs)("div",{className:"flex flex-col md:flex-row gap-6 md:gap-8 items-center md:items-start w-full relative",children:[(0,r.jsx)("div",{className:"hidden lg:block absolute top-0 right-0",children:(0,r.jsx)(w,{intent:"primary-outline",size:"md",iconClass:"text-2xl",leftIcon:f&&v?(0,r.jsx)(tC.eZR,{}):(0,r.jsx)(tC.XzR,{}),onClick:()=>{f&&v?X.open():D.open()},children:f&&v?"Sign Out":"Sign In"})}),(0,r.jsx)("div",{className:"flex-shrink-0 flex justify-center md:justify-start w-full md:w-auto p-2",children:(0,r.jsx)("img",{src:h.addonLogo||"/logo.png",alt:"Logo",width:128,height:128,className:"rounded-lg shadow-lg"})}),(0,r.jsxs)("div",{className:"flex flex-col gap-2 w-full min-w-0 lg:pr-36",children:[(0,r.jsxs)("div",{className:"flex flex-col md:flex-row md:items-end md:gap-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.jsx)("span",{className:"text-3xl md:text-4xl font-bold tracking-tight text-gray-100 truncate min-w-0",children:C}),(0,r.jsx)(E,{icon:(0,r.jsx)(c$.A,{className:"w-4 h-4"}),intent:"primary-subtle",onClick:M.open,className:"rounded-full flex-shrink-0",size:"sm"}),q>0&&(0,r.jsxs)("div",{className:"relative flex-shrink-0",children:[(0,r.jsxs)(to,{side:"bottom",trigger:(0,r.jsx)(E,{icon:(0,r.jsx)(cO.A,{className:"w-4 h-4"}),intent:"primary-subtle",size:"sm",className:"rounded-full",onClick:()=>{var e;return null==(e=V.current)?void 0:e.scrollIntoView({behavior:"smooth",block:"start"})}}),children:[q," update",q>1?"s":""," ","available — see What's New"]}),(0,r.jsx)("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-[--brand] pointer-events-none"})]})]}),(0,r.jsxs)("span",{className:"text-xl md:text-2xl font-semibold text-gray-400 md:mb-1",children:[A," ","nightly"===T||"dev"===T?(0,r.jsxs)("a",{href:`https://github.com/Viren070/AIOStreams/commit/${null==i?void 0:i.commit}`,target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",children:["(",null==i?void 0:i.commit,")"]}):null]})]}),(0,r.jsx)("div",{className:"text-base md:text-lg text-[--muted] font-medium mb-2",children:R})]})]}),G&&(0,r.jsx)(cr,{children:(0,r.jsx)("div",{className:"[&_a]:text-[--brand] [&_a:hover]:underline",dangerouslySetInnerHTML:{__html:G}})}),c.loadingTemplates?(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,r.jsx)(cK,{className:"h-6 w-40"}),(0,r.jsx)(cK,{className:"h-4 w-28"})]}),(0,r.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[0,1].map(e=>(0,r.jsxs)(um,{className:"p-4 flex flex-col gap-2",children:[(0,r.jsxs)("div",{className:"flex items-start justify-between gap-2 mb-1",children:[(0,r.jsx)(cK,{className:"h-4 w-3/4"}
16),(0,r.jsx)(cK,{className:"h-4 w-14 rounded flex-shrink-0"})]}),(0,r.jsx)(cK,{className:"h-3 w-full"}),(0,r.jsx)(cK,{className:"h-3 w-5/6"}),(0,r.jsx)(cK,{className:"h-3 w-2/3"}),(0,r.jsxs)("div",{className:"mt-2 flex items-center justify-between",children:[(0,r.jsx)(cK,{className:"h-3 w-16"}),(0,r.jsx)(cK,{className:"h-3 w-20"})]})]},e))})]}):c.templates.length>0?0===(l=(a=((null==i||null==(s=i.settings)?void 0:s.featuredTemplateIds)??[]).slice(0,2)).length>0?a.map(e=>c.templates.find(t=>t.metadata.id===e)).filter(e=>void 0!==e):c.templates.slice(0,2)).length?null:(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,r.jsx)("h3",{className:"text-lg font-semibold text-white",children:"Featured Templates"}),(0,r.jsxs)("button",{onClick:L.open,className:"text-sm text-[--brand] hover:underline transition-colors",children:["Browse all ",c.templates.length," →"]})]}),(0,r.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:l.map(e=>(0,r.jsx)(uT,{template:e,onOpen:()=>{H(e),L.open()}},e.metadata.id))})]}):null,(0,r.jsxs)("div",{className:"flex flex-col lg:flex-row gap-6",children:[(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsxs)(um,{className:"p-6 h-full flex flex-col gap-5",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-xl font-semibold text-white mb-1",children:"Get Started"}),(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"New here? Pick a setup mode and jump straight in, or load a template for an instant pre-configured setup."})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,r.jsx)("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Setup Mode"}),(0,r.jsx)(cH,{value:j,onChange:N,className:"w-full h-11 text-sm"})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-3 mt-auto",children:[(0,r.jsx)(w,{intent:"white",rounded:!0,leftIcon:(0,r.jsx)(da.gSK,{}),className:"w-full h-12 text-base font-semibold",onClick:()=>u(),children:f&&v?"Continue Setup":"Start Setup"}),(0,r.jsx)(w,{intent:"primary-outline",rounded:!0,className:"w-full h-12 text-base font-semibold",onClick:L.open,children:"Use a Template"}),!(f&&v)&&(0,r.jsxs)("p",{className:"text-xs text-gray-500 text-center mt-1",children:["Already have a config?"," ",(0,r.jsx)("button",{onClick:D.open,className:"text-[--brand] hover:underline",children:"Sign in"})," ","to load it."]})]})]})}),(0,r.jsx)("div",{className:"flex-[1.5]",children:(0,r.jsxs)(um,{className:"p-6 h-full flex flex-col gap-4",children:[(0,r.jsx)("h3",{className:"text-xl font-semibold text-white",children:"Resources & Support"}),(0,r.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3 flex-1",children:[(0,r.jsx)(uR,{href:"https://docs.aiostreams.viren070.me",icon:(0,r.jsx)(cF.A,{className:"w-7 h-7"}),children:"Docs"}),(0,r.jsx)(uR,{href:"https://docs.aiostreams.viren070.me/configuration/setup",icon:(0,r.jsx)(cF.A,{className:"w-7 h-7"}),children:"Setup Guide"}),(0,r.jsx)(uR,{href:"https://guides.viren070.me/stremio",icon:(0,r.jsx)(cz.A,{className:"w-7 h-7"}),children:"Stremio Guide"}),(0,r.jsx)(uR,{href:"https://discord.viren070.me",icon:(0,r.jsx)(P.fzZ,{className:"w-7 h-7"}),children:"Discord"}),(0,r.jsx)(uR,{href:"https://github.com/Viren070/AIOStreams",icon:(0,r.jsx)(nD.BR8,{className:"w-7 h-7"}),children:"GitHub"}),(0,r.jsx)(uR,{onClick:I.open,icon:(0,r.jsx)(cV.A,{className:"w-7 h-7"}),className:"bg-gradient-to-br from-red-500/20 to-pink-500/20 hover:from-red-500/30 hover:to-pink-500/30 border-red-400/30 hover:border-red-400/50",children:"Donate"})]})]})})]}),(0,r.jsx)("div",{ref:V,children:(0,r.jsx)(uM,{version:A,channel:T,onUpdatesFound:B})}),(0,r.jsx)("div",{className:"flex flex-col items-center",children:(0,r.jsxs)("div",{className:"flex flex-col items-center gap-0.5 text-xs text-gray-500",children:[(0,r.jsxs)("span",{children:["\xa9 ",new Date().getFullYear()," AIOStreams. Developed by Viren070."]}),(0,r.jsxs)("span",{children:["This beautiful UI would not be possible without"," ",(0,r.jsx)("a",{href:"https://seanime.rahim.app/",target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",children:"Seanime"})]})]})})]}),(0,r.jsx)(o9,{open:I.isOpen,onOpenChange:I.toggle}),(0,r.jsx)(uP,{open:M.isOpen,onOpenChange:M.toggle,currentName:C,currentLogo:h.addonLogo,currentDescription:h.addonDescription}),(0,r.jsx)(cG,{open:S.isOpen,onOpenChange:S.toggle}),(0,r.jsx)(o5,{open:D.isOpen,onSuccess:()=>{D.close(),x.oR.success("Signed in successfully")},onOpenChange:e=>{e||D.close()},initialUuid:m||void 0}),(0,r.jsx)(tk,{...X}),(0,r.jsx)(u_,{open:L.isOpen,onOpenChange:e=>{e?L.open():(L.close(),H(null))},deepLinkUrl:Y,deepLinkTemplateId:Z,initialExpandedTemplateId:null==K?void 0:K.metadata.id}),(0,r.jsx)(uD,{open:U.isOpen,onOpenChange:U.toggle,onNextMenu:()=>{U.close(),u()},onUseTemplate:()=>{U.close(),L.open()},nextMenuText:f&&v?"Continue Setup":"Start Fresh",nextMenuDescription:f&&v?"Continue adju
16sting your setup":"Build your configuration from scratch. Perfect if you want complete control over every setting.",useTemplateText:"Use a Template",useTemplateDescription:f&&v?"Apply a template to your existing setup":"Start with a pre-configured template. Great for getting up and running quickly with recommended settings."}),(0,r.jsx)(ty,{open:$.isOpen,onOpenChange:$.toggle,title:"Template Updates Available",contentClass:"max-w-2xl",children:(0,r.jsxs)("div",{className:"space-y-4 min-w-0",children:[(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"Templates you've applied have new versions available."}),(0,r.jsx)("div",{className:"space-y-3 max-h-[52vh] overflow-y-auto overflow-x-hidden pr-4 -mr-2",children:O.map(e=>(0,r.jsxs)("div",{className:"rounded-lg border border-gray-700 bg-gray-800/50 p-4 space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,r.jsx)("span",{className:"font-semibold text-white",children:e.template.metadata.name}),(0,r.jsxs)("span",{className:"text-xs text-gray-400 whitespace-nowrap flex-shrink-0",children:["v",e.appliedVersion," ",(0,r.jsx)("span",{className:"text-gray-600",children:"→"})," ",(0,r.jsxs)("span",{className:"text-green-400",children:["v",e.template.metadata.version]})]})]}),e.newChangelog.length>0?(0,r.jsx)("div",{className:"space-y-3",children:e.newChangelog.map(e=>(0,r.jsx)(ux,{entry:e},e.version))}):e.template.metadata.changelogUrl?(0,r.jsx)(uv,{update:e}):(0,r.jsx)("p",{className:"text-xs text-gray-500 italic",children:"No changelog provided for this update."}),(0,r.jsxs)("div",{className:"flex items-center gap-2 pt-1",children:[(0,r.jsx)(w,{intent:"primary",className:"flex-1",onClick:()=>{$.close(),H(e.template),L.open()},children:"Apply Update"}),(0,r.jsx)(w,{intent:"gray-outline",onClick:()=>{var t,s;return t=e.template.metadata.id,s=e.template.metadata.version,void(g(e=>({...e,appliedTemplates:(e.appliedTemplates??[]).map(e=>e.id===t?{...e,dismissedVersion:s}:e)})),ee(t))},children:"Skip this version"})]}),(0,r.jsx)("button",{className:"text-xs text-gray-600 hover:text-gray-400 transition-colors underline-offset-2 hover:underline",onClick:()=>{var t;return t=e.template.metadata.id,void(g(e=>({...e,appliedTemplates:(e.appliedTemplates??[]).filter(e=>e.id!==t)})),ee(t))},children:"Ignore all future updates for this template"})]},e.template.metadata.id))}),(0,r.jsxs)("div",{className:"flex items-center justify-between pt-2 border-t border-gray-700",children:[(0,r.jsx)("button",{className:"text-xs text-gray-500 hover:text-gray-300 transition-colors",onClick:()=>{g(e=>({...e,appliedTemplates:(e.appliedTemplates??[]).map(e=>{let t=O.find(t=>t.template.metadata.id===e.id);return t?{...e,dismissedVersion:t.template.metadata.version}:e})})),$.close()},children:"Dismiss all"}),(0,r.jsx)(w,{intent:"gray-outline",onClick:$.close,children:"Maybe later"})]})]})})]})}function uM(e){let{version:t,channel:s,onUpdatesFound:a}=e,[l,i]=n.useState(!0),[o,d]=n.useState(null),[c,u]=n.useState([]),[m,p]=n.useState([]),[h,x]=n.useState([]),[g,f]=n.useState(0),[v,y]=n.useState(!1),[j,N]=n.useState(!0),[k,S]=n.useState(1),[C,_]=n.useState(!1),[R,A]=n.useState(!1),T=n.useRef(null);if("dev"===s)return(0,r.jsx)(um,{className:"p-4",children:(0,r.jsxs)("p",{className:"text-sm text-gray-400",children:["This is a dev/PR build (",(0,r.jsx)("span",{className:"font-mono text-gray-300",children:t}),"). Changelog and update checks are not available."]})});let I=n.useCallback((e,t)=>{if("stable"===s){let s=e.replace("v","").split(".").map(Number),a=t.replace("v","").split(".").map(Number);for(let e=0;e<Math.max(s.length,a.length);e++){let t=s[e]||0,r=a[e]||0;if(t>r)return 1;if(t<r)return -1}return 0}{let s=e.replace("-nightly",""),a=t.replace("-nightly","");return s>a?1:s<a?-1:0}},[s]),E=n.useCallback(async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;try{let t=await fetch(`https://api.github.com/repos/viren070/aiostreams/releases?per_page=100&page=${e}`);if(!t.ok)throw Error("Failed to fetch releases");let s=await t.json(),a=t.headers.get("link"),r=a&&a.includes('rel="next"');return N(!!r),s}catch(e){throw e}},[]),M=n.useCallback((e,t)=>"stable"===t?e.filter(e=>e.tag_name.startsWith("v")&&!e.tag_name.includes("nightly")):e.filter(e=>e.tag_name.endsWith("-nightly")),[]);n.useEffect(()=>{if(!t||"unknown"===t.toLowerCase()){d("No version available."),i(!1);return}d(null),i(!0),u([]),p([]),x([]),f(0),S(1),N(!0),y(!1),E(1).then(e=>{let a=M(e,s);a.sort((e,t)=>
16new Date(t.published_at).getTime()-new Date(e.published_at).getTime()),u(a);let r=[],n=[];a.forEach(e=>{I(e.tag_name,t)>0?r.push(e):n.push(e)}),x(r),p(n),f(Math.min(5,n.length))}).catch(()=>d("Failed to load changelogs.")).finally(()=>i(!1))},[t,s,E,M,I]),n.useEffect(()=>{null==a||a(h.length)},[h.length,a]);let P=n.useCallback(async()=>{if(j&&!C){_(!0);try{let e=k+1,a=await E(e),r=M(a,s);if(r.length>0){r.sort((e,t)=>new Date(t.published_at).getTime()-new Date(e.published_at).getTime()),u(e=>[...e,...r]);let s=[],a=[];r.forEach(e=>{I(e.tag_name,t)>0?s.push(e):a.push(e)}),x(e=>[...e,...s]),p(e=>[...e,...a]),S(e)}}catch(e){console.error("Failed to fetch more releases:",e)}finally{_(!1)}}},[j,C,k,E,s,M,I,t]),D=n.useMemo(()=>v?[...h,...m]:m,[v,h,m]);n.useEffect(()=>{let e=()=>{let e=T.current;if(!e)return;let{scrollTop:t,scrollHeight:s,clientHeight:a}=e,r=D.length>g||j&&!C;A(s-t-a<50&&r&&!l)},t=T.current;if(t)return t.addEventListener("scroll",e),e(),()=>t.removeEventListener("scroll",e)},[g,D.length,j,C,l]);let L=D.length>g||j&&!C,U=n.useCallback(e=>I(e,t)>0,[I,t]);return(0,r.jsxs)(um,{className:"p-6 flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("h3",{className:"text-xl font-semibold text-white",children:"What's New?"}),h.length>0&&(0,r.jsxs)("span",{className:"text-xs font-medium text-[--brand]",children:[h.length," update",h.length>1?"s":""," available"]})]}),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("div",{ref:T,className:"max-h-[500px] overflow-y-auto pr-4 -mr-2",children:l?(0,r.jsx)("div",{className:"space-y-3",children:[void 0,void 0].map((e,t)=>(0,r.jsx)(cK,{className:"h-24 w-full"},t))}):o?(0,r.jsx)(nU,{intent:"alert",title:"Error",description:o}):0===D.length?(0,r.jsx)(nU,{intent:"info",title:"No changelogs found",description:`No ${s} changelogs available.`}):(0,r.jsxs)("div",{className:"space-y-3",children:[h.length>0&&!v&&(0,r.jsx)("div",{className:"flex justify-center pb-1",children:(0,r.jsxs)(w,{intent:"primary-outline",size:"sm",onClick:()=>{y(!0),f(Math.min(5,h.length+m.length))},children:["Show ",h.length," available update",h.length>1?"s":""]})}),D.slice(0,g).map(e=>(0,r.jsxs)(X,{className:b("border bg-gray-800/60 border-gray-700/50",U(e.tag_name)&&"border-[--brand]/40"),children:[(0,r.jsx)(ee,{className:"pb-2",children:(0,r.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,r.jsx)("span",{className:b("text-sm font-semibold",U(e.tag_name)?"text-[--brand]":"text-gray-200"),children:e.tag_name}),(0,r.jsx)("span",{className:"text-[10px] font-medium px-2.5 py-0.5 rounded-full bg-gray-700/60 text-gray-400 border border-gray-600/40 flex-shrink-0",children:new Date(e.published_at).toLocaleDateString()})]})}),(0,r.jsx)(ea,{className:"prose prose-invert prose-sm max-w-none min-w-0 [&_p]:text-sm [&_ul]:text-sm [&_li]:text-sm [&_h1]:text-xl [&_h2]:text-lg [&_h3]:text-base [&_pre]:overflow-x-auto [&_pre]:max-w-full [&_*]:break-words",children:(0,r.jsx)(cq.oz,{children:e.body?e.body.replace(e.tag_name,""):"No changelog provided."})}),(0,r.jsx)(er,{children:(0,r.jsxs)("a",{href:e.html_url,target:"_blank",rel:"noopener noreferrer",className:"text-gray-500 hover:text-white flex items-center justify-between w-full text-xs transition-colors",children:[(0,r.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,r.jsx)(cb.hL4,{className:"w-3.5 h-3.5"}),"View on GitHub"]}),(0,r.jsx)(cb.X6T,{className:"w-3 h-3"})]})})]},e.id||e.tag_name))]})}),R&&L&&(0,r.jsx)("div",{className:"absolute bottom-0 left-0 right-0 pointer-events-none",style:{height:"80px",background:"linear-gradient(to top, rgba(0,0,0,0.85) 0%, transparent 100%)",opacity:+!!R,transition:"opacity 0.3s ease-in-out"},children:(0,r.jsx)("div",{className:"h-full flex items-end justify-center pb-3 pointer-events-auto",children:(0,r.jsxs)("button",{onClick:()=>{D.length>g?(f(e=>Math.min(e+5,D.length)),D.length<=g+5&&j&&P()):j&&!C&&P()},disabled:C,className:"flex flex-col items-center gap-1 group disabled:opacity-50",children:[(0,r.jsx)("span",{className:"text-xs text-white/60 group-hover:text-white transition-colors",children:C?"Loading...":D.length>g?`Load ${Math.min(5,D.length-g)} more`:"Load more releases"}),C?(0,r.jsx)("div",{className:"w-4 h-4 border-2 border-white/60 border-t-transparent roun
16ded-full animate-spin"}):(0,r.jsx)("svg",{className:"w-4 h-4 text-white/50 group-hover:text-white transition-colors",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 14l-7 7m0 0l-7-7m7 7V3"})})]})})})]})]})}function uP(e){let{open:t,onOpenChange:s,currentName:a,currentLogo:l,currentDescription:i}=e,{userData:o,setUserData:d}=s4(),[c,u]=(0,n.useState)(a),[m,p]=(0,n.useState)(l),[h,g]=(0,n.useState)(i);return(0,n.useEffect)(()=>{u(a),p(l),g(i)},[a,l,i]),(0,r.jsx)(ty,{open:t,onOpenChange:s,title:"Customize Addon",children:(0,r.jsx)("form",{onSubmit:e=>{(e.preventDefault(),c.trim())?(d(e=>({...e,addonName:c.trim(),addonLogo:null==m?void 0:m.trim(),addonDescription:(null==h?void 0:h.trim())||void 0})),x.oR.success("Customization saved"),s(!1)):x.oR.error("Name cannot be empty")},children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(W,{label:"Addon Name",value:c,onValueChange:u,placeholder:"Enter addon name"}),(0,r.jsx)("p",{className:"text-xs text-[--muted]",children:"This name will be displayed in Stremio"})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(W,{label:"Logo URL",value:m,onValueChange:e=>{p(e.trim()||void 0)},placeholder:"Enter logo URL",type:"url"}),(0,r.jsx)("p",{className:"text-xs text-[--muted]",children:"Enter a valid URL for your addon's logo image. Leave blank for default logo."})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(np,{label:"Addon Description",value:h,onValueChange:g,placeholder:"Enter addon description",rows:3}),(0,r.jsx)("p",{className:"text-xs text-[--muted]",children:"This description will be displayed in Stremio"})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 mt-2",children:[(0,r.jsx)(w,{intent:"primary-outline",onClick:()=>s(!1),children:"Cancel"}),(0,r.jsx)(w,{type:"submit",intent:"primary",children:"Save Changes"})]})]})})})}function uD(e){let{open:t,onOpenChange:s,onNextMenu:a,onUseTemplate:n,nextMenuText:l,nextMenuDescription:i,useTemplateText:o,useTemplateDescription:d}=e;return(0,r.jsx)(ty,{open:t,onOpenChange:s,title:"Get Started",description:"Choose how you'd like to set up AIOStreams",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("button",{onClick:a,className:"w-full p-6 rounded-lg border-2 border-gray-700 bg-gray-800/50 hover:border-purple-500 hover:bg-purple-500/10 transition-all duration-200 text-left group",children:(0,r.jsxs)("div",{className:"flex items-start gap-4",children:[(0,r.jsx)("div",{className:"flex-shrink-0 w-12 h-12 rounded-full bg-purple-500/20 flex items-center justify-center group-hover:bg-purple-500/30 transition-colors",children:(0,r.jsx)(da.gSK,{className:"w-5 h-5 text-purple-400"})}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("h3",{className:"text-lg font-semibold text-white mb-2",children:l}),(0,r.jsx)("p",{className:"text-sm text-gray-400",children:i})]})]})}),(0,r.jsx)("button",{onClick:n,className:"w-full p-6 rounded-lg border-2 border-gray-700 bg-gray-800/50 hover:border-blue-500 hover:bg-blue-500/10 transition-all duration-200 text-left group",children:(0,r.jsxs)("div",{className:"flex items-start gap-4",children:[(0,r.jsx)("div",{className:"flex-shrink-0 w-12 h-12 rounded-full bg-blue-500/20 flex items-center justify-center group-hover:bg-blue-500/30 transition-colors",children:(0,r.jsx)(cx.A,{className:"w-5 h-5 text-blue-400"})}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("h3",{className:"text-lg font-semibold text-white mb-2",children:o}),(0,r.jsx)("p",{className:"text-sm text-gray-400",children:d})]})]})})]})})}var uL=s(4298),uU=s(9733),u$=s(858);let uO={root:(0,h.F)(["UI-Slider__root","relative flex w-full touch-none select-none items-center"],{variants:{size:{sm:"h-4 w-full",md:"h-5 w-full",lg:"h-6 w-full"}},defaultVariants:{size:"md"}}),track:(0,h.F)(["UI-Slider__track","relative h-1.5 w-full grow overflow-hidden rounded-full","bg-gray-200 dark:bg-gray-700","data-[disabled=true]:opacity-50"],{variants:{size:{sm:"h-1 w-full",md:"h-1.5 w-full",lg:"h-2 w-full"},defaultVariants:{size:"md"}}}),range:(0,h.F)(["UI-Slider__range","absolute h-full bg-brand","data-[disabled=true]:opacity-50"]),thumb:(0,h.F)(["UI-Slider__thumb","block h-4 w-4 roun
16ded-full","border border-brand/50 bg-white shadow transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[--ring] focus-visible:ring-offset-1","disabled:pointer-events-none disabled:opacity-50","data-[disabled=true]:opacity-50"],{variants:{size:{sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6"}},defaultVariants:{size:"md"}}),mark:(0,h.F)(["UI-Slider__mark","absolute top-6 -translate-x-1/2 text-xs text-gray-500"]),markIndicator:(0,h.F)(["UI-Slider__markIndicator","absolute top-[7px] h-1 w-0.5 -translate-x-1/2 bg-gray-300 dark:bg-gray-600"]),label:(0,h.F)(["UI-Slider__label","relative font-normal","data-[disabled=true]:text-gray-300 cursor-pointer user-select-none select-none"])},uF=n.forwardRef((e,t)=>{let[{value:s,className:a,onValueChange:l,defaultValue:i,trackClass:o,rangeClass:d,thumbClass:c,markClass:u,markIndicatorClass:m,labelClass:p,showMarks:h,marks:x,size:g,...f},{label:v,moreHelp:y,...j}]=O(e,n.useId()),w=n.useRef(!0),[N,k]=n.useState(s??i??[0]),S=n.useCallback(e=>{k(e),null==l||l(e)},[]);n.useEffect(()=>{i&&w.current||k(s??[0]),w.current=!1},[s]);let C=n.useMemo(()=>{if(!h||x)return[];let e=f.step||1,t=f.min||0;return Array.from({length:Math.floor(((f.max||100)-t)/e)+1},(s,a)=>({value:t+a*e,label:(t+a*e).toString()}))},[h,x,f.step,f.min,f.max]),_=x||C;return(0,r.jsx)(F,{...j,id:j.id,children:(0,r.jsxs)("div",{className:"flex flex-col gap-1",children:[v&&(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("label",{className:b(uO.label(),p),htmlFor:j.id,"data-disabled":j.disabled,children:v}),y&&(0,r.jsx)(U,{className:"text-sm",trigger:(0,r.jsx)(P.ExT,{className:"transition-opacity opacity-45 hover:opacity-90"}),children:y})]}),(0,r.jsxs)(u$.bL,{ref:a7([t]),className:b(uO.root({size:g}),a),value:N,onValueChange:S,disabled:j.disabled||j.readonly,"data-disabled":j.disabled,"data-readonly":j.readonly,"data-error":!!j.error,...f,children:[(0,r.jsx)(u$.CC,{className:b(uO.track(),o),children:(0,r.jsx)(u$.Q6,{className:b(uO.range(),d)})}),_.map(e=>{let{value:t,label:s}=e;return(0,r.jsxs)(n.Fragment,{children:[(0,r.jsx)("div",{className:b(uO.markIndicator(),m),style:{left:`${(t-(f.min||0))/((f.max||100)-(f.min||0))*100}%`}}),(0,r.jsx)("div",{className:b(uO.mark(),u),style:{left:`${(t-(f.min||0))/((f.max||100)-(f.min||0))*100}%`},children:s})]},t)}),N.map((e,t)=>(0,r.jsx)(u$.zi,{className:b(uO.thumb({size:g}),c)},t))]})]})})});function uz(e){let{filterName:t,preferredOptions:s,requiredOptions:a,excludedOptions:l,includedOptions:i,onPreferredChange:o,onRequiredChange:d,onExcludedChange:c,onIncludedChange:u,options:m}=e,[p,h]=(0,n.useState)(a),[x,g]=(0,n.useState)(l),[f,b]=(0,n.useState)(s),[v,y]=(0,n.useState)(i),[j,w]=(0,n.useState)(!1),{mode:N}=tX(),k=e=>e.filter(e=>m.some(t=>t.value===e));(0,n.useEffect)(()=>{h(k(a)),g(k(l)),b(k(s)),y(k(i))},[a,l,s,i]);let S=(0,dB.FR)((0,dB.MS)(dB.AN),(0,dB.MS)(dB.IG,{activationConstraint:{delay:150,tolerance:8}}));return(0,n.useEffect)(()=>{function e(e){j&&e.preventDefault()}function t(){w(!1)}return j?(document.body.addEventListener("touchmove",e,{passive:!1}),document.addEventListener("pointerup",t),document.addEventListener("touchend",t)):document.body.removeEventListener("touchmove",e),()=>{document.body.removeEventListener("touchmove",e),document.removeEventListener("pointerup",t),document.removeEventListener("touchend",t)}},[j]),(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsx)(cr,{title:`${t} Selection`,description:`Configure required, excluded, and preferred ${t.toLowerCase()}`,children:(0,r.jsxs)("div",{className:"space-y-4",children:["pro"===N&&(0,r.jsx)(ne,{label:`Required ${t}`,help:`Any stream that is not one of the required ${t.toLowerCase()} will be excluded.`,value:p,onValueChange:e=>{h(e),d(e)},options:m.map(e=>({value:e.value,label:e.name,textValue:e.name})),multiple:!0,emptyMessage:`No ${t.toLowerCase()} available`,placeholder:`Select required ${t.toLowerCase()}...`}),(0,r.jsx)("div",{children:(0,r.jsx)(ne,{label:`Excluded ${t}`,value:x,help:`Any stream that is one of the excluded ${t.toLowerCase()} will be excluded.`,onValueChange:e=>{g(e),c(e)},options:m.map(e=>({value:e.value,label:e.name,textValue:e.name})),multiple:!0,emptyMessage:`No ${t.toLowerCase()} available`,placeholder:`Select excluded ${t.toLowerCase()}...`})}),"pro"===N&&(0,r.jsx)("div",{children:(0,r.jsx)(ne,{label:`Included ${t}`,value:v,help:`Included ${t.toLowerCase()} will be included regardless of ANY other exclude/required filters, not just for ${t.toLowerCase()}`,onValueChange:e=>{y(e),u(e)},options:m.map(e=>({value:e.value,label:e.name,textValue:e.name})),multiple:!0,emptyMessage:`No ${t.toLowerCase()} available`,placeholder:`Select included ${t.toLowerCase()}...`})}),(0,r.jsx)("div",{children:(0,r.jsx)(ne,{label:`Preferred ${t}`,help:`Set preferred ${t.toLowerCase()} and control its order below. This is used if the relevant sort criterion is enabled in the Sorting section.`,value:f,onValueChange:e=>{b(e),o(e)},options:m.map(e=>({value:e.value,label:e.name,textValue:e.name})),multiple:!0,emptyMessage:`No ${t.toLowerCase()} available`,placeholder:`Select preferred ${t.toLowerCase()}...`})})]})}),f.length>0&&(0,r.jsx)(cr,{title:"Preference Order",description:`Drag to reorder your preferred ${t.toLowerCase()}`,children:(0,r.jsx)(dB.Mp,{modifiers:[dz.FN],onDragEnd:function(e){let{active:t,over:s}=e;
16if(s){if(t.id!==s.id){let e=f.indexOf(t.id),a=f.indexOf(s.id),r=(0,dV.be)(f,e,a);b(r),o(r)}w(!1)}},onDragStart:function(e){w(!0)},sensors:S,children:(0,r.jsx)(dV.gB,{items:f,strategy:dV._G,children:(0,r.jsx)("div",{className:"space-y-2",children:f.map(e=>{var t;return(0,r.jsx)(uV,{id:e,name:(null==(t=m.find(t=>t.value===e))?void 0:t.name)||e,onDelete:()=>{let t=f.filter(t=>t!==e);b(t),o(t)}},e)})})})})})]})}function uV(e){let{id:t,name:s,onDelete:a}=e,{attributes:n,listeners:l,setNodeRef:i,transform:o,transition:d,isDragging:c}=(0,dV.gl)({id:t}),u={transform:dq.Ks.Transform.toString(o),transition:d,opacity:c?.5:1};return(0,r.jsx)("div",{ref:i,style:u,children:(0,r.jsxs)("div",{className:"px-2.5 py-2 bg-[var(--background)] rounded-[--radius-md] border flex gap-3 relative",children:[(0,r.jsx)("div",{className:"rounded-full w-6 h-auto bg-[--muted] md:bg-[--subtle] md:hover:bg-[--subtle-highlight] cursor-move",...n,...l}),(0,r.jsx)("div",{className:"flex-1 flex flex-col justify-center min-w-0",children:(0,r.jsx)("span",{className:"font-mono text-base truncate",children:s})}),(0,r.jsx)("div",{className:"flex-shrink-0 ml-auto",children:(0,r.jsx)(E,{size:"sm",rounded:!0,icon:(0,r.jsx)(cb.H8h,{}),intent:"alert-subtle",onClick:e=>{e.preventDefault(),e.stopPropagation(),a()}})})]})})}function uq(e){let{open:t,onOpenChange:s,onImport:a}=e,[l,i]=(0,n.useState)(!1),o=(0,n.useRef)(null),d=tw(!1),[c,u]=(0,n.use
16State)(""),m=async()=>{if(!c)return void x.oR.error("Please enter a URL");i(!0);try{let e=await fetch(c);if(!e.ok)throw Error("Failed to fetch URL");let t=await e.json();a(t),d.close(),s(!1)}catch(e){console.error("Error importing from URL:",e),x.oR.error("Failed to import from URL")}finally{i(!1)}};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ty,{open:t,onOpenChange:s,title:"Import",children:(0,r.jsx)("div",{className:"space-y-4",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)("input",{type:"file",ref:o,onChange:e=>{var t;let r=null==(t=e.target.files)?void 0:t[0];if(!r)return;let n=new FileReader;n.onload=e=>{try{var t;let r=null==(t=e.target)?void 0:t.result,n=JSON.parse(r);a(n),s(!1)}catch(e){console.error("Error importing file:",e),x.oR.error("Failed to parse JSON file")}},n.readAsText(r),o.current&&(o.current.value="")},accept:".json",className:"hidden"}),(0,r.jsx)(w,{intent:"primary",onClick:()=>{var e;return null==(e=o.current)?void 0:e.click()},className:"w-full",children:"Import from File"}),(0,r.jsx)(w,{intent:"primary",onClick:d.open,className:"w-full",children:"Import from URL"})]})})}),(0,r.jsx)(ty,{open:d.isOpen,onOpenChange:d.close,title:"Import from URL",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(W,{label:"URL",value:c,onValueChange:u,placeholder:"Enter URL to JSON file"}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(w,{intent:"primary-outline",onClick:d.close,children:"Cancel"}),(0,r.jsx)(w,{intent:"primary",onClick:m,loading:l,children:"Import"})]})]})})]})}function uB(e,t){return e.length===t.length&&e.every((e,s)=>e===t[s])}function uK(e){let{renderType:t,syncMode:s,syncedValues:a,isLoading:l,fetchError:i}=e,{userData:o,setUserData:d}=s4(),{isOpen:c,open:u,close:m}=tw(!1),[p,h]=(0,n.useState)(null),[g,f]=(0,n.useState)(null),v="sel"===s,y=v?"selOverrides":"regexOverrides",j=v?"Expression":"Pattern";return l?(0,r.jsxs)("div",{className:"px-3 pb-2 text-xs text-[--muted] animate-pulse",children:["Loading ",j.toLowerCase(),"s..."]}):i&&0===a.length?(0,r.jsx)("div",{className:"px-3 pb-3",children:(0,r.jsxs)("div",{className:"rounded border border-red-500/30 bg-red-500/5 p-2 text-xs text-red-400",children:[(0,r.jsx)("span",{className:"font-medium",children:"Error: "}),i]})}):0===a.length?null:(0,r.jsxs)("div",{className:"px-3 pb-3 space-y-2",children:[i&&(0,r.jsxs)("div",{className:"rounded border border-yellow-500/30 bg-yellow-500/5 p-2 text-xs text-yellow-400",children:[(0,r.jsx)("span",{className:"font-medium",children:"Warning: "}),i]}),a.map((e,s)=>{let a=e.pattern??e.expression??"",n=o[y]||[],l=v?function(e){let t,s=!(arguments.length>1)||void 0===arguments[1]||arguments[1],a=/\/\*\s*(.*?)\s*\*\//g,r=[];for(;null!==(t=a.exec(e));){let e=t[1];e.startsWith("#")?s||r.push(e.slice(1).trim()):r.push(e)}return r.length>0?r:void 0}(a,!1):void 0,i=t=>v?t.expression===a||!!t.exprNames&&!!l&&uB(t.exprNames,l):t.pattern===a||e.name&&t.originalName===e.name,c=n.find(i),m=c?c.disabled:!1===e.enabled,p=v?(null==l?void 0:l.join(", "))??"":(null==c?void 0:c.name)??e.name??"",g=v?!!c&&!c.disabled&&void 0!==c.score:!!c&&!c.disabled,w=(null==c?void 0:c.score)!==void 0?c.score:e.score??0,N=t=>{d(s=>{let r=[...s[y]||[]];if(t){let t=r.findIndex(i);if(t>=0){let a=r[t],n=void 0!==a.score&&a.score!==e.score;return!v&&void 0!==a.name&&a.name!==e.name||n?r[t]={...a,disabled:!1}:!1===e.enabled?r[t]={...a,disabled:!1}:r.splice(t,1),{...s,[y]:r}}if(!1===e.enabled){let t=v?{expression:a,exprNames:l,disabled:!1}:{pattern:a,originalName:e.name,disabled:!1};return r.push(t),{...s,[y]:r}}return s}let n=r.findIndex(i),o=n>=0?r[n]:null,d=v?{expression:a,score:null==o?void 0:o.score,exprNames:l,disabled:!0}:{pattern:a,name:null==o?void 0:o.name,score:null==o?void 0:o.score,originalName:e.name,disabled:!0};return n>=0?r[n]=d:r.push(d),{...s,[y]:r}}),x.oR.success(t?`${j} enabled`:`${j} disabled`)},k=()=>{d(e=>({...e,[y]:(e[y]||[]).filter(e=>!i(e))})),x.oR.info("Override removed")};return(0,r.jsxs)("div",{className:b("p-2 rounded border",m?"opacity-50 border-gray-700/50 bg-gray-900/30":"border-gray-700 bg-gray-900/60",g&&!m&&"border-primary/40"),children:["simple"===t&&(0,r.jsxs)("div",{className:"relative flex gap-2 items-start pl-[calc(24px+0.5rem)]",children:[(0,r.jsx)("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 min-w-[24px] flex justify-center",children:(0,r.jsx)(r6,{value:!m,size:"lg",onValueChange:e=>N(!0===e)})}),(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(W,{value:a,label:`${j} (Synced)`,disabled:!0,size:"sm"})})]}),"nameable"===t&&(0,r.jsxs)("div",{className:"relative flex gap-2 items-start pl-[calc(24px+0.5rem)]",children:[(0,r.jsx)("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 min-w-[24px] flex justify-center",children:(0,r.jsx)(r6,{value:!m,size:"lg",onValueChange:e=>N(!0===e)})}),(0,r.jsx)("div",{className:"flex-none w-1/3",children:(0,r.jsx)(W,{value:p,label:!v&&g?"Name (Overridden)":"Name (Synced)",disabled:!0,size:"sm",className:b(m&&"line-through text-gray-500")})}),(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(W,{value:a,label:`${j} (Synced)`,disabled:!0,size:"sm",className:b(m&&"line-through text-gray-500")})}),(0,r.jsxs)("div",{className:"pb-0.5 flex gap-1 flex-shrink-0 self-end",children:[g&&(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"sm",rounded:!0,icon:(0,r.jsx)(cb.
16EEI,{className:"text-xs"}),intent:"alert-subtle",onClick:k,className:"h-[38px] w-[38px] border border-red-500/20 hover:border-red-500/50 transition-colors shadow-sm"}),children:"Reset Override"}),!v&&(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"sm",rounded:!0,icon:(0,r.jsx)(cb.uO9,{className:"text-xs"}),intent:g?"primary":"primary-subtle",onClick:()=>{h({pattern:a,name:(null==c?void 0:c.name)??e.name??"",originalName:e.name}),u()},className:"h-[38px] w-[38px] border border-primary/20 hover:border-primary/50 transition-colors shadow-sm"}),children:"Override"})]})]}),"ranked"===t&&(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 min-w-[24px] flex justify-center",children:(0,r.jsx)(r6,{value:!m,size:"lg",onValueChange:e=>N(!0===e)})}),(0,r.jsxs)("div",{className:"flex gap-2 items-start pl-[calc(24px+0.5rem)]",children:[(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(W,{value:a,label:`${j} (Synced)`,disabled:!0,size:"sm",className:b(m&&"line-through text-gray-500")})}),(0,r.jsxs)("div",{className:"pb-0.5 flex gap-1 flex-shrink-0 self-end",children:[g&&(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{rounded:!0,size:"sm",icon:(0,r.jsx)(cb.EEI,{className:"text-xs"}),intent:"alert-subtle",onClick:k}),children:"Reset Override"}),(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"sm",rounded:!0,icon:(0,r.jsx)(cb.uO9,{className:"text-xs"}),intent:g?"primary":"primary-subtle",onClick:()=>{v?f({expression:a,score:w,exprNames:l}):h({pattern:a,name:(null==c?void 0:c.name)??e.name??"",score:w,originalName:e.name}),u()}}),children:"Override"})]})]}),(0,r.jsxs)("div",{className:"flex gap-2 pl-[calc(24px+0.5rem)] mt-2",children:[(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(W,{value:p,label:`Name${l&&l.length>1?"s":""} (Synced)`,disabled:!0,size:"sm",className:b(m&&"line-through text-gray-500")})}),(0,r.jsx)("div",{className:"w-24",children:(0,r.jsx)(nn,{value:w,label:g?"Score (Ovr)":"Score",disabled:!0,size:"sm"})})]})]})]},s)}),(0,r.jsx)(ty,{open:c&&null!==p,onOpenChange:e=>{e||(h(null),m())},title:"Override",children:(0,r.jsxs)("div",{className:"space-y-4 py-2",children:[(0,r.jsxs)("p",{className:"text-xs text-[--muted] break-all",children:[j,":"," ",(0,r.jsx)("code",{className:"text-[--primary]",children:null==p?void 0:p.pattern})]}),("nameable"===t||"ranked"===t)&&(0,r.jsx)(W,{label:"Custom Name",value:(null==p?void 0:p.name)||"",onValueChange:e=>h(t=>t?{...t,name:e}:null)}),"ranked"===t&&(0,r.jsx)(nn,{label:"Custom Score",value:(null==p?void 0:p.score)||0,min:-1e6,max:1e6,step:50,onValueChange:e=>h(t=>t?{...t,score:e}:null)}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[(0,r.jsx)(w,{intent:"primary-outline",onClick:()=>{h(null),m()},children:"Cancel"}),(0,r.jsx)(w,{onClick:()=>{p&&(d(e=>{let t=[...e[y]||[]],s=t.findIndex(e=>e.pattern===p.pattern||p.originalName&&e.originalName===p.originalName),a=s>=0?t[s]:void 0,r={pattern:p.pattern,name:p.name||void 0,score:p.score||0,originalName:p.originalName,disabled:p.disabled??(null==a?void 0:a.disabled)};return s>=0?t[s]=r:t.push(r),{...e,[y]:t}}),h(null),m(),x.oR.success("Override saved"))},children:"Save Override"})]})]})}),(0,r.jsx)(ty,{open:c&&null!==g,onOpenChange:e=>{e||(f(null),m())},title:"Score Override",children:(0,r.jsxs)("div",{className:"space-y-4 py-2",children:[(0,r.jsxs)("p",{className:"text-xs text-[--muted] break-all",children:["Expression:"," ",(0,r.jsx)("code",{className:"text-[--primary]",children:null==g?void 0:g.expression})]}),(0,r.jsx)(nn,{label:"Custom Score",value:(null==g?void 0:g.score)||0,min:-1e6,max:1e6,step:50,onValueChange:e=>f(t=>t?{...t,score:e}:null)}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[(0,r.jsx)(w,{intent:"primary-outline",onClick:()=>{f(null),m()},children:"Cancel"}),(0,r.jsx)(w,{onClick:()=>{g&&(d(e=>{let t=[...e[y]||[]],s=t.findIndex(e=>e.expression===g.expression||!!e.exprNames&&!!g.exprNames&&uB(e.exprNames,g.exprNames)),a=s>=0?t[s]:void 0,r={expression:g.expression,score:g.score||0,exprNames:g.exprNames,disabled:g.disabled??(null==a?void 0:a.disabled)};return s>=0?t[s]=r:t.push(r),{...e,[y]:t}}),f(null),m(),x.oR.success("Score override saved"))},children:"Save Override"})]})]})})]})}function uH(e){var t;let{syncConfig:s,renderType:a="simple"}=e,{status:l}=e$(),{userData:i,password:o}
16=s4(),[d,c]=(0,n.useState)(""),[u,m]=(0,n.useState)({}),p=(null==s?void 0:s.syncMode)??"regex",h="sel"===p?"expressions":"patterns";if((0,n.useEffect)(()=>{if(!s)return;let{urls:e}=s;if(0===e.length)return;let t=new AbortController,a=i.uuid&&o?{uuid:i.uuid,password:o}:void 0;for(let s of(m(t=>{let s={...t};for(let r of e){var a;s[r]={values:(null==(a=t[r])?void 0:a.values)??[],isLoading:!0,error:null}}return s}),e))("sel"===p?eS([s],a).then(e=>{var t;let a=null==(t=e.errors)?void 0:t.find(e=>e.url===s);return{values:(e.expressions||[]).map(e=>({expression:e.expression,pattern:e.expression,name:e.name,score:e.score,enabled:e.enabled})),error:(null==a?void 0:a.error)??null}}):ek([s],a).then(e=>{var t;let a=null==(t=e.errors)?void 0:t.find(e=>e.url===s);return{values:(e.patterns||[]).map(e=>({pattern:e.pattern,name:e.name,score:e.score})),error:(null==a?void 0:a.error)??null}})).then(e=>{let{values:a,error:r}=e;t.signal.aborted||m(e=>({...e,[s]:{values:a,isLoading:!1,error:r}}))}).catch(e=>{t.signal.aborted||m(t=>({...t,[s]:{values:[],isLoading:!1,error:e instanceof Error?e.message:"Failed to fetch from URL"}}))});return()=>t.abort()},[null==s||null==(t=s.urls)?void 0:t.join(","),i.uuid,o,p]),!s)return null;let{urls:g,onUrlsChange:f,trusted:b}=s,v=e=>{for(let a of g.filter(t=>!e.includes(t))){var t;null==(t=s.onRemovePlaceholder)||t.call(s,a)}f(e)},y=()=>{(e=>{var t,s,a,r,n,i;let o=(null==l||null==(s=l.settings)||null==(t=s.regexAccess)?void 0:t.urls)||[];if(!e)return!1;try{new URL(e)}catch{return x.oR.error("Invalid URL format"),!1}if(g.includes(e))return x.oR.error("URL is already added"),!1;if("sel"===p){let t=(null==l||null==(r=l.settings)||null==(a=r.selSyncAccess)?void 0:a.level)??"all";return!!("all"===t||"trusted"===t&&b)||!!((null==l||null==(i=l.settings)||null==(n=i.selSyncAccess)?void 0:n.trustedUrls)||[]).includes(e)||(x.oR.error("This URL is not in the allowed list. Contact the instance owner to whitelist it."),!1)}return!!((null==l?void 0:l.settings.regexAccess.level)==="all"||(null==l?void 0:l.settings.regexAccess.level)==="trusted"&&b)||!!o.includes(e)||(x.oR.error("URL is not in the allowed list"),!1)})(d)&&(v([...g,d]),c(""))};return(0,r.jsxs)("div",{className:"mt-4 border-t border-gray-800 pt-4 space-y-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("h5",{className:"text-sm font-medium",children:["Synced URLs",g.length>0&&(0,r.jsxs)("span",{className:"ml-1.5 text-xs text-[--muted] font-normal",children:["(",g.length,")"]})]}),(0,r.jsxs)("p",{className:"text-xs text-[--muted]",children:["Automatically fetch and sync ",h," from URLs"]})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[g.length>0&&(0,r.jsx)("div",{className:"rounded-md border border-[--brand]/20 bg-[--brand]/5 divide-y divide-[--brand]/10",children:g.map(e=>{var t,n;let l=u[e];return(0,r.jsx)("div",{"data-synced-url":e,children:(0,r.jsx)(ts,{type:"single",collapsible:!0,children:(0,r.jsxs)(ta,{value:"items",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 p-2 px-3 text-sm",children:[(0,r.jsx)(tr,{children:(0,r.jsx)("button",{type:"button",className:"group flex items-center",children:(0,r.jsx)(cb.Vr3,{className:"text-[10px] text-[--muted] transition-transform duration-200 group-data-[state=open]:rotate-180"})})}),(0,r.jsx)("span",{className:"flex-1 break-all font-mono text-xs text-[--muted]",children:e}),s.onInsertPlaceholder&&(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"sm",rounded:!0,icon:(0,r.jsx)(cb.jHd,{}),intent:(null==(t=s.hasPlaceholder)?void 0:t.call(s,e))?"primary":"primary-subtle",onClick:()=>{var t,a;(null==(t=s.hasPlaceholder)?void 0:t.call(s,e))?null==(a=s.onRemovePlaceholder)||a.call(s,e):s.onInsertPlaceholder(e)}}),children:(null==(n=s.hasPlaceholder)?void 0:n.call(s,e))?"Remove from inline":"Place inline"}),(0,r.jsx)(E,{size:"sm",rounded:!0,icon:(0,r.jsx)(cb.H8h,{}),intent:"alert-subtle",onClick:()=>v(g.filter(t=>t!==e))})]}),(0,r.jsx)(tn,{children:(0,r.jsx)(uK,{renderType:a,syncMode:p,syncedValues:(null==l?void 0:l.values)??[],isLoading:(null==l?void 0:l.isLoading)??!0,fetchError:(null==l?void 0:l.error)??null})})]})})},e)})}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(W,{value:d,placeholder:`https://example.com/${h}.json`,onValueChange:c,onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),y())}})}),(0,r.jsx)(E,{onClick:y,disabled:!d,icon:(0,r.jsx)(cb.OiG,{}),rounded:!0,intent:"primary-subtle"})]})]})]})}function uG(e){return e.charAt(0).toLowerCase()+e.slice(1).replace(/\s+/g,"")}uF.displayName="Slider";let uW="flex items-center justify-end gap-2 md:contents",uY="shrink-0 mr-auto md:mr-0",uJ="flex gap-1 justify-end md:order-last",uZ="md:flex-1 md:min-w-[100px]";function uQ(e,t){let s=(0,n.useRef)(e);s.current=e;let a=(0,n.useRef)([]),r=(0,n.useRef)(0);for(;a.current.length<e.length;)a.current.push(`row-${r.current++}`);a.current.length=e.length;
16let[l,i]=(0,n.useState)(!1),o=(0,dB.FR)((0,dB.MS)(dB.AN),(0,dB.MS)(dB.IG,{activationConstraint:{delay:150,tolerance:8}}));(0,n.useEffect)(()=>{if(!l)return;let e=e=>e.preventDefault();return document.body.addEventListener("touchmove",e,{passive:!1}),()=>document.body.removeEventListener("touchmove",e)},[l]);let d=(0,n.useCallback)((e,r)=>{a.current=(0,dV.be)(a.current,e,r),t((0,dV.be)(s.current,e,r))},[t]),c=(0,n.useCallback)(e=>{a.current=a.current.filter((t,s)=>s!==e),t(s.current.filter((t,s)=>s!==e))},[t]),u=(0,n.useCallback)(e=>{i(!1);let{active:t,over:s}=e;if(!s||t.id===s.id)return;let r=a.current.indexOf(String(t.id)),n=a.current.indexOf(String(s.id));-1!==r&&-1!==n&&d(r,n)},[d]);return{count:e.length,keyAt:e=>a.current[e],sortableIds:[...a.current],move:d,removeAt:c,dndProps:{sensors:o,modifiers:[dz.FN],onDragStart:()=>i(!0),onDragEnd:u}}}function uX(e){let{rows:t,children:s}=e;return(0,r.jsx)(dB.Mp,{...t.dndProps,children:(0,r.jsx)(dV.gB,{items:t.sortableIds,strategy:dV._G,children:(0,r.jsx)("div",{className:"space-y-2",children:s})})})}function u0(e){let{id:t,children:s}=e,{attributes:a,listeners:n,setNodeRef:l,transform:i,transition:o,isDragging:d}=(0,dV.gl)({id:t}),c={transform:dq.Ks.Transform.toString(i),transition:o,opacity:d?.5:1};return(0,r.jsx)("div",{ref:l,style:c,children:(0,r.jsxs)("div",{className:"px-2.5 py-2 bg-[var(--background)] rounded-[--radius-md] border flex gap-3 relative",children:[(0,r.jsx)("div",{className:"rounded-full w-6 h-auto bg-[--muted] md:bg-[--subtle] md:hover:bg-[--subtle-highlight] cursor-move shrink-0",...a,...n}),(0,r.jsx)("div",{className:"flex-1 min-w-0 flex flex-col md:flex-row gap-2 md:items-center",children:s})]})})}function u1(e){let{rows:t,index:s,url:a,iconPosition:l}=e,i=(0,n.useCallback)(e=>{let t=(e.currentTarget.closest("[data-settings-card]")??document).querySelector(`[data-synced-url="${window.CSS.escape(a)}"]`);t&&(t.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(()=>{let e=t.querySelector("[data-radix-collection-item]");(null==e?void 0:e.dataset.state)!=="open"&&(null==e||e.click())},400))},[a]),o=(0,r.jsx)(to,{trigger:(0,r.jsx)("button",{type:"button","aria-label":"Jump to synced URL",onClick:i,className:"h-6 w-6 flex items-center justify-center cursor-pointer hover:opacity-80 transition-opacity shrink-0",children:(0,r.jsx)(cb.AnD,{className:"text-[--brand] text-base"})}),children:"Jump to synced URL"});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:uW,children:["inside"!==l&&(0,r.jsx)("div",{className:uY,children:o}),(0,r.jsx)("div",{className:uJ,children:(0,r.jsx)(u6,{rows:t,index:s})})]}),(0,r.jsxs)("div",{className:"md:flex-1 min-w-0 flex items-center gap-2 rounded-[--radius] bg-[--paper] border border-[--border] shadow-sm h-10 px-3 opacity-75 overflow-hidden",children:["inside"===l&&o,(0,r.jsx)("span",{className:"text-sm text-[--muted] font-mono truncate min-w-0 flex-1",children:a})]})]})}function u2(e,t,s,a,n){return t.map((t,l)=>{let i=e.keyAt(l),o=(null==n?void 0:n.syncEnabled)?function(e){if(!e.startsWith("<SYNCED: ")||!e.endsWith(">"))return null;let t=e.slice(9,-1).trim();return t.length>0?t:null}(s(t)):null;return(0,r.jsx)(u0,{id:i,children:o?(0,r.jsx)(u1,{rows:e,index:l,url:o,iconPosition:null==n?void 0:n.iconPosition}):a(t,l)},i)})}function u3(e,t,s){let a=tw(!1);return{modal:a,handleImport:(0,n.useCallback)(e=>{t(e)||x.oR.error("Invalid import format")},[t]),handleExport:(0,n.useCallback)(()=>{var t,a;let r,n,l,i,o,d,c,u,m,p;t=e(),n=(r=new Date).getFullYear(),l=String(r.getMonth()+1).padStart(2,"0"),i=String(r.getDate()).padStart(2,"0"),o=String(r.getHours()).padStart(2,"0"),d=String(r.getMinutes()).padStart(2,"0"),c=`${n}-${l}-${i}.${o}-${d}`,a=`${s.toLowerCase().replace(/\s+/g,"-")}-${c}.json`,u=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),m=URL.createObjectURL(u),(p=document.createElement("a")).href=m,p.download=a,document.body.appendChild(p),p.click(),document.body.removeChild(p),URL.revokeObjectURL(m)},[e,s])}}function u6(e){let{rows:t,index:s}=e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"sm",rounded:!0,icon:(0,r.jsx)(cb.uCC,{}),intent:"primary-subtle","aria-label":"Move up",disabled:0===s,onClick:e=>t.move(s,e.shiftKey?0:s-1)}),children:"Move up (shift to move to top)"}),(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"sm",rounded:!0,icon:(0,r.jsx)(cb.$TP,{}),intent:"primary-subtle","aria-label":"Move down",disabled:s===t.count-1,onClick:e=>t.move(s,e.shiftKey?t.count-1:s+1)}),children:"Move down (shift to move to bottom)"}),(0,r.jsx)(E,{size:"sm",rounded:!0,icon:(0,r.jsx)(cb.H8h,{}),intent:"alert-subtle","aria-label":"Remove",onClick:()=>t.removeAt(s)})]})}function u5(e){let{onAdd:t,onImportClick:s,onExport:a,children:n}=e;return(0,r.jsxs)("div",{className:"mt-2 flex gap-2 items-center",children:[(0,r.jsx)(E,{rounded:!0,size:"sm",intent:"primary-subtle",icon:(0,r.jsx)(cb.OiG,{}),onClick:t}),n,(0,r.jsxs)("div",{className:"ml-auto flex gap-2",children:[(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{rounded:!0,size:"sm",intent:"primary-subtle",icon:(0,r.jsx)(cb.PiR,{}),onClick:s}),children:"Import"}),(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{rounded:!0,size:"sm",intent:"primary-subtle",icon:(0,r.jsx)(cb.Mbn,{}),onClick:a}),children:"Export"})]})]})}function u4(e){let{fieldName:t,itemName:s,label:a,help:l,values:i,onValuesChange:o,placeholder:d,syncConfig:c,disabled:u}=e,m=(0,n.useRef)(i);m.current=i;let p=uQ(i,o),{modal:h,handleImport:x,handleExport:g}=u3((0,n.useCallback)(()=>({values:m.current}),[]),(0,n.useCallback)(e=>!!Array.isArray(e.values)&&(o(e.values),!0),[o]),a),f=(0,n.useCallback)((e,t)=>{let s=m.current;o([...s.slice(0,t),e,...s.slice(t+1)])},[o]);return(0,r.jsxs)(cr,{id:t??uG(a),title:a,description:l,children:[(0,r.jsx)(uX,{rows:p,children:u2(p,i,e=>e,(e,t)=>(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:uJ,children:(0,r.jsx)(u6,{rows:p,index:t})}),(0,r.jsx)("div",{className:"md:flex-1",children:(0,r.jsx)(W,{value:e,"aria-label":s,placeholder:d??s,onValueChange:e=>f(e,t)})})]}),{syncEnabled:!!c,iconPosition:"inside"})}),(0,r.jsx)(u5,{onAdd:()=>o([...i,""]),onImportClick:h.open,onExport:g}),(0,r.jsx)(uq,{open:h.isOpen,onOpenChange:h.toggle,onImport:x}),c&&(0,r.jsx)(uH,{syncConfig:c,renderType:"simple"})]},a)}function u9(e){let{title:t,fieldName:s,description:a,values:l,onValuesChange:i,onExpressionChange:o,onEnabledChange:d,placeholder:c,syncConfig:u}=e,m=(0,n.useRef)(l);m.current=l;let p=uQ(l,i),{modal:h,handleImport:x,handleExport:g}=u3((0,n.useCallback)(()=>m.current.map(e=>({expression:e.expression,enabled:e.enabled})),[]),(0,n.useCallback)(e=>Array.isArray(e)&&e.every(e=>"string"==typeof e.expression)?(i(e.map(e=>({expression:e.expression,enabled:e.enabled??!0}))),!0):!!Array.isArray(null==e?void 0:e.values)&&(i(e.values.map(e=>({expression:e,enabled:!0}))),!0),[i]),t);return(0,r.jsxs)(cr,{id:s??uG(t),title:t,description:a,children:[(0,r.jsx)(uX,{rows:p,children:u2(p,l,e=>e.expression,(e,t)=>(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:uW,children:[(0,r.jsx)("div",{className:uY,children:(0,r.jsx)(r6,{value:e.enabled??!0,defaultValue:!0,size:"lg","aria-label":"Enabled",onValueChange:e=>{d&&d(!0===e,t)}})}),(0,r.jsx)("div",{className:uJ,children:(0,r.jsx)(u6,{rows:p,index:t})})]}),(0,r.jsx)("div",{className:"md:flex-1",children:(0,r.jsx)(W,{value:e.expression,"aria-label":"Expression",placeholder:c,disabled:!1===e.enabled,onValueChange:e=>o(e,t)})})]}),{syncEnabled:!!u})}),(0,r.jsx)(u5,{onAdd:()=>i([...l,{expression:"",enabled:!0}]),onImportClick:h.open,onExport:g}),(0,r.jsx)(uq,{open:h.isOpen,onOpenChange:h.toggle,onImport:x}),u&&(0,r.jsx)(uH,{syncConfig:u,renderType:"nameable"})]})}function u8(e){let{title:t,description:s,keyName:a,keyId:l,keyPlaceholder:i,valueId:o,valueName:d,valuePlaceholder:c,values:u,onValuesChange:m,onValueChange:p,onKeyChange:h,disabled:x,syncConfig:g}=e,f=(0,n.useRef)(u);f.current=u;let b=uQ(u,m),{modal:v,handleImport:y,handleExport:j}=u3((0,n.useCallback)(()=>f.current.map(e=>({[l]:e.name,[o]:e.value})),[l,o]),(0,n.useCallback)(e=>!!(Array.isArray(e)&&e.every(e=>"string"==typeof e[l]&&"string"==typeof e[o]))&&(m(e.map(e=>({name:e[l],value:e[o]}))),!0),[m,l,o]),t);return(0,r.jsxs)(cr,{title:t,description:s,children:[(0,r.jsx)(uX,{rows:b,children:u2(b,u,e=>e.value,(e,t)=>(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:uJ,children:(0,r.jsx)(u6,{rows:b,index:t})}),(0,r.jsx)("div",{className:"md:flex-1",children:(0,r.jsx)(W,{value:e.name,"aria-label":a,placeholder:i,onValueChange:e=>h(e,t)})}),(0,r.jsx)("div",{className:"md:flex-1",children:(0,r.jsx)(W,{value:e.value,"aria-label":d,placeholder:c,onValueChange:e=>p(e,t)})})]}),{syncEnabled:!!g,iconPosition:"inside"})}),(0,r.jsx)(u5,{onAdd:()=>m([...u,{name:"",value:""}]),onImportClick:v.open,onExport:j}),(0,r.jsx)(uq,{open:v.isOpen,onOpenChange:v.toggle,onImport:y}),g&&(0,r.jsx)(uH,{syncConfig:g,renderType:"nameable"})]})}function u7(e){let{title:t,fieldName:s,description:a,values:l,onValuesChange:i,onExpressionChange:o,onScoreChange:d,onEnabledChange:c,syncConfig:u}=e,m=(0,n.useRef)(l);m.current=l;let p=uQ(l,i),{modal:h,handleImport:x,handleExport:g}=u3((0,n.useCallback)(()=>m.current.map(e=>({expression:e.expression,score:e.score,enabled:e.enabled})),[]),(0,n.useCallback)(e=>!!(Array.isArray(e)&&e.every(e=>"string"==typeof e.expression&&"number"==typeof e.score))&&(i(e.map(e=>({expression:e.expression,score:e.score,enabled:e.enabled??!0}))),!0),[i]),t);return(0,r.jsxs)(cr,{id:s??uG(t),title:t,description:a,children:[(0,r.jsx)(uX,{rows:p,children:u2(p,l,e=>e.expression,(e,t)=>(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:uW,children:[(0,r.jsx)("div",{className:uY,children:(0,r.jsx)(r6,{value:e.enabled??!0,defaultValue:!0,size:"lg","aria-label":"Enabled",onValueChange:e=>{c&&c(!0===e,t)}})}),(0,r.jsx)("div",{className:uJ,children:(0,r.jsx)(u6,{rows:p,index:t})})]}),(0,r.jsx)("div",{className:"md:flex-[3]",children:(0,r.jsx)(W,{value:e.expression,"aria-label":"Expression",placeholder:"addon(type(streams, 'debrid'), 'TorBox')",disabled:!1===e.enabled,onValueChange:e=>o(e,t)})}),(0,r.jsx)("div",{className:uZ,children:(0,r.jsx)(nn,{value:e.score||0,defaultValue:0,"aria-label":"Score",disabled:!1===e.enabled,onValueChange:e=>d(e||0,t),min:-1e6,max:1e6,step:50})})]}),{syncEnabled:!!u})}),(0,r.jsx)(u5,{onAdd:()=>i([...l,{expression:"",score:0,enabled:!0}]),onImportClick:h.open,onExport:g}),(0,r.jsx)(uq,{open:h.isOpen,onOpenChange:h.toggle,onImport:x}),u&&(0,r.jsx)(uH,{syncConfig:u,renderType:"ranked"})]})}function me(e){let{title:t,description:s,values:a,onValuesChange:l,onPatternChange:i,onNameChange:o,onScoreChange:d,syncConfig:c}=e,u=(0,n.useRef)(a);u.current=a;let m=uQ(a,l),{modal:p,handleImport:h,handleExport:x}
16=u3((0,n.useCallback)(()=>u.current.map(e=>({pattern:e.pattern,name:e.name,score:e.score})),[]),(0,n.useCallback)(e=>!!(Array.isArray(e)&&e.every(e=>"string"==typeof e.pattern&&"number"==typeof e.score))&&(l(e.map(e=>({pattern:e.pattern,name:e.name,score:e.score}))),!0),[l]),t);return(0,r.jsxs)(cr,{title:t,description:s,children:[(0,r.jsx)(uX,{rows:m,children:u2(m,a,e=>e.pattern,(e,t)=>(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:uJ,children:(0,r.jsx)(u6,{rows:m,index:t})}),(0,r.jsx)("div",{className:"md:flex-[3]",children:(0,r.jsx)(W,{value:e.pattern,"aria-label":"Pattern",placeholder:"Regex Pattern",onValueChange:e=>i(e,t)})}),(0,r.jsx)("div",{className:"md:flex-[2]",children:(0,r.jsx)(W,{value:e.name||"","aria-label":"Name",placeholder:"Name (Optional)",onValueChange:e=>o(e,t)})}),(0,r.jsx)("div",{className:uZ,children:(0,r.jsx)(nn,{value:e.score,"aria-label":"Score",onValueChange:e=>d(e??0,t),min:-1e6,max:1e6,step:50})})]}),{syncEnabled:!!c,iconPosition:"inside"})}),(0,r.jsx)(u5,{onAdd:()=>l([...a,{pattern:"",name:"",score:0}]),onImportClick:p.open,onExport:x}),(0,r.jsx)(uq,{open:p.isOpen,onOpenChange:p.toggle,onImport:h}),c&&(0,r.jsx)(uH,{syncConfig:c,renderType:"ranked"})]})}let mt=[{key:"movies",heading:"Movies"},{key:"series",heading:"Series"},{key:"anime",heading:"Anime Series"}];function ms(e){let{label:t,help:s,moviesValue:a,seriesValue:n,animeValue:l,onMoviesChange:i,onSeriesChange:o,onAnimeChange:d,min:c,max:u,formatValue:m,kind:p}=e,h={movies:a,series:n,anime:l},x={movies:i,series:o,anime:d};return(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsx)("h4",{className:"text-base font-medium",children:t}),mt.map(e=>{let{key:t,heading:a}=e,n=h[t],l=x[t];return(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("h5",{className:"text-sm font-medium text-[--muted]",children:a}),(0,r.jsxs)("div",{className:"flex flex-col md:flex-row gap-4",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)(uF,{min:c,max:u,defaultValue:[c,u],step:u/1e3,value:n,onValueChange:e=>void 0!==e&&(null==e?void 0:e[0])!==void 0&&(null==e?void 0:e[1])!==void 0&&l([e[0],e[1]]),minStepsBetweenThumbs:1,label:`${a} ${p} Range`,help:s}),(0,r.jsxs)("div",{className:"flex justify-between mt-1 text-xs text-[--muted]",children:[(0,r.jsx)("span",{children:m(n[0])}),(0,r.jsx)("span",{children:m(n[1])})]})]}),(0,r.jsxs)("div",{className:"flex gap-2 md:w-[240px] shrink-0",children:[(0,r.jsx)(nn,{label:"Min",step:u/1e3,value:n[0],min:c,max:n[1],onValueChange:e=>void 0!==e&&l([e,n[1]])}),(0,r.jsx)(nn,{label:"Max",step:u/1e3,value:n[1],min:n[0],max:u,onValueChange:e=>void 0!==e&&l([n[0],e])})]})]})]},t)})]})}function ma(e){let{min:t=0,max:s=1e11,...a}=e;return(0,r.jsx)(ms,{min:t,max:s,formatValue:rx,kind:"Size",...a})}function mr(e){let{min:t=0,max:s=25e7,...a}=e;return(0,r.jsx)(ms,{min:t,max:s,formatValue:rf,kind:"Bitrate",...a})}let mn=["2160p","1440p","1080p","720p","576p","480p","360p","240p","144p","Unknown"],ml=["BluRay REMUX","BluRay","WEB-DL","WEBRip","HDRip","HC HD-Rip","DVD REMUX","DVDRip","HDTV","CAM","TS","TC","SCR","Unknown"],mi=[],mo=[],md=[],mc=[],mu=b("w-full grid grid-cols-1 lg:grid lg:grid-cols-[300px,1fr] gap-4"),mm=b("font-bold text-base px-6 rounded-[--radius-md] w-fit lg:w-full border-none data-[state=active]:bg-[--subtle] data-[state=active]:text-white dark:hover:text-white","h-9 lg:justify-start px-3 transition-all duration-200 hover:bg-[--subtle]/50 hover:transform"),mp=b("w-full flex flex-wrap lg:flex-nowrap h-fit xl:h-10","lg:block p-2 lg:p-0"),mh=b("space-y-4 animate-in fade-in-0 slide-in-from-right-2 duration-300");function mx(e){if(e<24)return`${e}h`;let t=Math.floor(e/24);return`${t}d`}function mg(e){let{heading:t}=e;return(0,r.jsxs)("div",{className:"flex flex-col lg:flex-row lg:items-center lg:justify-between gap-4 mb-4",children:[(0,r.jsx)("h3",{children:t}),(0,r.jsx)("div",{className:"hidden lg:block lg:ml-auto",children:(0,r.jsx)(dT,{})})]})}let mf={conservative:"Removes duplicates conservatively - removes uncached versions which have cached versions from the same service, and removes P2P versions when cached versions exist",aggressive:"Aggressively removes all uncached and p2p streams when cached versions exist, and removes uncached streams when p2p versions exist",keep_all:"Keeps all streams and processes each group independently"},mb="aggressive";function mv(e){return`<SYNCED: ${e}>`}
16let my={syncedPreferredRegexUrls:"preferredRegexPatterns",syncedExcludedRegexUrls:"excludedRegexPatterns",syncedIncludedRegexUrls:"includedRegexPatterns",syncedRequiredRegexUrls:"requiredRegexPatterns",syncedRankedRegexUrls:"rankedRegexPatterns",syncedPreferredStreamExpressionUrls:"preferredStreamExpressions",syncedExcludedStreamExpressionUrls:"excludedStreamExpressions",syncedIncludedStreamExpressionUrls:"includedStreamExpressions",syncedRequiredStreamExpressionUrls:"requiredStreamExpressions",syncedRankedStreamExpressionUrls:"rankedStreamExpressions"};function mj(e,t){return"string"==typeof t?t:(null==t?void 0:t.pattern)!==void 0?t.pattern:(null==t?void 0:t.expression)!==void 0?t.expression:""}function mw(){return(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(ru,{className:"p-4 sm:p-8 space-y-4",children:(0,r.jsx)(mN,{})})})}function mN(){var e,t,s,a,l,i,o,d,c,u,m,p,h,g,f,b,v,y,j,N,k,S,C,_,R,A,T,I,M,D,L,$,O,F,z,V,q,B,K,H,G,W,Y,J,Z,Q,X,ee,et,es,ea,er,en,el,ei,eo,ed,ec,eu,em,ep,eh,ex,eg,ef,eb,ev,ey,ej,ew,eN,ek,eS,eC,e_,eR,eA,eT,eI,eE,eM,eP,eD,eL,eU,eO,eF,ez,eV,eq,eB,eK,eH,eG,eW,eY,eJ,eZ,eQ,eX,e0,e1,e2,e3,e6,e5,e4,e9,e8,e7,te,tt,ts,ta,tr,tn,tl,ti,to,td,tc,tu,tm,tp,th,tx,tg,tf,tb,tv,tj,tN,tk,tS,t_,tR,tA,tT,tI,tE,tM,tP,tD,tL,tU,t$,tO,tF,tz,tV,tq,tB,tK,tH,tG,tW;let{tab:tY,setTab:tJ}=ao("filters"),{status:tZ}=e$(),{mode:tQ}=tX(),{userData:t0,setUserData:t1}=s4(),{isInherited:t2,hasParent:t6}=s9(),t5=tw(!1),t4=tw(!1),t9=tw(!1),t8=e=>{let t=my[e];return{syncConfig:{urls:t0[e]||[],trusted:t0.trusted,syncMode:e.includes("StreamExpression")?"sel":"regex",onUrlsChange:t=>{t1(s=>({...s,[e]:t}))},onInsertPlaceholder:t?e=>{let s=function(e,t){let s=mv(t);switch(e){case"excludedRegexPatterns":case"includedRegexPatterns":case"requiredRegexPatterns":default:return s;case"preferredRegexPatterns":return{name:"",pattern:s};case"rankedRegexPatterns":return{pattern:s,name:"",score:0};case"excludedStreamExpressions":case"includedStreamExpressions":case"requiredStreamExpressions":case"preferredStreamExpressions":return{expression:s,enabled:!0};case"rankedStreamExpressions":return{expression:s,score:0,enabled:!0}}}(t,e);t1(e=>({...e,[t]:[...e[t]||[],s]}))}:void 0,onRemovePlaceholder:t?e=>{let s=mv(e);t1(e=>{let a=e[t];if(!Array.isArray(a))return e;let r=a.filter(e=>mj(t,e)!==s);return r.length===a.length?e:{...e,[t]:r}})}:void 0,hasPlaceholder:t?e=>{let s=mv(e),a=t0[t];return!!Array.isArray(a)&&a.some(e=>mj(t,e)===s)}:void 0}}};return(0,n.useEffect)(()=>{t0.preferredResolutions||t1(e=>({...e,preferredResolutions:mn})),t0.preferredQualities||t1(e=>({...e,preferredQualities:ml})),t0.preferredEncodes||t1(e=>({...e,preferredEncodes:mi})),t0.preferredStreamTypes||t1(e=>({...e,preferredStreamTypes:mo})),t0.preferredVisualTags||t1(e=>({...e,preferredVisualTags:md})),t0.preferredAudioTags||t1(e=>({...e,preferredAudioTags:mc}))},[]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(rF,{value:tY,onValueChange:e=>{tJ(e)},className:mu,triggerClass:mm,listClass:mp,contentClass:mh,children:[(0,r.jsx)(rz,{className:"flex-wrap max-w-full lg:space-y-2",children:(0,r.jsxs)(ca,{children:[(0,r.jsxs)("div",{className:"flex flex-col gap-4 md:flex-row justify-between items-center",children:[(0,r.jsx)("div",{className:"space-y-1 my-2 px-2",children:(0,r.jsxs)("div",{className:"flex items-center gap-2 justify-center md:justify-start",children:[(0,r.jsx)("h4",{children:"Filters"}),t6&&t2("filters")&&(0,r.jsx)(dF,{section:"filters"})]})}),(0,r.jsx)("div",{})]}),(0,r.jsxs)("div",{className:"overflow-x-none overflow-y-scroll lg:overflow-y-hidden h-40 lg:h-auto rounded-[--radius-md] border lg:border-none [--webkit-overflow-scrolling:touch]",children:[(0,r.jsxs)(rV,{value:"cache",children:[(0,r.jsx)(cb.lHQ,{className:"text-lg mr-3"}),"Cache"]}
16),(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)(rV,{value:"resolution",children:[(0,r.jsx)(tC._U5,{className:"text-lg mr-3"}),"Resolution"]})}),"pro"==tQ&&(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)(rV,{value:"quality",children:[(0,r.jsx)(cp.KBW,{className:"text-lg mr-3"}),"Quality"]})}),"pro"===tQ&&(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)(rV,{value:"encode",children:[(0,r.jsx)(cb.UUG,{className:"text-lg mr-3"}),"Encode"]})}),"pro"===tQ&&(0,r.jsxs)(rV,{value:"stream-type",children:[(0,r.jsx)(cp.iDz,{className:"text-lg mr-3"}),"Stream Type"]}),"pro"===tQ&&(0,r.jsxs)(rV,{value:"visual-tag",children:[(0,r.jsx)(cp.Xc1,{className:"text-lg mr-3"}),"Visual Tag"]}),"pro"===tQ&&(0,r.jsxs)(rV,{value:"audio-tag",children:[(0,r.jsx)(uL.YkV,{className:"text-lg mr-3"}),"Audio Tag"]}),"pro"===tQ&&(0,r.jsxs)(rV,{value:"audio-channel",children:[(0,r.jsx)(cp.pCc,{className:"text-lg mr-3"}),"Audio Channel"]}),(0,r.jsxs)(rV,{value:"language",children:[(0,r.jsx)(cb.gqt,{className:"text-lg mr-3"}),"Language"]}),(0,r.jsxs)(rV,{value:"subtitle",children:[(0,r.jsx)(cp.zZ_,{className:"text-lg mr-3"}),"Subtitle"]}),(0,r.jsxs)(rV,{value:"seeders",children:[(0,r.jsx)(cp.LTk,{className:"text-lg mr-3"}),"Seeders"]}),(0,r.jsxs)(rV,{value:"age",children:[(0,r.jsx)(cb.w_X,{className:"text-lg mr-3"}),"Age"]}),"pro"===tQ&&(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)(rV,{value:"matching",children:[(0,r.jsx)(cb.VsL,{className:"text-lg mr-3"}),"Matching"]})}),"pro"===tQ&&(0,r.jsxs)(rV,{value:"keyword",children:[(0,r.jsx)(cp.Gfv,{className:"text-lg mr-3"}),"Keyword"]}),"pro"===tQ&&(0,r.jsxs)(rV,{value:"release-group",children:[(0,r.jsx)(da.Com,{className:"text-lg mr-3"}),"Release Group"]}),"pro"===tQ&&(0,r.jsxs)(rV,{value:"stream-expression",children:[(0,r.jsx)(cy.awR,{className:"text-lg mr-3"}),"Stream Expression"]}),((null==tZ?void 0:tZ.settings.regexAccess.level)!=="none"||((null==tZ||null==(e=tZ.settings.regexAccess.patterns)?void 0:e.length)??0)>0||((null==tZ||null==(t=tZ.settings.regexAccess.urls)?void 0:t.length)??0)>0)&&"pro"===tQ&&(0,r.jsxs)(rV,{value:"regex",children:[(0,r.jsx)(uL.zvj,{className:"text-lg mr-3"}),"Regex"]}),(0,r.jsxs)(rV,{value:"size",children:[(0,r.jsx)(uU.mKD,{className:"text-lg mr-3"}),"Size"]}),(0,r.jsxs)(rV,{value:"bitrate",children:[(0,r.jsx)(cb.$BV,{className:"text-lg mr-3"}),"Bitrate"]}),(0,r.jsxs)(rV,{value:"limit",children:[(0,r.jsx)(uU.GJ9,{className:"text-lg mr-3"}),"Result Limits"]}),(0,r.jsxs)(rV,{value:"deduplicator",children:[(0,r.jsx)(cp.xbI,{className:"text-lg mr-3"}),"Deduplicator"]}),(0,r.jsxs)(rV,{value:"miscellaneous",children:[(0,r.jsx)(cp.y2g,{className:"text-lg mr-3"}),"Miscellaneous"]})]})]})}),(0,r.jsxs)("div",{className:"space-y-0 relative",children:[(0,r.jsx)(rq,{id:"filter-tab-cache",value:"cache",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(mg,{heading:"Cache"}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(cr,{id:"excludeUncached",title:"Uncached",description:"Control the exclusion of uncached results",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(rs,{label:"Exclude Uncached",help:"Completely remove uncached results",moreHelp:"Enabling this option overrides the below controls and cannot be used in conjunction with them",side:"right",value:t0.excludeUncached??!1,onValueChange:e=>{t1(t=>({...t,excludeUncached:e}))}}),"pro"===tQ&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ne,{help:"Addons selected here will have their uncached results excluded",label:"Exclude Uncached From Addons",value:t0.excludeUncachedFromAddons??[],onValueChange:e=>{t1(t=>({...t,excludeUncachedFromAddons:e}))},options:t0.presets.map(e=>({label:e.options.name||e.type,value:e.instanceId,textValue:e.options.name})),emptyMessage:"You haven't installed any addons...",placeholder:"Select addons...",multiple:!0,disabled:!0===t0.excludeUncached}),(0,r.jsx)(ne,{help:"Services selected here will have their uncached results excluded",label:"Exclude Uncached From Services",value:t0.excludeUncachedFromServices??[],onValueChange:e=>{t1(t=>({...t,excludeUncachedFromServices:e}))},options:Object.values((null==tZ?void 0:tZ.settings.services)??{}).map(e=>({label:e.name,value:e.id,textValue:e.name})),placeholder:"Select services...",emptyMessage:"This is odd... there aren't any services to choose from...",multiple:!0,disabled:!0===t0.excludeUncached}),(0,r.jsx)(ne,{help:"Stream types selected here will have their uncached results excluded",label:"Exclude Uncached From Stream Types",value:t0.excludeUncachedFromStreamTypes??[],onValueChange:e=>{t1(t=>({...t,excludeUncachedFromStreamTypes:e}))},options:sB.filter(e=>["debrid","usenet"].includes(e)).map(e=>({label:e,value:e,textValue:e})),emptyMessage:"This is odd... there aren't any stream types to choose from...",placeholder:"Select stream types...",multiple:!0,disabled:!0===t0.excludeUncached}),(0,r.jsx)(rn,{label:"Apply mode",disabled:!0===t0.excludeUncached,help:"How these three options (from addons, services and stream types) are applied. AND means a result must match all, OR means a result only needs to match one",value:t0.excludeUncachedMode??"or",onValueChange:e=>{t1(t=>({...t,excludeUncachedMode:e}))},options:[{label:"OR",value:"or"},{label:"AND",value:"and"}]})]})]})}),(0,r.jsx)(cr,{id:"excludeCached",title:"Cached",description:"Control the exclusion of cached results",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(rs,{label:"Exclude Cached",help:"Completely remove cached results",moreHelp:"Enabling this option overrides the below controls and cannot be used in conjunction with them",side:"right",value:t0.excludeCached??!1,onValueChange:e=>{t1(t=>({...t,excludeCached:e}))}}),"pro"===tQ&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ne,{help:"Addons selected here will have their cached results excluded",label:"Exclude Cached From Addons",value:t0.excludeCachedFromAddons??[],onValueChange:e=>{t1(t=>({...t,excludeCachedFromAddons:e}))},options:t0.presets.map(e=>({label:e.options.name||e.type,value:e.instanceId,textValue:e.options.name||e.type})),emptyMessage:"You haven't installed any addons...",placeholder:"Select addons...",multiple:!0,disabled:!0===t0.excludeCached}),(0,r.jsx)(ne,{help:"Services selected here will have their cached results excluded",label:"Exclude Cached From Services",value:t0.excludeCachedFromServices??[],onValueChange:e=>{t1(t=>({...t,excludeCachedFromServices:e}))},options:Object.values((null==tZ?void 0:tZ.settings.services)??{}).map(e=>({label:e.name,value:e.id,textValue:e.name})),placeholder:"Select services...",emptyMessage:"This is odd... there aren't any services to choose from...",multiple:!0,disabled:!0===t0.excludeCached}),(0,r.jsx)(ne,{help:"Stream types selected here will have their cached results excluded",label:"Exclude Cached From Stream Types",value:t0.excludeCachedFromStreamTypes??[],onValueChange:e=>{t1(t=>({...t,excludeCachedFromStreamTypes:e}))},options:sB.filter(e=>["debrid","usenet"].includes(e)).map(e=>({label:e,value:e,textValue:e})),emptyMessage:"This is odd... there aren't any stream types to choose from...",placeholder:"Select stream types...",multiple:!0,disabled:!0===t0.excludeCached}),(0,r.jsx)(rn,{label:"Apply mode",disabled:!0===t0.excludeCached,help:"How these three options (from addons, services and stream types) are applied. AND means a result must match all, OR means a result only needs to match one",value:t0.excludeCachedMode??"or",onValueChange:e=>{t1(t=>({...t,excludeCachedMode:e}))},options:[{label:"OR",value:"or"},{label:"AND",value:"and"}]})]})]})})]})]})}),(0,r.jsx)(rq,{id:"filter-tab-resolution",value:"resolution",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(mg,{heading:"Resolution"}),(0,r.jsx)(uz,{filterName:"Resolutions",preferredOptions:t0.preferredResolutions||mn,requiredOptions:t0.requiredResolutions||[],excludedOptions:t0.excludedResolutions||[],includedOptions:t0.includedResolutions||[],onPreferredChange:e=>t1(t=>({...t,preferredResolutions:e})),onRequiredChange:e=>t1(t=>({...t,requiredResolutions:e})),onExcludedChange:e=>t1(t=>({...t,excludedResolutions:e})),onIncludedChange:e=>t1(t=>({...t,includedResolutions:e})),options:sL.map(e=>({name:e,value:e}))})]})}
16),(0,r.jsx)(rq,{id:"filter-tab-quality",value:"quality",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(mg,{heading:"Quality"}),(0,r.jsx)(uz,{filterName:"Qualities",preferredOptions:t0.preferredQualities||ml,requiredOptions:t0.requiredQualities||[],excludedOptions:t0.excludedQualities||[],includedOptions:t0.includedQualities||[],onPreferredChange:e=>t1(t=>({...t,preferredQualities:e})),onRequiredChange:e=>t1(t=>({...t,requiredQualities:e})),onExcludedChange:e=>t1(t=>({...t,excludedQualities:e})),onIncludedChange:e=>t1(t=>({...t,includedQualities:e})),options:sU.map(e=>({name:e,value:e}))})]})}),(0,r.jsx)(rq,{id:"filter-tab-encode",value:"encode",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(mg,{heading:"Encode"}),(0,r.jsx)(uz,{filterName:"Encodes",preferredOptions:t0.preferredEncodes||mi,requiredOptions:t0.requiredEncodes||[],excludedOptions:t0.excludedEncodes||[],includedOptions:t0.includedEncodes||[],onPreferredChange:e=>t1(t=>({...t,preferredEncodes:e})),onRequiredChange:e=>t1(t=>({...t,requiredEncodes:e})),onExcludedChange:e=>t1(t=>({...t,excludedEncodes:e})),onIncludedChange:e=>t1(t=>({...t,includedEncodes:e})),options:sz.map(e=>({name:e,value:e}))})]})}),(0,r.jsx)(rq,{id:"filter-tab-stream-type",value:"stream-type",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(mg,{heading:"Stream Type"}),(0,r.jsx)(uz,{filterName:"Stream Types",preferredOptions:t0.preferredStreamTypes||mo,requiredOptions:t0.requiredStreamTypes||[],excludedOptions:t0.excludedStreamTypes||[],includedOptions:t0.includedStreamTypes||[],onPreferredChange:e=>t1(t=>({...t,preferredStreamTypes:e})),onRequiredChange:e=>t1(t=>({...t,requiredStreamTypes:e})),onExcludedChange:e=>t1(t=>({...t,excludedStreamTypes:e})),onIncludedChange:e=>t1(t=>({...t,includedStreamTypes:e})),options:sB.map(e=>({name:e,value:e}))})]})}),(0,r.jsx)(rq,{id:"filter-tab-visual-tag",value:"visual-tag",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(mg,{heading:"Visual Tag"}),(0,r.jsx)(uz,{filterName:"Visual Tags",preferredOptions:t0.preferredVisualTags||md,requiredOptions:t0.requiredVisualTags||[],excludedOptions:t0.excludedVisualTags||[],includedOptions:t0.includedVisualTags||[],onPreferredChange:e=>t1(t=>({...t,preferredVisualTags:e})),onRequiredChange:e=>t1(t=>({...t,requiredVisualTags:e})),onExcludedChange:e=>t1(t=>({...t,excludedVisualTags:e})),onIncludedChange:e=>t1(t=>({...t,includedVisualTags:e})),options:s$.map(e=>({name:e,value:e}))})]})}),(0,r.jsx)(rq,{id:"filter-tab-audio-tag",value:"audio-tag",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(mg,{heading:"Audio Tag"}),(0,r.jsx)(uz,{filterName:"Audio Tags",preferredOptions:t0.preferredAudioTags||[],requiredOptions:t0.requiredAudioTags||[],excludedOptions:t0.excludedAudioTags||[],includedOptions:t0.includedAudioTags||[],onPreferredChange:e=>t1(t=>({...t,preferredAudioTags:e})),onRequiredChange:e=>t1(t=>({...t,requiredAudioTags:e})),onExcludedChange:e=>t1(t=>({...t,excludedAudioTags:e})),onIncludedChange:e=>t1(t=>({...t,includedAudioTags:e})),options:sO.map(e=>({name:e,value:e}))})]})}),(0,r.jsx)(rq,{id:"filter-tab-audio-channel",value:"audio-channel",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(mg,{heading:"Audio Channel"}),(0,r.jsx)(uz,{filterName:"Audio Channels",preferredOptions:t0.preferredAudioChannels||[],requiredOptions:t0.requiredAudioChannels||[],excludedOptions:t0.excludedAudioChannels||[],includedOptions:t0.includedAudioChannels||[],onPreferredChange:e=>t1(t=>({...t,preferredAudioChannels:e})),onRequiredChange:e=>t1(t=>({...t,requiredAudioChannels:e})),onExcludedChange:e=>t1(t=>({...t,excludedAudioChannels:e})),onIncludedChange:e=>t1(t=>({...t,includedAudioChannels:e})),options:sF.map(e=>({name:e,value:e}))})]})}),(0,r.jsx)(rq,{id:"filter-tab-language",value:"language",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(mg,{heading:"Language"}),(0,r.jsx)(uz,{filterName:"Languages",preferredOptions:t0.preferredLanguages||[],requiredOptions:t0.requiredLanguages||[],excludedOptions:t0.excludedLanguages||[],includedOptions:t0.includedLanguages||[],onPreferredChange:e=>t1(t=>({...t,preferredLanguages:e})),onRequiredChange:e=>t1(t=>({...t,requiredLanguages:e})),onExcludedChange:e=>t1(t=>({...t,excludedLanguages:e})),onIncludedChange:e=>t1(t=>({...t,includedLanguages:e})),options:sQ.map(e=>({name:e.split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),value:e}))})]})}),(0,r.jsx)(rq,{id:"filter-tab-subtitle",value:"subtitle",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(mg,{heading:"Subtitle"}),(0,r.jsx)(nU,{intent:"warning",title:"Difference between Language and Subtitle filters",description:(0,r.jsxs)("div",{className:"text-sm",children:["Languages and subtitles behave differently depending on what information is available for a stream.",(0,r.jsx)("br",{}),(0,r.jsx)("br",{}),(0,r.jsxs)("span",{className:"inline-flex items-center gap-1",children:["When accurate media info is available",(0,r.jsx)(U,{className:"text-sm ",trigger:(0,r.jsx)(P.ExT,{className:"transition-opacity opacity-45 hover:opacity-90 inline-block cursor-pointer"}),children:(0,r.jsxs)("div",{className:"max-w-sm",children:[(0,r.jsx)("div",{className:"font-medium",children:"Accurate media info is available for:"}),(0,r.jsxs)("ul",{className:"list-disc list-inside mt-2 space-y-1 text-xs",children:[(0,r.jsx)("li",{children:"Certain results from built-in or service-wrapped addons"}),(0,r.jsx)("li",{children:"Certain results from StremThru Torz/Store and Meteor"}),(0,r.jsx)("li",{children:"Torznab/Newznab results from indexers that provide separate audio/subtitle metadata"}),(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{children:"nekoBT"})," results (all results have accurate audio/subtitle info)"]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{children:"Torrentio"})," anime results (subtitles field may be populated)"]})]})]})})]}),", ",(0,r.jsx)("code",{className:"bg-base-200 px-1 py-0.5 rounded",children:"languages"})," ","contains audio track languages and"," ",(0,r.jsx)("code",{className:"bg-base-200 px-1 py-0.5 rounded",children:"subtitles"})," ","contains embedded subtitle languages.",(0,r.jsx)("br",{}),(0,r.jsx)("br",{}),"In all other cases,"," ",(0,r.jsx)("code",{className:"bg-base-200 px-1 py-0.5 rounded",children:"subtitles"}
16)," ","is empty and"," ",(0,r.jsx)("code",{className:"bg-base-200 px-1 py-0.5 rounded",children:"languages"})," ",'contains every language found in the filename — including subtitle-only languages (e.g. a filename containing "Eng.Sub" will add English to languages, not subtitles). This is a known limitation of filename-only parsing.']})}),(0,r.jsx)(uz,{filterName:"Subtitles",preferredOptions:t0.preferredSubtitles||[],requiredOptions:t0.requiredSubtitles||[],excludedOptions:t0.excludedSubtitles||[],includedOptions:t0.includedSubtitles||[],onPreferredChange:e=>t1(t=>({...t,preferredSubtitles:e})),onRequiredChange:e=>t1(t=>({...t,requiredSubtitles:e})),onExcludedChange:e=>t1(t=>({...t,excludedSubtitles:e})),onIncludedChange:e=>t1(t=>({...t,includedSubtitles:e})),options:sQ.map(e=>({name:e.split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),value:e}))})]})}),(0,r.jsx)(rq,{id:"filter-tab-seeders",value:"seeders",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(mg,{heading:"Seeders"}),(0,r.jsx)(cr,{title:"Seeder Filters",description:"Configure required, excluded, and included seeder ranges",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsxs)("div",{className:"flex flex-col md:flex-row gap-4",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)(uF,{min:0,max:1e3,defaultValue:[0,1e3],value:t0.requiredSeederRange||[0,1e3],onValueChange:e=>void 0!==e&&(null==e?void 0:e[0])!==void 0&&(null==e?void 0:e[1])!==void 0&&t1(t=>({...t,requiredSeederRange:[e[0],e[1]]})),minStepsBetweenThumbs:1,label:"Required Seeder Range",help:"Streams with seeders outside this range will be excluded"}),(0,r.jsxs)("div",{className:"flex justify-between mt-1 text-xs text-[--muted]",children:[(0,r.jsx)("span",{children:(null==(s=t0.requiredSeederRange)?void 0:s[0])||0}),(0,r.jsx)("span",{children:(null==(a=t0.requiredSeederRange)?void 0:a[1])||1e3})]})]}),(0,r.jsxs)("div",{className:"flex gap-2 md:w-[240px] shrink-0",children:[(0,r.jsx)(nn,{label:"Min",value:(null==(l=t0.requiredSeederRange)?void 0:l[0])||0,min:0,max:(null==(i=t0.requiredSeederRange)?void 0:i[1])||1e3,onValueChange:e=>void 0!==e&&t1(t=>{var s;return{...t,requiredSeederRange:[e,(null==(s=t.requiredSeederRange)?void 0:s[1])||1e3]}})}),(0,r.jsx)(nn,{label:"Max",value:(null==(o=t0.requiredSeederRange)?void 0:o[1])||1e3,min:(null==(d=t0.requiredSeederRange)?void 0:d[0])||0,max:1e3,onValueChange:e=>void 0!==e&&t1(t=>{var s;return{...t,requiredSeederRange:[(null==(s=t.requiredSeederRange)?void 0:s[0])||0,e]}})})]})]}),"pro"===tQ&&(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"flex flex-col md:flex-row gap-4",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)(uF,{min:0,max:1e3,defaultValue:[0,1e3],value:t0.excludeSeederRange||[0,1e3],onValueChange:e=>void 0!==e&&(null==e?void 0:e[0])!==void 0&&(null==e?void 0:e[1])!==void 0&&t1(t=>({...t,excludeSeederRange:[e[0],e[1]]})),minStepsBetweenThumbs:1,label:"Excluded Seeder Range",help:"Streams with seeders in this range will be excluded"}),(0,r.jsxs)("div",{className:"flex justify-between mt-1 text-xs text-[--muted]",children:[(0,r.jsx)("span",{children:(null==(c=t0.excludeSeederRange)?void 0:c[0])||0}),(0,r.jsx)("span",{children:(null==(u=t0.excludeSeederRange)?void 0:u[1])||1e3})]})]}),(0,r.jsxs)("div",{className:"flex gap-2 md:w-[240px] shrink-0",children:[(0,r.jsx)(nn,{label:"Min",value:(null==(m=t0.excludeSeederRange)?void 0:m[0])||0,min:0,max:(null==(p=t0.excludeSeederRange)?void 0:p[1])||1e3,onValueChange:e=>void 0!==e&&t1(t=>{var s;return{...t,excludeSeederRange:[e,(null==(s=t.excludeSeederRange)?void 0:s[1])||1e3]}})}),(0,r.jsx)(nn,{label:"Max",value:(null==(h=t0.excludeSeederRange)?void 0:h[1])||1e3,min:(null==(g=t0.excludeSeederRange)?void 0:g[0])||0,max:1e3,onValueChange:e=>void 0!==e&&t1(t=>{var s;return{...t,excludeSeederRange:[(null==(s=t.excludeSeederRange)?void 0:s[0])||0,e]}})})]})]})}),"pro"===tQ&&(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"flex flex-col md:flex-row gap-4",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)(uF,{min:0,max:1e3,defaultValue:[0,1e3],value:t0.includeSeederRange||[0,1e3],onValueChange:e=>void 0!==e&&(null==e?void 0:e[0])!==void 0&&(null==e?void 0:e[1])!==void 0&&t1(t=>({...t,includeSeederRange:[e[0],e[1]]})),minStepsBetweenThumbs:1,label:"Included Seeder Range",help:"Streams with seeders in this range will be included, ignoring ANY other exclude/required filters, not just for this filter"}),(0,r.jsxs)("div",{className:"flex justify-between mt-1 text-xs text-[--muted]",children:[(0,r.jsx)("span",{children:(null==(f=t0.includeSeederRange)?void 0:f[0])||0}),(0,r.jsx)("span",{children:(null==(b=t0.includeSeederRange)?void 0:b[1])||1e3})]})]}),(0,r.jsxs)("div",{className:"flex gap-2 md:w-[240px] shrink-0",children:[(0,r.jsx)(nn,{label:"Min",value:(null==(v=t0.includeSeederRange)?void 0:v[0])||0,min:0,max:(null==(y=t0.includeSeederRange)?void 0:y[1])||1e3,onValueChange:e=>void 0!==e&&t1(t=>{var s;return{...t,includeSeederRange:[e,(null==(s=t.includeSeederRange)?void 0:s[1])||1e3]}})}),(0,r.jsx)(nn,{label:"Max",value:(null==(j=t0.includeSeederRange)?void 0:j[1])||1e3,min:(null==(N=t0.includeSeederRange)?void 0:N[0])||0,max:1e3,onValueChange:e=>void 0!==e&&t1(t=>{var s;return{...t,includeSeederRange:[(null==(s=t.includeSeederRange)?void 0:s[0])||0,e]}})})]})]})})]}),(0,r.jsx)("div",{className:"space-y-4",children:(0,r.jsx)(ne,{label:"Stream Types",emptyMessage:"There aren't any stream types to choose from...",options:["p2p","cached","uncached"].map(e=>({label:e,value:e})),value:t0.seederRangeTypes||[],onValueChange:e=>{t1(t=>({...t,seederRangeTypes:e}))},help:"Stream types that will use the seeder ranges defined above. Leave blank to apply to all stream types.",multiple:!0})})]})})]})}),(0,r.jsx)(rq,{id:"filter-tab-age",value:"age",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(mg,{heading:"Age"}),(0,r.jsx)(cr,{title:"Age Filters",description:"Configure required, excluded, and included age ranges (in hours since upload)",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsxs)("div",{className:"flex flex-col md:flex-row gap-4",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)(uF,{min:0,max:155520,step:24,defaultValue:[0,155520],value:t0.requiredAgeRange||[0,155520],onValueChange:e=>void 0!==e&&(null==e?void 0:e[0])!==void 0&&(null==e?void 0:e[1])!==void 0&&t1(t=>({...t,requiredAgeRange:[e[0],e[1]]})),minStepsBetweenThumbs:1,label:"Required Age Range",help:"Streams with age outside this range will be excluded"}),(0,r.jsxs)("div",{className:"flex justify-between mt-1 text-xs text-[--muted]",children:[(0,r.jsx)("span",{children:mx((null==(k=t0.requiredAgeRange)?void 0:k[0])||0)}),(0,r.jsx)("span",{children:mx((null==(S=t0.requiredAgeRange)?void 0:S[1])||155520)})]})]}),(0,r.jsxs)("div",{className:"flex gap-2 md:w-[240px] shrink-0",children:[(0,r.jsx)(nn,{label:"Min",step:24,value:(null==(C=t0.requiredAgeRange)?void 0:C[0])||0,min:0,max:(null==(_=t0.requiredAgeRange)?void 0:_[1])||155520,onValueChange:e=>void 0!==e&&t1(t=>{var s;return{...t,requiredAgeRange:[e,(null==(s=t.requiredAgeRange)?void 0:s[1])||155520]}})}),(0,r.jsx)(nn,{label:"Max",step:24,value:(null==(R=t0.requiredAgeRange)?void 0:R[1])||155520,min:(null==(A=t0.requiredAgeRange)?void 0:A[0])||0,max:155520,onValueChange:e=>void 0!==e&&t1(t=>{var s;return{...t,requiredAgeRange:[(null==(s=t.requiredAgeRange)?void 0:s[0])||0,e]}})})]})]}),"pro"===tQ&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex flex-col md:flex-row gap-4",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)(uF,{min:0,max:155520,step:24,defaultValue:[0,155520],value:t0.excludeAgeRange||[0,155520],onValueChange:e=>void 0!==e&&(null==e?void 0:e[0])!==void 0&&(null==e?void 0:e[1])!==void 0&&t1(t=>({...t,excludeAgeRange:[e[0],e[1]]})),minStepsBetweenThumbs:1,label:"Excluded Age Range",help:"Streams with age in this range will be excluded"}),(0,r.jsxs)("div",{className:"flex justify-between mt-1 text-xs text-[--muted]",children:[(0,r.jsx)("span",{children:mx((null==(T=t0.excludeAgeRange)?void 0:T[0])||0)}),(0,r.jsx)("span",{children:mx((null==(I=t0.excludeAgeRange)?void 0:I[1])||155520)})]})]}),(0,r.jsxs)("div",{className:"flex gap-2 md:w-[240px] shrink-0",children:[(0,r.jsx)(nn,{label:"Min",step:24,value:(null==(M=t0.excludeAgeRange)?void 0:M[0])||0,min:0,max:(null==(D=t0.excludeAgeRange)?void 0:D[1])||155520,onValueChange:e=>void 0!==e&&t1(t=>{var s;return{...t,excludeAgeRange:[e,(null==(s=t.excludeAgeRange)?void 0:s[1])||155520]}})}),(0,r.jsx)(nn,{label:"Max",step:24,value:(null==(L=t0.excludeAgeRange)?void 0:L[1])||155520,min:(null==($=t0.excludeAgeRange)?void 0:$[0])||0,max:155520,onValueChange:e=>void 0!==e&&t1(t=>{var s;return{...t,excludeAgeRange:[(null==(s=t.excludeAgeRange)?void 0:s[0])||0,e]}})})]})]}),(0,r.jsxs)("div",{className:"flex flex-col md:flex-row gap-4",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)(uF,{min:0,max:155520,step:24,defaultValue:[0,155520],value:t0.includeAgeRange||[0,155520],onValueChange:e=>void 0!==e&&(null==e?void 0:e[0])!==void 0&&(null==e?void 0:e[1])!==void 0&&t1(t=>({...t,includeAgeRange:[e[0],e[1]]})),minStepsBetweenThumbs:1,label:"Included Age Range",help:"Streams with age in this range will be included even if they would be excluded otherwise"}),(0,r.jsxs)("div",{className:"flex justify-between mt-1 text-xs text-[--muted]",children:[(0,r.jsx)("span",{children:mx((null==(O=t0.includeAgeRange)?void 0:O[0])||0)}),(0,r.jsx)("span",{children:mx((null==(F=t0.includeAgeRange)?void 0:F[1])||155520)})]})]}),(0,r.jsxs)("div",{className:"flex gap-2 md:w-[240px] shrink-0",children:[(0,r.jsx)(nn,{label:"Min",step:24,value:(null==(z=t0.includeAgeRange)?void 0:z[0])||0,min:0,max:(null==(V=t0.includeAgeRange)?void 0:V[1])||155520,onValueChange:e=>void 0!==e&&t1(t=>{var s;return{...t,includeAgeRange:[e,(null==(s=t.includeAgeRange)?void 0:s[1])||155520]}})}),(0,r.jsx)(nn,{label:"Max",step:24,value:(null==(q=t0.includeAgeRange)?void 0:q[1])||155520,min:(null==(B=t0.includeAgeRange)?void 0:B[0])||0,max:155520,onValueChange:e=>void 0!==e&&t1(t=>{var s;return{...t,includeAgeRange:[(null==(s=t.includeAgeRange)?void 0:s[0])||0,e]}})})]})]})]})]}),(0,r.jsx)("div",{className:"space-y-4",children:(0,r.jsx)(ne,{label:"Stream Types",emptyMessage:"There aren't any stream types to choose from...",options:["debrid","usenet","p2p"].map(e=>({label:e,value:e})),defaultValue:["usenet"],value:t0.ageRangeTypes||["usenet"],onValueChange:e=>{t1(t=>({...t,ageRangeTypes:e}))},help:"Stream types that will use the age ranges defined above. Leave blank to apply to all stream types.",multiple:!0})})]})})]})}),(0,r.jsx)(rq,{id:"filter-tab-matching",value:"matching",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(mg,{heading:"Matching"}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)(cr,{id:"titleMatching",title:"Title Matching",description:"Any streams which don't specifically match the requested title will be filtered out. You can optionally choose to only apply it to specific request types and addons. This requires a TMDB Read Access Token to be set in the Services menu.",children:[(0,r.jsx)(rs,{label:"Enabled",side:"right",value:(null==(K=t0.titleMatching)?void 0:K.enabled)??!1,onValueChange:e=>{t1(t=>({...t,titleMatching:{...t.titleMatching||{},enabled:e}}))}}),(0,r.jsx)(rn,{disabled:!(null==(H=t0.titleMatching)?void 0:H.enabled),label:"Matching Mode",options:["exact","contains"].map(e=>({label:e,value:e})),defaultValue:"exact",value:null==(G=t0.titleMatching)?void 0:G.mode,help:(null==(W=t0.titleMatching)?void 0:W.mode)==="contains"?"Streams whose detected title doesn't contain the requested title will be excluded":"Streams whose detected title doesn't match the requested title exactly will be excluded",onValueChange:e=>{t1(t=>({...t,titleMatching:{...t.titleMatching,mode:e}}))}}),(0,r.jsx)(rn,{disabled:!(null==(Y=t0.titleMatching)?void 0:Y.enabled),label:"Ambiguous Results",options:[{label:"keep",value:"keep"},{label:"discard",value:"discard"}],defaultValue:"keep",value:null==(J=t0.titleMatching)?void 0:J.ambiguousResults,help:"What to do with results that can't be told apart from a same-name series (reboots and country variants, e.g. The Office UK vs US). 'discard' keeps only results whose year, country tag or episode title confirms the requested series.",onValueChange:e=>{t1(t=>({...t,titleMatching:{...t.titleMatching,ambiguousResults:e}}))}}),(0,r.jsxs)("div",{className:"flex gap-4",children:[(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(uF,{label:"Similarity Threshold",help:"The minimum similarity threshold required for a title to be considered a match. Lower values allow more leniency whereas higher values are more strict.",moreHelp:"The similarity is calculated using the Levenshtein distance algorithm.",disabled:!(null==(Z=t0.titleMatching)?void 0:Z.enabled),value:[(null==(Q=t0.titleMatching)?void 0:Q.similarityThreshold)??.85],min:0,max:1,step:.
1601,defaultValue:[.85],onValueChange:e=>{t1(t=>({...t,titleMatching:{...t.titleMatching,similarityThreshold:e[0]}}))}})}),(0,r.jsx)("div",{className:"w-24",children:(0,r.jsx)(nn,{label:"Value",step:.01,value:(null==(X=t0.titleMatching)?void 0:X.similarityThreshold)??.85,min:0,max:1,disabled:!(null==(ee=t0.titleMatching)?void 0:ee.enabled),onValueChange:e=>{void 0!==e&&t1(t=>({...t,titleMatching:{...t.titleMatching,similarityThreshold:e}}))}})})]}),(0,r.jsx)("div",{className:"space-y-4",children:(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,r.jsx)(ne,{multiple:!0,disabled:!(null==(et=t0.titleMatching)?void 0:et.enabled),label:"Request Types",emptyMessage:"There aren't any request types to choose from...",help:"Request types that will use title matching. Leave blank to apply to all request types.",options:sY.map(e=>({label:e,value:e,textValue:e})),value:null==(es=t0.titleMatching)?void 0:es.requestTypes,onValueChange:e=>{t1(t=>({...t,titleMatching:{...t.titleMatching,requestTypes:e}}))}}),(0,r.jsx)(ne,{multiple:!0,disabled:!(null==(ea=t0.titleMatching)?void 0:ea.enabled),label:"Addons",help:"Addons that will use strict title matching. Leave blank to apply to all addons.",emptyMessage:"You haven't installed any addons yet...",options:t0.presets.map(e=>({label:e.options.name||e.type,textValue:e.options.name||e.type,value:e.instanceId})),value:(null==(er=t0.titleMatching)?void 0:er.addons)||[],onValueChange:e=>{t1(t=>({...t,titleMatching:{...t.titleMatching,addons:e}}))}})]})})]}),(0,r.jsxs)(cr,{id:"yearMatching",title:"Year Matching",description:"Any streams which don't specifically match the requested year will be filtered out. You can optionally choose to only apply it to specific request types and addons",children:[(0,r.jsx)(rs,{label:"Enable",side:"right",value:(null==(en=t0.yearMatching)?void 0:en.enabled)??!1,onValueChange:e=>{t1(t=>({...t,yearMatching:{...t.yearMatching,enabled:e}}))}}),(0,r.jsx)(rs,{label:"Strict",side:"right",help:"Filter out streams for movies that don't have a year specified.",moreHelp:"Disabling this will allow streams without a year to be included in the results.",disabled:!(null==(el=t0.yearMatching)?void 0:el.enabled),value:(null==(ei=t0.yearMatching)?void 0:ei.strict)??!0,onValueChange:e=>{t1(t=>({...t,yearMatching:{...t.yearMatching,strict:e}}))}}),(0,r.jsx)(ne,{multiple:!0,disabled:!(null==(eo=t0.yearMatching)?void 0:eo.enabled)||(null==(ed=t0.yearMatching)?void 0:ed.strict)===!1,label:"Strict Request Types",emptyMessage:"There aren't any request types to choose from...",help:"Request types where streams without a year are filtered out. Defaults to movie only, as series results usually don't include a year.",options:sY.map(e=>({label:e,value:e,textValue:e})),value:(null==(ec=t0.yearMatching)?void 0:ec.strictTypes)??["movie"],onValueChange:e=>{t1(t=>({...t,yearMatching:{...t.yearMatching,strictTypes:e}}))}}),(0,r.jsx)(rs,{label:"Use Initial Air Date",side:"right",help:"For series/anime, compare against only the initial air year instead of the full year range.",moreHelp:"Helps filter out same-title-different-show results (e.g. 'One Piece 2023' live-action vs 'One Piece 1999' anime). May also filter torrents that include a season air year in their name.",disabled:!(null==(eu=t0.yearMatching)?void 0:eu.enabled),value:(null==(em=t0.yearMatching)?void 0:em.useInitialAirDate)??!1,onValueChange:e=>{t1(t=>({...t,yearMatching:{...t.yearMatching,useInitialAirDate:e}}))}}),(0,r.jsx)(nn,{label:"Year Tolerance",disabled:!(null==(ep=t0.yearMatching)?void 0:ep.enabled),value:(null==(eh=t0.yearMatching)?void 0:eh.tolerance)??1,onValueChange:e=>{t1(t=>({...t,yearMatching:{...t.yearMatching,tolerance:e}}))},min:0,max:100,help:"The number of years to tolerate when matching years. For example, if the year tolerance is 5, then a stream with a year of 2020 will match a request for 2025."}),(0,r.jsx)("div",{className:"space-y-4",children:(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,r.jsx)(ne,{multiple:!0,disabled:!(null==(ex=t0.yearMatching)?void 0:ex.enabled),label:"Request Types",emptyMessage:"There aren't any request types to choose from...",help:"Request types that will use year matching. Leave blank to apply to all request types.",options:sY.map(e=>({label:e,value:e,textValue:e})),value:null==(eg=t0.yearMatching)?void 0:eg.requestTypes,onValueChange:e=>{t1(t=>({...t,yearMatching:{...t.yearMatching,requestTypes:e}}))}}),(0,r.jsx)(ne,{multiple:!0,disabled:!(null==(ef=t0.yearMatching)?void 0:ef.enabled),label:"Addons",help:"Addons that will use year matching. Leave blank to apply to all addons.",emptyMessage:"You haven't installed any addons yet...",options:t0.presets.map(e=>({label:e.options.name||e.type,textValue:e.options.name||e.type,value:e.instanceId})),value:(null==(eb=t0.yearMatching)?void 0:eb.addons)||[],onValueChange:e=>{t1(t=>({...t,yearMatching:{...t.yearMatching,addons:e}}))}})]})})]}),(0,r.jsxs)(cr,{id:"seasonEpisodeMatching",title:"Season/Episode Matching",description:"Any streams which don't specifically match the requested season/episode will be filtered out. You can optionally choose to only apply it to specific request types and addons",children:[(0,r.jsx)(rs,{label:"Enabled",side:"right",value:(null==(ev=t0.seasonEpisodeMatching)?void 0:ev.enabled)??!1,onValueChange:e=>{t1(t=>({...t,seasonEpisodeMatching:{...t.seasonEpisodeMatching||{},enabled:e}}))}}
16),(0,r.jsx)(rs,{label:"Strict",side:"right",help:"Filter out streams for series that don't have any season or episode specified.",moreHelp:"Disabling this will allow streams without a season or episode to be included in the results.",disabled:!(null==(ey=t0.seasonEpisodeMatching)?void 0:ey.enabled),value:(null==(ej=t0.seasonEpisodeMatching)?void 0:ej.strict)??!1,onValueChange:e=>{t1(t=>({...t,seasonEpisodeMatching:{...t.seasonEpisodeMatching,strict:e}}))}}),(0,r.jsx)("div",{className:"space-y-4",children:(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,r.jsx)(ne,{multiple:!0,disabled:!(null==(ew=t0.seasonEpisodeMatching)?void 0:ew.enabled),label:"Request Types",help:"Request types that will use season/episode matching. Leave blank to apply to all request types.",emptyMessage:"There aren't any request types to choose from...",options:sY.map(e=>({label:e,value:e,textValue:e})),value:null==(eN=t0.seasonEpisodeMatching)?void 0:eN.requestTypes,onValueChange:e=>{t1(t=>({...t,seasonEpisodeMatching:{...t.seasonEpisodeMatching,requestTypes:e}}))}}),(0,r.jsx)(ne,{multiple:!0,disabled:!(null==(ek=t0.seasonEpisodeMatching)?void 0:ek.enabled),label:"Addons",help:"Addons that will use season/episode matching. Leave blank to apply to all addons.",emptyMessage:"You haven't installed any addons yet...",options:t0.presets.map(e=>({label:e.options.name||e.type,textValue:e.options.name||e.type,value:e.instanceId})),value:(null==(eS=t0.seasonEpisodeMatching)?void 0:eS.addons)||[],onValueChange:e=>{t1(t=>({...t,seasonEpisodeMatching:{...t.seasonEpisodeMatching,addons:e}}))}})]})})]}),(0,r.jsxs)(cr,{id:"episodeTitleMatching",title:"Episode Title Matching",description:"Any streams whose release name carries an episode title that doesn't match the requested episode's title will be filtered out. Streams without an episode title are unaffected. Helps tell apart same-name series (e.g. The Office UK vs US) whose episode titles differ. You can optionally choose to only apply it to specific request types and addons.",children:[(0,r.jsx)(rs,{label:"Enabled",side:"right",value:(null==(eC=t0.episodeTitleMatching)?void 0:eC.enabled)??!1,onValueChange:e=>{t1(t=>({...t,episodeTitleMatching:{...t.episodeTitleMatching||{},enabled:e}}))}}),(0,r.jsxs)("div",{className:"flex gap-4",children:[(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(uF,{label:"Similarity Threshold",help:"The minimum similarity threshold required for an episode title to be considered a match. Lower values allow more leniency whereas higher values are more strict.",disabled:!(null==(e_=t0.episodeTitleMatching)?void 0:e_.enabled),value:[(null==(eR=t0.episodeTitleMatching)?void 0:eR.similarityThreshold)??.8],min:0,max:1,step:.01,defaultValue:[.8],onValueChange:e=>{t1(t=>({...t,episodeTitleMatching:{...t.episodeTitleMatching,similarityThreshold:e[0]}}))}})}),(0,r.jsx)("div",{className:"w-24",children:(0,r.jsx)(nn,{label:"Value",step:.01,value:(null==(eA=t0.episodeTitleMatching)?void 0:eA.similarityThreshold)??.8,min:0,max:1,disabled:!(null==(eT=t0.episodeTitleMatching)?void 0:eT.enabled),onValueChange:e=>{void 0!==e&&t1(t=>({...t,episodeTitleMatching:{...t.episodeTitleMatching,similarityThreshold:e}}))}})})]}),(0,r.jsx)("div",{className:"space-y-4",children:(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,r.jsx)(ne,{multiple:!0,disabled:!(null==(eI=t0.episodeTitleMatching)?void 0:eI.enabled),label:"Request Types",help:"Request types that will use episode title matching. Leave blank to apply to all request types.",emptyMessage:"There aren't any request types to choose from...",options:sY.map(e=>({label:e,value:e,textValue:e})),value:null==(eE=t0.episodeTitleMatching)?void 0:eE.requestTypes,onValueChange:e=>{t1(t=>({...t,episodeTitleMatching:{...t.episodeTitleMatching,requestTypes:e}}))}}),(0,r.jsx)(ne,{multiple:!0,disabled:!(null==(eM=t0.episodeTitleMatching)?void 0:eM.enabled),label:"Addons",help:"Addons that will use episode title matching. Leave blank to apply to all addons.",emptyMessage:"You haven't installed any addons yet...",options:t0.presets.map(e=>({label:e.options.name||e.type,textValue:e.options.name||e.type,value:e.instanceId}
16)),value:(null==(eP=t0.episodeTitleMatching)?void 0:eP.addons)||[],onValueChange:e=>{t1(t=>({...t,episodeTitleMatching:{...t.episodeTitleMatching,addons:e}}))}})]})})]}),(0,r.jsxs)(cr,{id:"languageInference",title:"Language Inference",description:"When a stream declares no language of its own, the language of the metadata title it matched is added to it. A source only contributes while its own filter is running, so Title needs Title Matching enabled and Episode Title needs Episode Title Matching enabled. Inference also happens after the language filters, so an inferred language reaches the formatter, sorting and stream expressions, but cannot be filtered on in the same request.",children:[(0,r.jsx)(rs,{label:"Enabled",side:"right",value:(null==(eD=t0.languageInference)?void 0:eD.enabled)??!0,onValueChange:e=>{t1(t=>({...t,languageInference:{...t.languageInference||{},enabled:e}}))}}),(0,r.jsx)(ne,{multiple:!0,disabled:(null==(eL=t0.languageInference)?void 0:eL.enabled)===!1,label:"Sources",emptyMessage:"There aren't any sources to choose from...",help:"Which matched title may contribute a language, on top of that title's own filter being enabled. Leave blank to allow both. Episode titles are the stronger signal, as a series title is often identical across languages.",options:[{label:"Title",value:"title",textValue:"Title"},{label:"Episode Title",value:"episodeTitle",textValue:"Episode Title"}],value:(null==(eU=t0.languageInference)?void 0:eU.sources)||[],onValueChange:e=>{t1(t=>({...t,languageInference:{...t.languageInference,sources:e}}))}})]})]})]})}),(0,r.jsx)(rq,{id:"filter-tab-stream-expression",value:"stream-expression",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(mg,{heading:"Stream Expression"}),(0,r.jsx)("div",{className:"mb-4",children:(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"Create advanced filters to exclude, prefer or require specific streams from your results using stream expressions. Write expressions that evaluate which streams to select based on properties like addon type, quality, size, or any other stream attributes. Multiple expressions can be combined using logical operators for precise filtering control. You can also use ternary operators to apply conditional logic to the streams."})}),(0,r.jsx)("div",{className:"mb-4 space-y-4",children:(null==tZ?void 0:tZ.settings.selSyncAccess.level)==="trusted"&&(t0.trusted?(0,r.jsx)(nU,{intent:"success",title:"Trusted User",description:(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("p",{children:"You are a trusted user. You can sync expressions from any URL."}),(null==tZ?void 0:tZ.settings.selSyncAccess.trustedUrls)&&tZ.settings.selSyncAccess.trustedUrls.length>0&&(0,r.jsx)("div",{className:"flex flex-row flex-wrap gap-2",children:(0,r.jsx)(w,{intent:"primary-outline",size:"sm",onClick:t9.open,children:"View Whitelisted Sync URLs"})})]})}):(0,r.jsx)(nU,{intent:"info",title:"Trusted Users Only",description:(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("p",{children:["Syncing stream expressions from arbitrary URLs is only available to trusted users. You can only sync from whitelisted URLs. If you are the owner of the instance, you can add your UUID to the"," ",(0,r.jsx)("code",{className:"font-mono",children:"TRUSTED_UUIDS"})," ","environment variable."]}),(null==tZ?void 0:tZ.settings.selSyncAccess.trustedUrls)&&tZ.settings.selSyncAccess.trustedUrls.length>0&&(0,r.jsx)("div",{className:"flex flex-row flex-wrap gap-2",children:(0,r.jsx)(w,{intent:"primary-outline",size:"sm",onClick:t9.open,children:"View Whitelisted Sync URLs"})})]})}))}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(cr,{title:"Help",children:(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("p",{className:"text-sm text-[--muted]",children:["This filter uses AIOStreams'"," ",(0,r.jsx)("a",{href:"https://docs.aiostreams.viren070.me/reference/stream-expressions",target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",children:"stream expression language"}),", the same syntax used in the Groups system. The difference here is that you only have the"," ",(0,r.jsx)("code",{children:"streams"})," constant containing all available streams"]}
16),(0,r.jsxs)("div",{className:"text-sm text-[--muted]",children:[(0,r.jsx)("p",{className:"font-medium mb-2",children:"How it works:"}),(0,r.jsxs)("ul",{className:"list-disc list-inside space-y-1 ml-2",children:[(0,r.jsx)("li",{children:"Your expression should return an array of streams"}),(0,r.jsxs)("li",{children:["Use functions like ",(0,r.jsx)("code",{children:"addon()"}),","," ",(0,r.jsx)("code",{children:"type()"}),", ",(0,r.jsx)("code",{children:"quality()"})," to filter streams"]}),(0,r.jsx)("li",{children:"Combine multiple attributes together using nested functions"}),(0,r.jsxs)("li",{children:["Apply conditional logic using ternary operators"," ",(0,r.jsx)("code",{children:"expression ? arrayIfTrue : arrayIfFalse"})," ","where the two arrays can be replaced with true or false for all streams and no streams respectively."]})]})]}),(0,r.jsxs)("p",{className:"text-sm text-[--muted]",children:[(0,r.jsx)("strong",{children:"Example:"})," ",(0,r.jsx)("code",{children:"addon(type(streams, 'debrid'), 'TorBox')"})," ","excludes all TorBox debrid streams."]}),(0,r.jsxs)("p",{className:"text-sm text-[--muted]",children:["For detailed syntax and available functions, see the"," ",(0,r.jsx)("a",{href:"https://docs.aiostreams.viren070.me/reference/stream-expressions#function-reference",target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:underline",children:"Full function reference"})]})]})}),(0,r.jsx)(u9,{title:"Required Stream Expressions",description:"The expressions to apply to the streams. Streams selected by any of these expressions will be required to be in the results.",placeholder:"addon(type(streams, 'debrid'), 'TorBox')",values:t0.requiredStreamExpressions||[],onValuesChange:e=>{t1(t=>({...t,requiredStreamExpressions:e}))},onExpressionChange:(e,t)=>
16{t1(s=>({...s,requiredStreamExpressions:[...(s.requiredStreamExpressions||[]).slice(0,t),{...(s.requiredStreamExpressions||[])[t],expression:e},...(s.requiredStreamExpressions||[]).slice(t+1)]}))},onEnabledChange:(e,t)=>{t1(s=>({...s,requiredStreamExpressions:[...(s.requiredStreamExpressions||[]).slice(0,t),{...(s.requiredStreamExpressions||[])[t],enabled:e},...(s.requiredStreamExpressions||[]).slice(t+1)]}))},...t8("syncedRequiredStreamExpressionUrls")}),(0,r.jsx)(u9,{title:"Excluded Stream Expressions",description:"The expressions to apply to the streams. Streams selected by any of these expressions will be excluded from the results.",placeholder:"addon(type(streams, 'debrid'), 'TorBox')",values:t0.excludedStreamExpressions||[],onValuesChange:e=>{t1(t=>({...t,excludedStreamExpressions:e}))},onExpressionChange:(e,t)=>{t1(s=>({...s,excludedStreamExpressions:[...(s.excludedStreamExpressions||[]).slice(0,t),{...(s.excludedStreamExpressions||[])[t],expression:e},...(s.excludedStreamExpressions||[]).slice(t+1)]}))},onEnabledChange:(e,t)=>
16{t1(s=>({...s,excludedStreamExpressions:[...(s.excludedStreamExpressions||[]).slice(0,t),{...(s.excludedStreamExpressions||[])[t],enabled:e},...(s.excludedStreamExpressions||[]).slice(t+1)]}))},...t8("syncedExcludedStreamExpressionUrls")}),(0,r.jsx)(u9,{title:"Included Stream Expressions",description:"The expressions to apply to the streams. Streams selected by any of these expressions will be included in the results.",placeholder:"addon(type(streams, 'debrid'), 'TorBox')",values:t0.includedStreamExpressions||[],onValuesChange:e=>{t1(t=>({...t,includedStreamExpressions:e}))},onExpressionChange:(e,t)=>{t1(s=>({...s,includedStreamExpressions:[...(s.includedStreamExpressions||[]).slice(0,t),{...(s.includedStreamExpressions||[])[t],expression:e},...(s.includedStreamExpressions||[]).slice(t+1)]}))},onEnabledChange:(e,t)=>{t1(s=>({...s,includedStreamExpressions:[...(s.includedStreamExpressions||[]).slice(0,t),{...(s.includedStreamExpressions||[])[t],enabled:e},...(s.includedStreamExpressions||[]).slice(t+1)]}))},...t8("syncedIncludedStreamExpressionUrls")}),(0,r.jsx)(u9,{title:"Preferred Stream Expressions",description:"The expressions to apply to the streams. Streams selected by these expressions will be preferred over other streams and ranked by the order they are in this list.",placeholder:"addon(type(streams, 'debrid'), 'TorBox')",values:t0.preferredStreamExpressions||[],onValuesChange:e=>{t1(t=>({...t,preferredStreamExpressions:e}))},onExpressionChange:(e,t)=>
16{t1(s=>({...s,preferredStreamExpressions:[...(s.preferredStreamExpressions||[]).slice(0,t),{...(s.preferredStreamExpressions||[])[t],expression:e},...(s.preferredStreamExpressions||[]).slice(t+1)]}))},onEnabledChange:(e,t)=>{t1(s=>({...s,preferredStreamExpressions:[...(s.preferredStreamExpressions||[]).slice(0,t),{...(s.preferredStreamExpressions||[])[t],enabled:e},...(s.preferredStreamExpressions||[]).slice(t+1)]}))},...t8("syncedPreferredStreamExpressionUrls")}),(0,r.jsx)(u7,{title:"Ranked Stream Expressions",description:"Add expressions with scores. All matching expressions accumulate their scores on each stream. Use negative scores to penalize matches. Sort by 'Stream Expression Score' to order by the total.",values:t0.rankedStreamExpressions||[],onValuesChange:e=>{t1(t=>({...t,rankedStreamExpressions:e}))},onExpressionChange:(e,t)=>{t1(s=>({...s,rankedStreamExpressions:[...(s.rankedStreamExpressions||[]).slice(0,t),{...(s.rankedStreamExpressions||[])[t],expression:e},...(s.rankedStreamExpressions||[]).slice(t+1)]}))},onScoreChange:(e,t)=>
16{t1(s=>({...s,rankedStreamExpressions:[...(s.rankedStreamExpressions||[]).slice(0,t),{...(s.rankedStreamExpressions||[])[t],score:e},...(s.rankedStreamExpressions||[]).slice(t+1)]}))},onEnabledChange:(e,t)=>{t1(s=>({...s,rankedStreamExpressions:[...(s.rankedStreamExpressions||[]).slice(0,t),{...(s.rankedStreamExpressions||[])[t],enabled:e},...(s.rankedStreamExpressions||[]).slice(t+1)]}))},...t8("syncedRankedStreamExpressionUrls")})]})]})}),(0,r.jsx)(rq,{id:"filter-tab-keyword",value:"keyword",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(mg,{heading:"Keyword"}),(0,r.jsx)("div",{className:"mb-4",children:(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"Filter your streams by keywords - words or phrases that must appear in the filename, folder name, indexer, or release group"})}),(0,r.jsxs)("div",{className:"space-y-4",children:["pro"===tQ&&(0,r.jsx)(u4,{label:"Required Keywords",help:"Streams that do not contain any of these keywords will be excluded",itemName:"Keyword",values:t0.requiredKeywords||[],onValuesChange:e=>{t1(t=>({...t,requiredKeywords:e}))}}),(0,r.jsx)(u4,{label:"Excluded Keywords",help:"Streams that contain any of these keywords will be excluded",itemName:"Keyword",values:t0.excludedKeywords||[],onValuesChange:e=>{t1(t=>({...t,excludedKeywords:e}))}}),"pro"===tQ&&(0,r.jsx)(u4,{label:"Included Keywords",help:"Streams that contain any of these keywords will be included, ignoring ANY other exclude/required filters, not just for this filter",itemName:"Keyword",values:t0.includedKeywords||[],onValuesChange:e=>{t1(t=>({...t,includedKeywords:e}))}}),(0,r.jsx)(u4,{label:"Preferred Keywords",help:"Streams that contain any of these keywords will be preferred",itemName:"Keyword",values:t0.preferredKeywords||[],onValuesChange:e=>{t1(t=>({...t,preferredKeywords:e}))}})]})]})}),(0,r.jsx)(rq,{id:"filter-tab-release-group",value:"release-group",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(mg,{heading:"Release Group"}),(0,r.jsx)("div",{className:"mb-4",children:(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"Filter your streams by release group - the group that released the content (e.g., SPARKS, NTb, FLUX, etc.)"})}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(u4,{label:"Required Release Groups",help:"Only streams from these release groups will be kept. Streams from other release groups will be excluded.",itemName:"Release Group",values:t0.requiredReleaseGroups||[],onValuesChange:e=>{t1(t=>({...t,requiredReleaseGroups:e}))}}),(0,r.jsx)(u4,{label:"Excluded Release Groups",help:"Streams from these release groups will be excluded",itemName:"Release Group",values:t0.excludedReleaseGroups||[],onValuesChange:e=>{t1(t=>({...t,excludedReleaseGroups:e}))}}),(0,r.jsx)(u4,{label:"Included Release Groups",help:"Streams from these release groups will be included, ignoring ANY other exclude/required filters, not just for this filter",itemName:"Release Group",values:t0.includedReleaseGroups||[],onValuesChange:e=>{t1(t=>({...t,includedReleaseGroups:e}))}}),(0,r.jsx)(u4,{label:"Preferred Release Groups",help:"Streams from these release groups will be sorted higher. The order matters - release groups at the top will be preferred over those below.",itemName:"Release Group",values:t0.preferredReleaseGroups||[],onValuesChange:e=>{t1(t=>({...t,preferredReleaseGroups:e}))}})]})]})}),(0,r.jsx)(rq,{id:"filter-tab-regex",value:"regex",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(mg,{heading:"Regex"}),(0,r.jsx)("div",{className:"mb-4",children:(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"Filter your streams by regular expressions that must match one of the following: filename, folder name, indexer, or release group"})}),(0,r.jsxs)("div",{className:"mb-4 space-y-4",children:[(null==tZ?void 0:tZ.settings.regexAccess.level)==="trusted"&&(t0.trusted?(0,r.jsx)(nU,{intent:"success",title:"Trusted User",description:(0,r.jsx)("p",{children:"You are a trusted user. You have full access to regex filters."})}):(0,r.jsx)(nU,{intent:"info",title:"Trusted Users Only",description:(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("p",{children:["Regex filters are only available to trusted users due to the potential for abuse. If you are the owner of the instance, you can add your UUID to the"," ",(0,r.jsx)("code",{className:"font-mono",children:"TRUSTED_UUIDS"})," ","environment variable."]})})})),((null==tZ||null==(eO=tZ.settings.regexAccess.patterns)?void 0:eO.length)||(null==tZ||null==(eF=tZ.settings.regexAccess.urls)?void 0:eF.length))&&(0,r.jsx)(nU,{intent:"info",title:"Allowed Regex Patterns",description:(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"max-w-full overflow-hidden",children:[(0,r.jsx)("p",{className:"break-words",children:"This instance has allowed a specific set of regexes to be used by all users."}),(null==tZ?void 0:tZ.settings.regexAccess.description)&&(0,r.jsx)("div",{className:"mt-2 break-words overflow-hidden",children:(0,r.jsx)(nz,{children:(null==tZ?void 0:tZ.settings.regexAccess.description)||""})})]}),(0,r.jsxs)("div",{className:"flex flex-row flex-wrap gap-2",children:[(null==tZ?void 0:tZ.settings.regexAccess.urls)&&tZ.settings.regexAccess.urls.length>0&&(0,r.jsx)(w,{intent:"primary-outline",size:"sm",onClick:t4.open,children:"View Allowed Import URLs"}),(0,r.jsx)(w,{intent:"primary-outline",size:"sm",onClick:t5.open,children:"View Allowed Patterns"})]})]})})]}),(0,r.jsxs)("div",{className:"space-y-4",children:["pro"===tQ&&(0,r.jsx)(u4,{fieldName:"requiredRegexPatterns",label:"Required Regex",help:"Streams that do not match any of these regular expressions will be excluded",itemName:"Regex",values:t0.requiredRegexPatterns||[],onValuesChange:e=>{t1(t=>({...t,requiredRegexPatterns:e}))},...t8("syncedRequiredRegexUrls")}),(0,r.jsx)(u4,{label:"Excluded Regex",fieldName:"excludedRegexPatterns",help:"Streams that match any of these regular expressions will be excluded",itemName:"Regex",values:t0.excludedRegexPatterns||[],onValuesChange:e=>{t1(t=>({...t,excludedRegexPatterns:e}))},...t8("syncedExcludedRegexUrls")}),"pro"===tQ&&(0,r.jsx)(u4,{label:"Included Regex",fieldName:"includedRegexPatterns",help:"Streams that match any of these regular expressions will be included, ignoring other exclude/required filters",itemName:"Regex",values:t0.includedRegexPatterns||[],onValuesChange:e=>{t1(t=>({...t,includedRegexPatterns:e}))},...t8("syncedIncludedRegexUrls")}),(0,r.jsx)(u8,{title:"Preferred Regex Patterns",description:"Define regex patterns with names for easy reference",...t8("syncedPreferredRegexUrls"),keyName:"Name",keyId:"name",keyPlaceholder:"Enter pattern name",valueId:"pattern",valueName:"Pattern",valuePlaceholder:"Enter regex pattern",values:(t0.preferredRegexPatterns||[]).map(e=>({name:e.name,value:e.pattern}
16)),onValuesChange:e=>{t1(t=>({...t,preferredRegexPatterns:e.map(e=>({name:e.name,pattern:e.value}))}))},onValueChange:(e,t)=>{t1(s=>({...s,preferredRegexPatterns:[...(s.preferredRegexPatterns||[]).slice(0,t),{...(s.preferredRegexPatterns||[])[t],pattern:e},...(s.preferredRegexPatterns||[]).slice(t+1)]}))},onKeyChange:(e,t)=>{t1(s=>({...s,preferredRegexPatterns:[...(s.preferredRegexPatterns||[]).slice(0,t),{...(s.preferredRegexPatterns||[])[t],name:e},...(s.preferredRegexPatterns||[]).slice(t+1)]}))}}),(0,r.jsx)(me,{title:"Ranked Regex Patterns",description:"Add regex patterns with scores. Matches on filename only. Accumulates scores.",values:t0.rankedRegexPatterns||[],onValuesChange:e=>{t1(t=>({...t,rankedRegexPatterns:e}))},onPatternChange:(e,t)=>{t1(s=>({...s,rankedRegexPatterns:[...(s.rankedRegexPatterns||[]).slice(0,t),{...(s.rankedRegexPatterns||[])[t],pattern:e},...(s.rankedRegexPatterns||[]).slice(t+1)]}))},onNameChange:(e,t)=>{t1(s=>({...s,rankedRegexPatterns:[...(s.rankedRegexPatterns||[]).slice(0,t),{...(s.rankedRegexPatterns||[])[t],name:e},...(s.rankedRegexPatterns||[]).slice(t+1)]}))},onScoreChange:(e,t)=>
16{t1(s=>({...s,rankedRegexPatterns:[...(s.rankedRegexPatterns||[]).slice(0,t),{...(s.rankedRegexPatterns||[])[t],score:e},...(s.rankedRegexPatterns||[]).slice(t+1)]}))},...t8("syncedRankedRegexUrls")})]})]})}),(0,r.jsx)(rq,{id:"filter-tab-bitrate",value:"bitrate",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(mg,{heading:"Bitrate"}),(0,r.jsx)("div",{className:"mb-4",children:(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"Set minimum and maximum bitrate limits for movies, series, and anime series. You can set a global limit, and also choose to set specific limits for each resolution. For a given stream, only one set of bitrate filters would be used. A resolution specific limit takes priority. Anime series limits take precedence over regular series limits."})}),(0,r.jsx)(nU,{intent:"warning",className:"mb-4",title:"Bitrate Accuracy",description:"Bitrate values are estimates calculated from file size and duration. These represent average bitrates and may not reflect peak bitrates or exact encoding quality."}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("div",{className:"rounded-[--radius-md] border bg-[--background] p-4",children:(0,r.jsx)(rs,{label:"Use Runtime from Metadata Providers",side:"right",help:"When enabled, uses runtime data from metadata providers (like TMDB) for bitrate calculations as fallback. Note: This makes estimates less accurate as actual file durations often differ from metadata, and most files lack duration info, making sorting by bitrate similar to sorting by size.",value:(null==(ez=t0.bitrate)?void 0:ez.useMetadataRuntime)??!0,onValueChange:e=>{t1(t=>({...t,bitrate:{...t.bitrate,useMetadataRuntime:e}}))}})}),(0,r.jsx)(cr,{title:"Global",description:"Apply bitrate filters for movies, series, and anime series",children:(0,r.jsx)(mr,{label:"Global Bitrate Limits",help:"Set the minimum and maximum bitrate limits for all results",moviesValue:((null==(eq=t0.bitrate)||null==(eV=eq.global)?void 0:eV.movies)||[0,25e7]).map(e=>Math.min(e,25e7)),seriesValue:((null==(eK=t0.bitrate)||null==(eB=eK.global)?void 0:eB.series)||[0,25e7]).map(e=>Math.min(e,25e7)),animeValue:((null==(eG=t0.bitrate)||null==(eH=eG.global)?void 0:eH.anime)||[0,25e7]).map(e=>Math.min(e,25e7)),onMoviesChange:e=>{t1(t=>{var s;return{...t,bitrate:{...t.bitrate,global:{...null==(s=t.bitrate)?void 0:s.global,movies:e}}}})},onSeriesChange:e=>{t1(t=>{var s;return{...t,bitrate:{...t.bitrate,global:{...null==(s=t.bitrate)?void 0:s.global,series:e}}}})},onAnimeChange:e=>{t1(t=>{var s;return{...t,bitrate:{...t.bitrate,global:{...null==(s=t.bitrate)?void 0:s.global,anime:e}}}})}})}),"pro"===tQ&&(0,r.jsx)(cr,{title:"Resolution-Specific",description:"Set bitrate limits for specific resolutions",children:(0,r.jsx)("div",{className:"space-y-8",children:sL.map(e=>{var t,s,a,n,l,i,o,d,c;return(0,r.jsx)(mr,{label:e,help:`Set the minimum and maximum bitrate for ${e} results`,moviesValue:((null==(a=t0.bitrate)||null==(s=a.resolution)||null==(t=s[e])?void 0:t.movies)||[0,25e7]).map(e=>Math.min(e,25e7)),seriesValue:((null==(i=t0.bitrate)||null==(l=i.resolution)||null==(n=l[e])?void 0:n.series)||[0,25e7]).map(e=>Math.min(e,25e7)),animeValue:((null==(c=t0.bitrate)||null==(d=c.resolution)||null==(o=d[e])?void 0:o.anime)||[0,25e7]).map(e=>Math.min(e,25e7)),onMoviesChange:t=>{t1(s=>{var a,r,n;return{...s,bitrate:{...s.bitrate,resolution:{...null==(a=s.bitrate)?void 0:a.resolution,[e]:{...null==(n=s.bitrate)||null==(r=n.resolution)?void 0:r[e],movies:t}}}}})},onSeriesChange:t=>{t1(s=>{var a,r,n;return{...s,bitrate:{...s.bitrate,resolution:{...null==(a=s.bitrate)?void 0:a.resolution,[e]:{...null==(n=s.bitrate)||null==(r=n.resolution)?void 0:r[e],series:t}}}}})},onAnimeChange:t=>{t1(s=>{var a,r,n;return{...s,bitrate:{...s.bitrate,resolution:{...null==(a=s.bitrate)?void 0:a.resolution,[e]:{...null==(n=s.bitrate)||null==(r=n.resolution)?void 0:r[e],anime:t}}}}})}},e)})})})]})]})}),(0,r.jsx)(rq,{id:"filter-tab-size",value:"size",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(mg,{heading:"Size"}),(0,r.jsx)("div",{className:"mb-4",children:(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"Set minimum and maximum size limits for movies, series, and anime series. You can set a global limit, and also choose to set specific limits for each resolution. For a given stream, only one set of size filters would be used. A resolution specific limit takes priority. Anime series limits take precedence over regular series limits."})}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(cr,{title:"Global",description:"Apply size filters for movies, series, and anime series",children:(0,r.jsx)(ma,{label:"Global Size Limits",help:"Set the minimum and maximum size limits for all results",moviesValue:(null==(eY=t0.size)||null==(eW=eY.global)?void 0:eW.movies)||[0,1e11],seriesValue:(null==(eZ=t0.size)||null==(eJ=eZ.global)?void 0:eJ.series)||[0,1e11],animeValue:(null==(eX=t0.size)||null==(eQ=eX.global)?void 0:eQ.anime)||[0,1e11],onMoviesChange:e=>{t1(t=>{var s;return{...t,size:{...t.size,global:{...null==(s=t.size)?void 0:s.global,movies:e}}}})},onSeriesChange:e=>{t1(t=>{var s;return{...t,size:{...t.size,global:{...null==(s=t.size)?void 0:s.global,series:e}}}})},onAnimeChange:e=>{t1(t=>{var s;return{...t,size:{...t.size,global:{...null==(s=t.size)?void 0:s.global,anime:e}}}})}})}),"pro"===tQ&&(0,r.jsx)(cr,{title:"Resolution-Specific",description:"Set size limits for specific resolutions",children:(0,r.jsx)("div",{className:"space-y-8",children:sL.map(e=>{var t,s,a,n,l,i,o,d,c;return(0,r.jsx)(ma,{label:e,help:`Set the minimum and maximum size for ${e} results`,moviesValue:(null==(a=t0.size)||null==(s=a.resolution)||null==(t=s[e])?void 0:t.movies)||[0,1e11],seriesValue:(null==(i=t0.size)||null==(l=i.resolution)||null==(n=l[e])?void 0:n.series)||[0,1e11],animeValue:(null==(c=t0.size)||null==(d=c.resolution)||null==(o=d[e])?void 0:o.anime)||[0,1e11],onMoviesChange:t=>{t1(s=>{var a,r,n;return{...s,size:{...s.size,resolution:{...null==(a=s.size)?void 0:a.resolution,[e]:{...null==(n=s.size)||null==(r=n.resolution)?void 0:r[e],movies:t}}}}})},onSeriesChange:t=>{t1(s=>{var a,r,n;return{...s,size:{...s.size,resolution:{...null==(a=s.size)?void 0:a.resolution,[e]:{...null==(n=s.size)||null==(r=n.resolution)?void 0:r[e],series:t}}}}})},onAnimeChange:t=>{t1(s=>{var a,r,n;return{...s,size:{...s.size,resolution:{...null==(a=s.size)?void 0:a.resolution,[e]:{...null==(n=s.size)||null==(r=n.resolution)?void 0:r[e],anime:t}}}}})}},e)})})})]})]})}),(0,r.jsx)(rq,{id:"filter-tab-limit",value:"limit",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(mg,{heading:"Result Limits"}),(0,r.jsx)(cr,{description:"Apply limits to specific kinds of results",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(rn,{label:"Limit Mode",help:"Independent: each category limit is checked separately. Conjunctive: category limits are combined into a composite key (e.g. 3 per resolution per addon).",value:(null==(e0=t0.resultLimits)?void 0:e0.mode)??"independent",onValueChange:e=>{t1(t=>({...t,resultLimits:{...t.resultLimits,mode:e}}))},options:[{label:"Independent",value:"independent"},{label:"Conjunctive",value:"conjunctive"}]}),(0,r.jsx)(nn,{help:"Global limit for all results",label:"Global Limit",value:(null==(e1=t0.resultLimits)?void 0:e1.global)||void 0,min:0,defaultValue:void 0,onValueChange:e=>{t1(t=>({...t,resultLimits:{...t.resultLimits,global:e||void 0}}))}}),"pro"===tQ&&(0,r.jsx)(nn,{help:"Limit for results by service",label:"Service Limit",value:(null==(e2=t0.resultLimits)?void 0:e2.service)||void 0,min:0,defaultValue:void 0,onValueChange:e=>{t1(t=>({...t,resultLimits:{...t.resultLimits,service:e||void 0}}))}}),"pro"===tQ&&(0,r.jsx)(nn,{help:"Limit for results by addon",label:"Addon Limit",value:(null==(e3=t0.resultLimits)?void 0:e3.addon)||void 0,min:0,defaultValue:void 0,onValueChange:e=>{t1(t=>({...t,resultLimits:{...t.resultLimits,addon:e||void 0}}))}}),(0,r.jsx)(nn,{help:"Limit for results by resolution",label:"Resolution Limit",value:(null==(e6=t0.resultLimits)?void 0:e6.resolution)||void 0,min:0,defaultValue:void 0,onValueChange:e=>{t1(t=>({...t,resultLimits:{...t.resultLimits,resolution:e||void 0}}))}}),"pro"===tQ&&(0,r.jsx)(nn,{help:"Limit for results by quality",label:"Quality Limit",value:(null==(e5=t0.resultLimits)?void 0:e5.quality)||void 0,min:0,defaultValue:void 0,onValueChange:e=>{t1(t=>({...t,resultLimits:{...t.resultLimits,quality:e||void 0}}))}}),"pro"===tQ&&(0,r.jsx)(nn,{help:"Limit for results by indexer",label:"Indexer Limit",value:(null==(e4=t0.resultLimits)?void 0:e4.indexer)||void 0,min:0,defaultValue:void 0,onValueChange:e=>{t1(t=>({...t,resultLimits:{...t.resultLimits,indexer:e||void 0}}))}}),"pro"===tQ&&(0,r.jsx)(nn,{help:"Limit for results by release group",label:"Release Group Limit",value:(null==(e9=t0.resultLimits)?void 0:e9.releaseGroup)||void 0,min:0,defaultValue:void 0,onValueChange:e=>{t1(t=>({...t,resultLimits:{...t.resultLimits,releaseGroup:e||void 0}}))}})]})})]})}),(0,r.jsx)(rq,{id:"filter-tab-deduplicator",value:"deduplicator",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(mg,{heading:"Deduplicator"}),(0,r.jsx)("div",{className:"mb-4",children:(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"Enable and customise the removal of duplicate results."})}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(cr,{children:(0,r.jsx)(rs,{label:"Enable",side:"right",value:(null==(e8=t0.deduplicator)?void 0:e8.enabled)??!1,onValueChange:e=>{t1(t=>({...t,deduplicator:{...t.deduplicator,enabled:e}}))}})}),"pro"===tQ&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(cr,{title:"Group Handling",description:(0,r.jsx)("div",{children:"Sets of duplicates are separated into groups based on the streams' type. (e.g. cached, uncached, p2p, etc.) These options control how each set of duplicates are handled."}),children:[(0,r.jsxs)("div",{className:"mt-2 space-y-2",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"font-medium",children:"Single Result"}),(0,r.jsx)("p",{className:"text-sm text-[--muted] mt-1",children:"Keeps only one result from your highest priority service and highest priority addon. Enabled tiebreakers (torrent seeders, usenet age) are applied at the position configured below - either before or after addon order is considered."})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"font-medium",children:"Per Service"}),(0,r.jsx)("p",{className:"text-sm text-[--muted] mt-1",children:"This keeps one result per service, and choses each result using the same criteria above."})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"font-medium",children:"Per Addon"}),(0,r.jsx)("p",{className:"text-sm text-[--muted] mt-1",children:"This keeps one result per addon, and choses each result from your highest priority service, and for P2P/uncached results it looks at the number of seeders."})]})]}),(0,r.jsx)(rn,{disabled:!(null==(e7=t0.deduplicator)?void 0:e7.enabled),label:"Cached Results",value:(null==(te=t0.deduplicator)?void 0:te.cached)??"disabled",options:[{label:"Disabled",value:"disabled"},{label:"Single Result",value:"single_result"},{label:"Per Service",value:"per_service"},{label:"Per Addon",value:"per_addon"}],onValueChange:e=>{t1(t=>({...t,deduplicator:{...t.deduplicator,cached:e}}))}}),(0,r.jsx)(rn,{disabled:!(null==(tt=t0.deduplicator)?void 0:tt.enabled),label:"Uncached Results",value:(null==(ts=t0.deduplicator)?void 0:ts.uncached)??"disabled",options:[{label:"Disabled",value:"disabled"},{label:"Single Result",value:"single_result"},{label:"Per Service",value:"per_service"},{label:"Per Addon",value:"per_addon"}],onValueChange:e=>{t1(t=>({...t,deduplicator:{...t.deduplicator,uncached:e}}))}}),(0,r.jsx)(rn,{disabled:!(null==(ta=t0.deduplicator)?void 0:ta.enabled),label:"P2P Results",value:(null==(tr=t0.deduplicator)?void 0:tr.p2p)??"disabled",options:[{label:"Disabled",value:"disabled"},{label:"Single Result",value:"single_result"},{label:"Per Service",value:"per_service"},{label:"Per Addon",value:"per_addon"}],onValueChange:e=>{t1(t=>({...t,deduplicator:{...t.deduplicator,p2p:e}}))}})]}),(0,r.jsxs)(cr,{title:"Other",children:[(0,r.jsx)(ne,{disabled:!(null==(tn=t0.deduplicator)?void 0:tn.enabled),label:"Detection Methods",multiple:!0,help:"Select the methods used to detect duplicates",value:(null==(tl=t0.deduplicator)?void 0:tl.keys)??["filename","
16infoHash"],emptyMessage:"No detection methods available",onValueChange:e=>{t1(t=>({...t,deduplicator:{...t.deduplicator,keys:e}}))},options:sR.map(e=>({label:e,value:e}))}),((null==(ti=t0.deduplicator)?void 0:ti.keys)??["filename","infoHash"]).includes("smartDetect")&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ne,{disabled:!(null==(to=t0.deduplicator)?void 0:to.enabled),label:"Smart Detect Attributes",multiple:!0,help:"Choose which file attributes are used to identify duplicates when Smart Detect is enabled. Numeric attributes (size, bitrate) use a configurable percentage tolerance.",value:(null==(td=t0.deduplicator)?void 0:td.smartDetectAttributes)??sI,emptyMessage:"No attributes available",onValueChange:e=>{t1(t=>({...t,deduplicator:{...t.deduplicator,smartDetectAttributes:e}}))},options:sT.map(e=>({label:e,value:e}))}),["size","bitrate"].some(e=>{var t;return((null==(t=t0.deduplicator)?void 0:t.smartDetectAttributes)??sI).includes(e)})&&(0,r.jsx)(nn,{disabled:!(null==(tc=t0.deduplicator)?void 0:tc.enabled),label:"Numeric Rounding (%)",help:"Numeric attributes (size, bitrate) are bucketed using geometric rounding at this tolerance. Two values within roughly this percentage of each other are treated as equal. Higher = more lenient; lower = stricter.",min:1,max:50,step:1,value:(null==(tu=t0.deduplicator)?void 0:tu.smartDetectRounding)??10,onValueChange:e=>{void 0!==e&&t1(t=>({...t,deduplicator:{...t.deduplicator,smartDetectRounding:e}}))}})]}),(0,r.jsx)(ne,{help:"Addons selected here will always have their results kept during deduplication.",label:"Addon Exclusions",value:(null==(tm=t0.deduplicator)?void 0:tm.excludeAddons)??[],onValueChange:e=>{t1(t=>({...t,deduplicator:{...t.deduplicator,excludeAddons:e}}))},options:t0.presets.map(e=>({label:e.options.name||e.type,value:e.instanceId,textValue:e.options.name})),emptyMessage:"You haven't installed any addons...",placeholder:"Select addons...",multiple:!0,disabled:(null==(tp=t0.deduplicator)?void 0:tp.enabled)===!1}),(0,r.jsx)(rn,{label:"Multi-Group Behaviour",help:`Configure how duplicates across multiple types are handled. e.g. if a given duplicate set has both cached and uncached streams, what should be done.
17                      ${mf[(null==(th=t0.deduplicator)?void 0:th.multiGroupBehaviour)||mb]}
18                      `,value:(null==(tx=t0.deduplicator)?void 0:tx.multiGroupBehaviour)??mb,onValueChange:e=>{t1(t=>({...t,deduplicator:{...t.deduplicator,multiGroupBehaviour:e}}))},disabled:!(null==(tg=t0.deduplicator)?void 0:tg.enabled),options:[{label:"Conservative",value:"conservative"},{label:"Aggressive",value:"aggressive"},{label:"Keep All",value:"keep_all"}]}),(0,r.jsx)(rn,{label:"Library Stream Behaviour",help:"How to treat library streams when duplicates are found. 'Ignore': library streams have no special priority — normal service/addon order decides. 'Prefer': a library stream always beats a non-library stream head-to-head, even if the non-library stream is from a higher-priority addon. Other tiebreakers still apply between two library streams. 'Exclusive': if the group contains any library stream, all non-library streams are dropped before selection runs — only meaningful with Per Service or Per Addon modes where multiple winners are kept.",value:(null==(tf=t0.deduplicator)?void 0:tf.libraryBehaviour)??"ignore",onValueChange:e=>{t1(t=>({...t,deduplicator:{...t.deduplicator,libraryBehaviour:e}}))},disabled:!(null==(tb=t0.deduplicator)?void 0:tb.enabled),options:[{label:"Ignore",value:"ignore"},{label:"Prefer",value:"prefer"},{label:"Exclusive",value:"exclusive"}]}),sA.map(e=>{var t,s;let a=((null==(t=t0.deduplicator)?void 0:t.tiebreakers)??[{type:"torrent_seeders",position:"before_addon"},{type:"usenet_age",position:"before_addon"}]).find(t=>t.type===e),n=(null==a?void 0:a.position)??"disabled";return(0,r.jsx)(rn,{disabled:!(null==(s=t0.deduplicator)?void 0:s.enabled),label:"torrent_seeders"===e?"Torrent Seeders Tiebreaker":"Usenet Age Tiebreaker",help:"torrent_seeders"===e?"When choosing between duplicate P2P or uncached streams, prefer the one with more seeders. Controls where in the priority order this check runs relative to addon order.":"When choosing between duplicate Usenet streams, prefer the newer post (posts released within the last 24 hours are considered equal). Controls where in the priority order this check runs relative to addon order.",value:n??"before_addon",onValueChange:t=>{t1(s=>{var a;let r=((null==(a=s.deduplicator)?void 0:a.tiebreakers)??[{type:"torrent_seeders",position:"before_addon"},{type:"usenet_age",position:"after_addon"}]).filter(t=>t.type!==e),n="disabled"===t?r:[...r,{type:e,position:t}];return{...s,deduplicator:{...s.deduplicator,tiebreakers:n}}})},options:[{label:"Disabled",value:"disabled"},{label:"Before Addon Order",value:"before_addon"},{label:"After Addon Order",value:"after_addon"}]},e)})]}),(0,r.jsxs)(cr,{title:"Merge Duplicates",description:"Instead of just discarding duplicates, fold their info into the surviving result: extra same-release failover targets and richer metadata from other addons.",children:[(0,r.jsx)(rs,{label:"Enable Merging",side:"right",disabled:!(null==(tv=t0.deduplicator)?void 0:tv.enabled),value:(null==(tN=t0.deduplicator)||null==(tj=tN.merge)?void 0:tj.enabled)??!1,onValueChange:e=>{t1(t=>{var s;return{...t,deduplicator:{...t.deduplicator,merge:{...null==(s=t.deduplicator)?void 0:s.merge,enabled:e}}}})}}),(0,r.jsx)(rs,{label:"Harvest Failover Variants",side:"right",help:"Collect discarded duplicates' playback URLs as same-release failover targets, so failover can try another copy of the SAME release (e.g. a different indexer's NZB) before moving to a different release. Follows your Failover content-type settings.",disabled:!(null==(tk=t0.deduplicator)?void 0:tk.enabled)||!(null==(t_=t0.deduplicator)||null==(tS=t_.merge)?void 0:tS.enabled),value:(null==(tA=t0.deduplicator)||null==(tR=tA.merge)?void 0:tR.failoverVariants)??!1,onValueChange:e=>{t1(t=>{var s;return{...t,deduplicator:{...t.deduplicator,merge:{...null==(s=t.deduplicator)?void 0:s.merge,failoverVariants:e}}}})}}),(0,r.jsx)(ne,{label:"Merged Metadata Fields",multiple:!0,help:"Which metadata to merge from discarded duplicates into the kept result. Languages/subtitles are merged accuracy-aware: an addon's accurate audio/subtitle split is never overwritten by inaccurate filename-parsed guesses.",disabled:!(null==(tT=t0.deduplicator)?void 0:tT.enabled)||!(null==(tE=t0.deduplicator)||null==(tI=tE.merge)?void 0:tI.enabled),value:(null==(tP=t0.deduplicator)||null==(tM=tP.merge)?void 0:tM.fields)??[],emptyMessage:"No fields available",onValueChange:e=>{t1(t=>{var s;return{...t,deduplicator:{...t.deduplicator,merge:{...null==(s=t.deduplicator)?void 0:s.merge,fields:e}}}})},options:t3.map(e=>({label:e,value:e}))})]})]})]})]})}),(0,r.jsx)(rq,{id:"filter-tab-miscellaneous",value:"miscellaneous",className:"space-y-4",children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(mg,{heading:"Miscellaneous"}),(0,r.jsx)("div",{className:"mb-4",children:(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"Additional miscellaneous filters."})}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)(cr,{id:"digitalReleaseFilter",title:"Digital Release Filter",description:"This will filter out all results for movies that are determined to not have a digital release.",children:[(0,r.jsx)(rs,{label:"Enabled",side:"right",value:(null==(tD=t0.digitalReleaseFilter)?void 0:tD.enabled)??!1,onValueChange:e=>{t1(t=>({...t,digitalReleaseFilter:{...t.digitalReleaseFilter||{},enabled:e}}))}}),(0,r.jsxs)("div",{className:"flex gap-4",children:[(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(uF,{label:"Tolerance",moreHelp:"Ignore the digital release filter if the movie was released within this many days of the current date. This accounts for early releases, leaks, and server timezone differences.",disabled:!(null==(tL=t0.digitalReleaseFilter)?void 0:tL.enabled),value:[(null==(tU=t0.digitalReleaseFilter)?void 0:tU.tolerance)??0],min:0,max:365,step:1,defaultValue:[0],onValueChange:e=>{t1(t=>({...t,digitalReleaseFilter:{...t.digitalReleaseFilter,tolerance:e[0]}}))}})}),(0,r.jsx)("div",{className:"w-24",children:(0,r.jsx)(nn,{label:"Value",step:1,value:(null==(t$=t0.digitalReleaseFilter)?void 0:t$.tolerance)??0,min:0,max:365,disabled:!(null==(tO=t0.digitalReleaseFilter)?void 0:tO.enabled),onValueChange:e=>{void 0!==e&&t1(t=>({...t,digitalReleaseFilter:{...t.digitalReleaseFilter,tolerance:e}}))}})})]}),(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"Tolerance in days"}),(0,r.jsx)("div",{className:"space-y-4",children:(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,r.jsx)(ne,{multiple:!0,disabled:!(null==(tF=t0.digitalReleaseFilter)?void 0:tF.enabled),label:"Request Types",emptyMessage:"There aren't any request types to choose from...",help:"Request types that will use the digital release filter. Leave blank to apply to all request types.",options:sY.map(e=>({label:e,value:e,textValue:e})),value:null==(tz=t0.digitalReleaseFilter)?void 0:tz.requestTypes,onValueChange:e=>{t1(t=>({...t,digitalReleaseFilter:{...t.digitalReleaseFilter,requestTypes:e}}))}}),(0,r.jsx)(ne,{multiple:!0,disabled:!(null==(tV=t0.digitalReleaseFilter)?void 0:tV.enabled),label:"Addons",help:"Addons that will use the digital release filter. Leave blank to apply to all addons.",emptyMessage:"You haven't installed any addons yet...",options:t0.presets.map(e=>({label:e.options.name||e.type,textValue:e.options.name||e.type,value:e.instanceId})),value:(null==(tq=t0.digitalReleaseFilter)?void 0:tq.addons)||[],onValueChange:e=>{t1(t=>({...t,digitalReleaseFilter:{...t.digitalReleaseFilter,addons:e}}))}})]})}),(0,r.jsx)(rs,{label:"Show Info Stream When Filtered",side:"right",defaultValue:!0,disabled:!(null==(tB=t0.digitalReleaseFilter)?void 0:tB.enabled),value:(null==(tK=t0.digitalReleaseFilter)?void 0:tK.showInfoOnFilter)??!0,moreHelp:"When the digital release filter triggers, show an info stream.",onValueChange:e=>{t1(t=>({...t,digitalReleaseFilter:{...t.digitalReleaseFilter,showInfoOnFilter:e}}))}})]}),(0,r.jsx)(cr,{id:"enableSeadex",title:"SeaDex Integration",description:"Fetch SeaDex data (releases.moe) for anime to identify best quality releases.",children:(0,r.jsx)(rs,{label:"Enable",side:"right",value:t0.enableSeadex??!0,defaultValue:!0,onValueChange:e=>{t1(t=>({...t,enableSeadex:e}))}})}),"pro"===tQ&&t0.excludeSeasonPacks&&(0,r.jsx)(cr,{id:"excludeSeasonPacks",title:"Exclude Season Packs",de
18scription:"Whether to filter out results that contain entire seasons.",children:(0,r.jsx)(rs,{label:"Enable",side:"right",value:t0.excludeSeasonPacks,onValueChange:e=>{t1(t=>({...t,excludeSeasonPacks:e}))}})})]})]})})]})]}),(0,r.jsx)(ty,{open:t5.isOpen,onOpenChange:t5.close,title:"Allowed Regex Patterns",description:"These are regex patterns that you are allowed to use in your filters.",children:(0,r.jsx)("div",{className:"space-y-4",children:(0,r.jsx)("div",{className:"border rounded-md bg-gray-900 border-gray-800 p-4 max-h-96 overflow-auto",children:(0,r.jsxs)("div",{className:"space-y-2",children:[null==tZ||null==(tH=tZ.settings.regexAccess.patterns)?void 0:tH.map((e,t)=>(0,r.jsx)("div",{className:"font-mono text-sm bg-gray-800 rounded px-3 py-2 break-all whitespace-pre-wrap",children:e},t)),(!(null==tZ?void 0:tZ.settings.regexAccess.patterns)||0===tZ.settings.regexAccess.patterns.length)&&(0,r.jsx)("div",{className:"text-muted-foreground text-sm text-center",children:"No allowed regex patterns configured"})]})})})}),(0,r.jsx)(ty,{open:t9.isOpen,onOpenChange:t9.close,title:"Whitelisted Sync URLs",description:"These are URLs that are whitelisted for syncing stream expressions.",children:(0,r.jsx)("div",{className:"space-y-4",children:(0,r.jsx)("div",{className:"border rounded-md bg-gray-900 border-gray-800 p-4 max-h-96 overflow-auto",children:(0,r.jsxs)("div",{className:"space-y-2",children:[null==tZ||null==(tG=tZ.settings.selSyncAccess.trustedUrls)?void 0:tG.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center gap-2 font-mono text-sm bg-gray-800 rounded px-3 py-2",children:[(0,r.jsx)("div",{className:"flex-1 break-all whitespace-pre-wrap",children:e}),(0,r.jsx)(E,{size:"sm",intent:"primary-subtle",icon:(0,r.jsx)(cb.zU_,{}),onClick:()=>rm(e,{onSuccess:()=>x.oR.success("URL copied to clipboard"),onError:()=>x.oR.error("Failed to copy URL")})})]},t)),(!(null==tZ?void 0:tZ.settings.selSyncAccess.trustedUrls)||0===tZ.settings.selSyncAccess.trustedUrls.length)&&(0,r.jsx)("div",{className:"text-muted-foreground text-sm text-center",children:"No whitelisted sync URLs configured"})]})})})}),(0,r.jsx)(ty,{open:t4.isOpen,onOpenChange:t4.close,title:"Allowed Regex Pattern URLs",description:"These are URLs that you can import regex patterns from.",children:(0,r.jsx)("div",{className:"space-y-4",children:(0,r.jsx)("div",{className:"border rounded-md bg-gray-900 border-gray-800 p-4 max-h-96 overflow-auto",children:(0,r.jsxs)("div",{className:"space-y-2",children:[null==tZ||null==(tW=tZ.settings.regexAccess.urls)?void 0:tW.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center gap-2 font-mono text-sm bg-gray-800 rounded px-3 py-2",children:[(0,r.jsx)("div",{className:"flex-1 break-all whitespace-pre-wrap",children:e}),(0,r.jsx)(E,{size:"sm",intent:"primary-subtle",icon:(0,r.jsx)(cb.zU_,{}),onClick:()=>rm(e,{onSuccess:()=>x.oR.success("URL copied to clipboard"),onError:()=>x.oR.error("Failed to copy URL")})})]},t)),(!(null==tZ?void 0:tZ.settings.regexAccess.urls)||0===tZ.settings.regexAccess.urls.length)&&(0,r.jsx)("div",{className:"text-muted-foreground text-sm text-center",children:"No allowed regex pattern URLs configured"})]})})})})]})}var mk=s(9114),mS=s(571),mC=s(7328),m_=s(1972),mR=s(5498),mA=s(8579),mT=s(339),mI=s(9413);let mE={global:"Global",movies:"Movies",series:"Series",anime:"Anime",cached:"Global Cached",uncached:"Global Uncached",cachedMovies:"Movie Cached",uncachedMovies:"Movie Uncached",cachedSeries:"Series Cached",uncachedSeries:"Series Uncached",cachedAnime:"Anime Cached",uncachedAnime:"Anime Uncached"};function mM(e,t){var s;return(null==(s=e.sortCriteria)?void 0:s[t])??[]}function mP(e){let{id:t,name:s,description:a,direction:n,onDirectionChange:l}=e,{attributes:i,listeners:o,setNodeRef:d,transform:c,transition:u,isDragging:m}=(0,dV.gl)({id:t}),p={transform:dq.Ks.Transform.toString(c),transition:u,opacity:m?.5:1};return(0,r.jsx)("div",{ref:d,style:p,children:(0,r.jsxs)("div",{className:"px-2.5 py-2 bg-[var(--background)] rounded-[--radius-md] border flex gap-3 relative",children:[(0,r.jsx)("div",{className:"rounded-full w-6 h-auto bg-[--muted] md:bg-[--subtle] md:hover:bg-[--subtle-highlight] cursor-move",...i,...o}),(0,r.jsxs)("div",{className:"flex-1 flex flex-col justify-center min-w-0",children:[(0,r.jsx)("span",{className:"font-mono text-base truncate",children:s}),(0,r.jsx)("span",{className:"text-[--muted] text-sm truncate",children:a})]}),(0,r.jsx)(E,{size:"sm",rounded:!0,icon:"asc"===n?(0,r.jsx)(mk.A,{}):(0,r.jsx)(mS.A,{}),intent:"primary-subtle",onClick:l})]})})}function mD(e){let{sortKey:t,inheritedFrom:s}=e,{userData:a,setUserData:l}
18=s4(),[i,o]=(0,n.useState)(!1),d=mM(a,t),c=(0,dB.FR)((0,dB.MS)(dB.AN),(0,dB.MS)(dB.IG,{activationConstraint:{delay:150,tolerance:8}}));function u(e){l(s=>({...s,sortCriteria:{...s.sortCriteria||{},[t]:e}}))}return(0,n.useEffect)(()=>{function e(e){i&&e.preventDefault()}return i?document.body.addEventListener("touchmove",e,{passive:!1}):document.body.removeEventListener("touchmove",e),()=>document.body.removeEventListener("touchmove",e)},[i]),(0,r.jsxs)("div",{className:"space-y-2",children:[0===d.length&&s&&(0,r.jsxs)("p",{className:"text-xs text-[--muted] italic",children:["Empty — using"," ",(0,r.jsx)("span",{className:"not-italic text-[--foreground]",children:s})," ","as fallback. Add criteria below to override."]}),0===d.length&&!s&&(0,r.jsx)("p",{className:"text-xs text-[--muted] italic",children:"No criteria defined yet."}),(0,r.jsx)(ne,{multiple:!0,value:d.map(e=>e.key),emptyMessage:"No sort criteria available",onValueChange:e=>{u(e.map(e=>d.find(t=>t.key===e)??{key:e,direction:sq[e].defaultDirection}))},options:sV.map(e=>({label:sq[e].name,textValue:sq[e].name,value:e}))}),d.length>0&&(0,r.jsx)(dB.Mp,{modifiers:[dz.FN],onDragEnd:function(e){let{active:t,over:s}=e;
18if(s&&t.id!==s.id){let e=d.findIndex(e=>`${e.key}-${e.direction}`===t.id),a=d.findIndex(e=>`${e.key}-${e.direction}`===s.id);u((0,dV.be)(d,e,a))}o(!1)},onDragStart:()=>o(!0),sensors:c,children:(0,r.jsx)(dV.gB,{items:d.map(e=>`${e.key}-${e.direction}`),strategy:dV._G,children:(0,r.jsx)("div",{className:"space-y-2",children:d.map(e=>(0,r.jsx)(mP,{id:`${e.key}-${e.direction}`,name:sq[e.key].name,description:"asc"===e.direction?`${sq[e.key].description}, ${sq[e.key].ascendingDescription}`:`${sq[e.key].description}, ${sq[e.key].descendingDescription}`,direction:e.direction,onDirectionChange:()=>{let t="asc"===e.direction?"desc":"asc";u(d.map(s=>s.key===e.key?{...s,direction:t}:s))}},`${e.key}-${e.direction}`))})})})]})}function mL(e){let{items:t}=e;if(0===t.length)return null;let s=t.slice(0,3);return(0,r.jsxs)("span",{className:"flex flex-wrap items-center gap-1",children:[s.map(e=>(0,r.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded bg-[--subtle] text-[--muted] border border-[--border]",children:sq[e.key].name},e.key)),t.length>3&&(0,r.jsxs)("span",{className:"text-xs text-[--muted]",children:["+",t.length-3]})]})}function mU(e){let{sortKey:t}=e;return(0,r.jsx)("span",{className:b("text-xs px-1.5 py-0.5 rounded border font-medium shrink-0","global"===t||"cached"===t||"uncached"===t?"bg-violet-500/10 text-violet-400 border-violet-500/20":"bg-blue-500/10 text-blue-400 border-blue-500/20"),children:mE[t]})}function m$(){let{userData:e}=s4(),t=[{type:"movie",label:"Movies",icon:(0,r.jsx)(mC.A,{className:"w-3.5 h-3.5"})},{type:"series",label:"Series",icon:(0,r.jsx)(m_.A,{className:"w-3.5 h-3.5"})},{type:"anime",label:"Anime",icon:(0,r.jsx)(mR.A,{className:"w-3.5 h-3.5"})}];return(0,r.jsx)(cr,{title:"Active Sort Configuration",description:"The sort orders that will actually be applied for each content type.",children:(0,r.jsx)("div",{className:"divide-y divide-[--border]",children:t.map(t=>{let{type:s,label:a,icon:n}=t,l=function(e,t){var s,a,r,n,l,i,o,d,c,u,m,p,h,x,g,f,b;let v=e.sortCriteria;if(!v)return{primaryKey:"global",primary:[],cachedKey:null,uncachedKey:null,cachedItems:[],uncachedItems:[],splitActive:!1};let y="global",j=(null==(s=v.cached)?void 0:s.length)?"cached":null,w=(null==(a=v.uncached)?void 0:a.length)?"uncached":null;"movie"===t?((null==(r=v.movies)?void 0:r.length)&&(y="movies"),(null==(n=v.cachedMovies)?void 0:n.length)?j="cachedMovies":(null==(l=v.cached)?void 0:l.length)&&(j="cached"),(null==(i=v.uncachedMovies)?void 0:i.length)?w="uncachedMovies":(null==(o=v.uncached)?void 0:o.length)&&(w="uncached")):"series"===t?((null==(d=v.series)?void 0:d.length)&&(y="series"),(null==(c=v.cachedSeries)?void 0:c.length)?j="cachedSeries":(null==(u=v.cached)?void 0:u.length)&&(j="cached"),(null==(m=v.uncachedSeries)?void 0:m.length)?w="uncachedSeries":(null==(p=v.uncached)?void 0:p.length)&&(w="uncached")):((null==(h=v.anime)?void 0:h.length)&&(y="anime"),(null==(x=v.cachedAnime)?void 0:x.length)?j="cachedAnime":(null==(g=v.cached)?void 0:g.length)&&(j="cached"),(null==(f=v.uncachedAnime)?void 0:f.length)?w="uncachedAnime":(null==(b=v.uncached)?void 0:b.length)&&(w="uncached"));let N=mM(e,y),k=N.length>0&&"cached"===N[0].key&&null!==j&&null!==w,S=j?mM(e,j):[],C=w?mM(e,w):[];return{primaryKey:y,primary:N,cachedKey:j,uncachedKey:w,cachedItems:S,uncachedItems:C,splitActive:k}}(e,s);return(0,r.jsxs)("div",{className:"py-3 first:pt-0 last:pb-0 space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium",children:[(0,r.jsx)("span",{className:"text-[--muted]",children:n}),a,l.splitActive&&(0,r.jsxs)("span",{className:"flex items-center gap-0.5 text-xs font-normal text-green-400",children:[(0,r.jsx)(mA.A,{className:"w-3 h-3"}),"split"]})]}),l.splitActive?(0,r.jsx)("div",{className:"ml-5 space-y-1.5",children:[{dot:"bg-green-400",label:"Cached",key:l.cachedKey,items:l.cachedItems},{dot:"bg-yellow-400",label:"Uncached",key:l.uncachedKey,items:l.uncachedItems}].map(e=>{let{dot:t,label:s,key:a,items:n}=e;return(0,r.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,r.jsx)("span",{className:b("w-1.5 h-1.5 rounded-full shrink-0",t)}),(0,r.jsx)(mU,{sortKey:a}),n.length>0&&(0,r.jsx)("span",{className:"text-[--muted] text-xs shrink-0",children:"→"}),(0,r.jsx)(mL,{items:n}),0===n.length&&(0,r.jsx)("span",{className:"text-xs text-[--muted] italic",children:"no criteria defined"})]},s)})}):(0,r.jsxs)("div",{className:"ml-5 flex items-center gap-1.5 flex-wrap",children:[(0,r.jsx)(mU,{sortKey:l.primaryKey}),l.primary.length>0&&(0,r.jsx)("span",{className:"text-[--muted] text-xs shrink-0",children:"→"}),(0,r.jsx)(mL,{items:l.primary}),0===l.primary.length&&(0,r.jsx)("span",{className:"text-xs text-[--muted] italic",children:"no criteria defined"})]}),!l.splitActive&&(l.cachedKey||l.uncachedKey)&&(0,r.jsxs)("div",{className:"ml-5 flex items-start gap-1.5 text-xs text-yellow-500/80",children:[(0,r.jsx)(mT.A,{className:"w-3.5 h-3.5 shrink-0 mt-px"}),(0,r.jsxs)("span",{children:["Cached sorts are defined but inactive — make"," ",(0,r.jsx)("span",{className:"text-yellow-400",children:"Cached"})," the first primary criterion to enable split mode"]})]})]},s)})})})}let mO={global:{primaryKey:"global",cachedKey:"cached",uncachedKey:"uncached",primaryLabel:"Primary Sort Order",primaryDescription:"The default sort applied to all content. Movie, Series, and Anime tabs can each define their own override."},movies:{primaryKey:"movies",cachedKey:"cachedMovies",uncachedKey:"uncachedMovies",primaryLabel:"Movie Primary Sort",primaryDescription:"Overrides the Global primary sort for movies. Leave empty to fall back to Global.",primaryInherit:"Global",cachedInherit:"Global Cached",uncachedInherit:"Global Uncached"},series:{primaryKey:"series",cachedKey:"cachedSeries",uncachedKey:"uncachedSeries",primaryLabel:"Series Primary Sort",primaryDescription:"Overrides the Global primary sort for series. Leave empty to fall back to Global.",primaryInherit:"Global",cachedInherit:"Global Cached",uncachedInherit:"Global Uncached"},anime:{primaryKey:"anime",cachedKey:"cachedAnime",uncachedKey:"uncachedAnime",primaryLabel:"Anime Primary Sort",primaryDescription:"Overrides the Global primary sort for anime. Leave empty to fall back to Global.",primaryInherit:"Global",cachedInherit:"Global Cached",uncachedInherit:"Global Uncached"}};function mF(e){let{type:t}=e,{userData:s}=s4(),a=mO[t],n=s.sortCriteria;function l(){var e;if("global"!==t)return((null==n||null==(e=n.cached)?void 0:e.length)??0)>0?"Global Cached":void 0}function i(){var e;if("global"!==t)return((null==n||null==(e=n.uncached)?void 0:e.length)??0)>0?"Global Uncached":void 0}return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(cr,{title:a.primaryLabel,description:a.primaryDescription,children:(0,r.jsx)(mD,{sortKey:a.primaryKey,inheritedFrom:a.primaryInherit})}),(0,r.jsx)(cr,{title:"Split by Cache",description:(0,r.jsxs)(r.Fragment,{children:["When ",(0,r.jsx)("strong",{children:'"Cached"'})," is the"," ",(0,r.jsx)("strong",{children:"first criterion"})," above and both sorts below are defined, cached and uncached streams are sorted independently then merged."]}),children:(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"w-2 h-2 rounded-full bg-green-400 shrink-0"}),(0,r.jsx)("span",{className:"text-sm font-medium",children:"Cached Streams"}),0===mM(s,a.cachedKey).length&&(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:l()?`— using ${l()} as fallback`:"— undefined, split requires this"})]}),(0,r.jsx)(mD,{sortKey:a.cachedKey,inheritedFrom:l()})]}),(0,r.jsx)("div",{className:"border-t border-[--border]"}),(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:"w-2 h-2 rounded-full bg-yellow-400 shrink-0"}),(0,r.jsx)("span",{className:"text-sm font-medium",children:"Uncached Streams"}),0===mM(s,a.uncachedKey).length&&(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:i()?`— using ${i()} as fallback`:"— undefined, split requires this"})]}),(0,r.jsx)(mD,{sortKey:a.uncachedKey,inheritedFrom:i()})]})]})})]})}function mz(){return(0,r.jsx)(ru,{className:"space-y-4 p-4 sm:p-8",children:(0,r.jsx)(mV,{})})}function mV(){var e,t,s,a,l,i,o,d,c;let{userData:u,setUserData:m}=s4(),{isInherited:p,hasParent:h}
18=s9(),[x,g]=(0,n.useState)("global");(0,n.useEffect)(()=>{u.sortCriteria||m(e=>({...e,sortCriteria:{global:[],movies:[],series:[],anime:[],cached:[],uncached:[],cachedMovies:[],uncachedMovies:[],cachedSeries:[],uncachedSeries:[],cachedAnime:[],uncachedAnime:[]}}))},[]);let f=u.sortCriteria,b=((null==f||null==(e=f.movies)?void 0:e.length)??0)>0||((null==f||null==(t=f.cachedMovies)?void 0:t.length)??0)>0||((null==f||null==(s=f.uncachedMovies)?void 0:s.length)??0)>0,v=((null==f||null==(a=f.series)?void 0:a.length)??0)>0||((null==f||null==(l=f.cachedSeries)?void 0:l.length)??0)>0||((null==f||null==(i=f.uncachedSeries)?void 0:i.length)??0)>0,y=((null==f||null==(o=f.anime)?void 0:o.length)??0)>0||((null==f||null==(d=f.cachedAnime)?void 0:d.length)??0)>0||((null==f||null==(c=f.uncachedAnime)?void 0:c.length)??0)>0;function j(e,t){return(0,r.jsxs)("span",{className:"flex items-center gap-1.5",children:[e,t&&(0,r.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-blue-400 inline-block"})]})}return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center w-full",children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h2",{children:"Sorting"}),h&&p("sorting")&&(0,r.jsx)(dF,{section:"sorting"})]}),(0,r.jsx)("p",{className:"text-[--muted]",children:"Configure how your streams are sorted and organised."})]}),(0,r.jsx)("div",{className:"hidden lg:block lg:ml-auto",children:(0,r.jsx)(dT,{})})]}),(0,r.jsx)(m$,{}),(0,r.jsx)(dO,{tabs:[{value:"global",label:"Global",icon:(0,r.jsx)(mI.A,{className:"w-4 h-4"}),content:(0,r.jsx)(mF,{type:"global"})},{value:"movies",label:j("Movies",b),icon:(0,r.jsx)(mC.A,{className:"w-4 h-4"}),content:(0,r.jsx)(mF,{type:"movies"})},{value:"series",label:j("Series",v),icon:(0,r.jsx)(m_.A,{className:"w-4 h-4"}),content:(0,r.jsx)(mF,{type:"series"})},{value:"anime",label:j("Anime",y),icon:(0,r.jsx)(mR.A,{className:"w-4 h-4"}),content:(0,r.jsx)(mF,{type:"anime"})}],activeTab:x,onTabChange:g})]})}function mq(){var e,t,s,a,n,l,i;let{userData:o,setUserData:d}=s4(),{status:c}=e$(),u=null==c||null==(t=c.settings)||null==(e=t.limits)?void 0:e.maxBackgroundPings;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(cr,{title:"Pre-cache Next Episode",id:"precacheNextEpisode",description:(0,r.jsxs)(r.Fragment,{children:["Fetches the next episode's streams in the background and pings the URLs selected by the precache selector, triggering server-side caching before you click."," ",void 0!==u&&(0,r.jsxs)(r.Fragment,{children:["Up to ",(0,r.jsx)("strong",{children:u})," stream",1===u?"":"s"," can be pinged per operation (",(0,r.jsx)("code",{children:"MAX_BACKGROUND_PINGS"}),")."]})]}),children:[(0,r.jsx)(rs,{label:"Enable",side:"right",value:o.precacheNextEpisode,onValueChange:e=>{d(t=>({...t,precacheNextEpisode:e}))}}),(0,r.jsx)(rs,{label:"First stream only",help:(0,r.jsxs)(r.Fragment,{children:["When on (default), only the first stream returned by the selector is pinged. Turn off to ping all streams the selector returns",void 0!==u?(0,r.jsxs)(r.Fragment,{children:[" ","(up to ",(0,r.jsx)("strong",{children:u}),","," ",(0,r.jsx)("code",{children:"MAX_BACKGROUND_PINGS"}),")"]}):(0,r.jsxs)(r.Fragment,{children:[" ","(capped by ",(0,r.jsx)("code",{children:"MAX_BACKGROUND_PINGS"}),")"]}),"."]}),side:"right",disabled:!o.precacheNextEpisode,value:o.precacheSingleStream??!0,defaultValue:!0,onValueChange:e=>{d(t=>({...t,precacheSingleStream:e}))}}),(0,r.jsx)(W,{label:"Precache Selector",help:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{children:"A SEL expression that determines which stream(s) to precache for the next episode. Should evaluate to a list of streams."}),(0,r.jsxs)("p",{className:"mt-2",children:[(0,r.jsx)("strong",{children:"Recommended pattern:"})," ",(0,r.jsx)("code",{children:"condition ? streamsToSelectFrom : []"})]}),(0,r.jsxs)("ul",{className:"mt-2 space-y-1 list-disc list-inside",children:[(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{children:"condition"})," - When precaching should activate"]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("code",{children:"streamsToSelectFrom"})," - Which streams AIOStreams should choose from"]})]}),(0,r.jsx)("p",{className:"mt-2",children:(0,r.jsx)("strong",{children:"Examples:"})}),(0,r.jsxs)("ul",{className:"mt-2 space-y-1 list-disc list-inside",children:[(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{children:"Default behavior"})," (precache only when all streams are uncached):",(0,r.jsx)("br",{}),(0,r.jsx)("code",{className:"text-xs",children:"count(cached(streams)) == 0 ? uncached(streams) : []"})]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{children:"Always precache first uncached stream
18:"}),(0,r.jsx)("br",{}),(0,r.jsx)("code",{className:"text-xs",children:"true ? uncached(streams) : []"})]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{children:"Only for anime series:"}),(0,r.jsx)("br",{}),(0,r.jsx)("code",{className:"text-xs",children:"queryType == 'anime.series' ? uncached(streams) : []"})]})]}),(0,r.jsx)("p",{className:"mt-2 text-sm text-gray-600",children:"Has access to the same constants as expression filters (streams, queryType, isAnime, etc.)."})]}),placeholder:"e.g., true ? uncached(streams) : []",disabled:!o.precacheNextEpisode,value:o.precacheSelector??"",onValueChange:e=>{d(t=>({...t,precacheSelector:e||void 0}))}})]}),(0,r.jsxs)(cr,{title:"Preload Streams",id:"preloadStreams",description:(0,r.jsxs)(r.Fragment,{children:["Automatically sends HTTP requests to selected streams so they start processing before you click — runs asynchronously without delaying results."," ",void 0!==u&&(0,r.jsxs)(r.Fragment,{children:["Up to ",(0,r.jsx)("strong",{children:u})," stream",1===u?"":"s"," can be pinged per operation (",(0,r.jsx)("code",{children:"MAX_BACKGROUND_PINGS"}),")."]})]}),children:[(0,r.jsx)(rs,{label:"Enable",side:"right",value:null==(s=o.preloadStreams)?void 0:s.enabled,onValueChange:e=>{d(t=>({...t,preloadStreams:{...t.preloadStreams,enabled:e}}))}}),(0,r.jsx)(rs,{label:"First stream only",help:(0,r.jsxs)(r.Fragment,{children:["When on (default), only the first stream returned by the selector is pinged. Turn off to ping all streams the selector returns",void 0!==u?(0,r.jsxs)(r.Fragment,{children:[" ","(up to ",(0,r.jsx)("strong",{children:u}),","," ",(0,r.jsx)("code",{children:"MAX_BACKGROUND_PINGS"}),")"]}):(0,r.jsxs)(r.Fragment,{children:[" ","(capped by ",(0,r.jsx)("code",{children:"MAX_BACKGROUND_PINGS"}),")"]}),"."]}),side:"right",disabled:!(null==(a=o.preloadStreams)?void 0:a.enabled),value:(null==(n=o.preloadStreams)?void 0:n.singleStream)??!0,defaultValue:!0,onValueChange:e=>{d(t=>({...t,preloadStreams:{...t.preloadStreams,singleStream:e}}))}}),(0,r.jsx)(W,{label:"Preload Selector",help:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{children:"A SEL expression that determines which streams to preload. Should evaluate to a list of streams — all streams in the result will have an HTTP request sent to their URLs."}),(0,r.jsx)("p",{className:"mt-2",children:(0,r.jsx)("strong",{children:"Examples:"})}),(0,r.jsxs)("ul",{className:"mt-2 space-y-1 list-disc list-inside",children:[(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{children:"Top 5 streams (default):"}),(0,r.jsx)("br",{}),(0,r.jsx)("code",{className:"text-xs",children:"slice(streams, 0, 5)"})]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{children:"Top 5 usenet streams only:"}),(0,r.jsx)("br",{}),(0,r.jsx)("code",{className:"text-xs",children:"slice(type(streams, 'usenet'), 0, 5)"})]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{children:"Top 3 cached streams:"}),(0,r.jsx)("br",{}),(0,r.jsx)("code",{className:"text-xs",children:"slice(cached(streams), 0, 3)"})]})]}),(0,r.jsx)("p",{className:"mt-2 text-sm text-gray-600",children:"Has access to the same constants as expression filters (streams, queryType, isAnime, etc.)."})]}),defaultValue:"slice(streams, 0, 2)",disabled:!(null==(l=o.preloadStreams)?void 0:l.enabled),value:(null==(i=o.preloadStreams)?void 0:i.selector)??"",onValueChange:e=>{d(t=>({...t,preloadStreams:{...t.preloadStreams,selector:e||void 0}}))}})]})]})}function mB(){var e,t,s,a,n,l,i,o,d,c,u,m;let{userData:p,setUserData:h}=s4();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(cr,{title:"Auto Play",id:"autoPlay",description:(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("p",{children:"Configure how AIOStreams suggests the next stream for Stremio's auto-play feature."}),(0,r.jsx)(nU,{intent:"info-basic",children:(0,r.jsxs)("p",{className:"text-sm",children:["AIOStreams does not (and cannot) directly control auto-play. It uses the"," ",(0,r.jsx)("code",{children:(0,r.jsx)("a",{rel:"noopener noreferrer",href:"https://github.com/Stremio/stremio-addon-sdk/blob/master/docs/api/responses/stream.md#additional-properties-to-provide-information--behaviour-flags",target:"_blank",className:"text-[--brand] hover:text-[--brand]/80 hover:underline",children:"bingeGroup"})})," ","attribute to suggest the next stream to Stremio. For this to work, you must have auto-play enabled in your Stremio settings."]})})]}),children:[(0,r.jsx)(rs,{label:"Enable",side:"right",value:(null==(e=p.autoPlay)?void 0:e.enabled)??!0,onValueChange:e=>{h(t=>({...t,autoPlay:{...t.autoPlay,enabled:e}}))}}),(0,r.jsx)(rn,{label:"Auto Play Method",disabled:(null==(t=p.autoPlay)?void 0:t.enabled)===!1,options:sP.map(e=>({label:sD[e].name,value:e})),value:(null==(s=p.autoPlay)?void 0:s.method)||"matchingFile",onValueChange:e=>{h(t=>({...t,autoPlay:{...t.autoPlay,method:e}}))},help:sD[(null==(a=p.autoPlay)?void 0:a.method)||"matchingFile"].description}),((null==(n=p.autoPlay)?void 0:n.method)??"matchingFile")==="matchingFile"&&(0,r.jsx)(ne,{label:"Auto Play Attributes",help:"The attributes that will be used to match the stream for auto-play. The first stream for the next episode that has the same set of attributes selected above will be auto-played. Less attributes means more likely to auto-play but less accurate in terms of playing a similar type of stream.",options:sE.map(e=>({label:e,value:e})),multiple:!0,disabled:(null==(l=p.autoPlay)?void 0:l.enabled)===!1,emptyMessage:"No attributes found",value:null==(i=p.autoPlay)?void 0:i.attributes,defaultValue:sM,onValueChange:e=>{h(t=>({...t,autoPlay:{...t.autoPlay,attributes:e}}))}})]}),(0,r.jsxs)(cr,{title:"Are you still there?",id:"areYouStillThere",description:"Stop autoplay after a number of consecutive episodes so the player returns to stream selection.",children:[(0,r.jsx)(rs,{label:"Enable",side:"right",value:null==(o=p.areYouStillThere)?void 0:o.enabled,onValueChange:e=>{h(t=>({...t,areYouStillThere:{...t.areYouStillThere,enabled:e}}))}}),(0,r.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[(0,r.jsx)(nn,{label:"Episodes before check",min:1,defaultValue:3,disabled:!(null==(d=p.areYouStillThere)?void 0:d.enabled),value:(null==(c=p.areYouStillThere)?void 0:c.episodesBeforeCheck)??3,onValueChange:e=>{h(t=>({...t,areYouStillThere:{...t.areYouStillThere,episodesBeforeCheck:Math.max(1,Number(e||3))}}))}}),(0,r.jsx)(nn,{label:"Cooldown (minutes)",min:1,defaultValue:60,disabled:!(null==(u=p.areYouStillThere)?void 0:u.enabled),value:(null==(m=p.areYouStillThere)?void 0:m.cooldownMinutes)??60,onValueChange:e=>{h(t=>({...t,areYouStillThere:{...t.areYouStillThere,cooldownMinutes:Math.max(1,Number(e||60))}}))}})]})]})]})}function mK(){var e,t,s,a,n;let{userData:l,setUserData:i}=s4();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(cr,{title:"Statistic Streams",id:"statistics",description:"AIOStreams will return the statistics of stream fetches and response times for each addon if enabled.",children:[(0,r.jsx)(rs,{label:"Enable",side:"right",value:null==(e=l.statistics)?void 0:e.enabled,onValueChange:e=>{i(t=>({...t,statistics:{...t.statistics,enabled:e}}))}}),(0,r.jsx)(rn,{label:"Statistics Position",help:"Whether to show the statistic streams at the top or bottom of the stream list.",disabled:!(null==(t=l.statistics)?void 0:t.enabled),options:[{label:"Top",value:"top"},{label:"Bottom",value:"bottom"}],value:(null==(s=l.statistics)?void 0:s.position)||"bottom",onValueChange:e=>{i(t=>({...t,statistics:{...t.statistics,position:e}}))}}
18),(0,r.jsx)(ne,{label:"Statistics to Show",options:["addon","filter","timing"].map(e=>({label:e,value:e})),emptyMessage:"No statistics to show",multiple:!0,defaultValue:["addon","filter","timing"],value:null==(a=l.statistics)?void 0:a.statsToShow,onValueChange:e=>{i(t=>({...t,statistics:{...t.statistics,statsToShow:e}}))}}),(0,r.jsx)(rs,{label:"Show Filter Stats on No Streams",side:"right",defaultValue:!0,value:(null==(n=l.statistics)?void 0:n.showFilterStatsOnNoStreams)??!0,moreHelp:"When filtering results in 0 streams, show filter removal statistics as forced streams regardless of your statistics settings. Use this if you normally don't want to see filter stats, but want to know why no streams are available when that happens.",onValueChange:e=>{i(t=>({...t,statistics:{...t.statistics,showFilterStatsOnNoStreams:e}}))}})]}),(0,r.jsx)(cr,{title:"External Downloads",id:"externalDownloads",description:"Adds a stream that automatically opens the stream in your browser below every stream for easier downloading",children:(0,r.jsx)(rs,{label:"Enable",side:"right",value:l.externalDownloads,onValueChange:e=>{i(t=>({...t,externalDownloads:e}))}})}),(0,r.jsxs)(cr,{id:"hideErrors",title:"Hide Errors",children:[(0,r.jsx)(rs,{label:"Hide Errors",help:"AIOStreams will attempt to return the errors in responses to streams, catalogs etc. Turning this on will hide the errors.",side:"right",value:l.hideErrors,onValueChange:e=>{i(t=>({...t,hideErrors:e}))}}),(0,r.jsx)(ne,{disabled:l.hideErrors,label:"Hide Errors for specific resources",options:sZ.map(e=>({label:e,value:e})),multiple:!0,help:"This lets you hide errors for specific resources. For example, you may want to hide errors for the catalog resource, but not for the stream resource.",emptyMessage:"No resources found",value:l.hideErrorsForResources,onValueChange:e=>{i(t=>({...t,hideErrorsForResources:e}))}})]})]})}let mH=[{value:"inherit",label:"Inherit from parent"},{value:"override",label:"Override with mine"}],mG=[{value:"inherit",label:"Inherit from parent"},{value:"extend",label:"Extend parent (add mine)"},{value:"override",label:"Override with mine"}],mW={presets:"Addons",services:"Services",filters:"Filters",sorting:"Sorting & Deduplication",formatter:"Formatter",proxy:"Proxy",metadata:"Metadata & Poster APIs",misc:"Miscellaneous Settings",branding:"Branding"},mY={presets:"Addon presets and groupings.",services:'Debrid and download service credentials. Use "Extend" to add or override individual services while keeping the rest from the parent.',filters:"All include, exclude, require and prefer filters.",sorting:"Sort criteria, deduplication rules and result limits.",formatter:"Stream title formatter.",proxy:"Proxy configuration.",metadata:"TMDB, RPDB, TVDB and poster API keys.",misc:"Playback, display and other miscellaneous settings.",branding:"Addon visual identity overrides."},mJ={filters:"Filters",sorting:"Sorting",formatter:"Formatter",proxy:"Proxy",metadata:"Metadata",misc:"Misc",branding:"Branding"},mZ=["filters","sorting","formatter","proxy","metadata","misc","branding"],mQ=Object.entries(t0).filter(e=>{let[,t]=e;return!t.ignoreForParentConfig}).map(e=>{let[t]=e;return t}).sort((e,t)=>{var s,a;return((null==(s=t0[e])?void 0:s.label)??e).localeCompare((null==(a=t0[t])?void 0:a.label)??t)}),mX=Object.fromEntries(mZ.map(e=>[e,mQ.filter(t=>{var s;return(null==(s=t0[t])?void 0:s.group)===e})]));function m0(e,t){var s;let a=null==(s=t0[e])?void 0:s.group;return a?(null==t?void 0:t[a])??"inherit":"inherit"}function m1(e){let{field:t,meta:s,activeOverride:a,groupStrategy:n,trimmedSearch:l,onChange:i}=e,o=[{value:"default",label:`Default: ${"inherit"===n?"Inherit (group)":"override"===n?"Override (group)":"Extend (group)"}`},..."list"===s.type?mG:mH];return(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3 px-3 py-2 rounded-[--radius] hover:bg-[--subtle] group",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col sm:flex-row sm:items-center sm:gap-2",children:[(0,r.jsx)("span",{className:"text-sm font-medium",children:s.label}),l&&(0,r.jsxs)("span",{className:"text-xs text-[--muted]",children:["(",mJ[s.group],")"]})]}),(0,r.jsx)("div",{className:"w-48 shrink-0",children:(0,r.jsx)(rn,{size:"sm",options:o,value:a??"default",onValueChange:e=>i(t,e)})})]})}function m2(e){var t;let{open:s,onOpenChange:a,strategies:l,fieldOverrides:i,onChange:o}
18=e,[d,c]=(0,n.useState)("filters"),[u,m]=(0,n.useState)(""),p=u.trim().toLowerCase(),h=(0,n.useMemo)(()=>p?mQ.filter(e=>{var t;return((null==(t=t0[e])?void 0:t.label)??e).toLowerCase().includes(p)}):mX[d]??[],[p,d]),x=(0,n.useMemo)(()=>Object.fromEntries(mZ.map(e=>[e,mQ.filter(t=>{var s;return(null==(s=t0[t])?void 0:s.group)===e&&i[t]}).length])),[i]),g=Object.keys(i).filter(e=>t0[e]).length;return(0,r.jsx)(ty,{open:s,onOpenChange:a,title:"Field Overrides",description:"Override the merge strategy for individual config fields. Field overrides always take precedence over the section-level strategy above.",contentClass:"!max-w-3xl",children:(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(W,{placeholder:"Search fields…",value:u,onValueChange:m}),!p&&(0,r.jsx)("div",{className:"flex gap-1.5 flex-wrap",children:mZ.map(e=>{let t=x[e],s=d===e;return(0,r.jsxs)("button",{onClick:()=>c(e),className:["flex items-center gap-1.5 px-3 py-1.5 rounded-[--radius] text-sm font-medium transition-colors",s?"bg-brand-500 text-white":"bg-[--subtle] text-[--muted] hover:text-[--text-color] hover:bg-[--subtle-border]"].join(" "),children:[mJ[e],t>0&&(0,r.jsx)("span",{className:["text-xs px-1.5 py-0.5 rounded-full font-semibold leading-none",s?"bg-white/20 text-white":"bg-[--brand]/20 text-[--brand]"].join(" "),children:t})]},e)})}),!p&&(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("p",{className:"text-sm font-semibold text-[--text-color]",children:[mJ[d],(0,r.jsxs)("span",{className:"ml-2 text-xs font-normal text-[--muted]",children:[(null==(t=mX[d])?void 0:t.length)??0," fields"]})]}),x[d]>0&&(0,r.jsxs)("button",{onClick:()=>{let e;return e=new Set(mQ.filter(e=>{var t;return(null==(t=t0[e])?void 0:t.group)===d}).map(e=>e)),void o(t=>Object.fromEntries(Object.entries(t).filter(t=>{let[s]=t;return!e.has(s)})))},className:"text-xs text-[--muted] hover:text-[--text-color] transition-colors",children:["Clear ",x[d]," override",1!==x[d]?"s":""]})]}),p&&(0,r.jsxs)("p",{className:"text-sm text-[--muted]",children:[h.length," field",1!==h.length?"s":""," ","matching “",u.trim(),"”"]}),(0,r.jsx)("div",{className:"space-y-1 max-h-[50vh] overflow-y-auto pr-0.5",children:0===h.length?(0,r.jsx)("p",{className:"text-sm text-[--muted] py-4 text-center",children:"No fields found."}):h.map(e=>{let t=t0[e],s=i[e],a=m0(e,l);return(0,r.jsx)(m1,{field:e,meta:t,activeOverride:s,groupStrategy:a,trimmedSearch:!!p,onChange:(e,t)=>
18{o(s=>{let a={...s};return t&&"default"!==t?a[e]=t:delete a[e],a})}},e)})}),g>0&&(0,r.jsxs)("p",{className:"text-xs text-[--muted] border-t pt-3",children:[g," field override",1!==g?"s":""," ","active across all sections."]})]})})}function m3(){let{userData:e,setUserData:t,uuid:s}=s4(),[a,l]=(0,n.useState)(""),[i,o]=(0,n.useState)(""),[d,c]=(0,n.useState)(!1),[u,m]=(0,n.useState)(!1),p=e.parentConfig;async function h(e){if(null==e||e.preventDefault(),a.trim()&&i){if(c(!0),a===s){x.oR.error("You cannot link to your own config"),c(!1);return}try{let e=await ex(a.trim(),i);t(t=>({...t,parentConfig:{uuid:e.uuid,password:i,mergeStrategies:{presets:"inherit",services:"inherit",filters:"inherit",sorting:"inherit",formatter:"inherit",proxy:"inherit",metadata:"inherit",misc:"inherit",branding:"inherit"}}})),l(""),o(""),x.oR.success("Parent config linked. Save your config to apply.")}catch(e){x.oR.error((null==e?void 0:e.message)??"Failed to link parent config")}finally{c(!1)}}}function g(e,s){t(t=>{var a;return{...t,parentConfig:{...t.parentConfig,mergeStrategies:{presets:"inherit",services:"inherit",filters:"inherit",sorting:"inherit",formatter:"inherit",proxy:"inherit",metadata:"inherit",misc:"inherit",branding:"inherit",...(null==(a=t.parentConfig)?void 0:a.mergeStrategies)??{},[e]:s}}}})}function f(e){t(t=>{var s;let a=(null==(s=t.parentConfig)?void 0:s.mergeStrategies)??{},r=a.fieldOverrides??{},n="function"==typeof e?e(r):e;return{...t,parentConfig:{...t.parentConfig,mergeStrategies:{presets:"inherit",services:"inherit",filters:"inherit",sorting:"inherit",formatter:"inherit",proxy:"inherit",metadata:"inherit",misc:"inherit",branding:"inherit",...a,fieldOverrides:Object.keys(n).length>0?n:void 0}}}})}let b=null==p?void 0:p.mergeStrategies,v=(null==b?void 0:b.fieldOverrides)??{},y=Object.keys(v).filter(e=>t0[e]).length;return(0,r.jsx)("div",{className:"space-y-4",children:p?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(cr,{title:"Parent Config",id:"parentConfig",description:"Settings from the parent config are merged into this config at runtime.",action:(0,r.jsx)(w,{intent:"alert-subtle",size:"sm",leftIcon:(0,r.jsx)(uU.KOA,{}),onClick:function(){t(e=>{let t={...e};return delete t.parentConfig,t}),x.oR.success("Parent config removed. Save your config to apply.")},children:"Unlink"}),children:(0,r.jsxs)("div",{className:"flex items-center gap-2 p-2 rounded-[--radius] bg-[--subtle] border text-sm",children:[(0,r.jsx)(uU.j2W,{className:"shrink-0 text-[--muted]"}),(0,r.jsx)("span",{className:"font-mono text-xs truncate text-[--muted]",children:p.uuid})]})}),(0,r.jsx)(cr,{title:"Merge Strategies",description:"For each section, choose whether to use the parent's settings, combine them with yours, or use only yours.",children:(0,r.jsxs)("div",{className:"space-y-4",children:[["presets","services"].map(e=>(0,r.jsx)("div",{className:"space-y-1",children:(0,r.jsx)(rn,{label:mW[e],help:mY[e],options:mG,value:(null==b?void 0:b[e])??"inherit",onValueChange:t=>g(e,t)})},e)),["filters","sorting","formatter","proxy","metadata","misc","branding"].map(e=>(0,r.jsx)("div",{className:"space-y-1",children:(0,r.jsx)(rn,{label:mW[e],help:mY[e],options:mH,value:(null==b?void 0:b[e])??"inherit",onValueChange:t=>g(e,t)})},e))]})}),(0,r.jsx)(cr,{title:"Field Overrides",description:"Fine-tune inheritance by setting a different strategy for individual fields. Overrides always take precedence over the section strategies above.",action:(0,r.jsx)(E,{size:"sm",intent:"white",rounded:!0,icon:(0,r.jsx)(nD.VSk,{}),onClick:()=>m(!0),title:"Configure Field Overrides"}),children:y>0?(0,r.jsx)("div",{className:"space-y-1 mt-2",children:Object.keys(v).filter(e=>t0[e]).map(e=>{let t=t0[e],s=v[e],a=m0(e,b);return(0,r.jsx)(m1,{field:e,meta:t,activeOverride:s,groupStrategy:a,trimmedSearch:!1,onChange:(e,t)=>
18{f(s=>{let a={...s};return t&&"default"!==t?a[e]=t:delete a[e],a})}},e)})}):(0,r.jsx)("p",{className:"text-sm text-[--muted] pt-2",children:"No field overrides configured. All fields use their section strategy."})}),(0,r.jsx)(m2,{open:u,onOpenChange:m,strategies:b,fieldOverrides:v,onChange:f})]}):(0,r.jsx)(cr,{title:"Link a Parent Config",id:"parentConfig",description:"Inherit settings from another config at runtime. Any changes made to the parent are immediately reflected here.",children:(0,r.jsxs)("form",{onSubmit:h,className:"space-y-3",children:[(0,r.jsx)(W,{label:"Parent UUID",placeholder:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",autoComplete:"off",value:a,onValueChange:l}),(0,r.jsx)(Z,{label:"Parent Password",autoComplete:"off",value:i,onValueChange:o}),(0,r.jsx)(w,{type:"submit",size:"sm",intent:"white",rounded:!0,loading:d,disabled:!a.trim()||!i,leftIcon:(0,r.jsx)(uU.j2W,{}),children:"Link Parent"})]})})})}let m6={maxScriptLength:4e3,maxInstructions:100,maxValueDepth:10,maxPathSegments:12,maxPathMatches:200},m5=new Set(["accessKey","parentConfig","variants"]),m4=new Set(["__proto__","prototype","constructor"]),m9=new Set(["true","false","null"]),m8=new Set(["set","merge","unset","clear","add","prepe
18nd","remove","enable","disable","use"]),m7=/^[a-z0-9][a-z0-9_-]{0,31}$/;function pe(e,t){let s,a=e.toLowerCase(),r=Math.max(2,Math.ceil(e.length/3));for(let e of t){let t=function(e,t){let s=Array(t.length+1),a=Array(t.length+1);for(let e=0;e<=t.length;e++)s[e]=e;for(let r=1;r<=e.length;r++){a[0]=r;for(let n=1;n<=t.length;n++)a[n]=Math.min(s[n]+1,a[n-1]+1,s[n-1]+ +(e[r-1]!==t[n-1]));for(let e=0;e<=t.length;e++)s[e]=a[e]}return s[t.length]}(a,e.toLowerCase());t<r&&(r=t,s=e)}return s}class pt extends Error{constructor(e,t){super(e),(0,en._)(this,"diagnostic",void 0),this.diagnostic=t}}class ps{get eof(){return this.pos>=this.src.length}peek(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.src[this.pos+e]??""}advance(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t="";for(let s=0;s<e&&!this.eof;s++){let e=this.src[this.pos++];"\n"===e&&this.line++,t+=e}return t}skipTrivia(){for(;!this.eof;){let e=this.peek();if("#"===e)for(;!this.eof&&"\n"!==this.peek();)this.advance();else{if(" "!==e&&"	"!==e&&"\r"!==e&&"\n"!==e)return;this.advance()}}}skipToNextLine(){for(;!this.eof&&"\n"!==this.peek();)this.advance();this.eof||this.advance()}fail(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=t.index??this.pos,a=t.source??this.src.slice(s,Math.max(s+1,this.pos));throw new pt(e,{index:s,source:a,line:this.line,message:e,category:t.category??"syntax",suggestion:t.suggestion})}constructor(e){(0,en._)(this,"src",void 0),(0,en._)(this,"pos",void 0),(0,en._)(this,"line",void 0),this.src=e,this.pos=0,this.line=1}}function pa(e){return/[A-Za-z_]/.test(e)}function pr(e){return/[A-Za-z0-9_]/.test(e)}function pn(e){return e>="0"&&e<="9"}function pl(e){pa(e.peek())||e.fail("expected a name");let t=e.pos,s="";for(;!e.eof&&pr(e.peek());)s+=e.advance();return m4.has(s)&&e.fail(`"${s}" is not an allowed name`,{index:t,source:s}),s}function pi(e){let t=e.pos,s="";for(;!e.eof&&/[A-Za-z0-9_.-]/.test(e.peek());)s+=e.advance();return s||e.fail("expected a value"),m4.has(s)&&e.fail(`"${s}" is not an allowed name`,{index:t,source:s}),s}let po=/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/;function pd(e){if(!pa(e.peek()))return;let t="",s=0;for(;pr(e.peek(s));)t+=e.peek(s++);return t}function pc(e){let t=e.pos,s=e.advance(),a="";for(;;){e.eof&&e.fail("unterminated string",{index:t});let r=e.advance();if(r===s)return a;if("\\"!==r){a+=r;continue}let n=e.advance();switch(n){case"n":a+="\n";break;case"t":a+="	";break;case"r":a+="\r";break;case"b":a+="\b";break;case"f":a+="\f";break;case"u":{let t=e.advance(4);/^[0-9a-fA-F]{4}$/.test(t)||e.fail("invalid unicode escape"),a+=String.fromCharCode(parseInt(t,16));break}case"\\":case"/":case'"':case"'":a+=n;break;default:e.fail(`invalid escape sequence "\\${n}"`)}}}function pu(e){let t=e.pos,s="";for("-"===e.peek()&&(s+=e.advance());pn(e.peek());)s+=e.advance();if("."===e.peek())for(s+=e.advance();pn(e.peek());)s+=e.advance();if("e"===e.peek()||"E"===e.peek())for(s+=e.advance(),("+"===e.peek()||"-"===e.peek())&&(s+=e.advance());pn(e.peek());)s+=e.advance();let a=Number(s);return""!==s&&"-"!==s&&Number.isFinite(a)||e.fail(`invalid number "${s}"`,{index:t,source:s||"-"}),a}function pm(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;s>t.maxValueDepth&&e.fail(`value nesting exceeds the maximum depth of ${t.maxValueDepth}`,{category:"limit"}),e.skipTrivia();let a=e.peek();if('"'===a||"'"===a)return pc(e);if("-"===a||pn(a))return pu(e);if("["===a){e.advance();let a=[];if(e.skipTrivia(),"]"===e.peek())return e.advance(),a;for(;;){if(a.push(pm(e,t,s+1)),e.skipTrivia(),","===e.peek()){if(e.advance(),e.skipTrivia(),"]"===e.peek())return e.advance(),a;continue}if("]"===e.peek())return e.advance(),a;e.fail('expected "," or "]" in array')}}if("{"===a){e.advance();let a={};if(e.skipTrivia(),"}"===e.peek())return e.advance(),a;for(;;){e.skipTrivia();let r=e.pos,n='"'===e.peek()||"'"===e.peek()?pc(e):pl(e);if(m4.has(n)&&e.fail(`"${n}" is not an allowed key`,{index:r,source:n}),Object.prototype.hasOwnProperty.call(a,n)&&e.fail(`duplicate key "${n}"`,{index:r,source:n}),e.skipTrivia(),":"!==e.peek()&&e.fail('expected ":" after object key'),e.advance(),a[n]=pm(e,t,s+1),e.skipTrivia(),","===e.peek()){if(e.advance(),e.skipTrivia(),"}"===e.peek())return e.advance(),a;continue}if("}"===e.peek())return e.advance(),a;e.fail('expected "," or "}" in object')}}let r=pd(e);if(r&&m9.has(r))return e.advance(r.length),"true"===r||"false"!==r&&null;e.fail("expected a value (string, number, boolean, null, array or object)")}function pp(e,t){let s=e.pos,a=pl(e);m5.has(a)&&e.fail(`"${a}" cannot be changed by a variant`,{index:s,source:a,category:"denied-field"}),Object.prototype.hasOwnProperty.call(t0,a)||e.fail(`"${a}" is not a known configuration field`,{index:s,source:a,category:"unknown-field",suggestion:pe(a,Object.keys(t0).filter(e=>!m5.has(e)))});let r=[];for(;!e.eof;){if("."===e.peek())e.advance(),r.push({kind:"key",name:pl(e)});else if("["===e.peek()){if(e.advance(),e.skipTrivia(),"*"===e.peek()&&"]"===e.peek(1))e.advance(),r.push({kind:"all"});else if(pn(e.peek())||"-"===e.peek()&&pn(e.peek(1))){let t=e.pos,s=pu(e);Number.isInteger(s)||e.fail("array index must be a whole number",{index:t}),r.push({kind:"index",index:s})}else{let s,a="";if(pa(e.peek()))for(a=pl(e);"."===e.peek();)e.advance(),a+=`.${pl(e)}`;e.skipTrivia(),"!"===e.peek()&&"*"===e.peek(1)&&"="===e.peek(2)?(e.advance(3),s="!*="):"!"===e.peek()&&"="===e.peek(1)?(e.advance(2),s="!="):"*"===e.peek()&&"="===e.peek(1)?(e.advance(2),s="*="):"="===e.peek()?(e.advance(),s="="):e.fail('expected "=", "!=", "*=" or "!*=" in selector'),e.skipTrivia();let n=function(e,t){let s=e.peek();if('"'===s||"'"===s||"["===s||"{"===s)return pm(e,t);let a="",r=0;for(;/[A-Za-z0-9_.+-]/.test(e.peek(r));)a+=e.peek(r++);return(a||e.fail("expected a value"),"true"===a||"false"===a)?(e.advance(a.length),"true"===a):"null"===a?(e.advance(a.length),null):po.test(a)?pu(e):pi(e)}(e,t);r.push({kind:"filter",key:a,operator:s,value:n})}e.skipTrivia(),"]"!==e.peek()&&e.fail('expected "]"'),e.advance()}else break;r.length>t.maxPathSegments&&e.fail(`path exceeds the maximum of ${t.maxPathSegments} segments`,{index:s,category:"limit"})}return{root:a,segments:r,raw:e.src.slice(s,e.pos),index:s}}function ph(e){return'"'===e.peek()||"'"===e.peek()?pc(e):pi(e)}function px(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:m6,s=[],a=[],r=[];if(e.length>t.maxScriptLength)return r.push({index:t.maxScriptLength,source:e.slice(t.maxScriptLength,t.maxScriptLength+20
18),line:1,message:`script exceeds the maximum length of ${t.maxScriptLength} characters`,category:"limit",severity:"error"}),{program:{statements:s,referencedVariants:a},diagnostics:r};let n=new ps(e);for(;n.skipTrivia(),!n.eof;){let l=n.pos,i=n.line;try{let o=function(e,t){let s=e.pos,a=e.line,r=pl(e);switch(!m8.has(r)&&e.fail(`unknown instruction "${r}"`,{index:s,source:r,category:"unknown-verb",suggestion:pe(r,[...m8])}),e.skipTrivia(),r){case"set":case"merge":{let n=pp(e,t);e.skipTrivia(),"="!==e.peek()&&e.fail(`expected "=" after the path in ${r}`),e.advance();let l=pm(e,t);return"merge"===r&&(null===l||"object"!=typeof l)&&e.fail("merge requires an object or array value",{index:s}),{op:r,path:n,value:l,index:s,line:a}}case"unset":case"clear":case"enable":case"disable":return{op:r,path:pp(e,t),index:s,line:a};case"add":case"prepend":case"remove":{let n=pp(e,t),l=function(e,t){let s=[];if(e.skipTrivia(),!function(e){let t=e.peek();if('"'===t||"'"===t||"["===t||"{"===t||"-"===t||pn(t))return!0;let s=pd(e);return void 0!==s&&m9.has(s)}(e))return s;for(s.push(pm(e,t));;){if(e.skipTrivia(),","!==e.peek())return s;e.advance(),s.push(pm(e,t))}}(e,t);return 0===l.length&&"remove"!==r&&e.fail(`${r} requires at least one value`,{index:s}),{op:r,path:n,values:l,index:s,line:a}}default:{let t=e.pos,r=pl(e);if(e.skipTrivia(),"formatter"===r)return{op:"useFormatter",name:ph(e),index:s,line:a};if("variant"===r){let t=e.pos,r=ph(e);return m7.test(r)||e.fail(`invalid variant id "${r}"`,{index:t,source:r}),{op:"useVariant",id:r,index:s,line:a}}return e.fail('expected "use formatter" or "use variant"',{index:t,source:r,suggestion:pe(r,["formatter","variant"])})}}}(n,t);if(s.push(o),"useVariant"===o.op&&a.push(o.id),s.length>t.maxInstructions){r.push({index:l,source:e.slice(l,n.pos),line:i,message:`script exceeds the maximum of ${t.maxInstructions} instructions`,category:"limit",severity:"error"});break}}catch(t){t instanceof pt?r.push({...t.diagnostic,severity:"error"}):r.push({index:l,source:e.slice(l,n.pos)||" ",line:i,message:t instanceof Error?t.message:String(t),category:"syntax",severity:"error"}),n.skipToNextLine()}}return{program:{statements:s,referencedVariants:a},diagnostics:r}}function pg(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function pf(e){if(Array.isArray(e))return e.map(pf);if(pg(e)){let t={};for(let[s,a]of Object.entries(e))m4.has(s)||(t[s]=pf(a));return t}return e}function pb(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,s)=>pb(e,t[s]));if(pg(e)&&pg(t)){let s=Object.keys(e),a=Object.keys(t);return s.length===a.length&&s.every(s=>Object.prototype.hasOwnProperty.call(t,s)&&pb(e[s],t[s]))}return!1}function pv(e,t,s){"string"==typeof t&&m4.has(t)||(e[t]=s)}function py(e,t){let s=e<0?t+e:e;return s>=0&&s<t?s:void 0}function pj(e,t){let s;if(t.key&&!pg(e))return!1;let a=e;for(let e of t.key?t.key.split("."):[]){if(!pg(a))return t.operator.startsWith("!");a=a[e]}let r=null!=a&&("object"!=typeof t.value||null===t.value);return s="*="===t.operator||"!*="===t.operator?r&&String(a).toLowerCase().includes(String(t.value).toLowerCase()):pb(a,t.value)||r&&String(a)===String(t.value),"!="===t.operator||"!*="===t.operator?!s:s}function pw(e){let t=new Map;for(let s of e)if(Array.isArray(s.container)&&"number"==typeof s.key){let e=t.get(s.container)??[];e.push(s.key),t.set(s.container,e)}else pg(s.container)&&delete s.container[s.key];for(let[e,s]of t)for(let t of[...new Set(s)].sort((e,t)=>t-e))e.splice(t,1)}function pN(e,t,s){let a="path"in e?e.path.raw:`use ${e.op}`;return{index:"path"in e?e.path.index:e.index,source:a,line:e.line,message:t,category:s,severity:"warning"}}var pk=s(3001),pS=s(9462);let pC=pS.Lz.theme({"&":{backgroundColor:"transparent",color:"var(--foreground)",fontSize:"0.8125rem",height:"100%"},".cm-content":{fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",padding:"0.5rem 0.6rem",caretColor:"var(--foreground)"},".cm-scroller":{fontFamily:"inherit",lineHeight:"1.6",overflow:"auto"},"&.cm-focused":{outline:"none"},".cm-placeholder":{color:"var(--muted)"},".cm-content ::selection":{backgroundColor:"color-mix(in srgb, var(--ring) 30%, transparent)"},".cm-matchingBracket, &.cm-focused .cm-matchingBracket":{backgroundColor:"color-mix(in srgb, var(--ring) 22%, transparent)",outline:"1px solid color-mix(in srgb, var(--ring) 45%, transparent)"},".cm-nonmatchingBracket":{backgroundColor:"color-mix(in srgb, var(--red) 3
180%, transparent)"},".cm-tooltip":{backgroundColor:"var(--paper)",border:"1px solid var(--border)",borderRadius:"var(--radius)",color:"var(--foreground)",boxShadow:"0 4px 16px rgba(0,0,0,0.25)"},".cm-tooltip.cm-tooltip-autocomplete > ul":{fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",maxHeight:"16rem"},".cm-tooltip-autocomplete ul li[aria-selected]":{backgroundColor:"color-mix(in srgb, var(--ring) 25%, transparent)",color:"var(--foreground)"},".cm-completionLabel":{color:"var(--foreground)"},".cm-completionDetail":{color:"var(--muted)",fontStyle:"italic"},".cm-tooltip.cm-tooltip-lint":{padding:"0.25rem 0.5rem"},".cm-diagnosticText":{color:"var(--foreground)"},".cmf-section":{color:"var(--sky)",fontWeight:"500"},".cmf-property":{color:"var(--blue)"},".cmf-dot":{color:"var(--muted)"},".cmf-modifier":{color:"var(--violet)"},".cmf-comparator":{color:"var(--amber)",fontWeight:"600"},".cmf-prefix":{color:"var(--amber)"},".cmf-args":{color:"var(--foreground)"},".cmf-literal":{color:"var(--green)"},".cmf-tool":{color:"var(--teal)",fontStyle:"italic"},".cmf-sep":{color:"var(--muted)"},".cmf-quote":{color:"var(--muted)"},".cmf-pipe":{color:"var(--rose)",fontWeight:"600"},".cmf-invalid":{color:"var(--muted)",textDecoration:"underline dotted color-mix(in srgb, var(--red) 60%, transparent)",opacity:"0.75"},".cmf-d0":{color:"var(--yellow)"},".cmf-d1":{color:"var(--violet)"},".cmf-d2":{color:"var(--sky)"},".cmf-d3":{color:"var(--pink)"},".cmf-d4":{color:"var(--teal)"},".cmf-hint":{color:"var(--muted)",fontStyle:"italic",opacity:"0.85",paddingLeft:"0.35rem"}});var p_=s(3708);let pR={comment:"cmv-comment",verb:"cmv-verb",root:"cmv-root",property:"cmv-property",operator:"cmv-operator",string:"cmv-string",number:"cmv-number",keyword:"cmv-keyword",punct:"cmv-punct"};function pA(e){let t=new p_.vB;for(let s of function(e){let t=[],s=0,a=!0,r=!1,n=!1,l=(e,s,a)=>t.push({kind:e,start:s,end:a});for(;s<e.length;){let t=e[s];if("\n"===t){a=!0,s++;continue}if(" "===t||"	"===t||"\r"===t){s++;continue}if("#"===t){let t=s;for(;s<e.length&&"\n"!==e[s];)s++;l("comment",t,s),a=!1;continue}if('"'===t||"'"===t){let i=s;for(s++;s<e.length&&e[s]!==t;)"\\"===e[s]&&s++,s++;s<e.length&&s++,l("string",i,s),a=!1,r=!1,n=!1;continue}if(pn(t)||"-"===t&&pn(e[s+1]??"")){let t=s;for(s++;s<e.length&&/[0-9.eE+-]/.test(e[s]);)s++;l("number",t,s),a=!1,r=!1,n=!1;continue}if(pa(t)){let t=s;for(;s<e.length&&pr(e[s]);)s++;let i=e.slice(t,s);m9.has(i)?l("keyword",t,s):a&&m8.has(i)?(l("verb",t,s),r=!0):r&&!n?(l("formatter"===i||"variant"===i?"verb":"root",t,s),r="formatter"===i||"variant"===i):l("property",t,s),a=!1,n=!1;continue}if("="===t||"!"===t||"*"===t){let t=s;for(;s<e.length&&/[=!*]/.test(e[s]);)s++;l("operator",t,s),a=!1;continue}n="."===t,l("punct",s,s+1),s++,a=!1}return t}(e.state.doc.toString()))t.add(s.start,s.end,pS.NZ.mark({class:pR[s.kind]}));return t.finish()}let pT=pS.Z9.fromClass(class{update(e){e.docChanged&&(this.decorations=pA(e.view))}constructor(e){(0,en._)(this,"decorations",void 0),this.decorations=pA(e)}},{decorations:e=>e.decorations}),pI=pS.Lz.theme({".cm-content":{caretColor:"transparent"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--foreground)",borderLeftWidth:"1px"},".cm-selectionBackground, &.cm-focused .cm-selectionBackground":{backgroundColor:"color-mix(in srgb, var(--ring) 30%, transparent)"},".cm-gutters":{backgroundColor:"transparent",border:"none",color:"var(--muted)",opacity:"0.6"},".cm-lineNumbers .cm-gutterElement":{padding:"0 0.5rem 0 0.75rem",minWidth:"2ch"},".cm-activeLineGutter":{backgroundColor:"transparent"},".cm-gutter-lint":{width:"1rem"},".cmv-comment":{color:"var(--muted)",fontStyle:"italic"},".cmv-verb":{color:"var(--violet)",fontWeight:"600"},".cmv-root":{color:"var(--sky)",fontWeight:"500"},".cmv-property":{color:"var(--blue)"},".cmv-operator":{color:"var(--amber)",fontWeight:"600"},".cmv-string":{color:"var(--green)"},".cmv-number":{color:"var(--teal)"},".cmv-keyword":{color:"var(--rose)"},".cmv-punct":{color:"var(--muted)"}});var pE=s(704),pM=s(5115);
18let pP=[{label:"set",type:"keyword",detail:"set <path> = <value>"},{label:"merge",type:"keyword",detail:"merge <path> = { ... }"},{label:"unset",type:"keyword",detail:"unset <path>"},{label:"clear",type:"keyword",detail:"clear <path>"},{label:"add",type:"keyword",detail:"add <path> <value>, ..."},{label:"prepend",type:"keyword",detail:"prepend <path> <value>, ..."},{label:"remove",type:"keyword",detail:"remove <path> [<value>, ...]"},{label:"enable",type:"keyword",detail:"enable <path>"},{label:"disable",type:"keyword",detail:"disable <path>"},{label:"use formatter ",type:"keyword",detail:"apply a saved formatter"},{label:"use variant ",type:"keyword",detail:"apply another variant"}],pD=/^\s*(set|merge|unset|clear|add|prepend|remove|enable|disable)\s+\w*$/,pL=Object.entries(t0).filter(e=>{let[t]=e;return!m5.has(t)}).map(e=>{let[t,s]=e;return{label:t,type:"list"===s.type?"property":"variable",detail:s.label}});function pU(e){let{value:t,onValueChange:s,limits:a,userData:l,currentVariantId:i,placeholder:o,disabled:d,className:c,initialHeight:u="14rem"}=e,m=(0,n.useMemo)(()=>[pT,pI,(0,pE.bu)(e=>{let t=e.state.doc.toString(),s=t.length;return px(t,a).diagnostics.map(e=>{let t=Math.max(0,Math.min(e.index,s)),a=Math.max(t+1,Math.min(e.index+(e.source?e.source.length:1),s)),r={from:t,to:a,severity:e.severity,message:e.message};if(e.suggestion){let t=e.suggestion;r.actions=[{name:`Replace with ${t}`,apply(e,s,a){e.dispatch({changes:{from:s,to:a,insert:t}})}}]}return r})},{delay:200}),function(e){let{userData:t,currentVariantId:s}=e;return(0,pM.yU)({override:[e=>{let a=e.state.doc.lineAt(e.pos),r=e.state.sliceDoc(a.from,e.pos),n=/use\s+formatter\s+"?([\w\s-]*)$/.exec(r);if(n){var l,i;let s=Object.keys((null==(i=t.formatter)||null==(l=i.definitions)?void 0:l.saved)??{});return{from:e.pos-n[1].length,options:s.map(e=>({label:e,type:"text",detail:"saved formatter"})),validFor:/^[\w\s-]*$/}}let o=/use\s+variant\s+"?([\w-]*)$/.exec(r);if(o)return{from:e.pos-o[1].length,options:(t.variants??[]).filter(e=>e.id!==s).map(e=>({label:e.id,type:"text",detail:e.name??"variant"})),validFor:/^[\w-]*$/};let d=/presets\[instanceId\s*!?\*?=\s*"?([\w-]*)$/.exec(r);if(d)return{from:e.pos-d[1].length,options:(t.presets??[]).map(e=>{var t;return{label:e.instanceId,type:"text",detail:(null==(t=e.options)?void 0:t.name)??e.type}}),validFor:/^[\w-]*$/};let c=/presets\[type\s*!?\*?=\s*"?([\w-]*)$/.exec(r);if(c){let s=[...new Set((t.presets??[]).map(e=>e.type))];return{from:e.pos-c[1].length,options:s.map(e=>({label:e,type:"text",detail:"addon type"})),validFor:/^[\w-]*$/}}let u=/services\[id\s*!?\*?=\s*"?([\w-]*)$/.exec(r);if(u)return{from:e.pos-u[1].length,options:(t.services??[]).map(e=>({label:e.id,type:"text",detail:"service"})),validFor:/^[\w-]*$/};let m=e.matchBefore(/[\w]*/);return m&&(m.from!==m.to||e.explicit)?/^\s*\w*$/.test(r)?{from:m.from,options:pP,validFor:/^\w*$/}:pD.test(r)?{from:m.from,options:pL,validFor:/^\w*$/}:null:null}]})}({userData:l,currentVariantId:i}),pk.Lz.lineWrapping,(0,pS.qf)(o??"")],[a,l,i,o]);return(0,r.jsx)("div",{style:{height:u,minHeight:"8rem"},className:b("w-full rounded-[--radius] border border-[--border] bg-[--paper] shadow-sm overflow-hidden transition","resize-y","focus-within:ring-1 focus-within:ring-[--ring] focus-within:border-brand",d&&"opacity-60 pointer-events-none",c),children:(0,r.jsx)(pk.Ay,{className:"h-full",value:t,onChange:s,editable:!d,theme:pC,indentWithTab:!1,height:"100%",basicSetup:{lineNumbers:!0,foldGutter:!1,highlightActiveLine:!1,highlightActiveLineGutter:!1,autocompletion:!1,bracketMatching:!0,closeBrackets:!0,searchKeymap:!1,highlightSelectionMatches:!1,indentOnInput:!1,drawSelection:!0},extensions:m})})}let p$=/^[a-z0-9][a-z0-9_-]{0,31}$/;function pO(){let{userData:e,setUserData:t}=s4(),{status:s}
18=e$(),[a,l]=(0,n.useState)(null),i=null==s?void 0:s.settings.variants,o=(0,n.useMemo)(()=>({maxScriptLength:(null==i?void 0:i.maxScriptLength)??4e3,maxInstructions:(null==i?void 0:i.maxInstructions)??100,maxValueDepth:(null==i?void 0:i.maxValueDepth)??10,maxPathSegments:(null==i?void 0:i.maxPathSegments)??12,maxPathMatches:(null==i?void 0:i.maxPathMatches)??200}),[i]),d=e.variants??[],c=(null==i?void 0:i.max)??10,u=e=>t(t=>({...t,variants:e}));return(null==i?void 0:i.access)==="none"?(0,r.jsx)(nU,{intent:"info-basic",title:"Variants are disabled",description:"This instance has turned off config variants."}):(0,r.jsxs)("div",{className:"space-y-4",id:"variants",children:[(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("p",{className:"text-sm text-[--muted]",children:["A variant is a named set of instructions that adjusts this configuration on the fly. Install one by adding"," ",(0,r.jsx)("code",{className:"text-xs px-1 py-0.5 rounded bg-[--subtle]",children:"?v=<id>"})," ","to your manifest URL and your client treats it as a separate addon. Use it for a second formatter, a different debrid account, or a tighter filter set without maintaining a second config."," ",(0,r.jsx)("a",{href:"https://docs.aiostreams.viren070.me/reference/config-expressions",target:"_blank",rel:"noreferrer",className:"underline",children:"Language reference"})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,r.jsx)(w,{size:"sm",intent:"white",rounded:!0,leftIcon:(0,r.jsx)(nD.GGD,{}),onClick:()=>{d.length>=c?x.oR.error(`This instance allows at most ${c} variants.`):u([...d,{id:function(e){if(!e.some(e=>"variant"===e.id))return"variant";for(let t=2;;t++){let s=`variant-${t}`;if(!e.some(e=>e.id===s))return s}}(d),script:""}])},disabled:d.length>=c,children:"Add variant"}),(0,r.jsxs)("span",{className:"text-xs text-[--muted]",children:[d.length," of ",c," used"]})]})]}),d.map((t,s)=>(0,r.jsx)(pF,{variant:t,variants:d,userData:e,limits:o,onChange:e=>u(d.map((t,a)=>a===s?{...t,...e}:t)),onDelete:()=>u(d.filter((e,t)=>t!==s)),onPreview:()=>l(t.id)},s)),0===d.length&&(0,r.jsx)(nU,{intent:"info-basic",title:"No variants yet",description:"Add one to serve a second, adjusted version of this configuration from the same UUID."}),(0,r.jsx)(pz,{variantId:a,variants:d,userData:e,limits:o,onClose:()=>l(null)})]})}function pF(e){let{variant:t,variants:s,userData:a,limits:l,onChange:i,onDelete:o,onPreview:d}=e,c=(0,n.useMemo)(()=>px(t.script,l).diagnostics,[t.script,l]).filter(e=>"error"===e.severity),u=p$.test(t.id)?s.filter(e=>e.id===t.id).length>1?"Another variant already uses this id.":void 0:'Use 1-32 characters: lowercase letters, digits, "-" or "_".';return(0,r.jsxs)(cr,{title:t.name||t.id,action:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(rs,{label:"Enabled",side:"right",value:!1!==t.enabled,onValueChange:e=>i({enabled:e})}),(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(nD.Vap,{}),onClick:d}),(0,r.jsx)(E,{size:"sm",intent:"alert-subtle",icon:(0,r.jsx)(nD.IXo,{}),onClick:o})]}),children:[(0,r.jsxs)("div",{className:"grid gap-3 md:grid-cols-2",children:[(0,r.jsx)(W,{label:"Id",help:"Used in the install URL as ?v=<id>. Changing it breaks existing installs.",value:t.id,error:u,onValueChange:e=>i({id:e.toLowerCase()})}),(0,r.jsx)(W,{label:"Name",help:'A label for this list and the install page. To rename the addon in your client, write set addonName = "..." below.',value:t.name??"",onValueChange:e=>i({name:e||void 0})})]}),(0,r.jsx)(pU,{value:t.script,onValueChange:e=>i({script:e}),limits:l,userData:a,currentVariantId:t.id,placeholder:"# Example: set formatter.id = 'prism' to switch to the built-in Prism formatter."}),(0,r.jsxs)("div",{className:"flex items-center justify-between text-xs text-[--muted]",children:[(0,r.jsxs)("span",{children:[t.script.length," / ",l.maxScriptLength," characters"]}),(0,r.jsx)("span",{className:c.length?"text-[--red]":void 0,children:c.length?`${c.length} error${1===c.length?"":"s"}`:"No errors"})]})]})}function pz(e){let{variantId:t,variants:s,userData:a,limits:l,onClose:i}
18=e,[o,d]=(0,n.useState)(null);(0,n.useEffect)(()=>{let e=s.find(e=>e.id===t);e&&d(e)},[t,s]);let c=(0,n.useMemo)(()=>{if(!o)return null;let{program:e,diagnostics:t}=px(o.script,l),r=t.filter(e=>"error"===e.severity);if(r.length)return{errors:r,notes:[],patched:null};let n=new Map(s.map(e=>[e.id,px(e.script,l).program])),i=function(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=structuredClone(e);return{userData:a,...function(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=[],r=new Set;return!function e(t,s,a,r,n,l,i){let o=a.maxDepth??5,d=a.limits??m6;for(let x of s.statements){var c,u,m,p,h;if("useVariant"===x.op){if(i>=o){r.push(pN(x,`variant nesting exceeds the maximum depth of ${o}`,"limit"));continue}if(l.has(x.id)){r.push(pN(x,`variant "${x.id}" is already being applied`,"unknown-variant"));continue}let s=null==(c=a.resolveVariant)?void 0:c.call(a,x.id);if(!s){r.push(pN(x,`unknown variant "${x.id}"`,"unknown-variant"));continue}l.add(x.id),e(t,s,a,r,n,l,i+1),l.delete(x.id);continue}if("useFormatter"===x.op){let e=null==t||null==(p=t.formatter)||null==(m=p.definitions)||null==(u=m.saved)?void 0:u[x.name];if(!e){r.push(pN(x,`no saved formatter named "${x.name}"`,"unknown-formatter"));continue}t.formatter={...t.formatter,id:"custom",definitions:{...null==(h=t.formatter)?void 0:h.definitions,custom:{
18name:e.name,description:e.description}}},n.add("formatter");continue}let s="set"===x.op||"merge"===x.op||"add"===x.op||"prepend"===x.op||"enable"===x.op||"disable"===x.op,g=function(e,t,s){let a=[{kind:"key",name:t.root},...t.segments],r=a[a.length-1],n=[e];for(let e=0;e<a.length-1;e++){let t=s?"key"===a[e+1].kind?{}:[]:void 0;if(0===(n=function(e,t,s){let a=[];for(let r of e)switch(t.kind){case"key":if(!pg(r))break;void 0===r[t.name]&&void 0!==s&&pv(r,t.name,s),void 0!==r[t.name]&&a.push(r[t.name]);break;case"index":{if(!Array.isArray(r))break;let e=py(t.index,r.length);void 0!==e&&a.push(r[e]);break}case"all":Array.isArray(r)&&a.push(...r);break;case"filter":Array.isArray(r)&&a.push(...r.filter(e=>pj(e,t)))}return a}(n,a[e],t)).length)return[]}let l=[];for(let e of n)switch(r.kind){case"key":pg(e)&&l.push({container:e,key:r.name});break;case"index":{if(!Array.isArray(e))break;let t=py(r.index,e.length);void 0!==t&&l.push({container:e,key:t});break}case"all":Array.isArray(e)&&e.forEach((t,s)=>l.push({container:e,key:s}));break;case"filter":Array.isArray(e)&&e.forEach((t,s)=>
18{pj(t,r)&&l.push({container:e,key:s})})}return l}(t,"enable"===x.op||"disable"===x.op?{...x.path,segments:[...x.path.segments,{kind:"key",name:"enabled"}]}:x.path,s);if(0===g.length){r.push(pN(x,`"${x.path.raw}" matched nothing, instruction skipped`,"no-match"));continue}if(g.length>d.maxPathMatches){r.push(pN(x,`"${x.path.raw}" matched ${g.length} places, over the limit of ${d.maxPathMatches}`,"limit"));continue}switch(x.op){case"set":for(let e of g)pv(e.container,e.key,pf(x.value));break;case"enable":case"disable":for(let e of g)pv(e.container,e.key,"enable"===x.op);break;case"merge":for(let e of g)pv(e.container,e.key,function e(t,s){if(!pg(s))return pf(s);let a=pg(t)?{...t}:{};for(let[t,r]of Object.entries(s))m4.has(t)||(null===r?delete a[t]:a[t]=e(a[t],r));return a}(e.container[e.key],x.value));break;case"unset":pw(g);break;case"clear":for(let e of g){let t=e.container[e.key];Array.isArray(t)?pv(e.container,e.key,[]):pg(t)?pv(e.container,e.key,{}):r.push(pN(x,`"${x.path.raw}" is not a list or object, clear skipped`,"no-match"))}break;case"add":case"prepend":for(let e of g){let t=e.container[e.key];if(void 0===t&&(t=[],pv(e.container,e.key,t)),!Array.isArray(t)){r.push(pN(x,`"${x.path.raw}" is not a list, ${x.op} skipped`,"no-match"));continue}let s=x.values.filter(e=>!t.some(t=>pb(t,e))).map(pf);"add"===x.op?t.push(...s):t.unshift(...s)}break;case"remove":if(0===x.values.length){pw(g);break}for(let e of g){let t=e.container[e.key];if(!Array.isArray(t)){r.push(pN(x,`"${x.path.raw}" is not a list, remove skipped`,"no-match"));continue}pv(e.container,e.key,t.filter(e=>!x.values.some(t=>pb(e,t))))}}n.add(x.path.root)}}(e,t,s,a,r,new Set(s.activeVariants??[]),0),{notes:a,touchedRoots:r}}(a,t,s)}}(a,e,{resolveVariant:e=>n.get(e),limits:l});return{errors:[],notes:i.notes,patched:i.userData}},[o,s,a,l]);return(0,r.jsx)(ty,{open:null!==t,onOpenChange:e=>!e&&i(),title:`Preview: ${(null==o?void 0:o.name)||(null==o?void 0:o.id)||""}`,contentClass:"max-w-4xl",children:(null==c?void 0:c.errors.length)?(0,r.jsx)(nU,{intent:"alert",title:"This script does not parse",description:c.errors.map(e=>`Line ${e.line}: ${e.message}`).join("\n")}):(0,r.jsxs)("div",{className:"space-y-3",children:[(null==c?void 0:c.notes.length)?(0,r.jsx)(nU,{intent:"warning",title:"Some instructions matched nothing",description:c.notes.map(e=>`Line ${e.line}: ${e.message}`).join("\n")}):null,(0,r.jsx)(df,{oldConfig:a,newConfig:(null==c?void 0:c.patched)??null})]})})}function pV(){return(0,r.jsx)(ru,{className:"space-y-4 p-4 sm:p-8",children:(0,r.jsx)(pq,{})})}function pq(){let{mode:e}=tX(),{tab:t,setTab:s}=ao("miscellaneous");return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center w-full",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"Miscellaneous"}),(0,r.jsx)("p",{className:"text-[--muted]",children:"Additional settings and configurations."})]}),(0,r.jsx)("div",{className:"hidden lg:block lg:ml-auto",children:(0,r.jsx)(dT,{})})]}),(0,r.jsx)(dO,{tabs:[{value:"background",label:"Background",icon:(0,r.jsx)(cb.uoG,{className:"w-4 h-4"}),content:(0,r.jsx)(mq,{})},{value:"playback",label:"Playback",icon:(0,r.jsx)(cb.gSK,{className:"w-4 h-4"}),content:"pro"===e?(0,r.jsx)(mB,{}):(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center gap-2",children:[(0,r.jsx)(nD.VSk,{className:"w-10 h-10 text-[--muted]"}),(0,r.jsx)("p",{className:"text-lg font-semibold",children:"Advanced Mode Required"}),(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"Playback settings are only available in Advanced mode."})]})},{value:"display",label:"Display",icon:(0,r.jsx)(cb.Ny1,{className:"w-4 h-4"}),content:"pro"===e?(0,r.jsx)(mK,{}):(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center gap-2",children:[(0,r.jsx)(nD.VSk,{className:"w-10 h-10 text-[--muted]"}),(0,r.jsx)("p",{className:"text-lg font-semibold",children:"Advanced Mode Required"}),(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"Display settings are only available in Advanced mode."})]})},{value:"parent",label:"Parent Config",icon:(0,r.jsx)(nD.ayE,{className:"w-4 h-4"}),content:(0,r.jsx)(m3,{})},{value:"variants",label:"Variants",icon:(0,r.jsx)(nD.s_k,{className:"w-4 h-4"}),content:"pro"===e?(0,r.jsx)(pO,{}):(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 text-center gap-2",children:[(0,r.jsx)(nD.VSk,{className:"w-10 h-10 text-[--muted]"}),(0,r.jsx)("p",{className:"text-lg font-semibold",children:"Advanced Mode Required"}),(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"Variants are only available in Advanced mode."})]})}],activeTab:t,onTabChange:s})]})}
18var pB=s(1131),pK=s(1896),pH=s(9799),pG=s(1915),pW=s(2898);function pY(e,t,s){return Object.fromEntries(Object.entries(e??{}).flatMap(e=>{let[a,r]=e,n=null==t?void 0:t.find(e=>e.id===a);if((null==n?void 0:n.type)==="password")return void 0!==s&&void 0!==r&&""!==r?[[a,s]]:[];let l=null==n?void 0:n.subOptions;return(null==l?void 0:l.length)&&r&&"object"==typeof r&&!Array.isArray(r)?[[a,pY(r,l,s)]]:[[a,r]]}))}function pJ(e){let{open:t,onOpenChange:s,userData:a,filterCredentials:l}=e,{status:i}=e$(),[o,d]=(0,n.useState)(""),[c,u]=(0,n.useState)(""),[m,p]=(0,n.useState)(""),[h,g]=(0,n.useState)("Debrid"),[f,b]=(0,n.useState)("");return(0,n.useEffect)(()=>{t&&(d(""),u(""),p(""),g("Debrid"),b(""))},[t]),(0,r.jsx)(ty,{open:t,onOpenChange:s,title:"Export as Template",description:"Configure your template metadata and settings",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(nU,{intent:"info",description:(0,r.jsxs)("div",{className:"space-y-2 text-sm",children:[(0,r.jsx)("p",{children:"A template is a configuration file that others can use as a starting point. All personal credentials will be replaced with placeholders."}),(0,r.jsxs)("p",{children:[(0,r.jsx)("strong",{children:"Want more control?"})," Edit the exported JSON manually to add advanced features like:"]}),(0,r.jsxs)("ul",{className:"list-disc list-inside ml-2 space-y-1",children:[(0,r.jsx)("li",{children:"Conditional inputs and fields based on user selections"}),(0,r.jsx)("li",{children:"Template placeholders for dynamic values"}),(0,r.jsx)("li",{children:"Service filtering and smart service selection"}),(0,r.jsx)("li",{children:"Custom validation and input grouping"})]}),(0,r.jsxs)("p",{children:["See the"," ",(0,r.jsx)("a",{href:"https://docs.aiostreams.viren070.me/guides/templates",target:"_blank",className:"text-[--brand] hover:text-[--brand]/80 hover:underline",rel:"noopener noreferrer",children:"Templates docs"})," ","for detailed documentation."]})]})}),(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(W,{label:"Template Name",placeholder:"e.g. My AIOStreams setup",value:o,onValueChange:d,required:!0}),(0,r.jsx)(np,{label:"Description",placeholder:"Describe what makes this template useful...",value:c,onValueChange:u,required:!0,rows:3}),(0,r.jsx)(W,{label:"Author",placeholder:"Your name or username",value:m,onValueChange:p,required:!0}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Category"}),(0,r.jsx)("div",{className:"flex gap-2",children:["Debrid","P2P","Custom"].map(e=>(0,r.jsx)(w,{intent:h===e?"primary":"gray-outline",size:"sm",onClick:()=>g(e),type:"button",children:e},e))})]}),"Custom"===h&&(0,r.jsx)(W,{label:"Custom Category",placeholder:"Enter category name (max 20 characters)",value:f,onValueChange:e=>{e.length<=20&&b(e)},required:!0})]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2 pt-2 border-t border-gray-700",children:[(0,r.jsx)(w,{intent:"primary-outline",onClick:()=>s(!1),children:"Cancel"}),(0,r.jsx)(w,{intent:"white",rounded:!0,onClick:()=>{if(!o.trim())return void x.oR.error("Please enter a template name");if(!c.trim())return void x.oR.error("Please enter a description");if(!m.trim())return void x.oR.error("Please enter an author name");if("Custom"===h&&!f.trim())return void x.oR.error("Please enter a custom category name");try{var e,t;let r=l(a);null==(e=a.services)||e.filter(e=>e.enabled).map(e=>e.id),a.tmdbApiKey&&(r.tmdbApiKey="<template_placeholder>"),a.tmdbAccessToken&&(r.tmdbAccessToken="<template_placeholder>"),a.tvdbApiKey&&(r.tvdbApiKey="<template_placeholder>"),a.rpdbApiKey&&(r.rpdbApiKey="<template_placeholder>"),(null==(t=a.proxy)?void 0:t.enabled)&&(r.proxy={...r.proxy,url:a.proxy.url?"<template_placeholder>":void 0,publicUrl:a.proxy.publicUrl?"<template_placeholder>":void 0,credentials:a.proxy.credentials?"<template_placeholder>":void 0,publicIp:a.proxy.publicIp?"<template_placeholder>":void 0}),r.presets&&r.presets.length>0&&(r.presets=r.presets.map(e=>{var t;let s=null==i?void 0:i.settings.presets.find(t=>t.ID===e.type),r=null==(t=a.presets)?void 0:t.find(t=>t.instanceId==e.instanceId);return{...e,options:pY((null==r?void 0:r.options)??e.options,null==s?void 0:s.OPTIONS,"<template_placeholder>")}}));let n="Custom"===h?f.trim():h,d=new Date,u=e=>e.toString().padStart(2,"0"),p=`${d.getFullYear()}-${u(d.getMonth()+1)}-${u(d.getDate())}.${u(d.getHours())}-${u(d.getMinutes())}-${u(d.getSeconds())}`,g={metadata:{id:`${o.toLowerCase().replace(/\s+/g,"-")}-${p}-${Math.random().toString(36).slice(2,9)}`,name:o,description:c,source:"external",author:m,version:"1.0.0",category:n,services:void 0,serviceRequired:!1,setToSaveInstallMenu:!0},config:r},b=JSON.stringify(g,null,2),v=new Blob([b],{type:"application/json"}),y=URL.createObjectURL(v),j=document.createElement("a");j.href=y,j.download=`${g.metadata.id}-template.json`,document.body.appendChild(j),j.click(),document.body.removeChild(j),URL.revokeObjectURL(y),x.oR.success("Template exported successfully"),s(!1)}catch(e){x.oR.error("Failed to export template")}},children:"Export Template"})]})]})})}function pZ(){let{user:e}=tS(),{uuid:t,password:s}=s4(),a=(0,o.jE)(),{data:l}=(0,eU.I)({...eL,enabled:!!e}),i=(null==l?void 0:l.profiles.find(e=>e.uuid===t))??null,[d,c]=n.useState(""),[u,m]=n.useState(""),[p,h]=n.useState(!1);if(n.useEffect(()=>{c((null==i?void 0:i.label)??""),m((null==i?void 0:i.alias)??"")},[null==i?void 0:i.id,null==i?void 0:i.label,null==i?void 0:i.alias]),!e||!t||!s)return null;
18let g=async(e,t)=>{h(!0);try{await e(),await a.invalidateQueries({queryKey:eL.queryKey}),x.oR.success(t)}catch(e){x.oR.error(e instanceof Error?e.message:"Something went wrong")}finally{h(!1)}};return(0,r.jsx)(cr,{title:"Profile",description:i?`Saved to ${e.username}. Pick it from Load Configuration to reopen it without the password.`:`Save this configuration to ${e.username} so you can reopen it without the password.`,children:i?(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-end gap-2",children:[(0,r.jsx)(W,{label:"Name",value:d,onValueChange:c,className:"flex-1"}),(0,r.jsx)(w,{intent:"gray-subtle",rounded:!0,loading:p,disabled:!d.trim()||d.trim()===i.label,onClick:()=>g(()=>ey(i.id,{label:d.trim()}),"Renamed"),children:"Rename"})]}),(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-end gap-2",children:[(0,r.jsx)(W,{label:"Share alias",value:u,onValueChange:m,placeholder:"Optional, e.g. living-room",className:"flex-1"}),(0,r.jsx)(w,{intent:"gray-subtle",rounded:!0,loading:p,disabled:u.trim().toLowerCase()===(i.alias??""),onClick:()=>g(()=>ey(i.id,{alias:u.trim()?u.trim():null}),u.trim()?"Alias set":"Alias removed"),children:u.trim()?"Set alias":"Clear alias"})]}),(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:i.alias?"Your manifest URL above uses this alias. Anyone with it can install this configuration, so treat it like the long URL, and keep it hard to guess.":"An alias shortens your manifest URL above. It replaces the UUID and password in the link, so it grants the same access."})]}),(0,r.jsx)(w,{intent:"alert-subtle",rounded:!0,size:"sm",loading:p,onClick:()=>g(()=>ej(i.id),"Profile deleted. The configuration itself is untouched."),children:"Delete profile"})]}):(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-end gap-2",children:[(0,r.jsx)(W,{label:"Name",value:d,onValueChange:c,placeholder:"Optional",className:"flex-1"}),(0,r.jsx)(w,{intent:"white",rounded:!0,loading:p,onClick:()=>g(()=>ev(t,s,d.trim()||void 0),"Saved to your profile"),children:"Save as profile"})]})})}function pQ(e){let{onClick:t,icon:s,title:a,description:n}=e;return(0,r.jsxs)("button",{onClick:t,className:"group relative flex flex-col items-center gap-4 roun
18ded-xl border-2 border-gray-700 bg-gradient-to-br from-gray-800/50 to-gray-800/30 p-6 text-center transition-all hover:border-brand-400 hover:from-brand-400/10 hover:to-brand-400/5 focus:outline-none focus-visible:ring-1 focus-visible:ring-brand-400",children:[(0,r.jsx)("div",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-gradient-to-br from-brand-500 to-brand-600 text-white shadow-lg transition-transform group-hover:scale-110",children:s}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-lg font-bold text-white",children:a}),(0,r.jsx)("p",{className:"mt-2 text-sm leading-relaxed text-gray-400",children:n})]})]})}function pX(e){let{logoSrc:t,icon:s,name:a,description:n,onClick:l,unofficial:i,beta:o,author:d,disabled:c,disabledReason:u}=e;return(0,r.jsxs)("button",{onClick:l,disabled:c,className:`group relative flex items-center gap-3 rounded-xl border-2 border-gray-700 bg-gradient-to-br from-gray-800/50 to-gray-800/30 p-3 text-left transition-all focus:outline-none focus-visible:ring-1 focus-visible:ring-brand-400 ${c?"cursor-not-allowed opacity-60":"hover:border-brand-400 hover:from-brand-400/10 hover:to-brand-400/5"}`,children:[(0,r.jsx)("div",{className:"flex-shrink-0 h-8 w-8 rounded-lg overflow-hidden flex items-center justify-center text-brand-400",children:t?(0,r.jsx)("img",{src:t,alt:a,className:"h-full w-full object-contain"}):s}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-white",children:a}),o&&(0,r.jsx)("span",{className:"rounded-full border border-amber-400/30 bg-amber-500/10 px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide text-amber-300",children:"Beta"}),i&&(0,r.jsx)("span",{className:"rounded-full border border-gray-600 bg-gray-800/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide text-gray-300",children:"Unofficial"})]}),(0,r.jsx)("p",{className:"text-xs text-gray-400 mt-0.5",children:n}),d&&(0,r.jsxs)("p",{className:"text-[11px] text-gray-500 mt-0.5",children:["Integration author: ",d]}),u&&(0,r.jsx)("p",{className:"text-[11px] text-amber-300 mt-1",children:u})]})]})}function p0(e){let{onSubmit:t,passwordRequirements:s,newPassword:a,confirmNewPassword:n,onNewPasswordChange:l,onConfirmNewPasswordChange:i,createLoading:o}=e;return(0,r.jsx)(cr,{title:"Create Configuration",description:"Set up your personalised addon configuration",children:(0,r.jsxs)("form",{onSubmit:t,className:"space-y-4",children:[(0,r.jsxs)("div",{children:[s.length>0&&(null==a?void 0:a.length)>0&&(0,r.jsx)(nU,{intent:"alert",title:"Password Requirements",description:(0,r.jsx)("ul",{className:"list-disc list-inside",children:s.map(e=>(0,r.jsx)("li",{children:e},e))})}),(0,r.jsx)(Z,{label:"Password",id:"password",name:"new-password",value:a,onValueChange:l,placeholder:"Enter a password to protect your configuration",required:!0,autoComplete:"new-password"}),(0,r.jsx)("div",{className:"pt-2",children:(0,r.jsx)(Z,{label:"Confirm Password",id:"confirm-password",name:"confirm-new-password",value:n,onValueChange:i,placeholder:"Re-enter your password",required:!0,autoComplete:"new-password"})}),(0,r.jsx)("p",{className:"text-sm text-[--muted] mt-1",children:"This is the password you will use to access and update your configuration later. You can change your password later using the Change Password option, but please remember your current password as it is required to make changes."})]}),(0,r.jsx)(w,{intent:"white",type:"submit",loading:o,rounded:!0,children:"Create"})]})})}function p1(e){let{uuid:t,onCopyUuid:s,onSave:a,saveLoading:n,showChanges:l,onShowChangesChange:i}=e;return(0,r.jsxs)(cr,{title:"Save Configuration",description:"Save your configuration to your account by clicking Save below.",children:[(0,r.jsx)("div",{className:"flex items-start gap-1",children:(0,r.jsx)(nU,{intent:"info",isClosable:!1,description:(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("span",{className:"text-md text-[--primary]",children:["Your UUID: ",(0,r.jsx)("span",{className:"font-bold",children:t})]}),(0,r.jsx)(tC.Xpf,{className:"min-h-5 min-w-5 cursor-pointer",onClick:s})]}),(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"Save your UUID and password - you'll need them to update your configuration later"})]}),className:"flex-1"})}),(0,r.jsx)("form",{onSubmit:a,children:(0,r.jsxs)("div",{className:"flex items-center justify-between gap-4 mt-4",children:[(0,r.jsx)(w,{type:"submit",intent:"white",loading:n,rounded:!0,children:"Save"}),(0,r.jsx)("div",{className:"flex items-center gap-2",children:(0,r.jsx)(rs,{id:"show-changes",label:"Show changes before saving",value:l,onValueChange:i})})]})})]})}let p2=[{name:"Nuvio",logoSrc:"https://nuvio.tv/assets/Logo_1080x1080.png",url:"https://nuvio.tv/"},{name:"RealStream",logoSrc:"https://rstream.app/logo-realstream.png",url:"https://rstream.app/",imgClassName:"scale-150"},{name:"Aurora",logoSrc:"https://auroramediacenter.com/logo.png",url:"https://auroramediacenter.com/",imgClassName:"scale-150"},{name:"Fusion",logoSrc:"https://fusionapp.dev/FUSN_dark-iOS.png",url:"https://fusionapp.dev/"},{name:"Omni",logoSrc:"https://omni.stkc.win/favicon.ico",url:"https://omni.stkc.win/"}];function p3(){return(0,r.jsx)("div",{className:"flex flex-wrap items-center gap-2 pt-1.5 ml-1",children:p2.map(e=>(0,r.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",title:e.name,"aria-label":`${e.name} (opens in a new tab)`,className:"flex-shrink-0 h-7 w-7 rounded-md overflow-hidden transition-transform hover:scale-110 focus:outline-none focus-visible:ring-1 focus-visible:ring-brand-400",children:(0,r.jsx)("img",{src:e.logoSrc,alt:e.name,className:`h-full w-full object-contain ${e.imgClassName??""}`})},e.name))})}function p6(e){let{variants:t,selected:s,onChange:a,location:n,onLocationChange:l}=e,i=e=>b("px-2.5 py-1 text-xs font-medium rounded-full border transition-colors",e?"bg-[--brand]/20 text-[--brand] border-[--brand]/50":"bg-transparent text-[--muted] border-[--border] hover:bg-[--subtle]");return(0,r.jsxs)("div",{className:"w-full rounded-xl border border-gray-700 bg-gray-800/30 p-5 shadow-inner",children:[(0,r.jsx)("h3",{className:"text-lg font-semibold text-white",children:"Variant"}),(0,r.jsx)("p",{className:"text-sm text-[--muted] mt-1",children:"The links below install the selected variant. Each one appears as a separate addon in your client; pick more than one to combine them."}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-1.5 mt-4",children:[(0,r.jsx)("button",{type:"button",onClick:()=>a([]),className:i(0===s.length),children:"Base config"}),t.map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>{let t;return t=e.id,a(s.includes(t)?s.filter(e=>e!==t):[...s,t])}
18,className:i(s.includes(e.id)),children:e.name||e.id},e.id))]}),s.length>0&&(0,r.jsx)("div",{className:"mt-5 pt-4 border-t border-gray-700/50 max-w-md",children:(0,r.jsx)(rn,{label:"Selector location",help:"path"===n?"In the path, as /v/id. Survives clients that rebuild request URLs from the base and would drop a query string.":"In the query string, as ?v=id. Some clients drop it after the manifest.",value:n,onValueChange:e=>l(e),options:[{value:"path",label:"Path segment (/v/)"},{value:"query",label:"Query parameter (?v=)"}]})})]})}function p5(e){let{encodedManifest:t,manifestUrl:s,usingAlias:a,variantSelector:n,onCopyManifestUrl:l,onOpenChillio:i,onOpenSeanime:o,onOpenJellyfin:d,onOpenAniyomi:c,onOpenNabIndexer:u,onOpenSearchApi:m,disableSeanimeCard:p,seanimeDisabledReason:h,disableNabIndexerCard:x,nabIndexerDisabledReason:g,disableSearchApiCard:f,searchApiDisabledReason:b}=e;return(0,r.jsx)(cr,{title:"Installation Options",description:"Install your addon using your preferred method. If a reinstall is necessary, a pop-up will tell you — otherwise, you do not need to reinstall.",children:(0,r.jsxs)("div",{className:"flex flex-col gap-6",children:[n,(0,r.jsx)("div",{className:"w-full rounded-xl border border-gray-700 bg-gray-800/30 p-5 shadow-inner",children:(0,r.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6 lg:gap-8 lg:items-center",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-4",children:[(0,r.jsx)("div",{className:"flex-shrink-0 h-12 w-12 rounded-lg bg-gray-900 flex items-center justify-center p-2 shadow-sm",children:(0,r.jsx)("img",{src:"https://raw.githubusercontent.com/Stremio/stremio-brand/refs/heads/master/logos/PNG/stremio-logo-800px.png",alt:"Stremio",className:"h-full w-full object-contain"})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-lg font-semibold text-white",children:"Stremio"}),(0,r.jsx)("p",{className:"text-sm text-gray-400",children:"Install to Stremio or other Stremio addon compatible clients using the Manifest URL."})]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[(0,r.jsx)(w,{onClick:()=>window.open(s.replace(/^https?:\/\//,"stremio://")),intent:"primary",className:"w-full shadow-md",children:"Install to Stremio"}),(0,r.jsx)(w,{onClick:()=>window.open(`https://web.stremio.com/#/addons?addon=${t}`),intent:"gray-outline",className:"w-full",children:"Install to Stremio Web"})]})]}),(0,r.jsxs)("div",{className:"space-y-1.5 lg:border-l lg:border-gray-700/50 lg:pl-8",children:[(0,r.jsx)("label",{className:"text-xs font-medium text-gray-400 ml-1",children:a?"Manifest URL (alias)":"Direct Manifest URL"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(W,{type:"text",readOnly:!0,value:s,className:"flex-1 font-mono text-sm bg-black/20",onClick:e=>e.currentTarget.select()}),(0,r.jsx)(w,{onClick:l,intent:"primary",className:"shrink-0 px-3","aria-label":"Copy install link",children:(0,r.jsx)(pB.A,{className:"h-4 w-4"})})]}),(0,r.jsxs)("p",{className:"text-xs text-gray-500 ml-1",children:["Install manually to Stremio or any Stremio addon compatible client.",a&&" Your profile alias stands in for the UUID and password; the long URL still works."]}),(0,r.jsx)(p3,{})]})]})}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("h3",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider mb-4 flex items-center gap-2",children:[(0,r.jsx)("div",{className:"h-px bg-gray-700 flex-1"}),"Other apps",(0,r.jsx)("div",{className:"h-px bg-gray-700 flex-1"})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3",children:[(0,r.jsx)(pX,{logoSrc:"https://seanime.app/seanime-logo.png",name:"Seanime",description:"Anime-focused client",onClick:o,disabled:p,disabledReason:h}),(0,r.jsx)(pX,{logoSrc:"https://raw.githubusercontent.com/jellyfin/jellyfin-ux/refs/heads/master/logos/PNG-4x/jellyfin-icon--color-on-dark.png",name:"Jellyfin",description:"Via Gelato plugin",unofficial:!0,author:"lostb1t",onClick:d}),(0,r.jsx)(pX,{logoSrc:"https://link.chillio.app/app-icon.png",name:"Chillio",description:"Via ChillLink protocol",onClick:i}),(0,r.jsx)(pX,{logoSrc:"https://aniyomi.org/img/logo-128px.png",name:"Aniyomi / Animiru",description:"Extension-based integration",unofficial:!0,author:"worldInColors",onClick:c})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("h3",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider mb-4 flex items-center gap-2",children:[(0,r.jsx)("div",{className:"h-px bg-gray-700 flex-1"}),"Programmatic / API access",(0,r.jsx)("div",{className:"h-px bg-gray-700 flex-1"})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3",children:[(0,r.jsx)(pX,{icon:(0,r.jsx)(pK.A,{className:"h-5 w-5"}),name:"Newznab / Torznab",description:"Indexer for Prowlarr, NZBHydra & *Arr apps",onClick:u,disabled:x,disabledReason:g}),(0,r.jsx)(pX,{icon:(0,r.jsx)(pH.A,{className:"h-5 w-5"}),name:"Search API",description:"JSON stream search endpoint",onClick:m,disabled:f,disabledReason:b})]})]})]})})}function p4(e){let{onExportOpen:t,onImportOpen:s,onImport:a,importFileRef:n}=e;return(0,r.jsx)(cr,{title:"Backups",description:"Export your settings or restore from a backup file",children:(0,r.jsxs)("div",{className:"flex flex-wrap gap-3",children:[(0,r.jsx)(w,{onClick:t,leftIcon:(0,r.jsx)(pG.A,{}),intent:"gray",children:"Export"}),(0,r.jsx)("input",{type:"file",accept:".json",className:"hidden",id:"import-file",onChange:a,ref:n}),(0,r.jsx)(w,{onClick:s,leftIcon:(0,r.jsx)(pW.A,{}),intent:"gray",children:"Import"})]})})}function p9(e){let{hasUser:t,onChangePasswordOpen:s,onDeleteUserOpen:a,onResetOpen:n}=e;return(0,r.jsx)(cr,{title:"Danger Zone",description:"Perform potentially destructive actions that cannot be undone",className:"lg:bg-red-950/70 border-red-500/20",titleClassName:"group-hover/settings-card:from-red-500/10 group-hover/settings-card:to-red-950/20",children:(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[t&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(w,{intent:"alert",rounded:!0,onClick:s,children:"Change Password"}),(0,r.jsx)(w,{intent:"alert",rounded:!0,onClick:a,children:"Delete User"})]}),(0,r.jsx)(w,{intent:"alert",rounded:!0,onClick:n,children:"Reset Configuration"})]})})}let p8="{catalog.name} - {catalog.type}",p7="aiostreams:install:variant-location",he="aiostreams:seanime:stremio-custom-source:manifest-url",ht="aiostreams:seanime:stremio-custom-source:name-template",hs="aiostreams:seanime:stremio-custom-source:catalog-selections",ha={title:e=>e.split(" ").map(e=>e.toLowerCase()).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),upper:e=>e.toUpperCase(),lower:e=>e.toLowerCase(),length:e=>e.length.toString()},hr=e=>`${e.type}::${e.id}`,hn=e=>{if("u"<typeof window)return null;try{return window.localStorage.getItem(e)}catch{return null}},hl=(e,t)=>{if("u">typeof window)try{window.localStorage.setItem(e,t)}catch{}},hi=e=>{if("u">typeof window)try{window.localStorage.removeItem(e)}catch{}};function ho(e,t){let s={addon:{name:t.addonName},catalog:{name:t.catalogName,type:t.catalogType}};return e.replace(/\{([a-z]+)\.([a-z]+)((?:::[^{}:\s]+)*)\}/gi,(e,t,a,r)=>{var n;let l=null==(n=s[t])?void 0:n[a];return"string"!=typeof l?e:("string"==typeof r&&r.length>0?r.split("::").map(e=>
18e.trim().toLowerCase()).filter(Boolean):[]).reduce((e,t)=>{let s=ha[t];return s?s(e):e},l)})}function hd(e){let{open:t,onOpenChange:s,baseUrl:a,initialManifestUrl:l}=e,[i,o]=n.useState("url"),[d,c]=n.useState(l),[u,m]=n.useState(null),[p,h]=n.useState([]),[g,f]=n.useState(!1),[b,v]=n.useState(null),[y,j]=n.useState(""),[N,k]=n.useState(p8);n.useEffect(()=>{if(!t){o("url"),m(null),h([]),v(null),j("");return}let e=hn(ht),s=hn(he);s===l&&hi(he),c(s&&s!==l?s:l),k(e||p8)},[t,l]),n.useEffect(()=>{t&&hl(ht,N)},[N,t]),n.useEffect(()=>{if(!t)return;let e=d.trim();e&&e!==l?hl(he,e):hi(he)},[d,l,t]),n.useEffect(()=>{t&&0!==p.length&&hl(hs,JSON.stringify(p.reduce((e,t)=>(e[hr(t)]={selected:t.selected,displayName:t.displayName},e),{})))},[p,t]);let S=async()=>{let e=d.trim();if(e){f(!0),v(null);try{let t=await fetch(e);if(!t.ok)throw Error(`HTTP ${t.status}: ${t.statusText}`);let s=await t.json();if(!Array.isArray(s.catalogs)||0===s.catalogs.length)return void v("This manifest has no catalogs.");m(s);let a=(()=>{let e=hn(hs);if(!e)return{};try{let t=JSON.parse(e);return"object"==typeof t&&null!==t?t:{}}catch{return{}}})();h(s.catalogs.map(e=>{var t,r;let n=null==(t=e.extra)?void 0:t.find(e=>"search"===e.name),l=a[hr(e)],i=ho(N,{addonName:s.name,catalogName:e.name,catalogType:e.type}),o=(null==l?void 0:l.selected)??(null==(r=e.extra)?void 0:r.find(e=>"search"!==e.name&&!0===e.isRequired))===void 0;return{id:e.id,type:e.type,name:e.name,hasSearch:!!n,searchRequired:(null==n?void 0:n.isRequired)===!0,displayName:(null==l?void 0:l.displayName)||i,selected:o}})),o("catalogs")}catch(e){v(e instanceof Error?e.message:"Failed to fetch manifest. Check the URL and try again.")}finally{f(!1)}}},C=e=>{var t;let s=(null==u||null==(t=u.logo)?void 0:t.startsWith("http"))?u.logo:"https://raw.githubusercontent.com/Stremio/stremio-brand/refs/heads/master/logos/PNG/stremio-logo-800px.png",r=btoa(unescape(encodeURIComponent(JSON.stringify({id:e.id,type:e.type,name:e.displayName,addonManifestUrl:d.trim(),addonLogo:s})))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return`${a}/seanime/extensions/${r}/stremio-custom-source.json`},_=p.filter(e=>e.selected).length,R=p.length>0&&p.every(e=>e.selected),A={url:"Enter a Stremio addon manifest URL to browse its catalogs.",catalogs:u?`${p.length} catalog${1!==p.length?"s":""} from ${u.name}. Pick the ones to expose as Seanime custom sources.`:"",import:"Paste this URL list in Seanime under Extensions → Add Extensions → Import from repository → Import all."},T={initial:{opacity:0,x:12},animate:{opacity:1,x:0},exit:{opacity:0,x:-12},transition:{duration:.18,ease:"easeOut"}};return(0,r.jsx)(ty,{open:t,onOpenChange:s,title:"Stremio Custom Source",description:A[i],contentClass:"max-w-2xl",children:(0,r.jsxs)(tp.N,{mode:"wait",initial:!1,children:["url"===i&&(0,r.jsxs)(th.P.div,{...T,className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(W,{value:d,onValueChange:c,placeholder:"https://…/manifest.json",className:"flex-1 font-mono text-sm",onKeyDown:e=>{"Enter"===e.key&&S()}}),(0,r.jsx)(w,{intent:"white",rounded:!0,onClick:S,loading:g,className:"shrink-0",children:"Continue"})]}),b&&(0,r.jsx)(nU,{intent:"alert",description:b,isClosable:!1})]},"url"),"catalogs"===i&&(0,r.jsxs)(th.P.div,{...T,className:"space-y-4",children:[u&&(0,r.jsxs)("div",{className:"flex items-center gap-3 pb-3 border-b border-gray-700/50",children:[u.logo&&(0,r.jsx)("img",{src:u.logo,alt:u.name,className:"h-8 w-8 rounded object-contain bg-gray-900 p-1"}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-gray-100 truncate",children:u.name}),(0,r.jsxs)("p",{className:"text-xs text-gray-500",children:[_," of ",p.length," selected"]})]}),(0,r.jsx)(E,{size:"sm",rounded:!0,intent:R?"primary":"primary-subtle",icon:R?(0,r.jsx)(J.Pqg,{className:"w-4 h-4"}):(0,r.jsx)(J.hpl,{className:"w-4 h-4"}),onClick:()=>{h(e=>e.map(e=>({...e,selected:!R})))},title:R?"Deselect all":"Select all"})]}),(0,r.jsx)("div",{className:"flex flex-col gap-1 max-h-80 overflow-y-auto -mx-1 px-1",children:p.map((e,t)=>(0,r.jsxs)("div",{className:`flex items-center gap-3 rounded-lg px-3 py-2 transition-colors ${e.selected?"bg-[--brand]/5 hover:bg-[--brand]/10":"hover:bg-gray-800/40"}`,children:[(0,r.jsx)("div",{className:"flex-shrink-0",children:(0,r.jsx)(r6,{id:`cat-${t}`,size:"sm",value:e.selected,onValueChange:e=>h(s=>s.map((s,a)=>a===t?{...s,selected:!0===e}:s))})}
18),(0,r.jsxs)("div",{className:"flex-shrink-0 w-36 cursor-pointer",onClick:()=>h(e=>e.map((e,s)=>s===t?{...e,selected:!e.selected}:e)),children:[(0,r.jsx)("p",{className:"text-sm font-medium text-gray-100 truncate",children:e.name}),(0,r.jsxs)("div",{className:"flex items-center gap-1 mt-0.5 text-[11px] text-gray-500",children:[(0,r.jsx)("span",{className:"capitalize",children:e.type}),e.hasSearch&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"text-gray-700",children:"\xb7"}),(0,r.jsxs)("span",{className:`flex items-center gap-0.5 ${e.searchRequired?"text-amber-400/80":"text-gray-500"}`,children:[(0,r.jsx)(cu.A,{className:"h-2.5 w-2.5"}),e.searchRequired?"search only":"searchable"]})]})]})]}),(0,r.jsx)("div",{className:"flex-1 min-w-0",children:(0,r.jsx)(W,{value:e.displayName,onValueChange:e=>h(s=>s.map((s,a)=>a===t?{...s,displayName:e}:s)),className:"w-full text-xs",placeholder:"Display name in Seanime"})})]},`${e.type}-${e.id}`))}),(0,r.jsx)(tp.N,{initial:!1,children:_>0&&(0,r.jsx)(th.P.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.18,ease:"easeOut"},className:"overflow-hidden",children:(0,r.jsxs)("div",{className:"rounded-lg border border-gray-700/60 bg-gray-800/30 p-3 space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(W,{value:N,onValueChange:k,placeholder:p8,className:"flex-1 font-mono text-xs",leftIcon:(0,r.jsx)(J.Uth,{className:"w-3.5 h-3.5"})}),(0,r.jsxs)(w,{intent:"primary-subtle",size:"sm",onClick:()=>{u&&(h(e=>e.map(e=>e.selected?{...e,displayName:ho(N,{addonName:u.name,catalogName:e.name,catalogType:e.type})}:e)),x.oR.success(`Renamed ${_} catalog${1!==_?"s":""}`))},className:"shrink-0",children:["Apply to ",_]})]}),(0,r.jsxs)("p",{className:"text-[11px] text-gray-500",children:["Variables:"," ",(0,r.jsx)("code",{className:"text-gray-400",children:"{addon.name}"}),","," ",(0,r.jsx)("code",{className:"text-gray-400",children:"{catalog.name}"}),","," ",(0,r.jsx)("code",{className:"text-gray-400",children:"{catalog.type}"})," \xb7 ","Modifiers:"," ",(0,r.jsx)("code",{className:"text-gray-400",children:"{catalog.type::title}"})]})]})},"rename-bar")}),b&&(0,r.jsx)(nU,{intent:"alert",description:b,isClosable:!1}),(0,r.jsxs)("div",{className:"flex justify-between pt-2",children:[(0,r.jsx)(w,{intent:"gray-outline",rounded:!0,onClick:()=>{o("url"),v(null)},children:"Back"}),(0,r.jsxs)(w,{intent:"white",rounded:!0,onClick:()=>{let e=p.filter(e=>e.selected);e.length?(v(null),j(JSON.stringify({urls:e.map(C)})),o("import")):v("Select at least one catalog.")},disabled:0===_,children:["Continue with ",_," catalog",1!==_?"s":""]})]})]},"catalogs"),"import"===i&&(0,r.jsxs)(th.P.div,{...T,className:"space-y-4",children:[(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)("label",{className:"text-xs font-medium text-gray-400 ml-1",children:"URL list JSON"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(W,{type:"text",readOnly:!0,value:y,className:"flex-1 font-mono text-sm bg-black/20",onClick:e=>e.currentTarget.select()}),(0,r.jsx)(w,{onClick:()=>rm(y,{onSuccess:()=>x.oR.success("Copied to clipboard"),onError:()=>x.oR.error("Failed to copy")}),intent:"primary",className:"shrink-0 px-3","aria-label":"Copy URL list",children:(0,r.jsx)(pB.A,{className:"h-4 w-4"})})]})]}),(0,r.jsx)("div",{className:"flex justify-between pt-2",children:(0,r.jsx)(w,{intent:"gray-outline",rounded:!0,onClick:()=>{o("catalogs"),v(null)},children:"Back"})})]},"import")]})})}function hc(){return(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(ru,{className:"space-y-4 p-4 sm:p-8",children:(0,r.jsx)(hu,{})})})}function hu(){var e,t,s,a,l;let{userData:i,setUserData:o,uuid:d,setUuid:c,password:u,setPassword:m,encryptedPassword:p,setEncryptedPassword:h}=s4(),[g,f]=n.useState(""),[b,v]=n.useState(""),[y,j]=n.useState(!1),[N,k]=n.useState([]),{status:S}=e$(),{user:C}=tS(),{data:_}=(0,eU.I)({...eL,enabled:!!C}),R=(null==_||null==(e=_.profiles.find(e=>e.uuid===d))?void 0:e.alias)??null,A=(null==S||null==(t=S.settings)?void 0:t.baseUrl)||window.location.origin,T=!!S,I=(null==S||null==(s=S.settings)?void 0:s.searchApiDisabled)??!1,E=(null==S||null==(a=S.settings)?void 0:a.nabApiDisabled)??!1,M=(null==S||null==(l=S.settings)?void 0:l.seanimeExtensionVersion)??null,P=T&&!I&&!M,D=I||P,L=I?"Requires Search API (disabled on this instance)":P?"Unavailable on this instance. Please ask your instance hoster.":void 0,U=n.useRef(null),$=tw(!1),[O,F]=n.useState(""),{setSelectedMenu:z,firstMenu:V}=as(),q=tw(!1),B=tw(!1),K=tw(!1),H=tw(!1),[G,Y]=n.useState(!0),[J,Q]=n.useState([]),[X,ee]=n.useState(()=>"query"===hn(p7)?"query":"path");n.useEffect(()=>{hl(p7,X)},[X]);let et=tw(!1),es=tw(!1),ea=tw(!1),er=tw(!1),en=tw(!1),el=tw(!1),ei=tw(!1),{handleSave:eo,loading:ed}=dA(),ec=tN({title:"Confirm Reset",description:`Are you sure you want to reset your configuration? This will clear all your settings${d?" but keep your user account":""}. This action cannot be undone.`,actionText:"Reset",actionIntent:"alert",onConfirm:()=>{o(null),z(V),x.oR.success("Configuration reset successfully")}}),eu=tN({title:"Confirm Deletion",description:"Are you sure you want to delete your configuration? This will permanently remove all your data. This action cannot be undone.",actionText:"Delete",actionIntent:"alert",onConfirm:()=>{j(!0),eK()}});n.useEffect(()=>{let e=[];d&&u?k([]):(g.length<6&&e.push("Password must be at least 6 characters long"),b.length>0&&g!==b&&e.push("Passwords do not match"),k(e))},[g,b,d,u]);let em=async e=>{if(null==e||e.preventDefault(),N.length>0)return void x.oR.error("Password requirements not met");j(!0);try{let e=await ep(i,g);x.oR.success("Configuration created successfully, your UUID and password are below"),c(e.uuid),h(e.encryptedPassword),m(g)}catch(e){x.oR.error(e instanceof Error?e.message:"Failed to create configuration")}finally{j(!1)}}
18,eh=e=>{var t,s,a;let r=structuredClone(e);return{...r,ip:void 0,uuid:void 0,accessKey:void 0,tmdbAccessToken:void 0,tmdbApiKey:void 0,tvdbApiKey:void 0,rpdbApiKey:void 0,topPosterApiKey:void 0,aioratingsApiKey:void 0,aioratingsProfileId:void 0,openposterdbApiKey:void 0,openposterdbUrl:void 0,openposterdbParameters:void 0,services:null==r||null==(t=r.services)?void 0:t.map(e=>({...e,credentials:{}})),variants:null==r||null==(s=r.variants)?void 0:s.map(e=>({...e,script:"# [redacted] variant scripts may contain credentials"})),proxy:{...null==r?void 0:r.proxy,credentials:void 0,url:void 0,publicUrl:void 0},presets:null==r||null==(a=r.presets)?void 0:a.map(e=>{let t=null==S?void 0:S.settings.presets.find(t=>t.ID===e.type);return{...e,options:pY(e.options,null==t?void 0:t.OPTIONS)}})}},ex=/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i,eb=d?ex.test(d)?R??null:d:null,ev=(i.variants??[]).filter(e=>!1!==e.enabled),ey=J.filter(e=>ev.some(t=>t.id===e)),ej=ey.map(encodeURIComponent).join(","),ew=ey.length&&"path"===X?`/v/${ej}`:"",eN=ey.length&&"query"===X?`?v=${ej}`:"",ek=d?eb?`${A}/stremio/u/${eb}${ew}/manifest.json${eN}`:`${A}/stremio/${d}/${p}${ew}/manifest.json${eN}`:"",eS=d?`${A}/chilllink/${d}/${p}${ew}${eN}`:"",eC=encodeURIComponent(ek),e_=!!d&&!!p&&ex.test(d),eR=e_?`${A}/seanime/${d}/${p}${ew}/extensions/aiostreams-plugin.json${eN}`:`${A}/seanime/extensions/aiostreams-plugin.json`,eA=e_?`${A}/seanime/${d}/${p}${ew}/extensions/aiostreams-torrent-provider.json${eN}`:`${A}/seanime/extensions/aiostreams-torrent-provider.json`,eT=async()=>{await rm(ek,{onSuccess:()=>x.oR.success("Manifest URL copied to clipboard"),onError:()=>x.oR.error("Failed to copy manifest URL")})},eI=async()=>{await rm(eS,{onSuccess:()=>x.oR.success("ChillLink URL copied to clipboard"),onError:()=>x.oR.error("Failed to copy ChillLink URL")})},eE=async()=>{await rm(eR,{onSuccess:()=>x.oR.success("Plugin URL copied to clipboard"),onError:()=>x.oR.error("Failed to copy URL")})},eM=async()=>{await rm(eA,{onSuccess:()=>x.oR.success("Torrent provider URL copied to clipboard"),onError:()=>x.oR.error("Failed to copy URL")})},eP=`${A}/api/v1/newznab/api`,eD=`${A}/api/v1/torznab/api`,eO=d&&p?btoa(`${d}:${p}`):"",eF=`${A}/api/v1/search`,ez=async()=>{await rm(eP,{onSuccess:()=>x.oR.success("Newznab URL copied to clipboard"),onError:()=>x.oR.error("Failed to copy URL")})},eV=async()=>{await rm(eD,{onSuccess:()=>x.oR.success("Torznab URL copied to clipboard"),onError:()=>x.oR.error("Failed to copy URL")})},eq=async()=>{await rm(eO,{onSuccess:()=>x.oR.success("API key copied to clipboard"),onError:()=>x.oR.error("Failed to copy API key")})},eB=async()=>{await rm(eF,{onSuccess:()=>x.oR.success("Search API URL copied to clipboard"),onError:()=>x.oR.error("Failed to copy URL")})},eK=async()=>{try{if(!d)return void x.oR.error("No UUID found");await eg(d,O),x.oR.success("Configuration deleted successfully"),c(null),h(null),m(null),o(null),z(V),$.close()}catch(e){x.oR.error(e instanceof Error?e.message:"Failed to delete configuration")}finally{j(!1)}},eH=tw(!1),[eG,eW]=n.useState(!1),[eY,eJ]=n.useState({currentPassword:"",newPassword:"",confirmNewPassword:""}),eZ=async e=>{if(e.preventDefault(),!d)return void x.oR.error("No UUID found");if(eY.newPassword.length<6)return void x.oR.error("New password must be at least 6 characters long");if(eY.newPassword!==eY.confirmNewPassword)return void x.oR.error("New passwords do not match");if(eY.newPassword===eY.currentPassword)return void x.oR.error("New password cannot be the same as current password");eW(!0);try{let e=await ef(d,eY.currentPassword,eY.newPassword);x.oR.success("Password changed successfully. Please reinstall AIOStreams."),m(eY.newPassword),h(e.encryptedPassword),eH.close(),eJ({currentPassword:"",newPassword:"",confirmNewPassword:""})}catch(e){x.oR.error(e instanceof Error?e.message:"Failed to change password")}finally{eW(!1)}};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center w-full",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"Install Addon"}),(0,r.jsx)("p",{className:"text-[--muted]",children:"Configure and install your personalized Stremio addon"})]}),(0,r.jsx)("div",{className:"hidden lg:block lg:ml-auto",children:(0,r.jsx)(dT,{})})]}
18),(0,r.jsxs)("div",{className:"space-y-4 mt-6",children:[d?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(p1,{uuid:d,onCopyUuid:()=>rm(d,{onSuccess:()=>x.oR.success("UUID copied to clipboard"),onError:()=>x.oR.error("Failed to copy UUID")}),onSave:e=>{e.preventDefault(),eo()},saveLoading:ed,showChanges:(null==i?void 0:i.showChanges)??!1,onShowChangesChange:e=>o(t=>({...t,showChanges:e}))}),(0,r.jsx)(p5,{encodedManifest:eC,manifestUrl:ek,usingAlias:!!eb,variantSelector:ev.length>0?(0,r.jsx)(p6,{variants:ev,selected:ey,onChange:Q,location:X,onLocationChange:ee}):void 0,onCopyManifestUrl:eT,onOpenChillio:et.open,onOpenSeanime:es.open,onOpenJellyfin:er.open,onOpenAniyomi:en.open,onOpenNabIndexer:el.open,onOpenSearchApi:ei.open,disableSeanimeCard:D,seanimeDisabledReason:L,disableNabIndexerCard:E,nabIndexerDisabledReason:E?"Newznab/Torznab API (disabled on this instance)":void 0,disableSearchApiCard:I,searchApiDisabledReason:I?"Search API (disabled on this instance)":void 0}),(0,r.jsx)(pZ,{})]}):(0,r.jsx)(p0,{onSubmit:em,passwordRequirements:N,newPassword:g,confirmNewPassword:b,onNewPasswordChange:f,onConfirmNewPasswordChange:v,createLoading:y}),(0,r.jsx)(p4,{onExportOpen:K.open,onImportOpen:H.open,onImport:e=>{var t;let s=null==(t=e.target.files)?void 0:t[0];if(!s)return;let a=new FileReader;a.onload=e=>{try{var t;let s=JSON.parse(null==(t=e.target)?void 0:t.result);if(s.metadata)return void x.oR.error("The imported file is a template, please use the template import option instead.");delete s.uuid,delete s.trusted,o(e=>({...e,...s1(s)})),x.oR.success("Configuration imported successfully")}catch(e){x.oR.error("Failed to import configuration: Invalid JSON file")}},a.readAsText(s)},importFileRef:U}),(0,r.jsx)(p9,{hasUser:!!d,onChangePasswordOpen:eH.open,onDeleteUserOpen:$.open,onResetOpen:ec.open}),(0,r.jsx)(ty,{open:eH.isOpen,onOpenChange:e=>{!eG&&(eH.toggle(),e||eJ({currentPassword:"",newPassword:"",confirmNewPassword:""}))},title:"Change Password",description:(0,r.jsx)(nU,{intent:"warning",description:"Changing your password will invalidate ALL existing installations. You will need to re-install AIOStreams after this change."}),children:(0,r.jsxs)("form",{onSubmit:eZ,className:"space-y-4",children:[(0,r.jsx)("input",{type:"text",name:"username",autoComplete:"username",value:d??"",readOnly:!0,"aria-hidden":"true",tabIndex:-1,className:"sr-only"}),(0,r.jsx)(Z,{id:"change-current-password",label:"Current Password",name:"current-password",autoComplete:"current-password",value:eY.currentPassword,required:!0,placeholder:"Enter your current password",onValueChange:e=>eJ(t=>({...t,currentPassword:e}))}),(0,r.jsx)(Z,{id:"change-new-password",label:"New Password",name:"new-password",autoComplete:"new-password",value:eY.newPassword,required:!0,placeholder:"Enter your new password",onValueChange:e=>eJ(t=>({...t,newPassword:e}))}),(0,r.jsx)(Z,{id:"change-confirm-new-password",label:"Confirm New Password",name:"confirm-new-password",autoComplete:"new-password",value:eY.confirmNewPassword,required:!0,placeholder:"Re-enter your new password",onValueChange:e=>eJ(t=>({...t,confirmNewPassword:e}))}),(0,r.jsxs)("div",{className:"pt-2 flex justify-end gap-3",children:[(0,r.jsx)(w,{type:"button",intent:"gray-outline",onClick:()=>{eG||eH.close()},disabled:eG,children:"Cancel"}),(0,r.jsx)(w,{type:"submit",intent:"alert",loading:eG,children:"Change Password"})]})]})}),(0,r.jsx)(ty,{open:$.isOpen,onOpenChange:$.toggle,title:"Delete Configuration",description:(0,r.jsx)(nU,{intent:"warning",description:"Please enter your password to confirm deletion of your user and all associated data. This action cannot be undone."}),children:(0,r.jsx)("form",{onSubmit:e=>{(e.preventDefault(),O)?eu.open():x.oR.error("Please enter your password")},children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(Z,{label:"Password",id:"delete-confirm-password",name:"password",value:O,required:!0,placeholder:"Enter your password to confirm deletion",onValueChange:e=>F(e)}),(0,r.jsx)("div",{className:"pt-2",children:(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3 w-full",children:[(0,r.jsx)(w,{type:"button",intent:"gray-outline",onClick:$.close,className:"w-full",children:"Cancel"}),(0,r.jsx)(w,{type:"submit",intent:"alert",loading:y,className:"w-full",children:"Delete"})]})})]})})}),(0,r.jsx)(ty,{open:et.isOpen,onOpenChange:et.toggle,title:"Install in Chillio",description:"Add your AIOStreams addon via the ChillLink protocol",children:(0,r.jsx)("div",{className:"flex flex-col gap-4",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(W,{type:"text",readOnly:!0,value:eS,className:"flex-1",onClick:e=>e.currentTarget.select()}),(0,r.jsx)(w,{onClick:eI,intent:"primary",className:"shrink-0 px-3","aria-label":"Copy ChillLink URL",children:(0,r.jsx)(pB.A,{className:"h-4 w-4"})})]})})}),(0,r.jsx)(ty,{open:es.isOpen,onOpenChange:es.toggle,title:"Install in Seanime",description:"Stream AIOStreams content directly within Seanime",children:(0,r.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,r.jsxs)("span",{className:"text-gray-400",children:["Seanime integration is in"," ",(0,r.jsx)("span",{className:"font-medium text-amber-300",children:"beta"})]}),(0,r.jsxs)("span",{className:"text-gray-400",children:["Extension ver
18sion:"," ",(0,r.jsx)("span",{className:"font-medium text-gray-200",children:M?`v${M}`:"Unavailable"})]})]}),(0,r.jsxs)("p",{className:"text-xs text-gray-400",children:["In Seanime, go to"," ",(0,r.jsx)("span",{className:"text-gray-200",children:"Extensions → Add Extensions → Install from URL"}),". Install one of the two extensions below."]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("p",{className:"text-sm font-medium text-white",children:["AIOStreams Plugin"," ",(0,r.jsx)("span",{className:"text-xs text-gray-500 font-normal",children:"— recommended for most"})]}),(0,r.jsx)("p",{className:"text-xs text-gray-400 mt-0.5",children:"Adds a dedicated results panel and tab to Seanime. Works with any URL or P2P based stream."})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(W,{type:"text",readOnly:!0,value:eR,className:"flex-1",onClick:e=>e.currentTarget.select()}),(0,r.jsx)(w,{onClick:eE,intent:"primary",className:"shrink-0 px-3","aria-label":"Copy plugin URL",children:(0,r.jsx)(pB.A,{className:"h-4 w-4"})})]}),!e_&&(0,r.jsx)("p",{className:"text-xs text-gray-500",children:"After installing, open the extension settings and enter your Manifest URL."})]}),(0,r.jsx)("div",{className:"border-t border-gray-700/60"}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium text-white",children:"AIOStreams Torrent Provider"}),(0,r.jsx)("p",{className:"text-xs text-gray-400 mt-0.5",children:"For native torrent integration. Only use this if you want a simpler extension and/or want Seanime to handle debrid."})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(W,{type:"text",readOnly:!0,value:eA,className:"flex-1",onClick:e=>e.currentTarget.select()}),(0,r.jsx)(w,{onClick:eM,intent:"primary",className:"shrink-0 px-3","aria-label":"Copy torrent provider URL",children:(0,r.jsx)(pB.A,{className:"h-4 w-4"})})]}),!e_&&(0,r.jsx)("p",{className:"text-xs text-gray-500",children:"After installing, open the extension settings and enter your Manifest URL."})]}),(0,r.jsx)("div",{className:"border-t border-gray-700/60"}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-medium text-white",children:"Stremio Custom Source"}),(0,r.jsx)("p",{className:"text-xs text-gray-400 mt-0.5",children:"Expose any Stremio addon catalog as a Seanime custom source to browse its library directly inside Seanime."})]}),(0,r.jsx)(w,{intent:"white",rounded:!0,className:"w-full",onClick:ea.open,children:"Configure"})]})]})}),(0,r.jsx)(hd,{open:ea.isOpen,onOpenChange:ea.toggle,baseUrl:A,initialManifestUrl:ek}),(0,r.jsx)(ty,{open:el.isOpen,onOpenChange:el.toggle,title:"Newznab / Torznab Indexer",description:"Use AIOStreams as a newznab/torznab indexer in Prowlarr, Sonarr or Radarr",children:(0,r.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,r.jsxs)("p",{className:"text-xs text-gray-400",children:["Add a ",(0,r.jsx)("span",{className:"text-gray-200",children:"Generic Newznab"})," ","(usenet) or ",(0,r.jsx)("span",{className:"text-gray-200",children:"Generic Torznab"})," ","(torrent) indexer. Only ID and season/episode searches are supported — free-text searches return no results."]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-white",children:"Newznab URL"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(W,{type:"text",readOnly:!0,value:eP,className:"flex-1 font-mono text-sm",onClick:e=>e.currentTarget.select()}),(0,r.jsx)(w,{onClick:ez,intent:"primary",className:"shrink-0 px-3","aria-label":"Copy Newznab URL",children:(0,r.jsx)(pB.A,{className:"h-4 w-4"})})]})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-white",children:"Torznab URL"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(W,{type:"text",readOnly:!0,value:eD,className:"flex-1 font-mono text-sm",onClick:e=>e.currentTarget.select()}),(0,r.jsx)(w,{onClick:eV,intent:"primary",className:"shrink-0 px-3","aria-label":"Copy Torznab URL",children:(0,r.jsx)(pB.A,{className:"h-4 w-4"})})]})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-white",children:"API Key"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(W,{type:"text",readOnly:!0,value:eO,className:"flex-1 font-mono text-sm",onClick:e=>e.currentTarget.select()}),(0,r.jsx)(w,{onClick:eq,intent:"primary",className:"shrink-0 px-3","aria-label":"Copy API key",children:(0,r.jsx)(pB.A,{className:"h-4 w-4"})})]}),(0,r.jsx)("p",{className:"text-xs text-gray-500",children:"Paste this into the indexer's API Key field."})]})]})}),(0,r.jsx)(ty,{open:ei.isOpen,onOpenChange:ei.toggle,title:"Search API",description:"Query your stream pipeline as JSON",children:(0,r.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,r.jsxs)("p",{className:"text-xs text-gray-400",children:[(0,r.jsxs)("span",{className:"font-mono text-gray-200",children:["GET ",eF]})," ","with query params ",(0,r.jsx)("span",{className:"text-gray-200",children:"type"})," and"," ",(0,r.jsx)("span",{className:"text-gray-200",children:"id"}),", authenticated with an"," ",(0,r.jsx)("span",{className:"text-gray-200",children:"Authorization: Basic base64(uuid:password)"})," ","header."]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-white",children:"Endpoint"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(W,{type:"text",readOnly:!0,value:eF,className:"flex-1 font-mono text-sm",onClick:e=>e.currentTarget.select()}),(0,r.jsx)(w,{onClick:eB,intent:"primary",className:"shrink-0 px-3","aria-label":"Copy Search API URL",children:(0,r.jsx)(pB.A,{className:"h-4 w-4"})})]})]})]})}),(0,r.jsx)(ty,{open:er.isOpen,onOpenChange:er.toggle,title:"AIOStreams for Jellyfin",description:"Install the Gelato plugin to bring AIOStreams to Jellyfin",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("p",{className:"text-sm text-gray-300",children:"Gelato is an unofficial Jellyfin plugin that brings Stremio addons into Jellyfin."}),(0,r.jsx)(w,{intent:"primary",className:"w-full",leftIcon:(0,r.jsx)(nD.HaR,{}),onClick:()=>window.open("https://github.com/lostb1t/Gelato","_blank"),children:"Open Gelato on GitHub"})]})}),(0,r.jsx)(ty,{open:en.isOpen,onOpenChange:en.toggle,title:"AIOStreams for Aniyomi / Animiru",description:"Install the extension to use AIOStreams in Aniyomi and Animiru",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("p",{className:"text-sm text-gray-300",children:"This unofficial extension brings AIOStreams support to Aniyomi and forks (e.g. Animiru)."}),(0,r.jsx)(w,{intent:"primary",className:"w-full",leftIcon:(0,r.jsx)(nD.HaR,{}),onClick:()=>window.open("https://github.com/worldInColors/aiostreams-extension","_blank"),children:"Open extension on GitHub"})]})}),(0,r.jsx)(tk,{...eu}),(0,r.jsx)(tk,{...ec}),(0,r.jsx)(ty,{open:K.isOpen,onOpenChange:K.toggle,title:"Export Configuration",description:"Choose how to export your configuration",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,r.jsx)(pQ,{onClick:()=>{try{let e=G?eh(i):structuredClone(i),t=JSON.stringify(e,null,2),s=new Blob([t],{type:"application/json"}),a=URL.createObjectURL(s),r=document.createElement("a");r.href=a;let n=new Date,l=e=>e.toString().padStart(2,"0"),o=`${n.getFullYear()}-${l(n.getMonth()+1)}-${l(n.getDate())}.${l(n.getHours())}-${l(n.getMinutes())}-${l(n.getSeconds())}`;r.download=`aiostreams-config-${o}.json`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(a),x.oR.success("Configuration exported successfully"),K.close()}catch(e){x.oR.error("Failed to export configuration")}},icon:(0,r.jsx)(pG.A,{className:"h-8 w-8"}),title:"Export Config",description:"Download as JSON file for backup or sharing"}),(0,r.jsx)(pQ,{onClick:()=>{K.close(),q.open()},icon:(0,r.jsx)(cx.A,{className:"h-8 w-8"}),title:"Export as Template",description:"Create reusable template with custom metadata"})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-3 mt-6 p-3 bg-gray-800/50 rounded-lg",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("div",{className:"text-sm font-medium text-white",children:"Exclude Credentials"}),(0,r.jsx)("div",{className:"text-xs text-gray-400 mt-1",children:"Remove sensitive API keys and passwords from the export"})]}),(0,r.jsx)(rs,{value:G,onValueChange:Y})]}),(0,r.jsx)(nU,{intent:"warning",isClosable:!1,description:"While excluding credentials removes your API keys, any custom addon URLs or manually overridden URLs in your config are not removed. These may contain sensitive information - double-check before sharing."})]})]})}),(0,r.jsx)(ty,{open:H.isOpen,onOpenChange:H.toggle,title:"Import Configuration",description:"Choose what type of configuration to import",children:(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,r.jsx)(pQ,{onClick:()=>{var e;H.close(),null==(e=U.current)||e.click()},icon:(0,r.jsx)(pW.A,{className:"h-8 w-8"}),title:"Import Config",description:"Restore from a backup JSON file"}),(0,r.jsx)(pQ,{onClick:()=>{H.close(),B.open()},icon:(0,r.jsx)(cx.A,{className:"h-8 w-8"}),title:"Import Template",description:"Load a pre-configured template"})]})}),(0,r.jsx)(pJ,{open:q.isOpen,onOpenChange:q.toggle,userData:i,filterCredentials:eh}),(0,r.jsx)(u_,{open:B.isOpen,onOpenChange:B.toggle,openImportModal:!0})]})]})}var hm=s(3046);let hp={torrentio:{name:`{stream.proxied::istrue["🕵️‍♂️ "||""]}{stream.private::istrue["🔑 "||""]}{stream.type::=p2p["[P2P] "||""]}{service.id::exists["[{service.shortName}"||""]}{service.cached::istrue["+] "||""]}{service.cached::isfalse[" download] "||""]}{addon.name} {stream.resolution::exists["{stream.resolution}"||"Unknown"]}
19{?{stream.visualTags::join(' | ')}?}`,description:`{?ℹ️{stream.message}?}
20{?{stream.folderName}?}
21{?{stream.filename}?}
22{stream.size::>0["💾{stream.size::bytes2} "||""]}{stream.folderSize::>0["/ 💾{stream.folderSize::bytes2}"||""]}{stream.seeders::>=0["👤{stream.seeders} "||""]}{?📅{stream.age} ?}{?⚙️{stream.indexer}?}
23{?{stream.languageEmojis::join(' / ')}?}{stream.subtitles::exists::and::stream.languageEmojis::exists[" "||""]}{stream.subtitles::exists["Subs / {stream.subtitleEmojis::join(' / ')}"||""]}
24`},torbox:{name:`{stream.proxied::istrue["🕵️‍♂️ "||""]}{stream.private::istrue["🔑 "||""]}{stream.type::=p2p["[P2P] "||""]}{addon.name}{stream.library::istrue[" (Your Media) "||""]}{service.cached::istrue[" (Instant "||""]}{service.cached::isfalse[" ("||""]}{service.id::exists["{service.shortName})"||""]}{? ({stream.resolution})?}`,description:`Quality: {stream.quality::exists["{stream.quality}"||"Unknown"]}
25Name: {stream.filename::exists["{stream.filename}"||"Unknown"]}
26Size: {stream.size::>0["{stream.size::bytes} "||""]}{stream.folderSize::>0["/ {stream.folderSize::bytes} "||""]}{?| Source: {stream.indexer} ?}{stream.duration::>0["| Duration: {stream.duration::time} "||""]}
27Languages: {?{stream.languages::join(', ')}?}{stream.subtitles::exists::and::stream.languages::exists[" | "||""]}{?Subtitles: {stream.subtitles::join(', ')}?}
28{?Message: {stream.message}?}`},gdrive:{name:`{stream.proxied::istrue["🕵️ "||""]}{stream.private::istrue["🔑 "||""]}{stream.type::=p2p["[P2P] "||""]}{?[{service.shortName}?}{service.cached::istrue["⚡] "||""]}{service.cached::isfalse["⏳] "||""]}{addon.name}{stream.library::istrue[" (Your Media)"||""]} {?{stream.resolution}?}{stream.seadexBest::istrue[" (Best)"||""]}{stream.seadex::istrue::and::stream.seadexBest::isfalse[" (SeaDex Alt.)"||""]}{stream.rseMatched::exists::and::stream.seadex::isfalse::and::stream.rseMatched::string::~T1::or::stream.rseMatched::string::~T2::or::stream.rseMatched::string::~T3::or::stream.rseMatched::string::~T4::or::stream.rseMatched::string::~T5::or::stream.rseMatched::string::~T6::or::stream.rseMatched::string::~T7::or::stream.rseMatched::string::~T8[" ({stream.rseMatched::first})"||""]}{stream.regexMatched::exists::and::stream.rseMatched::exists::isfalse::and::stream.seadex::isfalse[" ({stream.regexMatched})"||""]}`,description:`{?🎥 {stream.quality} ?}
28{?🎞️ {stream.encode} ?}{?🏷️ {stream.releaseGroup} ?}{?📡 {stream.network} ?}
29{?📺 {stream.visualTags::join(' | ')} ?}{?🎧 {stream.audioTags::join(' | ')} ?}{?🔊 {stream.audioChannels::join(' | ')}?}
30{stream.size::>0["📦 {stream.size::sbytes} "||""]}{stream.folderSize::>0["/ {stream.folderSize::sbytes} "||""]}{stream.bitrate::>0["({stream.bitrate::sbitrate})"||""]}{stream.duration::>0["⏱️ {stream.duration::time} "||""]}{stream.seeders::>0["👥 {stream.seeders} "||""]}{?📅 {stream.age} ?}{?🔍 {stream.indexer}?}
31{?🌎 {stream.languages::join(' | ')}?}{?📝 {stream.subtitles::join(' | ')}?}
32{stream.filename::exists["📁"||""]} {?{stream.folderName}/?}{?{stream.filename}?}
33{?ℹ️ {stream.message}?}
34      `},lightgdrive:{name:`{stream.proxied::istrue["🕵️ "||""]}{stream.private::istrue["🔑 "||""]}{stream.type::=p2p["[P2P] "||""]}{?[{service.shortName}?}{stream.library::istrue["☁️"||""]}{service.cached::istrue["⚡] "||""]}{service.cached::isfalse["⏳] "||""]}{addon.name}{? {stream.resolution}?}{stream.seadexBest::istrue[" (Best)"||""]}{stream.seadex::istrue::and::stream.seadexBest::isfalse[" (SeaDex Alt.)"||""]}{stream.rseMatched::exists::and::stream.seadex::isfalse::and::stream.rseMatched::string::~T1::or::stream.rseMatched::string::~T2::or::stream.rseMatched::string::~T3::or::stream.rseMatched::string::~T4::or::stream.rseMatched::string::~T5::or::stream.rseMatched::string::~T6::or::stream.rseMatched::string::~T7::or::stream.rseMatched::string::~T8[" ({stream.rseMatched::first})"||""]}{stream.regexMatched::exists::and::stream.rseMatched::exists::isfalse::and::stream.seadex::isfalse[" ({stream.regexMatched})"||""]}`,description:`{?📁 {stream.title::title}?}{? ({stream.year})?}{? {stream.seasonEpisode::join(' • ')}?}
35{?🎥 {stream.quality} ?}{?🎞️ {stream.encode} ?}{?🏷️ {stream.releaseGroup}?}{?📡 {stream.network} ?}
36{?📺 {stream.visualTags::join(' • ')} ?}{?🎧 {stream.audioTags::join(' • ')} ?}{?🔊 {stream.audioChannels::join(' • ')}?}
37{stream.size::>0["📦 {stream.size::sbytes} "||""]}{stream.folderSize::>0["/ {stream.folderSize::sbytes} "||""]}{stream.duration::>0["⏱️ {stream.duration::time} "||""]}{?📅 {stream.age} ?}{?🔍 {stream.indexer}?}
38{?🌐 {stream.languageEmojis::join(' / ')}?}{stream.subtitles::exists["📝 {stream.subtitleEmojis::join(' / ')}"||""]}
39{?ℹ️ {stream.message}?}`},minimalisticgdrive:{name:`{stream.resolution::exists["{stream.resolution::replace('2160p','✨ 4K')::replace('1440p','📀 2K')::replace('1080p','🧿1080p')::replace('720p','💿720p')}"||"N/A"]}{service.cached::istrue[" 🎫 "||""]}{service.cached::isfalse[" 🎟️ "||""]}
40{?{stream.quality::upper}?}
41`,description:`{?🔆 {stream.visualTags::join(' • ')}  ?}{?🔊 {stream.audioTags::join(' • ')}?}
42{stream.size::>0["📦 {stream.size::sbytes} "||""]}
43{?🌎 {stream.languages::join(' • ')}?}{?📝 {stream.subtitles::join(' • ')}?}
44`},prism:{name:`{stream.resolution::exists["{stream.resolution::replace('2160p', '🔥4K UHD')::replace('1440p','✨ QHD')::replace('1080p','🚀 FHD')::replace('720p','💿 HD')::replace('576p','💩 Low Quality')::replace('480p','💩 Low Quality')::replace('360p','💩 Low Quality')::replace('240p','💩 Low Quality')::replace('144p','💩 Low Quality')}"||"💩 Unknown"]}`,description:`{?🎬 {stream.title::title} ?}{?({stream.year}) ?}{?🍂 {stream.formattedSeasons} ?}{?🎞️ {stream.formattedEpisodes}?}{stream.seadexBest::istrue["🎚️ Best "||""]}{stream.seadex::istrue::and::stream.seadexBest::isfalse["🎚️ Alternative"||""]}{stream.rseMatched::exists::and::stream.seadex::isfalse::and::stream.rseMatched::string::~T1::or::stream.rseMatched::string::~T2::or::stream.rseMatched::string::~T3::or::stream.rseMatched::string::~T4::or::stream.rseMatched::string::~T5::or::stream.rseMatched::string::~T6::or::stream.rseMatched::string::~T7::or::stream.rseMatched::string::~T8[" 🎚️ {stream.rseMatched::first}"||""]}{stream.regexMatched::exists::and::stream.rseMatched::exists::isfalse::and::stream.seadex::isfalse["🎚️ {stream.regexMatched} "||""]}
45{?🎥 {stream.quality} ?}
45{?📺 {stream.visualTags::join(' | ')} ?}{?🎞️ {stream.encode} ?}{stream.duration::>0["⏱️ {stream.duration::time} "||""]}
46{?🎧 {stream.audioTags::join(' | ')} ?}{?🔊 {stream.audioChannels::join(' | ')} ?}{stream.languages::exists["🗣️ {stream.languageEmojis::join(' / ')}"||""]}{stream.subtitles::exists["📝 {stream.subtitleEmojis::join(' / ')}"||""]}
47{stream.size::>0["📦 {stream.size::sbytes} "||""]}{stream.folderSize::>0["/ {stream.folderSize::sbytes} "||""]}{stream.bitrate::>0["📊 {stream.bitrate::sbitrate} "||""]}{service.cached::isfalse::or::stream.type::=p2p::and::stream.seeders::>0["🌱 {stream.seeders} "||""]}{stream.type::=usenet::and::stream.age::exists["📅 {stream.age} "||""]}
48{?🏷️ {stream.releaseGroup} ?}{?📡 {stream.indexer} ?}{?🎭 {stream.network}?}
49{service.cached::istrue["⚡Ready "||""]}{service.cached::isfalse["❌ Not Ready "||""]}{service.id::exists["({service.shortName}) "||""]}{stream.library::istrue["📌 Library "||""]}{stream.type::=Usenet["📰 Usenet "||""]}{stream.type::=p2p["⚠️ P2P "||""]}{stream.type::=http["💻 Web Link "||""]}{stream.type::=youtube["▶️ Youtube "||""]}{stream.type::=live["📺 Live "||""]}{stream.proxied::istrue["🔒 Proxied "||""]}{stream.private::istrue["🔑 Private "||""]}🔍{addon.name} 
50{?ℹ️ {stream.message}?}
51`},tamtaro:{name:`{stream.resolution::exists["{stream.resolution::replace('2160p','\xa0\xa0\xa04K\xa0')::replace('1440p','\xa0\xa0\xa0\xa02K\xa0')::replace('p','P')}‍"||"‍\xa0\xa0\xa0\xa0\xa0"]}{?‍{stream.type::replace('debrid','\xa0\xa0\xa0\xa0')::replace('p2p','⁽ᵖ\xb2ᵖ⁾')::replace('live','⁽ˡᶦᵛᵉ⁾')::replace('http','⁽ʷᵉᵇ⁾')::replace('usenet','‍⁽ⁿᶻᵇ⁾‍')::replace('stremio-usenet','‏⁽ⁿᶻᵇ⁾')::replace('info','⁽ᶦⁿᶠᵒ⁾')::replace('statistic','⁽ˢᵗᵃᵗˢ⁾')::replace('external','⁽ᵉˣᵗ⁾')::replace('error','⁽ᵉʳʳᵒʳ⁾')::replace('youtube','⁽ʸᵗ⁾')}‍‍‍?}{service.cached["⚡"||"‍⏳‍​"||""]}{?‍‍
52\xa0\xa0〈{stream.quality::title::replace('Bluray Remux','Remux')::replace('Web-dl','Web‍-‍dl')::replace('Hc Hd-rip','HC\xa0HDRip')::replace('Hdrip','HDRip')}〉‍\xa0\xa0\xa0\xa0\xa0?}{stream.message::~Download["{tools.removeLine}
53"||""]}{?‍
54\xa0\xa0{stream.nSeScore::star::replace('⯪','☆')}\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0?}{stream.message::~Download["{tools.removeLine}
55"||""]}`,description:`{stream.title::exists["{stream.library::istrue["☁︎"||"{stream.preloading::istrue["➤"||"✎"]}"]}  {stream.date::exists["{stream.title::title::truncate(20)}"||"{stream.title::title::truncate(15)}"]}"||""]}{? \xb7 {stream.country} ?}{metadata.queryType::~series["{stream.date::exists[" \xb7 {stream.date::date('%-d %b %Y')} "||""]}"||"{stream.date::exists[" \xb7 {stream.date::date('%-d %b %Y')} "||"{? ({stream.year::replace('-20', '-')::replace('-19', '-')}) ?}"]}"]}{?  {stream.seasonEpisode::join('\xb7')::replace('E','ᴇ')::replace('S','s')::translate('0123456789','₀₁₂₃₄₅₆₇₈₉')}?}
56{?▣  {stream.encode}  ?}{stream.visualTags::exists["{stream.visualTags::in('DV','HLG','HDR','HDR10','HDR10+')["✦  "||"✧  "]}{stream.visualTags::sort::join(' \xb7 ')::replace('HDR \xb7 HDR','HDR')::replace('HDR10 \xb7 HDR10','HDR10')}  "||""]}{stream.visualTags::length::<=1::and::stream.audioTags::length::=1::and::stream.audioChannels::length::<=1["♬  {stream.audioTags::lsort::join(' \xb7 ')::replace('DD \xb7 DD','DD')::replace('DTS \xb7 DTS','DTS')}{?  ♯ {stream.audioChannels::rsort::join(' \xb7 ')}?}"||""]}
57{stream.visualTags::length::>1::or::stream.audioTags::length::=0::or::stream.audioTags::length::>1::or::stream.audioChannels::length::>1["{stream.audioTags::length::>0["♬  {stream.audioTags::lsort::join(' \xb7 ')::replace('DD \xb7 DD','DD')::replace('DTS \xb7 DTS','DTS')}  "||""]}{stream.audioChannels::length::>0["♯  {stream.audioChannels::rsort::join(' \xb7 ')} "||""]}"||""]}
58{stream.size::>0["{stream.seasonPack["❖ "||"◈ "||""]}{stream.size::>0::and::stream.folderSize::>0::and::stream.size::sbytes::~GB::and::stream.folderSize::sbytes::~GB["{stream.size::sbytes::replace(' GB','')}"||"{stream.size::sbytes}"]}"||""]}{stream.folderSize::>0[" / {stream.folderSize::sbytes}"||""]}{? \xb7 {stream.bitrate::sbitrate::replace('Mbps','ᴹᵇᵖˢ')::replace('Kbps','ᴷᵇᵖˢ')} ?}{stream.message::~Download["{tools.removeLine}"||""]}{service.cached::isfalse::or::stream.type::=p2p::and::stream.seeders::>0["⇄ {stream.seeders}❦ "||""]}{?\xb7 {stream.age}?}
59{stream.proxied::istrue["⛊ "||"⛉ "]}{?[{service.shortName}] ?}{addon.name}{stream.private[" ⚿ ᴘʀɪᴠᴀᴛᴇ "||""]}{? \xb7 {stream.releaseGroup::truncate(13)}?}{stream.indexer::exists::and::stream.type::~usenet[" \xb7 {stream.indexer::truncate(13)}"||""]}{stream.message::~Download["{tools.removeLine}
60"||""]}
61{?{stream.subtitles::exists["✓"||"⛿"]} {stream.uSmallLanguageCodes::join(' \xb7 ')::replace('ꜱ','s')::replace('ᴅᴜᴀʟ ᴀᴜᴅɪᴏ','ᴅᴜᴏ')::replace('ᴅᴜʙʙᴇᴅ','ᴅᴜʙ')} ?}{stream.subbed["{stream.uLanguages::exists["\xb7 sᴜʙ "||"⛿ sᴜʙ "]}"||""]}{?({stream.uSmallSubtitleCodes::join(' \xb7 ')::replace('ꜱ','s')}) ?}{stream.seadex::or::stream.message::length::>0::or::stream.rseMatched::length::>0::or::stream.editions::exists::or::stream.network::exists::or::stream.seScore::>0::or::stream.seScore::<0["{stream.uSmallLanguageCodes::length::>2::or::stream.uSmallSubtitleCodes::length::>2::or::stream.rseMatched::remove('TrueHD ATMOS','DD+ ATMOS','ATMOS','TrueHD','DTS-HD MA','FLAC','DTS-HD HRA','DD+','DD','DTS-ES','DTS X','DTS','AAC','Opus','DV (Disk)','DV','HDR10+ Boost','HDR','IMAX Enhanced','IMAX','UHD Streaming Boost','HD Streaming Boost','INTERNAL','No-RlsGroup','FHD','UHD','HD','4K','126811','SiC','FraMeSToR','TheFarm','hallowed','BHDStudio','FLUX','Season Pack')::join(' ')::length::>10["
62\xbb "||" \xbb "]}"||""]}{stream.seadex["{stream.seadexBest[" ʙᴇsᴛ ʀᴇʟᴇᴀsᴇ "||" ᴀʟᴛ ʙᴇsᴛ ʀᴇʟᴇᴀsᴇ "]}"||""]}{stream.seadex::isfalse::and::stream.rseMatched::length::>0["{stream.rseMatched::remove('TrueHD ATMOS','DD+ ATMOS','ATMOS','TrueHD','DTS-HD MA','FLAC','DTS-HD HRA','DD+','DD','DTS-ES','DTS X','DTS','AAC','Opus','DV (Disk)','DV','HDR10+ Boost','HDR','IMAX Enhanced','IMAX','UHD Streaming Boost','HD Streaming Boost','INTERNAL','No-RlsGroup','FHD','UHD','HD','4K','126811','SiC','FraMeSToR','TheFarm','hallowed','BHDStudio','FLUX','Season Pack')::join(' ')::replace('UHD ','')::replace('HD ','')::replace('Movies Anywhere','MA')::translate('0123456789','₀₁₂₃₄₅₆₇₈₉')::smallcaps::replace('ꜱ','s')} "||""]}{stream.seadex::isfalse::and::stream.rseMatched::length::>0::isfalse::and::stream.network::exists["{stream.network::smallcaps::replace('ꜱ','s')} "||""]}{stream.seadex::isfalse::and::stream.rseMatched::length::>0::isfalse::and::stream.network::exists::isfalse::and::stream.editions::exists["{stream.editions::join(' ')::remove('Edition')::smallcaps::replace('ꜱ','s')} "||""]}{stream.message::length::>0["{stream.message::replace('NZB Health: ✅','✅ ɴᴢʙ')::replace('NZB Health: 🧝','🧝 ɴᴢʙ')::replace('AvailNZB 💚','💚 ɴᴢʙ')::replace('NZB Health: ⚠️','ᴜɴᴠᴇʀɪғɪᴇᴅ ɴᴢʙ')::replace('NZB Health: 🚫','✘ɴᴢʙ')::smallcaps} "||""]}{stream.seScore::>0::or::stream.seScore::<0["{stream.seScore::string::translate('0123456789','₀₁₂₃₄₅₆₇₈₉')}"||""]}{stream.message::~Download["{tools.removeLine}"||""]}{service.cached::istrue::and::stream.message::~Download::istrue["
63➥ DL Stream"||""]}`}},hh={config:["addonName"],stream:["filename","folderName","size","bitrate","folderSize","library","quality","resolution","subbed","dubbed","languages","uLanguages","subtitles","uSubtitles","languageEmojis","uLanguageEmojis","subtitleEmojis","uSubtitleEmojis","languageCodes","uLanguageCodes","subtitleCodes","uSubtitleCodes","smallLanguageCodes","uSmallLanguageCodes","smallSubtitleCodes","uSmallSubtitleCodes","wedontknowwhatakilometeris","uWedontknowwhatakilometeris","visualTags","audioTags","releaseGroup","regexMatched","rankedRegexMatched","regexScore","nRegexScore","encode","audioChannels","edition","editions","remastered","regraded","repack","proper","uncensored","unrated","upscaled","hasChapters","network","container","extension","indexer","year","title","country","episodeTitle","date","folderSeasons","formattedFolderSeasons","seasons","season","formattedSeasons","episodes","episode","formattedEpisodes","folderEpisodes","formattedFolderEpisodes","seasonEpisode","seasonPack","seeders","private","freeleech","age","ageHours","duration","infoHash","type","message","proxied","seadex","seadexBest","seScore","nSeScore","seMatched","rseMatched","preloading","idMatched"],metadata:["queryType","type","isAnime","title","titles","year","yearEnd","runtime","episodeRuntime","genres","originalLanguage","country","season","episode","absoluteEpisode","relativeAbsoluteEpisode","episodeTitle","episodeTitles","latestSeason","daysSinceRelease","daysSinceFirstAired","daysSinceLastAired","hasNextEpisode","daysUntilNextEpisode","anilistId","malId","hasSeaDex"],service:["id","shortName","name","cached"],addon:["name","presetId","manifestUrl"],debug:["json","jsonf"]},hx=new Map(Object.entries(hh).flatMap(e=>{let[t,s]=e;return s.map(e=>[`${t}.${e}`.toLowerCase(),[t,e]])}));function hg(e,t){return hx.get(`${e}.${t}`.toLowerCase())}let hf=(()=>{let e=new Map;for(let[t,s]of Object.entries(hh))for(let a of s){let s=a.toLowerCase(),r=e.get(s);r?r.push(`${t}.${a}`):e.set(s,[`${t}.${a}`])}return e})();function hb(e,t){let s=Math.min(2,Math.floor(e.length/3));if(s<1)return[];let a=e.toLowerCase(),r=s+1,n=[];for(let e of t){let t=function(e,t,s){if(Math.abs(e.length-t.length)>s)return;let a=Array.from({length:t.length+1},(e,t)=>t);for(let r=1;r<=e.length;r++){let n=[r],l=r;
63for(let s=1;s<=t.length;s++){let i=+(e[r-1]!==t[s-1]);n[s]=Math.min(a[s]+1,n[s-1]+1,a[s-1]+i),l=Math.min(l,n[s])}if(l>s)return;a=n}let r=a[t.length];return r<=s?r:void 0}(a,e.toLowerCase(),s);void 0===t||t>r||(t<r&&(r=t,n=[]),n.push(e))}return n}function hv(e,t){let s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(0===e)return"0 B";let a=Math.floor(Math.log(e)/Math.log(t)),r=parseFloat((e/Math.pow(t,a)).toFixed(2));return s&&(r=Math.round(r)),r+" "+(1024===t?["B","KiB","MiB","GiB","TiB"]:["B","KB","MB","GB","TB"])[a]}function hy(e,t){let s;if(0===e)return"0 B";let a=Math.floor(Math.log(e)/Math.log(t)),r=e/Math.pow(t,a),n=Math.floor(r);return(n>=100?(s=Math.round(r)).toString():n>=10?(s=parseFloat(r.toFixed(1)))%1==0?s.toFixed(0):s.toFixed(1):(s=parseFloat(r.toFixed(2))).toString())+" "+(1024===t?["B","KiB","MiB","GiB","TiB"]:["B","KB","MB","GB","TB"])[a]}function hj(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!Number.isFinite(e)||e<=0)return"0 bps";let s=["bps","Kbps","Mbps","Gbps","Tbps"],a=Math.min(s.length-1,Math.max(0,Math.floor(Math.log(e)/Math.log(1e3)))),r=e/Math.pow(1e3,a);return r=t?Math.round(r):parseFloat(r.toFixed(2)),`${r} ${s[a]}`}let hw=[{iso_639_1:"aa",iso_639_2:"aar",iso_3166_1:"ET",flag:"\uD83C\uDDEA\uD83C\uDDF9",english_name:"Afar",name:"Qaf\xe1r af"},{iso_639_1:"ab",iso_639_2:"abk",iso_3166_1:"GE",flag:"\uD83C\uDDEC\uD83C\uDDEA",english_name:"Abkhazian",name:"Аҧсуа бызшәа"},{iso_639_1:"ae",iso_639_2:"ave",iso_3166_1:"IR",flag:"\uD83C\uDDEE\uD83C\uDDF7",english_name:"Avestan",name:"Avesta"},{iso_639_1:"af",iso_639_2:"afr",iso_3166_1:"ZA",flag:"\uD83C\uDDFF\uD83C\uDDE6",english_name:"Afrikaans",name:"Afrikaans"},{iso_639_1:"ak",iso_639_2:"aka",iso_3166_1:"GH",flag:"\uD83C\uDDEC\uD83C\uDDED",english_name:"Akan",name:"Akan"},{iso_639_1:"am",iso_639_2:"amh",iso_3166_1:"ET",flag:"\uD83C\uDDEA\uD83C\uDDF9",english_name:"Amharic",name:"አማርኛ"},{iso_639_1:"an",iso_639_2:"arg",iso_3166_1:"ES",flag:"\uD83C\uDDEA\uD83C\uDDF8",english_name:"Aragonese",name:"Aragon\xe9s"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"SA",flag:"\uD83C\uDDF8\uD83C\uDDE6",flag_priority:!0,english_name:"Arabic",name:"العربية"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"AE",flag:"\uD83C\uDDE6\uD83C\uDDEA",english_name:"Arabic (UAE)",name:"العربية"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"EG",flag:"\uD83C\uDDEA\uD83C\uDDEC",english_name:"Arabic (Egypt)",name:"العربية"},{iso_639_1:"as",iso_639_2:"asm",iso_3166_1:"IN",flag:"\uD83C\uDDEE\uD83C\uDDF3",english_name:"Assamese",name:"অসমীয়া"},{iso_639_1:"av",iso_639_2:"ava",iso_3166_1:"RU",flag:"\uD83C\uDDF7\uD83C\uDDFA",english_name:"Avaric",name:"Авар мацӀ"},{iso_639_1:"ay",iso_639_2:"aym",iso_3166_1:"BO",flag:"\uD83C\uDDE7\uD83C\uDDF4",english_name:"Aymara",name:"Aymar aru"},{iso_639_1:"az",iso_639_2:"aze",iso_3166_1:"AZ",flag:"\uD83C\uDDE6\uD83C\uDDFF",english_name:"Azerbaijani",name:"Azərbaycan"},{iso_639_1:"ba",iso_639_2:"bak",iso_3166_1:"RU",flag:"\uD83C\uDDF7\uD83C\uDDFA",english_name:"Bashkir",name:"Башҡорт теле"},{iso_639_1:"be",iso_639_2:"bel",iso_3166_1:"BY",flag:"\uD83C\uDDE7\uD83C\uDDFE",english_name:"Belarusian",name:"Беларуская мова"},{iso_639_1:"bg",iso_639_2:"bul",iso_3166_1:"BG",flag:"\uD83C\uDDE7\uD83C\uDDEC",english_name:"Bulgarian",name:"Български език"},{iso_639_1:"bi",iso_639_2:"bis",iso_3166_1:"VU",flag:"\uD83C\uDDFB\uD83C\uDDFA",english_name:"Bislama",name:"Bislama"},{iso_639_1:"bm",iso_639_2:"bam",iso_3166_1:"ML",flag:"\uD83C\uDDF2\uD83C\uDDF1",english_name:"Bambara",name:"Bamanankan"},{iso_639_1:"bn",iso_639_2:"ben",iso_3166_1:"BD",flag:"\uD83C\uDDE7\uD83C\uDDE9",flag_priority:!0,english_name:"Bengali",name:"বাংলা"},{iso_639_1:"bo",iso_639_2:"bod",iso_3166_1:"CN",flag:"\uD83C\uDDE8\uD83C\uDDF3",english_name:"Tibetan",name:"བོད་ཡིག"},{iso_639_1:"br",iso_639_2:"bre",iso_3166_1:"FR",flag:"\uD83C\uDDEB\uD83C\uDDF7",english_name:"Breton",name:"Brezhoneg"},{iso_639_1:"bs",iso_639_2:"bos",iso_3166_1:"BA",flag:"\uD83C\uDDE7\uD83C\uDDE6",english_name:"Bosnian",name:"Bosanski"},{iso_639_1:"ca",iso_639_2:"cat",iso_3166_1:"ES",flag:"\uD83C\uDDEA\uD83C\uDDF8",english_name:"Catalan",name:"Catal\xe0"},{iso_639_1:"ce",iso_639_2:"che",iso_3166_1:"RU",flag:"\uD83C\uDDF7\uD83C\uDDFA",english_name:"Chechen",name:"Нохчийн мотт"},{iso_639_1:"ch",iso_639_2:"cha",iso_3166_1:"MP",flag:"\uD83C\uDDF2\uD83C\uDDF5",english_name:"Chamorro",name:"Finu' Chamorro"},{iso_639_1:"co",iso_639_2:"cos",iso_3166_1:"FR",flag:"\uD83C\uDDEB\uD83C\uDDF7",english_name:"Corsican",name:"Corsu"},{iso_639_1:"cr",iso_639_2:"cre",iso_3166_1:"CA",flag:"\uD83C\uDDE8\uD83C\uDDE6",english_name:"Cree",name:"ᓀᐦᐃᔭᐍᐏᐣ"},{iso_639_1:"cs",iso_639_2:"ces",iso_3166_1:"CZ",flag:"\uD83C\uDDE8\uD83C\uDDFF",english_name:"Czech",name:"Česk\xfd"},{iso_639_1:"cu",iso_639_2:"chu",iso_3166_1:"RU",flag:"\uD83C\uDDF7\uD83C\uDDFA",english_name:"Church Slavic",name:"Словѣньскъ"},{iso_639_1:"cv",iso_639_2:"chv",iso_3166_1:"RU",flag:"\uD83C\uDDF7\uD83C\uDDFA",english_name:"Chuvash",name:"Чӑваш чӗлхи"},{iso_639_1:"cy",iso_639_2:"cym",iso_3166_1:"GB",flag:"\uD83C\uDDEC\uD83C\uDDE7",english_name:"Welsh",name:"Cymraeg"},{iso_639_1:"da",iso_639_2:"dan",iso_3166_1:"DK",flag:"\uD83C\uDDE9\uD83C\uDDF0",flag_priority:!0,english_name:"Danish",name:"Dansk"},{iso_639_1:"de",iso_639_2:"deu",iso_3166_1:"DE",flag:"\uD83C\uDDE9\uD83C\uDDEA",flag_priority:!0,english_name:"German",name:"Deutsch"},{iso_639_1:"dv",iso_639_2:"div",iso_3166_1:"MV",flag:"\uD83C\uDDF2\uD83C\uDDFB",english_name:"Divehi",name:"ދިވެހި"},{iso_639_1:"dz",iso_639_2:"dzo",iso_3166_1:"BT",flag:"\uD83C\uDDE7\uD83C\uDDF9",english_name:"Dzongkha",name:"རྫོང་ཁ"},{iso_639_1:"ee",iso_639_2:"ewe",iso_3166_1:"GH",flag:"\uD83C\uDDEC\uD83C\uDDED",english_name:"Ewe",name:"\xc8ʋegbe"},{iso_639_1:"el",iso_639_2:"ell",iso_3166_1:"GR",flag:"\uD83C\uDDEC\uD83C\uDDF7",english_name:"Greek",name:"Ελληνικά"},{iso_639_1:"en",iso_639_2:"eng",iso_3166_1:"GB",flag:"\uD83C\uDDEC\uD83C\uDDE7",flag_priority:!0,english_name:"English (UK)",name:"English"},{iso_639_1:"en",iso_639_2:"eng",iso_3166_1:"US",flag:"\uD83C\uDDFA\uD83C\uDDF8",english_name:"English (US)",name:"English"},{iso_639_1:"en",iso_639_2:"eng",iso_3166_1:"AU",flag:"\uD83C\uDDE6\uD83C\uDDFA",english_name:"English (Australia)",name:"English"},{iso_639_1:"en",iso_639_2:"eng",iso_3166_1:"CA",flag:"\uD83C\uDDE8\uD83C\uDDE6",english_name:"English (Canad
63a)",name:"English"},{iso_639_1:"en",iso_639_2:"eng",iso_3166_1:"IE",flag:"\uD83C\uDDEE\uD83C\uDDEA",english_name:"English (Ireland)",name:"English"},{iso_639_1:"en",iso_639_2:"eng",iso_3166_1:"NZ",flag:"\uD83C\uDDF3\uD83C\uDDFF",english_name:"English (New Zealand)",name:"English"},{iso_639_1:"eo",iso_639_2:"epo",iso_3166_1:null,flag:"\uD83C\uDF10",english_name:"Esperanto",name:"Esperanto"},{iso_639_1:"es",iso_639_2:"spa",iso_3166_1:"ES",flag:"\uD83C\uDDEA\uD83C\uDDF8",flag_priority:!0,english_name:"Spanish",name:"Espa\xf1ol"},{iso_639_1:"et",iso_639_2:"est",iso_3166_1:"EE",flag:"\uD83C\uDDEA\uD83C\uDDEA",english_name:"Estonian",name:"Eesti"},{iso_639_1:"eu",iso_639_2:"eus",iso_3166_1:"ES",flag:"\uD83C\uDFF4",english_name:"Basque",name:"Euskera"},{iso_639_1:"fa",iso_639_2:"fas",iso_3166_1:"IR",flag:"\uD83C\uDDEE\uD83C\uDDF7",english_name:"Persian",name:"فارسی"},{iso_639_1:"ff",iso_639_2:"ful",iso_3166_1:"SN",flag:"\uD83C\uDDF8\uD83C\uDDF3",english_name:"Fulah",name:"Fulfulde"},{iso_639_1:"fi",iso_639_2:"fin",iso_3166_1:"FI",flag:"\uD83C\uDDEB\uD83C\uDDEE",english_name:"Finnish",name:"Suomi"},{iso_639_1:"fj",iso_639_2:"fij",iso_3166_1:"FJ",flag:"\uD83C\uDDEB\uD83C\uDDEF",english_name:"Fijian",name:"Vosa Vakaviti"},{iso_639_1:"fo",iso_639_2:"fao",iso_3166_1:"FO",flag:"\uD83C\uDDEB\uD83C\uDDF4",english_name:"Faroese",name:"F\xf8royskt"},{iso_639_1:"fr",iso_639_2:"fra",iso_3166_1:"FR",flag:"\uD83C\uDDEB\uD83C\uDDF7",flag_priority:!0,english_name:"French",name:"Fran\xe7ais"},{iso_639_1:"fy",iso_639_2:"fry",iso_3166_1:"NL",flag:"\uD83C\uDDF3\uD83C\uDDF1",english_name:"Western Frisian",name:"Frysk"},{iso_639_1:"ga",iso_639_2:"gle",iso_3166_1:"IE",flag:"\uD83C\uDDEE\uD83C\uDDEA",english_name:"Irish",name:"Gaeilge"},{iso_639_1:"gd",iso_639_2:"gla",iso_3166_1:"GB",flag:"\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74\uDB40\uDC7F",english_name:"Scottish Gaelic",name:"G\xe0idhlig"},{iso_639_1:"gl",iso_639_2:"glg",iso_3166_1:"ES",flag:"\uD83C\uDDEA\uD83C\uDDF8",english_name:"Galician",name:"Galego"},{iso_639_1:"gn",iso_639_2:"grn",iso_3166_1:"PY",flag:"\uD83C\uDDF5\uD83C\uDDFE",english_name:"Guarani",name:"Ava\xf1e'ẽ"},{iso_639_1:"gu",iso_639_2:"guj",iso_3166_1:"IN",flag:"\uD83C\uDDEE\uD83C\uDDF3",english_name:"Gujarati",name:"ગુજરાતી"},{iso_639_1:"gv",iso_639_2:"glv",iso_3166_1:"IM",flag:"\uD83C\uDDEE\uD83C\uDDF2",english_name:"Manx",name:"Gaelg"},{iso_639_1:"ha",iso_639_2:"hau",iso_3166_1:"NG",flag:"\uD83C\uDDF3\uD83C\uDDEC",english_name:"Hausa",name:"Hausa"},{iso_639_1:"he",iso_639_2:"heb",iso_3166_1:"IL",flag:"\uD83C\uDDEE\uD83C\uDDF1",flag_priority:!0,english_name:"Hebrew",name:"עִבְרִית"},{iso_639_1:"hi",iso_639_2:"hin",iso_3166_1:"IN",flag:"\uD83C\uDDEE\uD83C\uDDF3",flag_priority:!0,english_name:"Hindi",name:"हिन्दी"},{iso_639_1:"ho",iso_639_2:"hmo",iso_3166_1:"PG",flag:"\uD83C\uDDF5\uD83C\uDDEC",english_name:"Hiri Motu",name:"Hiri Motu"},{iso_639_1:"hr",iso_639_2:"hrv",iso_3166_1:"HR",flag:"\uD83C\uDDED\uD83C\uDDF7",english_name:"Croatian",name:"Hrvatski"},{iso_639_1:"ht",iso_639_2:"hat",iso_3166_1:"HT",flag:"\uD83C\uDDED\uD83C\uDDF9",english_name:"Haitian; Haitian Creole",name:"Krey\xf2l ayisyen"},{iso_639_1:"hu",iso_639_2:"hun",iso_3166_1:"HU",flag:"\uD83C\uDDED\uD83C\uDDFA",english_name:"Hungarian",name:"Magyar"},{iso_639_1:"hy",iso_639_2:"hye",iso_3166_1:"AM",flag:"\uD83C\uDDE6\uD83C\uDDF2",english_name:"Armenian",name:"Հայերեն"},{iso_639_1:"hz",iso_639_2:"her",iso_3166_1:"NA",flag:"\uD83C\uDDF3\uD83C\uDDE6",english_name:"Herero",name:"Otjiherero"},{iso_639_1:"ia",iso_639_2:"ina",iso_3166_1:null,flag:"\uD83C\uDF10",english_name:"Interlingua",name:"Interlingua"},{iso_639_1:"id",iso_639_2:"ind",iso_3166_1:"ID",flag:"\uD83C\uDDEE\uD83C\uDDE9",flag_priority:!0,english_name:"Indonesian",name:"Bahasa Indonesia"},{iso_639_1:"ie",iso_639_2:"ile",iso_3166_1:null,flag:"\uD83C\uDF10",english_name:"Interlingue",name:"Interlingue"},{iso_639_1:"ig",iso_639_2:"ibo",iso_3166_1:"NG",flag:"\uD83C\uDDF3\uD83C\uDDEC",english_name:"Igbo",name:"Asụsụ Igbo"},{iso_639_1:"ii",iso_639_2:"iii",iso_3166_1:"CN",flag:"\uD83C\uDDE8\uD83C\uDDF3",english_name:"Sichuan Yi; Nuosu",name:"ꆈꌠꉙ"},{iso_639_1:"ik",iso_639_2:"ipk",iso_3166_1:"US",flag:"\uD83C\uDDFA\uD83C\uDDF8",english_name:"Inupiaq",name:"I\xf1upiaq"},{iso_639_1:"io",iso_639_2:"ido",iso_3166_1:null,flag:"\uD83C\uDF10",english_name:"Ido",name:"Ido"},{iso_639_1:"is",iso_639_2:"isl",iso_3166_1:"IS",flag:"\uD83C\uDDEE\uD83C\uDDF8",english_name:"Icelandic",name:"\xcdslenska"},{iso_639_1:"it",iso_639_2:"ita",iso_3166_1:"IT",flag:"\uD83C\uDDEE\uD83C\uDDF9",flag_priority:!0,english_name:"Italian",name:"Italiano"},{iso_639_1:"iu",iso_639_2:"iku",iso_3166_1:"CA",flag:"\uD83C\uDDE8\uD83C\uDDE6",english_name:"Inuktitut",name:"ᐃᓄᒃᑎᑐᑦ"},{iso_639_1:"ja",iso_639_2:"jpn",iso_3166_1:"JP",flag:"\uD83C\uDDEF\uD83C\uDDF5",english_name:"Japanese",name:"日本語"},{iso_639_1:"jv",iso_639_2:"jav",iso_3166_1:"ID",flag:"\uD83C\uDDEE\uD83C\uDDE9",english_name:"Javanese",name:"Basa Jawa"}
63,{iso_639_1:"ka",iso_639_2:"kat",iso_3166_1:"GE",flag:"\uD83C\uDDEC\uD83C\uDDEA",english_name:"Georgian",name:"ქართული"},{iso_639_1:"kg",iso_639_2:"kon",iso_3166_1:"CD",flag:"\uD83C\uDDE8\uD83C\uDDE9",english_name:"Kongo",name:"KiKongo"},{iso_639_1:"ki",iso_639_2:"kik",iso_3166_1:"KE",flag:"\uD83C\uDDF0\uD83C\uDDEA",english_name:"Kikuyu; Gikuyu",name:"Gĩkũyũ"},{iso_639_1:"kj",iso_639_2:"kua",iso_3166_1:"AO",flag:"\uD83C\uDDE6\uD83C\uDDF4",english_name:"Kuanyama; Kwanyama",name:"Kuanyama"},{iso_639_1:"kk",iso_639_2:"kaz",iso_3166_1:"KZ",flag:"\uD83C\uDDF0\uD83C\uDDFF",english_name:"Kazakh",name:"Қазақ"},{iso_639_1:"kl",iso_639_2:"kal",iso_3166_1:"GL",flag:"\uD83C\uDDEC\uD83C\uDDF1",english_name:"Kalaallisut; Greenlandic",name:"Kalaallisut"},{iso_639_1:"km",iso_639_2:"khm",iso_3166_1:"KH",flag:"\uD83C\uDDF0\uD83C\uDDED",english_name:"Central Khmer",name:"ភាសាខ្មែរ"},{iso_639_1:"kn",iso_639_2:"kan",iso_3166_1:"IN",flag:"\uD83C\uDDEE\uD83C\uDDF3",english_name:"Kannada",name:"ಕನ್ನಡ"},{iso_639_1:"ko",iso_639_2:"kor",iso_3166_1:"KR",flag:"\uD83C\uDDF0\uD83C\uDDF7",english_name:"Korean",name:"한국어/조선말"},{iso_639_1:"kr",iso_639_2:"kau",iso_3166_1:"NE",flag:"\uD83C\uDDF3\uD83C\uDDEA",english_name:"Kanuri",name:"Kanuri"},{iso_639_1:"ks",iso_639_2:"kas",iso_3166_1:"IN",flag:"\uD83C\uDDEE\uD83C\uDDF3",english_name:"Kashmiri",name:"कश्मीरी"},{iso_639_1:"ku",iso_639_2:"kur",iso_3166_1:"TR",flag:"\uD83C\uDDF9\uD83C\uDDF7",english_name:"Kurdish",name:"Kurd\xee"},{iso_639_1:"kv",iso_639_2:"kom",iso_3166_1:"RU",flag:"\uD83C\uDDF7\uD83C\uDDFA",english_name:"Komi",name:"Коми кыв"},{iso_639_1:"kw",iso_639_2:"cor",iso_3166_1:"GB",flag:"\uD83C\uDDEC\uD83C\uDDE7",english_name:"Cornish",name:"Kernewek"},{iso_639_1:"ky",iso_639_2:"kir",iso_3166_1:"KG",flag:"\uD83C\uDDF0\uD83C\uDDEC",english_name:"Kirghiz; Kyrgyz",name:"Кыргызча"},{iso_639_1:"la",iso_639_2:"lat",iso_3166_1:"VA",flag:"\uD83C\uDDFB\uD83C\uDDE6",english_name:"Latin",name:"Latine"},{iso_639_1:"lb",iso_639_2:"ltz",iso_3166_1:"LU",flag:"\uD83C\uDDF1\uD83C\uDDFA",english_name:"Luxembourgish; Letzeburgesch",name:"L\xebtzebuergesch"},{iso_639_1:"lg",iso_639_2:"lug",iso_3166_1:"UG",flag:"\uD83C\uDDFA\uD83C\uDDEC",english_name:"Ganda",name:"Luganda"},{iso_639_1:"li",iso_639_2:"lim",iso_3166_1:"NL",flag:"\uD83C\uDDF3\uD83C\uDDF1",english_name:"Limburgan; Limburger; Limburgish",name:"Limburgs"},{iso_639_1:"ln",iso_639_2:"lin",iso_3166_1:"CD",flag:"\uD83C\uDDE8\uD83C\uDDE9",english_name:"Lingala",name:"Ling\xe1la"},{iso_639_1:"lo",iso_639_2:"lao",iso_3166_1:"LA",flag:"\uD83C\uDDF1\uD83C\uDDE6",english_name:"Lao",name:"ພາສາລາວ"},{iso_639_1:"lt",iso_639_2:"lit",iso_3166_1:"LT",flag:"\uD83C\uDDF1\uD83C\uDDF9",english_name:"Lithuanian",name:"Lietuvių"},{iso_639_1:"lu",iso_639_2:"lub",iso_3166_1:"CD",flag:"\uD83C\uDDE8\uD83C\uDDE9",english_name:"Luba-Katanga",name:"Tshiluba"},{iso_639_1:"lv",iso_639_2:"lav",iso_3166_1:"LV",flag:"\uD83C\uDDF1\uD83C\uDDFB",english_name:"Latvian",name:"Latviešu"},{iso_639_1:"mg",iso_639_2:"mlg",iso_3166_1:"MG",flag:"\uD83C\uDDF2\uD83C\uDDEC",english_name:"Malagasy",name:"Malagasy"},{iso_639_1:"mh",iso_639_2:"mah",iso_3166_1:"MH",flag:"\uD83C\uDDF2\uD83C\uDDED",english_name:"Marshallese",name:"Kajin M̧ajeļ"},{iso_639_1:"mi",iso_639_2:"mri",iso_3166_1:"NZ",flag:"\uD83C\uDDF3\uD83C\uDDFF",english_name:"Maori",name:"Te Reo Māori"},{iso_639_1:"mk",iso_639_2:"mkd",iso_3166_1:"MK",flag:"\uD83C\uDDF2\uD83C\uDDF0",english_name:"Macedonian",name:"Македонски јазик"},{iso_639_1:"ml",iso_639_2:"mal",iso_3166_1:"IN",flag:"\uD83C\uDDEE\uD83C\uDDF3",english_name:"Malayalam",name:"മലയാളം"},{iso_639_1:"mn",iso_639_2:"mon",iso_3166_1:"MN",flag:"\uD83C\uDDF2\uD83C\uDDF3",english_name:"Mongolian",name:"Монгол"},{iso_639_1:"mr",iso_639_2:"mar",iso_3166_1:"IN",flag:"\uD83C\uDDEE\uD83C\uDDF3",english_name:"Marathi",name:"मराठी"},{iso_639_1:"ms",iso_639_2:"msa",iso_3166_1:"MY",flag:"\uD83C\uDDF2\uD83C\uDDFE",english_name:"Malay",name:"Bahasa Melayu"},{iso_639_1:"mt",iso_639_2:"mlt",iso_3166_1:"MT",flag:"\uD83C\uDDF2\uD83C\uDDF9",english_name:"Maltese",name:"Malti"},{iso_639_1:"my",iso_639_2:"mya",iso_3166_1:"MM",flag:"\uD83C\uDDF2\uD83C\uDDF2",english_name:"Burmese",name:"ဗမာစာ"},{iso_639_1:"na",iso_639_2:"nau",iso_3166_1:"NR",flag:"\uD83C\uDDF3\uD83C\uDDF7",english_name:"Nauru",name:"Dorerin Naoero"},{iso_639_1:"nb",iso_639_2:"nob",iso_3166_1:"NO",flag:"\uD83C\uDDF3\uD83C\uDDF4",english_name:"Bokm\xe5l, Norwegian; Norwegian Bokm\xe5l",name:"Bokm\xe5l"},{iso_639_1:"nd",iso_639_2:"nde",iso_3166_1:"ZW",flag:"\uD83C\uDDFF\uD83C\uDDFC",english_name:"Ndebele, North; North Ndebele",name:"IsiNdebele"},{iso_639_1:"ne",iso_639_2:"nep",iso_3166_1:"NP",flag:"\uD83C\uDDF3\uD83C\uDDF5",english_name:"Nepali",name:"नेपाली"},{iso_639_1:"ng",iso_639_2:"ndo",iso_3166_1:"NA",flag:"\uD83C\uDDF3\uD83C\uDDE6",english_name:"Ndonga",name:"Owambo"},{iso_639_1:"nl",iso_639_2:"nld",iso_3166_1:"NL",flag:"\uD83C\uDDF3\uD83C\uDDF1",flag_priority:!0,english_name:"Dutch; Flemish",name:"Nederlands"},{iso_639_1:"nn",iso_639_2:"nno",iso_3166_1:"NO",flag:"\uD83C\uDDF3\uD83C\uDDF4",english_name:"Norwegian Nynorsk; Nynorsk, Norwegian",name:"Nynorsk"},{iso_639_1:"no",iso_639_2:"nor",iso_3166_1:"NO",flag:"\uD83C\uDDF3\uD83C\uDDF4",flag_priority:!0,english_name:"Norwegian",name:"Norsk"},{iso_639_1:"nr",iso_639_2:"nbl",iso_3166_1:"ZA",flag:"\uD83C\uDDFF\uD83C\uDDE6",english_name:"Ndebele, South; South Ndebele",name:"IsiNdebele"},{iso_639_1:"nv",iso_639_2:"nav",iso_3166_1:"US",flag:"\uD83C\uDDFA\uD83C\uDDF8",english_name:"Navajo; Navaho",name:"Din\xe9 bizaad"},{iso_639_1:"ny",iso_639_2:"nya",iso_3166_1:"MW",flag:"\uD83C\uDDF2\uD83C\uDDFC",english_name:"Chichewa;
63 Chewa; Nyanja",name:"ChiCheŵa"},{iso_639_1:"oc",iso_639_2:"oci",iso_3166_1:"FR",flag:"\uD83C\uDDEB\uD83C\uDDF7",english_name:"Occitan (post 1500)",name:"Occitan"},{iso_639_1:"oj",iso_639_2:"oji",iso_3166_1:"CA",flag:"\uD83C\uDDE8\uD83C\uDDE6",english_name:"Ojibwa",name:"ᐊᓂᔑᓈᐯᒧᐎᓐ"},{iso_639_1:"om",iso_639_2:"orm",iso_3166_1:"ET",flag:"\uD83C\uDDEA\uD83C\uDDF9",english_name:"Oromo",name:"Afaan Oromoo"},{iso_639_1:"or",iso_639_2:"ori",iso_3166_1:"IN",flag:"\uD83C\uDDEE\uD83C\uDDF3",english_name:"Oriya",name:"ଓଡ଼ିଆ"},{iso_639_1:"os",iso_639_2:"oss",iso_3166_1:"RU",flag:"\uD83C\uDDF7\uD83C\uDDFA",english_name:"Ossetian; Ossetic",name:"Ирон \xe6взаг"},{iso_639_1:"pa",iso_639_2:"pan",iso_3166_1:"IN",flag:"\uD83C\uDDEE\uD83C\uDDF3",english_name:"Panjabi; Punjabi",name:"ਪੰਜਾਬੀ"},{iso_639_1:"pi",iso_639_2:"pli",iso_3166_1:"IN",flag:"\uD83C\uDDEE\uD83C\uDDF3",english_name:"Pali",name:"पाऴि"},{iso_639_1:"pl",iso_639_2:"pol",iso_3166_1:"PL",flag:"\uD83C\uDDF5\uD83C\uDDF1",english_name:"Polish",name:"Polski"},{iso_639_1:"ps",iso_639_2:"pus",iso_3166_1:"AF",flag:"\uD83C\uDDE6\uD83C\uDDEB",english_name:"Pushto; Pashto",name:"پښتو"},{iso_639_1:"pt",iso_639_2:"por",iso_3166_1:"PT",flag:"\uD83C\uDDF5\uD83C\uDDF9",flag_priority:!0,english_name:"Portuguese",name:"Portugu\xeas"},{iso_639_1:"pt",iso_639_2:"por",iso_3166_1:"BR",flag:"\uD83C\uDDE7\uD83C\uDDF7",english_name:"Portuguese (Brazil)",internal_english_name:"Portuguese (Brazil)",name:"Portugu\xeas"},{iso_639_1:"qu",iso_639_2:"que",iso_3166_1:"PE",flag:"\uD83C\uDDF5\uD83C\uDDEA",english_name:"Quechua",name:"Runa Simi"},{iso_639_1:"rm",iso_639_2:"roh",iso_3166_1:"CH",flag:"\uD83C\uDDE8\uD83C\uDDED",english_name:"Romansh",name:"Rumantsch grischun"},{iso_639_1:"rn",iso_639_2:"run",iso_3166_1:"BI",flag:"\uD83C\uDDE7\uD83C\uDDEE",english_name:"Rundi",name:"Kirundi"},{iso_639_1:"ro",iso_639_2:"ron",iso_3166_1:"RO",flag:"\uD83C\uDDF7\uD83C\uDDF4",english_name:"Romanian",name:"Rom\xe2nă"},{iso_639_1:"ru",iso_639_2:"rus",iso_3166_1:"RU",flag:"\uD83C\uDDF7\uD83C\uDDFA",flag_priority:!0,english_name:"Russian",name:"Pусский"},{iso_639_1:"rw",iso_639_2:"kin",iso_3166_1:"RW",flag:"\uD83C\uDDF7\uD83C\uDDFC",english_name:"Kinyarwanda",name:"Ikinyarwanda"},{iso_639_1:"sa",iso_639_2:"san",iso_3166_1:"IN",flag:"\uD83C\uDDEE\uD83C\uDDF3",english_name:"Sanskrit",name:"संस्कृतम्"},{iso_639_1:"sc",iso_639_2:"srd",iso_3166_1:"IT",flag:"\uD83C\uDDEE\uD83C\uDDF9",english_name:"Sardinian",
63name:"Sardu"},{iso_639_1:"sd",iso_639_2:"snd",iso_3166_1:"PK",flag:"\uD83C\uDDF5\uD83C\uDDF0",english_name:"Sindhi",name:"सिन्धी"},{iso_639_1:"se",iso_639_2:"sme",iso_3166_1:"NO",flag:"\uD83C\uDDF3\uD83C\uDDF4",english_name:"Northern Sami",name:"Davvis\xe1megiella"},{iso_639_1:"sg",iso_639_2:"sag",iso_3166_1:"CF",flag:"\uD83C\uDDE8\uD83C\uDDEB",english_name:"Sango",name:"Y\xe2ng\xe2 t\xee s\xe4ng\xf6"},{iso_639_1:"sh",iso_639_2:"hbs",iso_3166_1:"RS",flag:"\uD83C\uDDF7\uD83C\uDDF8",english_name:"Serbo-Croatian",name:"Srpskohrvatski"},{iso_639_1:"si",iso_639_2:"sin",iso_3166_1:"LK",flag:"\uD83C\uDDF1\uD83C\uDDF0",english_name:"Sinhala; Sinhalese",name:"සිංහල"},{iso_639_1:"sk",iso_639_2:"slk",iso_3166_1:"SK",flag:"\uD83C\uDDF8\uD83C\uDDF0",flag_priority:!0,english_name:"Slovak",name:"Slovenčina"},{iso_639_1:"sl",iso_639_2:"slv",iso_3166_1:"SI",flag:"\uD83C\uDDF8\uD83C\uDDEE",english_name:"Slovenian",name:"Slovenščina"},{iso_639_1:"sm",iso_639_2:"smo",iso_3166_1:"WS",flag:"\uD83C\uDDFC\uD83C\uDDF8",english_name:"Samoan",name:"Gagana fa'a Samoa"},{iso_639_1:"sn",iso_639_2:"sna",iso_3166_1:"ZW",flag:"\uD83C\uDDFF\uD83C\uDDFC",english_name:"Shona",name:"ChiShona"},{iso_639_1:"so",iso_639_2:"som",iso_3166_1:"SO",flag:"\uD83C\uDDF8\uD83C\uDDF4",english_name:"Somali",name:"Af Soomaali"},{iso_639_1:"sq",iso_639_2:"sqi",iso_3166_1:"AL",flag:"\uD83C\uDDE6\uD83C\uDDF1",english_name:"Albanian",
63name:"Shqip"},{iso_639_1:"sr",iso_639_2:"srp",iso_3166_1:"RS",flag:"\uD83C\uDDF7\uD83C\uDDF8",flag_priority:!0,english_name:"Serbian",name:"Srpski"},{iso_639_1:"ss",iso_639_2:"ssw",iso_3166_1:"SZ",flag:"\uD83C\uDDF8\uD83C\uDDFF",english_name:"Swati",name:"SiSwati"},{iso_639_1:"st",iso_639_2:"sot",iso_3166_1:"LS",flag:"\uD83C\uDDF1\uD83C\uDDF8",english_name:"Sotho, Southern",name:"Sesotho"},{iso_639_1:"su",iso_639_2:"sun",iso_3166_1:"ID",flag:"\uD83C\uDDEE\uD83C\uDDE9",english_name:"Sundanese",name:"Basa Sunda"},{iso_639_1:"sv",iso_639_2:"swe",iso_3166_1:"SE",flag:"\uD83C\uDDF8\uD83C\uDDEA",english_name:"Swedish",name:"Svenska"},{iso_639_1:"sw",iso_639_2:"swa",iso_3166_1:"KE",flag:"\uD83C\uDDF0\uD83C\uDDEA",english_name:"Swahili",name:"Kiswahili"},{iso_639_1:"ta",iso_639_2:"tam",iso_3166_1:"IN",flag:"\uD83C\uDDEE\uD83C\uDDF3",english_name:"Tamil",name:"தமிழ்"},{iso_639_1:"te",iso_639_2:"tel",iso_3166_1:"IN",flag:"\uD83C\uDDEE\uD83C\uDDF3",english_name:"Telugu",name:"తెలుగు"},{iso_639_1:"tg",iso_639_2:"tgk",iso_3166_1:"TJ",flag:"\uD83C\uDDF9\uD83C\uDDEF",english_name:"Tajik",name:"тоҷикӣ"},{iso_639_1:"th",iso_639_2:"tha",iso_3166_1:"TH",flag:"\uD83C\uDDF9\uD83C\uDDED",english_name:"Thai",name:"ภาษาไทย"},{iso_639_1:"ti",iso_639_2:"tir",iso_3166_1:"ER",flag:"\uD83C\uDDEA\uD83C\uDDF7",english_name:"Tigrinya",name:"ትግርኛ"},{iso_639_1:"tk",iso_639_2:"tuk",iso_3166_1:"TM",flag:"\uD83C\uDDF9\uD83C\uDDF2",english_name:"Turkmen",name:"T\xfcrkmen"},{iso_639_1:"tl",iso_639_2:"tgl",iso_3166_1:"PH",flag:"\uD83C\uDDF5\uD83C\uDDED",english_name:"Tagalog",name:"Wikang Tagalog"},{iso_639_1:"tn",iso_639_2:"tsn",iso_3166_1:"BW",flag:"\uD83C\uDDE7\uD83C\uDDFC",english_name:"Tswana",name:"Setswana"},{iso_639_1:"to",iso_639_2:"ton",iso_3166_1:"TO",flag:"\uD83C\uDDF9\uD83C\uDDF4",english_name:"Tonga (Tonga Islands)",name:"Faka Tonga"},{iso_639_1:"tr",iso_639_2:"tur",iso_3166_1:"TR",flag:"\uD83C\uDDF9\uD83C\uDDF7",english_name:"Turkish",name:"T\xfcrk\xe7e"},{iso_639_1:"ts",iso_639_2:"tso",iso_3166_1:"ZA",flag:"\uD83C\uDDFF\uD83C\uDDE6",english_name:"Tsonga",name:"Xitsonga"},{iso_639_1:"tt",iso_639_2:"tat",iso_3166_1:"RU",flag:"\uD83C\uDDF7\uD83C\uDDFA",english_name:"Tatar",name:"Татар теле"},{iso_639_1:"tw",iso_639_2:"twi",iso_3166_1:"GH",flag:"\uD83C\uDDEC\uD83C\uDDED",english_name:"Twi",name:"Twi"},{iso_639_1:"ty",iso_639_2:"tah",iso_3166_1:"PF",flag:"\uD83C\uDDF5\uD83C\uDDEB",english_name:"Tahitian",name:"Reo Tahiti"},{iso_639_1:"ug",iso_639_2:"uig",iso_3166_1:"CN",flag:"\uD83C\uDDE8\uD83C\uDDF3",english_name:"Uighur; Uyghur",name:"Uyƣurqə"}
63,{iso_639_1:"uk",iso_639_2:"ukr",iso_3166_1:"UA",flag:"\uD83C\uDDFA\uD83C\uDDE6",english_name:"Ukrainian",name:"Український"},{iso_639_1:"ur",iso_639_2:"urd",iso_3166_1:"PK",flag:"\uD83C\uDDF5\uD83C\uDDF0",english_name:"Urdu",name:"اردو"},{iso_639_1:"uz",iso_639_2:"uzb",iso_3166_1:"UZ",flag:"\uD83C\uDDFA\uD83C\uDDFF",english_name:"Uzbek",name:"Oʻzbek"},{iso_639_1:"ve",iso_639_2:"ven",iso_3166_1:"ZA",flag:"\uD83C\uDDFF\uD83C\uDDE6",english_name:"Venda",name:"Tshivenḓa"},{iso_639_1:"vi",iso_639_2:"vie",iso_3166_1:"VN",flag:"\uD83C\uDDFB\uD83C\uDDF3",english_name:"Vietnamese",name:"Tiếng Việt"},{iso_639_1:"vo",iso_639_2:"vol",iso_3166_1:null,flag:"\uD83C\uDF10",english_name:"Volap\xfck",name:"Volap\xfck"},{iso_639_1:"wa",iso_639_2:"wln",iso_3166_1:"BE",flag:"\uD83C\uDDE7\uD83C\uDDEA",english_name:"Walloon",name:"Walon"},{iso_639_1:"wo",iso_639_2:"wol",iso_3166_1:"SN",flag:"\uD83C\uDDF8\uD83C\uDDF3",english_name:"Wolof",name:"Wolof"},{iso_639_1:"xh",iso_639_2:"xho",iso_3166_1:"ZA",flag:"\uD83C\uDDFF\uD83C\uDDE6",english_name:"Xhosa",name:"IsiXhosa"},{iso_639_1:"yi",iso_639_2:"yid",iso_3166_1:"IL",flag:"\uD83C\uDDEE\uD83C\uDDF1",english_name:"Yiddish",name:"ייִדיש"},{iso_639_1:"yo",iso_639_2:"yor",iso_3166_1:"NG",flag:"\uD83C\uDDF3\uD83C\uDDEC",english_name:"Yoruba",name:"\xc8d\xe8 Yor\xf9b\xe1"},{iso_639_1:"za",iso_639_2:"zha",iso_3166_1:"CN",flag:"\uD83C\uDDE8\uD83C\uDDF3",english_name:"Zhuang; Chuang",name:"Saɯ cueŋƅ"},{iso_639_1:"zh",iso_639_2:"zho",iso_3166_1:"CN",flag:"\uD83C\uDDE8\uD83C\uDDF3",flag_priority:!0,english_name:"Chinese (Simplified)",name:"中文 (简体)"},{iso_639_1:"zh",iso_639_2:"zho",iso_3166_1:"TW",flag:"\uD83C\uDDF9\uD83C\uDDFC",english_name:"Chinese (Traditional)",name:"中文 (繁體)"},{iso_639_1:"zh",iso_639_2:"zho",iso_3166_1:"HK",flag:"\uD83C\uDDED\uD83C\uDDF0",english_name:"Chinese (Hong Kong)",name:"中文 (香港)"},{iso_639_1:"zh",iso_639_2:"zho",iso_3166_1:"SG",flag:"\uD83C\uDDF8\uD83C\uDDEC",english_name:"Chinese (Singapore)",name:"中文 (新加坡)"},{iso_639_1:"zu",iso_639_2:"zul",iso_3166_1:"ZA",flag:"\uD83C\uDDFF\uD83C\uDDE6",english_name:"Zulu",name:"IsiZulu"},{iso_639_1:"sw",iso_639_2:"swa",iso_3166_1:"TZ",flag:"\uD83C\uDDF9\uD83C\uDDFF",english_name:"Swahili (Tanzania)",name:"Kiswahili"},{iso_639_1:"fr",iso_639_2:"fra",iso_3166_1:"CA",flag:"\uD83C\uDDE8\uD83C\uDDE6",english_name:"French (Canada)",name:"Fran\xe7ais"},{iso_639_1:"fr",iso_639_2:"fra",iso_3166_1:"BE",flag:"\uD83C\uDDE7\uD83C\uDDEA",english_name:"French (Belgium)",name:"Fran\xe7ais"},{iso_639_1:"fr",iso_639_2:"fra",iso_3166_1:"CH",flag:"\uD83C\uDDE8\uD83C\uDDED",english_name:"French (Switzerland)",name:"Fran\xe7ais"},{iso_639_1:"de",iso_639_2:"deu",iso_3166_1:"AT",flag:"\uD83C\uDDE6\uD83C\uDDF9",english_name:"German (Austria)",name:"Deutsch"},{iso_639_1:"de",iso_639_2:"deu",iso_3166_1:"CH",flag:"\uD83C\uDDE8\uD83C\uDDED",english_name:"German (Switzerland)",name:"Deutsch"},{iso_639_1:"it",iso_639_2:"ita",iso_3166_1:"CH",flag:"\uD83C\uDDE8\uD83C\uDDED",english_name:"Italian (Switzerland)",name:"Italiano"},{iso_639_1:"es",iso_639_2:"spa",iso_3166_1:"MX",flag:"\uD83C\uDDF2\uD83C\uDDFD",english_name:"Spanish (Mexico)",internal_english_name:"Latino",name:"Espa\xf1ol"},{iso_639_1:"es",iso_639_2:"spa",iso_3166_1:"AR",flag:"\uD83C\uDDE6\uD83C\uDDF7",english_name:"Spanish (Argentina)",name:"Espa\xf1ol"},{iso_639_1:"es",iso_639_2:"spa",iso_3166_1:"CO",flag:"\uD83C\uDDE8\uD83C\uDDF4",english_name:"Spanish (Colombia)",name:"Espa\xf1ol"},{iso_639_1:"es",iso_639_2:"spa",iso_3166_1:"CL",flag:"\uD83C\uDDE8\uD83C\uDDF1",english_name:"Spanish (Chile)",name:"Espa\xf1ol"},{iso_639_1:"es",iso_639_2:"spa",iso_3166_1:"PE",flag:"\uD83C\uDDF5\uD83C\uDDEA",english_name:"Spanish (Peru)",name:"Espa\xf1ol"},{iso_639_1:"es",iso_639_2:"spa",iso_3166_1:"VE",flag:"\uD83C\uDDFB\uD83C\uDDEA",english_name:"Spanish (Venezuela)",name:"Espa\xf1ol"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"MA",flag:"\uD83C\uDDF2\uD83C\uDDE6",english_name:"Arabic (Morocco)",name:"العربية"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"DZ",flag:"\uD83C\uDDE9\uD83C\uDDFF",english_name:"Arabic (Algeria)",name:"العربية"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"TN",flag:"\uD83C\uDDF9\uD83C\uDDF3",english_name:"Arabic (Tunisia)",name:"العربية"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"LY",flag:"\uD83C\uDDF1\uD83C\uDDFE",english_name:"Arabic (Libya)",name:"العربية"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"JO",flag:"\uD83C\uDDEF\uD83C\uDDF4",english_name:"Arabic (Jordan)",name:"العربية"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"SY",flag:"\uD83C\uDDF8\uD83C\uDDFE",english_name:"Arabic (Syria)",name:"العربية"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"LB",flag:"\uD83C\uDDF1\uD83C\uDDE7",english_name:"Arabic (Lebanon)",name:"العربية"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"IQ",flag:"\uD83C\uDDEE\uD83C\uDDF6",english_name:"Arabic (Iraq)",name:"العربية"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"KW",flag:"\uD83C\uDDF0\uD83C\uDDFC",english_name:"Arabic (Kuwait)",name:"العربية"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"BH",flag:"\uD83C\uDDE7\uD83C\uDDED",english_name:"Arabic (Bahrain)",name:"العربية"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"QA",flag:"\uD83C\uDDF6\uD83C\uDDE6",english_name:"Arabic (Qatar)",name:"العربية"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"OM",flag:"\uD83C\uDDF4\uD83C\uDDF2",english_name:"Arabic (Oman)",name:"العربية"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"YE",flag:"\uD83C\uDDFE\uD83C\uDDEA",english_name:"Arabic (Yemen)",name:"العربية"},{iso_639_1:"ar",iso_639_2:"ara",iso_3166_1:"SD",flag:"\uD83C\uDDF8\uD83C\uDDE9",english_name:"Arabic (Sudan)",name:"العربية"},{iso_639_1:null,iso_639_2:"ace",iso_3166_1:"ID",flag:"\uD83C\uDDEE\uD83C\uDDE9",english_name:"Achinese",name:"Bahsa Ac\xe8h"},{iso_639_1:null,iso_639_2:"ach",iso_3166_1:"UG",flag:"\uD83C\uDDFA\uD83C\uDDEC",english_name:"Acoli",name:"Lwo"},{iso_639_1:null,iso_639_2:"ada",iso_3166_1:"GH",flag:"\uD83C\uDDEC\uD83C\uDDED",english_name:"Adangme",name:"Adangme"},{iso_639_1:null,iso_639_2:"ady",iso_3166_1:"RU",flag:"\uD83C\uDDF7\uD83C\uDDFA",english_name:"Adyghe; Adygei",name:"Адыгэбзэ"},{iso_639_1:null,iso_639_2:"afa",iso_3166_1:"ET",flag:"\uD83C\uDDEA\uD83C\uDDF9",english_name:"Afro-Asiatic languages",name:"Afro-Asiatic"},{iso_639_1:null,iso_639_2:"afh",iso_3166_1:"GH",flag:"\uD83C\uDDEC\uD83C\uDDED",english_name:"Afrihili",name:"Afrihili"},{iso_639_1:null,iso_639_2:"agq",iso_3166_1:"CM",flag:"\uD83C\uDDE8\uD83C\uDDF2",english_name:"Aghem",name:"Aghem"},{iso_639_1:null,iso_639_2:"ain",iso_3166_1:"JP",flag:"\uD83C\uDDEF\uD83C\uDDF5",english_name:"Ainu",n
63ame:"アイヌ イタㇰ"},{iso_639_1:null,iso_639_2:"akk",iso_3166_1:"IQ",flag:"\uD83C\uDDEE\uD83C\uDDF6",english_name:"Akkadian",name:"Akkadian"},{iso_639_1:null,iso_639_2:"ale",iso_3166_1:"US",flag:"\uD83C\uDDFA\uD83C\uDDF8",english_name:"Aleut",name:"Unangam Tunuu"},{iso_639_1:null,iso_639_2:"alt",iso_3166_1:"RU",flag:"\uD83C\uDDF7\uD83C\uDDFA",english_name:"Southern Altai",name:"Алтай тил"},{iso_639_1:null,iso_639_2:"ang",iso_3166_1:"GB",flag:"\uD83C\uDDEC\uD83C\uDDE7",english_name:"English, Old (ca.450-1100)",name:"Englisc"},{iso_639_1:null,iso_639_2:"anp",iso_3166_1:"IN",flag:"\uD83C\uDDEE\uD83C\uDDF3",english_name:"Angika",name:"अंगिका"},{iso_639_1:null,iso_639_2:"arc",iso_3166_1:"SY",flag:"\uD83C\uDDF8\uD83C\uDDFE",english_name:"Aramaic",name:"ܐܪܡܝܐ"},{iso_639_1:null,iso_639_2:"arn",iso_3166_1:"CL",flag:"\uD83C\uDDE8\uD83C\uDDF1",english_name:"Mapudungun; Mapuche",name:"Mapudungun"},{iso_639_1:null,iso_639_2:"arp",iso_3166_1:"US",flag:"\uD83C\uDDFA\uD83C\uDDF8",english_name:"Arapaho",name:"Hin\xf3noʼeit\xed\xedt"},{iso_639_1:null,iso_639_2:"arw",iso_3166_1:"GY",flag:"\uD83C\uDDEC\uD83C\uDDFE",english_name:"Arawak",name:"Arawak"},{iso_639_1:null,iso_639_2:"ast",iso_3166_1:"ES",flag:"\uD83C\uDDEA\uD83C\uDDF8",english_name:"Asturian; Bable; Leonese; Asturleonese",name:"Asturianu"}];function hN(e){return e.internal_english_name?e.internal_english_name:e.english_name.split(/;|\(/)[0].trim()}let hk={fre:"fra",ger:"deu",cze:"ces",slo:"slk",rum:"ron",dut:"nld",gre:"ell",alb:"sqi",baq:"eus",bur:"mya",chi:"zho",per:"fas",arm:"hye",geo:"kat",ice:"isl",mac:"mk
63d",mao:"mri",may:"msa",tib:"bod",wel:"cym"},hS=new Map(sQ.map(e=>[e.toLowerCase(),e])),hC=new Map;for(let e of hw)for(let t of[e.internal_english_name,e.english_name,...e.english_name.split(";").map(e=>e.split("(")[0])]){let s=null==t?void 0:t.trim().toLowerCase();if(!s)continue;let a=hC.get(s);a&&(a.flag_priority||!e.flag_priority)||hC.set(s,e)}let h_={"latin america":"419",latam:"419",la:"419"},hR=/^(.*\S)\s*\(([^()]+)\)$/;function hA(e){if(!e)return;let t=hN(e);return sQ.includes(t)?t:void 0}function hT(e){let t,s=hI(hk[t=e.toLowerCase().trim()]??t).toLowerCase().split("-"),a=hw.filter(e=>{var t,a,r,n;return 2===s.length?(null==(r=e.iso_639_1)?void 0:r.toLowerCase())===s[0]&&(null==(n=e.iso_3166_1)?void 0:n.toLowerCase())===s[1]:(null==(t=e.iso_639_1)?void 0:t.toLowerCase())===s[0]||(null==(a=e.iso_639_2)?void 0:a.toLowerCase())===s[0]});return a.find(e=>e.flag_priority)??a[0]}function hI(e){switch(e.toLowerCase()){case"zh-tw":case"zh-hans":return"zh";case"es-419":return"es-MX";default:return e}}function hE(e){if("string"!=typeof e)return;let t=e.trim();if(!(t.length>64))for(;t;){var s,a;let e=hS.get(t.toLowerCase());if(e)return e;let r=hA(hC.get(t.toLowerCase()));if(r)return r;let n=hA(hT(t));if(n)return n;let l=hR.exec(t);if(!l)break;let i=l[1].trim(),o=l[2].trim(),d=(null==(s=hC.get(i.toLowerCase()))?void 0:s.iso_639_1)??(null==(a=hT(i))?void 0:a.iso_639_1),c=h_[o.toLowerCase()]??(/^[a-z]{2}$/i.test(o)?o:void 0);if(d&&c){let e=hA(hT(`${d}-${c}`));if(e)return e}t=i}}let hM=new Set(["Latino","Portuguese (Brazil)"].map(e=>e.toLowerCase())),hP=new Map,hD={multi:"\uD83C\uDF0E",english:"\uD83C\uDDEC\uD83C\uDDE7",japanese:"\uD83C\uDDEF\uD83C\uDDF5",chinese:"\uD83C\uDDE8\uD83C\uDDF3",russian:"\uD83C\uDDF7\uD83C\uDDFA",arabic:"\uD83C\uDDF8\uD83C\uDDE6",portuguese:"\uD83C\uDDF5\uD83C\uDDF9","portuguese (brazil)":"\uD83C\uDDE7\uD83C\uDDF7",spanish:"\uD83C\uDDEA\uD83C\uDDF8",french:"\uD83C\uDDEB\uD83C\uDDF7",german:"\uD83C\uDDE9\uD83C\uDDEA",italian:"\uD83C\uDDEE\uD83C\uDDF9",korean:"\uD83C\uDDF0\uD83C\uDDF7",hindi:"\uD83C\uDDEE\uD83C\uDDF3",bengali:"\uD83C\uDDE7\uD83C\uDDE9",punjabi:"\uD83C\uDDF5\uD83C\uDDF0",marathi:"\uD83C\uDDEE\uD83C\uDDF3",gujarati:"\uD83C\uDDEE\uD83C\uDDF3",tamil:"\uD83C\uDDEE\uD83C\uDDF3",telugu:"\uD83C\uDDEE\uD83C\uDDF3",kannada:"\uD83C\uDDEE\uD83C\uDDF3",malayalam:"\uD83C\uDDEE\uD83C\uDDF3",thai:"\uD83C\uDDF9\uD83C\uDDED",vietnamese:"\uD83C\uDDFB\uD83C\uDDF3",indonesian:"\uD83C\uDDEE\uD83C\uDDE9",turkish:"\uD83C\uDDF9\uD83C\uDDF7",hebrew:"\uD83C\uDDEE\uD83C\uDDF1",persian:"\uD83C\uDDEE\uD83C\uDDF7",ukrainian:"\uD83C\uDDFA\uD83C\uDDE6",greek:"\uD83C\uDDEC\uD83C\uDDF7",lithuanian:"\uD83C\uDDF1\uD83C\uDDF9",latvian:"\uD83C\uDDF1\uD83C\uDDFB",estonian:"\uD83C\uDDEA\uD83C\uDDEA",polish:"\uD83C\uDDF5\uD83C\uDDF1",czech:"\uD83C\uDDE8\uD83C\uDDFF",slovak:"\uD83C\uDDF8\uD83C\uDDF0",hungarian:"\uD83C\uDDED\uD83C\uDDFA",romanian:"\uD83C\uDDF7\uD83C\uDDF4",bulgarian:"\uD83C\uDDE7\uD83C\uDDEC",serbian:"\uD83C\uDDF7\uD83C\uDDF8",croatian:"\uD83C\uDDED\uD83C\uDDF7",slovenian:"\uD83C\uDDF8\uD83C\uDDEE",dutch:"\uD83C\uDDF3\uD83C\uDDF1",danish:"\uD83C\uDDE9\uD83C\uDDF0",finnish:"\uD83C\uDDEB\uD83C\uDDEE",swedish:"\uD83C\uDDF8\uD83C\uDDEA",norwegian:"\uD83C\uDDF3\uD83C\uDDF4",malay:"\uD83C\uDDF2\uD83C\uDDFE",latino:"\uD83D\uDC83\uD83C\uDFFB",Latino:"\uD83C\uDDF2\uD83C\uDDFD"};s(8963).Buffer;let hL=e=>{let t=hE(e)??e;return function(e){let t=hP.get(e);if(void 0!==t||hP.has(e))return t;let s=function(e){var t,s,a;let r=hw.filter(t=>t.english_name.split(";").some(t=>t.split("(")[0].trim().toLowerCase()===e.toLowerCase())||t.internal_english_name&&t.internal_english_name.toLowerCase()===e.toLowerCase()||t.name.toLowerCase()===e.toLowerCase());if(0===r.length)return;let n=r.find(e=>e.flag_priority)??r[0];return hM.has(hN(n).toLowerCase())?`${null==(s=n.iso_639_1)?void 0:s.toUpperCase()}-${null==(a=n.iso_3166_1)?void 0:a.toUpperCase()}`:null==(t=n.iso_639_1)?void 0:t.toUpperCase()}(e);return hP.size>=1e3&&hP.clear(),hP.set(e,s),s}(t)||t.toUpperCase()},hU=e=>hD[(hE(e)??e).toLowerCase()]??"",h$=(e,t)=>[...new Set(e.map(e=>
63t(String(e))).filter(Boolean))],hO=(e,t)=>e.length>0?String(e[t]):"",hF=e=>t=>[...t].sort((t,s)=>{let a="number"==typeof t&&"number"==typeof s?t-s:String(t).localeCompare(String(s),void 0,{numeric:!0});return e?a:-a}),hz=e=>t=>{let s=Math.floor(t/20),a=+(t%20>=10);return"★".repeat(s)+"⯪".repeat(a)+(e?"☆".repeat(5-s-a):"")},hV={join:e=>e.join(", "),length:e=>e.length.toString(),first:e=>hO(e,0),last:e=>hO(e,e.length-1),random:e=>hO(e,Math.floor(Math.random()*e.length)),sort:hF(!0),rsort:hF(!1),lsort:e=>[...e].sort(),reverse:e=>[...e].reverse(),languagecode:e=>h$(e,hL),languageemoji:e=>h$(e,hU),string:e=>e.toString()},hq={comma:e=>e.toLocaleString(),hex:e=>e.toString(16),octal:e=>e.toString(8),binary:e=>e.toString(2),bytes:e=>hv(e,1e3),sbytes:e=>hy(e,1e3),sbytes10:e=>hy(e,1e3),sbytes2:e=>hy(e,1024),rbytes:e=>hv(e,1e3,!0),bytes10:e=>hv(e,1e3),rbytes10:e=>hv(e,1e3,!0),bytes2:e=>hv(e,1024),rbytes2:e=>hv(e,1024,!0),bitrate:e=>hj(e),rbitrate:e=>hj(e,!0),sbitrate:e=>(function(e){let t,s;if(!Number.isFinite(e)||e<=0)return"0 bps";let a=["bps","Kbps","Mbps","Gbps","Tbps"],r=Math.min(a.length-1,Math.max(0,Math.floor(Math.log(e)/Math.log(1e3)))),n=e/Math.pow(1e3,r),l=Math.floor(n);return s=l>=100?(t=Math.round(n)).toString():l>=10?(t=parseFloat(n.toFixed(1)))%1==0?t.toFixed(0):t.toFixed(1):(t=parseFloat(n.toFixed(2))).toString(),`${s} ${a[r]}`})(e),string:e=>e.toString(),time:e=>{let t,s,a,r,n;return a=Math.floor((s=Math.floor((t=Math.floor((e<0?0:e<1e3?60*e*1e3:e)/1e3))/60))/60),r=t%60,n=s%60,a>0?`${a}h:${n}m:${r}s`:r>0?`${n}m:${r}s`:`${n}m`},star:hz(!1),pstar:hz(!0)},hB=["upper","lower","title","length","reverse","base64","string","smallcaps","subscript","superscript","languagecode","languageemoji"],hK=Object.keys(hq),hH=Object.keys(hV),hG=["string"],hW=["istrue","isfalse","exists"],hY=[...hB,...hG,...hK,...hH,...hW],hJ=["$","^","~","=",">=",">","<=","<"].sort((e,t)=>t.length-e.length),hZ=["and","or","xor","neq","equal","left","right"],hQ=()=>hZ,hX=[...hY].map(e=>e.toLowerCase()).sort((e,t)=>t.length-e.length),h0=[["replace","replaceArgs"],["remove","loose"],["join","quoted"],["truncate","digits"],["slice","digitsOrPair"],["time","quoted"],["date","quoted"],["default","quoted"],["in","loose"],["translate","quotedPair"]],h1=/^\s*[A-Za-z_][A-Za-z0-9_]*\s*\.\s*[A-Za-z_][A-Za-z0-9_]*/,h2=new Set(["unknown-field","unknown-modifier","modifier-arguments"]);class h3{get atEnd(){return this.pos>=this.input.length}peek(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.input[this.pos+e]}eat(e){return this.input.substr(this.pos,e.length).toLowerCase()===e.toLowerCase()&&(this.pos+=e.length,!0)}startsWith(e){return this.input.substr(this.pos,e.length).toLowerCase()===e.toLowerCase()}slice(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.pos;return this.input.slice(e,t)}constructor(e,t=0){(0,en._)(this,"input",void 0),(0,en._)(this,"pos",void 0),this.input=e,this.pos=t}}function h6(e){return void 0!==e&&/[A-Za-z0-9_]/.test(e)}function h5(e){for(;!e.atEnd;){let t=e.peek();if("}"===t||"["===t||"]"===t||":"===t&&":"===e.peek(1))break;e.pos+=1}}function h4(e){let t=e.peek();if("'"!==t&&'"'!==t)return!1;for(e.pos+=1;!e.atEnd;){if(e.peek()===t){let t=e.peek(1);if(void 0===t||","===t||")"===t||/\s/.test(t))return e.pos+=1,!0}e.pos+=1}return!1}function h9(e){let t=e.pos;for(;void 0!==e.peek()&&/\d/.test(e.peek());)e.pos+=1;return e.pos>t}function h8(e){for(;void 0!==e.peek()&&/\s/.test(e.peek());)e.pos+=1}function h7(e,t){if(!e.eat("("))return!1;switch(t){case"quoted":if(!h4(e))return!1;break;case"quotedPair":if(!h4(e)||(h8(e),!e.eat(","))||(h8(e),!h4(e)))return!1;break;case"replaceArgs":if("{"===e.peek()){for(;!e.atEnd&&"}"!==e.peek();)e.pos+=1;if(!e.eat("}"))return!1}else if(!h4(e))return!1;if(h8(e),!e.eat(",")||(h8(e),!h4(e)))return!1;break;case"digits":if(!h9(e))return!1;break;case"digitsOrPair":if(h8(e),!h9(e))return!1;if(h8(e),e.eat(",")){if(h8(e),!h9(e))return!1;h8(e)}break;case"loose":return function(e){let t=-1;for(;!e.atEnd;){let s=e.peek();if("}"===s||"["===s||"]"===s||":"===s&&":"===e.peek(1))break;")"===s&&(t=e.pos),e.pos+=1}return -1!==t&&(e.pos=t,!0)}(e)&&e.eat(")")}return e.eat(")")}function xe(e){let t=e.pos;for(let[s,a]of h0)if(e.startsWith(`${s}(`)){if(e.pos+=s.length,h7(e,a))return e.slice(t);e.pos=t;break}for(let s of hJ)if(e.startsWith(s))return e.pos+=s.length,h5(e),e.slice(t);for(let s of hX)if(e.startsWith(s)&&!h6(e.peek(s.length)))return e.pos+=s.length,e.slice(t);e.pos=t}function xt(e){let t;if("'"===e.peek()||'"'===e.peek()){let s=e.peek(),a=e.pos;e.pos+=1;let r=e.pos;for(;!e.atEnd&&e.peek()!==s;)e.pos+=1;if(e.atEnd){e.pos=a;return}let n=e.slice(r);e.pos+=1,t={section:"",property:"",literal:n}}else t=function(e){let t=e.pos;for(;h6(e.peek());)e.pos+=1;let s=e.slice(t);if(!s||"."!==e.peek()){e.pos=t;return}e.pos+=1;let a=e.pos;for(;h6(e.peek());)e.pos+=1;let r=e.slice(a);if(!r){e.pos=t;return}let n=hg(s,r);if(!n){e.pos=t;return}return[s,r]=n,{section:s,property:r}}(e);if(!t)return;let s=[];for(;e.startsWith("::");){let t=e.pos;if(e.pos+=2,hQ().some(t=>e.startsWith(`${t}::`))){e.pos=t;break}let a=xe(e);if(void 0===a){e.pos=t;break}s.push(a)}return{...t,modifiers:s}}function xs(e,t){let s,a,r=e.pos,n=s=>{null==t||t(s,e.pos),e.pos=r};if(!e.eat("["))return n("no-open");let l=()=>{if(!e.eat('"'))return;let t="",s=0;for(;!e.atEnd;){let a=e.peek();if("\\"===a&&'"'===e.peek(1)){t+='"',e.pos+=2;continue}if("{"===a)s+=1;else if("}"===a)s=Math.max(0,s-1);else if('"'===a&&0===s)return e.pos+=1,t;t+=a,e.pos+=1}},i=e.pos+1,o=l();if(void 0===o)return n("true-branch");if(!e.eat("||"))return n("missing-or");let d=e.pos+1,c=l();return void 0===c?n("false-branch"):e.startsWith("||")&&(e.pos+=2,a=e.pos+1,void 0===(s=l()))?n("absent-branch"):e.eat("]")?{trueTemplate:o,falseTemplate:c,trueStart:i,falseStart:d,...void 0!==s?{absentTemplate:s,absentStart:a}:{}}:n("missing-close")}function xa(e){let t=e.pos,s=()=>{e.pos=t};if(!e.eat("{"))return s();h8(e);let a=[],r=[],n=xt(e);
63if(!n)return s();for(a.push(n);e.startsWith("::");){let t=e.pos;e.pos+=2;let n=hQ().find(t=>e.startsWith(`${t}::`));if(!n){e.pos=t;break}e.pos+=n.length+2;let l=xt(e);if(!l)return s();r.push(n.toLowerCase()),a.push(l)}let l="["===e.peek()?xs(e):void 0;return(h8(e),e.eat("}"))?{kind:"expression",source:e.slice(t),operands:a,comparators:r,start:t,end:e.pos,...l?{check:l}:{}}:s()}function xr(e){let t=new h3(e),s=[],a=[],r=0,n=0,l=t=>{if(t>r){let a={kind:"raw",text:e.slice(r,t)};a.start=r,a.end=t,s.push(a)}};for(;!t.atEnd;){if("{"!==t.peek()){t.pos+=1;continue}let i=t.pos;if(t.startsWith("{?")){let n=function(e){let t=e.pos;if(!e.eat("{?"))return;let s=e.pos,a=1;for(;!e.atEnd;){if(e.startsWith("{?")){a+=1,e.pos+=2;continue}if(e.startsWith("?}")){if(0==(a-=1)){let t=e.slice(s);return e.pos+=2,t}e.pos+=2;continue}e.pos+=1}e.pos=t}(t);if(void 0!==n){l(i);let e=xr(n),o=i+2;a.push(...e.diagnostics.map(e=>({...e,index:e.index+o}))),function e(t,s){for(let a of t)if(void 0!==a.start&&(a.start+=s),void 0!==a.end&&(a.end+=s),"group"===a.kind&&e(a.nodes,s),"expression"===a.kind&&a.check){let e=a.check;void 0!==e.trueStart&&(e.trueStart+=s),void 0!==e.falseStart&&(e.falseStart+=s),void 0!==e.absentStart&&(e.absentStart+=s)}}(e.nodes,o),s.push({kind:"group",nodes:e.nodes,start:i,end:t.pos}),r=t.pos;continue}a.length<25&&a.push({index:i,message:"unterminated group: no matching `?}`",source:e.slice(i,i+2),category:"unterminated-group"})}let o=function(e){let t=e.pos;for(let s of["newLine","removeLine"]){if(e.eat(`{tools.${s}}`))return{kind:"tool",tool:s};e.pos=t}}(t)??xa(t);if(!o){let o=e.indexOf("}",i),d=-1===o?"":e.slice(i+1,o);if(a.length<25){let t=function(e,t){let{end:s,terminated:a}=xl(e,t),r=e.slice(t,a?s+1:s),n=a?r.slice(1,-1):r.slice(1);if(!h1.test(n))return;let l=(e,s,a)=>({index:t,message:s,source:r,category:e,...a?{suggestion:a}:{}}),i=e=>{let t=e.toLowerCase(),s=h0.find(e=>{let[s]=e;return s===t});return l("modifier-arguments",s?`modifier \`${e}\` has invalid arguments; expected \`${t}${xn[s[1]]}\``:`modifier \`${e}\` takes no arguments`)},o=new h3(r);o.eat("{"),h8(o);let d=()=>{let e=o.pos;for(;h6(o.peek());)o.pos+=1;let t=o.slice(e);if(!t||"."!==o.peek()){o.pos=e;return}o.pos+=1;let s=o.pos;for(;h6(o.peek());)o.pos+=1;let a=o.slice(s);if(!a||hg(t,a))return;let r=function(e,t){let s=hf.get(t.toLowerCase());if(s)return[...s];let a=Object.keys(hh),r=a.find(t=>t.toLowerCase()===e.toLowerCase());return r?hb(t,hh[r]).map(e=>`${r}.${e}`):hb(e,a).map(e=>hg(e,t)).filter(e=>void 0!==e).map(e=>{let[t,s]=e;return`${t}.${s}`})}(t,a),n=r.length?` — did you mean \`${r.join("` or `")}\`?`:"";return l("unknown-field",`unknown field \`${t}.${a}\`${n}`,r[0])},c=()=>{for(;o.startsWith("::");){let e=o.pos;if(o.pos+=2,hQ().some(e=>o.startsWith(`${e}::`))){o.pos=e;break}let t=o.pos;if(xe(o)){if("("===o.peek())return i(o.slice(t));continue}if(hJ.some(e=>o.startsWith(e))){o.pos=e;break}let s=o.pos;for(;h6(o.peek());)o.pos+=1;let a=o.slice(s);if(!a)break;if(xi().includes(a.toLowerCase()))return i(a);let r=hb(a.toLowerCase(),xi())[0];return l("unknown-modifier",`unknown modifier \`${a}\`${r?` — did you mean \`${r}\`?`:""}`)}};for(;;){let e=d();if(e)return e;let t=c();if(t)return t;if(!o.startsWith("::"))break;let s=o.pos;o.pos+=2;let a=hQ().find(e=>o.startsWith(`${e}::`));if(!a){o.pos=s;break}o.pos+=a.length+2}if("["===o.peek()){let e;if(xs(o,(t,s)=>{e??(e={reason:t,at:s})}),e){let t=function(e,t,s){if("no-open"!==t)return"missing-close"===t?"conditional is missing its closing `]`":"missing-or"===t?"conditional branches must be separated by `||`":s>=e.length?'unterminated conditional branch: a nested `{` is missing its `}`, or the branch is missing its closing `"`':"\\"===e[s]&&'"'===e[s+1]?'conditional branch starts with an escaped quote `\\"` — escapes only apply one nesting level deeper':'conditional branch must start with `"`'}(r,e.reason,e.at);if(t)return l("conditional",t)}}return a?l("unparseable",`unparseable expression: {${n}}`):l("unterminated","unterminated expression: no closing `}`")}(e,i),s=i<n;t&&(!s||h2.has(t.category))&&a.push(t)}if(n=Math.max(n,xl(e,i).end),!d.includes("{")&&h1.test(d)){l(i),s.push({kind:"raw",text:`{invalid_expression(${d.trim()})}`,start:i,end:o+1}),t.pos=o+1,r=t.pos;continue}t.pos=i+1;continue}l(i),void 0===o.start&&(o.start=i),void 0===o.end&&(o.end=t.pos),s.push(o),r=t.pos}return l(e.length),{nodes:s,diagnostics:a}}let xn={quoted:"('text')",quotedPair:"('from', 'to')",replaceArgs:"('find', 'replaceWith')",digits:"(3)",digitsOrPair:"(0, 3)",loose:"('a', 'b')"};function xl(e,t){let s=0,a=Math.min(e.length,t+4e3);for(let r=t;r<a;r++){let t=e[r];if("{"===t)s+=1;else if("}"===t&&0==(s-=1))return{end:r,terminated:!0}}return{end:a,terminated:!1}}function xi(){return[...new Set([...hX,...h0.map(e=>{let[t]=e;return t})])]}let xo=e=>e;function xd(e,t,s,a,r,n){if(a<=s)return;let l=t(s),i=t(a-1)+1;i>l&&e.push({start:l,end:i,kind:r,depth:n})}function xc(e,t,s,a,r){let n=e.peek();if("'"===n||'"'===n){let l=e.pos;for(e.pos+=1;e.pos<t&&e.peek()!==n;)e.pos+=1;e.peek()===n&&(e.pos+=1),xd(r,s,l,e.pos,"literal",a)}else{let t=e.pos;for(;h6(e.peek());)e.pos+=1;if(xd(r,s,t,e.pos,"section",a),"."===e.peek()){xd(r,s,e.pos,e.pos+1,"dot",a),e.pos+=1;let t=e.pos;for(;h6(e.peek());)e.pos+=1;xd(r,s,t,e.pos,"property",a)}}for(;e.pos<t&&e.startsWith("::");){let t=e.pos;if(e.pos+=2,hQ().some(t=>e.startsWith(`${t}::`))){e.pos=t;break}xd(r,s,t,t+2,"separator",a);let n=e.pos;if(function(e,t,s,a){let r=e.pos;for(let[n,l]of h0){if(!e.startsWith(`${n}(`))continue;let i=r+n.length;e.pos=i;let o=e.pos;if(h7(e,l)){xd(a,t,r,i,"modifier",s),xd(a,t,o,e.pos,"call-args",s);return}e.pos=r;break}for(let n of hJ){if(!e.startsWith(n))continue;let l=r+n.length;xd(a,t,r,l,"prefix-op",s),e.pos=l;let i=e.pos;h5(e),xd(a,t,i,e.pos,"call-args",s);return}for(let n of hX)if(e.startsWith(n)&&!h6(e.peek(n.length))){xd(a,t,r,r+n.length,"modifier",s),e.pos=r+n.length;return}}(e,s,a,r),e.pos<=n)break}}function xu(e){let t=new Set;return e&&!function e(t,s,a){for(let r of t){if("group"===r.kind){e(r.nodes,s,a);continue}if("expression"===r.kind){for(let e of r.operands)void 0===e.literal&&e.section&&s.add(`${e.section}.${e.property}`);if(r.check&&!(a>=5))for(let t of[r.check.trueTemplate,r.check.falseTemplate,r.check.absentTemplate])t&&e(xr(t).nodes,s,a+1)}}}(xr(e).nodes,t,0),t}let xm={section:"cmf-section",property:"cmf-property",dot:"cmf-dot",literal:"cmf-literal",modifier:"cmf-modifier","call-args":"cmf-args",comparator:"cmf-comparator","prefix-op":"cmf-prefix",tool:"cmf-tool",separator:"cmf-sep",quote:"cmf-quote",pipe:"cmf-pipe",invalid:"cmf-invalid"},xp=new Set(["brace","bracket","group-brace"]);function xh(e){var t;let s,a=new p_.vB;for(let r of(s=[],function e(t,s,a,r,n,l){let i=s,o=s,d=e=>xd(l,r,o,e,"text",n);for(;i<a;){if("{"!==t[i]){i+=1;continue}let s=i,c=function(e,t,s){for(let a of["{tools.newline}","{tools.removeline}"]){let r=t+a.length;if(r<=s&&e.slice(t,r).toLowerCase()===a)return r}}(t,s,a);if(void 0!==c){d(s),xd(l,r,s,c,"tool",n),o=i=c;continue}if(t.startsWith("{?",s)){let c=function(e,t,s){let a=t+2,r=1;for(;a<s;){if(e.startsWith("{?",a)){r+=1,a+=2;continue}if(e.startsWith("?}",a)){if(0==(r-=1))return{bodyEnd:a,end:a+2};a+=2;continue}a+=1}}(t,s,a);
63if(void 0!==c){d(s),xd(l,r,s,s+2,"group-brace",n),e(t,s+2,c.bodyEnd,r,n+1,l),xd(l,r,c.bodyEnd,c.end,"group-brace",n),o=i=c.end;continue}}let u=new h3(t,s);if(xa(u)&&u.pos<=a){d(s),function(t,s,a,r,n,l){let i=new h3(t,s+1);for(xd(l,r,s,s+1,"brace",n),h8(i),xc(i,a,r,n,l);i.pos<a&&i.startsWith("::");){let e=i.pos;i.pos+=2;let t=hQ().find(e=>i.startsWith(`${e}::`));if(!t){i.pos=e;break}let s=e+2;xd(l,r,e,s,"separator",n),xd(l,r,s,s+t.length,"comparator",n),xd(l,r,s+t.length,s+t.length+2,"separator",n),i.pos=s+t.length+2,xc(i,a,r,n,l)}i.pos<a&&"["===i.peek()&&function(t,s,a,r,n){xd(n,a,t.pos,t.pos+1,"bracket",r),t.pos+=1;for(let l=0;l<3&&(function(t,s,a,r,n){if('"'!==t.peek())return;xd(n,a,t.pos,t.pos+1,"quote",r),t.pos+=1;let l="",i=[],o=0;for(;t.pos<s;){let e=t.peek();if("\\"===e&&'"'===t.peek(1)){i.push(t.pos),l+='"',t.pos+=2;continue}if("{"===e)o+=1;else if("}"===e)o=Math.max(0,o-1);else if('"'===e&&0===o)break;i.push(t.pos),l+=e,t.pos+=1}let d=t.pos;e(l,0,l.length,e=>a(e>=0&&e<i.length?i[e]:d),r+1,n),'"'===t.peek()&&(xd(n,a,d,d+1,"quote",r),t.pos+=1)}(t,s,a,r,n),t.startsWith("||"));l++)xd(n,a,t.pos,t.pos+2,"pipe",r),t.pos+=2;"]"===t.peek()&&(xd(n,a,t.pos,t.pos+1,"bracket",r),t.pos+=1)}(i,a,r,n,l),"}"===t[a-1]&&xd(l,r,a-1,a,"brace",n)}(t,s,u.pos,r,n,l),o=i=u.pos;continue}d(s);let m=xl(t,s),p=Math.min(m.terminated?m.end+1:m.end,a);p>s?(xd(l,r,s,p,"invalid",n),i=p):i=s+1,o=i}d(a)}(t=e.state.doc.toString(),0,t.length,xo,0,s),s.sort((e,t)=>e.start-t.start),s)){let e=xp.has(r.kind)?`cmf-d${r.depth%5}`:xm[r.kind];e&&a.add(r.start,r.end,pS.NZ.mark({class:e}))}return a.finish()}let xx=pS.Z9.fromClass(class{update(e){e.docChanged&&(this.decorations=xh(e.view))}constructor(e){(0,en._)(this,"decorations",void 0),this.decorations=xh(e)}},{decorations:e=>e.decorations}),xg=new Set(["unterminated","unterminated-group","unparseable"]),xf=(0,pE.bu)(e=>{let t=e.state.doc.toString(),s=t.length;return(function(e){let{nodes:t,diagnostics:s}=xr(e),a=[...s,...function e(t,s,a){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;
63if(r>5)return[];let n=[];for(let l of t){if("group"===l.kind){n.push(...e(l.nodes,s,a,r+1));continue}if("expression"===l.kind&&l.check)for(let[t,i]of[[l.check.trueTemplate,l.check.trueStart],[l.check.falseTemplate,l.check.falseStart],[l.check.absentTemplate,l.check.absentStart]]){if(void 0===t||void 0===i)continue;let l=function(e,t){let s=[],a=t,r=0;for(;a<e.length;){let t=e[a];if("\\"===t&&'"'===e[a+1]){s.push(a),a+=2;continue}if("{"===t)r+=1;else if("}"===t)r=Math.max(0,r-1);else if('"'===t&&0===r)break;s.push(a),a+=1}let n=a;return e=>e>=0&&e<s.length?s[e]:n}(s,a(i)),o=xr(t);n.push(...o.diagnostics.map(e=>({...e,index:l(e.index),message:`inside conditional branch: ${e.message}`}))),n.push(...e(o.nodes,s,l,r+1))}}return n}(t,e,e=>e)],r=new Set;return a.filter(e=>{let t=`${e.index}:${e.message}`;return!r.has(t)&&(r.add(t),!0)})})(t).map(e=>{let t=Math.max(0,Math.min(e.index,s)),a=Math.max(t+1,Math.min(e.index+(e.source?e.source.length:1),s)),r={from:t,to:a,severity:xg.has(e.category)?"error":"warning",message:e.message};if(e.suggestion){var n;let t=e.suggestion,s=null==(n=/`([^`]+)`/.exec(e.message))?void 0:n[1];r.actions=[{name:`Replace with ${t}`,apply(e,a,r){let n=e.state.doc.sliceString(a,r),l=s?n.indexOf(s):-1;s&&l>=0&&e.dispatch({changes:{from:a+l,to:a+l+s.length,insert:t}})}}]}return r})},{delay:200}),xb=Object.keys(hh),xv=xb.map(e=>({label:e,type:"namespace",apply:`${e}.`})),xy=[...h0.map(e=>{let[t,s]=e;return{label:t,type:"function",detail:xn[s],apply:`${t}${xn[s]}`}}),...hW.map(e=>({label:e,type:"keyword",detail:"conditional"})),...[...new Set([...hB,...hK,...hH,...hG])].map(e=>({label:e,type:"method"})),...hZ.map(e=>({label:e,type:"operator",detail:"comparator",apply:`${e}::`}))],xj=/^[A-Za-z]*$/,xw=(0,pM.yU)({override:[function(e){let t=e.state.doc.sliceString(0,e.pos),s=t.lastIndexOf("{");if(s<0||t.lastIndexOf("}")>s)return null;let a=t.slice(s),r=/::([A-Za-z]*)$/.exec(a);if(r)return{from:e.pos-r[1].length,options:xy,validFor:xj};let n=/([A-Za-z]+)\.([A-Za-z]*)$/.exec(a);if(n){var l;let t,s=(l=n[1],(t=xb.find(e=>e.toLowerCase()===l.toLowerCase()))?hh[t].map(e=>({label:e,type:"property"})):[]);if(s.length)return{from:e.pos-n[2].length,options:s,validFor:xj}}let i=/\{\s*([A-Za-z]*)$/.exec(a);return i?{from:e.pos-i[1].length,options:xv,validFor:xj}:null}],icons:!1});function xN(e){let{value:t,onValueChange:s,placeholder:a,disabled:l,className:i,initialHeight:o="11rem",minHeight:d="6rem",onFocusView:c,onViewReady:u}=e,m=(0,n.useRef)(null),p=(0,n.useRef)(c);p.current=c;let h=(0,n.useMemo)(()=>[xx,xf,xw,pk.Lz.lineWrapping,(0,pS.qf)(a??""),pk.Lz.domEventHandlers({focus:(e,t)=>{var s;return null==(s=p.current)||s.call(p,t),!1}})],[a]);return(0,r.jsx)("div",{style:{height:o,minHeight:d},className:b("w-full rounded-[--radius] border border-[--border] bg-[--paper] shadow-sm overflow-hidden transition","resize-y","focus-within:ring-1 focus-within:ring-[--ring] focus-within:border-brand",l&&"opacity-60 pointer-events-none",i),children:(0,r.jsx)(pk.Ay,{ref:m,className:"h-full",value:t,onChange:s,onCreateEditor:e=>null==u?void 0:u(e),editable:!l,theme:pC,indentWithTab:!1,height:"100%",basicSetup:{lineNumbers:!1,foldGutter:!1,highlightActiveLine:!1,highlightActiveLineGutter:!1,autocompletion:!1,bracketMatching:!0,closeBrackets:!0,searchKeymap:!1,highlightSelectionMatches:!1,indentOnInput:!1,drawSelection:!1},extensions:h})})}function xk(e){let{onInsert:t}=e,s=tw(!1);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(w,{intent:"white",size:"sm",onClick:s.open,children:"Snippets"}),(0,r.jsx)(ty,{open:s.isOpen,onOpenChange:s.close,title:"Formatter Snippets",children:(0,r.jsx)("div",{className:"space-y-4",children:sX.map((e,a)=>(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between border rounded-md p-3 bg-gray-900 border-gray-800 gap-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"font-semibold text-base mb-1",children:e.name}),(0,r.jsx)("div",{className:"text-sm text-muted-foreground mb-1 break-words",children:e.description}),(0,r.jsx)("div",{className:"font-mono text-xs bg-gray-800 rounded px-2 py-1 inline-block break-all",children:e.value})]}),(0,r.jsxs)("div",{className:"flex gap-2 sm:ml-4 flex-shrink-0",children:[t&&(0,r.jsx)(w,{size:"sm",intent:"primary",onClick:()=>{t(e.value)?(x.oR.success("Snippet inserted"),s.close()):x.oR.message("Click into a template first")},title:"Insert at cursor",children:(0,r.jsx)(cx.A,{className:"w-5 h-5"})}),(0,r.jsx)(w,{size:"sm",intent:"primary-outline",onClick:async()=>{await rm(e.value,{onSuccess:()=>x.oR.success("Snippet copied to clipboard"),onError:()=>x.oR.error("Failed to copy snippet to clipboard")})},title:"Copy snippet",children:(0,r.jsx)(pB.A,{className:"w-5 h-5"})})]})]},a))})})]})}function xS(e){let{name:t,onLoad:s,onRename:a,onDelete:l}
63=e,[i,o]=(0,n.useState)(!1),[d,c]=(0,n.useState)(t),u=tN({title:"Delete formatter",description:(0,r.jsxs)("span",{className:"break-all",children:["Are you sure you want to delete “",t,"”?"]}),actionText:"Delete",actionIntent:"alert-subtle",onConfirm:()=>l(t)});n.useEffect(()=>{c(t)},[t]);let m=()=>{let e=d.trim();e&&e!==t?a(t,e):c(t),o(!1)},p=()=>{c(t),o(!1)};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(tk,{...u}),(0,r.jsx)("div",{className:"flex items-center gap-2 overflow-hidden rounded-lg border border-gray-700 bg-gray-800/30 px-3 py-2.5 group/item",children:i?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(W,{value:d,onValueChange:c,autoFocus:!0,className:"flex-1 min-w-0 text-sm",onKeyDown:e=>{"Enter"===e.key&&m(),"Escape"===e.key&&p()}}),(0,r.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"sm",rounded:!0,intent:"primary-subtle",icon:(0,r.jsx)(J.sk9,{className:"h-3.5 w-3.5"}),onClick:m}),children:"Confirm rename"}),(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"sm",rounded:!0,intent:"gray-subtle",icon:(0,r.jsx)(J.SXS,{className:"h-3.5 w-3.5"}),onClick:p}),children:"Cancel"})]})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"flex-1 min-w-0 overflow-hidden",children:(0,r.jsx)(to,{trigger:(0,r.jsx)("span",{className:"truncate text-sm cursor-default",children:t}),children:t})}),(0,r.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"sm",rounded:!0,intent:"gray-subtle",icon:(0,r.jsx)(J.H6t,{className:"h-3.5 w-3.5"}),onClick:()=>o(!0),className:"opacity-0 group-hover/item:opacity-100 transition-opacity"}),children:"Rename"}),(0,r.jsx)(w,{size:"sm",intent:"primary-subtle",onClick:()=>s(t),children:"Load"}),(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"sm",rounded:!0,intent:"alert-subtle",icon:(0,r.jsx)(cb.H8h,{}),onClick:u.open}),children:"Delete"})]})]})})]})}function xC(e){let{open:t,onOpenChange:s,canSaveCurrent:a,savedDefinitions:l,onSave:i,onLoad:o,onRename:d,onDelete:c}=e,[u,m]=(0,n.useState)(""),p=(0,n.useMemo)(()=>Object.entries(l).sort((e,t)=>{let[s]=e,[a]=t;return s.localeCompare(a)}),[l]);n.useEffect(()=>{t||m("")},[t]);let h=()=>{u.trim()&&(i(u),m(""))};return(0,r.jsx)(ty,{open:t,onOpenChange:s,title:"Saved Formatters",description:"Save your current formatter or load a previously saved one",children:(0,r.jsxs)("div",{className:"space-y-4 w-full min-w-0",children:[(0,r.jsxs)("div",{className:"rounded-lg border border-gray-700/60 bg-gray-800/20 p-3 space-y-3",children:[(0,r.jsx)("p",{className:"text-xs font-medium text-gray-400 uppercase tracking-wide",children:"Save current"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(W,{value:u,onValueChange:m,placeholder:"Name for this formatter",disabled:!a,className:"flex-1 text-sm",onKeyDown:e=>{"Enter"===e.key&&a&&h()}}),(0,r.jsx)(w,{intent:"primary",disabled:!a||!u.trim(),onClick:h,className:"shrink-0",children:"Save"})]}),!a&&(0,r.jsx)("p",{className:"text-xs text-gray-500",children:"Customise a built-in formatter or switch to Custom first."})]}),(0,r.jsx)("div",{className:"space-y-2 max-h-72 overflow-y-auto overflow-x-hidden -mx-1 px-1",children:0===p.length?(0,r.jsx)("p",{className:"text-sm text-gray-500 text-center py-4",children:"No saved formatters yet."}):p.map(e=>{let[t]=e;return(0,r.jsx)(xS,{name:t,onLoad:o,onRename:d,onDelete:c},t)})})]})})}var x_=s(8170),xR=s(1460),xA=s(757),xT=s(5611),xI=s(7216);function xE(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:44,s=e.replace(/\s+/g," ").trim();return s.length>t?`${s.slice(0,t-1)}…`:s}let xM={expression:(0,r.jsx)(x_.A,{className:"w-3.5 h-3.5 text-[--sky]"}),group:(0,r.jsx)(xR.A,{className:"w-3.5 h-3.5 text-[--violet]"}),branch:(0,r.jsx)(xA.A,{className:"w-3.5 h-3.5 text-[--amber]"}),tool:(0,r.jsx)(xT.A,{className:"w-3.5 h-3.5 text-[--teal]"})};function xP(e){let{item:t,depth:s,onJump:a}=e,[l,i]=(0,n.useState)(s<2),o=t.children.length>0;return(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 rounded px-1 py-0.5 hover:bg-[--subtle] cursor-pointer text-xs",style:{paddingLeft:`${12*s+4}px`},children:[o?(0,r.jsx)("button",{type:"button",onClick:()=>i(e=>!e),className:"shrink-0 text-[--muted] hover:text-[--foreground]",children:l?(0,r.jsx)(dp.A,{className:"w-3.5 h-3.5"}):(0,r.jsx)(xI.A,{className:"w-3.5 h-3.5"})}):(0,r.jsx)("span",{className:"w-3.5 shrink-0"}),xM[t.kind],(0,r.jsx)("button",{type:"button",onClick:()=>a(t),className:"min-w-0 truncate font-mono text-left text-[--muted-highlight] hover:text-[--foreground]",title:"Jump to this part of the template",children:t.label})]}),o&&l&&(0,r.jsx)("div",{children:t.children.map((e,t)=>(0,r.jsx)(xP,{item:e,depth:s+1,onJump:a},t))})]})}function xD(e){let{template:t,getView:s}
63=e,[a,l]=(0,n.useState)(!1),i=(0,n.useMemo)(()=>(function e(t,s){let a=[];for(let r of t){if("raw"===r.kind)continue;let t=(r.start??0)+s,n=(r.end??0)+s;if("tool"===r.kind)a.push({label:`{tools.${r.tool}}`,from:t,to:n,kind:"tool",children:[]});else if("group"===r.kind)a.push({label:"optional group",from:t,to:n,kind:"group",children:e(r.nodes,s)});else if("expression"===r.kind){let s=[];if(r.check)for(let[t,a,n]of[["true",r.check.trueTemplate,r.check.trueStart],["false",r.check.falseTemplate,r.check.falseStart],["absent",r.check.absentTemplate,r.check.absentStart]])void 0!==a&&void 0!==n&&s.push({label:`${t}: "${xE(a,28)}"`,from:n,to:n+a.length,kind:"branch",children:e(xr(a).nodes,n)});a.push({label:xE(r.source),from:t,to:n,kind:"expression",children:s})}}return a})(xr(t).nodes,0),[t]),o=e=>{let t=s();if(!t)return;let a=t.state.doc.length;t.dispatch({selection:{anchor:Math.min(e.from,a),head:Math.min(e.to,a)},scrollIntoView:!0}),t.focus()};return 0===i.length?null:(0,r.jsxs)("div",{className:"mt-1.5",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>l(e=>!e),className:"flex items-center gap-1 text-xs text-[--muted] hover:text-[--foreground]",children:[a?(0,r.jsx)(dp.A,{className:"w-3.5 h-3.5"}):(0,r.jsx)(xI.A,{className:"w-3.5 h-3.5"}),"Structure (",i.length,")"]}),a&&(0,r.jsx)("div",{className:"mt-1 max-h-56 overflow-y-auto rounded-md border border-[--border] bg-[--subtle] p-1",children:i.map((e,t)=>(0,r.jsx)(xP,{item:e,depth:0,onJump:o},t))})]})}function xL(e){var t,s,a;let r=e.formatter.id,n=e.formatter.definitions;if(r===st)return{name:(null==n||null==(s=n.custom)?void 0:s.name)??"",description:(null==n||null==(a=n.custom)?void 0:a.description)??""};let l=null==n||null==(t=n.overrides)?void 0:t[r];if(l)return{name:l.name,description:l.description};let i=hp[r];return{name:(null==i?void 0:i.name)??"",description:(null==i?void 0:i.description)??""}}let xU="aiostreams:formatter-simple-editor";function x$(){try{return"1"===localStorage.getItem(xU)}catch{return!1}}let xO=Object.values({[t6]:{id:t6,name:"Google Drive",description:"Uses the formatting from the Stremio GDrive addon"},[t7]:{id:t7,name:"Prism",description:"An aesthetic formatter with every detail within 5 lines."},[se]:{id:se,name:"Tamtaro",description:"From Tamtaro's setup. Smartly detects status for cached (⚡/⏳), proxied (⛊/⛉), library (☁︎/✎), season packs (❖/◈) and HDR/DV (✦/✧). The last line in sᴍᴀʟʟ ᴄᴀᴘs displays your preferred language options, Usenet's health (☑ ɴᴢʙ), SeaDex (ᴀʟᴛ/ʙᴇsᴛ ʀᴇʟᴇᴀsᴇ), networks, special editions and attributes via ranked stream expressions."},[t5]:{id:t5,name:"Light Google Drive",description:"A lighter version of the GDrive formatter, focused on asthetics"},[t4]:{id:t4,name:"Minimalistic",description:"A minimalistic formatter which shows only the bare minimum"},[t9]:{id:t9,name:"Torrentio",description:"Uses the formatting from the Torrentio addon"},[t8]:{id:t8,name:"Torbox",description:"Uses the formatting from the TorBox Stremio addon"},[st]:{id:st,name:"Custom",description:"Define your own formatter"}});function xF(e,t,s){var a;let r=e.formatter.id;if(r===st)return{...e,formatter:{...e.formatter,definitions:{...e.formatter.definitions,custom:{
63name:t,description:s}}}};let n=hp[r],l=!!n&&t===n.name&&s===n.description,i={...(null==(a=e.formatter.definitions)?void 0:a.overrides)??{}};return l?delete i[r]:i[r]={name:t,description:s},{...e,formatter:{...e.formatter,definitions:{...e.formatter.definitions,overrides:Object.keys(i).length>0?i:void 0}}}}function xz(){var e,t;let{userData:s,setUserData:a}=s4(),l=tw(!1),i=tw(!1),o=(0,n.useRef)(null),d=(0,n.useRef)(null),c=(0,n.useRef)(null),[u,m]=(0,n.useState)(x$);function p(e,t,s,a){return u?(0,r.jsx)(np,{value:e,onValueChange:t,placeholder:s}):(0,r.jsx)(xN,{value:e,onValueChange:t,placeholder:s,onViewReady:e=>a.current=e,onFocusView:e=>c.current=e})}(0,n.useEffect)(()=>{try{localStorage.setItem(xU,u?"1":"0")}catch{}},[u]);let h=s.formatter.id,g=s.formatter.definitions,{name:f,description:b}=xL(s),v=h!==st&&!!(null==g||null==(e=g.overrides)?void 0:e[h]),y=(null==g?void 0:g.saved)??{},j=h===st||!!hp[h];return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(cr,{title:"Formatter Selection",id:"formatter",description:"Choose how your streams should be formatted",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,r.jsx)("div",{className:"flex-1 min-w-0",children:(0,r.jsx)(rn,{value:h,onValueChange:function(e){a(t=>{var s;if(e===st&&!(null==(s=t.formatter.definitions)?void 0:s.custom)){let{name:s,description:a}=xL(t);return{...t,formatter:{...t.formatter,id:e,definitions:{...t.formatter.definitions,custom:{
63name:s,description:a}}}}}return{...t,formatter:{...t.formatter,id:e}}})},options:xO.map(e=>({label:e.name,value:e.id}))})}),h!==st&&(0,r.jsx)("span",{className:`text-xs font-medium px-2 py-0.5 rounded-full border flex-shrink-0 min-w-[7.75rem] text-center ${v?"bg-yellow-500/20 text-yellow-400 border-yellow-500/30":"bg-green-500/20 text-green-400 border-green-500/30"}`,children:v?"Customised":"Using built-in"})]}),h!==st&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground mt-2",children:null==(t=xO.find(e=>e.id===h))?void 0:t.description}),j&&(0,r.jsxs)("div",{className:"space-y-4 mt-4",children:[(0,r.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,r.jsxs)("div",{className:"text-sm text-gray-400",children:["Type ",(0,r.jsx)("span",{className:"font-mono",children:"{debug.jsonf}"})," to see all available variables. See the"," ",(0,r.jsx)("a",{href:"https://docs.aiostreams.viren070.me/reference/custom-formatter",target:"_blank",rel:"noopener noreferrer",className:"text-[--brand] hover:text-[--brand]/80 hover:underline",children:"docs"})," ","for a full reference."]}),(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{rounded:!0,size:"sm",intent:"primary-subtle",className:"shrink-0",icon:u?(0,r.jsx)(pH.A,{className:"w-4 h-4"}):(0,r.jsx)(hm.A,{className:"w-4 h-4"}),onClick:()=>m(e=>!e)}),children:u?"Switch to the rich editor":"Switch to a plain textarea"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-sm font-medium mb-2 block",children:"Name Template"}),p(f,e=>a(t=>xF(t,e,xL(t).description)),"Enter a template for the stream name",o),!u&&(0,r.jsx)(xD,{template:f,getView:()=>o.current})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-sm font-medium mb-2 block",children:"Description Template"}),p(b,e=>a(t=>xF(t,xL(t).name,e)),"Enter a template for the stream description",d),!u&&(0,r.jsx)(xD,{template:b,getView:()=>d.current})]}),(0,r.jsxs)("div",{className:"flex gap-2 items-center flex-wrap",children:[(0,r.jsx)(xk,{onInsert:u?void 0:function(e){let t=c.current;return!!t&&(t.dispatch(t.state.replaceSelection(e)),t.focus(),!0)}}),v&&(0,r.jsx)(w,{intent:"white",size:"sm",onClick:function(){a(e=>{var t;let s=e.formatter.id,a={...(null==(t=e.formatter.definitions)?void 0:t.overrides)??{}};return delete a[s],{...e,formatter:{...e.formatter,definitions:{...e.formatter.definitions,overrides:Object.keys(a).length>0?a:void 0}}}})},children:"Reset to built-in"}),(0,r.jsxs)("div",{className:"ml-auto flex gap-2",children:[(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{rounded:!0,size:"sm",intent:"primary-subtle",icon:(0,r.jsx)(cb.dIn,{}),onClick:i.open}),children:"Saved formatters"}),(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{rounded:!0,size:"sm",intent:"primary-subtle",icon:(0,r.jsx)(cb.PiR,{}),onClick:l.open}),children:"Import"}),(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{rounded:!0,size:"sm",intent:"primary-subtle",icon:(0,r.jsx)(cb.Mbn,{}),onClick:function(){let e=new Blob([JSON.stringify({name:f,description:b},null,2)],{type:"application/json"}),t=URL.createObjectURL(e),s=document.createElement("a");s.href=t,s.download="formatter.json",document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(t),x.oR.success("Formatter exported successfully")}}),children:"Export"})]})]})]})]}),(0,r.jsx)(uq,{open:l.isOpen,onOpenChange:l.toggle,onImport:function(e){"string"==typeof e.name&&"string"==typeof e.description?(a(t=>xF(t,e.name,e.description)),x.oR.success("Formatter imported successfully")):x.oR.error("Invalid formatter format")}}),(0,r.jsx)(xC,{open:i.isOpen,onOpenChange:i.toggle,canSaveCurrent:h===st||v,savedDefinitions:y,onSave:function(e){let t=e.trim();t?(a(e=>{var s;let{name:a,description:r}=xL(e);return{...e,formatter:{...e.formatter,definitions:{...e.formatter.definitions,saved:{...(null==(s=e.formatter.definitions)?void 0:s.saved)??{},[t]:{name:a,description:r}}}}}}),x.oR.success("Formatter saved")):x.oR.error("Please enter a name")},onLoad:function(e){a(t=>{var s,a;let r=null==(a=t.formatter.definitions)||null==(s=a.saved)?void 0:s[e];return r?xF(t,r.name,r.description):t}),x.oR.success(`Loaded "${e}"`)},onRename:function(e,t){let s=t.trim();if(!s)return void x.oR.error("Name cannot be empty");if(s!==e){if(y[s])return void x.oR.error("A saved formatter with this name already exists");a(t=>{var a;let r=(null==(a=t.formatter.definitions)?void 0:a.saved)??{};if(!r[e])return t;let n=Object.entries(r).map(t=>{let[a,r]=t;return a===e?[s,r]:[a,r]});return{...t,formatter:{...t.formatter,definitions:{...t.formatter.definitions,saved:Object.fromEntries(n)}}}}),x.oR.success("Saved formatter renamed")}},onDelete:function(e){a(t=>{var s;let a={...(null==(s=t.formatter.definitions)?void 0:s.saved)??{}};return a[e]?(delete a[e],{...t,formatter:{...t.formatter,definitions:{...t.formatter.definitions,saved:Object.keys(a).length>0?a:void 0}}}):t}),x.oR.success("Saved formatter deleted")}})]})}var xV=s(7090),xq=s(7198),xB=s(8498),xK=s(8749),xH=s(5227);class xG{enqueue(e){this.queue=[e],this.process()}async process(){if(!this.processing){for(this.processing=!0;this.queue.length>0;){let e=this.queue.shift();if(e){try{await e()}catch(e){console.error("Error in format queue:",e)}await new Promise(e=>setTimeout(e,this.delay))}}this.processing=!1}}constructor(e){(0,en._)(this,"queue",[]),(0,en._)(this,"processing",!1),(0,en._)(this,"delay",void 0),this.delay=e}}let xW=(0,n.createContext)({used:new Set,onlyUsed:!1});function xY(e){let{used:t,onlyUsed:s,children:a}=e,l=(0,n.useMemo)(()=>({used:t,onlyUsed:s}),[t,s]);return(0,r.jsx)(xW.Provider,{value:l,children:a})}function xJ(e){return"string"==typeof e?[e]:e}function xZ(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],{used:s,onlyUsed:a}=(0,n.useContext)(xW),r=xJ(e).some(e=>s.has(e));return{isUsed:r,visible:t||r||!a}}function xQ(e){let{label:t,field:s,isUsed:a}=e,n=xJ(s);return(0,r.jsxs)("span",{className:"flex items-center gap-1.5 min-w-0",children:[(0,r.jsx)("span",{className:"truncate",children:t}),a&&(0,r.jsx)("span",{className:"shrink-0 w-1.5 h-1.5 rounded-full bg-[--brand]",title:`Used by your template (${n.join(", ")})`})]})}
63function xX(e){let{cols:t=3,children:s}=e;return(0,r.jsx)("div",{className:b("grid grid-cols-1 gap-4",{2:"sm:grid-cols-2",3:"sm:grid-cols-3",4:"sm:grid-cols-4"}[t]),children:s})}function x0(e){let{children:t}=e;return(0,r.jsx)("div",{className:"flex flex-wrap justify-center gap-x-6 gap-y-3 pt-1",children:t})}function x1(e){let{fields:t,children:s}=e,[a,l]=(0,n.useState)(""),i=function(e){let{used:t,onlyUsed:s}=(0,n.useContext)(xW);return s?e.filter(e=>xJ(e).some(e=>t.has(e))).length:e.length}(t);return 0===i?null:(0,r.jsx)(dM,{type:"single",collapsible:!0,value:a,onValueChange:l,className:"pt-1",children:(0,r.jsxs)(dP,{value:"advanced",className:"border border-[--border] rounded-[--radius-md] overflow-hidden",children:[(0,r.jsxs)(dD,{className:"py-2 text-sm text-[--muted-highlight]",children:["Advanced (",i,")"]}),(0,r.jsx)(dL,{className:"space-y-4",children:s})]})})}function x2(e){let{children:t}=e;return(0,r.jsx)("p",{className:"text-xs text-[--muted]",children:t})}function x3(e){let{field:t,label:s,help:a,disabled:n,always:l,value:i,onChange:o,placeholder:d,error:c}=e,{visible:u,isUsed:m}=xZ(t,l);return u?(0,r.jsx)(W,{label:(0,r.jsx)(xQ,{label:s,field:t,isUsed:m}),moreHelp:a,error:c,disabled:n,value:i,placeholder:d,onValueChange:e=>o(e??""),className:"w-full"}):null}function x6(e){let{field:t,label:s,help:a,disabled:n,value:l,onChange:i,min:o,max:d,step:c,placeholder:u}=e,{visible:m,isUsed:p}=xZ(t);return m?(0,r.jsx)(nn,{label:(0,r.jsx)(xQ,{label:s,field:t,isUsed:p}),moreHelp:a,disabled:n,allowEmpty:!0,value:l??"",placeholder:u,min:o,max:d,step:c,onValueChange:(e,t)=>
63i(""===t||Number.isNaN(e)?void 0:e),className:"w-full"}):null}function x5(e){let{field:t,label:s,help:a,disabled:n,value:l,onChange:i,options:o}=e,{visible:d,isUsed:c}=xZ(t);return d?(0,r.jsx)(rn,{label:(0,r.jsx)(xQ,{label:s,field:t,isUsed:c}),moreHelp:a,disabled:n,value:l,options:o,onValueChange:i,className:"w-full"}):null}function x4(e){let{field:t,label:s,help:a,disabled:n,value:l,onChange:i}=e,{visible:o,isUsed:d}=xZ(t);return o?(0,r.jsx)(rs,{label:(0,r.jsx)(xQ,{label:s,field:t,isUsed:d}),moreHelp:a,disabled:n,value:l,onValueChange:i}):null}function x9(e){let{field:t,label:s,help:a,disabled:n,value:l,onChange:i,placeholder:o}=e;return(0,r.jsx)(x3,{field:t,label:s,help:a??"Comma separated",disabled:n,value:l,onChange:i,placeholder:o})}let x8=e=>RegExp(`(?<![^\\s\\[(_\\-.,])(${e})(?=[\\s\\)\\]_.\\-,]|$)`,"i"),x7=e=>x8(`${e}(?![ .\\-_]?sub(title)?s?)`),ge={resolutions:{"2160p":x8("(bd|hd|m)?(4k|2160(p|i)?)|u(ltra)?[ .\\-_]?hd|3840\\s?x\\s?(\\d{4})"),"1440p":x8("(bd|hd|m)?(1440(p|i)?)|2k|w?q(uad)?[ .\\-_]?hd|2560\\s?x(\\d{4})"),"1080p":x8("(bd|hd|m)?(1080(p|i)?)|f(ull)?[ .\\-_]?hd|1920\\s?x\\s?(\\d{3,4})"),"720p":x8("(bd|hd|m)?((720|800)(p|i)?)|hd|1280\\s?x\\s?(\\d{3,4})"),"576p":x8("(bd|hd|m)?((576|534)(p|i)?)"),"480p":x8("(bd|hd|m)?(480(p|i)?)|sd"),"360p":x8("(bd|hd|m)?(360(p|i)?)"),"240p":x8("(bd|hd|m)?(240(p|i)?)"),"144p":x8("(bd|hd|m)?(144(p|i)?)")},qualities:{"BluRay REMUX":x8("(?<!dvd.*)(bd|br|b|uhd)?remux(?!.*dvd)"),BluRay:x8("(?<!remux.*)((bd|blu[ .\\-_]?ray)([ .\\-_]?rip)?|br[ .\\-_]?rip)(?!.*remux)"),"WEB-DL":x8("web[ .\\-_]?(dl)?(?![ .\\-_]?(rip|DLRip|cam))"),WEBRip:x8("web[ .\\-_]?rip"),HDRip:x8("hd[ .\\-_]?rip|web[ .\\-_]?dl[ .\\-_]?rip"),"HC HD-Rip":x8("hc|hd[ .\\-_]?rip"),"DVD REMUX":x8("(hd[ .\\-_]?)?dvd.*remux|remux.*(hd[ .\\-_]?)?dvd"),DVDRip:x8("dvd[ .\\-_]?(rip|mux|r|full|5|9)?"),HDTV:x8("(hd|pd)tv|tv[ .\\-_]?rip|hdtv[ .\\-_]?rip|dsr(ip)?|sat[ .\\-_]?rip"),CAM:x8("cam|hdcam|cam[ .\\-_]?rip"),TS:x8("telesync|ts|hd[ .\\-_]?ts|pdvd|predvd(rip)?"),TC:x8("telecine|tc|hd[ .\\-_]?tc"),SCR:x8("((dvd|bd|web|hd)?[ .\\-_]?)?(scr(eener)?)")},visualTags:{"10bit":x8("10[ .\\-_]?bit|hi10p?"),"HDR10+":x8("hdr[ .\\-_]?10[ .\\-_]?(p(lus)?|[+])"),HDR10:x8("hdr[ .\\-_]?10(?![ .\\-_]?(?:\\+|p(?:lus)?|bit|hi))"),HDR:x8("hdr(?![ .\\-_]?(?:10(?![ .\\-_]?(?:bit|hi))|\\+|p(?:lus)?))"),HLG:x8("hlg"),DV:x8("do?(lby)?[ .\\-_]?vi?(sion)?(?:[ .\\-_]?atmos)?|dv"),"3D":x8("(bd)?(3|three)[ .\\-_]?(d(imension)?(al)?)"),IMAX:x8("imax"),AI:x8("ai|ai(enhanced?|re[ .\\-_]?graded?)"),Upscaled:x8("(ai)?(uprez|ups(uhd|cal(ed?|ing)(uhd)?))(ai)?"),SDR:x8("sdr"),"H-OU":x8("h?(alf)?[ .\\-_]?(ou|over[ .\\-_]?under)"),"H-SBS":x8("h?(alf)?[ .\\-_]?(sbs|side[ .\\-_]?by[ .\\-_]?side)")},audioTags:{Atmos:x8("atmos|ddpa\\d?"),"DD+":x8("(d(olby)?[ .\\-_]?d(igital)?[ .\\-_]?((p(lus)?|\\+)a?)(?:[ .\\-_]?(2[ .\\-_]?0|5[ .\\-_]?1|7[ .\\-_]?1))?)|e[ .\\-_]?ac[ .\\-_]?3"),DD:x8("(d(olby)?[ .\\-_]?d(igital)?(?:[ .\\-_]?(5[ .\\-_]?1|7[ .\\-_]?1|2[ .\\-_]?0?))?)|(?<!e[ .\\-_]?)ac[ .\\-_]?3"),"DTS:X":x8("dts[ .\\-:_]?x"),"DTS-HD MA":x8("dts[ .\\-_]?hd[ .\\-_]?ma"),"DTS-HD":x8("dts[ .\\-_]?hd(?![ .\\-_]?ma)"),"DTS-ES":x8("dts[ .\\-_]?es"),DTS:x8("dts(?![ .\\-:_]?(x(?=[\\s\\)\\]_.\\-,]|$)|hd[ .\\-_]?(ma)?|es))"),TrueHD:x8("true[ .\\-_]?hd"),OPUS:x8("opus"),AAC:x8("q?aac(?:[ .\\-_]?2)?"),FLAC:x8("flac(?:[ .\\-_]?(lossless|2\\.0|x[2-4]))?")},audioChannels:{"2.0":x8("(d(olby)?[ .\\-_]?d(igital)?)?2[ .\\-_]?0(ch)?"),"5.1":x8("(d(olby)?[ .\\-_]?d(igital)?[ .\\-_]?((p(lus)?|\\+)a?)?)?5[ .\\-_]?1(ch)?"),"6.1":x8("(d(olby)?[ .\\-_]?d(igital)?[ .\\-_]?((p(lus)?|\\+)a?)?)?6[ .\\-_]?1(ch)?"),"7.1":x8("(d(olby)?[ .\\-_]?d(igital)?[ .\\-_]?((p(lus)?|\\+)a?)?)?7[ .\\-_]?1(ch)?")},encodes:{HEVC:x8("hevc[ .\\-_]?(10)?|[xh][ .\\-_]?265"),AVC:x8("avc|[xh][ .\\-_]?264"),AV1:x8("av1"),"VC-1":x8("vc[ .\\-_]?1"),XviD:x8("xvid"),DivX:x8("divx|dvix")},languages:{Multi:x7("multi"),"Dual Audio":x7("dual[ .\\-_]?(audio|lang(uage)?|flac|ac3|aac2?)"),Dubbed:x7("dub(s|bed|bing)?"),English:x7("english|eng"),Japanese:x7("japanese|jap|jpn"),Chinese:x7("chinese|chi"),Russian:x7("russian|rus"),Arabic:x7("arabic|ara"),Portuguese:x7("portuguese"),"Portuguese (Brazil)":x7("portuguese[ .\\-_]?brazil|pt[ .\\-_]?br"),Spanish:x7("spanish|spa|esp"),French:x7("french|fra|fr|vf|vff|vfi|vf2|vfq|truefrench"),German:x7("deu(tsch)?(land)?|ger(man)?"),Italian:x7("italian|ita"),Korean:x7("korean|kor"),Hindi:x7("hindi|hin"),Bengali:x7("bengali|ben(?![ .\\-_]?the[ .\\-_]?men)"),Punjabi:x7("punjabi|pan"),Marathi:x7("marathi|mar"),Gujarati:x7("gujarati|guj"),Tamil:x7("tamil|tam"),Telugu:x7("telugu|tel"),Kannada:x7("kannada|kan"),Malayalam:x7("malayalam|mal"),Thai:x7("thai|tha"),Vietnamese:x7("vietnamese|vie"),Indonesian:x7("indonesian|ind"),Turkish:x7("turkish|tur"),Hebrew:x7("hebrew|heb"),Persian:x7("persian|per"),Ukrainian:x7("ukrainian|ukr"),Greek:x7("greek|ell"),Lithuanian:x7("lithuanian|lit"),Latvian:x7("latvian|lav"),Estonian:x7("estonian|est"),Polish:x7("polish|pol"),Czech:x7("czech|cze"),Slovak:x7("slovak|slo"),Hungarian:x7("hungarian|hun"),Romanian:x7("romanian|rum"),Bulgarian:x7("bulgarian|bul"),Serbian:x7("serbian|srp"),Croatian:x7("croatian|hrv"),Slovenian:x7("slovenian|slv"),Dutch:x7("dutch|dut"),Danish:x7("danish|dan"),Finnish:x7("finnish|fin"),Swedish:x7("swedish|swe"),Norwegian:x7("norwegian|nor"),Malay:x7("malay"),Latino:x7("latino|lat")},releaseGroup:/-[. ]?(?!\d+$|S\d+|\d+x|ep?\d+|[^[]+]$)([^\-. []+[^\-. [)\]\d][^\-. [)\]]*)(?:\[[\w.-]+])?(?=\)|[.-]+\w{2,4}$|$)/i};var gt=s(9721);let gs=new Map;function ga(e,t){var s;return null==(s=Object.entries(t).find(t=>{let[s,a]=t;return a.test(e)}))?void 0:s[0]}function gr(e,t){return Object.entries(t).filter(t=>{let[s,a]=t;return a.test(e)}).map(e=>{let[t]=e;return t})}let gn=class{static parse(e){var t,s,a,r;let n=function(e){let t=gs.get(e);if(void 0!==t)return gs.delete(e),gs.set(e,t),t;let s=(0,gt.OI)(e);if(gs.size>=1e4){let e=gs.keys().next().value;void 0!==e&&gs.delete(e)}return gs.set(e,s),s}(e),l=n.title;if(["vinland","furiosaamadmax","horizonanamerican"].includes((l||"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\p{L}\p{N}+]/gu,"").toLowerCase())&&n.complete&&(l=`${l} Saga`),l&&l.length>
634){let t=RegExp(l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/ /g,"[._ ]"),"i");e=(e=e.replace(t,"").trim()).replace(/\s+/g,".").replace(/^\.+|\.+$/g,"")}let i=function(e){if(!e)return;let t=e.toLowerCase();if("4k"===t)return"2160p";if(sL.includes(t))return t;let s=t.match(/^(\d+)p$/);if(s){let e=parseInt(s[1],10);return sL.filter(e=>"Unknown"!==e).map(e=>[e,parseInt(e,10)]).reduce((t,s)=>Math.abs(s[1]-e)<Math.abs(t[1]-e)?s:t)[0]}}(n.resolution)||ga(e,ge.resolutions),o=ga(e,ge.qualities),d=ga(e,ge.encodes),c=gr(e,ge.audioChannels),u=gr(e,ge.visualTags),m=gr(e,ge.audioTags),p=e;(null==(t=n.group)?void 0:t.toLowerCase())==="ind"&&(p=p.replace(/ind/i,""));let h=[...new Set([...gr(p,ge.languages),...(n.languages||[]).map(e=>{switch(e.toLowerCase()){case"multi audio":return"Multi";case"dual audio":return"Dual Audio";case"multi subs":return;default:return function(e){let t=e.split("-"),s=hw.filter(e=>{var s,a,r;return 2===t.length?(null==(a=e.iso_639_1)?void 0:a.toLowerCase())===t[0].toLowerCase()&&(null==(r=e.iso_3166_1)?void 0:r.toLowerCase())===t[1].toLowerCase():(null==(s=e.iso_639_1)?void 0:s.toLowerCase())===t[0].toLowerCase()}),a=s.find(e=>e.flag_priority)||s[0];if(!a)return;let r=hN(a);return sQ.includes(r)?r:void 0}(hI(e))}}).filter(e=>!!e)])],x=(null==(s=e.match(ge.releaseGroup))?void 0:s[1])??n.group,g=l,f=n.year?n.year.toString():void 0;return{resolution:i,quality:o,languages:h,subtitles:[],encode:d,audioChannels:c,audioTags:m,visualTags:u,releaseGroup:x,title:g,year:f,country:n.country,episodeTitle:n.episodeTitle,subbed:n.subbed??!1,dubbed:n.dubbed??!1,editions:n.editions,regraded:n.regraded??!1,repack:n.repack??!1,proper:n.proper??!1,uncensored:n.uncensored??!1,unrated:n.unrated??!1,upscaled:n.upscaled??!1,network:n.network,container:n.container,extension:n.extension,seasons:n.seasons,volumes:n.volumes,episodes:n.episodes,date:n.date,seasonPack:!!((null==(a=n.seasons)?void 0:a.length)&&!(null==(r=n.episodes)?void 0:r.length))}}};function gl(e,t){return Array.from(new Set([...e??[],...t??[]]))}let gi={type:sK,isAnime:!1,title:"Sample Movie",titles:"Sample Movie, Sample Movie Alt Title",year:2024,yearEnd:void 0,season:void 0,episode:void 0,episodeTitles:"",genres:"Action, Thriller",runtime:120,episodeRuntime:void 0,absoluteEpisode:void 0,relativeAbsoluteEpisode:void 0,originalLanguage:"English",country:"US",latestSeason:void 0,daysSinceRelease:30,daysSinceFirstAired:void 0,daysSinceLastAired:void 0,hasNextEpisode:!1,daysUntilNextEpisode:void 0,anilistId:void 0,malId:void 0,hasSeaDex:!1},go={scenario:"movie",filename:"Movie.Title.2023.2160p.BluRay.HEVC.DV.TrueHD.Atmos.7.1.iTA.ENG-GROUP.mkv",folderName:"Movie.Title.2023.2160p.BluRay.HEVC.DV.TrueHD.Atmos.7.1.iTA.ENG-GROUP",parsedFileOverrides:{},type:"debrid",serviceId:"none",cached:!0,addonName:"Torrentio",presetId:"custom",manifestUrl:"http://localhost:2000/manifest.json",indexer:"RARBG",seeders:125,age:"10d",duration:912e4,size:625e8,folderSize:125e9,bitrate:void 0,infoHash:"dd8255ecdc7ca55fb0bbf8
631323d87062db1f6d1c",message:"This is a message",library:!1,proxied:!1,private:!1,freeleech:!1,preloading:!1,metadata:gi,regexMatched:"",regexScore:25,maxRegexScore:50,rankedRegexMatched:"",seMatched:"",seScore:150,maxSeScore:100,rseMatched:"",seadex:!1,seadexBest:!1},gd=["stream.filename","stream.folderName"],gc=["stream.type","stream.indexer","stream.seeders","stream.age","stream.ageHours","stream.duration","stream.size","stream.folderSize","stream.bitrate","stream.infoHash","stream.message","stream.library","stream.private","stream.freeleech","stream.proxied","stream.preloading","service.id","service.name","service.shortName","service.cached","addon.name","addon.presetId","addon.manifestUrl"],gu=["stream.regexMatched","stream.regexScore","stream.nRegexScore","stream.rankedRegexMatched","stream.seMatched","stream.seScore","stream.nSeScore","stream.rseMatched","stream.seadex","stream.seadexBest"],gm={source:gd,stream:gc,scoring:gu,metadata:[],parsed:[]},gp=[{id:"movie",label:"Movie",input:{}},{id:"series",label:"Series episode",input:{filename:"Series.Title.S02E05.The.Episode.Name.1080p.WEB-DL.DDP5.1.H.264-GROUP.mkv",folderName:"Series.Title.S02.1080p.WEB-DL.DDP5.1.H.264-GROUP",size:35e8,folderSize:35e9,duration:27e5,metadata:{type:sH,title:"Series Title",titles:"Series Title, Series Title (US)",year:2019,yearEnd:2024,season:2,episode:5,episodeTitles:"The Episode Name",genres:"Drama, Mystery",runtime:3e3,episodeRuntime:45,latestSeason:4,daysSinceRelease:2,daysSinceFirstAired:1830,daysSinceLastAired:2,hasNextEpisode:!0,daysUntilNextEpisode:5}}},{id:"anime",label:"Anime episode",input:{filename:"[SubsPlease] Anime Title - 13 (1080p) [A1B2C3D4].mkv",folderName:"[SubsPlease] Anime Title (01-24) (1080p)",size:14e8,folderSize:336e8,duration:144e4,seadex:!0,metadata:{type:sH,isAnime:!0,title:"Anime Title",titles:"Anime Title, アニメタイトル",year:2024,season:2,episode:1,absoluteEpisode:13,relativeAbsoluteEpisode:1,episodeTitles:"The Episode Name",genres:"Action, Fantasy",originalLanguage:"Japanese",country:"JP",runtime:576,episodeRuntime:24,anilistId:21,malId:21,hasSeaDex:!0,daysSinceRelease:1,hasNextEpisode:!0,daysUntilNextEpisode:7}}},{id:"season-pack",label:"Season pack",input:{filename:"Series.Title.S02.COMPLETE.2160p.WEB-DL.DV.HDR10.DDP5.1.H.265-GROUP",size:84e9,folderSize:84e9,duration:void 0,type:"p2p",seeders:42,metadata:{type:sH,title:"Series Title",titles:"Series Title",year:2019,season:2,genres:"Drama, Mystery",latestSeason:4,daysSinceRelease:400}}},{id:"usenet",label:"Usenet release",input:{filename:"Movie.Title.2023.2160p.UHD.BluRay.REMUX.DV.HDR.TrueHD.7.1.Atmos-GROUP.mkv",folderName:"Movie.Title.2023.2160p.UHD.BluRay.REMUX.DV.HDR.TrueHD.7.1.Atmos-GROUP",type:"usenet",serviceId:"aiostreams",indexer:"NZBGeek",addonName:"Newznab",age:"400d",seeders:void 0,size:82e9,folderSize:82e9}}],gh="aiostreams:formatter-preview";function gx(){try{var e,t;let s=localStorage.getItem(gh);if(!s)return go;let a=JSON.parse(s);if((null==a?void 0:a.version)!==2)return go;return{...go,...a.input,metadata:{...gi,...null==(e=a.input)?void 0:e.metadata},parsedFileOverrides:(null==(t=a.input)?void 0:t.parsedFileOverrides)??{}}}catch{return go}}function gg(e){try{return new URL(e),!0}catch{return!1}}function gf(e){return e.split(",").map(e=>e.trim()).filter(Boolean)}function gb(e){let t=function(e,t,s){if(!e&&!t)return;function a(){for(var e=arguments.length,t=Array(e),s=0;s<e;s++)t[s]=arguments[s];for(let e of t)if(e&&e.length>0)return e}let r=(null==t?void 0:t.seasonPack)||(null==e?void 0:e.seasonPack),n=a(null==e?void 0:e.episodes,null==t?void 0:t.episodes),l=a(null==e?void 0:e.seasons,null==t?void 0:t.seasons),i=function(e,t){if(!e)return t;if(!t)return e;let s=["title","year","country","episodeTitle","seasons","episodes","resolution","quality","encode","releaseGroup","editions","regraded","repack","proper","uncensored","unrated","upscaled","network","container","extension","visualTags","audioTags","audioChannels","languages","subtitles","seasonPack"];return s.reduce((t,s)=>t+ +!!e[s],0)>=s.reduce((e,s)=>e+ +!!t[s],0)?e:t}(e,t);
63return{title:(null==i?void 0:i.title)||(null==t?void 0:t.title)||(null==e?void 0:e.title),year:(null==e?void 0:e.year)||(null==t?void 0:t.year),country:(null==e?void 0:e.country)||(null==t?void 0:t.country),episodeTitle:(null==e?void 0:e.episodeTitle)||(null==t?void 0:t.episodeTitle),folderSeasons:l!==(null==t?void 0:t.seasons)?null==t?void 0:t.seasons:void 0,folderEpisodes:n!==(null==t?void 0:t.episodes)?null==t?void 0:t.episodes:void 0,seasons:l,episodes:n,date:(null==e?void 0:e.date)||(null==t?void 0:t.date),resolution:(null==e?void 0:e.resolution)||(null==t?void 0:t.resolution),quality:(null==e?void 0:e.quality)||(null==t?void 0:t.quality),encode:(null==e?void 0:e.encode)||(null==t?void 0:t.encode),releaseGroup:(null==e?void 0:e.releaseGroup)||(null==t?void 0:t.releaseGroup),editions:gl(null==t?void 0:t.editions,null==e?void 0:e.editions),regraded:(null==e?void 0:e.regraded)||(null==t?void 0:t.regraded),repack:(null==e?void 0:e.repack)||(null==t?void 0:t.repack),proper:(null==e?void 0:e.proper)||(null==t?void 0:t.proper),uncensored:(null==e?void 0:e.uncensored)||(null==t?void 0:t.uncensored),unrated:(null==e?void 0:e.unrated)||(null==t?void 0:t.unrated),upscaled:(null==e?void 0:e.upscaled)||(null==t?void 0:t.upscaled),network:(null==e?void 0:e.network)||(null==t?void 0:t.network),container:(null==e?void 0:e.container)||(null==t?void 0:t.container),extension:(null==e?void 0:e.extension)||(null==t?void 0:t.extension),visualTags:gl(null==t?void 0:t.visualTags,null==e?void 0:e.visualTags),audioTags:gl(null==t?void 0:t.audioTags,null==e?void 0:e.audioTags),audioChannels:gl(null==t?void 0:t.audioChannels,null==e?void 0:e.audioChannels),languages:gl(null==t?void 0:t.languages,null==e?void 0:e.languages),subtitles:gl(null==t?void 0:t.subtitles,null==e?void 0:e.subtitles),subbed:(null==e?void 0:e.subbed)||(null==t?void 0:t.subbed)||!1,dubbed:(null==e?void 0:e.dubbed)||(null==t?void 0:t.dubbed)||!1,seasonPack:r,...s}}(e.filename?gn.parse(e.filename):void 0,e.folderName?gn.parse(e.folderName):void 0,e.parsedFileOverrides);if(t){var s,a;return s={size:e.size,folderSize:e.folderSize},!t.seasonPack&&(null==(a=t.episodes)?void 0:a.length)&&(s.folderSize&&s.size&&s.folderSize>2*s.size?t.seasonPack=!0:t.episodes.length>5&&(t.seasonPack=!0)),t}}function gv(e){return e.size&&e.duration?Math.floor(8*e.size/(e.duration/1e3)):void 0}function gy(e){return void 0===e||""===e?null:e}function gj(e){let t=gf(e);return t.length?t:null}function gw(e){let{input:t,patch:s}=e;return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(x3,{field:"stream.filename",label:"Filename",always:!0,value:t.filename,onChange:e=>s({filename:e})}),(0,r.jsx)(x3,{field:"stream.folderName",label:"Folder name",always:!0,value:t.folderName,onChange:e=>s({folderName:e})}),(0,r.jsx)(x2,{children:"Both names are parsed and merged exactly as they are for a real stream. Everything they produce is on the Parsed File tab, where you can also override it."})]})}let gN="__none__",gk="__auto__",gS=[{key:"title",label:"Title",field:"stream.title",kind:"text"},{key:"year",label:"Year",field:"stream.year",kind:"text"},{key:"seasons",label:"Seasons",field:["stream.seasons","stream.season","stream.formattedSeasons","stream.seasonEpisode"],kind:"numberList"},{key:"episodes",label:"Episodes",field:["stream.episodes","stream.episode","stream.formattedEpisodes","stream.seasonEpisode"],kind:"numberList"},{key:"resolution",label:"Resolution",field:"stream.resolution",kind:"enum",options:sL},{key:"quality",label:"Quality",field:"stream.quality",kind:"enum",options:sU},{key:"encode",label:"Encode",field:"stream.encode",kind:"enum",options:sz},{key:"releaseGroup",label:"Release group",field:"stream.releaseGroup",kind:"text"},{key:"visualTags",label:"Visual tags",field:"stream.visualTags",kind:"enumList",options:s$},{key:"audioTags",label:"Audio tags",field:"stream.audioTags",kind:"enumList",options:sO},{key:"audioChannels",label:"Audio channels",field:"stream.audioChannels",kind:"enumList",options:sF},{key:"languages",label:"Languages",field:["stream.languages","stream.uLanguages","stream.languageEmojis","stream.uLanguageEmojis","stream.languageCodes","stream.uLanguageCodes","stream.smallLanguageCodes","stream.uSmallLanguageCodes","stream.wedontknowwhatakilometeris","stream.uWedontknowwhatakilometeris"],kind:"enumList",options:sQ},{key:"subtitles",label:"Subtitles",field:["stream.subtitles","stream.uSubtitles","stream.subtitleEmojis","stream.uSubtitleEmojis","stream.subtitleCodes","stream.uSubtitleCodes","stream.smallSubtitleCodes","stream.uSmallSubtitleCodes","stream.subbed"],kind:"enumList",options:sQ,help:"Only media info fills this in, so overriding is the only way to preview it"},{key:"editions",label:"Editions",field:["stream.edition","stream.editions"],kind:"textList"},{key:"seasonPack",label:"Season pack",field:"stream.seasonPack",kind:"bool"}],gC=[{key:"country",label:"Country",field:"stream.country",kind:"text"},{key:"episodeTitle",label:"Episode title",field:"stream.episodeTitle",kind:"text"},{key:"date",label:"Date",field:"stream.date",kind:"text"},{key:"folderSeasons",label:"Folder seasons",field:["stream.folderSeasons","stream.formattedFolderSeasons"],kind:"numberList"},{key:"folderEpisodes",label:"Folder episodes",field:["stream.folderEpisodes","stream.formattedFolderEpisodes"],kind:"numberList"},{key:"volumes",label:"Volumes",field:[],kind:"numberList",help:"Parsed but not exposed to templates"},{key:"network",label:"Network",field:"stream.network",kind:"text"},{key:"container",label:"Container",field:"stream.container",kind:"text"},{key:"extension",label:"Extension",field:"stream.extension",kind:"text"},{key:"subbed",label:"Subbed",field:"stream.subbed",kind:"bool"},{key:"dubbed",label:"Dubbed",field:"stream.dubbed",kind:"bool"},{key:"regraded",label:"Regraded",field:"stream.regraded",kind:"bool"},{key:"repack",label:"Repack",field:"stream.repack",kind:"bool"},{key:"proper",label:"Proper",field:"stream.proper",kind:"bool"},{key:"uncensored",label:"Uncensored",field:"stream.uncensored",kind:"bool"},{key:"unrated",label:"Unrated",field:"stream.unrated",kind:"bool"},{key:"upscaled",label:"Upscaled",field:"stream.upscaled",kind:"bool"},{key:"hasChapters",label:"Has chapters",field:"stream.hasChapters",kind:"bool",help:"Only media info fills this in, so overriding is the only way to preview it"}];function g_(e){return null==e||""===e||Array.isArray(e)&&0===e.length}function gR(e,t){return!!(g_(e)&&g_(t))||(Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((e,s)=>e===t[s]):e===t)}function gA(e){return null==e?"":Array.isArray(e)?e.join(", "):String(e)}function gT(e){let t,{row:s,parsed:a,overrides:n,setOverride:l}=e,{visible:i,isUsed:o}=xZ(s.field);if(!i)return null;let d=s.key in n,c=d?n[s.key]:null==a?void 0:a[s.key],u=(0,r.jsx)(xQ,{label:s.label,field:s.field,isUsed:o});switch(s.kind){case"enum":t=(0,r.jsx)(rn,{label:u,moreHelp:s.help,value:null==c?gN:String(c),options:[{label:"Not detected",value:gN},...(s.options??[]).map(e=>({label:e,value:e}))],onValueChange:e=>l(s.key,e===gN?"":e),className:"w-full"});break;case"enumList":t=(0,r.jsx)(ne,{label:u,moreHelp:s.help,multiple:!0,value:Array.isArray(c)?c.map(String):[],onValueChange:e=>l(s.key,e),options:(s.options??[]).map(e=>({label:e,value:e})),emptyMessage:"No matches",placeholder:"None",className:"w-full"});break;case"bool":t=(0,r.jsx)(rn,{label:u,moreHelp:s.help,value:d?String(c??!1):gk,options:[{label:`Auto (${(null==a?void 0:a[s.key])?"yes":"no"})`,value:gk},{label:"Yes",value:"true"},{label:"No",value:"false"}],onValueChange:e=>l(s.key,e===gk?void 0:"true"===e,!1),className:"w-full"});break;case"numberList":t=(0,r.jsx)(W,{label:u,moreHelp:s.help??"Comma separated",value:gA(c),placeholder:"Not detected",onValueChange:e=>l(s.key,gf(e??"").map(Number).filter(e=>!Number.isNaN(e))),className:"w-full"});break;case"textList":t=(0,r.jsx)(W,{label:u,moreHelp:s.help??"Comma separated",value:gA(c),placeholder:"Not detected",onValueChange:e=>l(s.key,gf(e??"")),className:"w-full"});break;default:t=(0,r.jsx)(W,{label:u,moreHelp:s.help,value:gA(c),placeholder:"Not detected",onValueChange:e=>l(s.key,e??""),className:"w-full"})}return(0,r.jsxs)("div",{className:"flex items-end gap-1.5",children:[(0,r.jsx)("div",{className:"min-w-0 flex-1",children:t}),(0,r.jsx)(E,{size:"sm",rounded:!0,intent:"gray-subtle",icon:(0,r.jsx)(xH.A,{className:"w-3.5 h-3.5"}),"aria-label":`Reset ${s.label}`,className:d?void 0:"invisible",onClick:()=>l(s.key,void 0)})]})}
63function gI(e){let{input:t,patch:s,parsed:a,effective:l}=e,[i,o]=(0,n.useState)(!1),d=t.parsedFileOverrides,c=Object.keys(d).length,u=function(e,t){let r,n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],l={...d};void 0===t||n&&gR(t,null==a?void 0:a[e])?delete l[e]:l[e]=t,(r=Object.keys(l)).length===Object.keys(d).length&&r.every(e=>gR(l[e],d[e]))||s({parsedFileOverrides:l})};return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsx)("p",{className:"text-xs text-[--muted]",children:c>0?`${c} override${1===c?"":"s"} applied on top of the parser`:"Straight from the parser. Editing any value overrides it."}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)(w,{size:"sm",intent:"gray-subtle",onClick:()=>o(e=>!e),children:[i?"Hide":"Show"," raw JSON"]}),(0,r.jsx)(w,{size:"sm",intent:"alert-subtle",disabled:0===c,onClick:()=>s({parsedFileOverrides:{}}),children:"Clear overrides"})]})]}),i&&(0,r.jsx)("pre",{className:"max-h-72 overflow-auto rounded-md border border-[--border] bg-[--subtle] p-3 text-xs",children:JSON.stringify(l??null,null,2)}),(0,r.jsx)(xX,{cols:3,children:gS.map(e=>(0,r.jsx)(gT,{row:e,parsed:a,overrides:d,setOverride:u},e.key))}),(0,r.jsx)(x1,{fields:gC.map(e=>e.field),children:(0,r.jsx)(xX,{cols:3,children:gC.map(e=>(0,r.jsx)(gT,{row:e,parsed:a,overrides:d,setOverride:u},e.key))})}),(0,r.jsx)(x2,{children:"Overrides stand in for the media info the engine folds in at this same point, which is the only source for subtitles and chapters."})]})}let gE=["service.id","service.name","service.shortName"],gM=["stream.infoHash","stream.bitrate","addon.presetId","addon.manifestUrl"];function gP(e){let{input:t,patch:s}=e,a="none"===t.serviceId,n=gv(t);return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)(xX,{cols:3,children:[(0,r.jsx)(x5,{field:"stream.type",label:"Stream type",value:t.type,onChange:e=>s({type:e}),options:sB.map(e=>({label:e.charAt(0).toUpperCase()+e.slice(1),value:e}))}),(0,r.jsx)(x5,{field:gE,label:"Service",value:t.serviceId,onChange:e=>s({serviceId:e}),options:[{label:"None",value:"none"},...Object.values(sC).map(e=>({label:e.name,value:e.id}))]}),(0,r.jsx)(x3,{field:"addon.name",label:"Addon name",value:t.addonName,onChange:e=>s({addonName:e})}),(0,r.jsx)(x3,{field:"stream.indexer",label:"Indexer",value:t.indexer,onChange:e=>s({indexer:e})}),(0,r.jsx)(x6,{field:"stream.seeders",label:"Seeders",value:t.seeders,onChange:e=>s({seeders:e}),min:0}),(0,r.jsx)(x3,{field:["stream.age","stream.ageHours"],label:"Age",help:"e.g. 30m, 12h, 10d, 2y",value:t.age,onChange:e=>s({age:e})}),(0,r.jsx)(x6,{field:"stream.duration",label:"Duration (seconds)",value:t.duration?t.duration/1e3:void 0,onChange:e=>s({duration:void 0===e?void 0:1e3*e}),min:0,step:60}),(0,r.jsx)(x6,{field:"stream.size",label:"Size (bytes)",help:t.size?rx(t.size):void 0,value:t.size,onChange:e=>s({size:e}),min:0,step:1e9}),(0,r.jsx)(x6,{field:"stream.folderSize",label:"Folder size (bytes)",help:t.folderSize?rx(t.folderSize):void 0,value:t.folderSize,onChange:e=>s({folderSize:e}),min:0,step:1e9})]}),(0,r.jsx)(x3,{field:"stream.message",label:"Message",value:t.message,onChange:e=>s({message:e}),placeholder:"This is a message"}),(0,r.jsxs)(x0,{children:[(0,r.jsx)(x4,{field:"service.cached",label:"Cached",disabled:a,help:a?"Needs a service":void 0,value:t.cached,onChange:e=>s({cached:e})}),(0,r.jsx)(x4,{field:"stream.library",label:"Library",value:t.library,onChange:e=>s({library:e})}),(0,r.jsx)(x4,{field:"stream.private",label:"Private",value:t.private,onChange:e=>s({private:e})}),(0,r.jsx)(x4,{field:"stream.freeleech",label:"Freeleech",value:t.freeleech,onChange:e=>s({freeleech:e})}),(0,r.jsx)(x4,{field:"stream.proxied",label:"Proxied",value:t.proxied,onChange:e=>s({proxied:e})}),(0,r.jsx)(x4,{field:"stream.preloading",label:"Preloading",value:t.preloading,onChange:e=>s({preloading:e})})]}),(0,r.jsx)(x1,{fields:gM,children:(0,r.jsxs)(xX,{cols:2,children:[(0,r.jsx)(x3,{field:"stream.infoHash",label:"Info hash",help:"Only sent for p2p streams",value:t.infoHash,onChange:e=>s({infoHash:e})}),(0,r.jsx)(x6,{field:"stream.bitrate",label:"Bitrate (bps)",help:"Blank derives it from size and duration",value:t.bitrate,onChange:e=>s({bitrate:e}),min:0,step:1e6,placeholder:n?`Auto: ${rf(n)}`:"Auto"}),(0,r.jsx)(x3,{field:"addon.presetId",label:"Preset ID",value:t.presetId,onChange:e=>s({presetId:e})}),(0,r.jsx)(x3,{field:"addon.manifestUrl",label:"Manifest URL",value:t.manifestUrl,onChange:e=>s({manifestUrl:e}),error:gg(t.manifestUrl)?void 0:"Must be a valid URL"})]})})]})}let gD=["metadata.titles","metadata.yearEnd","metadata.episodeRuntime","metadata.absoluteEpisode","metadata.relativeAbsoluteEpisode","metadata.originalLanguage","metadata.country","metadata.latestSeason","metadata.daysSinceRelease","metadata.daysSinceFirstAired","metadata.daysSinceLastAired","metadata.hasNextEpisode","metadata.daysUntilNextEpisode","metadata.anilistId","metadata.malId","metadata.hasSeaDex"];
63function gL(e){let{input:t,patch:s}=e,a=t.metadata,n=e=>s({metadata:{...a,...e}}),l=a.type?a.isAnime?`anime.${a.type}`:a.type:"";return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)(xX,{cols:3,children:[(0,r.jsx)(x5,{field:"metadata.type",label:"Type",value:a.type,onChange:e=>n({type:e}),options:sY.map(e=>({label:sJ[e],value:e}))}),(0,r.jsx)(x3,{field:"metadata.queryType",label:"Query type",help:"Derived from type and anime",disabled:!0,value:l,onChange:()=>void 0}),(0,r.jsx)(x3,{field:"metadata.title",label:"Title",value:a.title,onChange:e=>n({title:e})}),(0,r.jsx)(x6,{field:"metadata.year",label:"Year",value:a.year,onChange:e=>n({year:e}),min:0}),(0,r.jsx)(x6,{field:"metadata.season",label:"Season",value:a.season,onChange:e=>n({season:e}),min:0}),(0,r.jsx)(x6,{field:"metadata.episode",label:"Episode",value:a.episode,onChange:e=>n({episode:e}),min:0}),(0,r.jsx)(x9,{field:["metadata.episodeTitle","metadata.episodeTitles"],label:"Episode titles",help:"Comma separated; the first is metadata.episodeTitle",value:a.episodeTitles,onChange:e=>n({episodeTitles:e})}),(0,r.jsx)(x9,{field:"metadata.genres",label:"Genres",value:a.genres,onChange:e=>n({genres:e})}),(0,r.jsx)(x6,{field:"metadata.runtime",label:"Runtime (minutes)",value:a.runtime,onChange:e=>n({runtime:e}),min:0})]}),(0,r.jsx)(x0,{children:(0,r.jsx)(x4,{field:"metadata.isAnime",label:"Anime",value:a.isAnime,onChange:e=>n({isAnime:e})})}),(0,r.jsxs)(x1,{fields:gD,children:[(0,r.jsxs)(xX,{cols:3,children:[(0,r.jsx)(x9,{field:"metadata.titles",label:"Titles",value:a.titles,onChange:e=>n({titles:e})}),(0,r.jsx)(x6,{field:"metadata.yearEnd",label:"End year",value:a.yearEnd,onChange:e=>n({yearEnd:e}),min:0}),(0,r.jsx)(x6,{field:"metadata.episodeRuntime",label:"Episode runtime (minutes)",value:a.episodeRuntime,onChange:e=>n({episodeRuntime:e}),min:0}),(0,r.jsx)(x6,{field:"metadata.absoluteEpisode",label:"Absolute episode",value:a.absoluteEpisode,onChange:e=>n({absoluteEpisode:e}),min:0}),(0,r.jsx)(x6,{field:"metadata.relativeAbsoluteEpisode",label:"Relative absolute episode",value:a.relativeAbsoluteEpisode,onChange:e=>n({relativeAbsoluteEpisode:e}),min:0}),(0,r.jsx)(x3,{field:"metadata.originalLanguage",label:"Original language",help:"Also resolves the 'Original' entry in your language preferences",value:a.originalLanguage,onChange:e=>n({originalLanguage:e})}),(0,r.jsx)(x3,{field:"metadata.country",label:"Country",value:a.country,onChange:e=>n({country:e})}),(0,r.jsx)(x6,{field:"metadata.latestSeason",label:"Latest season",value:a.latestSeason,onChange:e=>n({latestSeason:e}),min:0}),(0,r.jsx)(x6,{field:"metadata.daysSinceRelease",label:"Days since release",value:a.daysSinceRelease,onChange:e=>n({daysSinceRelease:e}),min:0}),(0,r.jsx)(x6,{field:"metadata.daysSinceFirstAired",label:"Days since first aired",value:a.daysSinceFirstAired,onChange:e=>n({daysSinceFirstAired:e}),min:0}),(0,r.jsx)(x6,{field:"metadata.daysSinceLastAired",label:"Days since last aired",value:a.daysSinceLastAired,onChange:e=>n({daysSinceLastAired:e}),min:0}),(0,r.jsx)(x6,{field:"metadata.daysUntilNextEpisode",label:"Days until next episode",value:a.daysUntilNextEpisode,onChange:e=>n({daysUntilNextEpisode:e}),min:0}),(0,r.jsx)(x6,{field:"metadata.anilistId",label:"AniList ID",value:a.anilistId,onChange:e=>n({anilistId:e}),min:0}),(0,r.jsx)(x6,{field:"metadata.malId",label:"MyAnimeList ID",value:a.malId,onChange:e=>n({malId:e}),min:0})]}),(0,r.jsxs)(x0,{children:[(0,r.jsx)(x4,{field:"metadata.hasNextEpisode",label:"Has next episode",value:a.hasNextEpisode,onChange:e=>n({hasNextEpisode:e})}),(0,r.jsx)(x4,{field:"metadata.hasSeaDex",label:"Has SeaDex entry",value:a.hasSeaDex,onChange:e=>n({hasSeaDex:e})})]})]})]})}let gU=["stream.rankedRegexMatched","stream.rseMatched"];function g$(e){let{input:t,patch:s}=e;return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)(xX,{cols:3,children:[(0,r.jsx)(x3,{field:"stream.regexMatched",label:"Regex matched",value:t.regexMatched,onChange:e=>s({regexMatched:e}),placeholder:"e.g. 2160p"}),(0,r.jsx)(x6,{field:"stream.regexScore",label:"Regex score",value:t.regexScore,onChange:e=>s({regexScore:e}),min:-1e6,max:1e6,step:5}),(0,r.jsx)(x6,{field:"stream.nRegexScore",label:"Highest regex score",help:"Normalises stream.nRegexScore",value:t.maxRegexScore,onChange:e=>s({maxRegexScore:e}),min:1,step:10}
63),(0,r.jsx)(x3,{field:"stream.seMatched",label:"Stream expression matched",value:t.seMatched,onChange:e=>s({seMatched:e}),placeholder:"e.g. high-quality"}),(0,r.jsx)(x6,{field:"stream.seScore",label:"Stream expression score",value:t.seScore,onChange:e=>s({seScore:e}),min:-1e6,max:1e6,step:10}),(0,r.jsx)(x6,{field:"stream.nSeScore",label:"Highest expression score",help:"Normalises stream.nSeScore",value:t.maxSeScore,onChange:e=>s({maxSeScore:e}),min:1,step:25})]}),(0,r.jsxs)(x0,{children:[(0,r.jsx)(x4,{field:"stream.seadex",label:"SeaDex",value:t.seadex,onChange:e=>s({seadex:e})}),(0,r.jsx)(x4,{field:"stream.seadexBest",label:"SeaDex best",disabled:!t.seadex,value:t.seadex&&t.seadexBest,onChange:e=>s({seadexBest:e})})]}),(0,r.jsx)(x1,{fields:gU,children:(0,r.jsxs)(xX,{cols:2,children:[(0,r.jsx)(x9,{field:"stream.rankedRegexMatched",label:"Ranked regexes matched",value:t.rankedRegexMatched,onChange:e=>s({rankedRegexMatched:e}),placeholder:"2160p, HDR10+, REMUX"}),(0,r.jsx)(x9,{field:"stream.rseMatched",label:"Ranked expressions matched",value:t.rseMatched,onChange:e=>s({rseMatched:e}),placeholder:"high-quality, best-match"})]})})]})}function gO(e){let{name:t,description:s}=e;return(0,r.jsxs)("div",{className:"bg-gray-900 rounded-md p-4 border border-gray-800",children:[(0,r.jsx)("div",{className:"text-xl font-bold mb-1 overflow-x-auto",style:{whiteSpace:"pre"},children:t}),(0,r.jsx)("div",{className:"text-base text-muted-foreground overflow-x-auto",style:{whiteSpace:"pre"},children:s})]})}function gF(){let{userData:e}=s4(),t=(0,n.useRef)(new xG(200)),[s,a]=(0,n.useState)(gx),[l,i]=(0,n.useState)("source"),[o,d]=(0,n.useState)(!1),[c,u]=(0,n.use
63State)(null),m=(0,n.useCallback)(e=>{a(t=>({...t,...e}))},[]);(0,n.useEffect)(()=>{try{localStorage.setItem(gh,JSON.stringify({version:2,input:s}))}catch{}},[s]);let p=xL(e),h=(0,n.useMemo)(()=>new Set([...xu(p.name),...xu(p.description)]),[p.name,p.description]),g=(0,n.useMemo)(()=>gb({...s,parsedFileOverrides:{}}),[s]),f=(0,n.useMemo)(()=>gb(s),[s]),b=(0,n.useCallback)(async()=>{try{let t,a,r,n,l=await eC((t=gb(s),a=s.bitrate??gv(s),{id:"preview",type:s.type,addon:{name:s.addonName,preset:{type:s.presetId,id:s.presetId,options:{}},enabled:!0,manifestUrl:gg(s.manifestUrl)?s.manifestUrl:go.manifestUrl,timeout:1e4},library:s.library,parsedFile:t,filename:s.filename,folderName:s.folderName,folderSize:s.folderSize,indexer:s.indexer,regexMatched:{name:s.regexMatched||void 0,index:0},torrent:{infoHash:"p2p"===s.type&&s.infoHash||void 0,seeders:s.seeders,private:s.private,freeleech:s.freeleech},service:"none"===s.serviceId?void 0:{id:s.serviceId,cached:s.cached},age:function(e){let t=e.match(/^(\d+)([a-zA-Z])$/);if(!t)return;let s=parseInt(t[1],10);switch(t[2].toLowerCase()){case"d":return 24*s;case"h":return s;case"m":return s/60;case"y":return 24*s*365;default:return}}(s.age),duration:s.duration,size:s.size,bitrate:a,proxied:s.proxied,preloading:s.preloading,message:s.message,seadex:{isSeadex:s.seadex,isBest:s.seadex&&s.seadexBest},streamExpressionScore:s.seScore,streamExpressionMatched:s.seMatched?{name:s.seMatched,index:0}:void 0,rankedStreamExpressionsMatched:gf(s.rseMatched),regexScore:s.regexScore,rankedRegexesMatched:gf(s.rankedRegexMatched)}),{...(r=s.metadata,{type:n=gy(r.type),queryType:n?r.isAnime?`anime.${n}`:n:null,isAnime:r.isAnime,title:gy(r.title),titles:gj(r.titles),year:gy(r.year),yearEnd:gy(r.yearEnd),season:gy(r.season),episode:gy(r.episode),episodeTitles:gj(r.episodeTitles),genres:gj(r.genres),runtime:gy(r.runtime),episodeRuntime:gy(r.episodeRuntime),absoluteEpisode:gy(r.absoluteEpisode),relativeAbsoluteEpisode:gy(r.relativeAbsoluteEpisode),originalLanguage:gy(r.originalLanguage),country:gy(r.country),latestSeason:gy(r.latestSeason),daysSinceRelease:gy(r.daysSinceRelease),daysSinceFirstAired:gy(r.daysSinceFirstAired),daysSinceLastAired:gy(r.daysSinceLastAired),hasNextEpisode:r.hasNextEpisode,daysUntilNextEpisode:gy(r.daysUntilNextEpisode),anilistId:gy(r.anilistId),malId:gy(r.malId),hasSeaDex:r.hasSeaDex,maxRegexScore:gy(s.maxRegexScore),maxSeScore:gy(s.maxSeScore)}),userData:e});u({name:l.name,description:l.description})}catch(e){console.error("Error formatting stream:",e),x.oR.error(`Failed to format stream: ${e}`)}},[s,e]);(0,n.useEffect)(()=>{t.current.enqueue(b)},[b]);let v=[{value:"source",label:"Source",icon:(0,r.jsx)(xV.A,{className:"w-4 h-4"}),content:(0,r.jsx)(gw,{input:s,patch:m})},{value:"stream",label:"Stream",icon:(0,r.jsx)(xq.A,{className:"w-4 h-4"}),content:(0,r.jsx)(gP,{input:s,patch:m})},{value:"parsed",label:"Parsed File",icon:(0,r.jsx)(x_.A,{className:"w-4 h-4"}),content:(0,r.jsx)(gI,{input:s,patch:m,parsed:g,effective:f})},{value:"scoring",label:"Scoring",icon:(0,r.jsx)(xB.A,{className:"w-4 h-4"}),content:(0,r.jsx)(g$,{input:s,patch:m})},{value:"metadata",label:"Metadata",icon:(0,r.jsx)(cz.A,{className:"w-4 h-4"}),content:(0,r.jsx)(gL,{input:s,patch:m})}],y=o?v.filter(e=>(function(e,t){if("metadata"===e)return[...t].some(e=>e.startsWith("metadata."));if("parsed"===e){let e=new Set([...gd,...gc,...gu]);return[...t].some(t=>t.startsWith("stream.")&&!e.has(t))}return(gm[e]??[]).some(e=>t.has(e))})(e.value,h)):v;(0,n.useEffect)(()=>{y.length&&!y.some(e=>e.value===l)&&i(y[0].value)},[y,l]);let j=JSON.stringify(s)===JSON.stringify(go);return(0,r.jsx)(cr,{title:"Preview",description:"See how your streams would be formatted based on controllable variables",children:(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(gO,{name:null==c?void 0:c.name,description:null==c?void 0:c.description}),(0,r.jsx)(gz,{scenario:s.scenario,onScenario:e=>{let t;return a((t=gp.find(t=>t.id===e))?{...go,...t.input,metadata:{...gi,...t.input.metadata},scenario:e}:{...go,scenario:e})},onlyUsed:o,onOnlyUsed:d,usedCount:h.size,onReset:()=>a(go),resetDisabled:j}),(0,r.jsx)(xY,{used:h,onlyUsed:o,children:y.length?(0,r.jsx)(dO,{tabs:y,activeTab:l,onTabChange:i,revealOnChange:!0}):(0,r.jsx)("p",{className:"text-center text-sm text-[--muted] py-6",children:"This formatter reads no controllable fields."})})]})})}function gz(e){let{scenario:t,onScenario:s,onlyUsed:a,onOnlyUsed:n,usedCount:l,onReset:i,resetDisabled:o}=e;return(0,r.jsxs)("div",{className:"flex flex-col gap-3 rounded-md border border-gray-800 bg-gray-900/60 p-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.jsx)("span",{className:"shrink-0 text-xs font-medium uppercase tracking-wide text-[--muted]",children:"Scenario"}),(0,r.jsx)(rn,{className:"w-full sm:w-56",value:t,options:gp.map(e=>({label:e.label,value:e.id})),onValueChange:s})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2 sm:justify-end",children:[(0,r.jsx)(to,{trigger:(0,r.jsxs)("button",{type:"button",onClick:()=>n(!a),className:b("flex items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium transition-colors",a?"border-[--brand] bg-brand/10 text-[--brand]":"border-gray-800 text-[--muted] hover:text-[--foreground]"),children:[(0,r.jsx)(xK.A,{className:"w-4 h-4"}),"Used only",(0,r.jsx)("span",{className:"rounded-full bg-gray-800 px-2 py-0.5 text-xs leading-none",children:l})]}),children:"Show only the fields this formatter reads"}),(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{intent:"gray-subtle",icon:(0,r.jsx)(xH.A,{className:"w-4 h-4"}
63),"aria-label":"Reset preview inputs",disabled:o,onClick:i}),children:"Reset all preview inputs"})]})]})}function gV(){return(0,r.jsx)(ru,{className:"space-y-4 p-4 sm:p-8",children:(0,r.jsx)(gq,{})})}function gq(){let{isInherited:e,hasParent:t}=s9();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center w-full",children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h2",{children:"Formatter"}),t&&e("formatter")&&(0,r.jsx)(dF,{section:"formatter"})]}),(0,r.jsx)("p",{className:"text-[--muted]",children:"Format your streams to your liking."})]}),(0,r.jsx)("div",{className:"hidden lg:block lg:ml-auto",children:(0,r.jsx)(dT,{})})]}),(0,r.jsx)(xz,{}),(0,r.jsx)(gF,{})]})}function gB(){return(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(ru,{className:"space-y-4 p-4 sm:p-8",children:(0,r.jsx)(gK,{})})})}function gK(){var e,t,s,a,n,l,i,o,d,c,u,m,p,h,x,g,f,b,v,y;let{status:j}=e$(),{userData:w,setUserData:N}=s4(),{mode:k}=tX(),{isInherited:S,hasParent:C}=s9(),_=Object.entries(sS).map(e=>{let[t,s]=e;return{label:s.name,value:t}}),R=[...Object.values(sC).map(e=>({label:e.name,value:e.id,textValue:e.name})),{label:"None",value:"none",textValue:"None"}],A=w.presets.map(e=>({label:e.options.name||e.type,value:e.instanceId,textValue:e.options.name})),T=null==j?void 0:j.settings.forced.proxy,I=(null==T?void 0:T.enabled)!==null,E=(null==T?void 0:T.url)!==null,M=(null==T?void 0:T.publicUrl)!==null,P=(null==T?void 0:T.id)!==null,D=(null==T?void 0:T.publicIp)!==null,L=(null==T?void 0:T.credentials)!==null,U=(null==T?void 0:T.proxiedServices)!==null,$=null==T?void 0:T.disableProxiedAddons,O=(null==(e=w.proxy)?void 0:e.id)?sS[w.proxy.id]:void 0;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center w-full",children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h2",{children:"Proxy"}),C&&S("proxy")&&(0,r.jsx)(dF,{section:"proxy"})]}),(0,r.jsx)("p",{className:"text-[--muted]",children:"Configure a proxy for your streams to bypass IP restrictions or improve compatibility"})]}),(0,r.jsx)("div",{className:"hidden lg:block lg:ml-auto",children:(0,r.jsx)(dT,{})})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(cr,{children:(0,r.jsx)(rs,{side:"right",label:"Enable",value:(null==(t=w.proxy)?void 0:t.enabled)??!1,onValueChange:e=>{N(t=>({...t,proxy:{...t.proxy,enabled:e}}))},disabled:I})}),(0,r.jsxs)(cr,{children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(rn,{label:"Proxy Service",value:null==(s=w.proxy)?void 0:s.id,onValueChange:e=>{N(t=>({...t,proxy:{...t.proxy,id:e}}))},options:_,disabled:P||!(null==(a=w.proxy)?void 0:a.enabled)}),O&&(0,r.jsx)("p",{className:"text-[--muted] text-sm",children:(0,r.jsx)(nz,{children:O.description})})]}),(null==(n=w.proxy)?void 0:n.id)!=="builtin"&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(Z,{label:"URL",autoComplete:"new-password",value:(null==(l=w.proxy)?void 0:l.url)??"",onValueChange:e=>{N(t=>({...t,proxy:{...t.proxy,url:e}}))},placeholder:"Enter proxy URL",disabled:E||!(null==(i=w.proxy)?void 0:i.enabled)}),(0,r.jsx)("p",{className:"text-[--muted] text-sm",children:"The URL of your hosted proxy service."})]}),(null==(o=w.proxy)?void 0:o.id)!=="builtin"&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(Z,{label:"Public URL (optional)",autoComplete:"new-password",value:(null==(d=w.proxy)?void 0:d.publicUrl)??"",onValueChange:e=>{N(t=>({...t,proxy:{...t.proxy,publicUrl:e}}))},placeholder:"Enter proxy public URL",disabled:M||!(null==(c=w.proxy)?void 0:c.enabled)}),(0,r.jsxs)("p",{className:"text-[--muted] text-sm",children:["The public URL of your hosted proxy service. Provide this only if you want to use a local URL for requests but a publicly accessible URL is needed for streams. e.g. setting http://",(null==(u=w.proxy)?void 0:u.id)&&"stremthru"===w.proxy.id?"stremthru:8080":"mediaflow-proxy:8888","as the URL above but then using https://",(null==(m=w.proxy)?void 0:m.id)&&"stremthru"===w.proxy.id?"stremthru.yourdomain.com":"mediaflow-proxy.yourdomain.com","as the public URL."]})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(Z,{label:"Credentials",autoComplete:"new-password",value:(null==(p=w.proxy)?void 0:p.credentials)??"",onValueChange:e=>{N(t=>({...t,proxy:{...t.proxy,credentials:e}}))},placeholder:"Enter proxy credentials",disabled:L||!(null==(h=w.proxy)?void 0:h.enabled)}),O&&(0,r.jsx)("p",{className:"text-[--muted] text-sm",children:(0,r.jsx)(nz,{children:O.credentialDescription})})]}),"pro"===k&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(W,{label:"Public IP",value:(null==(x=w.proxy)?void 0:x.publicIp)??"",onValueChange:e=>{N(t=>({...t,proxy:{...t.proxy,publicIp:e||void 0}}))},placeholder:"Enter public IP",disabled:D||!(null==(g=w.proxy)?void 0:g.enabled)}),(0,r.jsxs)("p",{className:"text-[--muted] text-sm",children:["Configure this only when running ",null==O?void 0:O.name," ","locally with a proxy service. Leave empty if"," ",null==O?void 0:O.name," is configured locally without a proxy server or if it's hosted on a remote server."]})]})]}),"pro"===k&&(0,r.jsxs)(cr,{title:"Proxy Controls",description:"Optionally, specify services and addons that should be proxied. These options are applied conjunctively.",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(ne,{label:"Proxied Services",value:(null==(f=w.proxy)?void 0:f.proxiedServices)??[],onValueChange:e=>{N(t=>({...t,proxy:{...t.proxy,proxiedServices:e}}))},options:R,placeholder:"Select services to proxy",multiple:!0,disabled:U||!(null==(b=w.proxy)?void 0:b.enabled),emptyMessage:"No services available"}),(0,r.jsx)("p",{className:"text-[--muted] text-sm",children:"Only streams (that are detected to be) from these services will be proxied. Select None to enable proxying of streams that are not detected to be from a service."})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(ne,{label:"Proxied Addons",value:(null==(v=w.proxy)?void 0:v.proxiedAddons)??[],onValueChange:e=>{N(t=>({...t,proxy:{...t.proxy,proxiedAddons:e}}))},options:A,placeholder:"Select addons to proxy",multiple:!0,disabled:$||!(null==(y=w.proxy)?void 0:y.enabled),emptyMessage:"No addons available"}),(0,r.jsx)("p",{className:"text-[--muted] text-sm",children:"Only streams from these addons will be proxied"})]})]})]})]})}function gH(){return(0,r.jsx)(ru,{className:"space-y-4 p-4 sm:p-8",children:(0,r.jsx)(gG,{})})}function gG(){let{status:e}=e$(),t=s4(),[s,a]=n.useState("7d"),l=!!(t.uuid&&t.password),i=(null==e?void 0:e.settings.userAnalyticsEnabled)===!0,o=(0,eU.I)({queryKey:["user-analytics",t.uuid,s],queryFn:()=>eT(t.uuid,t.password,s),enabled:l&&i,refetchOnWindowFocus:!1,staleTime:3e4});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"flex items-center w-full",children:(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"Stats"}),(0,r.jsxs)("p",{className:"text-[--muted]",children:["Per-user breakdown of how your addons performed across recent stream requests. Data window is up to"," ",(0,r.jsx)("strong",{children:"24h"===s?"24 hours":"7 days"}),"; older events are pruned automatically."]})]})}),!l&&(0,r.jsx)(nU,{intent:"info",title:"Sign in to see your stats",description:"The Stats tab queries data attributed to your config UUID. Sign in to your config to view it."}),l&&!i&&(0,r.jsx)(nU,{intent:"warning",title:"Per-user analytics is disabled",description:"The owner of this instance has disabled per-user analytics. Ask them to enable it in Settings → Analytics."}),l&&i&&(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)(rF,{value:s,onValueChange:e=>a(e??"7d"),children:[(0,r.jsxs)(rz,{children:[(0,r.jsx)(rV,{value:"24h",children:"Last 24h"}),(0,r.jsx)(rV,{value:"7d",children:"Last 7 days"})]}
63),(0,r.jsxs)(rq,{value:s,className:"space-y-4 mt-4",children:[o.isLoading&&(0,r.jsx)(gW,{}),o.error&&(0,r.jsx)(nU,{intent:"alert",title:"Failed to load analytics",description:o.error.message}),o.data&&(0,r.jsx)(gY,{data:o.data})]})]})})]})}function gW(){return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:Array.from({length:4}).map((e,t)=>(0,r.jsx)(cK,{className:"h-24 rounded-md"},t))}),(0,r.jsx)(cK,{className:"h-64 rounded-md"})]})}function gY(e){let{data:t}=e,{status:s}=e$(),a=s4(),l=n.useMemo(()=>{let e=new Map;for(let t of(null==s?void 0:s.settings.presets)??[])e.set(t.ID,t.NAME);return e},[null==s?void 0:s.settings.presets]),i=n.useMemo(()=>{let e=new Set;for(let t of a.userData.presets??[])e.add(t.type);return e},[a.userData.presets]);if(0===t.totals.requests)return(0,r.jsx)(nU,{intent:"info",title:"No stream requests yet",description:"Once Stremio plays something, your stats will start populating. You can refresh this page after watching a few items."});let o=[],d=[];for(let e of t.perAddon)i.has(e.presetType)?o.push(e):d.push(e);return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)(gJ,{data:t}),(0,r.jsx)(cr,{title:"Per-addon performance",description:"One row per (preset, addon instance). Quality metrics use only requests that contributed to your final list — addons whose results were dropped because the exit condition fired aren't penalised.",children:(0,r.jsx)(gZ,{rows:o,presetNameByType:l})}),d.length>0&&(0,r.jsx)(cr,{title:"Removed addons (still in retention)",description:"These addons used to be in your config and still have stats within the retention window. They will disappear naturally once their data ages out.",titleClassName:"text-[--muted]",children:(0,r.jsx)(gZ,{rows:d,presetNameByType:l,muted:!0})}),t.perService.length>0&&(0,r.jsx)(cr,{title:"Per-service breakdown",description:"Surviving streams attributed to each debrid/cdn service across all merged contributions.",children:(0,r.jsx)(gQ,{rows:t.perService})}),t.latencyLeaderboard.length>0&&(0,r.jsx)(cr,{title:"Slowest addons",description:"Average response time across the window. Only includes addons with at least 3 successful requests.",children:(0,r.jsx)("ul",{className:"text-sm divide-y divide-[--border]",children:t.latencyLeaderboard.map((e,t)=>{var s;return(0,r.jsxs)("li",{className:"flex justify-between py-2",children:[(0,r.jsx)("span",{children:(null==(s=e.addonName)?void 0:s.trim())||l.get(e.presetType)||e.presetType}),(0,r.jsxs)("span",{className:"font-mono text-[--muted]",children:[(e.avgLatencyMs/1e3).toFixed(2),"s"]})]},`${e.presetType}-${e.instanceHash}-${t}`)})})})]})}function gJ(e){let{data:t}=e,s=[{label:"Requests",value:t.totals.requests.toLocaleString()},{label:"Avg final per request",value:t.totals.finalCountAvg.toFixed(1)},{label:"Cut-off rate",value:`${t.totals.cutOffRate}%`,muted:t.totals.cutOffRate<5},{label:"Error rate",value:`${t.totals.errorRate}%`,alert:t.totals.errorRate>10}];return(0,r.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:s.map(e=>(0,r.jsx)(X,{children:(0,r.jsxs)(ea,{className:"p-4",children:[(0,r.jsx)("div",{className:"text-xs text-[--muted] uppercase tracking-wide",children:e.label}),(0,r.jsx)("div",{className:b("text-2xl font-semibold mt-1",e.alert&&"text-red-400",e.muted&&"text-[--muted]"),children:e.value})]})},e.label))})}function gZ(e){let{rows:t,presetNameByType:s,muted:a}=e;return 0===t.length?(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"No data in this window."}):(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:b("w-full text-sm border-collapse",a&&"text-[--muted]"),children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"text-left border-b border-[--border]",children:[(0,r.jsx)(gX,{children:"Addon"}),(0,r.jsx)(gX,{align:"right",children:"Requests"}),(0,r.jsx)(gX,{align:"right",children:"Avg final"}),(0,r.jsx)(gX,{align:"right",children:"Final share"}),(0,r.jsx)(gX,{align:"right",children:"Cut-off"}),(0,r.jsx)(gX,{align:"right",children:"Errors"}),(0,r.jsx)(gX,{align:"right",children:"Avg latency"}),(0,r.jsx)(gX,{children:"Notes"})]})}),(0,r.jsx)("tbody",{children:t.map(e=>{var t;let a=s.get(e.presetType)??e.presetType,n=(null==(t=e.addonName)?void 0:t.trim())||a,l=!!e.addonName&&e.addonName.trim()!==a,i=[];return e.redundant&&i.push("Redundant"),e.slow&&i.push("Slow"),e.errorRate>25&&i.push("Unstable"),(0,r.jsxs)("tr",{className:"border-b border-[--border] last:border-0 hover:bg-[--subtle]/30",children:[(0,r.jsxs)(g0,{children:[(0,r.jsx)("div",{className:"font-medium",children:n}),(0,r.jsxs)("div",{className:"text-xs text-[--muted]",children:[l&&(0,r.jsx)("span",{className:"mr-2",children:a}),(0,r.jsxs)("span",{className:"font-mono",children:[e.instanceHash.slice(0,10),"…"]})]})]}),(0,r.jsx)(g0,{align:"right",children:e.requests}),(0,r.jsx)(g0,{align:"right",children:e.avgFinalContribution.toFixed(1)}),(0,r.jsxs)(g0,{align:"right",children:[e.finalShare.toFixed(1),"%"]}),(0,r.jsx)(g0,{align:"right",children:(0,r.jsxs)("span",{className:b(e.cutOffRate>30&&"text-amber-400"),children:[e.cutOffRate.toFixed(0),"%"]})}),(0,r.jsx)(g0,{align:"right",children:(0,r.jsxs)("span",{className:b(e.errorRate>10&&"text-red-400"),children:[e.errorRate.toFixed(0),"%"]})}),(0,r.jsx)(g0,{align:"right",children:null==e.avgLatencyMs?"—":`${(e.avgLatencyMs/1e3).toFixed(2)}s`}),(0,r.jsx)(g0,{children:i.length>0?(0,r.jsx)("span",{className:"text-xs",children:i.join(" \xb7 ")}):(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:"OK"})})]},`${e.presetType}-${e.instanceHash}`)})})]})})}function gQ(e){let{rows:t}=e;return(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm border-collapse",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{className:"text-left border-b border-[--border]",children:[(0,r.jsx)(gX,{children:"Service"}),(0,r.jsx)(gX,{align:"right",children:"Streams"}),(0,r.jsx)(gX,{align:"right",children:"Cached"}),(0,r.jsx)(gX,{align:"right",children:"Cached share"}),(0,r.jsx)(gX,{children:"Contributing addons"})]})}),(0,r.jsx)("tbody",{children:t.map(e=>(0,r.jsxs)("tr",{className:"border-b border-[--border] last:border-0 hover:bg-[--subtle]/30",children:[(0,r.jsx)(g0,{children:(0,r.jsx)("span",{className:"font-medium",children:e.serviceId})}),(0,r.jsx)(g0,{align:"right",children:e.finalCount}),(0,r.jsx)(g0,{align:"right",children:e.cachedCount}),(0,r.jsxs)(g0,{align:"right",children:[e.cachedShare.toFixed(0),"%"]}),(0,r.jsx)(g0,{children:(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:e.contributingAddons.join(", ")})})]},e.serviceId))})]})})}function gX(e){let{children:t,align:s}=e;return(0,r.jsx)("th",{className:b("py-2 px-3 text-xs font-semibold text-[--muted] uppercase tracking-wide","right"===s&&"text-right"),children:t})}function g0(e){let{children:t,align:s}=e;return(0,r.jsx)("td",{className:b("py-2 px-3","right"===s&&"text-right"),children:t})}function g1(){let{selectedMenu:e}=as();switch(e){case"about":return(0,r.jsx)(uI,{});case"services":return(0,r.jsx)(cd,{});case"addons":return(0,r.jsx)(cD,{});case"filters":return(0,r.jsx)(mw,{});case"sorting":return(0,r.jsx)(mz,{});case"formatter":return(0,r.jsx)(gV,{});case"proxy":return(0,r.jsx)(gB,{});case"miscellaneous":return(0,r.jsx)(pV,{});case"stats":return(0,r.jsx)(gH,{});case"save-install":return(0,r.jsx)(hc,{});default:return(0,r.jsxs)("div",{className:"p-8",children:[(0,r.jsx)("h2",{className:"text-2xl font-bold mb-4",children:e}),(0,r.jsx)("p",{className:"text-gray-400",children:"This section is under construction."})]})}}function g2(e){let{children:t,...s}=e,{selectedMenu:a}=as(),n=tw(!1),l=tw(!1),{userData:i,setUserData:o,uuid:d,setUuid:c,password:u,setPassword:m}=s4(),{open:p}=ah(),h=tN({title:"Sign Out",description:"Are you sure you want to sign out?",onConfirm:()=>{o(null),c(null),m(null)}});return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{"data-top-navbar":!0,className:b("w-full h-[5rem] relative overflow-hidden flex items-center","lg:hidden"),children:[(0,r.jsx)("div",{"data-top-navbar-content-container":!0,className:"relative z-10 px-4 w-full flex flex-row md:items-center overflow-x-auto overflow-y-hidden",children:(0,r.jsxs)("div",{"data-top-navbar-content":!0,className:"flex items-center w-full gap-3",children:[(0,r.jsx)(e9,{}),(0,r.jsx)(a3,{label:"Search settings",onOpen:p}),"about"!==a?(0,r.jsx)("div",{className:"flex items-center gap-2 lg:hidden",children:(0,r.jsx)(dT,{middleContent:(0,r.jsx)(E,{icon:d&&u?(0,r.jsx)(tC.eZR,{}):(0,r.jsx)(tC.XzR,{}),intent:"white-outline",rounded:!0,size:"md",onClick:()=>{d&&u?h.open():l.open()}})})}):(0,r.jsx)("div",{className:"block lg:hidden",children:(0,r.jsx)(w,{intent:"primary-subtle",size:"md",iconClass:"text-3xl",leftIcon:d&&u?(0,r.jsx)(tC.eZR,{}):(0,r.jsx)(tC.XzR,{}),onClick:()=>{d&&u?h.open():l.open()},children:d&&u?"Sign Out":"Sign In"})})]})}),(0,r.jsx)(o9,{open:n.isOpen,onOpenChange:n.toggle}),(0,r.jsx)(o5,{open:l.isOpen,onSuccess:()=>{l.close(),x.oR.success("Signed in successfully")},onOpenChange:e=>{e||l.close()}}),(0,r.jsx)(tk,{...h}),(0,r.jsx)(t_,{})]})})}function g3(e){let{error:t}=e,s=(0,o.jE)();return(0,r.jsx)(R,{showSpinner:!1,children:(0,r.jsx)(N,{title:"Something went wrong!",reset:()=>s.refetchQueries({queryKey:eD.queryKey}),children:(0,r.jsx)("p",{children:t})})})}function g6(){let{status:e,loading:t,error:s}=e$();return t?(0,r.jsx)(ds,{title:"Launching. . ."}):s||!e?(0,r.jsx)(g3,{error:s}):(0,r.jsx)(at,{children:(0,r.jsx)(ai,{children:(0,r.jsx)(ag,{children:(0,r.jsxs)(ap,{children:[(0,r.jsx)(dR,{children:(0,r.jsx)(e8,{children:(0,r.jsxs)(eY,{withSidebar:!0,sidebarSize:"slim",children:[(0,r.jsx)(eJ,{children:(0,r.jsx)(o8,{})}),(0,r.jsx)(eY,{children:(0,r.jsx)(eZ,{children:(0,r.jsxs)("div",{"data-main-layout-container":!0,className:"h-auto",children:[(0,r.jsx)(g2,{}),(0,r.jsx)("div",{"data-main-layout-content":!0,children:(0,r.jsx)(g1,{})})]})})})]})})}),(0,r.jsx)(aT,{})]})})})})}function g5(){return(0,r.jsx)(s5,{children:(0,r.jsx)(tQ,{children:(0,r.jsx)(g6,{})})})}function g4(){return(0,r.jsx)(g5,{})}let g9=new(s(4747)).E({defaultOptions:{queries:{staleTime:3e4,retry:!1}}}),g8=(0,d.un)({getParentRoute:()=>A,path:"/",component:function(){let e=(0,M.Z)();return(0,r.jsxs)("main",{className:"min-h-screen flex flex-col items-center justify-center gap-8 px-6 text-center",children:[(0,r.jsxs)("div",{className:"flex flex-col items-center gap-4",children:[(0,r.jsx)("img",{src:"/logo.png",alt:"AIOStreams",className:"max-h-[90px] object-contain"}),(0,r.jsx)("h1",{className:"text-3xl font-semibold tracking-tight",children:"AIOStreams"}),(0,r.jsx)("p",{className:"max-w-md text-[--muted]",children:"The all-in-one addon for Stremio. Configure your addon or manage this instance from the dashboard."})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[(0,r.jsx)(w,{intent:"primary",onClick:()=>{e({to:"/stremio/configure"})},children:"Configure"}),(0,r.jsx)(w,{intent:"primary-outline",onClick:()=>e({to:"/dashboard"}),children:"Dashboard"}),(0,r.jsx)(w,{intent:"gray-outline",onClick:()=>window.open("https://docs.aiostreams.viren070.me","_blank"),children:"Documentation"})]})]})}}),g7=(0,d.un)({getParentRoute:()=>A,path:"/login",beforeLoad:async()=>{let e=await g9.ensureQueryData(eP).catch(()=>null);if(e){let t=eO(new URLSearchParams(window.location.search).get("next"));if(!e.isAdmin&&t.startsWith("/dashboard"))return;throw(0,c.V2)({href:t})}},component:function(){let e=(0,o.jE)(),{status:t}=e$(),[s,a]=n.useState(""),[l,i]=n.useState(""),d=new URLSearchParams(window.location.search),c=n.useRef(d.get("error")).current,u=null==t?void 0:t.settings.oidc,m=(null==u?void 0:u.localLoginEnabled)!==!1,p=`/api/v1/auth/oidc/start?next=${encodeURIComponent(eO(d.get("next")))}`;n.useEffect(()=>{let e=c?eF[c]:void 0;if(e){x.oR.error(e.title,{description:e.description}),d.delete("error");let t=d.toString();window.history.replaceState(null,"",t?`?${t}`:window.location.pathname)}},[]),n.useEffect(()=>{(null==u?void 0:u.enabled)&&u.autoRedirect&&(d.has("local")||c||window.location.assign(p))},[null==u?void 0:u.enabled,null==u?void 0:u.autoRedirect]);let{mutate:h,isPending:g}=(0,eE.n)({mutationFn:e=>{let{username:t,password:s}=e;return eo(t,s)},onSuccess:t=>{e.setQueryData(eP.queryKey,t);let s=new URLSearchParams(window.location.search);window.location.href=eO(s.get("next"))},onError:e=>{e instanceof el&&e.is("UNAUTHORIZED")?x.oR.error("Invalid username or password"):e instanceof el&&e.is("RATE_LIMIT_EXCEEDED")?x.oR.error("Too many attempts. Please try again later."):x.oR.error(e instanceof Error?e.message:"Failed to log in")}});return(0,r.jsx)("main",{className:"min-h-screen flex items-center justify-center px-6",children:(0,r.jsxs)(X,{className:"w-full max-w-sm p-6",children:[(0,r.jsxs)("div",{className:"flex flex-col items-center gap-2 mb-6",children:[(0,r.jsx)("img",{src:"/logo.png",alt:"AIOStreams",className:"max-h-[60px] object-contain"}),(0,r.jsx)("h1",{className:"text-xl font-semibold",children:"Sign in"}),(0,r.jsx)("p",{className:"text-sm text-[--muted] text-center",children:"Log in to access this AIOStreams instance."}),m&&(0,r.jsxs)("p",{className:"text-xs text-[--muted] text-center",children:["Use a username and password from your instance's"," ",(0,r.jsx)("code",{className:"text-[--foreground]",children:"AIOSTREAMS_AUTH"})," ","environment variable"]})]}),(null==u?void 0:u.enabled)&&(0,r.jsxs)("div",{className:"flex flex-col gap-4 mb-4",children:[(0,r.jsx)(w,{intent:"primary-outline",className:"w-full",onClick:()=>window.location.assign(p),children:u.buttonLabel}),m&&(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{className:"h-px flex-1 bg-[--border]"}),(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:"or"}),(0,r.jsx)("span",{className:"h-px flex-1 bg-[--border]"})]})]}),m&&(0,r.jsxs)("form",{onSubmit:e=>{e.preventDefault(),s&&l&&h({username:s,password:l})},className:"flex flex-col gap-4",children:[(0,r.jsx)(W,{label:"Username",id:"username",name:"username",autoComplete:"username",autoCapitalize:"none",spellCheck:!1,value:s,required:!0,autoFocus:!0,placeholder:"Enter your username",onValueChange:a}),(0,r.jsx)(Z,{label:"Password",id:"password",name:"password",value:l,required:!0,placeholder:"Enter your password",onValueChange:i}),(0,r.jsx)(w,{type:"submit",intent:"primary",loading:g,disabled:g,className:"w-full",children:"Sign in"})]})]})})}}),fe=(0,d.un)({getParentRoute:()=>A,path:"/oauth/callback/gdrive",component:function(){let{mutate:e,isPending:t,data:s,error:a}=(0,eE.n)({mutationFn:e=>eR(e)});(0,n.useEffect)(()=>{let t=new URLSearchParams(window.location.search),s=t.get("error"),a=t.get("code");!s&&a&&e(a)},[]);let l=async()=>{(null==s?void 0:s.refreshToken)&&await rm(s.refreshToken,{onSuccess:()=>x.oR.success("Copied!"),onError:()=>x.oR.error("Failed to copy")})},i=new URLSearchParams(window.location.search).get("error")||(a?a.message:new URLSearchParams(window.location.search).get("code")?null:"No authorization code found in URL");return t?(0,r.jsx)(R,{showSpinner:!0,children:(0,r.jsx)(dt,{words:"Processing OAuth callback...",className:"text-2xl"})}):i?(0,r.jsx)(R,{showSpinner:!1,children:(0,r.jsx)(N,{title:"OAuth Error",showRefreshButton:!0,children:(0,r.jsx)("p",{children:i})})}):(0,r.jsx)("div",{className:"flex items-center justify-center min-h-screen p-4",children:(0,r.jsxs)(X,{className:"w-full max-w-lg p-6",children:[(0,r.jsx)("h1",{className:"text-2xl font-bold mb-4",children:"Google Drive Authorisation"}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"text-[--muted] space-y-2",children:[(0,r.jsx)("p",{children:"Authorisation successful! Please follow these steps:"}),(0,r.jsxs)("ol",{className:"list-decimal list-inside space-y-1",children:[(0,r.jsx)("li",{children:"Copy the refresh token below"}),(0,r.jsx)("li",{children:"Return to the previous tab"}),(0,r.jsx)("li",{children:"Paste the refresh token into the Refresh Token field"})]})]}),(null==s?void 0:s.refreshToken)&&(0,r.jsx)("div",{className:"relative",children:(0,r.jsxs)("div",{className:"p-4 pr-12 bg-[--subtle] rounded-md relative",children:[(0,r.jsx)("p",{className:"text-sm font-mono break-all",children:s.refreshToken
63}),(0,r.jsx)(E,{icon:(0,r.jsx)(tC.Xpf,{}),intent:"primary-subtle",className:"absolute top-1/2 -translate-y-1/2 right-2",onClick:l,"aria-label":"Copy authorization code"})]})})]})]})})}}),ft=(0,d.un)({getParentRoute:()=>A,path:"/splashscreen",component:function(){return(0,r.jsxs)(R,{showSpinner:!1,children:[(0,r.jsx)("img",{src:"/logo_2.png",alt:"Launching...",width:180,height:180,className:"animate-pulse"}),"Launching..."]})}});async function fs(e){var t;let{location:s}=e,a=await g9.ensureQueryData(eD).catch(()=>null);if((null==a||null==(t=a.settings)?void 0:t.protected)&&!await g9.ensureQueryData(eP).catch(()=>null))throw(0,c.V2)({to:"/login",search:{next:s.href}})}let fa=(0,d.un)({getParentRoute:()=>A,path:"/stremio/configure",beforeLoad:fs,component:g4}),fr=(0,d.un)({getParentRoute:()=>A,path:"/stremio/$uuid/$encryptedPassword/configure",beforeLoad:fs,component:g4}),fn=(0,d.un)({getParentRoute:()=>A,path:"/dashboard",beforeLoad:async e=>{let{location:t}=e,s=await g9.ensureQueryData(eP).catch(()=>null);if(!s)throw(0,c.V2)({to:"/login",search:{next:t.href}});if(!s.isAdmin)throw(0,c.V2)({to:"/login",search:{next:t.href,error:"forbidden"}})},component:function(){let{signOut:e}=tS(),{pathname:t}=(0,ez.z)(),s=(0,M.Z)(),a=tN({title:"Sign Out",description:"Are you sure you want to sign out?",onConfirm:async()=>{await e(),window.location.href="/login"}}),n=tI.map(e=>{let a=tE[e.href];if(a){let r=t.startsWith(e.href);return{name:e.label,iconType:e.icon,isCurrent:r,expanded:r,onClick:()=>s({to:e.href}),subItems:a.map(a=>({name:a.label,iconType:a.icon,isCurrent:t===`${e.href}/${a.id}`,onClick:()=>s({to:`${e.href}/${a.id}`})}))}}return{name:e.label,iconType:e.icon,isCurrent:t===e.href||t===`${e.href}/`,onClick:()=>s({to:e.href})}}),l=[{name:"Configure",iconType:tC.Wyp,onClick:()=>s({to:"/stremio/configure"})},{name:"Sign Out",iconType:tC.eZR,onClick:()=>a.open()}];return(0,r.jsxs)(tD,{children:[(0,r.jsxs)(e8,{children:[(0,r.jsxs)(eY,{withSidebar:!0,sidebarSize:"slim",children:[(0,r.jsx)(eJ,{children:(0,r.jsx)(tb,{header:(0,r.jsx)(a5,{}),items:n,footerItems:l})}),(0,r.jsx)(eY,{children:(0,r.jsxs)(eZ,{children:[(0,r.jsxs)("div",{"data-dashboard-top-navbar":!0,className:"lg:hidden w-full h-[5rem] relative overflow-hidden flex items-center gap-3 px-4",children:[(0,r.jsx)(e9,{}),(0,r.jsx)(a4,{}),(0,r.jsx)(t_,{})]}),(0,r.jsx)(m.s,{})]})})]}),(0,r.jsx)(tk,{...a})]}),(0,r.jsx)(aQ,{})]})}}),fl=(0,d.un)({getParentRoute:()=>fn,path:"/",component:function(){var e,t,s,a;let l=(0,eU.I)({queryKey:["dashboard","overview"],queryFn:()=>ei("/dashboard/analytics/overview"),staleTime:3e4}),i=(0,eU.I)({queryKey:["dashboard","tasks"],queryFn:()=>ei("/dashboard/tasks"),refetchInterval:1e4}),o=(0,eU.I)({queryKey:["dashboard","overview","logs"],queryFn:()=>ei("/dashboard/logs?order=desc&limit=10&level=error,warn"),refetchInterval:15e3}),{metrics:d}=lH(),c=n.useMemo(()=>{var e;let t=(null==(e=i.data)?void 0:e.tasks)??[];return 0===t.length?null:Math.round(t.filter(e=>"error"===e.lastStatus).length/t.length*100)},[i.data]),u=n.useMemo(()=>{var e;let t=((null==(e=i.data)?void 0:e.tasks)??[]).filter(e=>e.lastRunAt);return t.sort((e,t)=>(t.lastRunAt??0)-(e.lastRunAt??0)),t.slice(0,5)},[i.data]);return(0,r.jsxs)(ru,{className:"space-y-6 p-4 sm:p-8",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"Dashboard"}),(0,r.jsx)("p",{className:"text-[--muted]",children:"Live overview of this AIOStreams instance."})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[(0,r.jsx)(o6,{label:"Users",value:(null==(e=l.data)?void 0:e.totalUsers)??"—",hint:l.data?`+${l.data.newUsers.d1} today \xb7 +${l.data.newUsers.d7} this week`:void 0}),(0,r.jsx)(o6,{label:"Active 24h",value:(null==(t=l.data)?void 0:t.activeUsers.d1)??"—",hint:l.data?`${l.data.activeUsers.d7} this week`:void 0}),(0,r.jsx)(o6,{label:"Requests 24h",value:(null==(s=l.data)?void 0:s.requests24h)??"—"}),(0,r.jsx)(o6,{label:"Task failures",value:null==c?"—":`${c}%`,intent:null==c?void 0:c>0?"err":"ok",hint:i.data?`${i.data.tasks.length} tasks tracked`:void 0})]}),d&&(0,r.jsxs)(X,{className:"p-4 flex flex-wrap items-center gap-x-6 gap-y-2 text-sm",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-[--muted]",children:"uptime"}),(0,r.jsx)("span",{children:(a=d.process.uptimeSec)?ry(a):"0m"})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-[--muted]",children:"CPU"}),(0,r.jsxs)("span",{className:"tabular-nums",children:[d.cpu.total,"%"]}),null!=d.cpu.process&&(0,r.jsxs)("span",{className:"text-xs text-[--muted]",children:["(proc ",d.cpu.process,"%)"]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-[--muted]",children:"memory"}),(0,r.jsxs)("span",{className:"tabular-nums",children:[Math.round(d.memory.used/d.memory.total*100),"%"]})]}),d.lifecycleEnabled&&(0,r.jsx)("span",{className:"text-[10px] uppercase px-1.5 py-0.5 rounded bg-emerald-500/10 text-emerald-500 border border-emerald-500/20",children:"lifecycle enabled"})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[(0,r.jsxs)(X,{className:"p-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,r.jsxs)("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[(0,r.jsx)(tC.grf,{})," Recent task runs"]}),(0,r.jsx)(o2.N_,{to:"/dashboard/tasks",className:"text-xs text-[--muted] hover:text-[--foreground]",children:"View all →"})]}),(0,r.jsx)(lh,{query:i,errorTitle:"Failed to load tasks",children:()=>0===u.length?(0,r.jsx)("p",{className:"text-xs text-[--muted] italic",children:"No task runs yet."}):(0,r.jsx)("ul",{className:"space-y-1.5 text-sm",children:u.map(e=>(0,r.jsxs)("li",{className:"flex items-center gap-2 justify-between",children:[(0,r.jsx)("span",{className:"truncate",children:e.label}),(0,r.jsxs)("span",{className:"flex items-center gap-2 text-xs text-[--muted]",children:[(0,r.jsx)("span",{className:b("inline-block w-2 h-2 rounded-full","ok"===e.lastStatus&&"bg-emerald-500","error"===e.lastStatus&&"bg-red-500","skipped"===e.lastStatus&&"bg-amber-500",!e.lastStatus&&"bg-[--muted]")}),(0,r.jsx)("span",{children:(e=>{if(!e)return"never";let t=(Date.now()-e)/1e3;return t<0?`in ${ry(-t)}`:`${ry(t)} ago`})(e.lastRunAt)}),null!=e.lastDurationMs&&(0,r.jsxs)("span",{children:["\xb7 ",e.lastDurationMs,"ms"]})]})]},e.id))})})]}),(0,r.jsxs)(X,{className:"p-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,r.jsxs)("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[(0,r.jsx)(tC.m4U,{})," Recent warnings & errors"]}),(0,r.jsx)(o2.N_,{to:"/dashboard/logs",className:"text-xs text-[--muted] hover:text-[--foreground]",children:"View all →"})]}),(0,r.jsx)(lh,{query:o,errorTitle:"Failed to load recent logs",children:e=>e.logs.length?(0,r.jsx)("ul",{className:"space-y-1 text-xs",children:e.logs.slice(0,8).map(e=>{let t=function(e){try{let t=JSON.parse(e),s="string"==typeof t.level?t.level:"info",a="string"==typeof t.module?t.module:void 0,r="string"==typeof t.msg?t.msg:e;return{level:s,module:a,msg:r}}catch{return{level:"info",msg:e}}}(e.line);return(0,r.jsxs)("li",{className:"truncate",title:e.line,children:[(0,r.jsx)("span",{className:b("inline-block w-1.5 h-1.5 rounded-full align-middle mr-1.5","error"===t.level||"fatal"===t.level?"bg-red-500":"bg-amber-500")}),t.module&&(0,r.jsxs)("span",{className:"text-[--muted-highlight] font-mono",children:["[",t.module,"]"," "]}),(0,r.jsx)("span",{className:"text-[--foreground]",children:t.msg})]},e.seq)})}):(0,r.jsx)("p",{className:"text-xs text-[--muted] italic",children:"No recent warnings."})})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-sm font-semibold mb-3",children:"Sections"}),(0,r.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3",children:o3.map(e=>{let{to:t,label:s,desc:a,icon:n}=e;return(0,r.jsx)(o2.N_,{to:t,className:"block group",children:(0,r.jsxs)(X,{className:"p-4 h-full transition-colors group-hover:border-brand/40 group-hover:bg-brand/5",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,r.jsx)(n,{className:"text-[--muted] group-hover:text-brand"}),(0,r.jsx)("span",{className:"font-medium",children:s})]}),(0,r.jsx)("p",{className:"text-xs text-[--muted]",children:a})]})},t)})})]})]})}}),fi=(0,d.un)({getParentRoute:()=>fn,path:"analytics",component:function(){let[e,t]=n.useState("7d"),[s,a]=n.useState(null),l=(0,eU.I)({queryKey:["dashboard","analytics","overview"],queryFn:()=>ei("/dashboard/analytics/overview"),staleTime:3e4}),i=(0,eU.I)({queryKey:["dashboard","analytics","users",e],queryFn:()=>ei(`/dashboard/analytics/users?range=${e}`),staleTime:3e4}),o=(0,eU.I)({queryKey:["dashboard","analytics","requests",e],queryFn:()=>ei(`/dashboard/analytics/requests?range=${e}`),staleTime:3e4}),d=(0,eU.I)({queryKey:["dashboard","analytics","addons",e],queryFn:()=>ei(`/dashboard/analytics/addons?range=${e}`),staleTime:3e4}),c=(0,eU.I)({queryKey:["dashboard","analytics","features",e],queryFn:()=>ei(`/dashboard/analytics/features?range=${e}`),staleTime:3e4}),u=l.data;return(0,r.jsxs)(ru,{className:"p-4 sm:p-8 space-y-6",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"Analytics"}),(0,r.jsx)("p",{className:"text-[--muted]",children:"Usage, requests and addon health. Only anonymized IP prefixes (first 3 octets) are stored."})]}
63),(0,r.jsx)(lq,{value:e,onChange:t})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[(0,r.jsx)(lF,{label:"Configured users",value:u?(0,r.jsx)(lz,{value:u.totalUsers}):"—",hint:u?`+${rS(u.newUsers.d7)} this week`:""}),(0,r.jsx)(lF,{label:"New users (24h)",value:u?(0,r.jsx)(lz,{value:u.newUsers.d1}):"—",hint:u?`${rS(u.newUsers.d30)} in 30d`:""}),(0,r.jsx)(lF,{label:"Active users (24h)",value:u?(0,r.jsx)(lz,{value:u.activeUsers.d1}):"—",hint:u?`${rS(u.activeUsers.d7)} in 7d`:""}),(0,r.jsx)(lF,{label:"Requests (24h)",value:u?(0,r.jsx)(lz,{value:u.requests24h}):"—"})]}),(0,r.jsxs)(X,{className:"p-4",children:[(0,r.jsx)("h3",{className:"mb-3 text-sm font-semibold",children:"User growth"}),(0,r.jsx)(lh,{query:i,errorTitle:"Failed to load user analytics",children:e=>(0,r.jsx)(lL,{data:e.growth,xKey:"day",series:[{key:"total",label:"Total",color:"var(--brand)"},{key:"new",label:"New"}],height:260})})]}),(0,r.jsxs)(X,{className:"p-4",children:[(0,r.jsx)("h3",{className:"mb-3 text-sm font-semibold",children:"Requests by resource"}),(0,r.jsx)(lh,{query:o,errorTitle:"Failed to load request analytics",children:e=>(0,r.jsx)(lU,{data:e.series,xKey:"day",stacked:!0,series:e.resources.map(e=>({key:e})),height:260})})]}),(0,r.jsxs)(X,{className:"p-4",children:[(0,r.jsxs)("div",{className:"mb-3 flex items-center justify-between",children:[(0,r.jsxs)("h3",{className:"text-sm font-semibold",children:["Addon usage & errors"," ",(0,r.jsx)("span",{className:"text-[--muted] font-normal",children:"(marketplace defaults only)"})]}),d.data&&(0,r.jsxs)("span",{className:"text-xs text-[--muted]",children:[d.data.customEndpoints," custom endpoint",1===d.data.customEndpoints?"":"s"," excluded"]})]}),(0,r.jsx)(lh,{query:d,errorTitle:"Failed to load addon analytics",children:e=>e.addons.length?(0,r.jsxs)("div",{className:"grid lg:grid-cols-[1fr,240px] gap-6 items-center",children:[(0,r.jsx)("div",{className:"overflow-x-auto -mx-4 px-4 lg:mx-0 lg:px-0",children:(0,r.jsxs)("table",{className:"w-full text-sm min-w-[560px]",children:[(0,r.jsx)("thead",{className:"text-[--muted] text-xs uppercase",children:(0,r.jsxs)("tr",{className:"text-left border-b border-[--border]",children:[(0,r.jsx)("th",{className:"py-2 pr-3",children:"Addon"}),(0,r.jsx)("th",{className:"py-2 px-3 text-right",children:"Requests"}),(0,r.jsx)("th",{className:"py-2 px-3 text-right",children:"Share"}),(0,r.jsx)("th",{className:"py-2 px-3 text-right",children:"Errors"}),(0,r.jsx)("th",{className:"py-2 px-3 text-right",children:"Err %"}),(0,r.jsx)("th",{className:"py-2 pl-3 text-right",children:"Avg ms"})]})}),(0,r.jsx)("tbody",{children:e.addons.map(e=>(0,r.jsxs)("tr",{className:"border-b border-[--border]/50",children:[(0,r.jsx)("td",{className:"py-2 pr-3 font-medium",children:e.presetId}),(0,r.jsx)("td",{className:"py-2 px-3 text-right",children:(0,r.jsx)(lz,{value:e.requests})}),(0,r.jsxs)("td",{className:"py-2 px-3 text-right tabular-nums",children:[e.share,"%"]}),(0,r.jsx)("td",{className:"py-2 px-3 text-right tabular-nums",children:e.errors}),(0,r.jsxs)("td",{className:b("py-2 px-3 text-right tabular-nums",e.errorRate>10&&"text-red-500"),children:[e.errorRate,"%"]}),(0,r.jsx)("td",{className:"py-2 pl-3 text-right tabular-nums",children:e.avgLatencyMs??"—"})]},e.presetId))})]})}),(0,r.jsx)("div",{className:"mx-auto w-full max-w-[240px] aspect-square",children:(0,r.jsx)(l$,{data:e.addons.slice(0,6).map(e=>({name:e.presetId,value:e.requests})),centerLabel:"requests",centerValue:rS(e.total),height:240})})]}):(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"No addon data for this range."})})]}),(0,r.jsxs)(X,{className:"p-4",children:[(0,r.jsxs)("div",{className:"mb-3 flex items-center justify-between",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold",children:"Feature usage"}),(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:"distinct users per day, summed"})]}),(0,r.jsx)(lh,{query:c,errorTitle:"Failed to load feature analytics",children:e=>(0,r.jsxs)("div",{className:"grid lg:grid-cols-3 gap-6",children:[(0,r.jsx)(lB,{title:"Services",rows:e.service}),(0,r.jsx)(lB,{title:"Formatters",rows:e.formatter}),(0,r.jsx)(lB,{title:"Presets",rows:e.preset})]})})]}),(0,r.jsxs)(X,{className:"p-4",children:[(0,r.jsx)("h3",{className:"mb-3 text-sm font-semibold",children:"Most active users (hashed)"}),(0,r.jsx)(lh,{query:i,errorTitle:"Failed to load top users",children:e=>e.topUsers.length?(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsx)("table",{className:"w-full text-sm",children:(0,r.jsx)("tbody",{children:e.topUsers.map(e=>(0,r.jsxs)("tr",{className:"border-b border-[--border]/50",children:[(0,r.jsx)("td",{className:"py-1.5 font-mono text-xs text-[--muted] break-all",children:e.uuidHash.slice(0,16)}),(0,r.jsx)("td",{className:"py-1.5 pl-3 text-right whitespace-nowrap",children:(0,r.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,r.jsx)(lz,{value:e.requests}),(0,r.jsx)(to,{trigger:(0,r.jsx)("button",{onClick:()=>a(e.uuidHash),"aria-label":"View user activity",className:"text-[--muted] transition-colors hover:text-brand",children:(0,r.jsx)(nD.S8s,{className:"size-4"})}),children:"View activity"})]})})]},e.uuidHash))})})}):(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:"No data for this range."})})]}),(0,r.jsx)(lK,{uuidHash:s,range:e,onClose:()=>a(null)})]})}}),fo=(0,d.un)({getParentRoute:()=>fn,path:"logs",component:function(){let e=(0,n.useMemo)(rE,[]),[t,s]=(0,n.use
63State)(e.autoscroll),[a,l]=(0,n.useState)(e.wrap),[i,o]=(0,n.useState)(e.levels),[d,c]=(0,n.useState)(void 0),[u,m]=(0,n.useState)(""),[p,h]=(0,n.useState)(!1),g=rd(u,250),[f,v]=(0,n.useState)(new Set),y=tN({title:"Clear logs",description:"This permanently removes all retained logs. This cannot be undone.",actionText:"Clear",actionIntent:"alert-subtle",onConfirm:async()=>{try{await ei("POST /dashboard/logs/clear",{body:{confirm:!0}}),T(),x.oR.success("Logs cleared")}catch(e){x.oR.error((null==e?void 0:e.message)??"Failed to clear logs")}}}),j=(0,n.useMemo)(()=>{if(!p||!u)return null;try{return new RegExp(u),null}catch(e){return e instanceof Error?e.message:"Invalid regex"}},[p,u]);(0,n.useEffect)(()=>{localStorage.setItem(rI,JSON.stringify({autoscroll:t,wrap:a,levels:i}))},[t,a,i]);let k=(0,n.useMemo)(()=>({q:g,regex:p&&!j,levels:i,module:d}),[g,p,j,i,d]),{rows:S,loading:_,connected:R,error:A,clear:T,retry:I}=function(e){let[t,s]=(0,n.useState)([]),[a,r]=(0,n.useState)(!0),[l,i]=(0,n.useState)(!1),[o,d]=(0,n.useState)(null),[c,u]=(0,n.use
63State)(0),m=(0,n.useRef)(0),p=ri(e),h=(0,n.useCallback)(()=>u(e=>e+1),[]);return(0,n.useEffect)(()=>{let e=!1,t=null;return r(!0),d(null),s([]),m.current=0,(async()=>{try{let t=p?`&${p}`:"",a=await ei(`/dashboard/logs?order=asc&limit=2000${t}`);if(e)return;let r=a.logs.map(e=>rl(e.seq,e.line));s(r),m.current=r.length?r[r.length-1].seq:a.nextSeq}catch(t){e||d(t instanceof Error?t.message:"Failed to load logs")}finally{e||r(!1)}if(e)return;let a=`since=${m.current}${p?`&${p}`:""}`;(t=new EventSource(`/api/v1/dashboard/logs/stream?${a}`,{withCredentials:!0})).onopen=()=>!e&&i(!0),t.onerror=()=>!e&&i(!1),t.onmessage=t=>{if(e||!t.data)return;let a=Number(t.lastEventId);if(Number.isFinite(a)&&a<=m.current)return;Number.isFinite(a)&&(m.current=a);let r=rl(a||m.current,t.data);s(e=>{let t=e.length>=1e4?e.slice(1):e.slice();return t.push(r),t})}})(),()=>{e=!0,null==t||t.close(),i(!1)}},[p,c]),{rows:t,loading:a,connected:l,error:o,clear:(0,n.useCallback)(()=>s([]),[]),retry:h}}(k),[M,P]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let e=setTimeout(()=>P(!0),400);return()=>clearTimeout(e)},[]);let D=(0,n.useMemo)(()=>{let e=new Set;return S.forEach(t=>t.module&&e.add(t.module)),[{value:rT,label:"All modules"},...[...e].sort().map(e=>({value:e,label:e}))]},[S]),L=(0,n.useRef)(null),$=(0,n.useRef)(!0),[O,F]=(0,n.useState)(!0),z=(0,n.useRef)(0),V=(0,a9.T)({count:S.length,getScrollElement:()=>L.current,estimateSize:()=>30,overscan:20}),q=(0,n.useCallback)(()=>{let e=()=>{let e=L.current;e&&S.length&&(V.scrollToIndex(S.length-1,{align:"end"}),e.scrollTop=e.scrollHeight,z.current=e.scrollTop)};e(),requestAnimationFrame(()=>{e(),requestAnimationFrame(e)})},[S.length,V]);(0,n.useEffect)(()=>{M&&!_&&!A&&t&&$.current&&q()},[S.length,M,_,A,t,q]);let B=(0,n.useCallback)(()=>{let e=L.current;if(!e)return;let t=e.scrollTop,s=e.scrollHeight-t-e.clientHeight,a=t<z.current-2;z.current=t,s<80?$.current||($.current=!0,F(!0)):a&&$.current&&($.current=!1,F(!1))},[]),K=()=>(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(rs,{label:"Auto-scroll",labelClass:"whitespace-nowrap",side:"right",value:t,onValueChange:e=>{s(e),e&&($.current=!0,F(!0),q())}}),(0,r.jsx)(rs,{label:"Wrap",side:"right",value:a,onValueChange:l})]}),H=V.getVirtualItems();return(0,r.jsx)(ru,{className:"space-y-4 p-4 sm:p-8",children:(0,r.jsxs)("div",{className:"flex flex-col h-[calc(100vh-6rem)]",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"Logs"}),(0,r.jsxs)("p",{className:"text-[--muted]",children:["Live tail of recent logs."," ",(0,r.jsx)("span",{className:b("inline-block w-2 h-2 rounded-full align-middle",R?"bg-emerald-500":"bg-[--muted]")})," ",(0,r.jsxs)("span",{className:"text-xs",children:[R?"streaming":"disconnected"," \xb7 ",S.length," shown"]})]})]}),(0,r.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,r.jsx)(E,{size:"sm",intent:"gray-outline",icon:(0,r.jsx)(tC.id1,{}),"aria-label":"Clear logs",onClick:()=>y.open()}),(0,r.jsx)(w,{size:"sm",intent:"gray-outline",leftIcon:(0,r.jsx)(tC.Ah9,{}),onClick:()=>window.open(ro(k,"log"),"_blank"),children:".log"}),(0,r.jsx)(w,{size:"sm",intent:"gray-outline",leftIcon:(0,r.jsx)(tC.Ah9,{}),onClick:()=>window.open(ro(k,"json"),"_blank"),children:".json"})]})]}),(0,r.jsxs)(X,{className:"p-3 mb-3 flex flex-col gap-3",children:[(0,r.jsxs)("div",{className:"flex flex-wrap gap-3 items-center",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-[240px] flex flex-col gap-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)(W,{leftIcon:(0,r.jsx)(tC.iyI,{}),placeholder:p?"Regex pattern…":"Search all retained logs…",value:u,onValueChange:m,className:b("flex-1",j&&"border-red-500 focus-within:border-red-500")}),(0,r.jsx)("button",{type:"button",title:"Toggle regex search",onClick:()=>h(e=>!e),className:b("shrink-0 h-9 px-2 rounded-md border text-xs font-mono transition-colors",p&&!j?"border-brand bg-brand/10 text-brand":p&&j?"border-red-500 bg-red-500/10 text-red-500":"border-[--border] text-[--muted] hover:text-[--foreground] hover:border-[--foreground]"),children:".*"})]}),j&&(0,r.jsx)("p",{className:"text-xs text-red-500 pl-1",children:j})]}),(0,r.jsxs)("div",{className:"flex flex-1 md:flex-none items-center gap-2",children:[(0,r.jsx)("div",{className:"flex-1 md:min-w-[180px]",children:(0,r.jsx)(rn,{options:D,value:d??rT,onValueChange:e=>c(e===rT?void 0:e)})}),(0,r.jsx)("div",{className:"lg:hidden shrink-0",children:(0,r.jsx)(U,{trigger:(0,r.jsx)(E,{size:"sm",intent:"gray-outline",icon:(0,r.jsx)(tC.voe,{}),"aria-label":"Log view options"}),children:(0,r.jsx)("div",{className:"flex flex-col gap-4 p-1 min-w-[180px]",children:K()})})})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2 items-center",children:[r_.map(e=>(0,r.jsx)("button",{onClick:()=>o(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),className:b("px-2 py-0.5 rounded text-xs uppercase font-semibold border transition-colors",i.includes(e)?"border-brand bg-brand/10":"border-[--border] text-[--muted] hover:text-[--foreground]",i.includes(e)&&rR[e]),children:e},e)),(0,r.jsx)("div",{className:"flex-1"}),(0,r.jsx)("div",{className:"hidden lg:flex items-center gap-5",children:K()})]})]}),(0,r.jsxs)(X,{className:"flex-1 relative overflow-hidden p-0",children:[(!M||_)&&(0,r.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-3 z-10",children:[(0,r.jsx)(C,{className:"w-8 h-8"}),(0,r.jsx)("p",{className:"text-[--muted] text-sm",children:"Loading logs…"})]}),A&&M&&!_&&(0,r.jsx)("div",{className:"absolute inset-0 flex items-center justify-center z-10",children:(0,r.jsx)(N,{title:"Failed to load logs",reset:I,children:(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:A})})}),M&&!_&&!A&&0===S.length&&(0,r.jsx)("div",{className:"absolute inset-0 flex items-center justify-center text-[--muted] text-sm",children:"No logs match the current filters."}),(0,r.jsx)("div",{ref:L,onScroll:B,className:"h-full overflow-auto",children:M&&!_&&!A&&(0,r.jsx)("div",{style:{height:V.getTotalSize(),position:"relative"},children:H.map(e=>{let t=S[e.index];return(0,r.jsx)("div",{"data-index":e.index,ref:V.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${e.start}px)`},children:(0,r.jsx)(rP,{row:t,wrap:a,expanded:f.has(t.seq),onToggle:()=>{let e;return e=t.seq,v(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})}})},t.seq)})})}),t&&!O&&(0,r.jsx)(w,{size:"sm",intent:"primary",className:"absolute bottom-4 right-4 shadow-lg",leftIcon:(0,r.jsx)(tC.oVj,{}),onClick:()=>{$.current=!0,F(!0),q()},children:"Jump to latest"})]}),(0,r.jsx)(tk,{...y})]})})}}),fd=(0,d.un)({getParentRoute:()=>fn,path:"system",component:function(){let{metrics:e,connected:t,history:s,windowMs:a,error:l,retry:i}=lH(),[o,d]=n.useState("system"),[c,u]=n.useState("average"),[m,p]=n.useState(!1),h=tN({title:"Stop AIOStreams",description:"This halts the AIOStreams process only (never the host). It stays down until something starts it again.",actionText:"Stop",actionIntent:"alert-subtle",onConfirm:()=>{p(!0),ei("POST /dashboard/system/stop",{body:{confirm:"STOP"}}).then(()=>{x.oR.success("Process stopping — it stays down until something starts it again.")}).catch(e=>{x.oR.error((null==e?void 0:e.message)??"Failed to stop")}).finally(()=>p(!1))}});if(!e)return l?(0,r.jsx)(ru,{className:"p-4 sm:p-8",children:(0,r.jsx)(lp,{title:"Failed to load system metrics",message:l,onRetry:i})}):(0,r.jsx)(ru,{className:"p-4 sm:p-8",children:(0,r.jsx)(lm,{})});let g=e.memory.used/e.memory.total*100,f=e.disk?e.disk.used/e.disk.total*100:0,b=function(e,t,s){var a;let r=e=>{let t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}
63:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}`};if("process"===t||"average"===s){let s="process"===t?"process":"total";return{data:e.map(e=>({t:r(e.ts),[s]:e[s]})),series:[{key:s,label:"process"===t?"Process":"System"}]}}let n=(null==(a=e.at(-1))?void 0:a.perCore.length)??0;return{data:e.map(e=>{let t={t:r(e.ts)};for(let s=0;s<n;s++)t[`c${s}`]=e.perCore[s]??0;return t}),series:Array.from({length:n},(e,t)=>({key:`c${t}`,label:`Core ${t}`}))}}(s,o,c),v="process"===o?e.cpu.process??0:e.cpu.total;return(0,r.jsxs)(ru,{className:"p-4 sm:p-8 space-y-6",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"System"}),(0,r.jsxs)("p",{className:"text-[--muted]",children:[(0,r.jsx)("span",{className:`inline-block w-2 h-2 rounded-full align-middle ${t?"bg-emerald-500":"bg-[--muted]"}`})," ",(0,r.jsx)("span",{className:"text-xs",children:t?"live":"reconnecting"})]})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(w,{intent:"alert-outline",size:"sm",disabled:!e.lifecycleEnabled||m,loading:m,leftIcon:(0,r.jsx)(tC.ES$,{}),onClick:h.open,children:"STOP"}),(0,r.jsx)(tk,{...h})]})]}),!e.lifecycleEnabled&&(0,r.jsx)(nU,{intent:"info",description:"Stop is disabled. Set SYSTEM_LIFECYCLE_ENABLED=true to enable process lifecycle controls."}),(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[(0,r.jsx)(lG,{label:"CPU",pct:e.cpu.total,detail:`${e.cpu.cores} cores${e.cpu.loadavg?` \xb7 load ${e.cpu.loadavg[0].toFixed(2)}`:""}`}),(0,r.jsx)(lG,{label:"Memory",pct:g,detail:`${rx(e.memory.used)} / ${rx(e.memory.total)}`}),(0,r.jsx)(lG,{label:"Disk (data)",pct:f,detail:e.disk?`${rx(e.disk.used)} / ${rx(e.disk.total)}`:"unavailable"})]}),(0,r.jsxs)(X,{className:"p-4",children:[(0,r.jsxs)("div",{className:"flex items-start sm:items-center justify-between flex-col sm:flex-row gap-2 mb-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-sm font-semibold",children:"CPU utilisation"}),(0,r.jsxs)("p",{className:"text-xs text-[--muted]",children:["Last ",Math.round(a/6e4)," minutes \xb7 live \xb7 now"," ",(0,r.jsxs)("span",{className:"text-[--foreground] tabular-nums",children:[v,"%"]})]})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(lW,{value:o,onChange:e=>{d(e),"process"===e&&"per-core"===c&&u("average")},options:[{value:"system",label:"System"},{value:"process",label:"Process"}]}),(0,r.jsx)(lW,{value:c,onChange:u,options:[{value:"average",label:"Average"},{value:"per-core",label:"Per-core",disabled:"process"===o,title:"process"===o?"Process CPU is reported as a single aggregate — per-core is only available for system scope.":void 0}]})]})]}),(0,r.jsx)(lD,{data:b.data,xKey:"t",series:b.series,height:220,hideLegend:"per-core"!==c||"process"===o,valueFormatter:e=>`${e}%`})]}),(0,r.jsxs)(X,{className:"p-4",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold mb-3",children:"Process"}),(0,r.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[["Uptime",ry(e.process.uptimeSec)],["Node",e.process.nodeVersion],["PID",String(e.process.pid)],["Heap",rx(e.memory.heapUsed)],["RSS",rx(e.memory.rss)],["Platform",e.process.platform]].map(e=>{let[t,s]=e;return(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs text-[--muted]",children:t}),(0,r.jsx)("div",{className:"font-medium break-all",children:s})]},t)})})]})]})}}),fc=e=>"string"==typeof e&&e?e:void 0,fu=(0,d.un)({getParentRoute:()=>fn,path:"settings",validateSearch:e=>({tab:fc(e.tab),field:fc(e.field)}),component:function(){let{data:e,isLoading:t,error:s,refetch:a}=aF(),l=n.useMemo(()=>e?function(e){let t=new Map;for(let s of e){let e=aM(s.key);(t.get(e)??t.set(e,[]).get(e)).push(s)}let s=[];for(let[e,a]of t){let t=aI[e]??{label:aU(e),icon:aD,group:"Other",order:9999},r=t.sections?[...a].sort((t,s)=>aP(e,t.key)-aP(e,s.key)):a,n=new Map;for(let t of r){let s=function(e,t){var s;let a=null==(s=aI[e])?void 0:s.sections,r=t.split(".").slice(0,-1),n=a?function(e){if(0===e.length)return 0;let t=e[0].split("."),s=0;for(;s<t.length&&e.every(e=>e.split(".")[s]===t[s]);)s++;return s}(a):1;return r.slice(n).join(".")}(e,t.key);(n.get(s)??n.set(s,[]).get(s)).push(t)}s.push({section:e,...t,groups:n})}return s.sort((e,t)=>
63e.order-t.order||e.label.localeCompare(t.label))}(e.keys):[],[e]),i=(0,rD.S)({from:"/dashboard/settings"}),o=(0,M.Z)({from:"/dashboard/settings"}),[d,c]=n.useState("");n.useEffect(()=>{var e;if(!l.length)return;let t=i.tab?aI[e=i.tab]?e:aE.get(e)??e:void 0;t&&l.some(e=>e.section===t)?c(t):d||c(l[0].section)},[l,i.tab]);let u=n.useCallback(()=>{o({to:".",search:e=>({...e,field:void 0}),replace:!0,resetScroll:!1})},[o]);if(a6(i.field,!!d&&l.length>0,u),t)return(0,r.jsx)(ru,{className:"p-8 flex items-center justify-center",children:(0,r.jsx)(C,{className:"w-8 h-8"})});if(s||!e)return(0,r.jsx)(ru,{className:"p-8",children:(0,r.jsx)(N,{title:"Failed to load settings",reset:()=>a(),children:(0,r.jsx)("p",{className:"text-sm text-[--muted]",children:String(s)})})});let m=new Map;for(let e of l)(m.get(e.group)??m.set(e.group,[]).get(e.group)).push(e);return(0,r.jsx)(ru,{className:"p-4 sm:p-8 space-y-4 relative",children:(0,r.jsxs)(rF,{value:d,onValueChange:e=>{c(e),o({to:".",search:t=>({...t,tab:e}),replace:!0,resetScroll:!1})},className:b("w-full grid grid-cols-1 lg:grid lg:grid-cols-[280px,1fr] gap-4"),triggerClass:b("text-base px-6 rounded-[--radius-md] w-fit lg:w-full rounded-lg border-0","data-[state=active]:bg-[--subtle] data-[state=active]:text-white","dark:hover:text-white","h-9 lg:justify-start px-3 transition-all duration-200 hover:bg-[--subtle]/50 hover:transform"),listClass:b("w-full flex flex-wrap lg:flex-nowrap h-fit","lg:block p-2 lg:p-0"),children:[(0,r.jsx)(rz,{className:"flex-wrap max-w-full lg:space-y-2 lg:sticky lg:top-4",children:(0,r.jsx)(nE,{children:(0,r.jsx)("div",{className:"overflow-x-none overflow-y-hidden rounded-[--radius-md] space-y-1 lg:space-y-3 flex justify-center flex-wrap lg:block",children:[...m.entries()].map(e=>{let[t,s]=e;return(0,r.jsxs)(X,{className:"lg:p-2 contents lg:block border-0 bg-transparent lg:border lg:bg-gray-950/5 dark:lg:bg-gray-950/40",children:[(0,r.jsx)("p",{className:"hidden lg:block px-3 py-1 text-[10px] uppercase tracking-wider text-[--muted] font-semibold",children:t}),s.map(e=>(0,r.jsxs)(rV,{value:e.section,className:"group",children:[(0,r.jsx)(e.icon,{className:"text-xl mr-3 transition-transform duration-200 group-hover:translate-x-0.5"}),e.label]},e.section))]},t)})})})}),(0,r.jsx)("div",{children:l.map(t=>(0,r.jsx)(rq,{value:t.section,className:"space-y-4 animate-in fade-in-0 slide-in-from-bottom-2 duration-300",children:d===t.section&&(0,r.jsx)(lu,{tab:t,allKeys:e.keys})},t.section))})]})})}}),fm=(0,d.un)({getParentRoute:()=>fn,path:"streams",component:function(){var e,t;let s=(0,M.Z)(),{pathname:a}=(0,ez.z)(),n=iz(),l=null==(e=n.data)?void 0:e.summary,i=i$(n.data),o=(null==(t=tT.find(e=>a===`/dashboard/streams/${e.id}`))?void 0:t.id)??"active";return(0,r.jsxs)(ru,{className:"space-y-6 p-4 sm:p-8",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"Streams"}),(0,r.jsx)("p",{className:"text-[--muted]",children:l?(0,r.jsxs)(r.Fragment,{children:[l.streaming," streaming \xb7 ",l.paused+l.idle," ","paused \xb7"," ",(0,r.jsx)(iP,{value:l.totalBytesPerSec,format:rg,durationSec:i/1e3})]}):"Everything being served through the proxy and the usenet engine"})]}),(0,r.jsx)(iH,{})]}),(0,r.jsx)(lX,{sections:tT,value:o,onChange:e=>s({to:`/dashboard/streams/${e}`})}),(0,r.jsx)("div",{className:"min-w-0",children:(0,r.jsx)(th.P.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.18,ease:"easeOut"},children:(0,r.jsx)(m.s,{})},a)})]})}}),fp=(0,d.un)({getParentRoute:()=>fm,path:"/",beforeLoad:()=>{throw(0,c.V2)({to:"/dashboard/streams/active"})}}),fh=(0,d.un)({getParentRoute:()=>fm,path:"active",component:function(){var e,t;let s=iz(),a=i$(s.data),l=(null==(e=s.data)?void 0:e.streams)??[],i=null==(t=s.data)?void 0:t.summary,[o,d]=n.useState(null),[c,u]=n.useState(()=>Date.now());return n.useEffect(()=>{let e=setInterval(()=>u(Date.now()),1e3);return()=>clearInterval(e)},[]),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-3",children:[(0,r.jsx)(lF,{label:"Streaming",value:String((null==i?void 0:i.streaming)??0),hint:(null==i?void 0:i.connectionLimit)?`Pushing bytes right now \xb7 ${i.connectionLimit} concurrent streams allowed`:"Pushing bytes right now"}),(0,r.jsx)(lF,{label:"Paused",value:String(((null==i?void 0:i.paused)??0)+((null==i?void 0:i.idle)??0)),hint:"Connected or waiting, but nothing moving"}),(0,r.jsx)(lF,{label:"Combined speed",className:"col-span-2 lg:col-span-1",value:(0,r.jsx)(iP,{value:(null==i?void 0:i.totalBytesPerSec)??0,format:rg,durationSec:a/1e3})})]}),(0,r.jsx)(lh,{query:s,errorTitle:"Failed to load active streams",children:()=>0===l.length?(0,r.jsx)(X,{className:"p-8",children:(0,r.jsx)("p",{className:"text-center text-sm text-[--muted]",children:"Nothing streaming right now — rows appear as soon as a player starts pulling bytes through the proxy or the usenet engine."})}):(0,r.jsx)("div",{className:"space-y-2",children:l.map(e=>
63(0,r.jsx)(i6,{stream:e,now:c,frameMs:a,onBlock:d},e.id))})}),(0,r.jsx)(i5,{target:o,onClose:()=>d(null)})]})}}),fx=(0,d.un)({getParentRoute:()=>fm,path:"history",component:function(){var e,t;let s,[a,l]=n.useState("all"),[i,d]=n.useState(""),[c,u]=n.useState(1),[m,p]=n.useState(new Set);n.useEffect(()=>{u(1),p(new Set)},[a,i]);let h=function(e){let{limit:t=50,offset:s=0,username:a="",transport:r="",search:n=""}=e,l=n.trim(),i=new URLSearchParams({limit:String(t),offset:String(s)});return a&&i.set("username",a),r&&i.set("transport",r),l&&i.set("q",l),(0,eU.I)({queryKey:[...iD,"history",t,s,a,r,l],queryFn:()=>ei(`/dashboard/streams/history?${i.toString()}`),placeholderData:aV.rX,staleTime:1e4})}({limit:50,offset:(c-1)*50,transport:"all"===a?"":a,search:i}),g=(s=(0,o.jE)(),(0,eE.n)({mutationFn:e=>ei("DELETE /dashboard/streams/history",{body:e?{ids:e}:void 0}),onSuccess:()=>s.invalidateQueries({queryKey:[...iD,"history"]})})),f=(null==(e=h.data)?void 0:e.entries)??[],v=(null==(t=h.data)?void 0:t.total)??0,y=Math.max(1,Math.ceil(v/50)),j=f.length>0&&f.every(e=>m.has(e.id)),N=()=>{p(e=>{let t=new Set(e);if(j)for(let e of f)t.delete(e.id);else for(let e of f)t.add(e.id);return t})},k=(e,t)=>g.mutateAsync(e).then(e=>{x.oR.success(`${t} (${e.deleted})`),p(new Set),u(1)}).catch(e=>x.oR.error((null==e?void 0:e.message)??"Failed to delete")),S=tN({title:"Clear stream history",description:`Delete all ${v} finished stream${1===v?"":"s"}. Bandwidth totals are stored separately and are not affected.`,actionText:"Clear all",actionIntent:"alert-subtle",onConfirm:()=>void k(void 0,"History cleared")}),C=tN({title:"Delete selected streams",description:`Delete ${m.size} stream${1===m.size?"":"s"} from the history. Bandwidth totals are not affected.`,actionText:"Delete",actionIntent:"alert-subtle",onConfirm:()=>void k([...m],"Deleted")}),_=m.size>0;return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[(0,r.jsx)(W,{leftIcon:(0,r.jsx)(tC.iyI,{}),placeholder:"Search title or URL…",value:i,onValueChange:d,fieldClass:"sm:flex-1 sm:min-w-0"}),(0,r.jsx)(rn,{value:a,options:i9,onValueChange:e=>l(e),fieldClass:"sm:w-40 sm:shrink-0"}),(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2 sm:shrink-0",children:[(0,r.jsx)("span",{className:"text-xs tabular-nums text-[--muted]",children:_?`${m.size} selected`:`${v.toLocaleString()} ${1===v?"entry":"entries"}`}),(0,r.jsx)(w,{size:"sm",intent:"alert-subtle",leftIcon:(0,r.jsx)(tC.id1,{}),loading:g.isPending,disabled:0===v&&!_,onClick:()=>_?C.open():S.open(),children:_?"Delete selected":"Clear all"})]})]}),(0,r.jsx)(lh,{query:h,errorTitle:"Failed to load stream history",children:()=>0===f.length?(0,r.jsx)(X,{className:"p-8",children:(0,r.jsxs)("p",{className:"text-center text-sm text-[--muted]",children:["No finished streams",i||"all"!==a?" match this filter":" yet","."]})}):(0,r.jsxs)(X,{className:"overflow-hidden p-0",children:[(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{className:"bg-[--subtle]/40 text-xs uppercase text-[--muted]",children:(0,r.jsxs)("tr",{className:"text-left",children:[(0,r.jsx)("th",{className:"w-10 p-3",children:(0,r.jsx)(r6,{value:j,onValueChange:N,"aria-label":"Select all on this page"})}),(0,r.jsx)("th",{className:"p-3",children:"Stream"}),(0,r.jsx)("th",{className:"p-3",children:"User"}),(0,r.jsx)("th",{className:"p-3 text-right",children:"Served"}),(0,r.jsx)("th",{className:"p-3 text-right",children:"Reqs"}),(0,r.jsx)("th",{className:"p-3 text-right",children:"Duration"}),(0,r.jsx)("th",{className:"p-3",children:"Ended"})]})}),(0,r.jsx)("tbody",{children:f.map(e=>{let t=e.endReason?i4[e.endReason]:void 0,s=m.has(e.id);return(0,r.jsxs)("tr",{className:b("border-t border-[--border]/50 hover:bg-[--subtle]/30",s&&"bg-brand/[0.06]"),children:[(0,r.jsx)("td",{className:"p-3",children:(0,r.jsx)(r6,{value:s,onValueChange:()=>{var t;return t=e.id,void p(e=>{let s=new Set(e);return s.delete(t)||s.add(t),s})},"aria-label":"Select stream"})}),(0,r.jsx)("td",{className:"max-w-[420px] p-3",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(iW,{transport:e.transport}),(0,r.jsx)("span",{className:"truncate",title:e.filename||e.displayUrl||e.targetKey,children:e.filename||e.displayUrl||e.targetKey})]})}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{children:i0(e.username)}),e.clientIp&&(0,r.jsx)(iQ,{ip:e.clientIp})]})}),(0,r.jsx)("td",{className:"p-3 text-right tabular-nums",children:rx(e.bytesServed)}),(0,r.jsx)("td",{className:"p-3 text-right tabular-nums",children:e.requests}),(0,r.jsx)("td",{className:"p-3 text-right tabular-nums text-[--muted]",children:rk((e.endedAt??e.lastSeenAt)-e.startedAt)}),(0,r.jsx)("td",{className:"p-3 text-xs text-[--muted]",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[e.endedAt&&(0,r.jsx)("span",{className:"whitespace-nowrap",children:i1(e.endedAt)}),(null==t?void 0:t.className)&&(0,r.jsx)(iJ,{className:t.className,children:t.label})]})})]},e.id)})})]})}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 border-t border-[--border]/50 p-3 text-xs text-[--muted]",children:[(0,r.jsxs)("span",{className:"tabular-nums",children:["Showing ",(c-1)*50+1,"–",Math.min(50*c,v)," of ",v]}),y>1&&(0,r.jsxs)(ic,{children:[(0,r.jsx)(im,{direction:"previous",isDisabled:c<=1,onClick:()=>u(e=>Math.max(1,e-1))}),ih(c,y).map((e,t)=>"…"===e?(0,r.jsx)(ip,{},`e${t}`):(0,r.jsx)(iu,{value:e,"data-selected":e===c,onClick:()=>u(e)},e)),(0,r.jsx)(im,{direction:"next",isDisabled:c>=y,onClick:()=>u(e=>Math.min(y,e+1))})]})]})]})}),(0,r.jsx)(tk,{...S}),(0,r.jsx)(tk,{...C})]})}}),fg=(0,d.un)({getParentRoute:()=>fm,path:"bandwidth",component:function(){let[e,t]=n.useState("30d"),[s,a]=n.useState("total"),l=(0,eU.I)({queryKey:[...iD,"bandwidth",e],queryFn:()=>ei(`/dashboard/streams/bandwidth?window=${e}`),staleTime:15e3,refetchInterval:3e4}),i=l.data,o=(null==i?void 0:i.periodMode)==="monthly",d=n.useMemo(()=>
63{if(!i)return{rows:[],userSeries:[]};let e=function(e){let t=e.bucketMs>0?e.bucketMs:864e5,s=Math.floor(e.sinceMs/t)*t,a=Math.floor(e.generatedAt/t)*t,r=[];for(let e=s;e<=a&&r.length<400;e+=t)r.push(e);return r}(i),t=new Map(i.series.map(e=>[e.bucketMs,e.bytes])),s=i.seriesByUser.map((e,t)=>({key:`u${t}`,label:e.aggregated?"Others":i0(e.username),color:e.aggregated?"var(--muted)":lT[t%lT.length]})),a=i.seriesByUser.map(e=>new Map(e.series.map(e=>[e.bucketMs,e.bytes])));return{rows:e.map(e=>{var s;let r,n={t:(s=i.bucketMs,r=new Date(e),s<864e5?`${String(r.getHours()).padStart(2,"0")}:00`:i7.format(r)),at:i.bucketMs<864e5?ot.format(new Date(e)):oe.format(new Date(e)),bytes:t.get(e)??0};return a.forEach((t,s)=>{n[`u${s}`]=t.get(e)??0}),n}),userSeries:s}},[i]),c=o&&i?`since ${new Date(i.periodStart).toLocaleDateString()}`:"rolling 30 days",u=((null==i?void 0:i.globalLimit)??0)>0&&"30d"!==e;return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsx)("p",{className:"text-xs text-[--muted]",children:"Bytes served through AIOStreams. Unproxied links are not counted."}),(0,r.jsx)(iX,{value:e,onChange:t,options:[{value:"24h",label:"24h"},{value:"7d",label:"7d"},{value:"30d",label:o?"This month":"30d"}]})]}),(0,r.jsx)(lh,{query:l,errorTitle:"Failed to load bandwidth",children:e=>(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:b("grid grid-cols-2 gap-3",u?"lg:grid-cols-4":"lg:grid-cols-3"),children:[(0,r.jsx)(lF,{label:"Total",value:rx(e.total)}),(0,r.jsx)(lF,{label:"Usenet",value:rx(e.byTransport.usenet??0),hint:e.total>0?rb((e.byTransport.usenet??0)/e.total):void 0}),(0,r.jsx)(lF,{label:"Proxy",value:rx(e.byTransport.proxy??0),hint:e.total>0?rb((e.byTransport.proxy??0)/e.total):void 0}),u&&(0,r.jsx)(lF,{label:"This period",value:rx(e.periodTotal),hint:e.globalLimit>0?`of ${rx(e.globalLimit)} \xb7 ${c}`:c})]}),e.globalLimit>0&&(0,r.jsxs)(X,{className:"p-4",children:[(0,r.jsx)("h3",{className:"mb-3 text-sm font-semibold",children:"Shared bandwidth pool"}),(0,r.jsx)(os,{used:e.periodTotal,limit:e.globalLimit})]}),(0,r.jsxs)(X,{className:"p-4",children:[(0,r.jsxs)("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold",children:"Served over time"}),d.userSeries.length>0&&(0,r.jsx)(iX,{value:s,onChange:a,options:i8})]}),0===e.total?(0,r.jsx)("p",{className:"py-8 text-center text-sm text-[--muted]",children:"Nothing served in this window."}):"user"===s&&d.userSeries.length>0?(0,r.jsx)(lD,{data:d.rows,xKey:"t",series:d.userSeries,height:240,tooltipLabelKey:"at",valueFormatter:e=>rx(Number(e)),yTickFormatter:e=>rx(Number(e))}):(0,r.jsx)(lL,{data:d.rows,xKey:"t",series:[{key:"bytes",label:"Served",color:"var(--brand)"}],height:240,tooltipLabelKey:"at",valueFormatter:e=>rx(Number(e)),yTickFormatter:e=>rx(Number(e))})]}),(0,r.jsxs)(X,{className:"overflow-hidden p-0",children:[(0,r.jsx)("h3",{className:"p-4 pb-3 text-sm font-semibold",children:"By user"}),0===e.byUser.length?(0,r.jsx)("p",{className:"p-8 pt-0 text-center text-sm text-[--muted]",children:"No usage recorded in this window."}):(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{className:"bg-[--subtle]/40 text-xs uppercase text-[--muted]",children:(0,r.jsxs)("tr",{className:"text-left",children:[(0,r.jsx)("th",{className:"p-3",children:"User"}),(0,r.jsx)("th",{className:"p-3",children:"Usage this window"}),(0,r.jsx)("th",{className:"p-3 text-right",children:"Streams"})]})}),(0,r.jsx)("tbody",{children:e.byUser.map(e=>(0,r.jsxs)("tr",{className:"border-t border-[--border]/50",children:[(0,r.jsx)("td",{className:"p-3 font-medium",children:i0(e.username)}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsx)(os,{used:e.bytes,limit:e.limit})}),(0,r.jsx)("td",{className:"p-3 text-right text-xs tabular-nums text-[--muted]",children:e.connectionLimit>0?(0,r.jsx)(to,{trigger:(0,r.jsxs)("span",{children:["max ",e.connectionLimit]}),children:"Concurrent stream limit"}):"unlimited"})]},e.username||"(unidentified)"))})]})})]})]})})]})}}),ff=(0,d.un)({getParentRoute:()=>fm,path:"bans",component:function(){var e;let t,s=(0,eU.I)({queryKey:iU,queryFn:()=>ei("/dashboard/streams/bans"),staleTime:1e4}),a=(t=(0,o.jE)(),(0,eE.n)({mutationFn:e=>ei(`DELETE /dashboard/streams/bans/${encodeURIComponent(e)}`),onSuccess:()=>
63t.invalidateQueries({queryKey:iU})})),n=(null==(e=s.data)?void 0:e.bans)??[];return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsx)("p",{className:"text-xs text-[--muted]",children:"A block refuses new streams. Stopping a stream on its own only ends the current one — a player will reopen it."}),(0,r.jsx)(oa,{})]}),(0,r.jsx)(lh,{query:s,errorTitle:"Failed to load blocks",children:()=>0===n.length?(0,r.jsx)(X,{className:"p-8",children:(0,r.jsx)("p",{className:"text-center text-sm text-[--muted]",children:"No blocks in force."})}):(0,r.jsx)(X,{className:"overflow-hidden p-0",children:(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{className:"bg-[--subtle]/40 text-xs uppercase text-[--muted]",children:(0,r.jsxs)("tr",{className:"text-left",children:[(0,r.jsx)("th",{className:"p-3",children:"User"}),(0,r.jsx)("th",{className:"p-3",children:"Scope"}),(0,r.jsx)("th",{className:"p-3",children:"Reason"}),(0,r.jsx)("th",{className:"p-3",children:"Added"}),(0,r.jsx)("th",{className:"p-3",children:"Expires"}),(0,r.jsx)("th",{className:"p-3"})]})}),(0,r.jsx)("tbody",{children:n.map(e=>(0,r.jsxs)("tr",{className:"border-t border-[--border]/50 hover:bg-[--subtle]/30",children:[(0,r.jsx)("td",{className:"p-3 font-medium",children:e.username}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsx)(iJ,{children:"user"===e.scope?"All streams":"One title"})}),(0,r.jsx)("td",{className:"max-w-[280px] truncate p-3 text-[--muted]",children:e.reason||"—"}),(0,r.jsxs)("td",{className:"p-3 text-xs text-[--muted]",children:[i1(e.createdAt),e.createdBy?` by ${e.createdBy}`:""]}),(0,r.jsx)("td",{className:"p-3 text-xs text-[--muted]",children:function(e){if(!e.expiresAt)return"Until lifted";let t=e.expiresAt-Date.now();if(t<=0)return"Expired";let s=Math.round(t/6e4);if(s<60)return`${s}m left`;let a=Math.round(s/60);return a<48?`${a}h left`:`${Math.round(a/24)}d left`}(e)}),(0,r.jsx)("td",{className:"p-3 text-right",children:(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(tC.id1,{}),"aria-label":"Lift block",disabled:a.isPending,onClick:()=>a.mutateAsync(e.id).then(()=>x.oR.success("Block lifted")).catch(e=>x.oR.error((null==e?void 0:e.message)??"Failed to lift"))})})]},e.id))})]})})})})]})}}),fb=(0,d.un)({getParentRoute:()=>fn,path:"users",component:function(){let e=(0,o.jE)(),[t,s]=n.useState(1),[a,l]=n.useState(25),[i,d]=n.useState(""),[c,u]=n.useState("created_at"),[m,p]=n.useState("desc"),h=rd(i,300),[g,f]=n.useState(null),[b,v]=n.useState(new Set),[y,j]=n.useState(""),[N,k]=n.useState(!1),[S,C]=n.useState(1);n.useEffect(()=>C(t),[t]);let _=(0,eU.I)({queryKey:["dashboard","users",t,a,h,c,m],queryFn:()=>ei(`/dashboard/users?page=${t}&limit=${a}&q=${encodeURIComponent(h)}&sort=${c}&dir=${m}`),staleTime:1e4}),R=(0,eE.n)({mutationFn:e=>ei(`DELETE /dashboard/users/${e}`),onSuccess:()=>{x.oR.success("User config deleted."),e.invalidateQueries({queryKey:["dashboard","users"]})},onError:e=>x.oR.error((null==e?void 0:e.message)??"Delete failed")}),A=(0,eE.n)({mutationFn:e=>ei("DELETE /dashboard/users",{body:e}),onSuccess:t=>{x.oR.success(`Deleted ${t.deleted} user config${1===t.deleted?"":"s"}.`),v(new Set),e.invalidateQueries({queryKey:["dashboard","users"]})},onError:e=>x.oR.error((null==e?void 0:e.message)??"Batch delete failed")}),[T,I]=n.useState(null),M=tN({title:"Delete user config",description:"This permanently deletes this user configuration. This cannot be undone.",actionText:"Delete",actionIntent:"alert-subtle",onConfirm:()=>{T&&R.mutate(T)}}),P=tN({title:`Delete ${b.size} selected`,description:`This permanently deletes ${b.size} user configurations. This cannot be undone.`,actionText:"Delete",actionIntent:"alert-subtle",onConfirm:()=>A.mutate({uuids:[...b]}
63)}),D=async e=>{try{f(await ei(`/dashboard/users/${e}`))}catch(e){x.oR.error((null==e?void 0:e.message)??"Failed to load user")}},L=_.data,U=(null==L?void 0:L.items)??[],$=U.length>0&&U.every(e=>b.has(e.uuid)),O=U.some(e=>b.has(e.uuid))&&!$,F=e=>{v(t=>{let s=new Set(t);if(!0===e)for(let e of U)s.add(e.uuid);else for(let e of U)s.delete(e.uuid);return s})};return(0,r.jsxs)(ru,{className:"p-4 sm:p-8 space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"Users"}),(0,r.jsx)("p",{className:"text-[--muted]",children:L?`${L.total} configured users`:"Browse user configs"})]}),(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row gap-3 sm:items-center",children:[(0,r.jsx)(W,{leftIcon:(0,r.jsx)(tC.iyI,{}),placeholder:"Search by UUID…",value:i,onValueChange:e=>{d(e),s(1)},className:"flex-1"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-xs text-[--muted]",children:"Per page"}),(0,r.jsx)(rn,{value:String(a),options:lY.map(e=>({label:e,value:e})),onValueChange:e=>{l(Number(e)||25),s(1)},className:"w-24"})]})]}),b.size>0&&(0,r.jsxs)(X,{className:"p-3 flex flex-wrap items-center gap-3 border-brand/30 bg-brand/5",children:[(0,r.jsxs)("span",{className:"text-sm",children:[b.size," selected"]}),(0,r.jsx)(w,{size:"sm",intent:"gray-subtle",onClick:()=>v(new Set),children:"Clear"}),(0,r.jsx)(w,{size:"sm",intent:"alert-subtle",leftIcon:(0,r.jsx)(tC.id1,{}),loading:A.isPending,onClick:()=>P.open(),children:"Delete selected"}),h&&(0,r.jsx)(w,{size:"sm",intent:"alert-outline",onClick:()=>{j(""),k(!0)},children:"Delete all matching filter"})]}),(0,r.jsx)(lh,{query:_,errorTitle:"Failed to load users",children:()=>(0,r.jsx)(X,{className:"p-0 overflow-hidden",children:(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{className:"text-[--muted] text-xs uppercase bg-[--subtle]/40",children:(0,r.jsxs)("tr",{className:"text-left",children:[(0,r.jsx)("th",{className:"p-3 w-10",children:(0,r.jsx)(r6,{value:!!$||!!O&&"indeterminate",onValueChange:F,"aria-label":"Select all on page"})}),(0,r.jsx)("th",{className:"p-3",children:"UUID"}),[["created_at","Created"],["accessed_at","Last accessed"]].map(e=>{let[t,s]=e;return(0,r.jsxs)("th",{className:"p-3 cursor-pointer select-none",onClick:()=>{c===t?p(e=>"asc"===e?"desc":"asc"):(u(t),p("desc"))},children:[s,c===t?"asc"===m?" ▲":" ▼":""]},t)}),(0,r.jsx)("th",{className:"p-3 text-right",children:"Req 24h"}),(0,r.jsx)("th",{className:"p-3 text-right",children:"Actions"})]})}),(0,r.jsxs)("tbody",{children:[U.map(e=>(0,r.jsxs)("tr",{className:"border-t border-[--border]/50 hover:bg-[--subtle]/30",children:[(0,r.jsx)("td",{className:"p-3",children:(0,r.jsx)(r6,{value:b.has(e.uuid),onValueChange:t=>{var s;return s=e.uuid,void v(e=>{let a=new Set(e);return!0===t?a.add(s):a.delete(s),a})},"aria-label":`Select ${e.uuid}`})}),(0,r.jsxs)("td",{className:"p-3 font-mono text-xs cursor-pointer",title:e.uuid,onClick:()=>void rm(e.uuid,{onSuccess:()=>x.oR.success("UUID copied"),onError:()=>x.oR.error("Copy failed")}),children:[e.uuid.slice(0,8),"…",e.uuid.slice(-4)]}),(0,r.jsx)("td",{className:"p-3",children:rC(e.createdAt)}),(0,r.jsx)("td",{className:"p-3",children:rC(e.accessedAt)}),(0,r.jsx)("td",{className:"p-3 text-right tabular-nums",children:e.requests24h}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsxs)("div",{className:"flex justify-end gap-1",children:[(0,r.jsx)(E,{size:"sm",intent:"gray-subtle",icon:(0,r.jsx)(tC.wfp,{}),"aria-label":"Details",onClick:()=>D(e.uuid)}),(0,r.jsx)(E,{size:"sm",intent:"alert-subtle",icon:(0,r.jsx)(tC.id1,{}),"aria-label":"Delete",onClick:()=>{I(e.uuid),M.open()}})]})})]},e.uuid)),L&&0===U.length&&(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:6,className:"p-8 text-center text-[--muted]",children:"No users found."})})]})]})})})}),L&&(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsxs)("span",{className:"text-xs text-[--muted]",children:["Showing ",(L.page-1)*L.limit+ +(U.length>0),"–",Math.min(L.page*L.limit,L.total)," of ",L.total]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(w,{size:"sm",intent:"gray-outline",disabled:t<=1,onClick:()=>s(1),children:"\xab"}),(0,r.jsx)(w,{size:"sm",intent:"gray-outline",disabled:t<=1,onClick:()=>s(e=>Math.max(1,e-1)),children:"Prev"}),(0,r.jsxs)("div",{className:"flex items-center gap-1 text-xs text-[--muted]",children:["Page",(0,r.jsx)(nn,{value:S,min:1,max:Math.max(1,L.pages),onValueChange:e=>C(Number(e)||1),onKeyDown:e=>{"Enter"===e.key&&s(Math.max(1,Math.min(L.pages||1,Number(S)||1)))},className:"w-20"}),"/ ",L.pages||1]}),(0,r.jsx)(w,{size:"sm",intent:"gray-outline",disabled:t>=L.pages,onClick:()=>s(e=>Math.min(L.pages||1,e+1)),children:"Next"}),(0,r.jsx)(w,{size:"sm",intent:"gray-outline",disabled:t>=L.pages,onClick:()=>s(L.pages||1),children:"\xbb"})]})]}),(0,r.jsx)(ty,{open:!!g,onOpenChange:e=>!e&&f(null),title:"User detail",children:g&&(0,r.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs text-[--muted]",children:"UUID"}),(0,r.jsx)("div",{className:"font-mono break-all",children:g.uuid})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs text-[--muted]",children:"Created"}),rC(g.createdAt)]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs text-[--muted]",children:"Updated"}),rC(g.updatedAt)]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs text-[--muted]",children:"Last accessed"}),rC(g.accessedAt)]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs text-[--muted]",children:"Requests 24h"}),g.requests24h]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"text-xs text-[--muted] mb-1",children:"Recent error stages"}),g.recentErrorStages.length?(0,r.jsx)("ul",{className:"space-y-1",children:g.recentErrorStages.map(e=>(0,r.jsxs)("li",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:e.stage}),(0,r.jsx)("span",{className:"tabular-nums text-[--muted]",children:e.count})]},e.stage))}):(0,r.jsx)("span",{className:"text-[--muted]",children:"None"})]})]})}),(0,r.jsx)(tk,{...M}),(0,r.jsx)(tk,{...P}),(0,r.jsx)(ty,{open:N,onOpenChange:k,title:"Delete all users matching filter",footer:(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(w,{intent:"gray-outline",size:"sm",onClick:()=>k(!1),children:"Cancel"}),(0,r.jsx)(w,{intent:"alert-subtle",size:"sm",disabled:"DELETE"!==y||A.isPending,loading:A.isPending,onClick:()=>{A.mutate({allMatching:!0,q:h}),k(!1)},children:"Delete"})]}),children:(0,r.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,r.jsxs)("p",{children:["This permanently deletes ",(0,r.jsx)("strong",{children:"every"})," user configuration matching your current search (",(0,r.jsx)("code",{className:"font-mono",children:h||"<empty>"}),"). This cannot be undone."]}),(0,r.jsxs)("p",{className:"text-[--muted]",children:["Type ",(0,r.jsx)("code",{className:"font-mono",children:"DELETE"})," to confirm."]}),(0,r.jsx)(W,{value:y,onValueChange:j,placeholder:"DELETE"})]})})]})}}),fv=(0,d.un)({getParentRoute:()=>fn,path:"tasks",component:function(){let e=(0,o.jE)(),t=(0,eU.I)({queryKey:["dashboard","tasks"],queryFn:()=>ei("/dashboard/tasks"),refetchInterval:5e3}),s=(0,eE.n)({mutationFn:e=>{let{id:t,confirm:s}=e;return ei(`POST /dashboard/tasks/${t}/run`,{body:{confirm:s}})},onSuccess:t=>{x.oR.success((null==t?void 0:t.message)||"Task finished"),e.invali
63dateQueries({queryKey:["dashboard","tasks"]})},onError:e=>x.oR.error((null==e?void 0:e.message)??"Task failed")}),[a,l]=n.useState(null),i=tN({title:"Run destructive task",description:"This task is destructive and cannot be undone. Run it now?",actionText:"Run",actionIntent:"alert-subtle",onConfirm:()=>a&&s.mutate({id:a,confirm:!0})});return(0,r.jsxs)(ru,{className:"p-4 sm:p-8 space-y-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"Tasks"}),(0,r.jsx)("p",{className:"text-[--muted]",children:"Background & scheduled work. Run manual tasks on demand."})]}),(0,r.jsx)(lh,{query:t,errorTitle:"Failed to load tasks",children:e=>(0,r.jsx)("div",{className:"space-y-6",children:(e=>{let t=new Map;for(let s of e)(t.get(s.category)??t.set(s.category,[]).get(s.category)).push(s);return[...t.entries()]})(e.tasks).map(e=>{let[t,n]=e;return(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("h3",{className:"text-xs uppercase tracking-wider text-[--muted] font-semibold",children:t}),(0,r.jsx)("div",{className:"grid gap-2",children:n.map(e=>{var t;return(0,r.jsxs)(X,{className:"p-4",children:[(0,r.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-4",children:[(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,r.jsx)("span",{className:"font-medium",children:e.label}),e.destructive&&(0,r.jsx)("span",{className:"text-[10px] uppercase px-1.5 py-0.5 rounded bg-red-500/10 text-red-500 border border-red-500/20",children:"destructive"}),(0,r.jsx)("span",{className:b("text-[10px] uppercase px-1.5 py-0.5 rounded border",e.enabled?"bg-emerald-500/10 text-emerald-500 border-emerald-500/20":"bg-[--subtle] text-[--muted] border-[--border]"),children:e.enabled?"enabled":"disabled"}),e.claimedBy&&(0,r.jsxs)("span",{className:"text-[10px] uppercase px-1.5 py-0.5 rounded bg-blue-500/10 text-blue-500 border border-blue-500/20",children:["running on ",e.claimedBy.slice(0,8)]})]}),(0,r.jsx)("p",{className:"text-xs text-[--muted] mt-0.5",children:e.description})]}),(0,r.jsxs)("div",{className:"text-xs text-[--muted] grid grid-cols-2 gap-x-6 gap-y-0.5 sm:min-w-[220px]",children:[(0,r.jsx)("span",{children:"Schedule"}),(0,r.jsx)("span",{className:"text-[--foreground]",children:(t=e.intervalMs)?`every ${ry(t/1e3)}`:"manual"}),(0,r.jsx)("span",{children:"Last run"}),(0,r.jsxs)("span",{className:b("error"===e.lastStatus&&"text-red-500","ok"===e.lastStatus&&"text-emerald-500"),children:[lJ(e.lastRunAt),null!=e.lastDurationMs&&` \xb7 ${lZ(e.lastDurationMs)}`]}),"scheduled"===e.kind&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{children:"Next run"}),(0,r.jsx)("span",{className:"text-[--foreground]",children:lJ(e.nextRunAt)})]})]}),(0,r.jsx)(w,{size:"sm",intent:e.destructive?"alert-outline":"gray-outline",leftIcon:e.running?void 0:(0,r.jsx)(tC.UIR,{}),loading:e.running||s.isPending&&a===e.id,disabled:e.running,className:"w-full sm:w-auto",onClick:()=>{l(e.id),e.destructive?i.open():s.mutate({id:e.id})},children:"Run now"})]}),e.runs.length>1&&(0,r.jsxs)("details",{className:"mt-3 group",children:[(0,r.jsxs)("summary",{className:"cursor-pointer text-xs text-[--muted] flex items-center gap-1 list-none [&::-webkit-details-marker]:hidden",children:[(0,r.jsx)(tC.nwe,{className:"transition-transform group-open:rotate-180"}),e.runs.length," replicas"]}),(0,r.jsx)("div",{className:"mt-2 grid gap-1",children:e.runs.map(e=>(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,r.jsx)("span",{className:"font-mono text-[--muted]",children:e.instanceId.slice(0,8)}),e.self&&(0,r.jsx)("span",{className:"text-[10px] text-[--muted]",children:"this one"}),(0,r.jsxs)("span",{className:b("ml-auto","error"===e.lastStatus&&"text-red-500","ok"===e.lastStatus&&"text-emerald-500"),children:[lJ(e.lastRunAt),null!=e.lastDurationMs&&` \xb7 ${lZ(e.lastDurationMs)}`]})]},e.instanceId))})]}),"error"===e.lastStatus&&e.lastError&&(0,r.jsxs)("details",{className:"mt-3 group",children:[(0,r.jsxs)("summary",{className:"cursor-pointer text-xs text-red-500 flex items-center gap-1 list-none [&::-webkit-details-marker]:hidden",children:[(0,r.jsx)(tC.nwe,{className:"transition-transform group-open:rotate-180"}),"Last error"]}),(0,r.jsx)("pre",{className:"mt-2 p-2 text-[11px] font-mono whitespace-pre-wrap break-words bg-red-500/5 border border-red-500/20 rounded text-red-500/90",children:e.lastError})]})]},e.id)})})]},t)})})}),(0,r.jsx)(tk,{...i})]})}}),fy=(0,d.un)({getParentRoute:()=>fn,path:"cache",component:function(){let e=(0,o.jE)(),t=(0,eU.I)({queryKey:["dashboard","cache"],queryFn:()=>ei("/dashboard/cache"),refetchInterval:1e4}),s=t.data,[a,l]=n.useState({}),[i,d]=n.useState(null),c=async e=>{d(e);try{let t=await ei("POST /dashboard/cache/scan",{body:{prefix:e}});l(s=>({...s,[e]:t}))}catch(e){x.oR.error((null==e?void 0:e.message)??"Scan failed")}finally{d(null)}},u=(0,eE.n)({mutationFn:e=>ei("POST /dashboard/cache/clear",{body:{confirm:!0,prefix:e}}),onSuccess:()=>
63{x.oR.success("Cache cleared"),e.invalidateQueries({queryKey:["dashboard","cache"]})},onError:e=>x.oR.error((null==e?void 0:e.message)??"Clear failed")}),m=(0,eE.n)({mutationFn:()=>ei("POST /dashboard/tasks/clear-expired-cache/run",{body:{}}),onSuccess:t=>{x.oR.success((null==t?void 0:t.message)||"Expired keys cleared"),e.invalidateQueries({queryKey:["dashboard","cache"]})},onError:e=>x.oR.error((null==e?void 0:e.message)??"Failed")}),[p,h]=n.useState(),g=tN({title:"Clear cache",description:"This permanently removes cached entries. This cannot be undone.",actionText:"Clear",actionIntent:"alert-subtle",onConfirm:()=>u.mutate(p)}),f=null==s?void 0:s.totals;return(0,r.jsxs)(ru,{className:"p-4 sm:p-8 space-y-4",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"Cache"}),(0,r.jsx)("p",{className:"text-[--muted]",children:f?`${f.instances} instances \xb7 ${f.items??"—"} items${null!=f.redisDbSize?` \xb7 Redis DBSIZE ${f.redisDbSize}`:""}`:"Cache backends & prefixes"})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(w,{size:"sm",intent:"gray-outline",leftIcon:(0,r.jsx)(tC.Zxy,{}),loading:m.isPending,onClick:()=>m.mutate(),children:"Clear expired"}),(0,r.jsx)(w,{size:"sm",intent:"alert-outline",leftIcon:(0,r.jsx)(tC.id1,{}),onClick:()=>{h(void 0),g.open()},children:"Clear all"})]})]}),(0,r.jsx)(lh,{query:t,errorTitle:"Failed to load cache",children:e=>(0,r.jsx)(X,{className:"p-0 overflow-hidden",children:(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full text-sm",children:[(0,r.jsx)("thead",{className:"text-[--muted] text-xs uppercase bg-[--subtle]/40",children:(0,r.jsxs)("tr",{className:"text-left",children:[(0,r.jsx)("th",{className:"p-3",children:"Prefix"}),(0,r.jsx)("th",{className:"p-3",children:"Backend"}),(0,r.jsx)("th",{className:"p-3 text-right",children:"Items"}),(0,r.jsx)("th",{className:"p-3 text-right",children:"Max"}),(0,r.jsx)("th",{className:"p-3 text-right",children:"Est. size"}),(0,r.jsx)("th",{className:"p-3 text-right",children:"Expired"}),(0,r.jsx)("th",{className:"p-3 text-right",children:"Actions"})]})}),(0,r.jsx)("tbody",{children:e.instances.map(e=>(0,r.jsxs)("tr",{className:"border-t border-[--border]/50 hover:bg-[--subtle]/30",children:[(0,r.jsx)("td",{className:"p-3 font-mono text-xs",children:e.name}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsx)("span",{className:b("text-[10px] uppercase px-1.5 py-0.5 rounded border",lQ[e.backend]),children:e.backend})}),(0,r.jsx)("td",{className:"p-3 text-right tabular-nums",children:null!=e.items?e.items:a[e.name]?(0,r.jsxs)(r.Fragment,{children:[a[e.name].capped?"≥":"",a[e.name].count]}):"—"}),(0,r.jsx)("td",{className:"p-3 text-right tabular-nums",children:"disk"===e.backend?rx(e.maxSize):e.maxSize??"—"}),(0,r.jsx)("td",{className:"p-3 text-right tabular-nums",children:rx(e.estBytes)}),(0,r.jsx)("td",{className:"p-3 text-right tabular-nums",children:e.expired??"—"}),(0,r.jsx)("td",{className:"p-3",children:(0,r.jsxs)("div",{className:"flex justify-end gap-1",children:["redis"===e.backend&&null==e.items&&(0,r.jsx)(w,{size:"sm",intent:"gray-subtle",leftIcon:(0,r.jsx)(tC.LUJ,{}),loading:i===e.name,onClick:()=>c(e.name),title:"May be slow on large Redis instances",children:"Scan"}),(0,r.jsx)(E,{size:"sm",intent:"alert-subtle",icon:(0,r.jsx)(tC.id1,{}),"aria-label":"Clear prefix",onClick:()=>{h(e.name),g.open()}})]})})]},e.name))})]})})})}),(0,r.jsx)("p",{className:"text-xs text-[--muted]",children:"Redis per-prefix counts are opt-in (the “Scan” button) and rate-limited — a SCAN can be slow on large Redis instances."}),(0,r.jsx)(tk,{...g})]})}}),fj=(0,d.un)({getParentRoute:()=>fn,path:"blocklist",component:function(){var e;let t=(0,M.Z)(),{pathname:s}=(0,ez.z)(),a=l8().data,n=(null==(e=tA.find(e=>s===`/dashboard/blocklist/${e.id}`))?void 0:e.id)??"sources";return(0,r.jsxs)(ru,{className:"p-4 sm:p-8 space-y-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"Release Blocklists"}),(0,r.jsx)("p",{className:"text-[--muted]",children:a?`${a.counts.total} entries across ${a.sources.length} sources \xb7 ${a.counts.overrides} overrides`:"Shared verdicts about dead, defective, fake and mislabeled releases"})]}),(0,r.jsx)(lX,{sections:tA,value:n,onChange:e=>t({to:`/dashboard/blocklist/${e}`})}),(0,r.jsx)("div",{className:"min-w-0",children:(0,r.jsx)(th.P.div,{initial:{opacity:0,y:6}
63,animate:{opacity:1,y:0},transition:{duration:.18,ease:"easeOut"},children:(0,r.jsx)(m.s,{})},s)})]})}}),fw=(0,d.un)({getParentRoute:()=>fj,path:"/",beforeLoad:()=>{throw(0,c.V2)({to:"/dashboard/blocklist/sources"})}}),fN=(0,d.un)({getParentRoute:()=>fj,path:"sources",component:function(){let e=l8(),t=l7();return(0,r.jsx)(lh,{query:e,errorTitle:"Failed to load the blocklist",children:e=>(0,r.jsx)(ie,{snapshot:e,invalidate:t})})}}),fk=(0,d.un)({getParentRoute:()=>fj,path:"entries",component:function(){let e=l8(),t=l7();return(0,r.jsx)(lh,{query:e,errorTitle:"Failed to load the blocklist",children:e=>(0,r.jsx)(ix,{snapshot:e,invalidate:t})})}}),fS=(0,d.un)({getParentRoute:()=>fj,path:"publishing",component:function(){let e=l8(),t=l7();return(0,r.jsx)(lh,{query:e,errorTitle:"Failed to load the blocklist",children:e=>(0,r.jsx)(iN,{snapshot:e,invalidate:t})})}}),fC=(0,d.un)({getParentRoute:()=>fn,path:"usenet",component:function(){var e;let t=(0,M.Z)(),{pathname:s}=(0,ez.z)(),a=(null==(e=tR.find(e=>s===`/dashboard/usenet/${e.id}`))?void 0:e.id)??"library";return(0,r.jsxs)(ru,{className:"p-4 sm:p-8 space-y-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"Usenet"}),(0,r.jsx)("p",{className:"text-[--muted]",children:"The built-in usenet engine — your library, live activity, provider performance and settings."})]}),(0,r.jsx)(lX,{sections:tR,value:a,onChange:e=>t({to:`/dashboard/usenet/${e}`})}),(0,r.jsx)("div",{className:"min-w-0",children:(0,r.jsx)(th.P.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.18,ease:"easeOut"},children:(0,r.jsx)(m.s,{})},s)})]})}}),f_=(0,d.un)({getParentRoute:()=>fC,path:"/",beforeLoad:()=>{throw(0,c.V2)({to:"/dashboard/usenet/library"})}}),fR=(0,d.un)({getParentRoute:()=>fC,path:"library",component:function(){var e,t,s,a;let l,i,d,c,u,m;l=(0,o.jE)(),n.useEffect(()=>{let e=new EventSource("/api/v1/dashboard/usenet/library/stream",{withCredentials:!0});return e.onmessage=()=>{l.invalidateQueries({queryKey:[...aB,"library"]})},()=>e.close()},[l]);let[p,h]=n.useState("all"),[g,f]=n.useState(""),v=rd(g,300),[y,j]=n.useState(null),[w,N]=n.useState(null),[k,S]=n.useState(!1),[C,_]=n.useState(new Map),[R,A]=n.useState(oj),T=!function(e){let[t,s]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{if("u"<typeof window||!window.matchMedia)return;let t=window.matchMedia(e),a=()=>s(t.matches);return a(),t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[e]),t}("(min-width: 640px)")?"grid":R,[I,M]=n.useState("activity"),[P,D]=n.useState("desc"),[L,U]=n.useState(1),[$,O]=n.useState(ow);n.useEffect(()=>U(1),[p,v,I,P,$]);let F=function(e){let{limit:t=50,offset:s=0,status:a="all",statuses:r=[],search:n="",sort:l,dir:i}=e,o=[...r].sort().join(","),d=n.trim(),c=new URLSearchParams({limit:String(t),offset:String(s),status:a});return o&&c.set("statuses",o),d&&c.set("q",d),l&&c.set("sort",l),i&&c.set("dir",i),(0,eU.I)({queryKey:[...aB,"library",t,s,a,o,d,l??"",i??""],queryFn:()=>ei(`/dashboard/usenet/library?${c.toString()}`),placeholderData:aV.rX,staleTime:1e4})}({statuses:"all"===p?[]:[p],search:v,sort:I,dir:P,limit:$,offset:(L-1)*$}),z=(i=(0,o.jE)(),(0,eE.n)({mutationFn:e=>ei(`DELETE /dashboard/usenet/library/${encodeURIComponent(e)}`),onSuccess:()=>i.invalidateQueries({queryKey:[...aB,"library"]})})),V=(d=(0,o.jE)(),(0,eE.n)({mutationFn:()=>ei("DELETE /dashboard/usenet/library"),onSuccess:()=>d.invalidateQueries({queryKey:[...aB,"library"]})})),q=(c=(0,o.jE)(),(0,eE.n)({mutationFn:e=>ei("POST /dashboard/blocklist/mark",{body:{releases:e.map(aq).filter(e=>e.length>0),verdict:"dead"}}),onSuccess:()=>{c.invalidateQueries({queryKey:[...aB,"library"]}),c.invalidateQueries({queryKey:["dashboard","blocklist"]})}})),B=(u=(0,o.jE)(),(0,eE.n)({mutationFn:e=>ei("POST /dashboard/blocklist/unmark",{body:{releases:e.map(aq).filter(e=>e.length>0)}}),onSuccess:()=>{u.invalidateQueries({queryKey:[...aB,"library"]}
63),u.invalidateQueries({queryKey:["dashboard","blocklist"]})}})),K=(m=(0,o.jE)(),(0,eE.n)({mutationFn:e=>ei("POST /dashboard/usenet/library/requeue",{body:{hashes:e}}),onSuccess:()=>m.invalidateQueries({queryKey:[...aB,"library"]})})),H=n.useRef([]),[G,Y]=n.useState({mode:"block",entries:[]}),J=(null==(e=F.data)?void 0:e.entries)??[],Z=(null==(t=F.data)?void 0:t.total)??0,Q=Math.max(1,Math.ceil(Z/$));n.useEffect(()=>{L>Q&&U(Q)},[L,Q]);let ee=tN({title:"Delete library entries",description:"Remove the selected NZB(s) from the library/history. Failed entries are retried on the next request.",actionText:"Delete",actionIntent:"alert-subtle",onConfirm:()=>{let e=H.current;0!==e.length&&Promise.allSettled(e.map(e=>z.mutateAsync(e))).then(t=>{let s=t.filter(e=>"rejected"===e.status).length;s?x.oR.error(`${s} entr${1===s?"y":"ies"} failed to delete`):x.oR.success(1===e.length?"Entry deleted":"Entries deleted"),ep()})}}),et=tN({title:"Delete all library entries",description:"This will remove every entry from the library, including active imports. This action cannot be undone.",actionText:"Delete all",actionIntent:"alert-subtle",onConfirm:()=>{V.mutateAsync(void 0).then(()=>{x.oR.success("Library cleared"),ep()}).catch(e=>{x.oR.error((null==e?void 0:e.message)??"Failed to clear library")})}}),es=G.entries.length,ea="unblock"===G.mode,er=(null==(s=G.entries[0])?void 0:s.name)??(null==(a=G.entries[0])?void 0:a.nzbHash)??"",en=tN({title:`${ea?"Unblock":"Block"} release${es>1?"s":""}`,description:ea?es>1?`Allow ${es} releases again on this instance? Any local verdict is dropped and remote lists stop filtering them.`:`Allow "${er}" again on this instance? Any local verdict is dropped and remote lists stop filtering it.`:es>1?`Mark ${es} releases as dead on this instance's release blocklist? Their streams stop appearing in results; undo from the Blocklist page.`:`Mark "${er}" as dead on this instance's release blocklist? Its streams stop appearing in results; undo from the Blocklist page.`,actionText:ea?"Unblock":"Block",actionIntent:ea?"primary-subtle":"alert-subtle",onConfirm:()=>{0!==es&&(ea?B:q).mutateAsync(G.entries).then(()=>{let e=ea?"unblocked":"blocked";x.oR.success(1===es?`Release ${e}`:`${es} releases ${e}`),ep()}).catch(e=>x.oR.error((null==e?void 0:e.message)??`${ea?"Unblock":"Block"} failed`))}}),el=e=>{Y({mode:"block",entries:[e]}),en.open()},eo=e=>{Y({mode:"unblock",entries:[e]}),en.open()},ed=e=>{0!==e.length&&K.mutateAsync(e).then(e=>{0===e.requeued?x.oR.error(e.error??"Requeue failed"):(e.failed>0?x.oR.warning(`${e.requeued} requeued, ${e.failed} failed: ${e.error??""}`):x.oR.success(1===e.requeued?"Entry requeued":`${e.requeued} entries requeued`),ep())}).catch(e=>x.oR.error((null==e?void 0:e.message)??"Requeue failed"))},ec=e=>{H.current=[e],ee.open()},eu=(e,t)=>_(s=>{let a=new Map(s);return t?a.set(e.nzbHash,e):a.delete(e.nzbHash),a}),em=J.length>0&&J.every(e=>C.has(e.nzbHash)),ep=()=>{S(!1),_(new Map)};return(0,r.jsxs)("div",{className:"space-y-4 overflow-x-hidden",children:[(0,r.jsx)(oC,{}),(0,r.jsxs)("div",{className:"flex flex-col gap-2 xl:flex-row xl:items-center",children:[(0,r.jsx)(W,{leftIcon:(0,r.jsx)(tC.iyI,{}),placeholder:"Search by name…",value:g,onValueChange:f,fieldClass:"xl:flex-1 xl:min-w-0"}),(0,r.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center xl:shrink-0",children:[(0,r.jsx)(rn,{value:p,options:oh,onValueChange:e=>h(e),fieldClass:"sm:w-36 sm:flex-auto xl:flex-none"}),(0,r.jsxs)("div",{className:"flex items-stretch gap-2 sm:flex-auto xl:flex-none",children:[(0,r.jsx)(rn,{value:I,options:ox,onValueChange:e=>{M(e),D(og[e])},fieldClass:"sm:w-40 sm:flex-auto xl:flex-none"}),(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"md",intent:"gray-outline",icon:"asc"===P?(0,r.jsx)(tC.rH8,{}):(0,r.jsx)(tC.stI,{}),"aria-label":"asc"===P?"Ascending":"Descending",onClick:()=>D(e=>"asc"===e?"desc":"asc")}),children:"asc"===P?"Ascending":"Descending"})]}),(0,r.jsx)(rn,{value:String($),options:ob,onValueChange:e=>(e=>{O(e);try{localStorage.setItem(oy,String(e))}catch{}})(Number(e)),fieldClass:"sm:w-32 sm:flex-auto xl:flex-none"}),(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2 sm:justify-start sm:shrink-0",children:[(0,r.jsx)("div",{className:"hidden sm:block",children:(0,r.jsx)(oN,{value:R,onChange:e=>{A(e);try{localStorage.setItem(ov,e)}catch{}}})}),(0,r.jsx)("div",{className:"flex items-center gap-1.5",children:k?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("span",{className:"text-xs text-[--muted] tabular-nums",children:[C.size," selected"]}),(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"md",intent:"gray-subtle",icon:em?(0,r.jsx)(tC.B_A,{}):(0,r.jsx)(tC.aJB,{}),"aria-label":em?"Clear selection":"Select all",disabled:0===J.length,onClick:()=>_(e=>{let t=new Map(e);if(em)for(let e of J)t.delete(e.nzbHash);else for(let e of J)t.set(e.nzbHash,e);return t})}),children:em?"Clear selection":"Select all"}),(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"md",intent:"gray-subtle",icon:(0,r.jsx)(tC.Zxy,{}),"aria-label":"Requeue selected",loading:K.isPending,disabled:0===C.size,onClick:()=>ed([...C.keys()])}),children:"Requeue selected"}),(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"md",intent:"gray-subtle",icon:(0,r.jsx)(tC.PLI,{}),"aria-label":"Block selected",loading:q.isPending,disabled:0===C.size,onClick:()=>{let e=[...C.values()].filter(e=>aq(e).length>0);0===e.length?x.oR.error("None of the selected entries can be blocked"):(Y({mode:"block",entries:e}),en.open())}}),children:"Block selected releases"}),(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"md",intent:"alert-subtle",icon:(0,r.jsx)(tC.id1,{}),"aria-label":"Delete selected",disabled:0===C.size,onClick:()=>{0!==C.size&&(H.current=[...C.keys()],ee.open())}}),children:"Delete selected"}),(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"md",intent:"gray-outline",icon:(0,r.jsx)(tC.Gsv,{}),"aria-label":"Done selecting",onClick:ep}
63),children:"Done"})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"md",intent:"alert-subtle",icon:(0,r.jsx)(tC.id1,{}),"aria-label":"Delete all entries",loading:V.isPending,onClick:et.open}),children:"Delete all"}),(0,r.jsx)(to,{trigger:(0,r.jsx)(E,{size:"md",intent:"gray-outline",icon:(0,r.jsx)(tC.ekd,{}),"aria-label":"Select entries",disabled:0===J.length,onClick:()=>S(!0)}),children:"Select"})]})})]})]})]}),(0,r.jsx)(lh,{query:F,errorTitle:"Failed to load library",children:e=>0===e.entries.length?(0,r.jsx)(X,{className:"p-6 text-center text-sm text-[--muted]",children:v.trim()?"No entries match your search.":"No entries for this filter."}):(0,r.jsx)("div",{className:b("grid"===T?"grid gap-3 sm:grid-cols-2 xl:grid-cols-3 3xl:grid-cols-4 5xl:grid-cols-5":"flex flex-col gap-2"),children:e.entries.map(e=>(0,r.jsx)(oR,{entry:e,view:T,selectMode:k,selected:C.has(e.nzbHash),onToggleSelect:eu,onBrowse:j,onInfo:N,onBlock:el,onUnblock:eo,onRequeue:ed,onDelete:ec},e.nzbHash))})}),Q>1&&(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsxs)("span",{className:"text-xs text-[--muted] tabular-nums",children:["Showing ",(L-1)*$+ +(J.length>0),"–",Math.min(L*$,Z)," of ",Z]}),(0,r.jsxs)(ic,{children:[(0,r.jsx)(im,{direction:"previous",isDisabled:L<=1,onClick:()=>U(e=>Math.max(1,e-1))}),ih(L,Q).map((e,t)=>"…"===e?(0,r.jsx)(ip,{},`e${t}`):(0,r.jsx)(iu,{value:e,"data-selected":e===L,onClick:()=>U(e)},e)),(0,r.jsx)(im,{direction:"next",isDisabled:L>=Q,onClick:()=>U(e=>Math.min(Q,e+1))})]})]}),(0,r.jsx)(on,{hash:(null==y?void 0:y.nzbHash)??null,name:null==y?void 0:y.name,open:null!==y,onOpenChange:e=>!e&&j(null)}),(0,r.jsx)(om,{entry:w,open:null!==w,onOpenChange:e=>!e&&N(null)}),(0,r.jsx)(tk,{...ee}),(0,r.jsx)(tk,{...et}),(0,r.jsx)(tk,{...en})]})}}),fA=(0,d.un)({getParentRoute:()=>fC,path:"stats",component:function(){let[e,t]=n.useState("24h"),s=(0,eU.I)({queryKey:[...aB,"stats",e],queryFn:()=>ei(`/dashboard/usenet/stats?window=${e}`),staleTime:15e3,refetchInterval:3e4});return(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsx)("div",{className:"flex justify-end",children:(0,r.jsx)(oT,{value:e,onChange:t})}),(0,r.jsx)(oD,{}),(0,r.jsx)(lh,{query:s,errorTitle:"Failed to load usenet stats",children:e=>(0,r.jsx)(oF,{data:e})})]})}}),fT=(0,d.un)({getParentRoute:()=>fC,path:"providers",component:function(){var e;let t=(0,eU.I)({queryKey:[...aB,"providers"],queryFn:()=>ei("/dashboard/usenet/providers"),staleTime:1e4});return t.isLoading?(0,r.jsx)(lm,{}):t.isError?(0,r.jsx)(X,{className:"p-6 text-sm text-red-500",children:"Failed to load providers."}):(0,r.jsx)(oK,{providers:(null==(e=t.data)?void 0:e.providers)??[]})}}),fI=(0,d.un)({getParentRoute:()=>fC,path:"settings",validateSearch:e=>({field:fc(e.field)}),component:function(){var e,t;let s,a,l,i,d,c=aY(),{mutateAsync:u,isPending:m}=(s=(0,o.jE)(),(0,eE.n)({mutationFn:e=>ei("PATCH /dashboard/usenet/settings",{body:e}),onSuccess:()=>s.invalidateQueries({queryKey:aK})})),p=n.useRef(null),h=(0,rD.S)({from:"/dashboard/usenet/settings"}),g=(0,M.Z)({from:"/dashboard/usenet/settings"}),f=n.useCallback(()=>{g({to:".",search:e=>({...e,field:void 0}),replace:!0,resetScroll:!1})},[g]);a6(h.field,!!c.data,f);let b=(null==(e=c.data)?void 0:e.keys)??[],v=(null==(t=c.data)?void 0:t.profiles)??{},{schema:y,defaults:j,byName:w}=n.useMemo(()=>{var e;let t={},s={},a=new Map;for(let e of b){let r=n3(e.key);t[r]=rL.bz(),s[r]=null===e.value&&"enum"===e.ui.kind?"":e.value,a.set(r,e)}let r=null==(e=b.find(e=>e.key.replace(/^usenet\./,"")===oZ))?void 0:e.value,n=r&&"custom"!==r?v[r]:void 0;if(n)for(let e of oJ){let t=n3(oQ(e));t in s&&(s[t]=n[e])}return{schema:rL.Ik(t),defaults:s,byName:a}},[b,v]);if(c.isLoading)return(0,r.jsx)(lm,{});if(c.isError)return(0,r.jsx)(X,{className:"p-6 text-sm text-red-500",children:"Failed to load usenet settings."});let N=(a=new Map(b.map(e=>[e.key.replace(/^usenet\./,""),e])),l=new Set,i=o0.map(e=>{let t=e.leaves.map(e=>{let t=a.get(e);return t&&l.add(e),t}).filter(e=>!!e);return{title:e.title,note:e.note,keys:t}}).filter(e=>e.keys.length>0),(d=b.filter(e=>!l.has(e.key.replace(/^usenet\./,"")))).length&&i.push({title:"Other",note:void 0,keys:d}),i),k=new Set(oJ.map(e=>n3(oQ(e)))),S=n3(oQ(oZ));return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,r.jsx)(nP,{title:"Settings",description:"Configuration for the built-in usenet engine",icon:tC.nMM}),(0,r.jsx)("div",{className:"pt-1",children:(0,r.jsx)(lc,{sectionKeys:b,sectionLabel:"Usenet",invalidate:[aK],scope:oX})})]}),(0,r.jsx)(rJ,{schema:y,defaultValues:j,stackClass:"space-y-4 relative",onSubmit:async e=>{var t,s;let a="custom"!==e[S],r={};for(let[t,s]of Object.entries(e)){let e=w.get(t);if(!e||"environment"===e.source||a&&k.has(t))continue;let n=(null===e.value||null===e.default)&&""===s?null:s;JSON.stringify(n)!==JSON.stringify(e.value)&&(r[e.key]=n)}if(0===Object.keys(r).length){x.oR.info("No changes to save."),null==(t=p.current)||t.reset(e,{keepValues:!0});return}try{let t=await u(r);x.oR.success(`Saved ${t.updated.length} setting${1===t.updated.length?"":"s"}.`),null==(s=p.current)||s.reset(e,{keepValues:!0}),t.requiresRestart&&x.oR.warning("Some changes require a restart to take effect.",{duration:8e3})}catch(t){let e=null==t?void 0:t.issues;if(e)for(let[t,s]of Object.entries(e))x.oR.error(`${t}: ${s}`);else x.oR.error((null==t?void 0:t.message)??"Failed to save settings")}},children:e=>(p.current=e,(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o1,{profiles:v}),N.map(e=>(0,r.jsxs)(nM,{title:e.title,children:[e.note&&(0,r.jsx)("p",{className:"text-xs text-[--muted] -mt-1 mb-1",children:(0,r.jsx)(nz,{children:e.note})}),e.keys.map(e=>(0,r.jsx)("div",{id:`setting-${e.key}`,children:(0,r.jsx)(n4,{k:e})},e.key))]},e.title)),(0,r.jsx)("div",{className:"flex justify-end",children:(0,r.jsx)(n$,{isPending:m})}),(0,r.jsx)(nO,{isPending:m})]}))},b.map(e=>`${e.key}:${String(e.value)}`).join("|"))]})}}),fE=A.addChildren([g8,fa,fr,g7,fe,ft,fn.addChildren([fl,fi,fo,fd,fu,fb,fv,fy,fm.addChildren([fp,fh,fx,fg,ff]),fj.addChildren([fw,fN,fk,fS]),fC.addChildren([f_,fR,fA,fT,fI])])]),fM=(0,u.a)({routeTree:fE,context:{queryClient:g9},trailingSlash:"never",defaultPreload:"intent"}),fP=document.getElementById("root");l.createRoot(fP).render((0,r.jsx)(n.StrictMode,{children:(0,r.jsx)(o.Ht,{client:g9,children:(0,r.jsx)(i.p,{router:fM})})}))}},i={};function o(e){var t=i[e];if(void 0!==t)return t.exports;var s=i[e]={exports:{}};return l[e].call(s.exports,s,s.exports,o),s.exports}o.m=l,o.n=e=>
63{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(s,a){if(1&a&&(s=this(s)),8&a||"object"==typeof s&&s&&(4&a&&s.__esModule||16&a&&"function"==typeof s.then))return s;var r=Object.create(null);o.r(r);var n={};e=e||[null,t({}),t([]),t(t)];for(var l=2&a&&s;("object"==typeof l||"function"==typeof l)&&!~e.indexOf(l);l=t(l))Object.getOwnPropertyNames(l).forEach(e=>{n[e]=()=>s[e]});return n.default=()=>s,o.d(r,n),r},o.d=(e,t)=>{for(var s in t)o.o(t,s)&&!o.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.nc=void 0,s=[],o.O=(e,t,a,r)=>{if(t){r=r||0;for(var n=s.length;n>0&&s[n-1][2]>r;n--)s[n]=s[n-1];s[n]=[t,a,r];return}for(var l=1/0,n=0;n<s.length;n++){for(var[t,a,r]=s[n],i=!0,d=0;d<t.length;d++)(!1&r||l>=r)&&Object.keys(o.O).every(e=>o.O[e](t[d]))?t.splice(d--,1):(i=!1,r<l&&(l=r));if(i){s.splice(n--,1);var c=a();void 0!==c&&(e=c)}}return e},a={410:0},o.O.j=e=>0===a[e],r=(e,t)=>{var s,r,[n,l,i]=t,d=0;if(n.some(e=>0!==a[e])){for(s in l)o.o(l,s)&&(o.m[s]=l[s]);if(i)var c=i(o)}for(e&&e(t);d<n.length;d++)r=n[d],o.o(a,r)&&a[r]&&a[r][0](),a[r]=0;return o.O(c)},(n=self.webpackChunk_aiostreams_frontend=self.webpackChunk_aiostreams_frontend||[]).forEach(r.bind(null,0)),n.push=r.bind(null,n.push.bind(n));var d=o.O(void 0,["783","509"],()=>o(1932));d=o.O(d)})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.