backflow-ui-renderer 0.1.22 → 0.1.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,26 +1,29 @@
1
- "use strict";var Km=Object.defineProperty;var Zm=(e,t,n)=>t in e?Km(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var go=(e,t,n)=>Zm(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react"),tp=require("react-icons/fa"),xt=require("react-icons/fi"),Xo=require("react-icons/lu"),cn=require("react/jsx-runtime"),dc=require("@squeed/flow-sdk"),Wu=require("react-dom");function ep(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const Ra=ep(m);function wn(e){return e.length>2e3?`${e.slice(0,2e3)}…`:e}const np={button:"button, [role='button'], a",link:"a",input:"input, textarea",select:"select",textarea:"textarea",checkbox:"input[type='checkbox']"};function Qo(e){return(e||"").replace(/\s+/g," ").trim().toLowerCase()}function sp(e,t){if(!t.text)return!0;const n=Qo(t.text);return[e.textContent,e.placeholder,e.getAttribute("aria-label"),e.getAttribute("title"),e.value].map(Qo).some(s=>t.exact?s===n:s.includes(n))}function Wr(e,t=document){const n=e.role?np[e.role]||e.role:"*";return Array.from(t.querySelectorAll(n)).filter(s=>e.name&&s.getAttribute("name")!==e.name?!1:sp(s,e))}function Tn(e,t=document){return Wr(e,t)[e.index??0]||null}let is=!1;function ju(e){is=e}function Vu(){return is}function Ou(e,t){if(!is)return!1;const n=Tn(e,t);return n?(n.click(),!0):!1}async function ip(e){if(!is)return!1;const t=Tn(e);if(!t)return!1;let n=document.getElementById("__bf_remote_cursor");n||(n=document.body.appendChild(document.createElement("div")),n.id="__bf_remote_cursor",n.innerHTML='<svg width="22" height="30" viewBox="0 0 22 30" fill="none"><path d="M2 1.5 L2 22.5 L7.6 17.4 L11.2 25.8 L14.8 24.2 L11.3 16.1 L18.6 15.6 Z" fill="#fff" stroke="#111" stroke-width="1.6" stroke-linejoin="round"/></svg>',Object.assign(n.style,{position:"fixed",zIndex:"2147483647",pointerEvents:"none",width:"22px",height:"30px",transition:"left 180ms ease, top 180ms ease",filter:"drop-shadow(0 2px 3px rgba(0,0,0,0.45))",left:`${window.innerWidth-40}px`,top:`${window.innerHeight-48}px`}));const s=t.getBoundingClientRect();await new Promise(r=>requestAnimationFrame(()=>{n.style.left=`${s.left+s.width/2}px`,n.style.top=`${s.top+s.height/2}px`,r()})),await new Promise(r=>setTimeout(r,180));const i=document.body.appendChild(document.createElement("div"));return Object.assign(i.style,{position:"fixed",zIndex:"2147483646",pointerEvents:"none",left:n.style.left,top:n.style.top,width:"34px",height:"34px",border:"2px solid rgba(255,60,60,0.9)",borderRadius:"50%",transform:"translate(-50%, -50%)"}),i.animate([{transform:"translate(-50%, -50%) scale(0.3)",opacity:.9},{transform:"translate(-50%, -50%) scale(1)",opacity:0}],{duration:450}).finished.finally(()=>i.remove()),await n.animate([{transform:"scale(1)"},{transform:"scale(0.8)"},{transform:"scale(1)"}],{duration:160}).finished.catch(()=>{}),t.click(),!0}function Pa(e,t,n){var s;if(!is)return!1;const i=Tn({...e,role:e.role||"input"},n);if(!i)return!1;const r=i.tagName==="TEXTAREA"?window.HTMLTextAreaElement:window.HTMLInputElement,o=(s=Object.getOwnPropertyDescriptor(r.prototype,"value"))==null?void 0:s.set;return o==null||o.call(i,t),i.dispatchEvent(new Event("input",{bubbles:!0})),i.dispatchEvent(new Event("change",{bubbles:!0})),!0}function fc(e){const t=getComputedStyle(e).overflowY;return(t==="auto"||t==="scroll")&&e.scrollHeight>e.clientHeight}function rp(){const e=document.getElementById("__bf_remote_cursor"),t=Number.parseFloat((e==null?void 0:e.style.left)||""),n=Number.parseFloat((e==null?void 0:e.style.top)||"");let s=Number.isFinite(t)&&Number.isFinite(n)?document.elementFromPoint(t,n):null;for(;s instanceof HTMLElement;){if(fc(s))return s;s=s.parentElement}return Array.from(document.querySelectorAll("body *")).find(fc)||null}function Uu(e,t="down",n=600,s){const i=Math.min(Math.max(Math.abs(n),1),2e3),r=e?Tn(e,s):null;if(e&&!r)return!1;if(r)return r.scrollIntoView({behavior:"smooth",block:"center"}),!0;const o=rp();return o?(o.scrollBy({top:t==="down"?i:-i,behavior:"smooth"}),!0):(window.scrollBy({top:t==="down"?i:-i,behavior:"smooth"}),!0)}function Hu(e,t,n){if(!is)return!1;const s=Tn(e,n),i=Tn(t,n);if(!s||!i)return!1;const r=s.getBoundingClientRect(),o=i.getBoundingClientRect(),l=1,c=(p,g,d,w)=>g.dispatchEvent(new PointerEvent(p,{bubbles:!0,cancelable:!0,clientX:d,clientY:w,pointerId:l,pointerType:"touch",isPrimary:!0})),h=r.left+r.width/2,a=r.top+r.height/2,u=o.left+o.width/2,f=o.top+o.height/2;return c("pointerdown",s,h,a),c("pointermove",i,u,f),c("pointerup",i,u,f),!0}function qu(e,t=1e5){const n=e?Tn(e):document.documentElement;if(!n)return"";const s=Math.min(Math.max(Math.floor(t),1),1e5);return n.outerHTML.slice(0,s)}async function Gu(e){if(!is)return!1;const t=Object.getPrototypeOf(async function(){}).constructor,n=await new t(e)();return JSON.parse(JSON.stringify(n??null))}let mc=!1,Ds=[];const op=500;function ye(e){Ds.push(e),Ds.length>op&&Ds.shift()}function Yu(){if(mc)return;mc=!0,window.addEventListener("error",i=>{ye({type:"error",message:i.message,source:i.filename,line:i.lineno,col:i.colno,time:Date.now()})}),window.addEventListener("unhandledrejection",i=>{var r;ye({type:"rejection",message:((r=i.reason)==null?void 0:r.message)||String(i.reason),time:Date.now()})}),["error","warn"].forEach(i=>{const r=console[i].bind(console);console[i]=(...o)=>{ye({type:"console",level:i,message:o.map(String).join(" "),time:Date.now()}),r(...o)}});const e=window.fetch.bind(window);window.fetch=async(...i)=>{var r,o;const l=typeof i[0]=="string"?i[0]:i[0].url,c=(((r=i[1])==null?void 0:r.method)||"GET").toUpperCase(),h=typeof((o=i[1])==null?void 0:o.body)=="string"?wn(i[1].body):void 0;try{const a=await e(...i),u=(a.headers.get("content-type")||"").includes("text/event-stream");if(a.body&&!u?a.clone().text().then(f=>ye({type:"network",method:c,url:l,status:a.status,ok:a.ok,requestBody:h,responseBody:wn(f),time:Date.now()})).catch(()=>ye({type:"network",method:c,url:l,status:a.status,ok:a.ok,requestBody:h,time:Date.now()})):ye({type:"network",method:c,url:l,status:a.status,ok:a.ok,requestBody:h,time:Date.now()}),u&&a.body){const[f,p]=a.body.tee();a.__bfBody=f,Object.defineProperty(a,"body",{get:()=>f});const g=p.getReader(),d=new TextDecoder;(async()=>{try{for(;;){const{done:w,value:C}=await g.read();if(w)break;d.decode(C,{stream:!0}).split(`
2
- `).filter(x=>x.startsWith("data:")).forEach(x=>ye({type:"sse",url:l,data:wn(x.slice(5).trim()),time:Date.now()}))}}catch{}})()}return a}catch(a){throw ye({type:"network",method:c,url:l,error:(a==null?void 0:a.message)||String(a),requestBody:h,time:Date.now()}),a}};const t=XMLHttpRequest.prototype.open,n=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function(i,r,...o){return this.__bfMethod=i,this.__bfUrl=r,t.apply(this,[i,r,...o])},XMLHttpRequest.prototype.send=function(i){return this.addEventListener("loadend",()=>{ye({type:"network",method:this.__bfMethod||"GET",url:this.__bfUrl||"",status:this.status,ok:this.status>=200&&this.status<300,requestBody:typeof i=="string"?wn(i):void 0,responseBody:typeof this.responseText=="string"?wn(this.responseText):void 0,time:Date.now()})}),n.call(this,i)};const s=window.WebSocket;if(window.WebSocket=new Proxy(s,{construct(i,r){const o=new i(...r),l=String(r[0]);o.addEventListener("open",()=>ye({type:"ws",url:l,direction:"open",time:Date.now()})),o.addEventListener("close",()=>ye({type:"ws",url:l,direction:"close",time:Date.now()})),o.addEventListener("error",()=>ye({type:"ws",url:l,direction:"error",time:Date.now()})),o.addEventListener("message",h=>ye({type:"ws",url:l,direction:"receive",data:wn(String(h.data)),time:Date.now()}));const c=o.send.bind(o);return o.send=h=>(ye({type:"ws",url:l,direction:"send",data:wn(String(h)),time:Date.now()}),c(h)),o}}),"EventSource"in window){const i=window.EventSource;window.EventSource=new Proxy(i,{construct(r,o){const l=new r(...o),c=String(o[0]);return l.addEventListener("message",h=>ye({type:"sse",url:c,data:wn(String(h.data)),time:Date.now()})),l.addEventListener("error",()=>ye({type:"ws",url:c,direction:"error",time:Date.now()})),l}})}}function _a(e=!1){const t=[...Ds];return e&&(Ds=[]),t}function $a(){Ds=[]}let kn=null;async function ap(e){var t,n;switch(e.command){case"trigger":return ip(e.matcher||{});case"fill":return Pa(e.matcher||{},e.value??"");case"scroll":return Uu(e.matcher,e.direction,e.amount);case"drag":return!e.sourceMatcher||!e.targetMatcher?!1:Hu(e.sourceMatcher,e.targetMatcher);case"getDom":return qu(e.matcher,e.maxChars);case"evaluate":return Gu(e.script??"");case"diagnostics":{const s=window.__backflowDiagnostics;return s?e.submit?(t=s.sendReport)==null?void 0:t.call(s):(n=s.getReport)==null?void 0:n.call(s):{error:"UI diagnostics unavailable"}}case"find":return Wr(e.matcher||{}).map(s=>({tag:s.tagName.toLowerCase(),text:Qo(s.textContent)}));case"getLog":return _a(e.clear);case"clearLog":return $a(),!0;default:return{error:`Unknown command: ${e.command}`}}}function Xu(e,t,n){if(kn&&kn.readyState<=WebSocket.OPEN)return;const s=new WebSocket(e);kn=s;let i=!1;const r=()=>{i||(i=!0,s.send(JSON.stringify({type:"join_room",room:t})))};s.addEventListener("open",()=>{n?s.send(JSON.stringify({type:"auth",token:n})):r()}),s.addEventListener("message",async o=>{let l;try{l=JSON.parse(o.data)}catch{return}if(l.type==="authenticated"){r();return}if(!(l.type!=="agent_command"||l.room!==t)){window.dispatchEvent(new CustomEvent("backflow:remote-command",{detail:{active:!0}}));try{const c=await ap(l);s.send(JSON.stringify({type:"agent_command_result",room:t,requestId:l.requestId,result:c}))}finally{window.dispatchEvent(new CustomEvent("backflow:remote-command",{detail:{active:!1}}))}}}),s.addEventListener("close",()=>{kn===s&&(kn=null)})}function Jo(){kn==null||kn.close(),kn=null}function Qu(){Yu(),window.__backflowAgent={trigger:Ou,fill:Pa,scroll:Uu,drag:Hu,getDom:qu,evaluate:Gu,find:Wr,getLog:_a,clearLog:$a,isEnabled:Vu}}const ki={primary:"#3b82f6",accent:"#db2777",background:"#111827",surface:"#1f2937",surfaceHover:"#374151",border:"#374151",borderSubtle:"rgba(255,255,255,0.1)",text:"#ffffff",textSecondary:"#d1d5db",textMuted:"#9ca3af",textPlaceholder:"#6b7280",danger:"#ef4444",success:"#22c55e",warning:"#eab308",info:"#3b82f6"},Mi={primary:"#000000",accent:"#db2777",background:"#ffffff",surface:"#f9fafb",surfaceHover:"#f3f4f6",border:"#e5e7eb",borderSubtle:"rgba(0,0,0,0.06)",text:"#111827",textSecondary:"#4b5563",textMuted:"#6b7280",textPlaceholder:"#9ca3af",danger:"#ef4444",success:"#22c55e",warning:"#eab308",info:"#3b82f6"},lp={fontFamily:"inherit",headingFontFamily:"inherit",baseFontSize:"14px",headingFontSize:"24px",lineHeight:1.5},cp={borderRadius:"8px",borderRadiusLg:"12px",borderRadiusSm:"4px",spacing:"8px",cardPadding:"16px",sectionGap:"12px",containerMaxWidth:"none"},hp={shadow:"0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06)",shadowLg:"0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06)",transition:"all 0.15s ease",hoverOpacity:.85,scrollBehavior:"smooth"},up={buttonStyle:"solid",buttonRadius:"8px",inputStyle:"outline",inputRadius:"8px",cardBorder:!0,cardShadow:!1};function dp(e){const t=String(e).replace("#","");if(t.length!==6&&t.length!==3)return-1;const n=t.length===3?t.split("").map(o=>o+o).join(""):t,s=parseInt(n.slice(0,2),16),i=parseInt(n.slice(2,4),16),r=parseInt(n.slice(4,6),16);return(s*299+i*587+r*114)/1e3}function Ko(e){const t=dp(e);return t<0?"dark":t>128?"light":"dark"}const fp=/(^|\s)(bg-white|bg-gray-50|bg-gray-100|bg-gray-200|bg-indigo-50|bg-blue-50|text-gray-6\d\d|text-gray-7\d\d|text-gray-8\d\d|text-black|text-gray-9\d\d|border-gray-2\d\d|border-gray-3\d\d)/,mp=/(^|\s)(bg-gray-8\d\d|bg-gray-9\d\d|bg-slate-8\d\d|bg-slate-9\d\d|bg-zinc-8\d\d|bg-zinc-9\d\d|bg-neutral-8\d\d|bg-neutral-9\d\d|bg-black|text-gray-1\d\d|text-gray-2\d\d|text-gray-3\d\d|text-slate-1\d\d|text-slate-2\d\d|text-slate-3\d\d|border-gray-7\d\d|border-gray-8\d\d)/;function pp(e){if(!e||typeof e!="object")return null;const t=e.steps;if(!Array.isArray(t))return null;let n=0,s=0;const i=r=>{if(!r||typeof r!="object")return;const o=r,l=typeof o.className=="string"?o.className:"";fp.test(l)&&n++,mp.test(l)&&s++,Array.isArray(o.children)&&o.children.forEach(i),Array.isArray(o.components)&&o.components.forEach(i),o.component&&typeof o.component=="object"&&i(o.component)};return t.forEach(r=>{const o=r.config;o&&typeof o=="object"&&i(o)}),n===s?null:n>s?"light":"dark"}function Ju(e,t,n,s){const i=t!=null&&t.colorMode||e!=null&&e.colorMode||n!=null&&n.colorMode?"declared":"default",r=(t==null?void 0:t.colorMode)??(e==null?void 0:e.colorMode)??(n==null?void 0:n.colorMode)??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),l=r!=="light"?{...ki}:{...Mi};n!=null&&n.primaryColor&&(l.primary=n.primaryColor),n!=null&&n.accentColor&&(l.accent=n.accentColor);const c={...l,...(e==null?void 0:e.colors)||{},...(t==null?void 0:t.colors)||{}};if(s){const x=Ko(s);if(x!==r){const k=x==="light"?Mi:ki;c.text=c.text||k.text,c.textSecondary=c.textSecondary||k.textSecondary,c.textMuted=c.textMuted||k.textMuted,c.textPlaceholder=c.textPlaceholder||k.textPlaceholder,c.surface=c.surface||k.surface,c.surfaceHover=c.surfaceHover||k.surfaceHover,c.border=c.border||k.border,c.borderSubtle=c.borderSubtle||k.borderSubtle}}const h={...lp,...(e==null?void 0:e.typography)||{},...(t==null?void 0:t.typography)||{}},a={...cp,...(e==null?void 0:e.layout)||{},...(t==null?void 0:t.layout)||{}},u={...hp,...(e==null?void 0:e.effects)||{},...(t==null?void 0:t.effects)||{}},f={...up,...(e==null?void 0:e.components)||{},...(t==null?void 0:t.components)||{}},p=(e==null?void 0:e.persistedKeys)||(t==null?void 0:t.persistedKeys),g=(t==null?void 0:t.fullscreen)??(e==null?void 0:e.fullscreen),d={...(e==null?void 0:e.toast)||{},...(t==null?void 0:t.toast)||{}},w=(t==null?void 0:t.startupModal)||(e==null?void 0:e.startupModal),C=(t==null?void 0:t.realtime)||(e==null?void 0:e.realtime);return{colorMode:r,colorModeSource:i,colors:c,typography:h,layout:a,effects:u,components:f,toast:d,persistedKeys:p,fullscreen:g,startupModal:w,realtime:C}}function*Zo(e,t="$"){if(Array.isArray(e)){for(let n=0;n<e.length;n++)yield*Zo(e[n],`${t}[${n}]`);return}if(!(!e||typeof e!="object")){yield[e,t];for(const[n,s]of Object.entries(e))s&&typeof s=="object"&&(yield*Zo(s,`${t}.${n}`))}}function gp(e){const t={scenes:[],modals:[],widgets:[],actions:[],sources:[]};if(!e)return t;const n=Array.isArray(e.steps)?e.steps:[],s=Array.isArray(e.widgets)?e.widgets:[],i=n.map(a=>{var u;return{label:a.id||"(unnamed)",detail:[a.route,(u=a.config)==null?void 0:u.sceneName,a.requiresAuth?"auth":null].filter(Boolean).join(" · ")}}),r=Object.entries(e.modals||{}).map(([a,u])=>({label:a,detail:[u==null?void 0:u.title,u!=null&&u.popover?"popover":null,u==null?void 0:u.size].filter(Boolean).join(" · ")})),o=s.map(a=>({label:a.id||"(unnamed)",detail:`${Array.isArray(a.components)?a.components.length:0} components`})),l=a=>{var g,d;const u=a.match(/^\$\.steps\[(\d+)\]/);if(u)return((g=n[+u[1]])==null?void 0:g.id)||`step[${u[1]}]`;const f=a.match(/^\$\.widgets\[(\d+)\]/);if(f)return`widget:${((d=s[+f[1]])==null?void 0:d.id)??f[1]}`;const p=a.match(/^\$\.modals\.([^.[]+)/);return p?`modal:${p[1]}`:a.split(".")[1]||"root"},c=[],h=[];for(const[a,u]of Zo(e)){const f=l(u),p=typeof a.endpoint=="string";for(const g of["onClick","action","onSubmit","onChangeAction"])g==="action"&&p||typeof a[g]=="string"&&c.push({label:a[g],detail:f});typeof a.dataSource=="string"&&h.push({label:a.dataSource,detail:[f,a.key?`key: ${a.key}`:null].filter(Boolean).join(" · "),lookup:[a.key,a.dataSource.replace(/^\//,"")].filter(Boolean)})}return{scenes:i,modals:r,widgets:o,actions:c,sources:yp(h)}}function pc(e){return e.startsWith("sdk:")?e.split("(")[0]:e.replace(/^\//,"").split("?")[0]}function yp(e){const t=new Map;for(const n of e){const s=pc(n.label);t.set(s,(t.get(s)||0)+1)}return e.map(n=>{const s=t.get(pc(n.label))||1;return s>1?{...n,duplicateCount:s}:n})}function bp(e,t){for(const n of t||[]){const s=e==null?void 0:e[n];if(s!==void 0)return s}}function vp({inventory:e,registry:t,colors:n}){const[s,i]=m.useState({}),r=a=>i(u=>({...u,[a]:!u[a]})),o=a=>m.createElement("span",{key:"caret",style:{display:"inline-block",width:"10px",color:n.muted,transform:a?"rotate(90deg)":"none",transition:"transform 0.12s ease"}},"▸"),l=a=>m.createElement("pre",{key:"json",style:{margin:"4px 0 8px 18px",padding:"8px 10px",borderRadius:"8px",background:"rgba(0,0,0,0.35)",color:n.text,fontSize:"10px",lineHeight:1.5,maxHeight:"180px",overflow:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word"}},a===void 0?"not loaded in this scene":JSON.stringify(a,null,2)),c=(a,u,f)=>{const p=!!s[u],g=m.createElement(f?"button":"div",{key:"head",...f?{onClick:()=>r(u)}:{},style:{display:"flex",alignItems:"flex-start",gap:"6px",width:"100%",padding:"4px 0",background:"none",border:"none",textAlign:"left",cursor:f?"pointer":"default",fontSize:"11px",color:n.text}},f?o(p):null,m.createElement("div",{key:"label",style:{minWidth:0,flex:1}},m.createElement("div",{key:"name",style:{fontFamily:"monospace",wordBreak:"break-all"}},a.label),a.detail?m.createElement("div",{key:"detail",style:{color:n.muted,fontSize:"10px"}},a.detail):null),a.duplicateCount?m.createElement("span",{key:"dup",title:"Same endpoint used by multiple sources",style:{flex:"0 0 auto",padding:"1px 6px",borderRadius:"999px",fontSize:"9px",fontWeight:700,color:n.warn,border:`1px solid ${n.warn}`}},`×${a.duplicateCount}`):null);return m.createElement("div",{key:u,style:{paddingLeft:"16px"}},g,f&&p?l(bp(t,a.lookup)):null)},h=(a,u)=>{const f=e[a],p=!!s[a];return m.createElement("div",{key:a,style:{borderBottom:`1px solid ${n.border}`}},m.createElement("button",{key:"head",onClick:()=>r(a),style:{display:"flex",alignItems:"center",gap:"6px",width:"100%",padding:"8px 0",background:"none",border:"none",cursor:"pointer",textAlign:"left",fontSize:"11px",fontWeight:600,color:n.text}},o(p),m.createElement("span",{key:"label"},u),m.createElement("span",{key:"count",style:{color:n.muted,marginLeft:"auto"}},String(f.length))),p?m.createElement("div",{key:"items",style:{paddingBottom:"6px"}},...f.map((g,d)=>c(g,`${a}-${d}`,a==="sources"))):null)};return m.createElement("div",null,h("scenes","Scenes"),h("modals","Modals"),h("widgets","Widgets"),h("actions","Actions"),h("sources","Sources"))}const Ku={activity:xt.FiActivity,"alert-triangle":xt.FiAlertTriangle,archive:xt.FiArchive,"arrow-left":xt.FiArrowLeft,"arrow-right":xt.FiArrowRight,check:xt.FiCheck,"check-circle":xt.FiCheckCircle,"check-square":xt.FiCheckSquare,"chevron-down":xt.FiChevronDown,clock:xt.FiClock,copy:xt.FiCopy,"corner-up-left":xt.FiCornerUpLeft,cpu:xt.FiCpu,eye:xt.FiEye,"eye-off":xt.FiEyeOff,film:xt.FiFilm,image:xt.FiImage,"log-out":xt.FiLogOut,mail:xt.FiMail,"maximize-2":xt.FiMaximize2,"message-square":xt.FiMessageSquare,"minimize-2":xt.FiMinimize2,octagon:xt.FiOctagon,paperclip:xt.FiPaperclip,pin:Xo.LuPin,"pin-off":Xo.LuPinOff,play:xt.FiPlay,plus:xt.FiPlus,"refresh-cw":xt.FiRefreshCw,"rotate-cw":xt.FiRotateCw,save:xt.FiSave,search:xt.FiSearch,send:xt.FiSend,"share-2":xt.FiShare2,sun:xt.FiSun,"trash-2":xt.FiTrash2,user:xt.FiUser,"user-x":xt.FiUserX,x:xt.FiX},xp={...Ku,"fa-play":tp.FaPlay,sparkles:Xo.LuSparkles};function wp(e){return Ku[e]||null}function Sp(e){return xp[e]||null}function Na(e,t,n){const s=Sp(e);return s?m.createElement(s,{size:t,style:{...n,flexShrink:0}}):m.createElement("span",{style:{fontSize:`${t}px`,lineHeight:1,...n}},e)}const Cp=["go_to_step","navigate","show_modal","execute_workflow","fetch","set_data","scroll_to","auth","toast","show_toast","copy_to_clipboard"],kp=new Set(["go_back","toggle_theme","close_modal","toggle_select","accept_startup_modal","decline_startup_modal"]);function*ta(e,t="$"){if(Array.isArray(e)){for(let n=0;n<e.length;n++)yield*ta(e[n],`${t}[${n}]`);return}if(!(!e||typeof e!="object")){yield[e,t];for(const[n,s]of Object.entries(e))s&&typeof s=="object"&&(yield*ta(s,`${t}.${n}`))}}function Mp(e){const t=e.trim().match(/^(GET|POST|PUT|PATCH|DELETE)\s+(.+)$/i);return t?{method:t[1].toUpperCase(),path:t[2].trim()}:{method:"GET",path:e.trim()}}function Ep(e){const t=e.startsWith("$.modals.")?"modal":"",n=[...e.matchAll(/\.(?:components|children|content)\[(\d+)\]/g)].map(s=>s[1]);if(n.length!==0)return`${t}-${n.join("-")}`}function Tp(e){var k;const t=[],n=(S,T,P,I,L)=>t.push({level:S,code:T,where:P,msg:I,targetKey:L});if(!e)return t;const s=Array.isArray(e.steps)?e.steps:[],i=new Set(s.map(S=>S.id)),r=new Set(s.map(S=>S.route).filter(Boolean)),o=new Set(Object.keys(e.modals||{})),l=Array.isArray(e.widgets)?e.widgets:[],c=new Set(l.map(S=>S.id).filter(Boolean)),h=[...ta(e)],a=S=>{var L,O;const T=S.match(/^\$\.steps\[(\d+)\]/);if(T)return((L=s[+T[1]])==null?void 0:L.id)||`step[${T[1]}]`;const P=S.match(/^\$\.widgets\[(\d+)\]/);if(P)return`widget:${((O=l[+P[1]])==null?void 0:O.id)??P[1]}`;const I=S.match(/^\$\.modals\.([^.[]+)/);return I?`modal:${I[1]}`:S.split(".")[1]||"root"},u=[],f=[],p=[],g=[];for(const[S,T]of h){const P=`${a(T)}`,I=Ep(T),L=typeof S.endpoint=="string",O=typeof S.onClick=="string"?S.onClick:!L&&typeof S.action=="string"?S.action:"";for(const H of["onClick","action","onSubmit","onChangeAction"])H==="action"&&L||typeof S[H]=="string"&&u.push({raw:S[H],where:P,node:S,targetKey:I});typeof S.widgetId=="string"&&!c.has(S.widgetId)&&n("error","WIDGET_MISSING",P,`widgetId "${S.widgetId}" not declared in widgets[]`,I),typeof S.dataSource=="string"&&f.push({src:S.dataSource,where:P,node:S,targetKey:I}),S.feedback&&O&&p.push({fb:S.feedback,where:P,node:S,targetKey:I}),typeof S.preload=="string"&&u.push({raw:`fetch:${S.preload}`,where:P,node:S,targetKey:I}),S.upgradeScene&&!i.has(S.upgradeScene)&&n("error","SCENE_MISSING",P,`upgradeScene "${S.upgradeScene}" has no step`,I)}(k=e.config)!=null&&k.startupModal&&!o.has(e.config.startupModal)&&n("error","MODAL_MISSING","config",`startupModal "${e.config.startupModal}" not in modals`),r.has("/")||n("warn","NO_ROOT_ROUTE","config",'no step declares "route": "/"');const d=(S,T,P,I)=>{var D;const L=S.match(/^\{\{\s*(.+?)\s*\?\s*(.*?)\s+:\s+(.*?)\s*\}\}$/);if(L){d(L[2].trim(),T,P,I),d(L[3].trim(),T,P,I);return}const O=S.split(";").map(V=>V.trim()).filter(Boolean);if(O.length>1){for(const V of O)d(V,T,P,I);return}const H=O[0]??"";if(!H)return n("error","ACTION_EMPTY",T,"empty action string",I);if(kp.has(H)||/^sdk:[\w.]+\(/.test(H))return;const U=H.split(":")[0],q=H.slice(U.length+1);if(U.includes("{{"))return n("warn","ACTION_DYNAMIC",T,`"${H}" — verb resolves at runtime`,I);if(!Cp.includes(U))return n("error","ACTION_UNKNOWN",T,`"${H}" — renderer will no-op`,I);if(U==="go_to_step"){const V=q.split("?")[0].trim();V!=="/"&&!i.has(V)&&!r.has(V)&&n("error","SCENE_MISSING",T,`go_to_step:${V} has no step or route`,I);return}if(U==="show_modal"){!o.has(q)&&!q.includes("|")&&n("error","MODAL_MISSING",T,`show_modal:${q} not in modals`,I);return}if(U==="set_data"){/^([\w.]+)=(.*)$/.test(q)||n("error","SETDATA_MALFORMED",T,`set_data must be "key=value", got "${q}"`,I);return}if(U==="auth"){/^(login|register|forgot|reset|logout)$/.test(q)||n("error","AUTH_UNKNOWN",T,`auth:${q} unsupported`,I);return}if(U==="scroll_to"){h.some(([J])=>J.scrollTarget===q||J.id===q)||n("warn","ANCHOR_MISSING",T,`scroll_to:${q} — no matching anchor`,I);return}if(U==="navigate"||U==="toast"||U==="show_toast"||U==="copy_to_clipboard")return;const{method:X,path:j}=Mp(q);g.push({method:X,path:j}),!j.startsWith("/")&&!/^https?:/.test(j)&&!j.includes("{{")&&n("error","ROUTE_RELATIVE",T,`route "${j}" should start with "/"`,I),X!=="GET"&&(!P.refetchScope&&!P.optimistic&&n("warn","NO_REFETCH",T,`${X} ${j} has no refetchScope`,I),X==="DELETE"&&!((D=P.confirmation)!=null&&D.enabled)&&n("warn","NO_CONFIRM",T,`DELETE ${j} has no confirmation`,I),!P.onSuccess&&!P.onError&&n("warn","NO_FEEDBACK_UI",T,`${X} ${j} has no onSuccess/onError`,I))};for(const{raw:S,where:T,node:P,targetKey:I}of u)d(String(S),T,P,I);for(const{fb:S,where:T,node:P,targetKey:I}of p){const L=typeof S=="string"?S:S==null?void 0:S.transport;if(!L){n("error","FEEDBACK_NO_TRANSPORT",T,"feedback missing transport",I);continue}if(["sse","ws","websocket","poll"].includes(L)||n("error","FEEDBACK_TRANSPORT",T,`unknown transport "${L}"`,I),typeof S=="object"&&S.subscribeUrl){const U=String(S.subscribeUrl).trim(),q=U.startsWith("{{")&&U.endsWith("}}")?U.slice(2,-2).trim():U;/^(subscribe\.|\[.+\])/.test(q)||q.startsWith("/")||n("warn","SUBSCRIBE_URL",T,`subscribeUrl "${U}" may not resolve from the response`,I)}const O=String(P.onClick||P.action||"");O.includes("execute_workflow:")||O.includes("fetch:")||n("warn","FEEDBACK_ORPHAN",T,"feedback declared but node triggers no route",I)}const w=new Set(f.map(({node:S})=>S.key).filter(Boolean));for(const{src:S,where:T,node:P,targetKey:I}of f)S.startsWith("sdk:")?/^sdk:[\w.]+\(/.test(S)||n("error","SDK_CALL_MALFORMED",T,`"${S}" is not a callable sdk expression`,I):!S.startsWith("/")&&!/^https?:/.test(S)?n("error","DATASOURCE_RELATIVE",T,`dataSource "${S}" should start with "/"`,I):S.includes("{{")||g.push({method:"GET",path:S}),P.key||n("warn","NO_DATA_KEY",T,`list "${S}" has no key — refetch matching will miss it`,I),P.realtime&&!P.realtime.mode&&n("error","REALTIME_NO_MODE",T,"realtime block missing mode (sse|ws)",I);const C=new Set(g.map(S=>S.path.replace(/^\//,""))),x=JSON.stringify(e).match(/\{\{\[(.+?)\]/g)||[];for(const S of new Set(x)){const T=S.slice(3,-1);!w.has(T)&&!C.has(T)&&n("warn","REGISTRY_REF","bindings",`{{[${T}]}} has no list key or route producing it`)}return n("ok","SUMMARY","workflow",`${s.length} scenes · ${o.size} modals · ${c.size} widgets · ${u.length} actions · ${f.length} sources`),t}function Ap(){if(typeof window>"u")return!1;try{if(window.localStorage.getItem("backflow_dev_diagnostics")==="1")return!0;if(window.localStorage.getItem("backflow_dev_diagnostics")==="0")return!1}catch{}const e=window.location.hostname;return e==="localhost"||e==="127.0.0.1"||e==="[::1]"||e.endsWith(".local")||e.endsWith(".localhost")}const ri={error:"#f87171",warn:"#fbbf24",ok:"#4ade80"};function Rp({workflow:e,ctx:t}){const[n,s]=m.useState(!1),[i,r]=m.useState("issues"),[o,l]=m.useState("all"),c=m.useMemo(()=>Tp(e),[e]),h=m.useMemo(()=>gp(e),[e]),a={error:c.filter(D=>D.level==="error").length,warn:c.filter(D=>D.level==="warn").length},u=t.colorMode==="dark",f=u?"#12121a":"#ffffff",p=u?"#e5e7eb":"#1f2937",g=u?"#6b7280":"#9ca3af",d=u?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",w=a.error||a.warn,C=a.error?ri.error:ri.warn,x=D=>{if(typeof document>"u")return null;if(D.targetKey){const nt=typeof CSS<"u"&&CSS.escape?CSS.escape(D.targetKey):D.targetKey.replace(/(["\\])/g,"\\$1"),it=document.querySelector(`[data-component-key="${nt}"]`);if(it)return it}const V=D.where.match(/^widget:(.+)$/);if(!V)return null;const J=typeof CSS<"u"&&CSS.escape?CSS.escape(`-${V[1]}-`):`-${V[1]}-`.replace(/(["\\])/g,"\\$1");return document.querySelector(`[data-component-key*="${J}"]`)},k=(D,V)=>{D.scrollIntoView({behavior:"smooth",block:"center"});const J=D.style.outline,nt=D.style.outlineOffset;D.style.outline=`3px solid ${ri[V]}`,D.style.outlineOffset="3px",window.setTimeout(()=>{D.style.outline=J,D.style.outlineOffset=nt},1800)},S=D=>{var it,Q;const V=x(D);if(V){k(V,D.level);return}const J=D.where.match(/^modal:([^\s]+)/);J&&((it=t.openModal)==null||it.call(t,J[1])),D.where&&!D.where.includes(":")&&D.where!=="workflow"&&D.where!==t.sceneId&&((Q=t.navigateToScene)==null||Q.call(t,D.where)),window.setTimeout(()=>{const ut=x(D);ut&&k(ut,D.level)},80)},T=m.useCallback(()=>{const D=h.sources.map(V=>{var J;for(const nt of V.lookup||[])if(((J=t.registry)==null?void 0:J[nt])!==void 0)return{...V,loaded:!0,registryKey:nt,data:t.registry[nt]};return{...V,loaded:!1,registryKey:null,data:null}});return{generatedAt:new Date().toISOString(),sceneId:t.sceneId,authenticated:t.isAuthenticated,counts:{errors:a.error,warnings:a.warn,issues:a.error+a.warn,total:c.length},inventory:{scenes:h.scenes.length,modals:h.modals.length,widgets:h.widgets.length,actions:h.actions.length,sources:h.sources.length},issues:c,data:{...h,sources:D},runtime:{sceneDataKeys:Object.keys(t.sceneData||{}).sort(),registryKeys:Object.keys(t.registry||{}).sort()}}},[a.error,a.warn,t,h,c]);m.useEffect(()=>{if(typeof window>"u")return;const D={getReport:()=>T(),sendReport:async()=>{const V=T();return t.submitReport?t.submitReport(V):{submitted:!1,report:V}}};return window.__backflowDiagnostics=D,()=>{window.__backflowDiagnostics===D&&delete window.__backflowDiagnostics}},[T,t.submitReport]);const P=m.createElement("button",{key:"bf-diag-toggle","aria-label":"UI diagnostics",onClick:()=>s(D=>!D),style:{position:"fixed",bottom:"20px",right:"20px",zIndex:10060,width:"44px",height:"44px",borderRadius:"999px",border:`1px solid ${d}`,background:f,color:w?C:g,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",boxShadow:"0 6px 24px rgba(0,0,0,0.35)"}},Na("activity",18),w?m.createElement("span",{key:"count",style:{position:"absolute",top:"-4px",right:"-4px",minWidth:"18px",height:"18px",padding:"0 4px",borderRadius:"999px",background:C,color:"#0b0b0f",fontSize:"10px",fontWeight:700,display:"flex",alignItems:"center",justifyContent:"center"}},String(w)):null);if(!n)return m.createElement(m.Fragment,null,P);const I=o==="all"?c:c.filter(D=>D.level===o),L=()=>{const D=T(),V=new Blob([JSON.stringify(D,null,2)],{type:"application/json"}),J=URL.createObjectURL(V),nt=document.createElement("a");nt.href=J,nt.download="diagnostics.json",nt.click(),URL.revokeObjectURL(J)},O=(D,V)=>m.createElement("button",{key:D,onClick:()=>r(D),style:{padding:"4px 10px",borderRadius:"999px",border:"none",cursor:"pointer",fontSize:"11px",fontWeight:600,background:i===D?"#8b5cf6":"transparent",color:i===D?"#ffffff":g}},V),H=(D,V)=>m.createElement("button",{key:D,onClick:()=>l(D),style:{padding:"2px 8px",borderRadius:"999px",border:`1px solid ${o===D?"#8b5cf6":d}`,cursor:"pointer",fontSize:"10px",background:"transparent",color:o===D?"#a78bfa":g}},V),U=(D,V)=>m.createElement(D.level==="ok"?"div":"button",{key:`${D.code}-${V}`,...D.level!=="ok"?{onClick:()=>S(D)}:{},style:{display:"flex",gap:"8px",width:"100%",padding:"7px 0",borderBottom:`1px solid ${d}`,borderLeft:"none",borderRight:"none",borderTop:"none",background:"transparent",fontSize:"11px",lineHeight:1.45,textAlign:"left",cursor:D.level==="ok"?"default":"pointer"}},m.createElement("span",{key:"dot",style:{flex:"0 0 auto",width:"6px",height:"6px",marginTop:"5px",borderRadius:"999px",background:ri[D.level]}}),m.createElement("div",{key:"body",style:{minWidth:0}},m.createElement("div",{key:"head",style:{color:g,fontSize:"10px",fontFamily:"monospace"}},`${D.code} · ${D.where}`),m.createElement("div",{key:"msg",style:{color:p}},D.msg))),q=(D,V)=>m.createElement("div",{key:D,style:{display:"flex",gap:"8px",padding:"6px 0",borderBottom:`1px solid ${d}`,fontSize:"11px"}},m.createElement("span",{key:"k",style:{color:g,flex:"0 0 92px"}},D),m.createElement("span",{key:"v",style:{color:p,fontFamily:"monospace",wordBreak:"break-all"}},V||"—")),X=[q("scene",t.sceneId),q("auth",t.isAuthenticated?"authenticated":"anonymous"),q("sceneData",Object.keys(t.sceneData||{}).sort().join(", ")),q("registry",Object.keys(t.registry||{}).sort().join(", "))],j=m.createElement("div",{key:"bf-diag-panel",style:{position:"fixed",bottom:"74px",right:"20px",zIndex:10060,width:"min(420px, calc(100vw - 40px))",maxHeight:"min(60vh, 520px)",display:"flex",flexDirection:"column",borderRadius:"16px",border:`1px solid ${d}`,background:f,color:p,boxShadow:"0 20px 60px rgba(0,0,0,0.45)",overflow:"hidden"}},m.createElement("div",{key:"head",style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",borderBottom:`1px solid ${d}`}},m.createElement("span",{key:"title",style:{fontSize:"12px",fontWeight:700,marginRight:"auto"}},"UI diagnostics"),m.createElement("button",{key:"export-json",onClick:L,style:{padding:"4px 9px",borderRadius:"999px",border:`1px solid ${d}`,background:"transparent",color:g,cursor:"pointer",fontSize:"11px",fontWeight:600}},"Export JSON"),O("issues",`Issues ${a.error+a.warn}`),O("runtime","Runtime"),O("data","Data")),i==="issues"?m.createElement("div",{key:"filters",style:{display:"flex",gap:"6px",padding:"8px 14px 4px"}},H("all",`All ${c.length}`),H("error",`Errors ${a.error}`),H("warn",`Warnings ${a.warn}`)):null,m.createElement("div",{key:"body",style:{padding:"4px 14px 14px",overflowY:"auto",flex:1}},...i==="issues"?I.map(U):i==="runtime"?X:[m.createElement(vp,{key:"data-tree",inventory:h,registry:t.registry||{},colors:{text:p,muted:g,border:d,warn:ri.warn}})]));return m.createElement(m.Fragment,null,j,P)}function Pp(e,t){return!(t.enabled??Ap())||!e?null:m.createElement(Rp,{key:"bf-dev-diagnostics",workflow:e,ctx:t})}const Ia=m.createContext({});function Da(e){const t=m.useRef(null);return t.current===null&&(t.current=e()),t.current}const jr=m.createContext(null),La=m.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});class _p extends Ra.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent){const s=this.props.sizeRef.current;s.height=n.offsetHeight||0,s.width=n.offsetWidth||0,s.top=n.offsetTop,s.left=n.offsetLeft}return null}componentDidUpdate(){}render(){return this.props.children}}function $p({children:e,isPresent:t}){const n=m.useId(),s=m.useRef(null),i=m.useRef({width:0,height:0,top:0,left:0}),{nonce:r}=m.useContext(La);return m.useInsertionEffect(()=>{const{width:o,height:l,top:c,left:h}=i.current;if(t||!s.current||!o||!l)return;s.current.dataset.motionPopId=n;const a=document.createElement("style");return r&&(a.nonce=r),document.head.appendChild(a),a.sheet&&a.sheet.insertRule(`
1
+ "use strict";var Yp=Object.defineProperty;var Xp=(e,t,n)=>t in e?Yp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var il=(e,t,n)=>Xp(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("react"),Jp=require("react-icons/fa"),Yt=require("react-icons/fi"),Bl=require("react-icons/lu"),De=require("react/jsx-runtime"),Th=require("@squeed/flow-sdk"),_c=require("react-dom");function Qp(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const wc=Qp(v);function ts(e){return e.length>2e3?`${e.slice(0,2e3)}…`:e}const Kp={button:"button, [role='button'], a",link:"a",input:"input, textarea",select:"select",textarea:"textarea",checkbox:"input[type='checkbox']"};function Ol(e){return(e||"").replace(/\s+/g," ").trim().toLowerCase()}function tg(e,t){if(!t.text)return!0;const n=Ol(t.text);return[e.textContent,e.placeholder,e.getAttribute("aria-label"),e.getAttribute("title"),e.value].map(Ol).some(i=>t.exact?i===n:i.includes(n))}function La(e,t=document){const n=e.role?Kp[e.role]||e.role:"*";return Array.from(t.querySelectorAll(n)).filter(i=>e.name&&i.getAttribute("name")!==e.name?!1:tg(i,e))}function os(e,t=document){return La(e,t)[e.index??0]||null}let Os=!1;function nf(e){Os=e}function sf(){return Os}function rf(e,t){if(!Os)return!1;const n=os(e,t);return n?(n.click(),!0):!1}async function eg(e){if(!Os)return!1;const t=os(e);if(!t)return!1;let n=document.getElementById("__bf_remote_cursor");n||(n=document.body.appendChild(document.createElement("div")),n.id="__bf_remote_cursor",n.innerHTML='<svg width="22" height="30" viewBox="0 0 22 30" fill="none"><path d="M2 1.5 L2 22.5 L7.6 17.4 L11.2 25.8 L14.8 24.2 L11.3 16.1 L18.6 15.6 Z" fill="#fff" stroke="#111" stroke-width="1.6" stroke-linejoin="round"/></svg>',Object.assign(n.style,{position:"fixed",zIndex:"2147483647",pointerEvents:"none",width:"22px",height:"30px",transition:"left 180ms ease, top 180ms ease",filter:"drop-shadow(0 2px 3px rgba(0,0,0,0.45))",left:`${window.innerWidth-40}px`,top:`${window.innerHeight-48}px`}));const i=t.getBoundingClientRect();await new Promise(o=>requestAnimationFrame(()=>{n.style.left=`${i.left+i.width/2}px`,n.style.top=`${i.top+i.height/2}px`,o()})),await new Promise(o=>setTimeout(o,180));const r=document.body.appendChild(document.createElement("div"));return Object.assign(r.style,{position:"fixed",zIndex:"2147483646",pointerEvents:"none",left:n.style.left,top:n.style.top,width:"34px",height:"34px",border:"2px solid rgba(255,60,60,0.9)",borderRadius:"50%",transform:"translate(-50%, -50%)"}),r.animate([{transform:"translate(-50%, -50%) scale(0.3)",opacity:.9},{transform:"translate(-50%, -50%) scale(1)",opacity:0}],{duration:450}).finished.finally(()=>r.remove()),await n.animate([{transform:"scale(1)"},{transform:"scale(0.8)"},{transform:"scale(1)"}],{duration:160}).finished.catch(()=>{}),t.click(),!0}function Sc(e,t,n){var i;if(!Os)return!1;const r=os({...e,role:e.role||"input"},n);if(!r)return!1;const o=r.tagName==="TEXTAREA"?window.HTMLTextAreaElement:window.HTMLInputElement,l=(i=Object.getOwnPropertyDescriptor(o.prototype,"value"))==null?void 0:i.set;return l==null||l.call(r,t),r.dispatchEvent(new Event("input",{bubbles:!0})),r.dispatchEvent(new Event("change",{bubbles:!0})),!0}function Ph(e){const t=getComputedStyle(e).overflowY;return(t==="auto"||t==="scroll")&&e.scrollHeight>e.clientHeight}function ng(){const e=document.getElementById("__bf_remote_cursor"),t=Number.parseFloat((e==null?void 0:e.style.left)||""),n=Number.parseFloat((e==null?void 0:e.style.top)||"");let i=Number.isFinite(t)&&Number.isFinite(n)?document.elementFromPoint(t,n):null;for(;i instanceof HTMLElement;){if(Ph(i))return i;i=i.parentElement}return Array.from(document.querySelectorAll("body *")).find(Ph)||null}function of(e,t="down",n=600,i){const r=Math.min(Math.max(Math.abs(n),1),2e3),o=e?os(e,i):null;if(e&&!o)return!1;if(o)return o.scrollIntoView({behavior:"smooth",block:"center"}),!0;const l=ng();return l?(l.scrollBy({top:t==="down"?r:-r,behavior:"smooth"}),!0):(window.scrollBy({top:t==="down"?r:-r,behavior:"smooth"}),!0)}function af(e,t,n){if(!Os)return!1;const i=os(e,n),r=os(t,n);if(!i||!r)return!1;const o=i.getBoundingClientRect(),l=r.getBoundingClientRect(),h=1,u=(x,_,p,E)=>_.dispatchEvent(new PointerEvent(x,{bubbles:!0,cancelable:!0,clientX:p,clientY:E,pointerId:h,pointerType:"touch",isPrimary:!0})),f=o.left+o.width/2,c=o.top+o.height/2,m=l.left+l.width/2,y=l.top+l.height/2;return u("pointerdown",i,f,c),u("pointermove",r,m,y),u("pointerup",r,m,y),!0}function lf(e,t=1e5){const n=e?os(e):document.documentElement;if(!n)return"";const i=Math.min(Math.max(Math.floor(t),1),1e5);return n.outerHTML.slice(0,i)}async function cf(e){if(!Os)return!1;const t=Object.getPrototypeOf(async function(){}).constructor,n=await new t(e)();return JSON.parse(JSON.stringify(n??null))}let Eh=!1,yr=[];const ig=500;function en(e){yr.push(e),yr.length>ig&&yr.shift()}function hf(){if(Eh)return;Eh=!0,window.addEventListener("error",r=>{en({type:"error",message:r.message,source:r.filename,line:r.lineno,col:r.colno,time:Date.now()})}),window.addEventListener("unhandledrejection",r=>{var o;en({type:"rejection",message:((o=r.reason)==null?void 0:o.message)||String(r.reason),time:Date.now()})}),["error","warn"].forEach(r=>{const o=console[r].bind(console);console[r]=(...l)=>{en({type:"console",level:r,message:l.map(String).join(" "),time:Date.now()}),o(...l)}});const e=window.fetch.bind(window);window.fetch=async(...r)=>{var o,l;const h=typeof r[0]=="string"?r[0]:r[0].url,u=(((o=r[1])==null?void 0:o.method)||"GET").toUpperCase(),f=typeof((l=r[1])==null?void 0:l.body)=="string"?ts(r[1].body):void 0;try{const c=await e(...r),m=(c.headers.get("content-type")||"").includes("text/event-stream");if(c.body&&!m?c.clone().text().then(y=>en({type:"network",method:u,url:h,status:c.status,ok:c.ok,requestBody:f,responseBody:ts(y),time:Date.now()})).catch(()=>en({type:"network",method:u,url:h,status:c.status,ok:c.ok,requestBody:f,time:Date.now()})):en({type:"network",method:u,url:h,status:c.status,ok:c.ok,requestBody:f,time:Date.now()}),m&&c.body){const[y,x]=c.body.tee();c.__bfBody=y,Object.defineProperty(c,"body",{get:()=>y});const _=x.getReader(),p=new TextDecoder;(async()=>{try{for(;;){const{done:E,value:T}=await _.read();if(E)break;p.decode(T,{stream:!0}).split(`
2
+ `).filter(k=>k.startsWith("data:")).forEach(k=>en({type:"sse",url:h,data:ts(k.slice(5).trim()),time:Date.now()}))}}catch{}})()}return c}catch(c){throw en({type:"network",method:u,url:h,error:(c==null?void 0:c.message)||String(c),requestBody:f,time:Date.now()}),c}};const t=XMLHttpRequest.prototype.open,n=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function(r,o,...l){return this.__bfMethod=r,this.__bfUrl=o,t.apply(this,[r,o,...l])},XMLHttpRequest.prototype.send=function(r){return this.addEventListener("loadend",()=>{en({type:"network",method:this.__bfMethod||"GET",url:this.__bfUrl||"",status:this.status,ok:this.status>=200&&this.status<300,requestBody:typeof r=="string"?ts(r):void 0,responseBody:typeof this.responseText=="string"?ts(this.responseText):void 0,time:Date.now()})}),n.call(this,r)};const i=window.WebSocket;if(window.WebSocket=new Proxy(i,{construct(r,o){const l=new r(...o),h=String(o[0]);l.addEventListener("open",()=>en({type:"ws",url:h,direction:"open",time:Date.now()})),l.addEventListener("close",()=>en({type:"ws",url:h,direction:"close",time:Date.now()})),l.addEventListener("error",()=>en({type:"ws",url:h,direction:"error",time:Date.now()})),l.addEventListener("message",f=>en({type:"ws",url:h,direction:"receive",data:ts(String(f.data)),time:Date.now()}));const u=l.send.bind(l);return l.send=f=>(en({type:"ws",url:h,direction:"send",data:ts(String(f)),time:Date.now()}),u(f)),l}}),"EventSource"in window){const r=window.EventSource;window.EventSource=new Proxy(r,{construct(o,l){const h=new o(...l),u=String(l[0]);return h.addEventListener("message",f=>en({type:"sse",url:u,data:ts(String(f.data)),time:Date.now()})),h.addEventListener("error",()=>en({type:"ws",url:u,direction:"error",time:Date.now()})),h}})}}function Cc(e=!1){const t=[...yr];return e&&(yr=[]),t}function Mc(){yr=[]}let is=null;async function sg(e){var t,n;switch(e.command){case"trigger":return eg(e.matcher||{});case"fill":return Sc(e.matcher||{},e.value??"");case"scroll":return of(e.matcher,e.direction,e.amount);case"drag":return!e.sourceMatcher||!e.targetMatcher?!1:af(e.sourceMatcher,e.targetMatcher);case"getDom":return lf(e.matcher,e.maxChars);case"evaluate":return cf(e.script??"");case"diagnostics":{const i=window.__backflowDiagnostics;return i?e.submit?(t=i.sendReport)==null?void 0:t.call(i):(n=i.getReport)==null?void 0:n.call(i):{error:"UI diagnostics unavailable"}}case"find":return La(e.matcher||{}).map(i=>({tag:i.tagName.toLowerCase(),text:Ol(i.textContent)}));case"getLog":return Cc(e.clear);case"clearLog":return Mc(),!0;default:return{error:`Unknown command: ${e.command}`}}}function uf(e,t,n){if(is&&is.readyState<=WebSocket.OPEN)return;const i=new WebSocket(e);is=i;let r=!1;const o=()=>{r||(r=!0,i.send(JSON.stringify({type:"join_room",room:t})))};i.addEventListener("open",()=>{n?i.send(JSON.stringify({type:"auth",token:n})):o()}),i.addEventListener("message",async l=>{let h;try{h=JSON.parse(l.data)}catch{return}if(h.type==="authenticated"){o();return}if(!(h.type!=="agent_command"||h.room!==t)){window.dispatchEvent(new CustomEvent("backflow:remote-command",{detail:{active:!0}}));try{const u=await sg(h);i.send(JSON.stringify({type:"agent_command_result",room:t,requestId:h.requestId,result:u}))}finally{window.dispatchEvent(new CustomEvent("backflow:remote-command",{detail:{active:!1}}))}}}),i.addEventListener("close",()=>{is===i&&(is=null)})}function Fl(){is==null||is.close(),is=null}function df(){hf(),window.__backflowAgent={trigger:rf,fill:Sc,scroll:of,drag:af,getDom:lf,evaluate:cf,find:La,getLog:Cc,clearLog:Mc,isEnabled:sf}}const ho={primary:"#3b82f6",accent:"#db2777",background:"#111827",surface:"#1f2937",surfaceHover:"#374151",border:"#374151",borderSubtle:"rgba(255,255,255,0.1)",text:"#ffffff",textSecondary:"#d1d5db",textMuted:"#9ca3af",textPlaceholder:"#6b7280",danger:"#ef4444",success:"#22c55e",warning:"#eab308",info:"#3b82f6"},uo={primary:"#000000",accent:"#db2777",background:"#ffffff",surface:"#f9fafb",surfaceHover:"#f3f4f6",border:"#e5e7eb",borderSubtle:"rgba(0,0,0,0.06)",text:"#111827",textSecondary:"#4b5563",textMuted:"#6b7280",textPlaceholder:"#9ca3af",danger:"#ef4444",success:"#22c55e",warning:"#eab308",info:"#3b82f6"},rg={fontFamily:"inherit",headingFontFamily:"inherit",baseFontSize:"14px",headingFontSize:"24px",lineHeight:1.5},og={borderRadius:"8px",borderRadiusLg:"12px",borderRadiusSm:"4px",spacing:"8px",cardPadding:"16px",sectionGap:"12px",containerMaxWidth:"none"},ag={shadow:"0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06)",shadowLg:"0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06)",transition:"all 0.15s ease",hoverOpacity:.85,scrollBehavior:"smooth"},lg={buttonStyle:"solid",buttonRadius:"8px",inputStyle:"outline",inputRadius:"8px",cardBorder:!0,cardShadow:!1};function cg(e){const t=String(e).replace("#","");if(t.length!==6&&t.length!==3)return-1;const n=t.length===3?t.split("").map(l=>l+l).join(""):t,i=parseInt(n.slice(0,2),16),r=parseInt(n.slice(2,4),16),o=parseInt(n.slice(4,6),16);return(i*299+r*587+o*114)/1e3}function Wl(e){const t=cg(e);return t<0?"dark":t>128?"light":"dark"}const hg=/(^|\s)(bg-white|bg-gray-50|bg-gray-100|bg-gray-200|bg-indigo-50|bg-blue-50|text-gray-6\d\d|text-gray-7\d\d|text-gray-8\d\d|text-black|text-gray-9\d\d|border-gray-2\d\d|border-gray-3\d\d)/,ug=/(^|\s)(bg-gray-8\d\d|bg-gray-9\d\d|bg-slate-8\d\d|bg-slate-9\d\d|bg-zinc-8\d\d|bg-zinc-9\d\d|bg-neutral-8\d\d|bg-neutral-9\d\d|bg-black|text-gray-1\d\d|text-gray-2\d\d|text-gray-3\d\d|text-slate-1\d\d|text-slate-2\d\d|text-slate-3\d\d|border-gray-7\d\d|border-gray-8\d\d)/;function dg(e){if(!e||typeof e!="object")return null;const t=e.steps;if(!Array.isArray(t))return null;let n=0,i=0;const r=o=>{if(!o||typeof o!="object")return;const l=o,h=typeof l.className=="string"?l.className:"";hg.test(h)&&n++,ug.test(h)&&i++,Array.isArray(l.children)&&l.children.forEach(r),Array.isArray(l.components)&&l.components.forEach(r),l.component&&typeof l.component=="object"&&r(l.component)};return t.forEach(o=>{const l=o.config;l&&typeof l=="object"&&r(l)}),n===i?null:n>i?"light":"dark"}function ff(e,t,n,i){const r=t!=null&&t.colorMode||e!=null&&e.colorMode||n!=null&&n.colorMode?"declared":"default",o=(t==null?void 0:t.colorMode)??(e==null?void 0:e.colorMode)??(n==null?void 0:n.colorMode)??(typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),h=o!=="light"?{...ho}:{...uo};n!=null&&n.primaryColor&&(h.primary=n.primaryColor),n!=null&&n.accentColor&&(h.accent=n.accentColor);const u={...h,...(e==null?void 0:e.colors)||{},...(t==null?void 0:t.colors)||{}};if(i){const k=Wl(i);if(k!==o){const A=k==="light"?uo:ho;u.text=u.text||A.text,u.textSecondary=u.textSecondary||A.textSecondary,u.textMuted=u.textMuted||A.textMuted,u.textPlaceholder=u.textPlaceholder||A.textPlaceholder,u.surface=u.surface||A.surface,u.surfaceHover=u.surfaceHover||A.surfaceHover,u.border=u.border||A.border,u.borderSubtle=u.borderSubtle||A.borderSubtle}}const f={...rg,...(e==null?void 0:e.typography)||{},...(t==null?void 0:t.typography)||{}},c={...og,...(e==null?void 0:e.layout)||{},...(t==null?void 0:t.layout)||{}},m={...ag,...(e==null?void 0:e.effects)||{},...(t==null?void 0:t.effects)||{}},y={...lg,...(e==null?void 0:e.components)||{},...(t==null?void 0:t.components)||{}},x=(e==null?void 0:e.persistedKeys)||(t==null?void 0:t.persistedKeys),_=(t==null?void 0:t.fullscreen)??(e==null?void 0:e.fullscreen),p={...(e==null?void 0:e.toast)||{},...(t==null?void 0:t.toast)||{}},E=(t==null?void 0:t.startupModal)||(e==null?void 0:e.startupModal),T=(t==null?void 0:t.realtime)||(e==null?void 0:e.realtime);return{colorMode:o,colorModeSource:r,colors:u,typography:f,layout:c,effects:m,components:y,toast:p,persistedKeys:x,fullscreen:_,startupModal:E,realtime:T}}function*Vl(e,t="$"){if(Array.isArray(e)){for(let n=0;n<e.length;n++)yield*Vl(e[n],`${t}[${n}]`);return}if(!(!e||typeof e!="object")){yield[e,t];for(const[n,i]of Object.entries(e))i&&typeof i=="object"&&(yield*Vl(i,`${t}.${n}`))}}function fg(e){const t={scenes:[],modals:[],widgets:[],actions:[],sources:[]};if(!e)return t;const n=Array.isArray(e.steps)?e.steps:[],i=Array.isArray(e.widgets)?e.widgets:[],r=n.map(c=>{var m;return{label:c.id||"(unnamed)",detail:[c.route,(m=c.config)==null?void 0:m.sceneName,c.requiresAuth?"auth":null].filter(Boolean).join(" · ")}}),o=Object.entries(e.modals||{}).map(([c,m])=>({label:c,detail:[m==null?void 0:m.title,m!=null&&m.popover?"popover":null,m==null?void 0:m.size].filter(Boolean).join(" · ")})),l=i.map(c=>({label:c.id||"(unnamed)",detail:`${Array.isArray(c.components)?c.components.length:0} components`})),h=c=>{var _,p;const m=c.match(/^\$\.steps\[(\d+)\]/);if(m)return((_=n[+m[1]])==null?void 0:_.id)||`step[${m[1]}]`;const y=c.match(/^\$\.widgets\[(\d+)\]/);if(y)return`widget:${((p=i[+y[1]])==null?void 0:p.id)??y[1]}`;const x=c.match(/^\$\.modals\.([^.[]+)/);return x?`modal:${x[1]}`:c.split(".")[1]||"root"},u=[],f=[];for(const[c,m]of Vl(e)){const y=h(m),x=typeof c.endpoint=="string";for(const _ of["onClick","action","onSubmit","onChangeAction"])_==="action"&&x||typeof c[_]=="string"&&u.push({label:c[_],detail:y});typeof c.dataSource=="string"&&f.push({label:c.dataSource,detail:[y,c.key?`key: ${c.key}`:null].filter(Boolean).join(" · "),lookup:[c.key,c.dataSource.replace(/^\//,"")].filter(Boolean)})}return{scenes:r,modals:o,widgets:l,actions:u,sources:mg(f)}}function Lh(e){return e.startsWith("sdk:")?e.split("(")[0]:e.replace(/^\//,"").split("?")[0]}function mg(e){const t=new Map;for(const n of e){const i=Lh(n.label);t.set(i,(t.get(i)||0)+1)}return e.map(n=>{const i=t.get(Lh(n.label))||1;return i>1?{...n,duplicateCount:i}:n})}function pg(e,t){for(const n of t||[]){const i=e==null?void 0:e[n];if(i!==void 0)return i}}function gg({inventory:e,registry:t,colors:n}){const[i,r]=v.useState({}),o=c=>r(m=>({...m,[c]:!m[c]})),l=c=>v.createElement("span",{key:"caret",style:{display:"inline-block",width:"10px",color:n.muted,transform:c?"rotate(90deg)":"none",transition:"transform 0.12s ease"}},"▸"),h=c=>v.createElement("pre",{key:"json",style:{margin:"4px 0 8px 18px",padding:"8px 10px",borderRadius:"8px",background:"rgba(0,0,0,0.35)",color:n.text,fontSize:"10px",lineHeight:1.5,maxHeight:"180px",overflow:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word"}},c===void 0?"not loaded in this scene":JSON.stringify(c,null,2)),u=(c,m,y)=>{const x=!!i[m],_=v.createElement(y?"button":"div",{key:"head",...y?{onClick:()=>o(m)}:{},style:{display:"flex",alignItems:"flex-start",gap:"6px",width:"100%",padding:"4px 0",background:"none",border:"none",textAlign:"left",cursor:y?"pointer":"default",fontSize:"11px",color:n.text}},y?l(x):null,v.createElement("div",{key:"label",style:{minWidth:0,flex:1}},v.createElement("div",{key:"name",style:{fontFamily:"monospace",wordBreak:"break-all"}},c.label),c.detail?v.createElement("div",{key:"detail",style:{color:n.muted,fontSize:"10px"}},c.detail):null),c.duplicateCount?v.createElement("span",{key:"dup",title:"Same endpoint used by multiple sources",style:{flex:"0 0 auto",padding:"1px 6px",borderRadius:"999px",fontSize:"9px",fontWeight:700,color:n.warn,border:`1px solid ${n.warn}`}},`×${c.duplicateCount}`):null);return v.createElement("div",{key:m,style:{paddingLeft:"16px"}},_,y&&x?h(pg(t,c.lookup)):null)},f=(c,m)=>{const y=e[c],x=!!i[c];return v.createElement("div",{key:c,style:{borderBottom:`1px solid ${n.border}`}},v.createElement("button",{key:"head",onClick:()=>o(c),style:{display:"flex",alignItems:"center",gap:"6px",width:"100%",padding:"8px 0",background:"none",border:"none",cursor:"pointer",textAlign:"left",fontSize:"11px",fontWeight:600,color:n.text}},l(x),v.createElement("span",{key:"label"},m),v.createElement("span",{key:"count",style:{color:n.muted,marginLeft:"auto"}},String(y.length))),x?v.createElement("div",{key:"items",style:{paddingBottom:"6px"}},...y.map((_,p)=>u(_,`${c}-${p}`,c==="sources"))):null)};return v.createElement("div",null,f("scenes","Scenes"),f("modals","Modals"),f("widgets","Widgets"),f("actions","Actions"),f("sources","Sources"))}const mf={activity:Yt.FiActivity,"alert-triangle":Yt.FiAlertTriangle,archive:Yt.FiArchive,"arrow-left":Yt.FiArrowLeft,"arrow-right":Yt.FiArrowRight,check:Yt.FiCheck,"check-circle":Yt.FiCheckCircle,"check-square":Yt.FiCheckSquare,"chevron-down":Yt.FiChevronDown,clock:Yt.FiClock,copy:Yt.FiCopy,"corner-up-left":Yt.FiCornerUpLeft,cpu:Yt.FiCpu,eye:Yt.FiEye,"eye-off":Yt.FiEyeOff,film:Yt.FiFilm,image:Yt.FiImage,"log-out":Yt.FiLogOut,mail:Yt.FiMail,"maximize-2":Yt.FiMaximize2,"message-square":Yt.FiMessageSquare,"minimize-2":Yt.FiMinimize2,octagon:Yt.FiOctagon,paperclip:Yt.FiPaperclip,pin:Bl.LuPin,"pin-off":Bl.LuPinOff,play:Yt.FiPlay,plus:Yt.FiPlus,"refresh-cw":Yt.FiRefreshCw,"rotate-cw":Yt.FiRotateCw,save:Yt.FiSave,search:Yt.FiSearch,send:Yt.FiSend,"share-2":Yt.FiShare2,sun:Yt.FiSun,"trash-2":Yt.FiTrash2,user:Yt.FiUser,"user-x":Yt.FiUserX,x:Yt.FiX},yg={...mf,"fa-play":Jp.FaPlay,sparkles:Bl.LuSparkles};function vg(e){return mf[e]||null}function bg(e){return yg[e]||null}function kc(e,t,n){const i=bg(e);return i?v.createElement(i,{size:t,style:{...n,flexShrink:0}}):v.createElement("span",{style:{fontSize:`${t}px`,lineHeight:1,...n}},e)}const xg=["go_to_step","navigate","show_modal","execute_workflow","fetch","set_data","scroll_to","auth","toast","show_toast","copy_to_clipboard"],_g=new Set(["go_back","toggle_theme","close_modal","toggle_select","accept_startup_modal","decline_startup_modal"]);function*jl(e,t="$"){if(Array.isArray(e)){for(let n=0;n<e.length;n++)yield*jl(e[n],`${t}[${n}]`);return}if(!(!e||typeof e!="object")){yield[e,t];for(const[n,i]of Object.entries(e))i&&typeof i=="object"&&(yield*jl(i,`${t}.${n}`))}}function wg(e){const t=e.trim().match(/^(GET|POST|PUT|PATCH|DELETE)\s+(.+)$/i);return t?{method:t[1].toUpperCase(),path:t[2].trim()}:{method:"GET",path:e.trim()}}function Sg(e){const t=e.startsWith("$.modals.")?"modal":"",n=[...e.matchAll(/\.(?:components|children|content)\[(\d+)\]/g)].map(i=>i[1]);if(n.length!==0)return`${t}-${n.join("-")}`}function Cg(e){var A;const t=[],n=(P,I,$,j,U)=>t.push({level:P,code:I,where:$,msg:j,targetKey:U});if(!e)return t;const i=Array.isArray(e.steps)?e.steps:[],r=new Set(i.map(P=>P.id)),o=new Set(i.map(P=>P.route).filter(Boolean)),l=new Set(Object.keys(e.modals||{})),h=Array.isArray(e.widgets)?e.widgets:[],u=new Set(h.map(P=>P.id).filter(Boolean)),f=[...jl(e)],c=P=>{var U,nt;const I=P.match(/^\$\.steps\[(\d+)\]/);if(I)return((U=i[+I[1]])==null?void 0:U.id)||`step[${I[1]}]`;const $=P.match(/^\$\.widgets\[(\d+)\]/);if($)return`widget:${((nt=h[+$[1]])==null?void 0:nt.id)??$[1]}`;const j=P.match(/^\$\.modals\.([^.[]+)/);return j?`modal:${j[1]}`:P.split(".")[1]||"root"},m=[],y=[],x=[],_=[];for(const[P,I]of f){const $=`${c(I)}`,j=Sg(I),U=typeof P.endpoint=="string",nt=typeof P.onClick=="string"?P.onClick:!U&&typeof P.action=="string"?P.action:"";for(const ot of["onClick","action","onSubmit","onChangeAction"])ot==="action"&&U||typeof P[ot]=="string"&&m.push({raw:P[ot],where:$,node:P,targetKey:j});typeof P.widgetId=="string"&&!u.has(P.widgetId)&&n("error","WIDGET_MISSING",$,`widgetId "${P.widgetId}" not declared in widgets[]`,j),typeof P.dataSource=="string"&&y.push({src:P.dataSource,where:$,node:P,targetKey:j}),P.feedback&&nt&&x.push({fb:P.feedback,where:$,node:P,targetKey:j}),typeof P.preload=="string"&&m.push({raw:`fetch:${P.preload}`,where:$,node:P,targetKey:j}),P.upgradeScene&&!r.has(P.upgradeScene)&&n("error","SCENE_MISSING",$,`upgradeScene "${P.upgradeScene}" has no step`,j)}(A=e.config)!=null&&A.startupModal&&!l.has(e.config.startupModal)&&n("error","MODAL_MISSING","config",`startupModal "${e.config.startupModal}" not in modals`),o.has("/")||n("warn","NO_ROOT_ROUTE","config",'no step declares "route": "/"');const p=(P,I,$,j)=>{var Z;const U=P.match(/^\{\{\s*(.+?)\s*\?\s*(.*?)\s+:\s+(.*?)\s*\}\}$/);if(U){p(U[2].trim(),I,$,j),p(U[3].trim(),I,$,j);return}const nt=P.split(";").map(tt=>tt.trim()).filter(Boolean);if(nt.length>1){for(const tt of nt)p(tt,I,$,j);return}const ot=nt[0]??"";if(!ot)return n("error","ACTION_EMPTY",I,"empty action string",j);if(_g.has(ot)||/^sdk:[\w.]+\(/.test(ot))return;const q=ot.split(":")[0],it=ot.slice(q.length+1);if(q.includes("{{"))return n("warn","ACTION_DYNAMIC",I,`"${ot}" — verb resolves at runtime`,j);if(!xg.includes(q))return n("error","ACTION_UNKNOWN",I,`"${ot}" — renderer will no-op`,j);if(q==="go_to_step"){const tt=it.split("?")[0].trim();tt!=="/"&&!r.has(tt)&&!o.has(tt)&&n("error","SCENE_MISSING",I,`go_to_step:${tt} has no step or route`,j);return}if(q==="show_modal"){!l.has(it)&&!it.includes("|")&&n("error","MODAL_MISSING",I,`show_modal:${it} not in modals`,j);return}if(q==="set_data"){/^([\w.]+)=(.*)$/.test(it)||n("error","SETDATA_MALFORMED",I,`set_data must be "key=value", got "${it}"`,j);return}if(q==="auth"){/^(login|register|forgot|reset|logout)$/.test(it)||n("error","AUTH_UNKNOWN",I,`auth:${it} unsupported`,j);return}if(q==="scroll_to"){f.some(([st])=>st.scrollTarget===it||st.id===it)||n("warn","ANCHOR_MISSING",I,`scroll_to:${it} — no matching anchor`,j);return}if(q==="navigate"||q==="toast"||q==="show_toast"||q==="copy_to_clipboard")return;const{method:ct,path:K}=wg(it);_.push({method:ct,path:K}),!K.startsWith("/")&&!/^https?:/.test(K)&&!K.includes("{{")&&n("error","ROUTE_RELATIVE",I,`route "${K}" should start with "/"`,j),ct!=="GET"&&(!$.refetchScope&&!$.optimistic&&n("warn","NO_REFETCH",I,`${ct} ${K} has no refetchScope`,j),ct==="DELETE"&&!((Z=$.confirmation)!=null&&Z.enabled)&&n("warn","NO_CONFIRM",I,`DELETE ${K} has no confirmation`,j),!$.onSuccess&&!$.onError&&n("warn","NO_FEEDBACK_UI",I,`${ct} ${K} has no onSuccess/onError`,j))};for(const{raw:P,where:I,node:$,targetKey:j}of m)p(String(P),I,$,j);for(const{fb:P,where:I,node:$,targetKey:j}of x){const U=typeof P=="string"?P:P==null?void 0:P.transport;if(!U){n("error","FEEDBACK_NO_TRANSPORT",I,"feedback missing transport",j);continue}if(["sse","ws","websocket","poll"].includes(U)||n("error","FEEDBACK_TRANSPORT",I,`unknown transport "${U}"`,j),typeof P=="object"&&P.subscribeUrl){const q=String(P.subscribeUrl).trim(),it=q.startsWith("{{")&&q.endsWith("}}")?q.slice(2,-2).trim():q;/^(subscribe\.|\[.+\])/.test(it)||it.startsWith("/")||n("warn","SUBSCRIBE_URL",I,`subscribeUrl "${q}" may not resolve from the response`,j)}const nt=String($.onClick||$.action||"");nt.includes("execute_workflow:")||nt.includes("fetch:")||n("warn","FEEDBACK_ORPHAN",I,"feedback declared but node triggers no route",j)}const E=new Set(y.map(({node:P})=>P.key).filter(Boolean));for(const{src:P,where:I,node:$,targetKey:j}of y)P.startsWith("sdk:")?/^sdk:[\w.]+\(/.test(P)||n("error","SDK_CALL_MALFORMED",I,`"${P}" is not a callable sdk expression`,j):!P.startsWith("/")&&!/^https?:/.test(P)?n("error","DATASOURCE_RELATIVE",I,`dataSource "${P}" should start with "/"`,j):P.includes("{{")||_.push({method:"GET",path:P}),$.key||n("warn","NO_DATA_KEY",I,`list "${P}" has no key — refetch matching will miss it`,j),$.realtime&&!$.realtime.mode&&n("error","REALTIME_NO_MODE",I,"realtime block missing mode (sse|ws)",j);const T=new Set(_.map(P=>P.path.replace(/^\//,""))),k=JSON.stringify(e).match(/\{\{\[(.+?)\]/g)||[];for(const P of new Set(k)){const I=P.slice(3,-1);!E.has(I)&&!T.has(I)&&n("warn","REGISTRY_REF","bindings",`{{[${I}]}} has no list key or route producing it`)}return n("ok","SUMMARY","workflow",`${i.length} scenes · ${l.size} modals · ${u.size} widgets · ${m.length} actions · ${y.length} sources`),t}function Mg(){if(typeof window>"u")return!1;try{if(window.localStorage.getItem("backflow_dev_diagnostics")==="1")return!0;if(window.localStorage.getItem("backflow_dev_diagnostics")==="0")return!1}catch{}const e=window.location.hostname;return e==="localhost"||e==="127.0.0.1"||e==="[::1]"||e.endsWith(".local")||e.endsWith(".localhost")}const Zr={error:"#f87171",warn:"#fbbf24",ok:"#4ade80"};function kg({workflow:e,ctx:t}){const[n,i]=v.useState(!1),[r,o]=v.useState("issues"),[l,h]=v.useState("all"),u=v.useMemo(()=>Cg(e),[e]),f=v.useMemo(()=>fg(e),[e]),c={error:u.filter(Z=>Z.level==="error").length,warn:u.filter(Z=>Z.level==="warn").length},m=t.colorMode==="dark",y=m?"#12121a":"#ffffff",x=m?"#e5e7eb":"#1f2937",_=m?"#6b7280":"#9ca3af",p=m?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",E=c.error||c.warn,T=c.error?Zr.error:Zr.warn,k=Z=>{if(typeof document>"u")return null;if(Z.targetKey){const J=typeof CSS<"u"&&CSS.escape?CSS.escape(Z.targetKey):Z.targetKey.replace(/(["\\])/g,"\\$1"),bt=document.querySelector(`[data-component-key="${J}"]`);if(bt)return bt}const tt=Z.where.match(/^widget:(.+)$/);if(!tt)return null;const st=typeof CSS<"u"&&CSS.escape?CSS.escape(`-${tt[1]}-`):`-${tt[1]}-`.replace(/(["\\])/g,"\\$1");return document.querySelector(`[data-component-key*="${st}"]`)},A=(Z,tt)=>{Z.scrollIntoView({behavior:"smooth",block:"center"});const st=Z.style.outline,J=Z.style.outlineOffset;Z.style.outline=`3px solid ${Zr[tt]}`,Z.style.outlineOffset="3px",window.setTimeout(()=>{Z.style.outline=st,Z.style.outlineOffset=J},1800)},P=Z=>{var bt,et;const tt=k(Z);if(tt){A(tt,Z.level);return}const st=Z.where.match(/^modal:([^\s]+)/);st&&((bt=t.openModal)==null||bt.call(t,st[1])),Z.where&&!Z.where.includes(":")&&Z.where!=="workflow"&&Z.where!==t.sceneId&&((et=t.navigateToScene)==null||et.call(t,Z.where)),window.setTimeout(()=>{const ht=k(Z);ht&&A(ht,Z.level)},80)},I=v.useCallback(()=>{const Z=f.sources.map(tt=>{var st;for(const J of tt.lookup||[])if(((st=t.registry)==null?void 0:st[J])!==void 0)return{...tt,loaded:!0,registryKey:J,data:t.registry[J]};return{...tt,loaded:!1,registryKey:null,data:null}});return{generatedAt:new Date().toISOString(),sceneId:t.sceneId,authenticated:t.isAuthenticated,counts:{errors:c.error,warnings:c.warn,issues:c.error+c.warn,total:u.length},inventory:{scenes:f.scenes.length,modals:f.modals.length,widgets:f.widgets.length,actions:f.actions.length,sources:f.sources.length},issues:u,data:{...f,sources:Z},runtime:{sceneDataKeys:Object.keys(t.sceneData||{}).sort(),registryKeys:Object.keys(t.registry||{}).sort()}}},[c.error,c.warn,t,f,u]);v.useEffect(()=>{if(typeof window>"u")return;const Z={getReport:()=>I(),sendReport:async()=>{const tt=I();return t.submitReport?t.submitReport(tt):{submitted:!1,report:tt}}};return window.__backflowDiagnostics=Z,()=>{window.__backflowDiagnostics===Z&&delete window.__backflowDiagnostics}},[I,t.submitReport]);const $=v.createElement("button",{key:"bf-diag-toggle","aria-label":"UI diagnostics",onClick:()=>i(Z=>!Z),style:{position:"fixed",bottom:"20px",right:"20px",zIndex:10060,width:"44px",height:"44px",borderRadius:"999px",border:`1px solid ${p}`,background:y,color:E?T:_,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",boxShadow:"0 6px 24px rgba(0,0,0,0.35)"}},kc("activity",18),E?v.createElement("span",{key:"count",style:{position:"absolute",top:"-4px",right:"-4px",minWidth:"18px",height:"18px",padding:"0 4px",borderRadius:"999px",background:T,color:"#0b0b0f",fontSize:"10px",fontWeight:700,display:"flex",alignItems:"center",justifyContent:"center"}},String(E)):null);if(!n)return v.createElement(v.Fragment,null,$);const j=l==="all"?u:u.filter(Z=>Z.level===l),U=()=>{const Z=I(),tt=new Blob([JSON.stringify(Z,null,2)],{type:"application/json"}),st=URL.createObjectURL(tt),J=document.createElement("a");J.href=st,J.download="diagnostics.json",J.click(),URL.revokeObjectURL(st)},nt=(Z,tt)=>v.createElement("button",{key:Z,onClick:()=>o(Z),style:{padding:"4px 10px",borderRadius:"999px",border:"none",cursor:"pointer",fontSize:"11px",fontWeight:600,background:r===Z?"#8b5cf6":"transparent",color:r===Z?"#ffffff":_}},tt),ot=(Z,tt)=>v.createElement("button",{key:Z,onClick:()=>h(Z),style:{padding:"2px 8px",borderRadius:"999px",border:`1px solid ${l===Z?"#8b5cf6":p}`,cursor:"pointer",fontSize:"10px",background:"transparent",color:l===Z?"#a78bfa":_}},tt),q=(Z,tt)=>v.createElement(Z.level==="ok"?"div":"button",{key:`${Z.code}-${tt}`,...Z.level!=="ok"?{onClick:()=>P(Z)}:{},style:{display:"flex",gap:"8px",width:"100%",padding:"7px 0",borderBottom:`1px solid ${p}`,borderLeft:"none",borderRight:"none",borderTop:"none",background:"transparent",fontSize:"11px",lineHeight:1.45,textAlign:"left",cursor:Z.level==="ok"?"default":"pointer"}},v.createElement("span",{key:"dot",style:{flex:"0 0 auto",width:"6px",height:"6px",marginTop:"5px",borderRadius:"999px",background:Zr[Z.level]}}),v.createElement("div",{key:"body",style:{minWidth:0}},v.createElement("div",{key:"head",style:{color:_,fontSize:"10px",fontFamily:"monospace"}},`${Z.code} · ${Z.where}`),v.createElement("div",{key:"msg",style:{color:x}},Z.msg))),it=(Z,tt)=>v.createElement("div",{key:Z,style:{display:"flex",gap:"8px",padding:"6px 0",borderBottom:`1px solid ${p}`,fontSize:"11px"}},v.createElement("span",{key:"k",style:{color:_,flex:"0 0 92px"}},Z),v.createElement("span",{key:"v",style:{color:x,fontFamily:"monospace",wordBreak:"break-all"}},tt||"—")),ct=[it("scene",t.sceneId),it("auth",t.isAuthenticated?"authenticated":"anonymous"),it("sceneData",Object.keys(t.sceneData||{}).sort().join(", ")),it("registry",Object.keys(t.registry||{}).sort().join(", "))],K=v.createElement("div",{key:"bf-diag-panel",style:{position:"fixed",bottom:"74px",right:"20px",zIndex:10060,width:"min(420px, calc(100vw - 40px))",maxHeight:"min(60vh, 520px)",display:"flex",flexDirection:"column",borderRadius:"16px",border:`1px solid ${p}`,background:y,color:x,boxShadow:"0 20px 60px rgba(0,0,0,0.45)",overflow:"hidden"}},v.createElement("div",{key:"head",style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",borderBottom:`1px solid ${p}`}},v.createElement("span",{key:"title",style:{fontSize:"12px",fontWeight:700,marginRight:"auto"}},"UI diagnostics"),v.createElement("button",{key:"export-json",onClick:U,style:{padding:"4px 9px",borderRadius:"999px",border:`1px solid ${p}`,background:"transparent",color:_,cursor:"pointer",fontSize:"11px",fontWeight:600}},"Export JSON"),nt("issues",`Issues ${c.error+c.warn}`),nt("runtime","Runtime"),nt("data","Data")),r==="issues"?v.createElement("div",{key:"filters",style:{display:"flex",gap:"6px",padding:"8px 14px 4px"}},ot("all",`All ${u.length}`),ot("error",`Errors ${c.error}`),ot("warn",`Warnings ${c.warn}`)):null,v.createElement("div",{key:"body",style:{padding:"4px 14px 14px",overflowY:"auto",flex:1}},...r==="issues"?j.map(q):r==="runtime"?ct:[v.createElement(gg,{key:"data-tree",inventory:f,registry:t.registry||{},colors:{text:x,muted:_,border:p,warn:Zr.warn}})]));return v.createElement(v.Fragment,null,K,$)}function Tg(e,t){return!(t.enabled??Mg())||!e?null:v.createElement(kg,{key:"bf-dev-diagnostics",workflow:e,ctx:t})}const Tc=v.createContext({});function Pc(e){const t=v.useRef(null);return t.current===null&&(t.current=e()),t.current}const Aa=v.createContext(null),Ec=v.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});class Pg extends wc.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent){const i=this.props.sizeRef.current;i.height=n.offsetHeight||0,i.width=n.offsetWidth||0,i.top=n.offsetTop,i.left=n.offsetLeft}return null}componentDidUpdate(){}render(){return this.props.children}}function Eg({children:e,isPresent:t}){const n=v.useId(),i=v.useRef(null),r=v.useRef({width:0,height:0,top:0,left:0}),{nonce:o}=v.useContext(Ec);return v.useInsertionEffect(()=>{const{width:l,height:h,top:u,left:f}=r.current;if(t||!i.current||!l||!h)return;i.current.dataset.motionPopId=n;const c=document.createElement("style");return o&&(c.nonce=o),document.head.appendChild(c),c.sheet&&c.sheet.insertRule(`
3
3
  [data-motion-pop-id="${n}"] {
4
4
  position: absolute !important;
5
- width: ${o}px !important;
6
- height: ${l}px !important;
7
- top: ${c}px !important;
8
- left: ${h}px !important;
5
+ width: ${l}px !important;
6
+ height: ${h}px !important;
7
+ top: ${u}px !important;
8
+ left: ${f}px !important;
9
9
  }
10
- `),()=>{document.head.removeChild(a)}},[t]),cn.jsx(_p,{isPresent:t,childRef:s,sizeRef:i,children:Ra.cloneElement(e,{ref:s})})}const Np=({children:e,initial:t,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:r,mode:o})=>{const l=Da(Ip),c=m.useId(),h=m.useCallback(u=>{l.set(u,!0);for(const f of l.values())if(!f)return;s&&s()},[l,s]),a=m.useMemo(()=>({id:c,initial:t,isPresent:n,custom:i,onExitComplete:h,register:u=>(l.set(u,!1),()=>l.delete(u))}),r?[Math.random(),h]:[n,h]);return m.useMemo(()=>{l.forEach((u,f)=>l.set(f,!1))},[n]),Ra.useEffect(()=>{!n&&!l.size&&s&&s()},[n]),o==="popLayout"&&(e=cn.jsx($p,{isPresent:n,children:e})),cn.jsx(jr.Provider,{value:a,children:e})};function Ip(){return new Map}function Zu(e=!0){const t=m.useContext(jr);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:i}=t,r=m.useId();m.useEffect(()=>{e&&i(r)},[e]);const o=m.useCallback(()=>e&&s&&s(r),[r,s,e]);return!n&&s?[!1,o]:[!0]}const Ji=e=>e.key||"";function gc(e){const t=[];return m.Children.forEach(e,n=>{m.isValidElement(n)&&t.push(n)}),t}const za=typeof window<"u",td=za?m.useLayoutEffect:m.useEffect,Dp=({children:e,custom:t,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:r="sync",propagate:o=!1})=>{const[l,c]=Zu(o),h=m.useMemo(()=>gc(e),[e]),a=o&&!l?[]:h.map(Ji),u=m.useRef(!0),f=m.useRef(h),p=Da(()=>new Map),[g,d]=m.useState(h),[w,C]=m.useState(h);td(()=>{u.current=!1,f.current=h;for(let S=0;S<w.length;S++){const T=Ji(w[S]);a.includes(T)?p.delete(T):p.get(T)!==!0&&p.set(T,!1)}},[w,a.length,a.join("-")]);const x=[];if(h!==g){let S=[...h];for(let T=0;T<w.length;T++){const P=w[T],I=Ji(P);a.includes(I)||(S.splice(T,0,P),x.push(P))}r==="wait"&&x.length&&(S=x),C(gc(S)),d(h);return}process.env.NODE_ENV!=="production"&&r==="wait"&&w.length>1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);const{forceRender:k}=m.useContext(Ia);return cn.jsx(cn.Fragment,{children:w.map(S=>{const T=Ji(S),P=o&&!l?!1:h===w||a.includes(T),I=()=>{if(p.has(T))p.set(T,!0);else return;let L=!0;p.forEach(O=>{O||(L=!1)}),L&&(k==null||k(),C(f.current),o&&(c==null||c()),s&&s())};return cn.jsx(Np,{isPresent:P,initial:!u.current||n?void 0:!1,custom:P?void 0:t,presenceAffectsLayout:i,mode:r,onExitComplete:P?void 0:I,children:S},T)})})},Ae=e=>e;let Us=Ae,An=Ae;process.env.NODE_ENV!=="production"&&(Us=(e,t)=>{!e&&typeof console<"u"&&console.warn(t)},An=(e,t)=>{if(!e)throw new Error(t)});function Fa(e){let t;return()=>(t===void 0&&(t=e()),t)}const Fs=(e,t,n)=>{const s=t-e;return s===0?1:(n-e)/s},Qe=e=>e*1e3,hn=e=>e/1e3,Lp={useManualTiming:!1};function zp(e){let t=new Set,n=new Set,s=!1,i=!1;const r=new WeakSet;let o={delta:0,timestamp:0,isProcessing:!1};function l(h){r.has(h)&&(c.schedule(h),e()),h(o)}const c={schedule:(h,a=!1,u=!1)=>{const p=u&&s?t:n;return a&&r.add(h),p.has(h)||p.add(h),h},cancel:h=>{n.delete(h),r.delete(h)},process:h=>{if(o=h,s){i=!0;return}s=!0,[t,n]=[n,t],t.forEach(l),t.clear(),s=!1,i&&(i=!1,c.process(h))}};return c}const Ki=["read","resolveKeyframes","update","preRender","render","postRender"],Fp=40;function ed(e,t){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},r=()=>n=!0,o=Ki.reduce((C,x)=>(C[x]=zp(r),C),{}),{read:l,resolveKeyframes:c,update:h,preRender:a,render:u,postRender:f}=o,p=()=>{const C=performance.now();n=!1,i.delta=s?1e3/60:Math.max(Math.min(C-i.timestamp,Fp),1),i.timestamp=C,i.isProcessing=!0,l.process(i),c.process(i),h.process(i),a.process(i),u.process(i),f.process(i),i.isProcessing=!1,n&&t&&(s=!1,e(p))},g=()=>{n=!0,s=!0,i.isProcessing||e(p)};return{schedule:Ki.reduce((C,x)=>{const k=o[x];return C[x]=(S,T=!1,P=!1)=>(n||g(),k.schedule(S,T,P)),C},{}),cancel:C=>{for(let x=0;x<Ki.length;x++)o[Ki[x]].cancel(C)},state:i,steps:o}}const{schedule:Bt,cancel:Rn,state:me,steps:yo}=ed(typeof requestAnimationFrame<"u"?requestAnimationFrame:Ae,!0),nd=m.createContext({strict:!1}),yc={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},Bs={};for(const e in yc)Bs[e]={isEnabled:t=>yc[e].some(n=>!!t[n])};function Bp(e){for(const t in e)Bs[t]={...Bs[t],...e[t]}}const Wp=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function Er(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||Wp.has(e)}let sd=e=>!Er(e);function jp(e){e&&(sd=t=>t.startsWith("on")?!Er(t):e(t))}try{jp(require("@emotion/is-prop-valid").default)}catch{}function Vp(e,t,n){const s={};for(const i in e)i==="values"&&typeof e.values=="object"||(sd(i)||n===!0&&Er(i)||!t&&!Er(i)||e.draggable&&i.startsWith("onDrag"))&&(s[i]=e[i]);return s}const bc=new Set;function Vr(e,t,n){e||bc.has(t)||(console.warn(t),bc.add(t))}function Op(e){if(typeof Proxy>"u")return e;const t=new Map,n=(...s)=>(process.env.NODE_ENV!=="production"&&Vr(!1,"motion() is deprecated. Use motion.create() instead."),e(...s));return new Proxy(n,{get:(s,i)=>i==="create"?e:(t.has(i)||t.set(i,e(i)),t.get(i))})}const Or=m.createContext({});function Ei(e){return typeof e=="string"||Array.isArray(e)}function Ur(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}const Ba=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Wa=["initial",...Ba];function Hr(e){return Ur(e.animate)||Wa.some(t=>Ei(e[t]))}function id(e){return!!(Hr(e)||e.variants)}function Up(e,t){if(Hr(e)){const{initial:n,animate:s}=e;return{initial:n===!1||Ei(n)?n:void 0,animate:Ei(s)?s:void 0}}return e.inherit!==!1?t:{}}function Hp(e){const{initial:t,animate:n}=Up(e,m.useContext(Or));return m.useMemo(()=>({initial:t,animate:n}),[vc(t),vc(n)])}function vc(e){return Array.isArray(e)?e.join(" "):e}const qp=Symbol.for("motionComponentSymbol");function As(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function Gp(e,t,n){return m.useCallback(s=>{s&&e.onMount&&e.onMount(s),t&&(s?t.mount(s):t.unmount()),n&&(typeof n=="function"?n(s):As(n)&&(n.current=s))},[t])}const ja=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),Yp="framerAppearId",rd="data-"+ja(Yp),{schedule:Va}=ed(queueMicrotask,!1),od=m.createContext({});function Xp(e,t,n,s,i){var r,o;const{visualElement:l}=m.useContext(Or),c=m.useContext(nd),h=m.useContext(jr),a=m.useContext(La).reducedMotion,u=m.useRef(null);s=s||c.renderer,!u.current&&s&&(u.current=s(e,{visualState:t,parent:l,props:n,presenceContext:h,blockInitialAnimation:h?h.initial===!1:!1,reducedMotionConfig:a}));const f=u.current,p=m.useContext(od);f&&!f.projection&&i&&(f.type==="html"||f.type==="svg")&&Qp(u.current,n,i,p);const g=m.useRef(!1);m.useInsertionEffect(()=>{f&&g.current&&f.update(n,h)});const d=n[rd],w=m.useRef(!!d&&!(!((r=window.MotionHandoffIsComplete)===null||r===void 0)&&r.call(window,d))&&((o=window.MotionHasOptimisedAnimation)===null||o===void 0?void 0:o.call(window,d)));return td(()=>{f&&(g.current=!0,window.MotionIsMounted=!0,f.updateFeatures(),Va.render(f.render),w.current&&f.animationState&&f.animationState.animateChanges())}),m.useEffect(()=>{f&&(!w.current&&f.animationState&&f.animationState.animateChanges(),w.current&&(queueMicrotask(()=>{var C;(C=window.MotionHandoffMarkAsComplete)===null||C===void 0||C.call(window,d)}),w.current=!1))}),f}function Qp(e,t,n,s){const{layoutId:i,layout:r,drag:o,dragConstraints:l,layoutScroll:c,layoutRoot:h}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:ad(e.parent)),e.projection.setOptions({layoutId:i,layout:r,alwaysMeasureLayout:!!o||l&&As(l),visualElement:e,animationType:typeof r=="string"?r:"both",initialPromotionConfig:s,layoutScroll:c,layoutRoot:h})}function ad(e){if(e)return e.options.allowProjection!==!1?e.projection:ad(e.parent)}function Jp({preloadedFeatures:e,createVisualElement:t,useRender:n,useVisualState:s,Component:i}){var r,o;e&&Bp(e);function l(h,a){let u;const f={...m.useContext(La),...h,layoutId:Kp(h)},{isStatic:p}=f,g=Hp(h),d=s(h,p);if(!p&&za){Zp(f,e);const w=tg(f);u=w.MeasureLayout,g.visualElement=Xp(i,d,f,t,w.ProjectionNode)}return cn.jsxs(Or.Provider,{value:g,children:[u&&g.visualElement?cn.jsx(u,{visualElement:g.visualElement,...f}):null,n(i,h,Gp(d,g.visualElement,a),d,p,g.visualElement)]})}l.displayName=`motion.${typeof i=="string"?i:`create(${(o=(r=i.displayName)!==null&&r!==void 0?r:i.name)!==null&&o!==void 0?o:""})`}`;const c=m.forwardRef(l);return c[qp]=i,c}function Kp({layoutId:e}){const t=m.useContext(Ia).id;return t&&e!==void 0?t+"-"+e:e}function Zp(e,t){const n=m.useContext(nd).strict;if(process.env.NODE_ENV!=="production"&&t&&n){const s="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";e.ignoreStrict?Us(!1,s):An(!1,s)}}function tg(e){const{drag:t,layout:n}=Bs;if(!t&&!n)return{};const s={...t,...n};return{MeasureLayout:t!=null&&t.isEnabled(e)||n!=null&&n.isEnabled(e)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}const eg=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function Oa(e){return typeof e!="string"||e.includes("-")?!1:!!(eg.indexOf(e)>-1||/[A-Z]/u.test(e))}function xc(e){const t=[{},{}];return e==null||e.values.forEach((n,s)=>{t[0][s]=n.get(),t[1][s]=n.getVelocity()}),t}function Ua(e,t,n,s){if(typeof t=="function"){const[i,r]=xc(s);t=t(n!==void 0?n:e.custom,i,r)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[i,r]=xc(s);t=t(n!==void 0?n:e.custom,i,r)}return t}const ea=e=>Array.isArray(e),ng=e=>!!(e&&typeof e=="object"&&e.mix&&e.toValue),sg=e=>ea(e)?e[e.length-1]||0:e,ve=e=>!!(e&&e.getVelocity);function yr(e){const t=ve(e)?e.get():e;return ng(t)?t.toValue():t}function ig({scrapeMotionValuesFromProps:e,createRenderState:t,onUpdate:n},s,i,r){const o={latestValues:rg(s,i,r,e),renderState:t()};return n&&(o.onMount=l=>n({props:s,current:l,...o}),o.onUpdate=l=>n(l)),o}const ld=e=>(t,n)=>{const s=m.useContext(Or),i=m.useContext(jr),r=()=>ig(e,t,s,i);return n?r():Da(r)};function rg(e,t,n,s){const i={},r=s(e,{});for(const f in r)i[f]=yr(r[f]);let{initial:o,animate:l}=e;const c=Hr(e),h=id(e);t&&h&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),l===void 0&&(l=t.animate));let a=n?n.initial===!1:!1;a=a||o===!1;const u=a?l:o;if(u&&typeof u!="boolean"&&!Ur(u)){const f=Array.isArray(u)?u:[u];for(let p=0;p<f.length;p++){const g=Ua(e,f[p]);if(g){const{transitionEnd:d,transition:w,...C}=g;for(const x in C){let k=C[x];if(Array.isArray(k)){const S=a?k.length-1:0;k=k[S]}k!==null&&(i[x]=k)}for(const x in d)i[x]=d[x]}}}return i}const Hs=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],rs=new Set(Hs),cd=e=>t=>typeof t=="string"&&t.startsWith(e),hd=cd("--"),og=cd("var(--"),Ha=e=>og(e)?ag.test(e.split("/*")[0].trim()):!1,ag=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,ud=(e,t)=>t&&typeof e=="number"?t.transform(e):e,un=(e,t,n)=>n>t?t:n<e?e:n,qs={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Ti={...qs,transform:e=>un(0,1,e)},Zi={...qs,default:1},Ii=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),Cn=Ii("deg"),Je=Ii("%"),ct=Ii("px"),lg=Ii("vh"),cg=Ii("vw"),wc={...Je,parse:e=>Je.parse(e)/100,transform:e=>Je.transform(e*100)},hg={borderWidth:ct,borderTopWidth:ct,borderRightWidth:ct,borderBottomWidth:ct,borderLeftWidth:ct,borderRadius:ct,radius:ct,borderTopLeftRadius:ct,borderTopRightRadius:ct,borderBottomRightRadius:ct,borderBottomLeftRadius:ct,width:ct,maxWidth:ct,height:ct,maxHeight:ct,top:ct,right:ct,bottom:ct,left:ct,padding:ct,paddingTop:ct,paddingRight:ct,paddingBottom:ct,paddingLeft:ct,margin:ct,marginTop:ct,marginRight:ct,marginBottom:ct,marginLeft:ct,backgroundPositionX:ct,backgroundPositionY:ct},ug={rotate:Cn,rotateX:Cn,rotateY:Cn,rotateZ:Cn,scale:Zi,scaleX:Zi,scaleY:Zi,scaleZ:Zi,skew:Cn,skewX:Cn,skewY:Cn,distance:ct,translateX:ct,translateY:ct,translateZ:ct,x:ct,y:ct,z:ct,perspective:ct,transformPerspective:ct,opacity:Ti,originX:wc,originY:wc,originZ:ct},Sc={...qs,transform:Math.round},qa={...hg,...ug,zIndex:Sc,size:ct,fillOpacity:Ti,strokeOpacity:Ti,numOctaves:Sc},dg={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},fg=Hs.length;function mg(e,t,n){let s="",i=!0;for(let r=0;r<fg;r++){const o=Hs[r],l=e[o];if(l===void 0)continue;let c=!0;if(typeof l=="number"?c=l===(o.startsWith("scale")?1:0):c=parseFloat(l)===0,!c||n){const h=ud(l,qa[o]);if(!c){i=!1;const a=dg[o]||o;s+=`${a}(${h}) `}n&&(t[o]=h)}}return s=s.trim(),n?s=n(t,i?"":s):i&&(s="none"),s}function Ga(e,t,n){const{style:s,vars:i,transformOrigin:r}=e;let o=!1,l=!1;for(const c in t){const h=t[c];if(rs.has(c)){o=!0;continue}else if(hd(c)){i[c]=h;continue}else{const a=ud(h,qa[c]);c.startsWith("origin")?(l=!0,r[c]=a):s[c]=a}}if(t.transform||(o||n?s.transform=mg(t,e.transform,n):s.transform&&(s.transform="none")),l){const{originX:c="50%",originY:h="50%",originZ:a=0}=r;s.transformOrigin=`${c} ${h} ${a}`}}const pg={offset:"stroke-dashoffset",array:"stroke-dasharray"},gg={offset:"strokeDashoffset",array:"strokeDasharray"};function yg(e,t,n=1,s=0,i=!0){e.pathLength=1;const r=i?pg:gg;e[r.offset]=ct.transform(-s);const o=ct.transform(t),l=ct.transform(n);e[r.array]=`${o} ${l}`}function Cc(e,t,n){return typeof e=="string"?e:ct.transform(t+n*e)}function bg(e,t,n){const s=Cc(t,e.x,e.width),i=Cc(n,e.y,e.height);return`${s} ${i}`}function Ya(e,{attrX:t,attrY:n,attrScale:s,originX:i,originY:r,pathLength:o,pathSpacing:l=1,pathOffset:c=0,...h},a,u){if(Ga(e,h,u),a){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:f,style:p,dimensions:g}=e;f.transform&&(g&&(p.transform=f.transform),delete f.transform),g&&(i!==void 0||r!==void 0||p.transform)&&(p.transformOrigin=bg(g,i!==void 0?i:.5,r!==void 0?r:.5)),t!==void 0&&(f.x=t),n!==void 0&&(f.y=n),s!==void 0&&(f.scale=s),o!==void 0&&yg(f,o,l,c,!1)}const Xa=()=>({style:{},transform:{},transformOrigin:{},vars:{}}),dd=()=>({...Xa(),attrs:{}}),Qa=e=>typeof e=="string"&&e.toLowerCase()==="svg";function fd(e,{style:t,vars:n},s,i){Object.assign(e.style,t,i&&i.getProjectionStyles(s));for(const r in n)e.style.setProperty(r,n[r])}const md=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function pd(e,t,n,s){fd(e,t,void 0,s);for(const i in t.attrs)e.setAttribute(md.has(i)?i:ja(i),t.attrs[i])}const Tr={};function vg(e){Object.assign(Tr,e)}function gd(e,{layout:t,layoutId:n}){return rs.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!Tr[e]||e==="opacity")}function Ja(e,t,n){var s;const{style:i}=e,r={};for(const o in i)(ve(i[o])||t.style&&ve(t.style[o])||gd(o,e)||((s=n==null?void 0:n.getValue(o))===null||s===void 0?void 0:s.liveStyle)!==void 0)&&(r[o]=i[o]);return r}function yd(e,t,n){const s=Ja(e,t,n);for(const i in e)if(ve(e[i])||ve(t[i])){const r=Hs.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;s[r]=e[i]}return s}function xg(e,t){try{t.dimensions=typeof e.getBBox=="function"?e.getBBox():e.getBoundingClientRect()}catch{t.dimensions={x:0,y:0,width:0,height:0}}}const kc=["x","y","width","height","cx","cy","r"],wg={useVisualState:ld({scrapeMotionValuesFromProps:yd,createRenderState:dd,onUpdate:({props:e,prevProps:t,current:n,renderState:s,latestValues:i})=>{if(!n)return;let r=!!e.drag;if(!r){for(const l in i)if(rs.has(l)){r=!0;break}}if(!r)return;let o=!t;if(t)for(let l=0;l<kc.length;l++){const c=kc[l];e[c]!==t[c]&&(o=!0)}o&&Bt.read(()=>{xg(n,s),Bt.render(()=>{Ya(s,i,Qa(n.tagName),e.transformTemplate),pd(n,s)})})}})},Sg={useVisualState:ld({scrapeMotionValuesFromProps:Ja,createRenderState:Xa})};function bd(e,t,n){for(const s in t)!ve(t[s])&&!gd(s,n)&&(e[s]=t[s])}function Cg({transformTemplate:e},t){return m.useMemo(()=>{const n=Xa();return Ga(n,t,e),Object.assign({},n.vars,n.style)},[t])}function kg(e,t){const n=e.style||{},s={};return bd(s,n,e),Object.assign(s,Cg(e,t)),s}function Mg(e,t){const n={},s=kg(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=s,n}function Eg(e,t,n,s){const i=m.useMemo(()=>{const r=dd();return Ya(r,t,Qa(s),e.transformTemplate),{...r.attrs,style:{...r.style}}},[t]);if(e.style){const r={};bd(r,e.style,e),i.style={...r,...i.style}}return i}function Tg(e=!1){return(n,s,i,{latestValues:r},o)=>{const c=(Oa(n)?Eg:Mg)(s,r,o,n),h=Vp(s,typeof n=="string",e),a=n!==m.Fragment?{...h,...c,ref:i}:{},{children:u}=s,f=m.useMemo(()=>ve(u)?u.get():u,[u]);return m.createElement(n,{...a,children:f})}}function Ag(e,t){return function(s,{forwardMotionProps:i}={forwardMotionProps:!1}){const o={...Oa(s)?wg:Sg,preloadedFeatures:e,useRender:Tg(i),createVisualElement:t,Component:s};return Jp(o)}}function vd(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let s=0;s<n;s++)if(t[s]!==e[s])return!1;return!0}function qr(e,t,n){const s=e.getProps();return Ua(s,t,n!==void 0?n:s.custom,e)}const Rg=Fa(()=>window.ScrollTimeline!==void 0);class Pg{constructor(t){this.stop=()=>this.runAll("stop"),this.animations=t.filter(Boolean)}get finished(){return Promise.all(this.animations.map(t=>"finished"in t?t.finished:t))}getAll(t){return this.animations[0][t]}setAll(t,n){for(let s=0;s<this.animations.length;s++)this.animations[s][t]=n}attachTimeline(t,n){const s=this.animations.map(i=>{if(Rg()&&i.attachTimeline)return i.attachTimeline(t);if(typeof n=="function")return n(i)});return()=>{s.forEach((i,r)=>{i&&i(),this.animations[r].stop()})}}get time(){return this.getAll("time")}set time(t){this.setAll("time",t)}get speed(){return this.getAll("speed")}set speed(t){this.setAll("speed",t)}get startTime(){return this.getAll("startTime")}get duration(){let t=0;for(let n=0;n<this.animations.length;n++)t=Math.max(t,this.animations[n].duration);return t}runAll(t){this.animations.forEach(n=>n[t]())}flatten(){this.runAll("flatten")}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}class _g extends Pg{then(t,n){return Promise.all(this.animations).then(t).catch(n)}}function Ka(e,t){return e?e[t]||e.default||e:void 0}const na=2e4;function xd(e){let t=0;const n=50;let s=e.next(t);for(;!s.done&&t<na;)t+=n,s=e.next(t);return t>=na?1/0:t}function Za(e){return typeof e=="function"}function Mc(e,t){e.timeline=t,e.onfinish=null}const tl=e=>Array.isArray(e)&&typeof e[0]=="number",$g={linearEasing:void 0};function Ng(e,t){const n=Fa(e);return()=>{var s;return(s=$g[t])!==null&&s!==void 0?s:n()}}const Ar=Ng(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),wd=(e,t,n=10)=>{let s="";const i=Math.max(Math.round(t/n),2);for(let r=0;r<i;r++)s+=e(Fs(0,i-1,r))+", ";return`linear(${s.substring(0,s.length-2)})`};function Sd(e){return!!(typeof e=="function"&&Ar()||!e||typeof e=="string"&&(e in sa||Ar())||tl(e)||Array.isArray(e)&&e.every(Sd))}const hi=([e,t,n,s])=>`cubic-bezier(${e}, ${t}, ${n}, ${s})`,sa={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:hi([0,.65,.55,1]),circOut:hi([.55,0,1,.45]),backIn:hi([.31,.01,.66,-.59]),backOut:hi([.33,1.53,.69,.99])};function Cd(e,t){if(e)return typeof e=="function"&&Ar()?wd(e,t):tl(e)?hi(e):Array.isArray(e)?e.map(n=>Cd(n,t)||sa.easeOut):sa[e]}const Ve={x:!1,y:!1};function kd(){return Ve.x||Ve.y}function Ig(e,t,n){var s;if(e instanceof Element)return[e];if(typeof e=="string"){let i=document;const r=(s=void 0)!==null&&s!==void 0?s:i.querySelectorAll(e);return r?Array.from(r):[]}return Array.from(e)}function Md(e,t){const n=Ig(e),s=new AbortController,i={passive:!0,...t,signal:s.signal};return[n,i,()=>s.abort()]}function Ec(e){return t=>{t.pointerType==="touch"||kd()||e(t)}}function Dg(e,t,n={}){const[s,i,r]=Md(e,n),o=Ec(l=>{const{target:c}=l,h=t(l);if(typeof h!="function"||!c)return;const a=Ec(u=>{h(u),c.removeEventListener("pointerleave",a)});c.addEventListener("pointerleave",a,i)});return s.forEach(l=>{l.addEventListener("pointerenter",o,i)}),r}const Ed=(e,t)=>t?e===t?!0:Ed(e,t.parentElement):!1,el=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,Lg=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function zg(e){return Lg.has(e.tagName)||e.tabIndex!==-1}const ui=new WeakSet;function Tc(e){return t=>{t.key==="Enter"&&e(t)}}function bo(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const Fg=(e,t)=>{const n=e.currentTarget;if(!n)return;const s=Tc(()=>{if(ui.has(n))return;bo(n,"down");const i=Tc(()=>{bo(n,"up")}),r=()=>bo(n,"cancel");n.addEventListener("keyup",i,t),n.addEventListener("blur",r,t)});n.addEventListener("keydown",s,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),t)};function Ac(e){return el(e)&&!kd()}function Bg(e,t,n={}){const[s,i,r]=Md(e,n),o=l=>{const c=l.currentTarget;if(!Ac(l)||ui.has(c))return;ui.add(c);const h=t(l),a=(p,g)=>{window.removeEventListener("pointerup",u),window.removeEventListener("pointercancel",f),!(!Ac(p)||!ui.has(c))&&(ui.delete(c),typeof h=="function"&&h(p,{success:g}))},u=p=>{a(p,n.useGlobalTarget||Ed(c,p.target))},f=p=>{a(p,!1)};window.addEventListener("pointerup",u,i),window.addEventListener("pointercancel",f,i)};return s.forEach(l=>{!zg(l)&&l.getAttribute("tabindex")===null&&(l.tabIndex=0),(n.useGlobalTarget?window:l).addEventListener("pointerdown",o,i),l.addEventListener("focus",h=>Fg(h,i),i)}),r}function Wg(e){return e==="x"||e==="y"?Ve[e]?null:(Ve[e]=!0,()=>{Ve[e]=!1}):Ve.x||Ve.y?null:(Ve.x=Ve.y=!0,()=>{Ve.x=Ve.y=!1})}const Td=new Set(["width","height","top","left","right","bottom",...Hs]);let br;function jg(){br=void 0}const Ke={now:()=>(br===void 0&&Ke.set(me.isProcessing||Lp.useManualTiming?me.timestamp:performance.now()),br),set:e=>{br=e,queueMicrotask(jg)}};function nl(e,t){e.indexOf(t)===-1&&e.push(t)}function sl(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}class il{constructor(){this.subscriptions=[]}add(t){return nl(this.subscriptions,t),()=>sl(this.subscriptions,t)}notify(t,n,s){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](t,n,s);else for(let r=0;r<i;r++){const o=this.subscriptions[r];o&&o(t,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}function Ad(e,t){return t?e*(1e3/t):0}const Rc=30,Vg=e=>!isNaN(parseFloat(e));class Og{constructor(t,n={}){this.version="11.18.2",this.canTrackVelocity=null,this.events={},this.updateAndNotify=(s,i=!0)=>{const r=Ke.now();this.updatedAt!==r&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(s),this.current!==this.prev&&this.events.change&&this.events.change.notify(this.current),i&&this.events.renderRequest&&this.events.renderRequest.notify(this.current)},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=Ke.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=Vg(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return process.env.NODE_ENV!=="production"&&Vr(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new il);const s=this.events[t].add(n);return t==="change"?()=>{s(),Bt.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t,n=!0){!n||!this.passiveEffect?this.updateAndNotify(t,n):this.passiveEffect(t,this.updateAndNotify)}setWithVelocity(t,n,s){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-s}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=Ke.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>Rc)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Rc);return Ad(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Ai(e,t){return new Og(e,t)}function Ug(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Ai(n))}function Hg(e,t){const n=qr(e,t);let{transitionEnd:s={},transition:i={},...r}=n||{};r={...r,...s};for(const o in r){const l=sg(r[o]);Ug(e,o,l)}}function qg(e){return!!(ve(e)&&e.add)}function ia(e,t){const n=e.getValue("willChange");if(qg(n))return n.add(t)}function Rd(e){return e.props[rd]}const Pd=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,Gg=1e-7,Yg=12;function Xg(e,t,n,s,i){let r,o,l=0;do o=t+(n-t)/2,r=Pd(o,s,i)-e,r>0?n=o:t=o;while(Math.abs(r)>Gg&&++l<Yg);return o}function Di(e,t,n,s){if(e===t&&n===s)return Ae;const i=r=>Xg(r,0,1,e,n);return r=>r===0||r===1?r:Pd(i(r),t,s)}const _d=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,$d=e=>t=>1-e(1-t),Nd=Di(.33,1.53,.69,.99),rl=$d(Nd),Id=_d(rl),Dd=e=>(e*=2)<1?.5*rl(e):.5*(2-Math.pow(2,-10*(e-1))),ol=e=>1-Math.sin(Math.acos(e)),Ld=$d(ol),zd=_d(ol),Fd=e=>/^0[^.\s]+$/u.test(e);function Qg(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||Fd(e):!0}const gi=e=>Math.round(e*1e5)/1e5,al=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Jg(e){return e==null}const Kg=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,ll=(e,t)=>n=>!!(typeof n=="string"&&Kg.test(n)&&n.startsWith(e)||t&&!Jg(n)&&Object.prototype.hasOwnProperty.call(n,t)),Bd=(e,t,n)=>s=>{if(typeof s!="string")return s;const[i,r,o,l]=s.match(al);return{[e]:parseFloat(i),[t]:parseFloat(r),[n]:parseFloat(o),alpha:l!==void 0?parseFloat(l):1}},Zg=e=>un(0,255,e),vo={...qs,transform:e=>Math.round(Zg(e))},Jn={test:ll("rgb","red"),parse:Bd("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:s=1})=>"rgba("+vo.transform(e)+", "+vo.transform(t)+", "+vo.transform(n)+", "+gi(Ti.transform(s))+")"};function t0(e){let t="",n="",s="",i="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),s=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),s=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,s+=s,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(s,16),alpha:i?parseInt(i,16)/255:1}}const ra={test:ll("#"),parse:t0,transform:Jn.transform},Rs={test:ll("hsl","hue"),parse:Bd("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:s=1})=>"hsla("+Math.round(e)+", "+Je.transform(gi(t))+", "+Je.transform(gi(n))+", "+gi(Ti.transform(s))+")"},be={test:e=>Jn.test(e)||ra.test(e)||Rs.test(e),parse:e=>Jn.test(e)?Jn.parse(e):Rs.test(e)?Rs.parse(e):ra.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Jn.transform(e):Rs.transform(e)},e0=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function n0(e){var t,n;return isNaN(e)&&typeof e=="string"&&(((t=e.match(al))===null||t===void 0?void 0:t.length)||0)+(((n=e.match(e0))===null||n===void 0?void 0:n.length)||0)>0}const Wd="number",jd="color",s0="var",i0="var(",Pc="${}",r0=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Ri(e){const t=e.toString(),n=[],s={color:[],number:[],var:[]},i=[];let r=0;const l=t.replace(r0,c=>(be.test(c)?(s.color.push(r),i.push(jd),n.push(be.parse(c))):c.startsWith(i0)?(s.var.push(r),i.push(s0),n.push(c)):(s.number.push(r),i.push(Wd),n.push(parseFloat(c))),++r,Pc)).split(Pc);return{values:n,split:l,indexes:s,types:i}}function Vd(e){return Ri(e).values}function Od(e){const{split:t,types:n}=Ri(e),s=t.length;return i=>{let r="";for(let o=0;o<s;o++)if(r+=t[o],i[o]!==void 0){const l=n[o];l===Wd?r+=gi(i[o]):l===jd?r+=be.transform(i[o]):r+=i[o]}return r}}const o0=e=>typeof e=="number"?0:e;function a0(e){const t=Vd(e);return Od(e)(t.map(o0))}const Pn={test:n0,parse:Vd,createTransformer:Od,getAnimatableNone:a0},l0=new Set(["brightness","contrast","saturate","opacity"]);function c0(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[s]=n.match(al)||[];if(!s)return e;const i=n.replace(s,"");let r=l0.has(t)?1:0;return s!==n&&(r*=100),t+"("+r+i+")"}const h0=/\b([a-z-]*)\(.*?\)/gu,oa={...Pn,getAnimatableNone:e=>{const t=e.match(h0);return t?t.map(c0).join(" "):e}},u0={...qa,color:be,backgroundColor:be,outlineColor:be,fill:be,stroke:be,borderColor:be,borderTopColor:be,borderRightColor:be,borderBottomColor:be,borderLeftColor:be,filter:oa,WebkitFilter:oa},cl=e=>u0[e];function Ud(e,t){let n=cl(e);return n!==oa&&(n=Pn),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const d0=new Set(["auto","none","0"]);function f0(e,t,n){let s=0,i;for(;s<e.length&&!i;){const r=e[s];typeof r=="string"&&!d0.has(r)&&Ri(r).values.length&&(i=e[s]),s++}if(i&&n)for(const r of t)e[r]=Ud(n,i)}const _c=e=>e===qs||e===ct,$c=(e,t)=>parseFloat(e.split(", ")[t]),Nc=(e,t)=>(n,{transform:s})=>{if(s==="none"||!s)return 0;const i=s.match(/^matrix3d\((.+)\)$/u);if(i)return $c(i[1],t);{const r=s.match(/^matrix\((.+)\)$/u);return r?$c(r[1],e):0}},m0=new Set(["x","y","z"]),p0=Hs.filter(e=>!m0.has(e));function g0(e){const t=[];return p0.forEach(n=>{const s=e.getValue(n);s!==void 0&&(t.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),t}const Ws={width:({x:e},{paddingLeft:t="0",paddingRight:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),height:({y:e},{paddingTop:t="0",paddingBottom:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:Nc(4,13),y:Nc(5,14)};Ws.translateX=Ws.x;Ws.translateY=Ws.y;const Kn=new Set;let aa=!1,la=!1;function Hd(){if(la){const e=Array.from(Kn).filter(s=>s.needsMeasurement),t=new Set(e.map(s=>s.element)),n=new Map;t.forEach(s=>{const i=g0(s);i.length&&(n.set(s,i),s.render())}),e.forEach(s=>s.measureInitialState()),t.forEach(s=>{s.render();const i=n.get(s);i&&i.forEach(([r,o])=>{var l;(l=s.getValue(r))===null||l===void 0||l.set(o)})}),e.forEach(s=>s.measureEndState()),e.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}la=!1,aa=!1,Kn.forEach(e=>e.complete()),Kn.clear()}function qd(){Kn.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(la=!0)})}function y0(){qd(),Hd()}class hl{constructor(t,n,s,i,r,o=!1){this.isComplete=!1,this.isAsync=!1,this.needsMeasurement=!1,this.isScheduled=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=s,this.motionValue=i,this.element=r,this.isAsync=o}scheduleResolve(){this.isScheduled=!0,this.isAsync?(Kn.add(this),aa||(aa=!0,Bt.read(qd),Bt.resolveKeyframes(Hd))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:s,motionValue:i}=this;for(let r=0;r<t.length;r++)if(t[r]===null)if(r===0){const o=i==null?void 0:i.get(),l=t[t.length-1];if(o!==void 0)t[0]=o;else if(s&&n){const c=s.readValue(n,l);c!=null&&(t[0]=c)}t[0]===void 0&&(t[0]=l),i&&o===void 0&&i.set(t[0])}else t[r]=t[r-1]}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(){this.isComplete=!0,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe),Kn.delete(this)}cancel(){this.isComplete||(this.isScheduled=!1,Kn.delete(this))}resume(){this.isComplete||this.scheduleResolve()}}const Gd=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),b0=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function v0(e){const t=b0.exec(e);if(!t)return[,];const[,n,s,i]=t;return[`--${n??s}`,i]}const x0=4;function Yd(e,t,n=1){An(n<=x0,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`);const[s,i]=v0(e);if(!s)return;const r=window.getComputedStyle(t).getPropertyValue(s);if(r){const o=r.trim();return Gd(o)?parseFloat(o):o}return Ha(i)?Yd(i,t,n+1):i}const Xd=e=>t=>t.test(e),w0={test:e=>e==="auto",parse:e=>e},Qd=[qs,ct,Je,Cn,cg,lg,w0],Ic=e=>Qd.find(Xd(e));class Jd extends hl{constructor(t,n,s,i,r){super(t,n,s,i,r,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let c=0;c<t.length;c++){let h=t[c];if(typeof h=="string"&&(h=h.trim(),Ha(h))){const a=Yd(h,n.current);a!==void 0&&(t[c]=a),c===t.length-1&&(this.finalKeyframe=h)}}if(this.resolveNoneKeyframes(),!Td.has(s)||t.length!==2)return;const[i,r]=t,o=Ic(i),l=Ic(r);if(o!==l)if(_c(o)&&_c(l))for(let c=0;c<t.length;c++){const h=t[c];typeof h=="string"&&(t[c]=parseFloat(h))}else this.needsMeasurement=!0}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,s=[];for(let i=0;i<t.length;i++)Qg(t[i])&&s.push(i);s.length&&f0(t,s,n)}measureInitialState(){const{element:t,unresolvedKeyframes:n,name:s}=this;if(!t||!t.current)return;s==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Ws[s](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&t.getValue(s,i).jump(i,!1)}measureEndState(){var t;const{element:n,name:s,unresolvedKeyframes:i}=this;if(!n||!n.current)return;const r=n.getValue(s);r&&r.jump(this.measuredOrigin,!1);const o=i.length-1,l=i[o];i[o]=Ws[s](n.measureViewportBox(),window.getComputedStyle(n.current)),l!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=l),!((t=this.removedTransforms)===null||t===void 0)&&t.length&&this.removedTransforms.forEach(([c,h])=>{n.getValue(c).set(h)}),this.resolveNoneKeyframes()}}const Dc=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(Pn.test(e)||e==="0")&&!e.startsWith("url("));function S0(e){const t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function C0(e,t,n,s){const i=e[0];if(i===null)return!1;if(t==="display"||t==="visibility")return!0;const r=e[e.length-1],o=Dc(i,t),l=Dc(r,t);return Us(o===l,`You are trying to animate ${t} from "${i}" to "${r}". ${i} is not an animatable value - to enable this animation set ${i} to a value animatable to ${r} via the \`style\` property.`),!o||!l?!1:S0(e)||(n==="spring"||Za(n))&&s}const k0=e=>e!==null;function Gr(e,{repeat:t,repeatType:n="loop"},s){const i=e.filter(k0),r=t&&n!=="loop"&&t%2===1?0:i.length-1;return!r||s===void 0?i[r]:s}const M0=40;class Kd{constructor({autoplay:t=!0,delay:n=0,type:s="keyframes",repeat:i=0,repeatDelay:r=0,repeatType:o="loop",...l}){this.isStopped=!1,this.hasAttemptedResolve=!1,this.createdAt=Ke.now(),this.options={autoplay:t,delay:n,type:s,repeat:i,repeatDelay:r,repeatType:o,...l},this.updateFinishedPromise()}calcStartTime(){return this.resolvedAt?this.resolvedAt-this.createdAt>M0?this.resolvedAt:this.createdAt:this.createdAt}get resolved(){return!this._resolved&&!this.hasAttemptedResolve&&y0(),this._resolved}onKeyframesResolved(t,n){this.resolvedAt=Ke.now(),this.hasAttemptedResolve=!0;const{name:s,type:i,velocity:r,delay:o,onComplete:l,onUpdate:c,isGenerator:h}=this.options;if(!h&&!C0(t,s,i,r))if(o)this.options.duration=0;else{c&&c(Gr(t,this.options,n)),l&&l(),this.resolveFinishedPromise();return}const a=this.initPlayback(t,n);a!==!1&&(this._resolved={keyframes:t,finalKeyframe:n,...a},this.onPostResolved())}onPostResolved(){}then(t,n){return this.currentFinishedPromise.then(t,n)}flatten(){this.options.type="keyframes",this.options.ease="linear"}updateFinishedPromise(){this.currentFinishedPromise=new Promise(t=>{this.resolveFinishedPromise=t})}}const Ht=(e,t,n)=>e+(t-e)*n;function xo(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function E0({hue:e,saturation:t,lightness:n,alpha:s}){e/=360,t/=100,n/=100;let i=0,r=0,o=0;if(!t)i=r=o=n;else{const l=n<.5?n*(1+t):n+t-n*t,c=2*n-l;i=xo(c,l,e+1/3),r=xo(c,l,e),o=xo(c,l,e-1/3)}return{red:Math.round(i*255),green:Math.round(r*255),blue:Math.round(o*255),alpha:s}}function Rr(e,t){return n=>n>0?t:e}const wo=(e,t,n)=>{const s=e*e,i=n*(t*t-s)+s;return i<0?0:Math.sqrt(i)},T0=[ra,Jn,Rs],A0=e=>T0.find(t=>t.test(e));function Lc(e){const t=A0(e);if(Us(!!t,`'${e}' is not an animatable color. Use the equivalent color code instead.`),!t)return!1;let n=t.parse(e);return t===Rs&&(n=E0(n)),n}const zc=(e,t)=>{const n=Lc(e),s=Lc(t);if(!n||!s)return Rr(e,t);const i={...n};return r=>(i.red=wo(n.red,s.red,r),i.green=wo(n.green,s.green,r),i.blue=wo(n.blue,s.blue,r),i.alpha=Ht(n.alpha,s.alpha,r),Jn.transform(i))},R0=(e,t)=>n=>t(e(n)),Li=(...e)=>e.reduce(R0),ca=new Set(["none","hidden"]);function P0(e,t){return ca.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function _0(e,t){return n=>Ht(e,t,n)}function ul(e){return typeof e=="number"?_0:typeof e=="string"?Ha(e)?Rr:be.test(e)?zc:I0:Array.isArray(e)?Zd:typeof e=="object"?be.test(e)?zc:$0:Rr}function Zd(e,t){const n=[...e],s=n.length,i=e.map((r,o)=>ul(r)(r,t[o]));return r=>{for(let o=0;o<s;o++)n[o]=i[o](r);return n}}function $0(e,t){const n={...e,...t},s={};for(const i in n)e[i]!==void 0&&t[i]!==void 0&&(s[i]=ul(e[i])(e[i],t[i]));return i=>{for(const r in s)n[r]=s[r](i);return n}}function N0(e,t){var n;const s=[],i={color:0,var:0,number:0};for(let r=0;r<t.values.length;r++){const o=t.types[r],l=e.indexes[o][i[o]],c=(n=e.values[l])!==null&&n!==void 0?n:0;s[r]=c,i[o]++}return s}const I0=(e,t)=>{const n=Pn.createTransformer(t),s=Ri(e),i=Ri(t);return s.indexes.var.length===i.indexes.var.length&&s.indexes.color.length===i.indexes.color.length&&s.indexes.number.length>=i.indexes.number.length?ca.has(e)&&!i.values.length||ca.has(t)&&!s.values.length?P0(e,t):Li(Zd(N0(s,i),i.values),n):(Us(!0,`Complex values '${e}' and '${t}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`),Rr(e,t))};function tf(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?Ht(e,t,n):ul(e)(e,t)}const D0=5;function ef(e,t,n){const s=Math.max(t-D0,0);return Ad(n-e(s),t-s)}const Ut={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},So=.001;function L0({duration:e=Ut.duration,bounce:t=Ut.bounce,velocity:n=Ut.velocity,mass:s=Ut.mass}){let i,r;Us(e<=Qe(Ut.maxDuration),"Spring duration must be 10 seconds or less");let o=1-t;o=un(Ut.minDamping,Ut.maxDamping,o),e=un(Ut.minDuration,Ut.maxDuration,hn(e)),o<1?(i=h=>{const a=h*o,u=a*e,f=a-n,p=ha(h,o),g=Math.exp(-u);return So-f/p*g},r=h=>{const u=h*o*e,f=u*n+n,p=Math.pow(o,2)*Math.pow(h,2)*e,g=Math.exp(-u),d=ha(Math.pow(h,2),o);return(-i(h)+So>0?-1:1)*((f-p)*g)/d}):(i=h=>{const a=Math.exp(-h*e),u=(h-n)*e+1;return-So+a*u},r=h=>{const a=Math.exp(-h*e),u=(n-h)*(e*e);return a*u});const l=5/e,c=F0(i,r,l);if(e=Qe(e),isNaN(c))return{stiffness:Ut.stiffness,damping:Ut.damping,duration:e};{const h=Math.pow(c,2)*s;return{stiffness:h,damping:o*2*Math.sqrt(s*h),duration:e}}}const z0=12;function F0(e,t,n){let s=n;for(let i=1;i<z0;i++)s=s-e(s)/t(s);return s}function ha(e,t){return e*Math.sqrt(1-t*t)}const B0=["duration","bounce"],W0=["stiffness","damping","mass"];function Fc(e,t){return t.some(n=>e[n]!==void 0)}function j0(e){let t={velocity:Ut.velocity,stiffness:Ut.stiffness,damping:Ut.damping,mass:Ut.mass,isResolvedFromDuration:!1,...e};if(!Fc(e,W0)&&Fc(e,B0))if(e.visualDuration){const n=e.visualDuration,s=2*Math.PI/(n*1.2),i=s*s,r=2*un(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:Ut.mass,stiffness:i,damping:r}}else{const n=L0(e);t={...t,...n,mass:Ut.mass},t.isResolvedFromDuration=!0}return t}function nf(e=Ut.visualDuration,t=Ut.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:s,restDelta:i}=n;const r=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],l={done:!1,value:r},{stiffness:c,damping:h,mass:a,duration:u,velocity:f,isResolvedFromDuration:p}=j0({...n,velocity:-hn(n.velocity||0)}),g=f||0,d=h/(2*Math.sqrt(c*a)),w=o-r,C=hn(Math.sqrt(c/a)),x=Math.abs(w)<5;s||(s=x?Ut.restSpeed.granular:Ut.restSpeed.default),i||(i=x?Ut.restDelta.granular:Ut.restDelta.default);let k;if(d<1){const T=ha(C,d);k=P=>{const I=Math.exp(-d*C*P);return o-I*((g+d*C*w)/T*Math.sin(T*P)+w*Math.cos(T*P))}}else if(d===1)k=T=>o-Math.exp(-C*T)*(w+(g+C*w)*T);else{const T=C*Math.sqrt(d*d-1);k=P=>{const I=Math.exp(-d*C*P),L=Math.min(T*P,300);return o-I*((g+d*C*w)*Math.sinh(L)+T*w*Math.cosh(L))/T}}const S={calculatedDuration:p&&u||null,next:T=>{const P=k(T);if(p)l.done=T>=u;else{let I=0;d<1&&(I=T===0?Qe(g):ef(k,T,P));const L=Math.abs(I)<=s,O=Math.abs(o-P)<=i;l.done=L&&O}return l.value=l.done?o:P,l},toString:()=>{const T=Math.min(xd(S),na),P=wd(I=>S.next(T*I).value,T,30);return T+"ms "+P}};return S}function Bc({keyframes:e,velocity:t=0,power:n=.8,timeConstant:s=325,bounceDamping:i=10,bounceStiffness:r=500,modifyTarget:o,min:l,max:c,restDelta:h=.5,restSpeed:a}){const u=e[0],f={done:!1,value:u},p=L=>l!==void 0&&L<l||c!==void 0&&L>c,g=L=>l===void 0?c:c===void 0||Math.abs(l-L)<Math.abs(c-L)?l:c;let d=n*t;const w=u+d,C=o===void 0?w:o(w);C!==w&&(d=C-u);const x=L=>-d*Math.exp(-L/s),k=L=>C+x(L),S=L=>{const O=x(L),H=k(L);f.done=Math.abs(O)<=h,f.value=f.done?C:H};let T,P;const I=L=>{p(f.value)&&(T=L,P=nf({keyframes:[f.value,g(f.value)],velocity:ef(k,L,f.value),damping:i,stiffness:r,restDelta:h,restSpeed:a}))};return I(0),{calculatedDuration:null,next:L=>{let O=!1;return!P&&T===void 0&&(O=!0,S(L),I(L)),T!==void 0&&L>=T?P.next(L-T):(!O&&S(L),f)}}}const V0=Di(.42,0,1,1),O0=Di(0,0,.58,1),sf=Di(.42,0,.58,1),U0=e=>Array.isArray(e)&&typeof e[0]!="number",Wc={linear:Ae,easeIn:V0,easeInOut:sf,easeOut:O0,circIn:ol,circInOut:zd,circOut:Ld,backIn:rl,backInOut:Id,backOut:Nd,anticipate:Dd},jc=e=>{if(tl(e)){An(e.length===4,"Cubic bezier arrays must contain four numerical values.");const[t,n,s,i]=e;return Di(t,n,s,i)}else if(typeof e=="string")return An(Wc[e]!==void 0,`Invalid easing type '${e}'`),Wc[e];return e};function H0(e,t,n){const s=[],i=n||tf,r=e.length-1;for(let o=0;o<r;o++){let l=i(e[o],e[o+1]);if(t){const c=Array.isArray(t)?t[o]||Ae:t;l=Li(c,l)}s.push(l)}return s}function q0(e,t,{clamp:n=!0,ease:s,mixer:i}={}){const r=e.length;if(An(r===t.length,"Both input and output ranges must be the same length"),r===1)return()=>t[0];if(r===2&&t[0]===t[1])return()=>t[1];const o=e[0]===e[1];e[0]>e[r-1]&&(e=[...e].reverse(),t=[...t].reverse());const l=H0(t,s,i),c=l.length,h=a=>{if(o&&a<e[0])return t[0];let u=0;if(c>1)for(;u<e.length-2&&!(a<e[u+1]);u++);const f=Fs(e[u],e[u+1],a);return l[u](f)};return n?a=>h(un(e[0],e[r-1],a)):h}function G0(e,t){const n=e[e.length-1];for(let s=1;s<=t;s++){const i=Fs(0,t,s);e.push(Ht(n,1,i))}}function Y0(e){const t=[0];return G0(t,e.length-1),t}function X0(e,t){return e.map(n=>n*t)}function Q0(e,t){return e.map(()=>t||sf).splice(0,e.length-1)}function Pr({duration:e=300,keyframes:t,times:n,ease:s="easeInOut"}){const i=U0(s)?s.map(jc):jc(s),r={done:!1,value:t[0]},o=X0(n&&n.length===t.length?n:Y0(t),e),l=q0(o,t,{ease:Array.isArray(i)?i:Q0(t,i)});return{calculatedDuration:e,next:c=>(r.value=l(c),r.done=c>=e,r)}}const J0=e=>{const t=({timestamp:n})=>e(n);return{start:()=>Bt.update(t,!0),stop:()=>Rn(t),now:()=>me.isProcessing?me.timestamp:Ke.now()}},K0={decay:Bc,inertia:Bc,tween:Pr,keyframes:Pr,spring:nf},Z0=e=>e/100;class dl extends Kd{constructor(t){super(t),this.holdTime=null,this.cancelTime=null,this.currentTime=0,this.playbackSpeed=1,this.pendingPlayState="running",this.startTime=null,this.state="idle",this.stop=()=>{if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.teardown();const{onStop:c}=this.options;c&&c()};const{name:n,motionValue:s,element:i,keyframes:r}=this.options,o=(i==null?void 0:i.KeyframeResolver)||hl,l=(c,h)=>this.onKeyframesResolved(c,h);this.resolver=new o(r,l,n,s,i),this.resolver.scheduleResolve()}flatten(){super.flatten(),this._resolved&&Object.assign(this._resolved,this.initPlayback(this._resolved.keyframes))}initPlayback(t){const{type:n="keyframes",repeat:s=0,repeatDelay:i=0,repeatType:r,velocity:o=0}=this.options,l=Za(n)?n:K0[n]||Pr;let c,h;l!==Pr&&typeof t[0]!="number"&&(process.env.NODE_ENV!=="production"&&An(t.length===2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${t}`),c=Li(Z0,tf(t[0],t[1])),t=[0,100]);const a=l({...this.options,keyframes:t});r==="mirror"&&(h=l({...this.options,keyframes:[...t].reverse(),velocity:-o})),a.calculatedDuration===null&&(a.calculatedDuration=xd(a));const{calculatedDuration:u}=a,f=u+i,p=f*(s+1)-i;return{generator:a,mirroredGenerator:h,mapPercentToKeyframes:c,calculatedDuration:u,resolvedDuration:f,totalDuration:p}}onPostResolved(){const{autoplay:t=!0}=this.options;this.play(),this.pendingPlayState==="paused"||!t?this.pause():this.state=this.pendingPlayState}tick(t,n=!1){const{resolved:s}=this;if(!s){const{keyframes:L}=this.options;return{done:!0,value:L[L.length-1]}}const{finalKeyframe:i,generator:r,mirroredGenerator:o,mapPercentToKeyframes:l,keyframes:c,calculatedDuration:h,totalDuration:a,resolvedDuration:u}=s;if(this.startTime===null)return r.next(0);const{delay:f,repeat:p,repeatType:g,repeatDelay:d,onUpdate:w}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-a/this.speed,this.startTime)),n?this.currentTime=t:this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=Math.round(t-this.startTime)*this.speed;const C=this.currentTime-f*(this.speed>=0?1:-1),x=this.speed>=0?C<0:C>a;this.currentTime=Math.max(C,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=a);let k=this.currentTime,S=r;if(p){const L=Math.min(this.currentTime,a)/u;let O=Math.floor(L),H=L%1;!H&&L>=1&&(H=1),H===1&&O--,O=Math.min(O,p+1),!!(O%2)&&(g==="reverse"?(H=1-H,d&&(H-=d/u)):g==="mirror"&&(S=o)),k=un(0,1,H)*u}const T=x?{done:!1,value:c[0]}:S.next(k);l&&(T.value=l(T.value));let{done:P}=T;!x&&h!==null&&(P=this.speed>=0?this.currentTime>=a:this.currentTime<=0);const I=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&P);return I&&i!==void 0&&(T.value=Gr(c,this.options,i)),w&&w(T.value),I&&this.finish(),T}get duration(){const{resolved:t}=this;return t?hn(t.calculatedDuration):0}get time(){return hn(this.currentTime)}set time(t){t=Qe(t),this.currentTime=t,this.holdTime!==null||this.speed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.speed)}get speed(){return this.playbackSpeed}set speed(t){const n=this.playbackSpeed!==t;this.playbackSpeed=t,n&&(this.time=hn(this.currentTime))}play(){if(this.resolver.isScheduled||this.resolver.resume(),!this._resolved){this.pendingPlayState="running";return}if(this.isStopped)return;const{driver:t=J0,onPlay:n,startTime:s}=this.options;this.driver||(this.driver=t(r=>this.tick(r))),n&&n();const i=this.driver.now();this.holdTime!==null?this.startTime=i-this.holdTime:this.startTime?this.state==="finished"&&(this.startTime=i):this.startTime=s??this.calcStartTime(),this.state==="finished"&&this.updateFinishedPromise(),this.cancelTime=this.startTime,this.holdTime=null,this.state="running",this.driver.start()}pause(){var t;if(!this._resolved){this.pendingPlayState="paused";return}this.state="paused",this.holdTime=(t=this.currentTime)!==null&&t!==void 0?t:0}complete(){this.state!=="running"&&this.play(),this.pendingPlayState=this.state="finished",this.holdTime=null}finish(){this.teardown(),this.state="finished";const{onComplete:t}=this.options;t&&t()}cancel(){this.cancelTime!==null&&this.tick(this.cancelTime),this.teardown(),this.updateFinishedPromise()}teardown(){this.state="idle",this.stopDriver(),this.resolveFinishedPromise(),this.updateFinishedPromise(),this.startTime=this.cancelTime=null,this.resolver.cancel()}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}}const ty=new Set(["opacity","clipPath","filter","transform"]);function ey(e,t,n,{delay:s=0,duration:i=300,repeat:r=0,repeatType:o="loop",ease:l="easeInOut",times:c}={}){const h={[t]:n};c&&(h.offset=c);const a=Cd(l,i);return Array.isArray(a)&&(h.easing=a),e.animate(h,{delay:s,duration:i,easing:Array.isArray(a)?"linear":a,fill:"both",iterations:r+1,direction:o==="reverse"?"alternate":"normal"})}const ny=Fa(()=>Object.hasOwnProperty.call(Element.prototype,"animate")),_r=10,sy=2e4;function iy(e){return Za(e.type)||e.type==="spring"||!Sd(e.ease)}function ry(e,t){const n=new dl({...t,keyframes:e,repeat:0,delay:0,isGenerator:!0});let s={done:!1,value:e[0]};const i=[];let r=0;for(;!s.done&&r<sy;)s=n.sample(r),i.push(s.value),r+=_r;return{times:void 0,keyframes:i,duration:r-_r,ease:"linear"}}const rf={anticipate:Dd,backInOut:Id,circInOut:zd};function oy(e){return e in rf}class Vc extends Kd{constructor(t){super(t);const{name:n,motionValue:s,element:i,keyframes:r}=this.options;this.resolver=new Jd(r,(o,l)=>this.onKeyframesResolved(o,l),n,s,i),this.resolver.scheduleResolve()}initPlayback(t,n){let{duration:s=300,times:i,ease:r,type:o,motionValue:l,name:c,startTime:h}=this.options;if(!l.owner||!l.owner.current)return!1;if(typeof r=="string"&&Ar()&&oy(r)&&(r=rf[r]),iy(this.options)){const{onComplete:u,onUpdate:f,motionValue:p,element:g,...d}=this.options,w=ry(t,d);t=w.keyframes,t.length===1&&(t[1]=t[0]),s=w.duration,i=w.times,r=w.ease,o="keyframes"}const a=ey(l.owner.current,c,t,{...this.options,duration:s,times:i,ease:r});return a.startTime=h??this.calcStartTime(),this.pendingTimeline?(Mc(a,this.pendingTimeline),this.pendingTimeline=void 0):a.onfinish=()=>{const{onComplete:u}=this.options;l.set(Gr(t,this.options,n)),u&&u(),this.cancel(),this.resolveFinishedPromise()},{animation:a,duration:s,times:i,type:o,ease:r,keyframes:t}}get duration(){const{resolved:t}=this;if(!t)return 0;const{duration:n}=t;return hn(n)}get time(){const{resolved:t}=this;if(!t)return 0;const{animation:n}=t;return hn(n.currentTime||0)}set time(t){const{resolved:n}=this;if(!n)return;const{animation:s}=n;s.currentTime=Qe(t)}get speed(){const{resolved:t}=this;if(!t)return 1;const{animation:n}=t;return n.playbackRate}set speed(t){const{resolved:n}=this;if(!n)return;const{animation:s}=n;s.playbackRate=t}get state(){const{resolved:t}=this;if(!t)return"idle";const{animation:n}=t;return n.playState}get startTime(){const{resolved:t}=this;if(!t)return null;const{animation:n}=t;return n.startTime}attachTimeline(t){if(!this._resolved)this.pendingTimeline=t;else{const{resolved:n}=this;if(!n)return Ae;const{animation:s}=n;Mc(s,t)}return Ae}play(){if(this.isStopped)return;const{resolved:t}=this;if(!t)return;const{animation:n}=t;n.playState==="finished"&&this.updateFinishedPromise(),n.play()}pause(){const{resolved:t}=this;if(!t)return;const{animation:n}=t;n.pause()}stop(){if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.resolveFinishedPromise(),this.updateFinishedPromise();const{resolved:t}=this;if(!t)return;const{animation:n,keyframes:s,duration:i,type:r,ease:o,times:l}=t;if(n.playState==="idle"||n.playState==="finished")return;if(this.time){const{motionValue:h,onUpdate:a,onComplete:u,element:f,...p}=this.options,g=new dl({...p,keyframes:s,duration:i,type:r,ease:o,times:l,isGenerator:!0}),d=Qe(this.time);h.setWithVelocity(g.sample(d-_r).value,g.sample(d).value,_r)}const{onStop:c}=this.options;c&&c(),this.cancel()}complete(){const{resolved:t}=this;t&&t.animation.finish()}cancel(){const{resolved:t}=this;t&&t.animation.cancel()}static supports(t){const{motionValue:n,name:s,repeatDelay:i,repeatType:r,damping:o,type:l}=t;if(!n||!n.owner||!(n.owner.current instanceof HTMLElement))return!1;const{onUpdate:c,transformTemplate:h}=n.owner.getProps();return ny()&&s&&ty.has(s)&&!c&&!h&&!i&&r!=="mirror"&&o!==0&&l!=="inertia"}}const ay={type:"spring",stiffness:500,damping:25,restSpeed:10},ly=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),cy={type:"keyframes",duration:.8},hy={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},uy=(e,{keyframes:t})=>t.length>2?cy:rs.has(e)?e.startsWith("scale")?ly(t[1]):ay:hy;function dy({when:e,delay:t,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:r,repeatType:o,repeatDelay:l,from:c,elapsed:h,...a}){return!!Object.keys(a).length}const fl=(e,t,n,s={},i,r)=>o=>{const l=Ka(s,e)||{},c=l.delay||s.delay||0;let{elapsed:h=0}=s;h=h-Qe(c);let a={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...l,delay:-h,onUpdate:f=>{t.set(f),l.onUpdate&&l.onUpdate(f)},onComplete:()=>{o(),l.onComplete&&l.onComplete()},name:e,motionValue:t,element:r?void 0:i};dy(l)||(a={...a,...uy(e,a)}),a.duration&&(a.duration=Qe(a.duration)),a.repeatDelay&&(a.repeatDelay=Qe(a.repeatDelay)),a.from!==void 0&&(a.keyframes[0]=a.from);let u=!1;if((a.type===!1||a.duration===0&&!a.repeatDelay)&&(a.duration=0,a.delay===0&&(u=!0)),u&&!r&&t.get()!==void 0){const f=Gr(a.keyframes,l);if(f!==void 0)return Bt.update(()=>{a.onUpdate(f),a.onComplete()}),new _g([])}return!r&&Vc.supports(a)?new Vc(a):new dl(a)};function fy({protectedKeys:e,needsAnimating:t},n){const s=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,s}function of(e,t,{delay:n=0,transitionOverride:s,type:i}={}){var r;let{transition:o=e.getDefaultTransition(),transitionEnd:l,...c}=t;s&&(o=s);const h=[],a=i&&e.animationState&&e.animationState.getState()[i];for(const u in c){const f=e.getValue(u,(r=e.latestValues[u])!==null&&r!==void 0?r:null),p=c[u];if(p===void 0||a&&fy(a,u))continue;const g={delay:n,...Ka(o||{},u)};let d=!1;if(window.MotionHandoffAnimation){const C=Rd(e);if(C){const x=window.MotionHandoffAnimation(C,u,Bt);x!==null&&(g.startTime=x,d=!0)}}ia(e,u),f.start(fl(u,f,p,e.shouldReduceMotion&&Td.has(u)?{type:!1}:g,e,d));const w=f.animation;w&&h.push(w)}return l&&Promise.all(h).then(()=>{Bt.update(()=>{l&&Hg(e,l)})}),h}function ua(e,t,n={}){var s;const i=qr(e,t,n.type==="exit"?(s=e.presenceContext)===null||s===void 0?void 0:s.custom:void 0);let{transition:r=e.getDefaultTransition()||{}}=i||{};n.transitionOverride&&(r=n.transitionOverride);const o=i?()=>Promise.all(of(e,i,n)):()=>Promise.resolve(),l=e.variantChildren&&e.variantChildren.size?(h=0)=>{const{delayChildren:a=0,staggerChildren:u,staggerDirection:f}=r;return my(e,t,a+h,u,f,n)}:()=>Promise.resolve(),{when:c}=r;if(c){const[h,a]=c==="beforeChildren"?[o,l]:[l,o];return h().then(()=>a())}else return Promise.all([o(),l(n.delay)])}function my(e,t,n=0,s=0,i=1,r){const o=[],l=(e.variantChildren.size-1)*s,c=i===1?(h=0)=>h*s:(h=0)=>l-h*s;return Array.from(e.variantChildren).sort(py).forEach((h,a)=>{h.notify("AnimationStart",t),o.push(ua(h,t,{...r,delay:n+c(a)}).then(()=>h.notify("AnimationComplete",t)))}),Promise.all(o)}function py(e,t){return e.sortNodePosition(t)}function gy(e,t,n={}){e.notify("AnimationStart",t);let s;if(Array.isArray(t)){const i=t.map(r=>ua(e,r,n));s=Promise.all(i)}else if(typeof t=="string")s=ua(e,t,n);else{const i=typeof t=="function"?qr(e,t,n.custom):t;s=Promise.all(of(e,i,n))}return s.then(()=>{e.notify("AnimationComplete",t)})}const yy=Wa.length;function af(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?af(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<yy;n++){const s=Wa[n],i=e.props[s];(Ei(i)||i===!1)&&(t[s]=i)}return t}const by=[...Ba].reverse(),vy=Ba.length;function xy(e){return t=>Promise.all(t.map(({animation:n,options:s})=>gy(e,n,s)))}function wy(e){let t=xy(e),n=Oc(),s=!0;const i=c=>(h,a)=>{var u;const f=qr(e,a,c==="exit"?(u=e.presenceContext)===null||u===void 0?void 0:u.custom:void 0);if(f){const{transition:p,transitionEnd:g,...d}=f;h={...h,...d,...g}}return h};function r(c){t=c(e)}function o(c){const{props:h}=e,a=af(e.parent)||{},u=[],f=new Set;let p={},g=1/0;for(let w=0;w<vy;w++){const C=by[w],x=n[C],k=h[C]!==void 0?h[C]:a[C],S=Ei(k),T=C===c?x.isActive:null;T===!1&&(g=w);let P=k===a[C]&&k!==h[C]&&S;if(P&&s&&e.manuallyAnimateOnMount&&(P=!1),x.protectedKeys={...p},!x.isActive&&T===null||!k&&!x.prevProp||Ur(k)||typeof k=="boolean")continue;const I=Sy(x.prevProp,k);let L=I||C===c&&x.isActive&&!P&&S||w>g&&S,O=!1;const H=Array.isArray(k)?k:[k];let U=H.reduce(i(C),{});T===!1&&(U={});const{prevResolvedValues:q={}}=x,X={...q,...U},j=J=>{L=!0,f.has(J)&&(O=!0,f.delete(J)),x.needsAnimating[J]=!0;const nt=e.getValue(J);nt&&(nt.liveStyle=!1)};for(const J in X){const nt=U[J],it=q[J];if(p.hasOwnProperty(J))continue;let Q=!1;ea(nt)&&ea(it)?Q=!vd(nt,it):Q=nt!==it,Q?nt!=null?j(J):f.add(J):nt!==void 0&&f.has(J)?j(J):x.protectedKeys[J]=!0}x.prevProp=k,x.prevResolvedValues=U,x.isActive&&(p={...p,...U}),s&&e.blockInitialAnimation&&(L=!1),L&&(!(P&&I)||O)&&u.push(...H.map(J=>({animation:J,options:{type:C}})))}if(f.size){const w={};f.forEach(C=>{const x=e.getBaseTarget(C),k=e.getValue(C);k&&(k.liveStyle=!0),w[C]=x??null}),u.push({animation:w})}let d=!!u.length;return s&&(h.initial===!1||h.initial===h.animate)&&!e.manuallyAnimateOnMount&&(d=!1),s=!1,d?t(u):Promise.resolve()}function l(c,h){var a;if(n[c].isActive===h)return Promise.resolve();(a=e.variantChildren)===null||a===void 0||a.forEach(f=>{var p;return(p=f.animationState)===null||p===void 0?void 0:p.setActive(c,h)}),n[c].isActive=h;const u=o(c);for(const f in n)n[f].protectedKeys={};return u}return{animateChanges:o,setActive:l,setAnimateFunction:r,getState:()=>n,reset:()=>{n=Oc(),s=!0}}}function Sy(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!vd(t,e):!1}function qn(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Oc(){return{animate:qn(!0),whileInView:qn(),whileHover:qn(),whileTap:qn(),whileDrag:qn(),whileFocus:qn(),exit:qn()}}class $n{constructor(t){this.isMounted=!1,this.node=t}update(){}}class Cy extends $n{constructor(t){super(t),t.animationState||(t.animationState=wy(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();Ur(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)===null||t===void 0||t.call(this)}}let ky=0;class My extends $n{constructor(){super(...arguments),this.id=ky++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===s)return;const i=this.node.animationState.setActive("exit",!t);n&&!t&&i.then(()=>n(this.id))}mount(){const{register:t}=this.node.presenceContext||{};t&&(this.unmount=t(this.id))}unmount(){}}const Ey={animation:{Feature:Cy},exit:{Feature:My}};function Pi(e,t,n,s={passive:!0}){return e.addEventListener(t,n,s),()=>e.removeEventListener(t,n)}function zi(e){return{point:{x:e.pageX,y:e.pageY}}}const Ty=e=>t=>el(t)&&e(t,zi(t));function yi(e,t,n,s){return Pi(e,t,Ty(n),s)}const Uc=(e,t)=>Math.abs(e-t);function Ay(e,t){const n=Uc(e.x,t.x),s=Uc(e.y,t.y);return Math.sqrt(n**2+s**2)}class lf{constructor(t,n,{transformPagePoint:s,contextWindow:i,dragSnapToOrigin:r=!1}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const u=ko(this.lastMoveEventInfo,this.history),f=this.startEvent!==null,p=Ay(u.offset,{x:0,y:0})>=3;if(!f&&!p)return;const{point:g}=u,{timestamp:d}=me;this.history.push({...g,timestamp:d});const{onStart:w,onMove:C}=this.handlers;f||(w&&w(this.lastMoveEvent,u),this.startEvent=this.lastMoveEvent),C&&C(this.lastMoveEvent,u)},this.handlePointerMove=(u,f)=>{this.lastMoveEvent=u,this.lastMoveEventInfo=Co(f,this.transformPagePoint),Bt.update(this.updatePoint,!0)},this.handlePointerUp=(u,f)=>{this.end();const{onEnd:p,onSessionEnd:g,resumeAnimation:d}=this.handlers;if(this.dragSnapToOrigin&&d&&d(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const w=ko(u.type==="pointercancel"?this.lastMoveEventInfo:Co(f,this.transformPagePoint),this.history);this.startEvent&&p&&p(u,w),g&&g(u,w)},!el(t))return;this.dragSnapToOrigin=r,this.handlers=n,this.transformPagePoint=s,this.contextWindow=i||window;const o=zi(t),l=Co(o,this.transformPagePoint),{point:c}=l,{timestamp:h}=me;this.history=[{...c,timestamp:h}];const{onSessionStart:a}=n;a&&a(t,ko(l,this.history)),this.removeListeners=Li(yi(this.contextWindow,"pointermove",this.handlePointerMove),yi(this.contextWindow,"pointerup",this.handlePointerUp),yi(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),Rn(this.updatePoint)}}function Co(e,t){return t?{point:t(e.point)}:e}function Hc(e,t){return{x:e.x-t.x,y:e.y-t.y}}function ko({point:e},t){return{point:e,delta:Hc(e,cf(t)),offset:Hc(e,Ry(t)),velocity:Py(t,.1)}}function Ry(e){return e[0]}function cf(e){return e[e.length-1]}function Py(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,s=null;const i=cf(e);for(;n>=0&&(s=e[n],!(i.timestamp-s.timestamp>Qe(t)));)n--;if(!s)return{x:0,y:0};const r=hn(i.timestamp-s.timestamp);if(r===0)return{x:0,y:0};const o={x:(i.x-s.x)/r,y:(i.y-s.y)/r};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}const hf=1e-4,_y=1-hf,$y=1+hf,uf=.01,Ny=0-uf,Iy=0+uf;function Ne(e){return e.max-e.min}function Dy(e,t,n){return Math.abs(e-t)<=n}function qc(e,t,n,s=.5){e.origin=s,e.originPoint=Ht(t.min,t.max,e.origin),e.scale=Ne(n)/Ne(t),e.translate=Ht(n.min,n.max,e.origin)-e.originPoint,(e.scale>=_y&&e.scale<=$y||isNaN(e.scale))&&(e.scale=1),(e.translate>=Ny&&e.translate<=Iy||isNaN(e.translate))&&(e.translate=0)}function bi(e,t,n,s){qc(e.x,t.x,n.x,s?s.originX:void 0),qc(e.y,t.y,n.y,s?s.originY:void 0)}function Gc(e,t,n){e.min=n.min+t.min,e.max=e.min+Ne(t)}function Ly(e,t,n){Gc(e.x,t.x,n.x),Gc(e.y,t.y,n.y)}function Yc(e,t,n){e.min=t.min-n.min,e.max=e.min+Ne(t)}function vi(e,t,n){Yc(e.x,t.x,n.x),Yc(e.y,t.y,n.y)}function zy(e,{min:t,max:n},s){return t!==void 0&&e<t?e=s?Ht(t,e,s.min):Math.max(e,t):n!==void 0&&e>n&&(e=s?Ht(n,e,s.max):Math.min(e,n)),e}function Xc(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function Fy(e,{top:t,left:n,bottom:s,right:i}){return{x:Xc(e.x,n,i),y:Xc(e.y,t,s)}}function Qc(e,t){let n=t.min-e.min,s=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,s]=[s,n]),{min:n,max:s}}function By(e,t){return{x:Qc(e.x,t.x),y:Qc(e.y,t.y)}}function Wy(e,t){let n=.5;const s=Ne(e),i=Ne(t);return i>s?n=Fs(t.min,t.max-s,e.min):s>i&&(n=Fs(e.min,e.max-i,t.min)),un(0,1,n)}function jy(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const da=.35;function Vy(e=da){return e===!1?e=0:e===!0&&(e=da),{x:Jc(e,"left","right"),y:Jc(e,"top","bottom")}}function Jc(e,t,n){return{min:Kc(e,t),max:Kc(e,n)}}function Kc(e,t){return typeof e=="number"?e:e[t]||0}const Zc=()=>({translate:0,scale:1,origin:0,originPoint:0}),Ps=()=>({x:Zc(),y:Zc()}),th=()=>({min:0,max:0}),Kt=()=>({x:th(),y:th()});function Fe(e){return[e("x"),e("y")]}function df({top:e,left:t,right:n,bottom:s}){return{x:{min:t,max:n},y:{min:e,max:s}}}function Oy({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function Uy(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),s=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:s.y,right:s.x}}function Mo(e){return e===void 0||e===1}function fa({scale:e,scaleX:t,scaleY:n}){return!Mo(e)||!Mo(t)||!Mo(n)}function Xn(e){return fa(e)||ff(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function ff(e){return eh(e.x)||eh(e.y)}function eh(e){return e&&e!=="0%"}function $r(e,t,n){const s=e-n,i=t*s;return n+i}function nh(e,t,n,s,i){return i!==void 0&&(e=$r(e,i,s)),$r(e,n,s)+t}function ma(e,t=0,n=1,s,i){e.min=nh(e.min,t,n,s,i),e.max=nh(e.max,t,n,s,i)}function mf(e,{x:t,y:n}){ma(e.x,t.translate,t.scale,t.originPoint),ma(e.y,n.translate,n.scale,n.originPoint)}const sh=.999999999999,ih=1.0000000000001;function Hy(e,t,n,s=!1){const i=n.length;if(!i)return;t.x=t.y=1;let r,o;for(let l=0;l<i;l++){r=n[l],o=r.projectionDelta;const{visualElement:c}=r.options;c&&c.props.style&&c.props.style.display==="contents"||(s&&r.options.layoutScroll&&r.scroll&&r!==r.root&&$s(e,{x:-r.scroll.offset.x,y:-r.scroll.offset.y}),o&&(t.x*=o.x.scale,t.y*=o.y.scale,mf(e,o)),s&&Xn(r.latestValues)&&$s(e,r.latestValues))}t.x<ih&&t.x>sh&&(t.x=1),t.y<ih&&t.y>sh&&(t.y=1)}function _s(e,t){e.min=e.min+t,e.max=e.max+t}function rh(e,t,n,s,i=.5){const r=Ht(e.min,e.max,i);ma(e,t,n,r,s)}function $s(e,t){rh(e.x,t.x,t.scaleX,t.scale,t.originX),rh(e.y,t.y,t.scaleY,t.scale,t.originY)}function pf(e,t){return df(Uy(e.getBoundingClientRect(),t))}function qy(e,t,n){const s=pf(e,n),{scroll:i}=t;return i&&(_s(s.x,i.offset.x),_s(s.y,i.offset.y)),s}const gf=({current:e})=>e?e.ownerDocument.defaultView:null,Gy=new WeakMap;class Yy{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Kt(),this.visualElement=t}start(t,{snapToCursor:n=!1}={}){const{presenceContext:s}=this.visualElement;if(s&&s.isPresent===!1)return;const i=a=>{const{dragSnapToOrigin:u}=this.getProps();u?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(zi(a).point)},r=(a,u)=>{const{drag:f,dragPropagation:p,onDragStart:g}=this.getProps();if(f&&!p&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Wg(f),!this.openDragLock))return;this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Fe(w=>{let C=this.getAxisMotionValue(w).get()||0;if(Je.test(C)){const{projection:x}=this.visualElement;if(x&&x.layout){const k=x.layout.layoutBox[w];k&&(C=Ne(k)*(parseFloat(C)/100))}}this.originPoint[w]=C}),g&&Bt.postRender(()=>g(a,u)),ia(this.visualElement,"transform");const{animationState:d}=this.visualElement;d&&d.setActive("whileDrag",!0)},o=(a,u)=>{const{dragPropagation:f,dragDirectionLock:p,onDirectionLock:g,onDrag:d}=this.getProps();if(!f&&!this.openDragLock)return;const{offset:w}=u;if(p&&this.currentDirection===null){this.currentDirection=Xy(w),this.currentDirection!==null&&g&&g(this.currentDirection);return}this.updateAxis("x",u.point,w),this.updateAxis("y",u.point,w),this.visualElement.render(),d&&d(a,u)},l=(a,u)=>this.stop(a,u),c=()=>Fe(a=>{var u;return this.getAnimationState(a)==="paused"&&((u=this.getAxisMotionValue(a).animation)===null||u===void 0?void 0:u.play())}),{dragSnapToOrigin:h}=this.getProps();this.panSession=new lf(t,{onSessionStart:i,onStart:r,onMove:o,onSessionEnd:l,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:h,contextWindow:gf(this.visualElement)})}stop(t,n){const s=this.isDragging;if(this.cancel(),!s)return;const{velocity:i}=n;this.startAnimation(i);const{onDragEnd:r}=this.getProps();r&&Bt.postRender(()=>r(t,n))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(t,n,s){const{drag:i}=this.getProps();if(!s||!tr(t,i,this.currentDirection))return;const r=this.getAxisMotionValue(t);let o=this.originPoint[t]+s[t];this.constraints&&this.constraints[t]&&(o=zy(o,this.constraints[t],this.elastic[t])),r.set(o)}resolveConstraints(){var t;const{dragConstraints:n,dragElastic:s}=this.getProps(),i=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(t=this.visualElement.projection)===null||t===void 0?void 0:t.layout,r=this.constraints;n&&As(n)?this.constraints||(this.constraints=this.resolveRefConstraints()):n&&i?this.constraints=Fy(i.layoutBox,n):this.constraints=!1,this.elastic=Vy(s),r!==this.constraints&&i&&this.constraints&&!this.hasMutatedConstraints&&Fe(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=jy(i.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!As(t))return!1;const s=t.current;An(s!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.");const{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const r=qy(s,i.root,this.visualElement.getTransformPagePoint());let o=By(i.layout.layoutBox,r);if(n){const l=n(Oy(o));this.hasMutatedConstraints=!!l,l&&(o=df(l))}return o}startAnimation(t){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:r,dragSnapToOrigin:o,onDragTransitionEnd:l}=this.getProps(),c=this.constraints||{},h=Fe(a=>{if(!tr(a,n,this.currentDirection))return;let u=c&&c[a]||{};o&&(u={min:0,max:0});const f=i?200:1e6,p=i?40:1e7,g={type:"inertia",velocity:s?t[a]:0,bounceStiffness:f,bounceDamping:p,timeConstant:750,restDelta:1,restSpeed:10,...r,...u};return this.startAxisValueAnimation(a,g)});return Promise.all(h).then(l)}startAxisValueAnimation(t,n){const s=this.getAxisMotionValue(t);return ia(this.visualElement,t),s.start(fl(t,s,0,n,this.visualElement,!1))}stopAnimation(){Fe(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){Fe(t=>{var n;return(n=this.getAxisMotionValue(t).animation)===null||n===void 0?void 0:n.pause()})}getAnimationState(t){var n;return(n=this.getAxisMotionValue(t).animation)===null||n===void 0?void 0:n.state}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,s=this.visualElement.getProps(),i=s[n];return i||this.visualElement.getValue(t,(s.initial?s.initial[t]:void 0)||0)}snapToCursor(t){Fe(n=>{const{drag:s}=this.getProps();if(!tr(n,s,this.currentDirection))return;const{projection:i}=this.visualElement,r=this.getAxisMotionValue(n);if(i&&i.layout){const{min:o,max:l}=i.layout.layoutBox[n];r.set(t[n]-Ht(o,l,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!As(n)||!s||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};Fe(o=>{const l=this.getAxisMotionValue(o);if(l&&this.constraints!==!1){const c=l.get();i[o]=Wy({min:c,max:c},this.constraints[o])}});const{transformTemplate:r}=this.visualElement.getProps();this.visualElement.current.style.transform=r?r({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.resolveConstraints(),Fe(o=>{if(!tr(o,t,null))return;const l=this.getAxisMotionValue(o),{min:c,max:h}=this.constraints[o];l.set(Ht(c,h,i[o]))})}addListeners(){if(!this.visualElement.current)return;Gy.set(this.visualElement,this);const t=this.visualElement.current,n=yi(t,"pointerdown",c=>{const{drag:h,dragListener:a=!0}=this.getProps();h&&a&&this.start(c)}),s=()=>{const{dragConstraints:c}=this.getProps();As(c)&&c.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,r=i.addEventListener("measure",s);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),Bt.read(s);const o=Pi(window,"resize",()=>this.scalePositionWithinConstraints()),l=i.addEventListener("didUpdate",({delta:c,hasLayoutChanged:h})=>{this.isDragging&&h&&(Fe(a=>{const u=this.getAxisMotionValue(a);u&&(this.originPoint[a]+=c[a].translate,u.set(u.get()+c[a].translate))}),this.visualElement.render())});return()=>{o(),n(),r(),l&&l()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:i=!1,dragConstraints:r=!1,dragElastic:o=da,dragMomentum:l=!0}=t;return{...t,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:r,dragElastic:o,dragMomentum:l}}}function tr(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Xy(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class Qy extends $n{constructor(t){super(t),this.removeGroupControls=Ae,this.removeListeners=Ae,this.controls=new Yy(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Ae}unmount(){this.removeGroupControls(),this.removeListeners()}}const oh=e=>(t,n)=>{e&&Bt.postRender(()=>e(t,n))};class Jy extends $n{constructor(){super(...arguments),this.removePointerDownListener=Ae}onPointerDown(t){this.session=new lf(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:gf(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:oh(t),onStart:oh(n),onMove:s,onEnd:(r,o)=>{delete this.session,i&&Bt.postRender(()=>i(r,o))}}}mount(){this.removePointerDownListener=yi(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const vr={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function ah(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const oi={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(ct.test(e))e=parseFloat(e);else return e;const n=ah(e,t.target.x),s=ah(e,t.target.y);return`${n}% ${s}%`}},Ky={correct:(e,{treeScale:t,projectionDelta:n})=>{const s=e,i=Pn.parse(e);if(i.length>5)return s;const r=Pn.createTransformer(e),o=typeof i[0]!="number"?1:0,l=n.x.scale*t.x,c=n.y.scale*t.y;i[0+o]/=l,i[1+o]/=c;const h=Ht(l,c,.5);return typeof i[2+o]=="number"&&(i[2+o]/=h),typeof i[3+o]=="number"&&(i[3+o]/=h),r(i)}};class Zy extends m.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:r}=t;vg(tb),r&&(n.group&&n.group.add(r),s&&s.register&&i&&s.register(r),r.root.didUpdate(),r.addEventListener("animationComplete",()=>{this.safeToRemove()}),r.setOptions({...r.options,onExitComplete:()=>this.safeToRemove()})),vr.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:s,drag:i,isPresent:r}=this.props,o=s.projection;return o&&(o.isPresent=r,i||t.layoutDependency!==n||n===void 0?o.willUpdate():this.safeToRemove(),t.isPresent!==r&&(r?o.promote():o.relegate()||Bt.postRender(()=>{const l=o.getStack();(!l||!l.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),Va.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:i}=t;i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),s&&s.deregister&&s.deregister(i))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function yf(e){const[t,n]=Zu(),s=m.useContext(Ia);return cn.jsx(Zy,{...e,layoutGroup:s,switchLayoutGroup:m.useContext(od),isPresent:t,safeToRemove:n})}const tb={borderRadius:{...oi,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:oi,borderTopRightRadius:oi,borderBottomLeftRadius:oi,borderBottomRightRadius:oi,boxShadow:Ky};function eb(e,t,n){const s=ve(e)?e:Ai(e);return s.start(fl("",s,t,n)),s.animation}function nb(e){return e instanceof SVGElement&&e.tagName!=="svg"}const sb=(e,t)=>e.depth-t.depth;class ib{constructor(){this.children=[],this.isDirty=!1}add(t){nl(this.children,t),this.isDirty=!0}remove(t){sl(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(sb),this.isDirty=!1,this.children.forEach(t)}}function rb(e,t){const n=Ke.now(),s=({timestamp:i})=>{const r=i-n;r>=t&&(Rn(s),e(r-t))};return Bt.read(s,!0),()=>Rn(s)}const bf=["TopLeft","TopRight","BottomLeft","BottomRight"],ob=bf.length,lh=e=>typeof e=="string"?parseFloat(e):e,ch=e=>typeof e=="number"||ct.test(e);function ab(e,t,n,s,i,r){i?(e.opacity=Ht(0,n.opacity!==void 0?n.opacity:1,lb(s)),e.opacityExit=Ht(t.opacity!==void 0?t.opacity:1,0,cb(s))):r&&(e.opacity=Ht(t.opacity!==void 0?t.opacity:1,n.opacity!==void 0?n.opacity:1,s));for(let o=0;o<ob;o++){const l=`border${bf[o]}Radius`;let c=hh(t,l),h=hh(n,l);if(c===void 0&&h===void 0)continue;c||(c=0),h||(h=0),c===0||h===0||ch(c)===ch(h)?(e[l]=Math.max(Ht(lh(c),lh(h),s),0),(Je.test(h)||Je.test(c))&&(e[l]+="%")):e[l]=h}(t.rotate||n.rotate)&&(e.rotate=Ht(t.rotate||0,n.rotate||0,s))}function hh(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const lb=vf(0,.5,Ld),cb=vf(.5,.95,Ae);function vf(e,t,n){return s=>s<e?0:s>t?1:n(Fs(e,t,s))}function uh(e,t){e.min=t.min,e.max=t.max}function ze(e,t){uh(e.x,t.x),uh(e.y,t.y)}function dh(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function fh(e,t,n,s,i){return e-=t,e=$r(e,1/n,s),i!==void 0&&(e=$r(e,1/i,s)),e}function hb(e,t=0,n=1,s=.5,i,r=e,o=e){if(Je.test(t)&&(t=parseFloat(t),t=Ht(o.min,o.max,t/100)-o.min),typeof t!="number")return;let l=Ht(r.min,r.max,s);e===r&&(l-=t),e.min=fh(e.min,t,n,l,i),e.max=fh(e.max,t,n,l,i)}function mh(e,t,[n,s,i],r,o){hb(e,t[n],t[s],t[i],t.scale,r,o)}const ub=["x","scaleX","originX"],db=["y","scaleY","originY"];function ph(e,t,n,s){mh(e.x,t,ub,n?n.x:void 0,s?s.x:void 0),mh(e.y,t,db,n?n.y:void 0,s?s.y:void 0)}function gh(e){return e.translate===0&&e.scale===1}function xf(e){return gh(e.x)&&gh(e.y)}function yh(e,t){return e.min===t.min&&e.max===t.max}function fb(e,t){return yh(e.x,t.x)&&yh(e.y,t.y)}function bh(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function wf(e,t){return bh(e.x,t.x)&&bh(e.y,t.y)}function vh(e){return Ne(e.x)/Ne(e.y)}function xh(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class mb{constructor(){this.members=[]}add(t){nl(this.members,t),t.scheduleRender()}remove(t){if(sl(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){const n=this.members.findIndex(i=>t===i);if(n===0)return!1;let s;for(let i=n;i>=0;i--){const r=this.members[i];if(r.isPresent!==!1){s=r;break}}return s?(this.promote(s),!0):!1}promote(t,n){const s=this.lead;if(t!==s&&(this.prevLead=s,this.lead=t,t.show(),s)){s.instance&&s.scheduleRender(),t.scheduleRender(),t.resumeFrom=s,n&&(t.resumeFrom.preserveOpacity=!0),s.snapshot&&(t.snapshot=s.snapshot,t.snapshot.latestValues=s.animationValues||s.latestValues),t.root&&t.root.isUpdating&&(t.isLayoutDirty=!0);const{crossfade:i}=t.options;i===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(t=>{const{options:n,resumingFrom:s}=t;n.onExitComplete&&n.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(t=>{t.instance&&t.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function pb(e,t,n){let s="";const i=e.x.translate/t.x,r=e.y.translate/t.y,o=(n==null?void 0:n.z)||0;if((i||r||o)&&(s=`translate3d(${i}px, ${r}px, ${o}px) `),(t.x!==1||t.y!==1)&&(s+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:h,rotate:a,rotateX:u,rotateY:f,skewX:p,skewY:g}=n;h&&(s=`perspective(${h}px) ${s}`),a&&(s+=`rotate(${a}deg) `),u&&(s+=`rotateX(${u}deg) `),f&&(s+=`rotateY(${f}deg) `),p&&(s+=`skewX(${p}deg) `),g&&(s+=`skewY(${g}deg) `)}const l=e.x.scale*t.x,c=e.y.scale*t.y;return(l!==1||c!==1)&&(s+=`scale(${l}, ${c})`),s||"none"}const Qn={type:"projectionFrame",totalNodes:0,resolvedTargetDeltas:0,recalculatedProjection:0},di=typeof window<"u"&&window.MotionDebug!==void 0,Eo=["","X","Y","Z"],gb={visibility:"hidden"},wh=1e3;let yb=0;function To(e,t,n,s){const{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),s&&(s[e]=0))}function Sf(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=Rd(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",Bt,!(i||r))}const{parent:s}=e;s&&!s.hasCheckedOptimisedAppear&&Sf(s)}function Cf({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(o={},l=t==null?void 0:t()){this.id=yb++,this.animationId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,di&&(Qn.totalNodes=Qn.resolvedTargetDeltas=Qn.recalculatedProjection=0),this.nodes.forEach(xb),this.nodes.forEach(Mb),this.nodes.forEach(Eb),this.nodes.forEach(wb),di&&window.MotionDebug.record(Qn)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,this.root=l?l.root||l:this,this.path=l?[...l.path,l]:[],this.parent=l,this.depth=l?l.depth+1:0;for(let c=0;c<this.path.length;c++)this.path[c].shouldResetTransform=!0;this.root===this&&(this.nodes=new ib)}addEventListener(o,l){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new il),this.eventHandlers.get(o).add(l)}notifyListeners(o,...l){const c=this.eventHandlers.get(o);c&&c.notify(...l)}hasListeners(o){return this.eventHandlers.has(o)}mount(o,l=this.root.hasTreeAnimated){if(this.instance)return;this.isSVG=nb(o),this.instance=o;const{layoutId:c,layout:h,visualElement:a}=this.options;if(a&&!a.current&&a.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),l&&(h||c)&&(this.isLayoutDirty=!0),e){let u;const f=()=>this.root.updateBlockedByResize=!1;e(o,()=>{this.root.updateBlockedByResize=!0,u&&u(),u=rb(f,250),vr.hasAnimatedSinceResize&&(vr.hasAnimatedSinceResize=!1,this.nodes.forEach(Ch))})}c&&this.root.registerSharedNode(c,this),this.options.animate!==!1&&a&&(c||h)&&this.addEventListener("didUpdate",({delta:u,hasLayoutChanged:f,hasRelativeTargetChanged:p,layout:g})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const d=this.options.transition||a.getDefaultTransition()||_b,{onLayoutAnimationStart:w,onLayoutAnimationComplete:C}=a.getProps(),x=!this.targetLayout||!wf(this.targetLayout,g)||p,k=!f&&p;if(this.options.layoutRoot||this.resumeFrom&&this.resumeFrom.instance||k||f&&(x||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0),this.setAnimationOrigin(u,k);const S={...Ka(d,"layout"),onPlay:w,onComplete:C};(a.shouldReduceMotion||this.options.layoutRoot)&&(S.delay=0,S.type=!1),this.startAnimation(S)}else f||Ch(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=g})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const o=this.getStack();o&&o.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,Rn(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(Tb),this.animationId++)}getTransformTemplate(){const{visualElement:o}=this.options;return o&&o.getProps().transformTemplate}willUpdate(o=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Sf(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let a=0;a<this.path.length;a++){const u=this.path[a];u.shouldResetTransform=!0,u.updateScroll("snapshot"),u.options.layoutRoot&&u.willUpdate(!1)}const{layoutId:l,layout:c}=this.options;if(l===void 0&&!c)return;const h=this.getTransformTemplate();this.prevTransformTemplateValue=h?h(this.latestValues,""):void 0,this.updateSnapshot(),o&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Sh);return}this.isUpdating||this.nodes.forEach(Cb),this.isUpdating=!1,this.nodes.forEach(kb),this.nodes.forEach(bb),this.nodes.forEach(vb),this.clearAllSnapshots();const l=Ke.now();me.delta=un(0,1e3/60,l-me.timestamp),me.timestamp=l,me.isProcessing=!0,yo.update.process(me),yo.preRender.process(me),yo.render.process(me),me.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Va.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Sb),this.sharedNodes.forEach(Ab)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Bt.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Bt.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure())}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let c=0;c<this.path.length;c++)this.path[c].updateScroll();const o=this.layout;this.layout=this.measure(!1),this.layoutCorrected=Kt(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:l}=this.options;l&&l.notify("LayoutMeasure",this.layout.layoutBox,o?o.layoutBox:void 0)}updateScroll(o="measure"){let l=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===o&&(l=!1),l){const c=s(this.instance);this.scroll={animationId:this.root.animationId,phase:o,isRoot:c,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:c}}}resetTransform(){if(!i)return;const o=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,l=this.projectionDelta&&!xf(this.projectionDelta),c=this.getTransformTemplate(),h=c?c(this.latestValues,""):void 0,a=h!==this.prevTransformTemplateValue;o&&(l||Xn(this.latestValues)||a)&&(i(this.instance,h),this.shouldResetTransform=!1,this.scheduleRender())}measure(o=!0){const l=this.measurePageBox();let c=this.removeElementScroll(l);return o&&(c=this.removeTransform(c)),$b(c),{animationId:this.root.animationId,measuredBox:l,layoutBox:c,latestValues:{},source:this.id}}measurePageBox(){var o;const{visualElement:l}=this.options;if(!l)return Kt();const c=l.measureViewportBox();if(!(((o=this.scroll)===null||o===void 0?void 0:o.wasRoot)||this.path.some(Nb))){const{scroll:a}=this.root;a&&(_s(c.x,a.offset.x),_s(c.y,a.offset.y))}return c}removeElementScroll(o){var l;const c=Kt();if(ze(c,o),!((l=this.scroll)===null||l===void 0)&&l.wasRoot)return c;for(let h=0;h<this.path.length;h++){const a=this.path[h],{scroll:u,options:f}=a;a!==this.root&&u&&f.layoutScroll&&(u.wasRoot&&ze(c,o),_s(c.x,u.offset.x),_s(c.y,u.offset.y))}return c}applyTransform(o,l=!1){const c=Kt();ze(c,o);for(let h=0;h<this.path.length;h++){const a=this.path[h];!l&&a.options.layoutScroll&&a.scroll&&a!==a.root&&$s(c,{x:-a.scroll.offset.x,y:-a.scroll.offset.y}),Xn(a.latestValues)&&$s(c,a.latestValues)}return Xn(this.latestValues)&&$s(c,this.latestValues),c}removeTransform(o){const l=Kt();ze(l,o);for(let c=0;c<this.path.length;c++){const h=this.path[c];if(!h.instance||!Xn(h.latestValues))continue;fa(h.latestValues)&&h.updateSnapshot();const a=Kt(),u=h.measurePageBox();ze(a,u),ph(l,h.latestValues,h.snapshot?h.snapshot.layoutBox:void 0,a)}return Xn(this.latestValues)&&ph(l,this.latestValues),l}setTargetDelta(o){this.targetDelta=o,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(o){this.options={...this.options,...o,crossfade:o.crossfade!==void 0?o.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==me.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(o=!1){var l;const c=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=c.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=c.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=c.isSharedProjectionDirty);const h=!!this.resumingFrom||this!==c;if(!(o||h&&this.isSharedProjectionDirty||this.isProjectionDirty||!((l=this.parent)===null||l===void 0)&&l.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:u,layoutId:f}=this.options;if(!(!this.layout||!(u||f))){if(this.resolvedRelativeTargetAt=me.timestamp,!this.targetDelta&&!this.relativeTarget){const p=this.getClosestProjectingParent();p&&p.layout&&this.animationProgress!==1?(this.relativeParent=p,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Kt(),this.relativeTargetOrigin=Kt(),vi(this.relativeTargetOrigin,this.layout.layoutBox,p.layout.layoutBox),ze(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)){if(this.target||(this.target=Kt(),this.targetWithTransforms=Kt()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Ly(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):ze(this.target,this.layout.layoutBox),mf(this.target,this.targetDelta)):ze(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget){this.attemptToResolveRelativeTarget=!1;const p=this.getClosestProjectingParent();p&&!!p.resumingFrom==!!this.resumingFrom&&!p.options.layoutScroll&&p.target&&this.animationProgress!==1?(this.relativeParent=p,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Kt(),this.relativeTargetOrigin=Kt(),vi(this.relativeTargetOrigin,this.target,p.target),ze(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}di&&Qn.resolvedTargetDeltas++}}}getClosestProjectingParent(){if(!(!this.parent||fa(this.parent.latestValues)||ff(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){var o;const l=this.getLead(),c=!!this.resumingFrom||this!==l;let h=!0;if((this.isProjectionDirty||!((o=this.parent)===null||o===void 0)&&o.isProjectionDirty)&&(h=!1),c&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(h=!1),this.resolvedRelativeTargetAt===me.timestamp&&(h=!1),h)return;const{layout:a,layoutId:u}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(a||u))return;ze(this.layoutCorrected,this.layout.layoutBox);const f=this.treeScale.x,p=this.treeScale.y;Hy(this.layoutCorrected,this.treeScale,this.path,c),l.layout&&!l.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(l.target=l.layout.layoutBox,l.targetWithTransforms=Kt());const{target:g}=l;if(!g){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(dh(this.prevProjectionDelta.x,this.projectionDelta.x),dh(this.prevProjectionDelta.y,this.projectionDelta.y)),bi(this.projectionDelta,this.layoutCorrected,g,this.latestValues),(this.treeScale.x!==f||this.treeScale.y!==p||!xh(this.projectionDelta.x,this.prevProjectionDelta.x)||!xh(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",g)),di&&Qn.recalculatedProjection++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(o=!0){var l;if((l=this.options.visualElement)===null||l===void 0||l.scheduleRender(),o){const c=this.getStack();c&&c.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Ps(),this.projectionDelta=Ps(),this.projectionDeltaWithTransform=Ps()}setAnimationOrigin(o,l=!1){const c=this.snapshot,h=c?c.latestValues:{},a={...this.latestValues},u=Ps();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!l;const f=Kt(),p=c?c.source:void 0,g=this.layout?this.layout.source:void 0,d=p!==g,w=this.getStack(),C=!w||w.members.length<=1,x=!!(d&&!C&&this.options.crossfade===!0&&!this.path.some(Pb));this.animationProgress=0;let k;this.mixTargetDelta=S=>{const T=S/1e3;kh(u.x,o.x,T),kh(u.y,o.y,T),this.setTargetDelta(u),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(vi(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),Rb(this.relativeTarget,this.relativeTargetOrigin,f,T),k&&fb(this.relativeTarget,k)&&(this.isProjectionDirty=!1),k||(k=Kt()),ze(k,this.relativeTarget)),d&&(this.animationValues=a,ab(a,h,this.latestValues,T,x,C)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=T},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){this.notifyListeners("animationStart"),this.currentAnimation&&this.currentAnimation.stop(),this.resumingFrom&&this.resumingFrom.currentAnimation&&this.resumingFrom.currentAnimation.stop(),this.pendingAnimation&&(Rn(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Bt.update(()=>{vr.hasAnimatedSinceResize=!0,this.currentAnimation=eb(0,wh,{...o,onUpdate:l=>{this.mixTargetDelta(l),o.onUpdate&&o.onUpdate(l)},onComplete:()=>{o.onComplete&&o.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(wh),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:l,target:c,layout:h,latestValues:a}=o;if(!(!l||!c||!h)){if(this!==o&&this.layout&&h&&kf(this.options.animationType,this.layout.layoutBox,h.layoutBox)){c=this.target||Kt();const u=Ne(this.layout.layoutBox.x);c.x.min=o.target.x.min,c.x.max=c.x.min+u;const f=Ne(this.layout.layoutBox.y);c.y.min=o.target.y.min,c.y.max=c.y.min+f}ze(l,c),$s(l,a),bi(this.projectionDeltaWithTransform,this.layoutCorrected,l,a)}}registerSharedNode(o,l){this.sharedNodes.has(o)||this.sharedNodes.set(o,new mb),this.sharedNodes.get(o).add(l);const h=l.options.initialPromotionConfig;l.promote({transition:h?h.transition:void 0,preserveFollowOpacity:h&&h.shouldPreserveFollowOpacity?h.shouldPreserveFollowOpacity(l):void 0})}isLead(){const o=this.getStack();return o?o.lead===this:!0}getLead(){var o;const{layoutId:l}=this.options;return l?((o=this.getStack())===null||o===void 0?void 0:o.lead)||this:this}getPrevLead(){var o;const{layoutId:l}=this.options;return l?(o=this.getStack())===null||o===void 0?void 0:o.prevLead:void 0}getStack(){const{layoutId:o}=this.options;if(o)return this.root.sharedNodes.get(o)}promote({needsReset:o,transition:l,preserveFollowOpacity:c}={}){const h=this.getStack();h&&h.promote(this,c),o&&(this.projectionDelta=void 0,this.needsReset=!0),l&&this.setOptions({transition:l})}relegate(){const o=this.getStack();return o?o.relegate(this):!1}resetSkewAndRotation(){const{visualElement:o}=this.options;if(!o)return;let l=!1;const{latestValues:c}=o;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(l=!0),!l)return;const h={};c.z&&To("z",o,h,this.animationValues);for(let a=0;a<Eo.length;a++)To(`rotate${Eo[a]}`,o,h,this.animationValues),To(`skew${Eo[a]}`,o,h,this.animationValues);o.render();for(const a in h)o.setStaticValue(a,h[a]),this.animationValues&&(this.animationValues[a]=h[a]);o.scheduleRender()}getProjectionStyles(o){var l,c;if(!this.instance||this.isSVG)return;if(!this.isVisible)return gb;const h={visibility:""},a=this.getTransformTemplate();if(this.needsReset)return this.needsReset=!1,h.opacity="",h.pointerEvents=yr(o==null?void 0:o.pointerEvents)||"",h.transform=a?a(this.latestValues,""):"none",h;const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){const d={};return this.options.layoutId&&(d.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,d.pointerEvents=yr(o==null?void 0:o.pointerEvents)||""),this.hasProjected&&!Xn(this.latestValues)&&(d.transform=a?a({},""):"none",this.hasProjected=!1),d}const f=u.animationValues||u.latestValues;this.applyTransformsToTarget(),h.transform=pb(this.projectionDeltaWithTransform,this.treeScale,f),a&&(h.transform=a(f,h.transform));const{x:p,y:g}=this.projectionDelta;h.transformOrigin=`${p.origin*100}% ${g.origin*100}% 0`,u.animationValues?h.opacity=u===this?(c=(l=f.opacity)!==null&&l!==void 0?l:this.latestValues.opacity)!==null&&c!==void 0?c:1:this.preserveOpacity?this.latestValues.opacity:f.opacityExit:h.opacity=u===this?f.opacity!==void 0?f.opacity:"":f.opacityExit!==void 0?f.opacityExit:0;for(const d in Tr){if(f[d]===void 0)continue;const{correct:w,applyTo:C}=Tr[d],x=h.transform==="none"?f[d]:w(f[d],u);if(C){const k=C.length;for(let S=0;S<k;S++)h[C[S]]=x}else h[d]=x}return this.options.layoutId&&(h.pointerEvents=u===this?yr(o==null?void 0:o.pointerEvents)||"":"none"),h}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>{var l;return(l=o.currentAnimation)===null||l===void 0?void 0:l.stop()}),this.root.nodes.forEach(Sh),this.root.sharedNodes.clear()}}}function bb(e){e.updateLayout()}function vb(e){var t;const n=((t=e.resumeFrom)===null||t===void 0?void 0:t.snapshot)||e.snapshot;if(e.isLead()&&e.layout&&n&&e.hasListeners("didUpdate")){const{layoutBox:s,measuredBox:i}=e.layout,{animationType:r}=e.options,o=n.source!==e.layout.source;r==="size"?Fe(u=>{const f=o?n.measuredBox[u]:n.layoutBox[u],p=Ne(f);f.min=s[u].min,f.max=f.min+p}):kf(r,n.layoutBox,s)&&Fe(u=>{const f=o?n.measuredBox[u]:n.layoutBox[u],p=Ne(s[u]);f.max=f.min+p,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[u].max=e.relativeTarget[u].min+p)});const l=Ps();bi(l,s,n.layoutBox);const c=Ps();o?bi(c,e.applyTransform(i,!0),n.measuredBox):bi(c,s,n.layoutBox);const h=!xf(l);let a=!1;if(!e.resumeFrom){const u=e.getClosestProjectingParent();if(u&&!u.resumeFrom){const{snapshot:f,layout:p}=u;if(f&&p){const g=Kt();vi(g,n.layoutBox,f.layoutBox);const d=Kt();vi(d,s,p.layoutBox),wf(g,d)||(a=!0),u.options.layoutRoot&&(e.relativeTarget=d,e.relativeTargetOrigin=g,e.relativeParent=u)}}}e.notifyListeners("didUpdate",{layout:s,snapshot:n,delta:c,layoutDelta:l,hasLayoutChanged:h,hasRelativeTargetChanged:a})}else if(e.isLead()){const{onExitComplete:s}=e.options;s&&s()}e.options.transition=void 0}function xb(e){di&&Qn.totalNodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function wb(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function Sb(e){e.clearSnapshot()}function Sh(e){e.clearMeasurements()}function Cb(e){e.isLayoutDirty=!1}function kb(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function Ch(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function Mb(e){e.resolveTargetDelta()}function Eb(e){e.calcProjection()}function Tb(e){e.resetSkewAndRotation()}function Ab(e){e.removeLeadSnapshot()}function kh(e,t,n){e.translate=Ht(t.translate,0,n),e.scale=Ht(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function Mh(e,t,n,s){e.min=Ht(t.min,n.min,s),e.max=Ht(t.max,n.max,s)}function Rb(e,t,n,s){Mh(e.x,t.x,n.x,s),Mh(e.y,t.y,n.y,s)}function Pb(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const _b={duration:.45,ease:[.4,0,.1,1]},Eh=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),Th=Eh("applewebkit/")&&!Eh("chrome/")?Math.round:Ae;function Ah(e){e.min=Th(e.min),e.max=Th(e.max)}function $b(e){Ah(e.x),Ah(e.y)}function kf(e,t,n){return e==="position"||e==="preserve-aspect"&&!Dy(vh(t),vh(n),.2)}function Nb(e){var t;return e!==e.root&&((t=e.scroll)===null||t===void 0?void 0:t.wasRoot)}const Ib=Cf({attachResizeListener:(e,t)=>Pi(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Ao={current:void 0},Mf=Cf({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!Ao.current){const e=new Ib({});e.mount(window),e.setOptions({layoutScroll:!0}),Ao.current=e}return Ao.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),Db={pan:{Feature:Jy},drag:{Feature:Qy,ProjectionNode:Mf,MeasureLayout:yf}};function Rh(e,t,n){const{props:s}=e;e.animationState&&s.whileHover&&e.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,r=s[i];r&&Bt.postRender(()=>r(t,zi(t)))}class Lb extends $n{mount(){const{current:t}=this.node;t&&(this.unmount=Dg(t,n=>(Rh(this.node,n,"Start"),s=>Rh(this.node,s,"End"))))}unmount(){}}class zb extends $n{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Li(Pi(this.node.current,"focus",()=>this.onFocus()),Pi(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Ph(e,t,n){const{props:s}=e;e.animationState&&s.whileTap&&e.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),r=s[i];r&&Bt.postRender(()=>r(t,zi(t)))}class Fb extends $n{mount(){const{current:t}=this.node;t&&(this.unmount=Bg(t,n=>(Ph(this.node,n,"Start"),(s,{success:i})=>Ph(this.node,s,i?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const pa=new WeakMap,Ro=new WeakMap,Bb=e=>{const t=pa.get(e.target);t&&t(e)},Wb=e=>{e.forEach(Bb)};function jb({root:e,...t}){const n=e||document;Ro.has(n)||Ro.set(n,{});const s=Ro.get(n),i=JSON.stringify(t);return s[i]||(s[i]=new IntersectionObserver(Wb,{root:e,...t})),s[i]}function Vb(e,t,n){const s=jb(t);return pa.set(e,n),s.observe(e),()=>{pa.delete(e),s.unobserve(e)}}const Ob={some:0,all:1};class Ub extends $n{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:s,amount:i="some",once:r}=t,o={root:n?n.current:void 0,rootMargin:s,threshold:typeof i=="number"?i:Ob[i]},l=c=>{const{isIntersecting:h}=c;if(this.isInView===h||(this.isInView=h,r&&!h&&this.hasEnteredView))return;h&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",h);const{onViewportEnter:a,onViewportLeave:u}=this.node.getProps(),f=h?a:u;f&&f(c)};return Vb(this.node.current,o,l)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(Hb(t,n))&&this.startObserver()}unmount(){}}function Hb({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const qb={inView:{Feature:Ub},tap:{Feature:Fb},focus:{Feature:zb},hover:{Feature:Lb}},Gb={layout:{ProjectionNode:Mf,MeasureLayout:yf}},ga={current:null},Ef={current:!1};function Yb(){if(Ef.current=!0,!!za)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>ga.current=e.matches;e.addListener(t),t()}else ga.current=!1}const Xb=[...Qd,be,Pn],Qb=e=>Xb.find(Xd(e)),_h=new WeakMap;function Jb(e,t,n){for(const s in t){const i=t[s],r=n[s];if(ve(i))e.addValue(s,i),process.env.NODE_ENV==="development"&&Vr(i.version==="11.18.2",`Attempting to mix Motion versions ${i.version} with 11.18.2 may not work as expected.`);else if(ve(r))e.addValue(s,Ai(i,{owner:e}));else if(r!==i)if(e.hasValue(s)){const o=e.getValue(s);o.liveStyle===!0?o.jump(i):o.hasAnimated||o.set(i)}else{const o=e.getStaticValue(s);e.addValue(s,Ai(o!==void 0?o:i,{owner:e}))}}for(const s in n)t[s]===void 0&&e.removeValue(s);return t}const $h=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Kb{scrapeMotionValuesFromProps(t,n,s){return{}}constructor({parent:t,props:n,presenceContext:s,reducedMotionConfig:i,blockInitialAnimation:r,visualState:o},l={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=hl,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const p=Ke.now();this.renderScheduledAt<p&&(this.renderScheduledAt=p,Bt.render(this.render,!1,!0))};const{latestValues:c,renderState:h,onUpdate:a}=o;this.onUpdate=a,this.latestValues=c,this.baseTarget={...c},this.initialValues=n.initial?{...c}:{},this.renderState=h,this.parent=t,this.props=n,this.presenceContext=s,this.depth=t?t.depth+1:0,this.reducedMotionConfig=i,this.options=l,this.blockInitialAnimation=!!r,this.isControllingVariants=Hr(n),this.isVariantNode=id(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:u,...f}=this.scrapeMotionValuesFromProps(n,{},this);for(const p in f){const g=f[p];c[p]!==void 0&&ve(g)&&g.set(c[p],!1)}}mount(t){this.current=t,_h.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,s)=>this.bindToMotionValue(s,n)),Ef.current||Yb(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:ga.current,process.env.NODE_ENV!=="production"&&Vr(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected."),this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){_h.delete(this.current),this.projection&&this.projection.unmount(),Rn(this.notifyUpdate),Rn(this.render),this.valueSubscriptions.forEach(t=>t()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(const t in this.events)this.events[t].clear();for(const t in this.features){const n=this.features[t];n&&(n.unmount(),n.isMounted=!1)}this.current=null}bindToMotionValue(t,n){this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)();const s=rs.has(t),i=n.on("change",l=>{this.latestValues[t]=l,this.props.onUpdate&&Bt.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0)}),r=n.on("renderRequest",this.scheduleRender);let o;window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{i(),r(),o&&o(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in Bs){const n=Bs[t];if(!n)continue;const{isEnabled:s,Feature:i}=n;if(!this.features[t]&&i&&s(this.props)&&(this.features[t]=new i(this)),this.features[t]){const r=this.features[t];r.isMounted?r.update():(r.mount(),r.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Kt()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let s=0;s<$h.length;s++){const i=$h[s];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const r="on"+i,o=t[r];o&&(this.propEventSubscriptions[i]=this.on(i,o))}this.prevMotionValues=Jb(this,this.scrapeMotionValuesFromProps(t,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue(),this.onUpdate&&this.onUpdate(this)}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(t){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(t),()=>n.variantChildren.delete(t)}addValue(t,n){const s=this.values.get(t);n!==s&&(s&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let s=this.values.get(t);return s===void 0&&n!==void 0&&(s=Ai(n===null?void 0:n,{owner:this}),this.addValue(t,s)),s}readValue(t,n){var s;let i=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:(s=this.getBaseTargetFromProps(this.props,t))!==null&&s!==void 0?s:this.readValueFromInstance(this.current,t,this.options);return i!=null&&(typeof i=="string"&&(Gd(i)||Fd(i))?i=parseFloat(i):!Qb(i)&&Pn.test(n)&&(i=Ud(t,n)),this.setBaseTarget(t,ve(i)?i.get():i)),ve(i)?i.get():i}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){var n;const{initial:s}=this.props;let i;if(typeof s=="string"||typeof s=="object"){const o=Ua(this.props,s,(n=this.presenceContext)===null||n===void 0?void 0:n.custom);o&&(i=o[t])}if(s&&i!==void 0)return i;const r=this.getBaseTargetFromProps(this.props,t);return r!==void 0&&!ve(r)?r:this.initialValues[t]!==void 0&&i===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new il),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}}class Tf extends Kb{constructor(){super(...arguments),this.KeyframeResolver=Jd}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){return t.style?t.style[n]:void 0}removeValueFromRenderState(t,{vars:n,style:s}){delete n[t],delete s[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;ve(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Zb(e){return window.getComputedStyle(e)}class tv extends Tf{constructor(){super(...arguments),this.type="html",this.renderInstance=fd}readValueFromInstance(t,n){if(rs.has(n)){const s=cl(n);return s&&s.default||0}else{const s=Zb(t),i=(hd(n)?s.getPropertyValue(n):s[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(t,{transformPagePoint:n}){return pf(t,n)}build(t,n,s){Ga(t,n,s.transformTemplate)}scrapeMotionValuesFromProps(t,n,s){return Ja(t,n,s)}}class ev extends Tf{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Kt}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(rs.has(n)){const s=cl(n);return s&&s.default||0}return n=md.has(n)?n:ja(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,s){return yd(t,n,s)}build(t,n,s){Ya(t,n,this.isSVGTag,s.transformTemplate)}renderInstance(t,n,s,i){pd(t,n,s,i)}mount(t){this.isSVGTag=Qa(t.tagName),super.mount(t)}}const nv=(e,t)=>Oa(e)?new ev(t):new tv(t,{allowProjection:e!==m.Fragment}),sv=Ag({...Ey,...qb,...Db,...Gb},nv),Nr=Op(sv),iv={div:"div",span:"span",p:"p",hr:"hr",a:"a",strong:"strong",em:"em",del:"del",li:"li",ul:"ul",ol:"ol",form:"form",img:"img",header:"header",footer:"footer",section:"section",nav:"nav",main:"main",article:"article",aside:"aside",figure:"figure",figcaption:"figcaption",th:"th",td:"td",caption:"caption",blockquote:"blockquote",address:"address",time:"time",legend:"legend",label:"label",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",code:"code"},rv=new Set(["motion","initial","animate","exit","transition","variants","whileHover","whileTap","whileFocus","whileInView","animateLayout"]);function E(e,t,...n){const{style:s,className:i,...r}=t||{};if(r.motion){const l={};for(const h of rv)if(h in r){const a=h==="animateLayout"?"layout":h;let u=r[h];a==="transition"&&u&&typeof u=="object"&&(u={...u,repeat:Math.max(0,Number(u.repeat)||0)}),l[a]=u,delete r[h]}const c=Nr[e]||Nr.div;return m.createElement(c,{...r,className:i,style:s||{},...l},...n)}delete r.animateLayout;const o=iv[e];return o?m.createElement(o,{...r,className:i,style:s||{}},...n):m.createElement(e,{...r,className:i,style:s||{}},...n)}const ov={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Af={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Rf=["base","sm","md","lg","xl","2xl"],oe={0:"0px","0.5":"0.125rem",1:"0.25rem","1.5":"0.375rem",2:"0.5rem","2.5":"0.625rem",3:"0.75rem","3.5":"0.875rem",4:"1rem",5:"1.25rem",6:"1.5rem",7:"1.75rem",8:"2rem",9:"2.25rem",10:"2.5rem",11:"2.75rem",12:"3rem",14:"3.5rem",16:"4rem",20:"5rem",24:"6rem",28:"7rem",32:"8rem",36:"9rem",40:"10rem",44:"11rem",48:"12rem",52:"13rem",56:"14rem",60:"15rem",64:"16rem",72:"18rem",80:"20rem",96:"24rem"},er={xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem","4xl":"2.25rem","5xl":"3rem","6xl":"3.75rem","7xl":"4.5rem","8xl":"6rem","9xl":"8rem"},Nh={"1/2":"50%","1/3":"33.333333%","2/3":"66.666667%","1/4":"25%","2/4":"50%","3/4":"75%","1/5":"20%","2/5":"40%","3/5":"60%","4/5":"80%","1/6":"16.666667%","2/6":"33.333333%","3/6":"50%","4/6":"66.666667%","5/6":"83.333333%","1/12":"8.333333%","2/12":"16.666667%","3/12":"25%","4/12":"33.333333%","5/12":"41.666667%","6/12":"50%","7/12":"58.333333%","8/12":"66.666667%","9/12":"75%","10/12":"83.333333%","11/12":"91.666667%",full:"100%",auto:"auto",screen:"100vw",fit:"fit-content",max:"max-content",min:"min-content"},nr={"flex-row":"row","flex-row-reverse":"row-reverse","flex-col":"column","flex-col-reverse":"column-reverse"},sr={"items-start":"flex-start","items-end":"flex-end","items-center":"center","items-baseline":"baseline","items-stretch":"stretch"},ir={"justify-start":"flex-start","justify-end":"flex-end","justify-center":"center","justify-between":"space-between","justify-around":"space-around","justify-evenly":"space-evenly"},rr={"rounded-none":"0px","rounded-sm":"0.125rem",rounded:"0.25rem","rounded-md":"0.375rem","rounded-lg":"0.5rem","rounded-xl":"0.75rem","rounded-2xl":"1rem","rounded-3xl":"1.5rem","rounded-full":"9999px"},av=["hidden","block","flex","grid","inline","inline-block","inline-flex"];function lv(e,t,n,s){const i=new Map,r=e.split(/\s+/).filter(Boolean);for(const o of r){const l=new RegExp(n.source).exec(o);if(l){i.set(l[1],s(l));continue}const c=new RegExp(t.source).exec(o);c&&i.set("base",s([null,null,c[1]]))}return i}function Pf(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const s of n){const i=s.match(/^(sm|md|lg|xl|2xl):(flex-row|flex-row-reverse|flex-col|flex-col-reverse)$/);if(i&&nr[i[2]]){t.set(i[1],nr[i[2]]);continue}nr[s]&&t.set("base",nr[s])}return t}function _f(e){return lv(e,/^gap-(\d+(?:\.\d+)?)$/,/^(sm|md|lg|xl|2xl):gap-(\d+(?:\.\d+)?)$/,t=>oe[t[2]]||`${t[2]}px`)}function $f(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const s of n){const i=s.match(/^(sm|md|lg|xl|2xl):w-(.+)$/);if(i){const o=Nh[i[2]]||oe[i[2]]||i[2];o&&t.set(i[1],o);continue}const r=s.match(/^w-(.+)$/);if(r){const o=Nh[r[1]]||oe[r[1]]||r[1];o&&t.set("base",o)}}return t}function Nf(e){const t=new Map,n=new Map,s=new Map,i=new Map,r=new Map,o=new Map,l=new Map,c=e.split(/\s+/).filter(Boolean);for(const h of c)for(const[a,u]of[["m-",t],["mt-",n],["mr-",s],["mb-",i],["ml-",r],["mx-",o],["my-",l]]){const f=h.match(new RegExp(`^(sm|md|lg|xl|2xl):${a}(\\d+(?:\\.\\d+)?)$`));if(f&&oe[f[2]]){u.set(f[1],oe[f[2]]);break}const p=h.match(new RegExp(`^${a}(\\d+(?:\\.\\d+)?)$`));if(p&&oe[p[1]]){u.set("base",oe[p[1]]);break}}return{all:t,t:n,r:s,b:i,l:r,x:o,y:l}}function If(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const s of n){const i=s.match(/^(sm|md|lg|xl|2xl):(items-start|items-end|items-center|items-baseline|items-stretch)$/);if(i&&sr[i[2]]){t.set(i[1],sr[i[2]]);continue}sr[s]&&t.set("base",sr[s])}return t}function Df(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const s of n){const i=s.match(/^(sm|md|lg|xl|2xl):(justify-start|justify-end|justify-center|justify-between|justify-around|justify-evenly)$/);if(i&&ir[i[2]]){t.set(i[1],ir[i[2]]);continue}ir[s]&&t.set("base",ir[s])}return t}function Lf(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const s of n){const i=s.match(/^(sm|md|lg|xl|2xl):(rounded-none|rounded-sm|rounded|rounded-md|rounded-lg|rounded-xl|rounded-2xl|rounded-3xl|rounded-full)$/);if(i&&rr[i[2]]){t.set(i[1],rr[i[2]]);continue}rr[s]&&t.set("base",rr[s])}return t}function ml(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const s of n){const i=s.match(/^(sm|md|lg|xl|2xl):(hidden|block|flex|grid|inline|inline-block|inline-flex)$/);if(i){t.set(i[1],i[2]==="hidden"?"none":i[2]);continue}av.includes(s)&&t.set("base",s==="hidden"?"none":s)}return t}function pl(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const s of n){const i=s.match(/^(sm|md|lg|xl|2xl):grid-cols-(\d+)$/);if(i){t.set(i[1],parseInt(i[2],10));continue}const r=s.match(/^grid-cols-(\d+)$/);r&&t.set("base",parseInt(r[1],10))}return t}function gl(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const s of n){const i=s.match(/^(sm|md|lg|xl|2xl):text-(xs|sm|base|lg|xl|2xl|3xl|4xl|5xl|6xl|7xl|8xl|9xl)$/);if(i&&er[i[2]]){t.set(i[1],er[i[2]]);continue}const r=s.match(/^text-(xs|sm|base|lg|xl|2xl|3xl|4xl|5xl|6xl|7xl|8xl|9xl)$/);r&&er[r[1]]&&t.set("base",er[r[1]])}return t}function yl(e){const t=new Map,n=new Map,s=new Map,i=e.split(/\s+/).filter(Boolean);for(const r of i){const o=r.match(/^(sm|md|lg|xl|2xl):px-(\d+(?:\.\d+)?)$/);if(o&&oe[o[2]]){t.set(o[1],oe[o[2]]);continue}const l=r.match(/^px-(\d+(?:\.\d+)?)$/);if(l&&oe[l[1]]){t.set("base",oe[l[1]]);continue}const c=r.match(/^(sm|md|lg|xl|2xl):py-(\d+(?:\.\d+)?)$/);if(c&&oe[c[2]]){n.set(c[1],oe[c[2]]);continue}const h=r.match(/^py-(\d+(?:\.\d+)?)$/);if(h&&oe[h[1]]){n.set("base",oe[h[1]]);continue}const a=r.match(/^(sm|md|lg|xl|2xl):p-(\d+(?:\.\d+)?)$/);if(a&&oe[a[2]]){s.set(a[1],oe[a[2]]);continue}const u=r.match(/^p-(\d+(?:\.\d+)?)$/);u&&oe[u[1]]&&s.set("base",oe[u[1]])}return{px:t,py:n,p:s}}function ya(e){return e.flexDirection.size>0||e.gap.size>0||e.width.size>0||e.alignItems.size>0||e.justifyContent.size>0||e.padding.px.size>0||e.padding.py.size>0||e.padding.p.size>0||e.display.size>0||e.gridCols.size>0||e.textSize.size>0||e.borderRadius.size>0||e.margin.all.size>0||e.margin.t.size>0||e.margin.r.size>0||e.margin.b.size>0||e.margin.l.size>0||e.margin.x.size>0||e.margin.y.size>0}function ba(e){return{flexDirection:Pf(e),gap:_f(e),width:$f(e),margin:Nf(e),alignItems:If(e),justifyContent:Df(e),padding:yl(e),display:ml(e),gridCols:pl(e),textSize:gl(e),borderRadius:Lf(e),any:!1}}const _i=ov;function cv(e){return pl(e)}function hv(e,t){let n=e.get("base")??1;const s=["2xl","xl","lg","md","sm"];if(t<=0){for(const i of s)if(e.has(i))return e.get(i);return n}for(const i of["sm","md","lg","xl","2xl"])t>=(_i[i]||0)&&e.has(i)&&(n=e.get(i));return n}function bl(e){return gl(e)}function ht(e,t,n){let s=e.get("base")??n;for(const i of["sm","md","lg","xl","2xl"])t>=(_i[i]||0)&&e.has(i)&&(s=e.get(i));return s}function Fi(e){return yl(e)}function Gs(e){return ml(e)}function zf(e){const[t,n]=m.useState(()=>{var i;return((i=e.current)==null?void 0:i.offsetWidth)??0}),s=m.useRef(t);return m.useEffect(()=>{const i=e.current;if(!i)return;const r=i.offsetWidth;r>0&&r!==s.current&&(s.current=r,n(r));const o=new ResizeObserver(l=>{for(const c of l){const h=Math.round(c.contentRect.width);h>0&&h!==s.current&&(s.current=h,n(h))}});return o.observe(i),()=>{o.disconnect()}},[e]),t}function uv(e,t,n){var h,a,u;const i=(Array.isArray(t.tabItems)?t.tabItems:Array.isArray(t.tabs)?t.tabs:[]).filter(f=>!f.condition||!e.evaluateCondition||e.evaluateCondition(f.condition));if(i.length===0)return null;const r=`__tab_${n}`,o=e.sceneData[r]??(t.defaultTab||0),l={width:"100%",display:"flex",flexDirection:"column",...t.className?((h=e.parseClassNameResponsive)==null?void 0:h.call(e,t.className,n))??e.parseClassName(t.className):{}},c=e.getCommonProps(n,l,t);return m.createElement("div",{key:n,...c},m.createElement("div",{style:{display:"flex",borderBottom:`1px solid ${e.cfg.colors.borderSubtle}`,gap:"0"}},i.map((f,p)=>m.createElement("button",{key:`${n}-tab-${p}`,onClick:()=>e.setSceneData(g=>({...g,[r]:p})),style:{padding:"8px 16px",fontSize:"13px",fontWeight:o===p?600:400,color:o===p?e.cfg.colors.primary:e.cfg.colors.textMuted,borderBottom:o===p?`2px solid ${e.cfg.colors.primary}`:"2px solid transparent",background:"none",border:"none",borderBottomStyle:"solid",borderBottomWidth:"2px",borderBottomColor:o===p?e.cfg.colors.primary:"transparent",cursor:"pointer",transition:e.cfg.effects.transition}},f.label||f.title))),m.createElement("div",{style:{padding:"12px 0"}},(Array.isArray((a=i[o])==null?void 0:a.content)?i[o].content:Array.isArray((u=i[o])==null?void 0:u.children)?i[o].children:[]).map((f,p)=>e.renderComponent(f,p,`${n}-tabcontent-${o}`))))}function dv(e,t,n){var o;Array.isArray(t.items)&&!Array.isArray(t.accordionItems)&&(t.accordionItems=t.items);const s=Array.isArray(t.accordionItems)?t.accordionItems:[];if(s.length===0)return null;const i={width:"100%",display:"flex",flexDirection:"column",gap:"1px",...t.className?((o=e.parseClassNameResponsive)==null?void 0:o.call(e,t.className,n))??e.parseClassName(t.className):{}},r=e.getCommonProps(n,i,t);return m.createElement("div",{key:n,...r},s.map((l,c)=>{const h=`__acc_${n}_${c}`,a=e.sceneData[h]??(l.defaultOpen||!1);return m.createElement("div",{key:`${n}-acc-${c}`},m.createElement("button",{onClick:()=>e.setSceneData(u=>({...u,[h]:!a})),style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 12px",background:"none",border:"none",borderBottom:`1px solid ${e.cfg.colors.borderSubtle}`,color:e.cfg.colors.textSecondary,fontSize:e.cfg.typography.baseFontSize,fontWeight:500,cursor:"pointer",transition:e.cfg.effects.transition}},E("span",{style:{display:"flex",alignItems:"center",gap:"8px"}},l.icon?e.renderIcon(l.icon,14,{color:e.cfg.colors.primary}):null,E("span",null,l.title)),E("span",{style:{transform:a?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s",fontSize:"24px"}},"▾")),m.createElement(Dp,{initial:!1},a&&m.createElement(Nr.div,{key:`${n}-acc-body-${c}`,initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{height:{duration:.3,ease:"easeInOut"},opacity:{duration:.25}},style:{overflow:"hidden"}},m.createElement("div",{style:{padding:"8px 12px",display:"flex",flexDirection:"column",gap:"8px"}},(Array.isArray(l.content)?l.content:typeof l.content=="string"?[{type:"text",text:l.content}]:Array.isArray(l.children)?l.children:[]).map((f,p)=>e.renderComponent(f,p,`${n}-acc-${c}-content`))))))}))}function fv(e,t,n){var p,g,d,w,C;const s=(p=e.paginationState)==null?void 0:p[n],i=t.pagination===!0&&s&&s.total>s.limit,r=t.pagination==="scroll",o=s?Math.ceil(s.total/s.limit):0,l=t.className||"flex flex-col gap-3 w-full",c=((g=e.parseClassNameResponsive)==null?void 0:g.call(e,l,n))??e.parseClassName(l);t.rawStyle&&Object.assign(c,t.rawStyle);const h=(d=e.loading)==null?void 0:d[n],a=(w=e.listData)==null?void 0:w[n],u=Array.isArray(a)?a:[],f=e.renderMode==="css-driven"?{"data-bf-r":`${e.scopeId}-${n}`}:{};return m.createElement("div",{key:n,className:l,style:c,"data-component-key":n,...f},h&&(t.loadingComponent?e.renderComponent(t.loadingComponent,0,n):m.createElement("div",{className:"flex justify-center py-4"},E("div",{className:"w-6 h-6 border-2 border-primary border-t-transparent rounded-full animate-spin"}))),!h&&u.length===0&&t.emptyComponent&&e.renderComponent(t.emptyComponent,0,`${n}-empty`),!h&&t.selectable&&e.sceneData._selectMode&&u.length>0&&E("div",{key:`${n}-sel-hdr`,style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:((C=t.selectionStyle)==null?void 0:C.headerPadding)||"0.5rem 2rem"}},E("button",{type:"button",onClick:()=>{const x=Array.isArray(e.sceneData._selIds)?e.sceneData._selIds:[],k=u.map((T,P)=>String(T.id||P)),S=k.length>0&&k.every(T=>x.includes(T));e.setSceneData(T=>({...T,_selIds:S?[]:k}))},style:{background:"none",border:"none",cursor:"pointer",color:e.cfg.colors.textSecondary,fontSize:"12px",fontFamily:"inherit",padding:"4px 0"}},(Array.isArray(e.sceneData._selIds)?e.sceneData._selIds:[]).filter(x=>u.some(k=>String(k.id)===x)).length===u.filter(x=>x.id).length&&u.length>0?"Deselect all":"Select all"),(Array.isArray(e.sceneData._selIds)?e.sceneData._selIds:[]).length>0?E("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},...(Array.isArray(t.selectActions)?t.selectActions:[]).map((x,k)=>E("button",{key:k,type:"button",onClick:()=>{var T;const S=Array.isArray(e.sceneData._selIds)?e.sceneData._selIds:[];S.length!==0&&((T=e.runBulkSelectAction)==null||T.call(e,x,t.dataSource,n,S))},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"28px",height:"28px",border:"none",borderRadius:"4px",cursor:"pointer",backgroundColor:"transparent",color:e.cfg.colors.textSecondary,transition:"all 0.15s ease",padding:"0"},onMouseEnter:S=>{S.currentTarget.style.backgroundColor=e.cfg.colors.border,S.currentTarget.style.color=e.cfg.colors.text},onMouseLeave:S=>{S.currentTarget.style.backgroundColor="transparent",S.currentTarget.style.color=e.cfg.colors.textSecondary}},e.renderIcon(x.icon,12))),E("span",{style:{fontSize:"12px",color:e.cfg.colors.textMuted}},`${(Array.isArray(e.sceneData._selIds)?e.sceneData._selIds:[]).length} selected`)):null),!h&&u.length>0&&(()=>{var V,J,nt,it;const x=(V=t.groupBy)==null?void 0:V.field,k=Q=>{const ut=Q==null?void 0:Q[x];if(ut&&typeof ut=="object"&&ut._seconds)return ut._seconds*1e3;const Ct=Date.parse(ut);return isNaN(Ct)?0:Ct},S=Q=>{if(!Q)return"Earlier";const ut=new Date(Q),Ct=new Date,ft=qt=>`${qt.getFullYear()}-${qt.getMonth()}-${qt.getDate()}`;if(ft(ut)===ft(Ct))return"Today";const Dt=new Date(Ct);return Dt.setDate(Ct.getDate()-1),ft(ut)===ft(Dt)?"Yesterday":ut.toLocaleDateString()},P=((J=t.sort)==null?void 0:J.field)||x?[...u].sort((Q,ut)=>{var ft;const Ct=k(ut)-k(Q);return((ft=t.sort)==null?void 0:ft.direction)==="asc"?-Ct:Ct}):u,I=String(e.sceneData.recordingSearchApplied||"").trim().toLowerCase(),[L,O]=String(e.sceneData.recordingDateFilterApplied||"").split("|"),H=L?Date.parse(`${L}T00:00:00`):0,U=O?Date.parse(`${O}T23:59:59.999`):Number.POSITIVE_INFINITY,X=((nt=t.itemsFilter)!=null&&nt.field?P.filter(Q=>String(Q==null?void 0:Q[t.itemsFilter.field])===String(t.itemsFilter.eq)):P).filter(Q=>{const ut=!I||[Q.url,Q.title,Q.prompt].some(ft=>String(ft||"").toLowerCase().includes(I)),Ct=k(Q);return ut&&Ct>=H&&Ct<=U}),j={};if(x)for(const Q of X)(j[it=S(k(Q))]||(j[it]=[])).push(Q);const D=(Q,ut)=>{var Ct,ft,Dt,qt,ne,te,mt,he;if(t.renderItem){const Pe=JSON.parse(JSON.stringify(t.renderItem)),ae={...Q};if(t.labelField&&t.labelMap){const bt=String(t.labelField.split(".").reduce((Rt,Lt)=>Rt==null?void 0:Rt[Lt],Q)??"");ae.label=t.labelMap[bt]??""}const In={};if(Array.isArray(Pe.children)){for(const bt of Pe.children)if(bt.content){const Rt=bt.content.match(/^\{\{(\w+)\}\}$/);if(Rt){const Lt=Rt[1],kt=Q[Lt];Array.isArray(kt)&&(In[Lt]=kt)}}}const Oe=JSON.stringify(Pe).replace(/\{\{([\w.]+)(?:\|(date|time|datetime|timeago))?\}\}/g,(bt,Rt,Lt)=>{const kt=Rt.split(".").reduce((yt,wt)=>yt==null?void 0:yt[wt],ae);if(Array.isArray(kt))return bt;if(kt==null)return"";if(Lt){const yt=kt&&typeof kt=="object"&&"_seconds"in kt?new Date(kt._seconds*1e3):new Date(kt);if(!isNaN(yt.getTime())){if(Lt==="timeago"){const wt=Math.floor((Date.now()-yt.getTime())/6e4);if(wt<1)return"just now";if(wt<60)return`${wt}m ago`;const gt=Math.floor(wt/60);if(gt<24)return`${gt}h ago`;const Xt=Math.floor(gt/24);return Xt<7?`${Xt}d ago`:yt.toLocaleDateString()}return Lt==="date"?yt.toLocaleDateString():Lt==="time"?yt.toLocaleTimeString():yt.toLocaleString()}}return typeof kt=="string"?kt.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t"):kt!==void 0?JSON.stringify(kt):""}),xe=JSON.parse(Oe);if(xe.children&&(xe.children=xe.children.map(bt=>{var kt;const Rt=bt.fieldType||"text",Lt=(kt=bt.content)==null?void 0:kt.match(/^\{\{(\w+)\}\}$/);if(Lt){const yt=Lt[1],wt=In[yt];if(wt)return Rt==="dropdown"?{...bt,type:"select",content:void 0,placeholder:bt.fieldPlaceholder||`Select ${yt}...`,options:wt.map(gt=>({label:typeof gt=="object"?gt.label||gt.name||JSON.stringify(gt):String(gt),value:typeof gt=="object"?gt.value||gt.id||JSON.stringify(gt):String(gt)})),name:`${n}-${ut}-${yt}`,className:bt.className||"w-full text-sm bg-slate-700 border border-slate-500 text-white rounded-lg px-3 py-1.5"}:Rt==="multiselect"?{...bt,type:"container",content:void 0,className:bt.className||"flex flex-col gap-1 w-full",children:[...bt.fieldPlaceholder?[{type:"text",content:bt.fieldPlaceholder,className:"text-xs text-gray-400 mb-1"}]:[{type:"text",content:`Select ${yt}`,className:"text-xs text-gray-400 mb-1"}],...wt.map((gt,Xt)=>({type:"checkbox",label:typeof gt=="object"?gt.label||gt.name||JSON.stringify(gt):String(gt),name:`${n}-${ut}-${yt}-${Xt}`,className:"text-sm text-gray-200"}))]}:Rt==="image-grid"?{...bt,type:"container",content:void 0,className:"flex flex-row gap-2 w-full overflow-x-auto py-1",children:wt.slice(0,10).map((gt,Xt)=>({type:"image",src:typeof gt=="string"?gt:gt.url||gt.src||"",alt:`${yt} ${Xt+1}`,className:"w-12 h-12 rounded-lg object-cover flex-shrink-0"}))}:{...bt,type:"container",content:void 0,className:"flex flex-col gap-1 w-full",children:[{type:"text",content:`⚠ "${yt}" is an array (${wt.length} items)`,className:"text-xs font-semibold text-amber-400"},{type:"text",content:"Use ⚡ to fetch fields, then set type in sidebar",className:"text-xs text-amber-300 opacity-75"}]}}return Rt==="image"&&bt.content&&!bt.content.includes("{{")?{...bt,type:"image",src:bt.content,alt:bt.content,content:void 0,className:bt.className||"w-full h-32 rounded-lg object-cover"}:bt})),t.selectable&&e.sceneData._selectMode){const bt=String(Q.id||ut),Rt=Array.isArray(e.sceneData._selIds)&&e.sceneData._selIds.map(String).includes(bt),Lt=yt=>yt?[yt.text,yt.content,...yt.children?yt.children.flatMap(Lt):[]].filter(wt=>typeof wt=="string"&&wt.trim()&&!wt.includes("{{")):[],kt=xe.text||xe.label||Lt(xe).slice(0,2).join(" — ")||String(Q.id||ut);return E("button",{key:`${n}-item-${ut}`,className:(Ct=t.selectionStyle)==null?void 0:Ct.className,type:"button",onClick:()=>{e.setSceneData(yt=>({...yt,_selIds:(()=>{const wt=Array.isArray(yt._selIds)?yt._selIds.map(String):[];return wt.includes(bt)?wt.filter(gt=>gt!==bt):[...wt,bt]})()}))},style:{width:"100%",textAlign:"left",padding:"1rem 2rem",border:`1px solid ${Rt?((ft=t.selectionStyle)==null?void 0:ft.selectedBorderColor)||e.cfg.colors.accent||"#fff":((Dt=t.selectionStyle)==null?void 0:Dt.borderColor)||e.cfg.colors.border}`,borderRadius:((qt=t.selectionStyle)==null?void 0:qt.borderRadius)||e.cfg.components.inputRadius||"8px",marginBottom:"0.5rem",backgroundColor:Rt?((ne=t.selectionStyle)==null?void 0:ne.selectedBackgroundColor)||e.cfg.colors.surface:"transparent",color:e.cfg.colors.text,cursor:"pointer",fontFamily:"inherit",fontSize:"14px",fontWeight:Rt?600:400,transition:"all 0.15s ease",outline:"none"},onMouseEnter:yt=>{var gt,Xt;const wt=yt.currentTarget.firstElementChild;!Rt&&wt&&(wt.style.borderColor=((gt=t.selectionStyle)==null?void 0:gt.selectedBorderColor)||e.cfg.colors.accent||"#fff",wt.style.backgroundColor=((Xt=t.selectionStyle)==null?void 0:Xt.selectedBackgroundColor)||e.cfg.colors.surface,yt.currentTarget.style.borderColor=e.cfg.colors.textMuted)},onMouseLeave:yt=>{var gt,Xt,Ue;const wt=yt.currentTarget.firstElementChild;!Rt&&wt&&(wt.style.borderColor=((gt=t.selectionStyle)==null?void 0:gt.borderColor)||e.cfg.colors.border,wt.style.backgroundColor="transparent"),yt.currentTarget.style.borderColor=Rt?((Xt=t.selectionStyle)==null?void 0:Xt.selectedBorderColor)||e.cfg.colors.accent||"#fff":((Ue=t.selectionStyle)==null?void 0:Ue.borderColor)||e.cfg.colors.border}},E("span",{"aria-hidden":!0,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"18px",height:"18px",marginRight:"10px",border:`1px solid ${Rt?((te=t.selectionStyle)==null?void 0:te.selectedBorderColor)||e.cfg.colors.accent||"#fff":((mt=t.selectionStyle)==null?void 0:mt.borderColor)||e.cfg.colors.border}`,borderRadius:"5px",backgroundColor:Rt?((he=t.selectionStyle)==null?void 0:he.selectedBorderColor)||e.cfg.colors.accent||"#fff":"transparent",color:Rt?e.cfg.colors.background:"transparent",transition:"all 0.15s ease"}},Rt?e.renderIcon("check",12):null),kt)}return E("div",{key:`${n}-row-${ut}`,style:{display:"contents"},onClickCapture:()=>{e.rowContextRef&&(e.rowContextRef.current=Q)}},e.renderComponent(xe,ut,`${n}-item`))}return null};return x?Object.entries(j).map(([Q,ut],Ct)=>E("div",{key:`${n}-group-${Ct}`,style:{display:"flex",flexDirection:"column",gap:"6px"}},E("div",{key:`${n}-group-hdr-${Ct}`,style:{fontSize:"11px",fontWeight:600,letterSpacing:"0.05em",textTransform:"uppercase",color:e.cfg.colors.textMuted,padding:"10px 4px 2px"}},Q),ut.map(D))):X.map(D)})(),r&&(s==null?void 0:s.hasMore)&&E("div",{"data-bf-scroll-load":n,style:{height:"48px",width:"100%",display:"flex",alignItems:"center",justifyContent:"center",...h&&((s==null?void 0:s.page)??0)>0?{}:{pointerEvents:"none",opacity:.55}}},h&&((s==null?void 0:s.page)??0)>0?E("div",{style:{width:"18px",height:"18px",border:"2px solid rgba(128,128,128,0.25)",borderTopColor:e.cfg.colors.primary,borderRadius:"50%",animation:"bf-spin 0.7s linear infinite"}}):E("div",{style:{width:"18px",height:"2px",borderRadius:"2px",background:e.cfg.colors.textMuted,opacity:.4}})),i&&m.createElement("div",{className:"flex items-center justify-center gap-3 mt-4 py-2"},m.createElement("button",{onClick:()=>e.fetchListData(t.dataSource,n,s.page-1,s.limit),disabled:s.page===0||h,className:"flex items-center justify-center w-7 h-7 text-xs text-gray-400 hover:text-white hover:bg-[#222222] rounded border border-[#333333] disabled:opacity-30 disabled:cursor-not-allowed transition-all bg-transparent"},"◀"),E("span",{className:"text-xs text-gray-500"},`${s.page+1} / ${o}`),m.createElement("button",{onClick:()=>e.fetchListData(t.dataSource,n,s.page+1,s.limit),disabled:!s.hasMore||h,className:"flex items-center justify-center w-7 h-7 text-xs text-gray-400 hover:text-white hover:bg-[#222222] rounded border border-[#333333] disabled:opacity-30 disabled:cursor-not-allowed transition-all bg-transparent"},"▶")))}function mv({api:e,c:t,componentKey:n}){var H,U,q,X;const s=(H=e.paginationState)==null?void 0:H[n],i=t.pagination!==!1&&s&&s.total>s.limit,r=s?Math.ceil(s.total/s.limit):0,o=t.className||"w-full overflow-x-auto rounded-xl bg-gray-800/50 border border-gray-700/50",l=((U=e.parseClassNameResponsive)==null?void 0:U.call(e,o,n))??e.parseClassName(o);t.rawStyle&&Object.assign(l,t.rawStyle);const c=(q=e.loading)==null?void 0:q[n],h=(X=e.listData)==null?void 0:X[n],a=Array.isArray(h)?h:[],u=e.renderMode==="css-driven"?{"data-bf-r":`${e.scopeId}-${n}`}:{},f=!!t.sortable,p=t.sortMode==="client"?"client":"server",[g,d]=m.useState(null),[w,C]=m.useState({}),x=m.useMemo(()=>{if(!g||p!=="client")return a;const j=g.dir==="asc"?1:-1;return[...a].sort((D,V)=>{const J=D[g.key],nt=V[g.key];return J===nt?0:J==null?1:nt==null?-1:String(J).localeCompare(String(nt),void 0,{numeric:!0})*j})},[a,g,p]),k=j=>{if(!f&&!j.sortable)return;const D=j.field||j.key;let V=null;!g||g.key!==D?V={key:D,dir:"asc"}:g.dir==="asc"&&(V={key:D,dir:"desc"}),d(V),p==="server"&&V&&e.fetchListData(t.dataSource,n,0,(s==null?void 0:s.limit)||t.pageSize||10,V.key,V.dir)},S=(j,D)=>j.replace(/\{\{([\w.]+)(?:\s*\|\|\s*([^}]+))?\}\}/g,(V,J,nt)=>{const it=J.split(".").reduce((Q,ut)=>Q==null?void 0:Q[ut],D);return it==null||it===""?nt??"":String(it)}),T=async(j,D)=>{var nt;const V=w[j.id??""]||{},J=D.filter(it=>it.editable&&V[it.field||it.key]!==void 0);for(const it of J){const Q=it.field||it.key,ut=it.onCellChange||t.onSave;if(!ut)continue;const Ct=ut.replace(/\{\{field\}\}/g,JSON.stringify(V[Q]));if(Ct.startsWith("sdk:"))await e.handleButtonClick(S(Ct,j),{});else{const ft=S(Ct,j);await fetch(ft,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[Q]:V[Q]})})}}J.length&&((nt=e.showToast)==null||nt.call(e,(J.length===1,"Saved"),"success"),C(it=>{const Q={...it};return delete Q[j.id??""],Q}),e.fetchListData(t.dataSource,n,(s==null?void 0:s.page)||0,(s==null?void 0:s.limit)||t.pageSize||10))},P=(j,D,V)=>{const J=D.field||D.key,nt=j.id??"";C(it=>({...it,[nt]:{...it[nt]||{},[J]:V}}))},I=(j,D)=>{const V=j.field||j.key,J=D.id??"",nt=w[J]||{},it=nt[V]!==void 0?nt[V]:D[V],Q=j.fieldType||"text",ut={style:{width:"100%",background:"transparent",color:e.cfg.colors.text,border:`1px solid ${e.cfg.colors.border}`,borderRadius:"4px",padding:"2px 6px",fontSize:"13px",fontFamily:"inherit"}},Ct=()=>{j.onCellChange&&nt[j.key]!==void 0&&T(D,[j])};if(Q==="select"||Q==="dropdown")return E("select",{...ut,value:String(it??""),onChange:ft=>{P(D,j,ft.target.value),j.onCellChange&&T(D,[j])},children:(Array.isArray(j.fieldOptions)?j.fieldOptions:[]).map((ft,Dt)=>E("option",{key:Dt,value:ft.value,children:ft.label??ft.value}))});if(Q==="multiselect"){const ft=Array.isArray(it)?it:[];return E("div",{style:{display:"flex",flexDirection:"column",gap:2}},(Array.isArray(j.fieldOptions)?j.fieldOptions:[]).map((Dt,qt)=>{const ne=ft.includes(Dt.value);return E("label",{key:qt,style:{display:"flex",alignItems:"center",gap:4,fontSize:12}},E("input",{type:"checkbox",checked:ne,onChange:te=>{const mt=te.target.checked?[...ft,Dt.value]:ft.filter(he=>he!==Dt.value);P(D,j,mt),j.onCellChange&&T(D,[j])}}),E("span",{children:Dt.label??Dt.value}))}))}return Q==="image"?E("div",{style:{display:"flex",alignItems:"center",gap:6}},it?E("img",{src:String(it),alt:j.label,style:{width:32,height:32,borderRadius:4,objectFit:"cover"}}):null,E("input",{...ut,value:String(it??""),placeholder:j.fieldPlaceholder||"Image URL",onChange:ft=>P(D,j,ft.target.value),onBlur:Ct})):E("input",{...ut,type:Q==="number"?"number":"text",value:String(it??""),placeholder:j.fieldPlaceholder||"",onChange:ft=>P(D,j,Q==="number"?Number(ft.target.value):ft.target.value),onBlur:Ct})},L=j=>{const D=w[j.id??""];return!!D&&Object.keys(D).some(V=>{var J;return(J=t.columns)==null?void 0:J.some(nt=>nt.editable&&(nt.field||nt.key)===V)})},O=!!t.onSave;return m.createElement("div",{key:n,className:o,style:l,"data-component-key":n,...u},c&&(t.loadingComponent?e.renderComponent(t.loadingComponent,0,n):m.createElement("div",{className:"flex justify-center py-4"},E("div",{className:"w-6 h-6 border-2 border-primary border-t-transparent rounded-full animate-spin"}))),m.createElement("table",{className:"w-full"},Array.isArray(t.columns)&&m.createElement("thead",{className:"bg-gray-900/50"},m.createElement("tr",{},t.columns.map(j=>m.createElement("th",{key:j.key,className:"px-4 py-3 text-left text-sm font-medium text-gray-400"},(f||j.sortable)&&j.sortable!==!1?(()=>{const D=g&&g.key===j.key?g:null;return E("button",{type:"button",onClick:()=>k(j),style:{background:"none",border:"none",color:"inherit",fontFamily:"inherit",fontSize:"inherit",cursor:"pointer",padding:0},children:`${j.label||j.key}${D?D.dir==="asc"?" ↑":" ↓":" ⇅"}`})})():j.label||j.key)),O&&m.createElement("th",{key:"__save",className:"px-4 py-3 text-left text-sm font-medium text-gray-400"},""))),m.createElement("tbody",{className:"divide-y divide-gray-700/50"},x.map((j,D)=>{var V;return m.createElement("tr",{key:j.id??D,className:"hover:bg-gray-700/30 transition-colors"},(V=t.columns)==null?void 0:V.map(J=>m.createElement("td",{key:J.key,className:"px-4 py-3 text-sm text-white"},J.editable?I(J,j):J.template?S(J.template,j):(()=>{const it=(J.field||J.key).split(".").reduce((Q,ut)=>Q==null?void 0:Q[ut],j);return it==null||it===""?"":String(it)})())),O&&m.createElement("td",{key:"__save-cell",className:"px-4 py-3 text-sm"},E("button",{type:"button",disabled:!L(j)||c,onClick:()=>T(j,t.columns||[]),className:"px-3 py-1 rounded text-xs font-semibold border transition-all disabled:opacity-40 disabled:cursor-not-allowed",style:{background:L(j)?e.cfg.colors.primary:"transparent",color:L(j)?"#ffffff":e.cfg.colors.textSecondary,borderColor:e.cfg.colors.border},children:"Save"})))}))),i&&m.createElement("div",{className:"flex items-center justify-center gap-3 mt-4 py-2"},m.createElement("button",{onClick:()=>e.fetchListData(t.dataSource,n,s.page-1,s.limit),disabled:s.page===0||c,className:"flex items-center justify-center w-7 h-7 text-xs text-gray-400 hover:text-white hover:bg-[#222222] rounded border border-[#333333] disabled:opacity-30 disabled:cursor-not-allowed transition-all bg-transparent"},"◀"),E("span",{className:"text-xs text-gray-500"},`${s.page+1} / ${r}`),m.createElement("button",{onClick:()=>e.fetchListData(t.dataSource,n,s.page+1,s.limit),disabled:!s.hasMore||c,className:"flex items-center justify-center w-7 h-7 text-xs text-gray-400 hover:text-white hover:bg-[#222222] rounded border border-[#333333] disabled:opacity-30 disabled:cursor-not-allowed transition-all bg-transparent"},"▶")))}function pv(e,t,n){return m.createElement(mv,{api:e,c:t,componentKey:n})}function Nt(e){var t=e.width,n=e.height;if(t<0)throw new Error("Negative width is not allowed for Size");if(n<0)throw new Error("Negative height is not allowed for Size");return{width:t,height:n}}function Zn(e,t){return e.width===t.width&&e.height===t.height}var gv=function(){function e(t){var n=this;this._resolutionListener=function(){return n._onResolutionChanged()},this._resolutionMediaQueryList=null,this._observers=[],this._window=t,this._installResolutionListener()}return e.prototype.dispose=function(){this._uninstallResolutionListener(),this._window=null},Object.defineProperty(e.prototype,"value",{get:function(){return this._window.devicePixelRatio},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(t){var n=this,s={next:t};return this._observers.push(s),{unsubscribe:function(){n._observers=n._observers.filter(function(i){return i!==s})}}},e.prototype._installResolutionListener=function(){if(this._resolutionMediaQueryList!==null)throw new Error("Resolution listener is already installed");var t=this._window.devicePixelRatio;this._resolutionMediaQueryList=this._window.matchMedia("all and (resolution: ".concat(t,"dppx)")),this._resolutionMediaQueryList.addListener(this._resolutionListener)},e.prototype._uninstallResolutionListener=function(){this._resolutionMediaQueryList!==null&&(this._resolutionMediaQueryList.removeListener(this._resolutionListener),this._resolutionMediaQueryList=null)},e.prototype._reinstallResolutionListener=function(){this._uninstallResolutionListener(),this._installResolutionListener()},e.prototype._onResolutionChanged=function(){var t=this;this._observers.forEach(function(n){return n.next(t._window.devicePixelRatio)}),this._reinstallResolutionListener()},e}();function yv(e){return new gv(e)}var bv=function(){function e(t,n,s){var i;this._canvasElement=null,this._bitmapSizeChangedListeners=[],this._suggestedBitmapSize=null,this._suggestedBitmapSizeChangedListeners=[],this._devicePixelRatioObservable=null,this._canvasElementResizeObserver=null,this._canvasElement=t,this._canvasElementClientSize=Nt({width:this._canvasElement.clientWidth,height:this._canvasElement.clientHeight}),this._transformBitmapSize=n??function(r){return r},this._allowResizeObserver=(i=s==null?void 0:s.allowResizeObserver)!==null&&i!==void 0?i:!0,this._chooseAndInitObserver()}return e.prototype.dispose=function(){var t,n;if(this._canvasElement===null)throw new Error("Object is disposed");(t=this._canvasElementResizeObserver)===null||t===void 0||t.disconnect(),this._canvasElementResizeObserver=null,(n=this._devicePixelRatioObservable)===null||n===void 0||n.dispose(),this._devicePixelRatioObservable=null,this._suggestedBitmapSizeChangedListeners.length=0,this._bitmapSizeChangedListeners.length=0,this._canvasElement=null},Object.defineProperty(e.prototype,"canvasElement",{get:function(){if(this._canvasElement===null)throw new Error("Object is disposed");return this._canvasElement},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"canvasElementClientSize",{get:function(){return this._canvasElementClientSize},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bitmapSize",{get:function(){return Nt({width:this.canvasElement.width,height:this.canvasElement.height})},enumerable:!1,configurable:!0}),e.prototype.resizeCanvasElement=function(t){this._canvasElementClientSize=Nt(t),this.canvasElement.style.width="".concat(this._canvasElementClientSize.width,"px"),this.canvasElement.style.height="".concat(this._canvasElementClientSize.height,"px"),this._invalidateBitmapSize()},e.prototype.subscribeBitmapSizeChanged=function(t){this._bitmapSizeChangedListeners.push(t)},e.prototype.unsubscribeBitmapSizeChanged=function(t){this._bitmapSizeChangedListeners=this._bitmapSizeChangedListeners.filter(function(n){return n!==t})},Object.defineProperty(e.prototype,"suggestedBitmapSize",{get:function(){return this._suggestedBitmapSize},enumerable:!1,configurable:!0}),e.prototype.subscribeSuggestedBitmapSizeChanged=function(t){this._suggestedBitmapSizeChangedListeners.push(t)},e.prototype.unsubscribeSuggestedBitmapSizeChanged=function(t){this._suggestedBitmapSizeChangedListeners=this._suggestedBitmapSizeChangedListeners.filter(function(n){return n!==t})},e.prototype.applySuggestedBitmapSize=function(){if(this._suggestedBitmapSize!==null){var t=this._suggestedBitmapSize;this._suggestedBitmapSize=null,this._resizeBitmap(t),this._emitSuggestedBitmapSizeChanged(t,this._suggestedBitmapSize)}},e.prototype._resizeBitmap=function(t){var n=this.bitmapSize;Zn(n,t)||(this.canvasElement.width=t.width,this.canvasElement.height=t.height,this._emitBitmapSizeChanged(n,t))},e.prototype._emitBitmapSizeChanged=function(t,n){var s=this;this._bitmapSizeChangedListeners.forEach(function(i){return i.call(s,t,n)})},e.prototype._suggestNewBitmapSize=function(t){var n=this._suggestedBitmapSize,s=Nt(this._transformBitmapSize(t,this._canvasElementClientSize)),i=Zn(this.bitmapSize,s)?null:s;n===null&&i===null||n!==null&&i!==null&&Zn(n,i)||(this._suggestedBitmapSize=i,this._emitSuggestedBitmapSizeChanged(n,i))},e.prototype._emitSuggestedBitmapSizeChanged=function(t,n){var s=this;this._suggestedBitmapSizeChangedListeners.forEach(function(i){return i.call(s,t,n)})},e.prototype._chooseAndInitObserver=function(){var t=this;if(!this._allowResizeObserver){this._initDevicePixelRatioObservable();return}xv().then(function(n){return n?t._initResizeObserver():t._initDevicePixelRatioObservable()})},e.prototype._initDevicePixelRatioObservable=function(){var t=this;if(this._canvasElement!==null){var n=Ih(this._canvasElement);if(n===null)throw new Error("No window is associated with the canvas");this._devicePixelRatioObservable=yv(n),this._devicePixelRatioObservable.subscribe(function(){return t._invalidateBitmapSize()}),this._invalidateBitmapSize()}},e.prototype._invalidateBitmapSize=function(){var t,n;if(this._canvasElement!==null){var s=Ih(this._canvasElement);if(s!==null){var i=(n=(t=this._devicePixelRatioObservable)===null||t===void 0?void 0:t.value)!==null&&n!==void 0?n:s.devicePixelRatio,r=this._canvasElement.getClientRects(),o=r[0]!==void 0?wv(r[0],i):Nt({width:this._canvasElementClientSize.width*i,height:this._canvasElementClientSize.height*i});this._suggestNewBitmapSize(o)}}},e.prototype._initResizeObserver=function(){var t=this;this._canvasElement!==null&&(this._canvasElementResizeObserver=new ResizeObserver(function(n){var s=n.find(function(o){return o.target===t._canvasElement});if(!(!s||!s.devicePixelContentBoxSize||!s.devicePixelContentBoxSize[0])){var i=s.devicePixelContentBoxSize[0],r=Nt({width:i.inlineSize,height:i.blockSize});t._suggestNewBitmapSize(r)}}),this._canvasElementResizeObserver.observe(this._canvasElement,{box:"device-pixel-content-box"}))},e}();function vv(e,t){return new bv(e,t.transform,t.options)}function Ih(e){return e.ownerDocument.defaultView}function xv(){return new Promise(function(e){var t=new ResizeObserver(function(n){e(n.every(function(s){return"devicePixelContentBoxSize"in s})),t.disconnect()});t.observe(document.body,{box:"device-pixel-content-box"})}).catch(function(){return!1})}function wv(e,t){return Nt({width:Math.round(e.left*t+e.width*t)-Math.round(e.left*t),height:Math.round(e.top*t+e.height*t)-Math.round(e.top*t)})}var Sv=function(){function e(t,n,s){if(n.width===0||n.height===0)throw new TypeError("Rendering target could only be created on a media with positive width and height");if(this._mediaSize=n,s.width===0||s.height===0)throw new TypeError("Rendering target could only be created using a bitmap with positive integer width and height");this._bitmapSize=s,this._context=t}return e.prototype.useMediaCoordinateSpace=function(t){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),this._context.scale(this._horizontalPixelRatio,this._verticalPixelRatio),t({context:this._context,mediaSize:this._mediaSize})}finally{this._context.restore()}},e.prototype.useBitmapCoordinateSpace=function(t){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),t({context:this._context,mediaSize:this._mediaSize,bitmapSize:this._bitmapSize,horizontalPixelRatio:this._horizontalPixelRatio,verticalPixelRatio:this._verticalPixelRatio})}finally{this._context.restore()}},Object.defineProperty(e.prototype,"_horizontalPixelRatio",{get:function(){return this._bitmapSize.width/this._mediaSize.width},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_verticalPixelRatio",{get:function(){return this._bitmapSize.height/this._mediaSize.height},enumerable:!1,configurable:!0}),e}();function ts(e,t){var n=e.canvasElementClientSize;if(n.width===0||n.height===0)return null;var s=e.bitmapSize;if(s.width===0||s.height===0)return null;var i=e.canvasElement.getContext("2d",t);return i===null?null:new Sv(i,n,s)}/*!
10
+ `),()=>{document.head.removeChild(c)}},[t]),De.jsx(Pg,{isPresent:t,childRef:i,sizeRef:r,children:wc.cloneElement(e,{ref:i})})}const Lg=({children:e,initial:t,isPresent:n,onExitComplete:i,custom:r,presenceAffectsLayout:o,mode:l})=>{const h=Pc(Ag),u=v.useId(),f=v.useCallback(m=>{h.set(m,!0);for(const y of h.values())if(!y)return;i&&i()},[h,i]),c=v.useMemo(()=>({id:u,initial:t,isPresent:n,custom:r,onExitComplete:f,register:m=>(h.set(m,!1),()=>h.delete(m))}),o?[Math.random(),f]:[n,f]);return v.useMemo(()=>{h.forEach((m,y)=>h.set(y,!1))},[n]),wc.useEffect(()=>{!n&&!h.size&&i&&i()},[n]),l==="popLayout"&&(e=De.jsx(Eg,{isPresent:n,children:e})),De.jsx(Aa.Provider,{value:c,children:e})};function Ag(){return new Map}function pf(e=!0){const t=v.useContext(Aa);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:i,register:r}=t,o=v.useId();v.useEffect(()=>{e&&r(o)},[e]);const l=v.useCallback(()=>e&&i&&i(o),[o,i,e]);return!n&&i?[!1,l]:[!0]}const Wo=e=>e.key||"";function Ah(e){const t=[];return v.Children.forEach(e,n=>{v.isValidElement(n)&&t.push(n)}),t}const Lc=typeof window<"u",gf=Lc?v.useLayoutEffect:v.useEffect,Rg=({children:e,custom:t,initial:n=!0,onExitComplete:i,presenceAffectsLayout:r=!0,mode:o="sync",propagate:l=!1})=>{const[h,u]=pf(l),f=v.useMemo(()=>Ah(e),[e]),c=l&&!h?[]:f.map(Wo),m=v.useRef(!0),y=v.useRef(f),x=Pc(()=>new Map),[_,p]=v.useState(f),[E,T]=v.useState(f);gf(()=>{m.current=!1,y.current=f;for(let P=0;P<E.length;P++){const I=Wo(E[P]);c.includes(I)?x.delete(I):x.get(I)!==!0&&x.set(I,!1)}},[E,c.length,c.join("-")]);const k=[];if(f!==_){let P=[...f];for(let I=0;I<E.length;I++){const $=E[I],j=Wo($);c.includes(j)||(P.splice(I,0,$),k.push($))}o==="wait"&&k.length&&(P=k),T(Ah(P)),p(f);return}process.env.NODE_ENV!=="production"&&o==="wait"&&E.length>1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);const{forceRender:A}=v.useContext(Tc);return De.jsx(De.Fragment,{children:E.map(P=>{const I=Wo(P),$=l&&!h?!1:f===E||c.includes(I),j=()=>{if(x.has(I))x.set(I,!0);else return;let U=!0;x.forEach(nt=>{nt||(U=!1)}),U&&(A==null||A(),T(y.current),l&&(u==null||u()),i&&i())};return De.jsx(Lg,{isPresent:$,initial:!m.current||n?void 0:!1,custom:$?void 0:t,presenceAffectsLayout:r,mode:o,onExitComplete:$?void 0:j,children:P},I)})})},bn=e=>e;let kr=bn,as=bn;process.env.NODE_ENV!=="production"&&(kr=(e,t)=>{!e&&typeof console<"u"&&console.warn(t)},as=(e,t)=>{if(!e)throw new Error(t)});function Ac(e){let t;return()=>(t===void 0&&(t=e()),t)}const xr=(e,t,n)=>{const i=t-e;return i===0?1:(n-e)/i},ai=e=>e*1e3,Ai=e=>e/1e3,Ng={useManualTiming:!1};function Ig(e){let t=new Set,n=new Set,i=!1,r=!1;const o=new WeakSet;let l={delta:0,timestamp:0,isProcessing:!1};function h(f){o.has(f)&&(u.schedule(f),e()),f(l)}const u={schedule:(f,c=!1,m=!1)=>{const x=m&&i?t:n;return c&&o.add(f),x.has(f)||x.add(f),f},cancel:f=>{n.delete(f),o.delete(f)},process:f=>{if(l=f,i){r=!0;return}i=!0,[t,n]=[n,t],t.forEach(h),t.clear(),i=!1,r&&(r=!1,u.process(f))}};return u}const Vo=["read","resolveKeyframes","update","preRender","render","postRender"],zg=40;function yf(e,t){let n=!1,i=!0;const r={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,l=Vo.reduce((T,k)=>(T[k]=Ig(o),T),{}),{read:h,resolveKeyframes:u,update:f,preRender:c,render:m,postRender:y}=l,x=()=>{const T=performance.now();n=!1,r.delta=i?1e3/60:Math.max(Math.min(T-r.timestamp,zg),1),r.timestamp=T,r.isProcessing=!0,h.process(r),u.process(r),f.process(r),c.process(r),m.process(r),y.process(r),r.isProcessing=!1,n&&t&&(i=!1,e(x))},_=()=>{n=!0,i=!0,r.isProcessing||e(x)};return{schedule:Vo.reduce((T,k)=>{const A=l[k];return T[k]=(P,I=!1,$=!1)=>(n||_(),A.schedule(P,I,$)),T},{}),cancel:T=>{for(let k=0;k<Vo.length;k++)l[Vo[k]].cancel(T)},state:r,steps:l}}const{schedule:ge,cancel:ls,state:Xe,steps:sl}=yf(typeof requestAnimationFrame<"u"?requestAnimationFrame:bn,!0),vf=v.createContext({strict:!1}),Rh={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},_r={};for(const e in Rh)_r[e]={isEnabled:t=>Rh[e].some(n=>!!t[n])};function Dg(e){for(const t in e)_r[t]={..._r[t],...e[t]}}const $g=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function ga(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||$g.has(e)}let bf=e=>!ga(e);function Bg(e){e&&(bf=t=>t.startsWith("on")?!ga(t):e(t))}try{Bg(require("@emotion/is-prop-valid").default)}catch{}function Og(e,t,n){const i={};for(const r in e)r==="values"&&typeof e.values=="object"||(bf(r)||n===!0&&ga(r)||!t&&!ga(r)||e.draggable&&r.startsWith("onDrag"))&&(i[r]=e[r]);return i}const Nh=new Set;function Ra(e,t,n){e||Nh.has(t)||(console.warn(t),Nh.add(t))}function Fg(e){if(typeof Proxy>"u")return e;const t=new Map,n=(...i)=>(process.env.NODE_ENV!=="production"&&Ra(!1,"motion() is deprecated. Use motion.create() instead."),e(...i));return new Proxy(n,{get:(i,r)=>r==="create"?e:(t.has(r)||t.set(r,e(r)),t.get(r))})}const Na=v.createContext({});function fo(e){return typeof e=="string"||Array.isArray(e)}function Ia(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}const Rc=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Nc=["initial",...Rc];function za(e){return Ia(e.animate)||Nc.some(t=>fo(e[t]))}function xf(e){return!!(za(e)||e.variants)}function Wg(e,t){if(za(e)){const{initial:n,animate:i}=e;return{initial:n===!1||fo(n)?n:void 0,animate:fo(i)?i:void 0}}return e.inherit!==!1?t:{}}function Vg(e){const{initial:t,animate:n}=Wg(e,v.useContext(Na));return v.useMemo(()=>({initial:t,animate:n}),[Ih(t),Ih(n)])}function Ih(e){return Array.isArray(e)?e.join(" "):e}const jg=Symbol.for("motionComponentSymbol");function cr(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function Hg(e,t,n){return v.useCallback(i=>{i&&e.onMount&&e.onMount(i),t&&(i?t.mount(i):t.unmount()),n&&(typeof n=="function"?n(i):cr(n)&&(n.current=i))},[t])}const Ic=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),Zg="framerAppearId",_f="data-"+Ic(Zg),{schedule:zc}=yf(queueMicrotask,!1),wf=v.createContext({});function Ug(e,t,n,i,r){var o,l;const{visualElement:h}=v.useContext(Na),u=v.useContext(vf),f=v.useContext(Aa),c=v.useContext(Ec).reducedMotion,m=v.useRef(null);i=i||u.renderer,!m.current&&i&&(m.current=i(e,{visualState:t,parent:h,props:n,presenceContext:f,blockInitialAnimation:f?f.initial===!1:!1,reducedMotionConfig:c}));const y=m.current,x=v.useContext(wf);y&&!y.projection&&r&&(y.type==="html"||y.type==="svg")&&qg(m.current,n,r,x);const _=v.useRef(!1);v.useInsertionEffect(()=>{y&&_.current&&y.update(n,f)});const p=n[_f],E=v.useRef(!!p&&!(!((o=window.MotionHandoffIsComplete)===null||o===void 0)&&o.call(window,p))&&((l=window.MotionHasOptimisedAnimation)===null||l===void 0?void 0:l.call(window,p)));return gf(()=>{y&&(_.current=!0,window.MotionIsMounted=!0,y.updateFeatures(),zc.render(y.render),E.current&&y.animationState&&y.animationState.animateChanges())}),v.useEffect(()=>{y&&(!E.current&&y.animationState&&y.animationState.animateChanges(),E.current&&(queueMicrotask(()=>{var T;(T=window.MotionHandoffMarkAsComplete)===null||T===void 0||T.call(window,p)}),E.current=!1))}),y}function qg(e,t,n,i){const{layoutId:r,layout:o,drag:l,dragConstraints:h,layoutScroll:u,layoutRoot:f}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:Sf(e.parent)),e.projection.setOptions({layoutId:r,layout:o,alwaysMeasureLayout:!!l||h&&cr(h),visualElement:e,animationType:typeof o=="string"?o:"both",initialPromotionConfig:i,layoutScroll:u,layoutRoot:f})}function Sf(e){if(e)return e.options.allowProjection!==!1?e.projection:Sf(e.parent)}function Gg({preloadedFeatures:e,createVisualElement:t,useRender:n,useVisualState:i,Component:r}){var o,l;e&&Dg(e);function h(f,c){let m;const y={...v.useContext(Ec),...f,layoutId:Yg(f)},{isStatic:x}=y,_=Vg(f),p=i(f,x);if(!x&&Lc){Xg(y,e);const E=Jg(y);m=E.MeasureLayout,_.visualElement=Ug(r,p,y,t,E.ProjectionNode)}return De.jsxs(Na.Provider,{value:_,children:[m&&_.visualElement?De.jsx(m,{visualElement:_.visualElement,...y}):null,n(r,f,Hg(p,_.visualElement,c),p,x,_.visualElement)]})}h.displayName=`motion.${typeof r=="string"?r:`create(${(l=(o=r.displayName)!==null&&o!==void 0?o:r.name)!==null&&l!==void 0?l:""})`}`;const u=v.forwardRef(h);return u[jg]=r,u}function Yg({layoutId:e}){const t=v.useContext(Tc).id;return t&&e!==void 0?t+"-"+e:e}function Xg(e,t){const n=v.useContext(vf).strict;if(process.env.NODE_ENV!=="production"&&t&&n){const i="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";e.ignoreStrict?kr(!1,i):as(!1,i)}}function Jg(e){const{drag:t,layout:n}=_r;if(!t&&!n)return{};const i={...t,...n};return{MeasureLayout:t!=null&&t.isEnabled(e)||n!=null&&n.isEnabled(e)?i.MeasureLayout:void 0,ProjectionNode:i.ProjectionNode}}const Qg=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function Dc(e){return typeof e!="string"||e.includes("-")?!1:!!(Qg.indexOf(e)>-1||/[A-Z]/u.test(e))}function zh(e){const t=[{},{}];return e==null||e.values.forEach((n,i)=>{t[0][i]=n.get(),t[1][i]=n.getVelocity()}),t}function $c(e,t,n,i){if(typeof t=="function"){const[r,o]=zh(i);t=t(n!==void 0?n:e.custom,r,o)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[r,o]=zh(i);t=t(n!==void 0?n:e.custom,r,o)}return t}const Hl=e=>Array.isArray(e),Kg=e=>!!(e&&typeof e=="object"&&e.mix&&e.toValue),ty=e=>Hl(e)?e[e.length-1]||0:e,sn=e=>!!(e&&e.getVelocity);function aa(e){const t=sn(e)?e.get():e;return Kg(t)?t.toValue():t}function ey({scrapeMotionValuesFromProps:e,createRenderState:t,onUpdate:n},i,r,o){const l={latestValues:ny(i,r,o,e),renderState:t()};return n&&(l.onMount=h=>n({props:i,current:h,...l}),l.onUpdate=h=>n(h)),l}const Cf=e=>(t,n)=>{const i=v.useContext(Na),r=v.useContext(Aa),o=()=>ey(e,t,i,r);return n?o():Pc(o)};function ny(e,t,n,i){const r={},o=i(e,{});for(const y in o)r[y]=aa(o[y]);let{initial:l,animate:h}=e;const u=za(e),f=xf(e);t&&f&&!u&&e.inherit!==!1&&(l===void 0&&(l=t.initial),h===void 0&&(h=t.animate));let c=n?n.initial===!1:!1;c=c||l===!1;const m=c?h:l;if(m&&typeof m!="boolean"&&!Ia(m)){const y=Array.isArray(m)?m:[m];for(let x=0;x<y.length;x++){const _=$c(e,y[x]);if(_){const{transitionEnd:p,transition:E,...T}=_;for(const k in T){let A=T[k];if(Array.isArray(A)){const P=c?A.length-1:0;A=A[P]}A!==null&&(r[k]=A)}for(const k in p)r[k]=p[k]}}}return r}const Tr=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Fs=new Set(Tr),Mf=e=>t=>typeof t=="string"&&t.startsWith(e),kf=Mf("--"),iy=Mf("var(--"),Bc=e=>iy(e)?sy.test(e.split("/*")[0].trim()):!1,sy=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,Tf=(e,t)=>t&&typeof e=="number"?t.transform(e):e,Ri=(e,t,n)=>n>t?t:n<e?e:n,Pr={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},mo={...Pr,transform:e=>Ri(0,1,e)},jo={...Pr,default:1},_o=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),ns=_o("deg"),li=_o("%"),At=_o("px"),ry=_o("vh"),oy=_o("vw"),Dh={...li,parse:e=>li.parse(e)/100,transform:e=>li.transform(e*100)},ay={borderWidth:At,borderTopWidth:At,borderRightWidth:At,borderBottomWidth:At,borderLeftWidth:At,borderRadius:At,radius:At,borderTopLeftRadius:At,borderTopRightRadius:At,borderBottomRightRadius:At,borderBottomLeftRadius:At,width:At,maxWidth:At,height:At,maxHeight:At,top:At,right:At,bottom:At,left:At,padding:At,paddingTop:At,paddingRight:At,paddingBottom:At,paddingLeft:At,margin:At,marginTop:At,marginRight:At,marginBottom:At,marginLeft:At,backgroundPositionX:At,backgroundPositionY:At},ly={rotate:ns,rotateX:ns,rotateY:ns,rotateZ:ns,scale:jo,scaleX:jo,scaleY:jo,scaleZ:jo,skew:ns,skewX:ns,skewY:ns,distance:At,translateX:At,translateY:At,translateZ:At,x:At,y:At,z:At,perspective:At,transformPerspective:At,opacity:mo,originX:Dh,originY:Dh,originZ:At},$h={...Pr,transform:Math.round},Oc={...ay,...ly,zIndex:$h,size:At,fillOpacity:mo,strokeOpacity:mo,numOctaves:$h},cy={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},hy=Tr.length;function uy(e,t,n){let i="",r=!0;for(let o=0;o<hy;o++){const l=Tr[o],h=e[l];if(h===void 0)continue;let u=!0;if(typeof h=="number"?u=h===(l.startsWith("scale")?1:0):u=parseFloat(h)===0,!u||n){const f=Tf(h,Oc[l]);if(!u){r=!1;const c=cy[l]||l;i+=`${c}(${f}) `}n&&(t[l]=f)}}return i=i.trim(),n?i=n(t,r?"":i):r&&(i="none"),i}function Fc(e,t,n){const{style:i,vars:r,transformOrigin:o}=e;let l=!1,h=!1;for(const u in t){const f=t[u];if(Fs.has(u)){l=!0;continue}else if(kf(u)){r[u]=f;continue}else{const c=Tf(f,Oc[u]);u.startsWith("origin")?(h=!0,o[u]=c):i[u]=c}}if(t.transform||(l||n?i.transform=uy(t,e.transform,n):i.transform&&(i.transform="none")),h){const{originX:u="50%",originY:f="50%",originZ:c=0}=o;i.transformOrigin=`${u} ${f} ${c}`}}const dy={offset:"stroke-dashoffset",array:"stroke-dasharray"},fy={offset:"strokeDashoffset",array:"strokeDasharray"};function my(e,t,n=1,i=0,r=!0){e.pathLength=1;const o=r?dy:fy;e[o.offset]=At.transform(-i);const l=At.transform(t),h=At.transform(n);e[o.array]=`${l} ${h}`}function Bh(e,t,n){return typeof e=="string"?e:At.transform(t+n*e)}function py(e,t,n){const i=Bh(t,e.x,e.width),r=Bh(n,e.y,e.height);return`${i} ${r}`}function Wc(e,{attrX:t,attrY:n,attrScale:i,originX:r,originY:o,pathLength:l,pathSpacing:h=1,pathOffset:u=0,...f},c,m){if(Fc(e,f,m),c){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:y,style:x,dimensions:_}=e;y.transform&&(_&&(x.transform=y.transform),delete y.transform),_&&(r!==void 0||o!==void 0||x.transform)&&(x.transformOrigin=py(_,r!==void 0?r:.5,o!==void 0?o:.5)),t!==void 0&&(y.x=t),n!==void 0&&(y.y=n),i!==void 0&&(y.scale=i),l!==void 0&&my(y,l,h,u,!1)}const Vc=()=>({style:{},transform:{},transformOrigin:{},vars:{}}),Pf=()=>({...Vc(),attrs:{}}),jc=e=>typeof e=="string"&&e.toLowerCase()==="svg";function Ef(e,{style:t,vars:n},i,r){Object.assign(e.style,t,r&&r.getProjectionStyles(i));for(const o in n)e.style.setProperty(o,n[o])}const Lf=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function Af(e,t,n,i){Ef(e,t,void 0,i);for(const r in t.attrs)e.setAttribute(Lf.has(r)?r:Ic(r),t.attrs[r])}const ya={};function gy(e){Object.assign(ya,e)}function Rf(e,{layout:t,layoutId:n}){return Fs.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!ya[e]||e==="opacity")}function Hc(e,t,n){var i;const{style:r}=e,o={};for(const l in r)(sn(r[l])||t.style&&sn(t.style[l])||Rf(l,e)||((i=n==null?void 0:n.getValue(l))===null||i===void 0?void 0:i.liveStyle)!==void 0)&&(o[l]=r[l]);return o}function Nf(e,t,n){const i=Hc(e,t,n);for(const r in e)if(sn(e[r])||sn(t[r])){const o=Tr.indexOf(r)!==-1?"attr"+r.charAt(0).toUpperCase()+r.substring(1):r;i[o]=e[r]}return i}function yy(e,t){try{t.dimensions=typeof e.getBBox=="function"?e.getBBox():e.getBoundingClientRect()}catch{t.dimensions={x:0,y:0,width:0,height:0}}}const Oh=["x","y","width","height","cx","cy","r"],vy={useVisualState:Cf({scrapeMotionValuesFromProps:Nf,createRenderState:Pf,onUpdate:({props:e,prevProps:t,current:n,renderState:i,latestValues:r})=>{if(!n)return;let o=!!e.drag;if(!o){for(const h in r)if(Fs.has(h)){o=!0;break}}if(!o)return;let l=!t;if(t)for(let h=0;h<Oh.length;h++){const u=Oh[h];e[u]!==t[u]&&(l=!0)}l&&ge.read(()=>{yy(n,i),ge.render(()=>{Wc(i,r,jc(n.tagName),e.transformTemplate),Af(n,i)})})}})},by={useVisualState:Cf({scrapeMotionValuesFromProps:Hc,createRenderState:Vc})};function If(e,t,n){for(const i in t)!sn(t[i])&&!Rf(i,n)&&(e[i]=t[i])}function xy({transformTemplate:e},t){return v.useMemo(()=>{const n=Vc();return Fc(n,t,e),Object.assign({},n.vars,n.style)},[t])}function _y(e,t){const n=e.style||{},i={};return If(i,n,e),Object.assign(i,xy(e,t)),i}function wy(e,t){const n={},i=_y(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,i.userSelect=i.WebkitUserSelect=i.WebkitTouchCallout="none",i.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=i,n}function Sy(e,t,n,i){const r=v.useMemo(()=>{const o=Pf();return Wc(o,t,jc(i),e.transformTemplate),{...o.attrs,style:{...o.style}}},[t]);if(e.style){const o={};If(o,e.style,e),r.style={...o,...r.style}}return r}function Cy(e=!1){return(n,i,r,{latestValues:o},l)=>{const u=(Dc(n)?Sy:wy)(i,o,l,n),f=Og(i,typeof n=="string",e),c=n!==v.Fragment?{...f,...u,ref:r}:{},{children:m}=i,y=v.useMemo(()=>sn(m)?m.get():m,[m]);return v.createElement(n,{...c,children:y})}}function My(e,t){return function(i,{forwardMotionProps:r}={forwardMotionProps:!1}){const l={...Dc(i)?vy:by,preloadedFeatures:e,useRender:Cy(r),createVisualElement:t,Component:i};return Gg(l)}}function zf(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let i=0;i<n;i++)if(t[i]!==e[i])return!1;return!0}function Da(e,t,n){const i=e.getProps();return $c(i,t,n!==void 0?n:i.custom,e)}const ky=Ac(()=>window.ScrollTimeline!==void 0);class Ty{constructor(t){this.stop=()=>this.runAll("stop"),this.animations=t.filter(Boolean)}get finished(){return Promise.all(this.animations.map(t=>"finished"in t?t.finished:t))}getAll(t){return this.animations[0][t]}setAll(t,n){for(let i=0;i<this.animations.length;i++)this.animations[i][t]=n}attachTimeline(t,n){const i=this.animations.map(r=>{if(ky()&&r.attachTimeline)return r.attachTimeline(t);if(typeof n=="function")return n(r)});return()=>{i.forEach((r,o)=>{r&&r(),this.animations[o].stop()})}}get time(){return this.getAll("time")}set time(t){this.setAll("time",t)}get speed(){return this.getAll("speed")}set speed(t){this.setAll("speed",t)}get startTime(){return this.getAll("startTime")}get duration(){let t=0;for(let n=0;n<this.animations.length;n++)t=Math.max(t,this.animations[n].duration);return t}runAll(t){this.animations.forEach(n=>n[t]())}flatten(){this.runAll("flatten")}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}class Py extends Ty{then(t,n){return Promise.all(this.animations).then(t).catch(n)}}function Zc(e,t){return e?e[t]||e.default||e:void 0}const Zl=2e4;function Df(e){let t=0;const n=50;let i=e.next(t);for(;!i.done&&t<Zl;)t+=n,i=e.next(t);return t>=Zl?1/0:t}function Uc(e){return typeof e=="function"}function Fh(e,t){e.timeline=t,e.onfinish=null}const qc=e=>Array.isArray(e)&&typeof e[0]=="number",Ey={linearEasing:void 0};function Ly(e,t){const n=Ac(e);return()=>{var i;return(i=Ey[t])!==null&&i!==void 0?i:n()}}const va=Ly(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),$f=(e,t,n=10)=>{let i="";const r=Math.max(Math.round(t/n),2);for(let o=0;o<r;o++)i+=e(xr(0,r-1,o))+", ";return`linear(${i.substring(0,i.length-2)})`};function Bf(e){return!!(typeof e=="function"&&va()||!e||typeof e=="string"&&(e in Ul||va())||qc(e)||Array.isArray(e)&&e.every(Bf))}const Xr=([e,t,n,i])=>`cubic-bezier(${e}, ${t}, ${n}, ${i})`,Ul={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Xr([0,.65,.55,1]),circOut:Xr([.55,0,1,.45]),backIn:Xr([.31,.01,.66,-.59]),backOut:Xr([.33,1.53,.69,.99])};function Of(e,t){if(e)return typeof e=="function"&&va()?$f(e,t):qc(e)?Xr(e):Array.isArray(e)?e.map(n=>Of(n,t)||Ul.easeOut):Ul[e]}const Xn={x:!1,y:!1};function Ff(){return Xn.x||Xn.y}function Ay(e,t,n){var i;if(e instanceof Element)return[e];if(typeof e=="string"){let r=document;const o=(i=void 0)!==null&&i!==void 0?i:r.querySelectorAll(e);return o?Array.from(o):[]}return Array.from(e)}function Wf(e,t){const n=Ay(e),i=new AbortController,r={passive:!0,...t,signal:i.signal};return[n,r,()=>i.abort()]}function Wh(e){return t=>{t.pointerType==="touch"||Ff()||e(t)}}function Ry(e,t,n={}){const[i,r,o]=Wf(e,n),l=Wh(h=>{const{target:u}=h,f=t(h);if(typeof f!="function"||!u)return;const c=Wh(m=>{f(m),u.removeEventListener("pointerleave",c)});u.addEventListener("pointerleave",c,r)});return i.forEach(h=>{h.addEventListener("pointerenter",l,r)}),o}const Vf=(e,t)=>t?e===t?!0:Vf(e,t.parentElement):!1,Gc=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,Ny=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Iy(e){return Ny.has(e.tagName)||e.tabIndex!==-1}const Jr=new WeakSet;function Vh(e){return t=>{t.key==="Enter"&&e(t)}}function rl(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const zy=(e,t)=>{const n=e.currentTarget;if(!n)return;const i=Vh(()=>{if(Jr.has(n))return;rl(n,"down");const r=Vh(()=>{rl(n,"up")}),o=()=>rl(n,"cancel");n.addEventListener("keyup",r,t),n.addEventListener("blur",o,t)});n.addEventListener("keydown",i,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",i),t)};function jh(e){return Gc(e)&&!Ff()}function Dy(e,t,n={}){const[i,r,o]=Wf(e,n),l=h=>{const u=h.currentTarget;if(!jh(h)||Jr.has(u))return;Jr.add(u);const f=t(h),c=(x,_)=>{window.removeEventListener("pointerup",m),window.removeEventListener("pointercancel",y),!(!jh(x)||!Jr.has(u))&&(Jr.delete(u),typeof f=="function"&&f(x,{success:_}))},m=x=>{c(x,n.useGlobalTarget||Vf(u,x.target))},y=x=>{c(x,!1)};window.addEventListener("pointerup",m,r),window.addEventListener("pointercancel",y,r)};return i.forEach(h=>{!Iy(h)&&h.getAttribute("tabindex")===null&&(h.tabIndex=0),(n.useGlobalTarget?window:h).addEventListener("pointerdown",l,r),h.addEventListener("focus",f=>zy(f,r),r)}),o}function $y(e){return e==="x"||e==="y"?Xn[e]?null:(Xn[e]=!0,()=>{Xn[e]=!1}):Xn.x||Xn.y?null:(Xn.x=Xn.y=!0,()=>{Xn.x=Xn.y=!1})}const jf=new Set(["width","height","top","left","right","bottom",...Tr]);let la;function By(){la=void 0}const ci={now:()=>(la===void 0&&ci.set(Xe.isProcessing||Ng.useManualTiming?Xe.timestamp:performance.now()),la),set:e=>{la=e,queueMicrotask(By)}};function Yc(e,t){e.indexOf(t)===-1&&e.push(t)}function Xc(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}class Jc{constructor(){this.subscriptions=[]}add(t){return Yc(this.subscriptions,t),()=>Xc(this.subscriptions,t)}notify(t,n,i){const r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](t,n,i);else for(let o=0;o<r;o++){const l=this.subscriptions[o];l&&l(t,n,i)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}function Hf(e,t){return t?e*(1e3/t):0}const Hh=30,Oy=e=>!isNaN(parseFloat(e));class Fy{constructor(t,n={}){this.version="11.18.2",this.canTrackVelocity=null,this.events={},this.updateAndNotify=(i,r=!0)=>{const o=ci.now();this.updatedAt!==o&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(i),this.current!==this.prev&&this.events.change&&this.events.change.notify(this.current),r&&this.events.renderRequest&&this.events.renderRequest.notify(this.current)},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=ci.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=Oy(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return process.env.NODE_ENV!=="production"&&Ra(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new Jc);const i=this.events[t].add(n);return t==="change"?()=>{i(),ge.read(()=>{this.events.change.getSize()||this.stop()})}:i}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t,n=!0){!n||!this.passiveEffect?this.updateAndNotify(t,n):this.passiveEffect(t,this.updateAndNotify)}setWithVelocity(t,n,i){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-i}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=ci.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>Hh)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Hh);return Hf(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function po(e,t){return new Fy(e,t)}function Wy(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,po(n))}function Vy(e,t){const n=Da(e,t);let{transitionEnd:i={},transition:r={},...o}=n||{};o={...o,...i};for(const l in o){const h=ty(o[l]);Wy(e,l,h)}}function jy(e){return!!(sn(e)&&e.add)}function ql(e,t){const n=e.getValue("willChange");if(jy(n))return n.add(t)}function Zf(e){return e.props[_f]}const Uf=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,Hy=1e-7,Zy=12;function Uy(e,t,n,i,r){let o,l,h=0;do l=t+(n-t)/2,o=Uf(l,i,r)-e,o>0?n=l:t=l;while(Math.abs(o)>Hy&&++h<Zy);return l}function wo(e,t,n,i){if(e===t&&n===i)return bn;const r=o=>Uy(o,0,1,e,n);return o=>o===0||o===1?o:Uf(r(o),t,i)}const qf=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Gf=e=>t=>1-e(1-t),Yf=wo(.33,1.53,.69,.99),Qc=Gf(Yf),Xf=qf(Qc),Jf=e=>(e*=2)<1?.5*Qc(e):.5*(2-Math.pow(2,-10*(e-1))),Kc=e=>1-Math.sin(Math.acos(e)),Qf=Gf(Kc),Kf=qf(Kc),tm=e=>/^0[^.\s]+$/u.test(e);function qy(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||tm(e):!0}const no=e=>Math.round(e*1e5)/1e5,th=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Gy(e){return e==null}const Yy=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,eh=(e,t)=>n=>!!(typeof n=="string"&&Yy.test(n)&&n.startsWith(e)||t&&!Gy(n)&&Object.prototype.hasOwnProperty.call(n,t)),em=(e,t,n)=>i=>{if(typeof i!="string")return i;const[r,o,l,h]=i.match(th);return{[e]:parseFloat(r),[t]:parseFloat(o),[n]:parseFloat(l),alpha:h!==void 0?parseFloat(h):1}},Xy=e=>Ri(0,255,e),ol={...Pr,transform:e=>Math.round(Xy(e))},Rs={test:eh("rgb","red"),parse:em("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:i=1})=>"rgba("+ol.transform(e)+", "+ol.transform(t)+", "+ol.transform(n)+", "+no(mo.transform(i))+")"};function Jy(e){let t="",n="",i="",r="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),i=e.substring(5,7),r=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),i=e.substring(3,4),r=e.substring(4,5),t+=t,n+=n,i+=i,r+=r),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(i,16),alpha:r?parseInt(r,16)/255:1}}const Gl={test:eh("#"),parse:Jy,transform:Rs.transform},hr={test:eh("hsl","hue"),parse:em("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:i=1})=>"hsla("+Math.round(e)+", "+li.transform(no(t))+", "+li.transform(no(n))+", "+no(mo.transform(i))+")"},nn={test:e=>Rs.test(e)||Gl.test(e)||hr.test(e),parse:e=>Rs.test(e)?Rs.parse(e):hr.test(e)?hr.parse(e):Gl.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Rs.transform(e):hr.transform(e)},Qy=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Ky(e){var t,n;return isNaN(e)&&typeof e=="string"&&(((t=e.match(th))===null||t===void 0?void 0:t.length)||0)+(((n=e.match(Qy))===null||n===void 0?void 0:n.length)||0)>0}const nm="number",im="color",t0="var",e0="var(",Zh="${}",n0=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function go(e){const t=e.toString(),n=[],i={color:[],number:[],var:[]},r=[];let o=0;const h=t.replace(n0,u=>(nn.test(u)?(i.color.push(o),r.push(im),n.push(nn.parse(u))):u.startsWith(e0)?(i.var.push(o),r.push(t0),n.push(u)):(i.number.push(o),r.push(nm),n.push(parseFloat(u))),++o,Zh)).split(Zh);return{values:n,split:h,indexes:i,types:r}}function sm(e){return go(e).values}function rm(e){const{split:t,types:n}=go(e),i=t.length;return r=>{let o="";for(let l=0;l<i;l++)if(o+=t[l],r[l]!==void 0){const h=n[l];h===nm?o+=no(r[l]):h===im?o+=nn.transform(r[l]):o+=r[l]}return o}}const i0=e=>typeof e=="number"?0:e;function s0(e){const t=sm(e);return rm(e)(t.map(i0))}const cs={test:Ky,parse:sm,createTransformer:rm,getAnimatableNone:s0},r0=new Set(["brightness","contrast","saturate","opacity"]);function o0(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[i]=n.match(th)||[];if(!i)return e;const r=n.replace(i,"");let o=r0.has(t)?1:0;return i!==n&&(o*=100),t+"("+o+r+")"}const a0=/\b([a-z-]*)\(.*?\)/gu,Yl={...cs,getAnimatableNone:e=>{const t=e.match(a0);return t?t.map(o0).join(" "):e}},l0={...Oc,color:nn,backgroundColor:nn,outlineColor:nn,fill:nn,stroke:nn,borderColor:nn,borderTopColor:nn,borderRightColor:nn,borderBottomColor:nn,borderLeftColor:nn,filter:Yl,WebkitFilter:Yl},nh=e=>l0[e];function om(e,t){let n=nh(e);return n!==Yl&&(n=cs),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const c0=new Set(["auto","none","0"]);function h0(e,t,n){let i=0,r;for(;i<e.length&&!r;){const o=e[i];typeof o=="string"&&!c0.has(o)&&go(o).values.length&&(r=e[i]),i++}if(r&&n)for(const o of t)e[o]=om(n,r)}const Uh=e=>e===Pr||e===At,qh=(e,t)=>parseFloat(e.split(", ")[t]),Gh=(e,t)=>(n,{transform:i})=>{if(i==="none"||!i)return 0;const r=i.match(/^matrix3d\((.+)\)$/u);if(r)return qh(r[1],t);{const o=i.match(/^matrix\((.+)\)$/u);return o?qh(o[1],e):0}},u0=new Set(["x","y","z"]),d0=Tr.filter(e=>!u0.has(e));function f0(e){const t=[];return d0.forEach(n=>{const i=e.getValue(n);i!==void 0&&(t.push([n,i.get()]),i.set(n.startsWith("scale")?1:0))}),t}const wr={width:({x:e},{paddingLeft:t="0",paddingRight:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),height:({y:e},{paddingTop:t="0",paddingBottom:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:Gh(4,13),y:Gh(5,14)};wr.translateX=wr.x;wr.translateY=wr.y;const Ns=new Set;let Xl=!1,Jl=!1;function am(){if(Jl){const e=Array.from(Ns).filter(i=>i.needsMeasurement),t=new Set(e.map(i=>i.element)),n=new Map;t.forEach(i=>{const r=f0(i);r.length&&(n.set(i,r),i.render())}),e.forEach(i=>i.measureInitialState()),t.forEach(i=>{i.render();const r=n.get(i);r&&r.forEach(([o,l])=>{var h;(h=i.getValue(o))===null||h===void 0||h.set(l)})}),e.forEach(i=>i.measureEndState()),e.forEach(i=>{i.suspendedScrollY!==void 0&&window.scrollTo(0,i.suspendedScrollY)})}Jl=!1,Xl=!1,Ns.forEach(e=>e.complete()),Ns.clear()}function lm(){Ns.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Jl=!0)})}function m0(){lm(),am()}class ih{constructor(t,n,i,r,o,l=!1){this.isComplete=!1,this.isAsync=!1,this.needsMeasurement=!1,this.isScheduled=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=i,this.motionValue=r,this.element=o,this.isAsync=l}scheduleResolve(){this.isScheduled=!0,this.isAsync?(Ns.add(this),Xl||(Xl=!0,ge.read(lm),ge.resolveKeyframes(am))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:i,motionValue:r}=this;for(let o=0;o<t.length;o++)if(t[o]===null)if(o===0){const l=r==null?void 0:r.get(),h=t[t.length-1];if(l!==void 0)t[0]=l;else if(i&&n){const u=i.readValue(n,h);u!=null&&(t[0]=u)}t[0]===void 0&&(t[0]=h),r&&l===void 0&&r.set(t[0])}else t[o]=t[o-1]}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(){this.isComplete=!0,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe),Ns.delete(this)}cancel(){this.isComplete||(this.isScheduled=!1,Ns.delete(this))}resume(){this.isComplete||this.scheduleResolve()}}const cm=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),p0=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function g0(e){const t=p0.exec(e);if(!t)return[,];const[,n,i,r]=t;return[`--${n??i}`,r]}const y0=4;function hm(e,t,n=1){as(n<=y0,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`);const[i,r]=g0(e);if(!i)return;const o=window.getComputedStyle(t).getPropertyValue(i);if(o){const l=o.trim();return cm(l)?parseFloat(l):l}return Bc(r)?hm(r,t,n+1):r}const um=e=>t=>t.test(e),v0={test:e=>e==="auto",parse:e=>e},dm=[Pr,At,li,ns,oy,ry,v0],Yh=e=>dm.find(um(e));class fm extends ih{constructor(t,n,i,r,o){super(t,n,i,r,o,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:i}=this;if(!n||!n.current)return;super.readKeyframes();for(let u=0;u<t.length;u++){let f=t[u];if(typeof f=="string"&&(f=f.trim(),Bc(f))){const c=hm(f,n.current);c!==void 0&&(t[u]=c),u===t.length-1&&(this.finalKeyframe=f)}}if(this.resolveNoneKeyframes(),!jf.has(i)||t.length!==2)return;const[r,o]=t,l=Yh(r),h=Yh(o);if(l!==h)if(Uh(l)&&Uh(h))for(let u=0;u<t.length;u++){const f=t[u];typeof f=="string"&&(t[u]=parseFloat(f))}else this.needsMeasurement=!0}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,i=[];for(let r=0;r<t.length;r++)qy(t[r])&&i.push(r);i.length&&h0(t,i,n)}measureInitialState(){const{element:t,unresolvedKeyframes:n,name:i}=this;if(!t||!t.current)return;i==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=wr[i](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const r=n[n.length-1];r!==void 0&&t.getValue(i,r).jump(r,!1)}measureEndState(){var t;const{element:n,name:i,unresolvedKeyframes:r}=this;if(!n||!n.current)return;const o=n.getValue(i);o&&o.jump(this.measuredOrigin,!1);const l=r.length-1,h=r[l];r[l]=wr[i](n.measureViewportBox(),window.getComputedStyle(n.current)),h!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=h),!((t=this.removedTransforms)===null||t===void 0)&&t.length&&this.removedTransforms.forEach(([u,f])=>{n.getValue(u).set(f)}),this.resolveNoneKeyframes()}}const Xh=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(cs.test(e)||e==="0")&&!e.startsWith("url("));function b0(e){const t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function x0(e,t,n,i){const r=e[0];if(r===null)return!1;if(t==="display"||t==="visibility")return!0;const o=e[e.length-1],l=Xh(r,t),h=Xh(o,t);return kr(l===h,`You are trying to animate ${t} from "${r}" to "${o}". ${r} is not an animatable value - to enable this animation set ${r} to a value animatable to ${o} via the \`style\` property.`),!l||!h?!1:b0(e)||(n==="spring"||Uc(n))&&i}const _0=e=>e!==null;function $a(e,{repeat:t,repeatType:n="loop"},i){const r=e.filter(_0),o=t&&n!=="loop"&&t%2===1?0:r.length-1;return!o||i===void 0?r[o]:i}const w0=40;class mm{constructor({autoplay:t=!0,delay:n=0,type:i="keyframes",repeat:r=0,repeatDelay:o=0,repeatType:l="loop",...h}){this.isStopped=!1,this.hasAttemptedResolve=!1,this.createdAt=ci.now(),this.options={autoplay:t,delay:n,type:i,repeat:r,repeatDelay:o,repeatType:l,...h},this.updateFinishedPromise()}calcStartTime(){return this.resolvedAt?this.resolvedAt-this.createdAt>w0?this.resolvedAt:this.createdAt:this.createdAt}get resolved(){return!this._resolved&&!this.hasAttemptedResolve&&m0(),this._resolved}onKeyframesResolved(t,n){this.resolvedAt=ci.now(),this.hasAttemptedResolve=!0;const{name:i,type:r,velocity:o,delay:l,onComplete:h,onUpdate:u,isGenerator:f}=this.options;if(!f&&!x0(t,i,r,o))if(l)this.options.duration=0;else{u&&u($a(t,this.options,n)),h&&h(),this.resolveFinishedPromise();return}const c=this.initPlayback(t,n);c!==!1&&(this._resolved={keyframes:t,finalKeyframe:n,...c},this.onPostResolved())}onPostResolved(){}then(t,n){return this.currentFinishedPromise.then(t,n)}flatten(){this.options.type="keyframes",this.options.ease="linear"}updateFinishedPromise(){this.currentFinishedPromise=new Promise(t=>{this.resolveFinishedPromise=t})}}const Te=(e,t,n)=>e+(t-e)*n;function al(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function S0({hue:e,saturation:t,lightness:n,alpha:i}){e/=360,t/=100,n/=100;let r=0,o=0,l=0;if(!t)r=o=l=n;else{const h=n<.5?n*(1+t):n+t-n*t,u=2*n-h;r=al(u,h,e+1/3),o=al(u,h,e),l=al(u,h,e-1/3)}return{red:Math.round(r*255),green:Math.round(o*255),blue:Math.round(l*255),alpha:i}}function ba(e,t){return n=>n>0?t:e}const ll=(e,t,n)=>{const i=e*e,r=n*(t*t-i)+i;return r<0?0:Math.sqrt(r)},C0=[Gl,Rs,hr],M0=e=>C0.find(t=>t.test(e));function Jh(e){const t=M0(e);if(kr(!!t,`'${e}' is not an animatable color. Use the equivalent color code instead.`),!t)return!1;let n=t.parse(e);return t===hr&&(n=S0(n)),n}const Qh=(e,t)=>{const n=Jh(e),i=Jh(t);if(!n||!i)return ba(e,t);const r={...n};return o=>(r.red=ll(n.red,i.red,o),r.green=ll(n.green,i.green,o),r.blue=ll(n.blue,i.blue,o),r.alpha=Te(n.alpha,i.alpha,o),Rs.transform(r))},k0=(e,t)=>n=>t(e(n)),So=(...e)=>e.reduce(k0),Ql=new Set(["none","hidden"]);function T0(e,t){return Ql.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function P0(e,t){return n=>Te(e,t,n)}function sh(e){return typeof e=="number"?P0:typeof e=="string"?Bc(e)?ba:nn.test(e)?Qh:A0:Array.isArray(e)?pm:typeof e=="object"?nn.test(e)?Qh:E0:ba}function pm(e,t){const n=[...e],i=n.length,r=e.map((o,l)=>sh(o)(o,t[l]));return o=>{for(let l=0;l<i;l++)n[l]=r[l](o);return n}}function E0(e,t){const n={...e,...t},i={};for(const r in n)e[r]!==void 0&&t[r]!==void 0&&(i[r]=sh(e[r])(e[r],t[r]));return r=>{for(const o in i)n[o]=i[o](r);return n}}function L0(e,t){var n;const i=[],r={color:0,var:0,number:0};for(let o=0;o<t.values.length;o++){const l=t.types[o],h=e.indexes[l][r[l]],u=(n=e.values[h])!==null&&n!==void 0?n:0;i[o]=u,r[l]++}return i}const A0=(e,t)=>{const n=cs.createTransformer(t),i=go(e),r=go(t);return i.indexes.var.length===r.indexes.var.length&&i.indexes.color.length===r.indexes.color.length&&i.indexes.number.length>=r.indexes.number.length?Ql.has(e)&&!r.values.length||Ql.has(t)&&!i.values.length?T0(e,t):So(pm(L0(i,r),r.values),n):(kr(!0,`Complex values '${e}' and '${t}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`),ba(e,t))};function gm(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?Te(e,t,n):sh(e)(e,t)}const R0=5;function ym(e,t,n){const i=Math.max(t-R0,0);return Hf(n-e(i),t-i)}const ke={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},cl=.001;function N0({duration:e=ke.duration,bounce:t=ke.bounce,velocity:n=ke.velocity,mass:i=ke.mass}){let r,o;kr(e<=ai(ke.maxDuration),"Spring duration must be 10 seconds or less");let l=1-t;l=Ri(ke.minDamping,ke.maxDamping,l),e=Ri(ke.minDuration,ke.maxDuration,Ai(e)),l<1?(r=f=>{const c=f*l,m=c*e,y=c-n,x=Kl(f,l),_=Math.exp(-m);return cl-y/x*_},o=f=>{const m=f*l*e,y=m*n+n,x=Math.pow(l,2)*Math.pow(f,2)*e,_=Math.exp(-m),p=Kl(Math.pow(f,2),l);return(-r(f)+cl>0?-1:1)*((y-x)*_)/p}):(r=f=>{const c=Math.exp(-f*e),m=(f-n)*e+1;return-cl+c*m},o=f=>{const c=Math.exp(-f*e),m=(n-f)*(e*e);return c*m});const h=5/e,u=z0(r,o,h);if(e=ai(e),isNaN(u))return{stiffness:ke.stiffness,damping:ke.damping,duration:e};{const f=Math.pow(u,2)*i;return{stiffness:f,damping:l*2*Math.sqrt(i*f),duration:e}}}const I0=12;function z0(e,t,n){let i=n;for(let r=1;r<I0;r++)i=i-e(i)/t(i);return i}function Kl(e,t){return e*Math.sqrt(1-t*t)}const D0=["duration","bounce"],$0=["stiffness","damping","mass"];function Kh(e,t){return t.some(n=>e[n]!==void 0)}function B0(e){let t={velocity:ke.velocity,stiffness:ke.stiffness,damping:ke.damping,mass:ke.mass,isResolvedFromDuration:!1,...e};if(!Kh(e,$0)&&Kh(e,D0))if(e.visualDuration){const n=e.visualDuration,i=2*Math.PI/(n*1.2),r=i*i,o=2*Ri(.05,1,1-(e.bounce||0))*Math.sqrt(r);t={...t,mass:ke.mass,stiffness:r,damping:o}}else{const n=N0(e);t={...t,...n,mass:ke.mass},t.isResolvedFromDuration=!0}return t}function vm(e=ke.visualDuration,t=ke.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:i,restDelta:r}=n;const o=n.keyframes[0],l=n.keyframes[n.keyframes.length-1],h={done:!1,value:o},{stiffness:u,damping:f,mass:c,duration:m,velocity:y,isResolvedFromDuration:x}=B0({...n,velocity:-Ai(n.velocity||0)}),_=y||0,p=f/(2*Math.sqrt(u*c)),E=l-o,T=Ai(Math.sqrt(u/c)),k=Math.abs(E)<5;i||(i=k?ke.restSpeed.granular:ke.restSpeed.default),r||(r=k?ke.restDelta.granular:ke.restDelta.default);let A;if(p<1){const I=Kl(T,p);A=$=>{const j=Math.exp(-p*T*$);return l-j*((_+p*T*E)/I*Math.sin(I*$)+E*Math.cos(I*$))}}else if(p===1)A=I=>l-Math.exp(-T*I)*(E+(_+T*E)*I);else{const I=T*Math.sqrt(p*p-1);A=$=>{const j=Math.exp(-p*T*$),U=Math.min(I*$,300);return l-j*((_+p*T*E)*Math.sinh(U)+I*E*Math.cosh(U))/I}}const P={calculatedDuration:x&&m||null,next:I=>{const $=A(I);if(x)h.done=I>=m;else{let j=0;p<1&&(j=I===0?ai(_):ym(A,I,$));const U=Math.abs(j)<=i,nt=Math.abs(l-$)<=r;h.done=U&&nt}return h.value=h.done?l:$,h},toString:()=>{const I=Math.min(Df(P),Zl),$=$f(j=>P.next(I*j).value,I,30);return I+"ms "+$}};return P}function tu({keyframes:e,velocity:t=0,power:n=.8,timeConstant:i=325,bounceDamping:r=10,bounceStiffness:o=500,modifyTarget:l,min:h,max:u,restDelta:f=.5,restSpeed:c}){const m=e[0],y={done:!1,value:m},x=U=>h!==void 0&&U<h||u!==void 0&&U>u,_=U=>h===void 0?u:u===void 0||Math.abs(h-U)<Math.abs(u-U)?h:u;let p=n*t;const E=m+p,T=l===void 0?E:l(E);T!==E&&(p=T-m);const k=U=>-p*Math.exp(-U/i),A=U=>T+k(U),P=U=>{const nt=k(U),ot=A(U);y.done=Math.abs(nt)<=f,y.value=y.done?T:ot};let I,$;const j=U=>{x(y.value)&&(I=U,$=vm({keyframes:[y.value,_(y.value)],velocity:ym(A,U,y.value),damping:r,stiffness:o,restDelta:f,restSpeed:c}))};return j(0),{calculatedDuration:null,next:U=>{let nt=!1;return!$&&I===void 0&&(nt=!0,P(U),j(U)),I!==void 0&&U>=I?$.next(U-I):(!nt&&P(U),y)}}}const O0=wo(.42,0,1,1),F0=wo(0,0,.58,1),bm=wo(.42,0,.58,1),W0=e=>Array.isArray(e)&&typeof e[0]!="number",eu={linear:bn,easeIn:O0,easeInOut:bm,easeOut:F0,circIn:Kc,circInOut:Kf,circOut:Qf,backIn:Qc,backInOut:Xf,backOut:Yf,anticipate:Jf},nu=e=>{if(qc(e)){as(e.length===4,"Cubic bezier arrays must contain four numerical values.");const[t,n,i,r]=e;return wo(t,n,i,r)}else if(typeof e=="string")return as(eu[e]!==void 0,`Invalid easing type '${e}'`),eu[e];return e};function V0(e,t,n){const i=[],r=n||gm,o=e.length-1;for(let l=0;l<o;l++){let h=r(e[l],e[l+1]);if(t){const u=Array.isArray(t)?t[l]||bn:t;h=So(u,h)}i.push(h)}return i}function j0(e,t,{clamp:n=!0,ease:i,mixer:r}={}){const o=e.length;if(as(o===t.length,"Both input and output ranges must be the same length"),o===1)return()=>t[0];if(o===2&&t[0]===t[1])return()=>t[1];const l=e[0]===e[1];e[0]>e[o-1]&&(e=[...e].reverse(),t=[...t].reverse());const h=V0(t,i,r),u=h.length,f=c=>{if(l&&c<e[0])return t[0];let m=0;if(u>1)for(;m<e.length-2&&!(c<e[m+1]);m++);const y=xr(e[m],e[m+1],c);return h[m](y)};return n?c=>f(Ri(e[0],e[o-1],c)):f}function H0(e,t){const n=e[e.length-1];for(let i=1;i<=t;i++){const r=xr(0,t,i);e.push(Te(n,1,r))}}function Z0(e){const t=[0];return H0(t,e.length-1),t}function U0(e,t){return e.map(n=>n*t)}function q0(e,t){return e.map(()=>t||bm).splice(0,e.length-1)}function xa({duration:e=300,keyframes:t,times:n,ease:i="easeInOut"}){const r=W0(i)?i.map(nu):nu(i),o={done:!1,value:t[0]},l=U0(n&&n.length===t.length?n:Z0(t),e),h=j0(l,t,{ease:Array.isArray(r)?r:q0(t,r)});return{calculatedDuration:e,next:u=>(o.value=h(u),o.done=u>=e,o)}}const G0=e=>{const t=({timestamp:n})=>e(n);return{start:()=>ge.update(t,!0),stop:()=>ls(t),now:()=>Xe.isProcessing?Xe.timestamp:ci.now()}},Y0={decay:tu,inertia:tu,tween:xa,keyframes:xa,spring:vm},X0=e=>e/100;class rh extends mm{constructor(t){super(t),this.holdTime=null,this.cancelTime=null,this.currentTime=0,this.playbackSpeed=1,this.pendingPlayState="running",this.startTime=null,this.state="idle",this.stop=()=>{if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.teardown();const{onStop:u}=this.options;u&&u()};const{name:n,motionValue:i,element:r,keyframes:o}=this.options,l=(r==null?void 0:r.KeyframeResolver)||ih,h=(u,f)=>this.onKeyframesResolved(u,f);this.resolver=new l(o,h,n,i,r),this.resolver.scheduleResolve()}flatten(){super.flatten(),this._resolved&&Object.assign(this._resolved,this.initPlayback(this._resolved.keyframes))}initPlayback(t){const{type:n="keyframes",repeat:i=0,repeatDelay:r=0,repeatType:o,velocity:l=0}=this.options,h=Uc(n)?n:Y0[n]||xa;let u,f;h!==xa&&typeof t[0]!="number"&&(process.env.NODE_ENV!=="production"&&as(t.length===2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${t}`),u=So(X0,gm(t[0],t[1])),t=[0,100]);const c=h({...this.options,keyframes:t});o==="mirror"&&(f=h({...this.options,keyframes:[...t].reverse(),velocity:-l})),c.calculatedDuration===null&&(c.calculatedDuration=Df(c));const{calculatedDuration:m}=c,y=m+r,x=y*(i+1)-r;return{generator:c,mirroredGenerator:f,mapPercentToKeyframes:u,calculatedDuration:m,resolvedDuration:y,totalDuration:x}}onPostResolved(){const{autoplay:t=!0}=this.options;this.play(),this.pendingPlayState==="paused"||!t?this.pause():this.state=this.pendingPlayState}tick(t,n=!1){const{resolved:i}=this;if(!i){const{keyframes:U}=this.options;return{done:!0,value:U[U.length-1]}}const{finalKeyframe:r,generator:o,mirroredGenerator:l,mapPercentToKeyframes:h,keyframes:u,calculatedDuration:f,totalDuration:c,resolvedDuration:m}=i;if(this.startTime===null)return o.next(0);const{delay:y,repeat:x,repeatType:_,repeatDelay:p,onUpdate:E}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-c/this.speed,this.startTime)),n?this.currentTime=t:this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=Math.round(t-this.startTime)*this.speed;const T=this.currentTime-y*(this.speed>=0?1:-1),k=this.speed>=0?T<0:T>c;this.currentTime=Math.max(T,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=c);let A=this.currentTime,P=o;if(x){const U=Math.min(this.currentTime,c)/m;let nt=Math.floor(U),ot=U%1;!ot&&U>=1&&(ot=1),ot===1&&nt--,nt=Math.min(nt,x+1),!!(nt%2)&&(_==="reverse"?(ot=1-ot,p&&(ot-=p/m)):_==="mirror"&&(P=l)),A=Ri(0,1,ot)*m}const I=k?{done:!1,value:u[0]}:P.next(A);h&&(I.value=h(I.value));let{done:$}=I;!k&&f!==null&&($=this.speed>=0?this.currentTime>=c:this.currentTime<=0);const j=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&$);return j&&r!==void 0&&(I.value=$a(u,this.options,r)),E&&E(I.value),j&&this.finish(),I}get duration(){const{resolved:t}=this;return t?Ai(t.calculatedDuration):0}get time(){return Ai(this.currentTime)}set time(t){t=ai(t),this.currentTime=t,this.holdTime!==null||this.speed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.speed)}get speed(){return this.playbackSpeed}set speed(t){const n=this.playbackSpeed!==t;this.playbackSpeed=t,n&&(this.time=Ai(this.currentTime))}play(){if(this.resolver.isScheduled||this.resolver.resume(),!this._resolved){this.pendingPlayState="running";return}if(this.isStopped)return;const{driver:t=G0,onPlay:n,startTime:i}=this.options;this.driver||(this.driver=t(o=>this.tick(o))),n&&n();const r=this.driver.now();this.holdTime!==null?this.startTime=r-this.holdTime:this.startTime?this.state==="finished"&&(this.startTime=r):this.startTime=i??this.calcStartTime(),this.state==="finished"&&this.updateFinishedPromise(),this.cancelTime=this.startTime,this.holdTime=null,this.state="running",this.driver.start()}pause(){var t;if(!this._resolved){this.pendingPlayState="paused";return}this.state="paused",this.holdTime=(t=this.currentTime)!==null&&t!==void 0?t:0}complete(){this.state!=="running"&&this.play(),this.pendingPlayState=this.state="finished",this.holdTime=null}finish(){this.teardown(),this.state="finished";const{onComplete:t}=this.options;t&&t()}cancel(){this.cancelTime!==null&&this.tick(this.cancelTime),this.teardown(),this.updateFinishedPromise()}teardown(){this.state="idle",this.stopDriver(),this.resolveFinishedPromise(),this.updateFinishedPromise(),this.startTime=this.cancelTime=null,this.resolver.cancel()}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}}const J0=new Set(["opacity","clipPath","filter","transform"]);function Q0(e,t,n,{delay:i=0,duration:r=300,repeat:o=0,repeatType:l="loop",ease:h="easeInOut",times:u}={}){const f={[t]:n};u&&(f.offset=u);const c=Of(h,r);return Array.isArray(c)&&(f.easing=c),e.animate(f,{delay:i,duration:r,easing:Array.isArray(c)?"linear":c,fill:"both",iterations:o+1,direction:l==="reverse"?"alternate":"normal"})}const K0=Ac(()=>Object.hasOwnProperty.call(Element.prototype,"animate")),_a=10,tv=2e4;function ev(e){return Uc(e.type)||e.type==="spring"||!Bf(e.ease)}function nv(e,t){const n=new rh({...t,keyframes:e,repeat:0,delay:0,isGenerator:!0});let i={done:!1,value:e[0]};const r=[];let o=0;for(;!i.done&&o<tv;)i=n.sample(o),r.push(i.value),o+=_a;return{times:void 0,keyframes:r,duration:o-_a,ease:"linear"}}const xm={anticipate:Jf,backInOut:Xf,circInOut:Kf};function iv(e){return e in xm}class iu extends mm{constructor(t){super(t);const{name:n,motionValue:i,element:r,keyframes:o}=this.options;this.resolver=new fm(o,(l,h)=>this.onKeyframesResolved(l,h),n,i,r),this.resolver.scheduleResolve()}initPlayback(t,n){let{duration:i=300,times:r,ease:o,type:l,motionValue:h,name:u,startTime:f}=this.options;if(!h.owner||!h.owner.current)return!1;if(typeof o=="string"&&va()&&iv(o)&&(o=xm[o]),ev(this.options)){const{onComplete:m,onUpdate:y,motionValue:x,element:_,...p}=this.options,E=nv(t,p);t=E.keyframes,t.length===1&&(t[1]=t[0]),i=E.duration,r=E.times,o=E.ease,l="keyframes"}const c=Q0(h.owner.current,u,t,{...this.options,duration:i,times:r,ease:o});return c.startTime=f??this.calcStartTime(),this.pendingTimeline?(Fh(c,this.pendingTimeline),this.pendingTimeline=void 0):c.onfinish=()=>{const{onComplete:m}=this.options;h.set($a(t,this.options,n)),m&&m(),this.cancel(),this.resolveFinishedPromise()},{animation:c,duration:i,times:r,type:l,ease:o,keyframes:t}}get duration(){const{resolved:t}=this;if(!t)return 0;const{duration:n}=t;return Ai(n)}get time(){const{resolved:t}=this;if(!t)return 0;const{animation:n}=t;return Ai(n.currentTime||0)}set time(t){const{resolved:n}=this;if(!n)return;const{animation:i}=n;i.currentTime=ai(t)}get speed(){const{resolved:t}=this;if(!t)return 1;const{animation:n}=t;return n.playbackRate}set speed(t){const{resolved:n}=this;if(!n)return;const{animation:i}=n;i.playbackRate=t}get state(){const{resolved:t}=this;if(!t)return"idle";const{animation:n}=t;return n.playState}get startTime(){const{resolved:t}=this;if(!t)return null;const{animation:n}=t;return n.startTime}attachTimeline(t){if(!this._resolved)this.pendingTimeline=t;else{const{resolved:n}=this;if(!n)return bn;const{animation:i}=n;Fh(i,t)}return bn}play(){if(this.isStopped)return;const{resolved:t}=this;if(!t)return;const{animation:n}=t;n.playState==="finished"&&this.updateFinishedPromise(),n.play()}pause(){const{resolved:t}=this;if(!t)return;const{animation:n}=t;n.pause()}stop(){if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.resolveFinishedPromise(),this.updateFinishedPromise();const{resolved:t}=this;if(!t)return;const{animation:n,keyframes:i,duration:r,type:o,ease:l,times:h}=t;if(n.playState==="idle"||n.playState==="finished")return;if(this.time){const{motionValue:f,onUpdate:c,onComplete:m,element:y,...x}=this.options,_=new rh({...x,keyframes:i,duration:r,type:o,ease:l,times:h,isGenerator:!0}),p=ai(this.time);f.setWithVelocity(_.sample(p-_a).value,_.sample(p).value,_a)}const{onStop:u}=this.options;u&&u(),this.cancel()}complete(){const{resolved:t}=this;t&&t.animation.finish()}cancel(){const{resolved:t}=this;t&&t.animation.cancel()}static supports(t){const{motionValue:n,name:i,repeatDelay:r,repeatType:o,damping:l,type:h}=t;if(!n||!n.owner||!(n.owner.current instanceof HTMLElement))return!1;const{onUpdate:u,transformTemplate:f}=n.owner.getProps();return K0()&&i&&J0.has(i)&&!u&&!f&&!r&&o!=="mirror"&&l!==0&&h!=="inertia"}}const sv={type:"spring",stiffness:500,damping:25,restSpeed:10},rv=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),ov={type:"keyframes",duration:.8},av={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},lv=(e,{keyframes:t})=>t.length>2?ov:Fs.has(e)?e.startsWith("scale")?rv(t[1]):sv:av;function cv({when:e,delay:t,delayChildren:n,staggerChildren:i,staggerDirection:r,repeat:o,repeatType:l,repeatDelay:h,from:u,elapsed:f,...c}){return!!Object.keys(c).length}const oh=(e,t,n,i={},r,o)=>l=>{const h=Zc(i,e)||{},u=h.delay||i.delay||0;let{elapsed:f=0}=i;f=f-ai(u);let c={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...h,delay:-f,onUpdate:y=>{t.set(y),h.onUpdate&&h.onUpdate(y)},onComplete:()=>{l(),h.onComplete&&h.onComplete()},name:e,motionValue:t,element:o?void 0:r};cv(h)||(c={...c,...lv(e,c)}),c.duration&&(c.duration=ai(c.duration)),c.repeatDelay&&(c.repeatDelay=ai(c.repeatDelay)),c.from!==void 0&&(c.keyframes[0]=c.from);let m=!1;if((c.type===!1||c.duration===0&&!c.repeatDelay)&&(c.duration=0,c.delay===0&&(m=!0)),m&&!o&&t.get()!==void 0){const y=$a(c.keyframes,h);if(y!==void 0)return ge.update(()=>{c.onUpdate(y),c.onComplete()}),new Py([])}return!o&&iu.supports(c)?new iu(c):new rh(c)};function hv({protectedKeys:e,needsAnimating:t},n){const i=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,i}function _m(e,t,{delay:n=0,transitionOverride:i,type:r}={}){var o;let{transition:l=e.getDefaultTransition(),transitionEnd:h,...u}=t;i&&(l=i);const f=[],c=r&&e.animationState&&e.animationState.getState()[r];for(const m in u){const y=e.getValue(m,(o=e.latestValues[m])!==null&&o!==void 0?o:null),x=u[m];if(x===void 0||c&&hv(c,m))continue;const _={delay:n,...Zc(l||{},m)};let p=!1;if(window.MotionHandoffAnimation){const T=Zf(e);if(T){const k=window.MotionHandoffAnimation(T,m,ge);k!==null&&(_.startTime=k,p=!0)}}ql(e,m),y.start(oh(m,y,x,e.shouldReduceMotion&&jf.has(m)?{type:!1}:_,e,p));const E=y.animation;E&&f.push(E)}return h&&Promise.all(f).then(()=>{ge.update(()=>{h&&Vy(e,h)})}),f}function tc(e,t,n={}){var i;const r=Da(e,t,n.type==="exit"?(i=e.presenceContext)===null||i===void 0?void 0:i.custom:void 0);let{transition:o=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(o=n.transitionOverride);const l=r?()=>Promise.all(_m(e,r,n)):()=>Promise.resolve(),h=e.variantChildren&&e.variantChildren.size?(f=0)=>{const{delayChildren:c=0,staggerChildren:m,staggerDirection:y}=o;return uv(e,t,c+f,m,y,n)}:()=>Promise.resolve(),{when:u}=o;if(u){const[f,c]=u==="beforeChildren"?[l,h]:[h,l];return f().then(()=>c())}else return Promise.all([l(),h(n.delay)])}function uv(e,t,n=0,i=0,r=1,o){const l=[],h=(e.variantChildren.size-1)*i,u=r===1?(f=0)=>f*i:(f=0)=>h-f*i;return Array.from(e.variantChildren).sort(dv).forEach((f,c)=>{f.notify("AnimationStart",t),l.push(tc(f,t,{...o,delay:n+u(c)}).then(()=>f.notify("AnimationComplete",t)))}),Promise.all(l)}function dv(e,t){return e.sortNodePosition(t)}function fv(e,t,n={}){e.notify("AnimationStart",t);let i;if(Array.isArray(t)){const r=t.map(o=>tc(e,o,n));i=Promise.all(r)}else if(typeof t=="string")i=tc(e,t,n);else{const r=typeof t=="function"?Da(e,t,n.custom):t;i=Promise.all(_m(e,r,n))}return i.then(()=>{e.notify("AnimationComplete",t)})}const mv=Nc.length;function wm(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?wm(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<mv;n++){const i=Nc[n],r=e.props[i];(fo(r)||r===!1)&&(t[i]=r)}return t}const pv=[...Rc].reverse(),gv=Rc.length;function yv(e){return t=>Promise.all(t.map(({animation:n,options:i})=>fv(e,n,i)))}function vv(e){let t=yv(e),n=su(),i=!0;const r=u=>(f,c)=>{var m;const y=Da(e,c,u==="exit"?(m=e.presenceContext)===null||m===void 0?void 0:m.custom:void 0);if(y){const{transition:x,transitionEnd:_,...p}=y;f={...f,...p,..._}}return f};function o(u){t=u(e)}function l(u){const{props:f}=e,c=wm(e.parent)||{},m=[],y=new Set;let x={},_=1/0;for(let E=0;E<gv;E++){const T=pv[E],k=n[T],A=f[T]!==void 0?f[T]:c[T],P=fo(A),I=T===u?k.isActive:null;I===!1&&(_=E);let $=A===c[T]&&A!==f[T]&&P;if($&&i&&e.manuallyAnimateOnMount&&($=!1),k.protectedKeys={...x},!k.isActive&&I===null||!A&&!k.prevProp||Ia(A)||typeof A=="boolean")continue;const j=bv(k.prevProp,A);let U=j||T===u&&k.isActive&&!$&&P||E>_&&P,nt=!1;const ot=Array.isArray(A)?A:[A];let q=ot.reduce(r(T),{});I===!1&&(q={});const{prevResolvedValues:it={}}=k,ct={...it,...q},K=st=>{U=!0,y.has(st)&&(nt=!0,y.delete(st)),k.needsAnimating[st]=!0;const J=e.getValue(st);J&&(J.liveStyle=!1)};for(const st in ct){const J=q[st],bt=it[st];if(x.hasOwnProperty(st))continue;let et=!1;Hl(J)&&Hl(bt)?et=!zf(J,bt):et=J!==bt,et?J!=null?K(st):y.add(st):J!==void 0&&y.has(st)?K(st):k.protectedKeys[st]=!0}k.prevProp=A,k.prevResolvedValues=q,k.isActive&&(x={...x,...q}),i&&e.blockInitialAnimation&&(U=!1),U&&(!($&&j)||nt)&&m.push(...ot.map(st=>({animation:st,options:{type:T}})))}if(y.size){const E={};y.forEach(T=>{const k=e.getBaseTarget(T),A=e.getValue(T);A&&(A.liveStyle=!0),E[T]=k??null}),m.push({animation:E})}let p=!!m.length;return i&&(f.initial===!1||f.initial===f.animate)&&!e.manuallyAnimateOnMount&&(p=!1),i=!1,p?t(m):Promise.resolve()}function h(u,f){var c;if(n[u].isActive===f)return Promise.resolve();(c=e.variantChildren)===null||c===void 0||c.forEach(y=>{var x;return(x=y.animationState)===null||x===void 0?void 0:x.setActive(u,f)}),n[u].isActive=f;const m=l(u);for(const y in n)n[y].protectedKeys={};return m}return{animateChanges:l,setActive:h,setAnimateFunction:o,getState:()=>n,reset:()=>{n=su(),i=!0}}}function bv(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!zf(t,e):!1}function Ts(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function su(){return{animate:Ts(!0),whileInView:Ts(),whileHover:Ts(),whileTap:Ts(),whileDrag:Ts(),whileFocus:Ts(),exit:Ts()}}class us{constructor(t){this.isMounted=!1,this.node=t}update(){}}class xv extends us{constructor(t){super(t),t.animationState||(t.animationState=vv(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();Ia(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)===null||t===void 0||t.call(this)}}let _v=0;class wv extends us{constructor(){super(...arguments),this.id=_v++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:i}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===i)return;const r=this.node.animationState.setActive("exit",!t);n&&!t&&r.then(()=>n(this.id))}mount(){const{register:t}=this.node.presenceContext||{};t&&(this.unmount=t(this.id))}unmount(){}}const Sv={animation:{Feature:xv},exit:{Feature:wv}};function yo(e,t,n,i={passive:!0}){return e.addEventListener(t,n,i),()=>e.removeEventListener(t,n)}function Co(e){return{point:{x:e.pageX,y:e.pageY}}}const Cv=e=>t=>Gc(t)&&e(t,Co(t));function io(e,t,n,i){return yo(e,t,Cv(n),i)}const ru=(e,t)=>Math.abs(e-t);function Mv(e,t){const n=ru(e.x,t.x),i=ru(e.y,t.y);return Math.sqrt(n**2+i**2)}class Sm{constructor(t,n,{transformPagePoint:i,contextWindow:r,dragSnapToOrigin:o=!1}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const m=ul(this.lastMoveEventInfo,this.history),y=this.startEvent!==null,x=Mv(m.offset,{x:0,y:0})>=3;if(!y&&!x)return;const{point:_}=m,{timestamp:p}=Xe;this.history.push({..._,timestamp:p});const{onStart:E,onMove:T}=this.handlers;y||(E&&E(this.lastMoveEvent,m),this.startEvent=this.lastMoveEvent),T&&T(this.lastMoveEvent,m)},this.handlePointerMove=(m,y)=>{this.lastMoveEvent=m,this.lastMoveEventInfo=hl(y,this.transformPagePoint),ge.update(this.updatePoint,!0)},this.handlePointerUp=(m,y)=>{this.end();const{onEnd:x,onSessionEnd:_,resumeAnimation:p}=this.handlers;if(this.dragSnapToOrigin&&p&&p(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const E=ul(m.type==="pointercancel"?this.lastMoveEventInfo:hl(y,this.transformPagePoint),this.history);this.startEvent&&x&&x(m,E),_&&_(m,E)},!Gc(t))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=i,this.contextWindow=r||window;const l=Co(t),h=hl(l,this.transformPagePoint),{point:u}=h,{timestamp:f}=Xe;this.history=[{...u,timestamp:f}];const{onSessionStart:c}=n;c&&c(t,ul(h,this.history)),this.removeListeners=So(io(this.contextWindow,"pointermove",this.handlePointerMove),io(this.contextWindow,"pointerup",this.handlePointerUp),io(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),ls(this.updatePoint)}}function hl(e,t){return t?{point:t(e.point)}:e}function ou(e,t){return{x:e.x-t.x,y:e.y-t.y}}function ul({point:e},t){return{point:e,delta:ou(e,Cm(t)),offset:ou(e,kv(t)),velocity:Tv(t,.1)}}function kv(e){return e[0]}function Cm(e){return e[e.length-1]}function Tv(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,i=null;const r=Cm(e);for(;n>=0&&(i=e[n],!(r.timestamp-i.timestamp>ai(t)));)n--;if(!i)return{x:0,y:0};const o=Ai(r.timestamp-i.timestamp);if(o===0)return{x:0,y:0};const l={x:(r.x-i.x)/o,y:(r.y-i.y)/o};return l.x===1/0&&(l.x=0),l.y===1/0&&(l.y=0),l}const Mm=1e-4,Pv=1-Mm,Ev=1+Mm,km=.01,Lv=0-km,Av=0+km;function kn(e){return e.max-e.min}function Rv(e,t,n){return Math.abs(e-t)<=n}function au(e,t,n,i=.5){e.origin=i,e.originPoint=Te(t.min,t.max,e.origin),e.scale=kn(n)/kn(t),e.translate=Te(n.min,n.max,e.origin)-e.originPoint,(e.scale>=Pv&&e.scale<=Ev||isNaN(e.scale))&&(e.scale=1),(e.translate>=Lv&&e.translate<=Av||isNaN(e.translate))&&(e.translate=0)}function so(e,t,n,i){au(e.x,t.x,n.x,i?i.originX:void 0),au(e.y,t.y,n.y,i?i.originY:void 0)}function lu(e,t,n){e.min=n.min+t.min,e.max=e.min+kn(t)}function Nv(e,t,n){lu(e.x,t.x,n.x),lu(e.y,t.y,n.y)}function cu(e,t,n){e.min=t.min-n.min,e.max=e.min+kn(t)}function ro(e,t,n){cu(e.x,t.x,n.x),cu(e.y,t.y,n.y)}function Iv(e,{min:t,max:n},i){return t!==void 0&&e<t?e=i?Te(t,e,i.min):Math.max(e,t):n!==void 0&&e>n&&(e=i?Te(n,e,i.max):Math.min(e,n)),e}function hu(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function zv(e,{top:t,left:n,bottom:i,right:r}){return{x:hu(e.x,n,r),y:hu(e.y,t,i)}}function uu(e,t){let n=t.min-e.min,i=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,i]=[i,n]),{min:n,max:i}}function Dv(e,t){return{x:uu(e.x,t.x),y:uu(e.y,t.y)}}function $v(e,t){let n=.5;const i=kn(e),r=kn(t);return r>i?n=xr(t.min,t.max-i,e.min):i>r&&(n=xr(e.min,e.max-r,t.min)),Ri(0,1,n)}function Bv(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const ec=.35;function Ov(e=ec){return e===!1?e=0:e===!0&&(e=ec),{x:du(e,"left","right"),y:du(e,"top","bottom")}}function du(e,t,n){return{min:fu(e,t),max:fu(e,n)}}function fu(e,t){return typeof e=="number"?e:e[t]||0}const mu=()=>({translate:0,scale:1,origin:0,originPoint:0}),ur=()=>({x:mu(),y:mu()}),pu=()=>({min:0,max:0}),Le=()=>({x:pu(),y:pu()});function $n(e){return[e("x"),e("y")]}function Tm({top:e,left:t,right:n,bottom:i}){return{x:{min:t,max:n},y:{min:e,max:i}}}function Fv({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function Wv(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),i=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:i.y,right:i.x}}function dl(e){return e===void 0||e===1}function nc({scale:e,scaleX:t,scaleY:n}){return!dl(e)||!dl(t)||!dl(n)}function Ls(e){return nc(e)||Pm(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Pm(e){return gu(e.x)||gu(e.y)}function gu(e){return e&&e!=="0%"}function wa(e,t,n){const i=e-n,r=t*i;return n+r}function yu(e,t,n,i,r){return r!==void 0&&(e=wa(e,r,i)),wa(e,n,i)+t}function ic(e,t=0,n=1,i,r){e.min=yu(e.min,t,n,i,r),e.max=yu(e.max,t,n,i,r)}function Em(e,{x:t,y:n}){ic(e.x,t.translate,t.scale,t.originPoint),ic(e.y,n.translate,n.scale,n.originPoint)}const vu=.999999999999,bu=1.0000000000001;function Vv(e,t,n,i=!1){const r=n.length;if(!r)return;t.x=t.y=1;let o,l;for(let h=0;h<r;h++){o=n[h],l=o.projectionDelta;const{visualElement:u}=o.options;u&&u.props.style&&u.props.style.display==="contents"||(i&&o.options.layoutScroll&&o.scroll&&o!==o.root&&fr(e,{x:-o.scroll.offset.x,y:-o.scroll.offset.y}),l&&(t.x*=l.x.scale,t.y*=l.y.scale,Em(e,l)),i&&Ls(o.latestValues)&&fr(e,o.latestValues))}t.x<bu&&t.x>vu&&(t.x=1),t.y<bu&&t.y>vu&&(t.y=1)}function dr(e,t){e.min=e.min+t,e.max=e.max+t}function xu(e,t,n,i,r=.5){const o=Te(e.min,e.max,r);ic(e,t,n,o,i)}function fr(e,t){xu(e.x,t.x,t.scaleX,t.scale,t.originX),xu(e.y,t.y,t.scaleY,t.scale,t.originY)}function Lm(e,t){return Tm(Wv(e.getBoundingClientRect(),t))}function jv(e,t,n){const i=Lm(e,n),{scroll:r}=t;return r&&(dr(i.x,r.offset.x),dr(i.y,r.offset.y)),i}const Am=({current:e})=>e?e.ownerDocument.defaultView:null,Hv=new WeakMap;class Zv{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Le(),this.visualElement=t}start(t,{snapToCursor:n=!1}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const r=c=>{const{dragSnapToOrigin:m}=this.getProps();m?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(Co(c).point)},o=(c,m)=>{const{drag:y,dragPropagation:x,onDragStart:_}=this.getProps();if(y&&!x&&(this.openDragLock&&this.openDragLock(),this.openDragLock=$y(y),!this.openDragLock))return;this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),$n(E=>{let T=this.getAxisMotionValue(E).get()||0;if(li.test(T)){const{projection:k}=this.visualElement;if(k&&k.layout){const A=k.layout.layoutBox[E];A&&(T=kn(A)*(parseFloat(T)/100))}}this.originPoint[E]=T}),_&&ge.postRender(()=>_(c,m)),ql(this.visualElement,"transform");const{animationState:p}=this.visualElement;p&&p.setActive("whileDrag",!0)},l=(c,m)=>{const{dragPropagation:y,dragDirectionLock:x,onDirectionLock:_,onDrag:p}=this.getProps();if(!y&&!this.openDragLock)return;const{offset:E}=m;if(x&&this.currentDirection===null){this.currentDirection=Uv(E),this.currentDirection!==null&&_&&_(this.currentDirection);return}this.updateAxis("x",m.point,E),this.updateAxis("y",m.point,E),this.visualElement.render(),p&&p(c,m)},h=(c,m)=>this.stop(c,m),u=()=>$n(c=>{var m;return this.getAnimationState(c)==="paused"&&((m=this.getAxisMotionValue(c).animation)===null||m===void 0?void 0:m.play())}),{dragSnapToOrigin:f}=this.getProps();this.panSession=new Sm(t,{onSessionStart:r,onStart:o,onMove:l,onSessionEnd:h,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:f,contextWindow:Am(this.visualElement)})}stop(t,n){const i=this.isDragging;if(this.cancel(),!i)return;const{velocity:r}=n;this.startAnimation(r);const{onDragEnd:o}=this.getProps();o&&ge.postRender(()=>o(t,n))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:i}=this.getProps();!i&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(t,n,i){const{drag:r}=this.getProps();if(!i||!Ho(t,r,this.currentDirection))return;const o=this.getAxisMotionValue(t);let l=this.originPoint[t]+i[t];this.constraints&&this.constraints[t]&&(l=Iv(l,this.constraints[t],this.elastic[t])),o.set(l)}resolveConstraints(){var t;const{dragConstraints:n,dragElastic:i}=this.getProps(),r=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(t=this.visualElement.projection)===null||t===void 0?void 0:t.layout,o=this.constraints;n&&cr(n)?this.constraints||(this.constraints=this.resolveRefConstraints()):n&&r?this.constraints=zv(r.layoutBox,n):this.constraints=!1,this.elastic=Ov(i),o!==this.constraints&&r&&this.constraints&&!this.hasMutatedConstraints&&$n(l=>{this.constraints!==!1&&this.getAxisMotionValue(l)&&(this.constraints[l]=Bv(r.layoutBox[l],this.constraints[l]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!cr(t))return!1;const i=t.current;as(i!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.");const{projection:r}=this.visualElement;if(!r||!r.layout)return!1;const o=jv(i,r.root,this.visualElement.getTransformPagePoint());let l=Dv(r.layout.layoutBox,o);if(n){const h=n(Fv(l));this.hasMutatedConstraints=!!h,h&&(l=Tm(h))}return l}startAnimation(t){const{drag:n,dragMomentum:i,dragElastic:r,dragTransition:o,dragSnapToOrigin:l,onDragTransitionEnd:h}=this.getProps(),u=this.constraints||{},f=$n(c=>{if(!Ho(c,n,this.currentDirection))return;let m=u&&u[c]||{};l&&(m={min:0,max:0});const y=r?200:1e6,x=r?40:1e7,_={type:"inertia",velocity:i?t[c]:0,bounceStiffness:y,bounceDamping:x,timeConstant:750,restDelta:1,restSpeed:10,...o,...m};return this.startAxisValueAnimation(c,_)});return Promise.all(f).then(h)}startAxisValueAnimation(t,n){const i=this.getAxisMotionValue(t);return ql(this.visualElement,t),i.start(oh(t,i,0,n,this.visualElement,!1))}stopAnimation(){$n(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){$n(t=>{var n;return(n=this.getAxisMotionValue(t).animation)===null||n===void 0?void 0:n.pause()})}getAnimationState(t){var n;return(n=this.getAxisMotionValue(t).animation)===null||n===void 0?void 0:n.state}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,i=this.visualElement.getProps(),r=i[n];return r||this.visualElement.getValue(t,(i.initial?i.initial[t]:void 0)||0)}snapToCursor(t){$n(n=>{const{drag:i}=this.getProps();if(!Ho(n,i,this.currentDirection))return;const{projection:r}=this.visualElement,o=this.getAxisMotionValue(n);if(r&&r.layout){const{min:l,max:h}=r.layout.layoutBox[n];o.set(t[n]-Te(l,h,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:i}=this.visualElement;if(!cr(n)||!i||!this.constraints)return;this.stopAnimation();const r={x:0,y:0};$n(l=>{const h=this.getAxisMotionValue(l);if(h&&this.constraints!==!1){const u=h.get();r[l]=$v({min:u,max:u},this.constraints[l])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",i.root&&i.root.updateScroll(),i.updateLayout(),this.resolveConstraints(),$n(l=>{if(!Ho(l,t,null))return;const h=this.getAxisMotionValue(l),{min:u,max:f}=this.constraints[l];h.set(Te(u,f,r[l]))})}addListeners(){if(!this.visualElement.current)return;Hv.set(this.visualElement,this);const t=this.visualElement.current,n=io(t,"pointerdown",u=>{const{drag:f,dragListener:c=!0}=this.getProps();f&&c&&this.start(u)}),i=()=>{const{dragConstraints:u}=this.getProps();cr(u)&&u.current&&(this.constraints=this.resolveRefConstraints())},{projection:r}=this.visualElement,o=r.addEventListener("measure",i);r&&!r.layout&&(r.root&&r.root.updateScroll(),r.updateLayout()),ge.read(i);const l=yo(window,"resize",()=>this.scalePositionWithinConstraints()),h=r.addEventListener("didUpdate",({delta:u,hasLayoutChanged:f})=>{this.isDragging&&f&&($n(c=>{const m=this.getAxisMotionValue(c);m&&(this.originPoint[c]+=u[c].translate,m.set(m.get()+u[c].translate))}),this.visualElement.render())});return()=>{l(),n(),o(),h&&h()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:i=!1,dragPropagation:r=!1,dragConstraints:o=!1,dragElastic:l=ec,dragMomentum:h=!0}=t;return{...t,drag:n,dragDirectionLock:i,dragPropagation:r,dragConstraints:o,dragElastic:l,dragMomentum:h}}}function Ho(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Uv(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class qv extends us{constructor(t){super(t),this.removeGroupControls=bn,this.removeListeners=bn,this.controls=new Zv(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||bn}unmount(){this.removeGroupControls(),this.removeListeners()}}const _u=e=>(t,n)=>{e&&ge.postRender(()=>e(t,n))};class Gv extends us{constructor(){super(...arguments),this.removePointerDownListener=bn}onPointerDown(t){this.session=new Sm(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Am(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:i,onPanEnd:r}=this.node.getProps();return{onSessionStart:_u(t),onStart:_u(n),onMove:i,onEnd:(o,l)=>{delete this.session,r&&ge.postRender(()=>r(o,l))}}}mount(){this.removePointerDownListener=io(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const ca={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function wu(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const Ur={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(At.test(e))e=parseFloat(e);else return e;const n=wu(e,t.target.x),i=wu(e,t.target.y);return`${n}% ${i}%`}},Yv={correct:(e,{treeScale:t,projectionDelta:n})=>{const i=e,r=cs.parse(e);if(r.length>5)return i;const o=cs.createTransformer(e),l=typeof r[0]!="number"?1:0,h=n.x.scale*t.x,u=n.y.scale*t.y;r[0+l]/=h,r[1+l]/=u;const f=Te(h,u,.5);return typeof r[2+l]=="number"&&(r[2+l]/=f),typeof r[3+l]=="number"&&(r[3+l]/=f),o(r)}};class Xv extends v.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:i,layoutId:r}=this.props,{projection:o}=t;gy(Jv),o&&(n.group&&n.group.add(o),i&&i.register&&r&&i.register(o),o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,onExitComplete:()=>this.safeToRemove()})),ca.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:i,drag:r,isPresent:o}=this.props,l=i.projection;return l&&(l.isPresent=o,r||t.layoutDependency!==n||n===void 0?l.willUpdate():this.safeToRemove(),t.isPresent!==o&&(o?l.promote():l.relegate()||ge.postRender(()=>{const h=l.getStack();(!h||!h.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),zc.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:i}=this.props,{projection:r}=t;r&&(r.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(r),i&&i.deregister&&i.deregister(r))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function Rm(e){const[t,n]=pf(),i=v.useContext(Tc);return De.jsx(Xv,{...e,layoutGroup:i,switchLayoutGroup:v.useContext(wf),isPresent:t,safeToRemove:n})}const Jv={borderRadius:{...Ur,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Ur,borderTopRightRadius:Ur,borderBottomLeftRadius:Ur,borderBottomRightRadius:Ur,boxShadow:Yv};function Qv(e,t,n){const i=sn(e)?e:po(e);return i.start(oh("",i,t,n)),i.animation}function Kv(e){return e instanceof SVGElement&&e.tagName!=="svg"}const tb=(e,t)=>e.depth-t.depth;class eb{constructor(){this.children=[],this.isDirty=!1}add(t){Yc(this.children,t),this.isDirty=!0}remove(t){Xc(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(tb),this.isDirty=!1,this.children.forEach(t)}}function nb(e,t){const n=ci.now(),i=({timestamp:r})=>{const o=r-n;o>=t&&(ls(i),e(o-t))};return ge.read(i,!0),()=>ls(i)}const Nm=["TopLeft","TopRight","BottomLeft","BottomRight"],ib=Nm.length,Su=e=>typeof e=="string"?parseFloat(e):e,Cu=e=>typeof e=="number"||At.test(e);function sb(e,t,n,i,r,o){r?(e.opacity=Te(0,n.opacity!==void 0?n.opacity:1,rb(i)),e.opacityExit=Te(t.opacity!==void 0?t.opacity:1,0,ob(i))):o&&(e.opacity=Te(t.opacity!==void 0?t.opacity:1,n.opacity!==void 0?n.opacity:1,i));for(let l=0;l<ib;l++){const h=`border${Nm[l]}Radius`;let u=Mu(t,h),f=Mu(n,h);if(u===void 0&&f===void 0)continue;u||(u=0),f||(f=0),u===0||f===0||Cu(u)===Cu(f)?(e[h]=Math.max(Te(Su(u),Su(f),i),0),(li.test(f)||li.test(u))&&(e[h]+="%")):e[h]=f}(t.rotate||n.rotate)&&(e.rotate=Te(t.rotate||0,n.rotate||0,i))}function Mu(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const rb=Im(0,.5,Qf),ob=Im(.5,.95,bn);function Im(e,t,n){return i=>i<e?0:i>t?1:n(xr(e,t,i))}function ku(e,t){e.min=t.min,e.max=t.max}function Dn(e,t){ku(e.x,t.x),ku(e.y,t.y)}function Tu(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function Pu(e,t,n,i,r){return e-=t,e=wa(e,1/n,i),r!==void 0&&(e=wa(e,1/r,i)),e}function ab(e,t=0,n=1,i=.5,r,o=e,l=e){if(li.test(t)&&(t=parseFloat(t),t=Te(l.min,l.max,t/100)-l.min),typeof t!="number")return;let h=Te(o.min,o.max,i);e===o&&(h-=t),e.min=Pu(e.min,t,n,h,r),e.max=Pu(e.max,t,n,h,r)}function Eu(e,t,[n,i,r],o,l){ab(e,t[n],t[i],t[r],t.scale,o,l)}const lb=["x","scaleX","originX"],cb=["y","scaleY","originY"];function Lu(e,t,n,i){Eu(e.x,t,lb,n?n.x:void 0,i?i.x:void 0),Eu(e.y,t,cb,n?n.y:void 0,i?i.y:void 0)}function Au(e){return e.translate===0&&e.scale===1}function zm(e){return Au(e.x)&&Au(e.y)}function Ru(e,t){return e.min===t.min&&e.max===t.max}function hb(e,t){return Ru(e.x,t.x)&&Ru(e.y,t.y)}function Nu(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function Dm(e,t){return Nu(e.x,t.x)&&Nu(e.y,t.y)}function Iu(e){return kn(e.x)/kn(e.y)}function zu(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class ub{constructor(){this.members=[]}add(t){Yc(this.members,t),t.scheduleRender()}remove(t){if(Xc(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){const n=this.members.findIndex(r=>t===r);if(n===0)return!1;let i;for(let r=n;r>=0;r--){const o=this.members[r];if(o.isPresent!==!1){i=o;break}}return i?(this.promote(i),!0):!1}promote(t,n){const i=this.lead;if(t!==i&&(this.prevLead=i,this.lead=t,t.show(),i)){i.instance&&i.scheduleRender(),t.scheduleRender(),t.resumeFrom=i,n&&(t.resumeFrom.preserveOpacity=!0),i.snapshot&&(t.snapshot=i.snapshot,t.snapshot.latestValues=i.animationValues||i.latestValues),t.root&&t.root.isUpdating&&(t.isLayoutDirty=!0);const{crossfade:r}=t.options;r===!1&&i.hide()}}exitAnimationComplete(){this.members.forEach(t=>{const{options:n,resumingFrom:i}=t;n.onExitComplete&&n.onExitComplete(),i&&i.options.onExitComplete&&i.options.onExitComplete()})}scheduleRender(){this.members.forEach(t=>{t.instance&&t.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function db(e,t,n){let i="";const r=e.x.translate/t.x,o=e.y.translate/t.y,l=(n==null?void 0:n.z)||0;if((r||o||l)&&(i=`translate3d(${r}px, ${o}px, ${l}px) `),(t.x!==1||t.y!==1)&&(i+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:f,rotate:c,rotateX:m,rotateY:y,skewX:x,skewY:_}=n;f&&(i=`perspective(${f}px) ${i}`),c&&(i+=`rotate(${c}deg) `),m&&(i+=`rotateX(${m}deg) `),y&&(i+=`rotateY(${y}deg) `),x&&(i+=`skewX(${x}deg) `),_&&(i+=`skewY(${_}deg) `)}const h=e.x.scale*t.x,u=e.y.scale*t.y;return(h!==1||u!==1)&&(i+=`scale(${h}, ${u})`),i||"none"}const As={type:"projectionFrame",totalNodes:0,resolvedTargetDeltas:0,recalculatedProjection:0},Qr=typeof window<"u"&&window.MotionDebug!==void 0,fl=["","X","Y","Z"],fb={visibility:"hidden"},Du=1e3;let mb=0;function ml(e,t,n,i){const{latestValues:r}=t;r[e]&&(n[e]=r[e],t.setStaticValue(e,0),i&&(i[e]=0))}function $m(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=Zf(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:r,layoutId:o}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",ge,!(r||o))}const{parent:i}=e;i&&!i.hasCheckedOptimisedAppear&&$m(i)}function Bm({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:i,resetTransform:r}){return class{constructor(l={},h=t==null?void 0:t()){this.id=mb++,this.animationId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,Qr&&(As.totalNodes=As.resolvedTargetDeltas=As.recalculatedProjection=0),this.nodes.forEach(yb),this.nodes.forEach(wb),this.nodes.forEach(Sb),this.nodes.forEach(vb),Qr&&window.MotionDebug.record(As)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=l,this.root=h?h.root||h:this,this.path=h?[...h.path,h]:[],this.parent=h,this.depth=h?h.depth+1:0;for(let u=0;u<this.path.length;u++)this.path[u].shouldResetTransform=!0;this.root===this&&(this.nodes=new eb)}addEventListener(l,h){return this.eventHandlers.has(l)||this.eventHandlers.set(l,new Jc),this.eventHandlers.get(l).add(h)}notifyListeners(l,...h){const u=this.eventHandlers.get(l);u&&u.notify(...h)}hasListeners(l){return this.eventHandlers.has(l)}mount(l,h=this.root.hasTreeAnimated){if(this.instance)return;this.isSVG=Kv(l),this.instance=l;const{layoutId:u,layout:f,visualElement:c}=this.options;if(c&&!c.current&&c.mount(l),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),h&&(f||u)&&(this.isLayoutDirty=!0),e){let m;const y=()=>this.root.updateBlockedByResize=!1;e(l,()=>{this.root.updateBlockedByResize=!0,m&&m(),m=nb(y,250),ca.hasAnimatedSinceResize&&(ca.hasAnimatedSinceResize=!1,this.nodes.forEach(Bu))})}u&&this.root.registerSharedNode(u,this),this.options.animate!==!1&&c&&(u||f)&&this.addEventListener("didUpdate",({delta:m,hasLayoutChanged:y,hasRelativeTargetChanged:x,layout:_})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const p=this.options.transition||c.getDefaultTransition()||Pb,{onLayoutAnimationStart:E,onLayoutAnimationComplete:T}=c.getProps(),k=!this.targetLayout||!Dm(this.targetLayout,_)||x,A=!y&&x;if(this.options.layoutRoot||this.resumeFrom&&this.resumeFrom.instance||A||y&&(k||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0),this.setAnimationOrigin(m,A);const P={...Zc(p,"layout"),onPlay:E,onComplete:T};(c.shouldReduceMotion||this.options.layoutRoot)&&(P.delay=0,P.type=!1),this.startAnimation(P)}else y||Bu(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=_})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const l=this.getStack();l&&l.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,ls(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(Cb),this.animationId++)}getTransformTemplate(){const{visualElement:l}=this.options;return l&&l.getProps().transformTemplate}willUpdate(l=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&$m(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let c=0;c<this.path.length;c++){const m=this.path[c];m.shouldResetTransform=!0,m.updateScroll("snapshot"),m.options.layoutRoot&&m.willUpdate(!1)}const{layoutId:h,layout:u}=this.options;if(h===void 0&&!u)return;const f=this.getTransformTemplate();this.prevTransformTemplateValue=f?f(this.latestValues,""):void 0,this.updateSnapshot(),l&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach($u);return}this.isUpdating||this.nodes.forEach(xb),this.isUpdating=!1,this.nodes.forEach(_b),this.nodes.forEach(pb),this.nodes.forEach(gb),this.clearAllSnapshots();const h=ci.now();Xe.delta=Ri(0,1e3/60,h-Xe.timestamp),Xe.timestamp=h,Xe.isProcessing=!0,sl.update.process(Xe),sl.preRender.process(Xe),sl.render.process(Xe),Xe.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,zc.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(bb),this.sharedNodes.forEach(Mb)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,ge.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){ge.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure())}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let u=0;u<this.path.length;u++)this.path[u].updateScroll();const l=this.layout;this.layout=this.measure(!1),this.layoutCorrected=Le(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:h}=this.options;h&&h.notify("LayoutMeasure",this.layout.layoutBox,l?l.layoutBox:void 0)}updateScroll(l="measure"){let h=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===l&&(h=!1),h){const u=i(this.instance);this.scroll={animationId:this.root.animationId,phase:l,isRoot:u,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:u}}}resetTransform(){if(!r)return;const l=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,h=this.projectionDelta&&!zm(this.projectionDelta),u=this.getTransformTemplate(),f=u?u(this.latestValues,""):void 0,c=f!==this.prevTransformTemplateValue;l&&(h||Ls(this.latestValues)||c)&&(r(this.instance,f),this.shouldResetTransform=!1,this.scheduleRender())}measure(l=!0){const h=this.measurePageBox();let u=this.removeElementScroll(h);return l&&(u=this.removeTransform(u)),Eb(u),{animationId:this.root.animationId,measuredBox:h,layoutBox:u,latestValues:{},source:this.id}}measurePageBox(){var l;const{visualElement:h}=this.options;if(!h)return Le();const u=h.measureViewportBox();if(!(((l=this.scroll)===null||l===void 0?void 0:l.wasRoot)||this.path.some(Lb))){const{scroll:c}=this.root;c&&(dr(u.x,c.offset.x),dr(u.y,c.offset.y))}return u}removeElementScroll(l){var h;const u=Le();if(Dn(u,l),!((h=this.scroll)===null||h===void 0)&&h.wasRoot)return u;for(let f=0;f<this.path.length;f++){const c=this.path[f],{scroll:m,options:y}=c;c!==this.root&&m&&y.layoutScroll&&(m.wasRoot&&Dn(u,l),dr(u.x,m.offset.x),dr(u.y,m.offset.y))}return u}applyTransform(l,h=!1){const u=Le();Dn(u,l);for(let f=0;f<this.path.length;f++){const c=this.path[f];!h&&c.options.layoutScroll&&c.scroll&&c!==c.root&&fr(u,{x:-c.scroll.offset.x,y:-c.scroll.offset.y}),Ls(c.latestValues)&&fr(u,c.latestValues)}return Ls(this.latestValues)&&fr(u,this.latestValues),u}removeTransform(l){const h=Le();Dn(h,l);for(let u=0;u<this.path.length;u++){const f=this.path[u];if(!f.instance||!Ls(f.latestValues))continue;nc(f.latestValues)&&f.updateSnapshot();const c=Le(),m=f.measurePageBox();Dn(c,m),Lu(h,f.latestValues,f.snapshot?f.snapshot.layoutBox:void 0,c)}return Ls(this.latestValues)&&Lu(h,this.latestValues),h}setTargetDelta(l){this.targetDelta=l,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(l){this.options={...this.options,...l,crossfade:l.crossfade!==void 0?l.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Xe.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(l=!1){var h;const u=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=u.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=u.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=u.isSharedProjectionDirty);const f=!!this.resumingFrom||this!==u;if(!(l||f&&this.isSharedProjectionDirty||this.isProjectionDirty||!((h=this.parent)===null||h===void 0)&&h.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:m,layoutId:y}=this.options;if(!(!this.layout||!(m||y))){if(this.resolvedRelativeTargetAt=Xe.timestamp,!this.targetDelta&&!this.relativeTarget){const x=this.getClosestProjectingParent();x&&x.layout&&this.animationProgress!==1?(this.relativeParent=x,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Le(),this.relativeTargetOrigin=Le(),ro(this.relativeTargetOrigin,this.layout.layoutBox,x.layout.layoutBox),Dn(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)){if(this.target||(this.target=Le(),this.targetWithTransforms=Le()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Nv(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):Dn(this.target,this.layout.layoutBox),Em(this.target,this.targetDelta)):Dn(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget){this.attemptToResolveRelativeTarget=!1;const x=this.getClosestProjectingParent();x&&!!x.resumingFrom==!!this.resumingFrom&&!x.options.layoutScroll&&x.target&&this.animationProgress!==1?(this.relativeParent=x,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Le(),this.relativeTargetOrigin=Le(),ro(this.relativeTargetOrigin,this.target,x.target),Dn(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}Qr&&As.resolvedTargetDeltas++}}}getClosestProjectingParent(){if(!(!this.parent||nc(this.parent.latestValues)||Pm(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){var l;const h=this.getLead(),u=!!this.resumingFrom||this!==h;let f=!0;if((this.isProjectionDirty||!((l=this.parent)===null||l===void 0)&&l.isProjectionDirty)&&(f=!1),u&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(f=!1),this.resolvedRelativeTargetAt===Xe.timestamp&&(f=!1),f)return;const{layout:c,layoutId:m}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(c||m))return;Dn(this.layoutCorrected,this.layout.layoutBox);const y=this.treeScale.x,x=this.treeScale.y;Vv(this.layoutCorrected,this.treeScale,this.path,u),h.layout&&!h.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(h.target=h.layout.layoutBox,h.targetWithTransforms=Le());const{target:_}=h;if(!_){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Tu(this.prevProjectionDelta.x,this.projectionDelta.x),Tu(this.prevProjectionDelta.y,this.projectionDelta.y)),so(this.projectionDelta,this.layoutCorrected,_,this.latestValues),(this.treeScale.x!==y||this.treeScale.y!==x||!zu(this.projectionDelta.x,this.prevProjectionDelta.x)||!zu(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",_)),Qr&&As.recalculatedProjection++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(l=!0){var h;if((h=this.options.visualElement)===null||h===void 0||h.scheduleRender(),l){const u=this.getStack();u&&u.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=ur(),this.projectionDelta=ur(),this.projectionDeltaWithTransform=ur()}setAnimationOrigin(l,h=!1){const u=this.snapshot,f=u?u.latestValues:{},c={...this.latestValues},m=ur();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!h;const y=Le(),x=u?u.source:void 0,_=this.layout?this.layout.source:void 0,p=x!==_,E=this.getStack(),T=!E||E.members.length<=1,k=!!(p&&!T&&this.options.crossfade===!0&&!this.path.some(Tb));this.animationProgress=0;let A;this.mixTargetDelta=P=>{const I=P/1e3;Ou(m.x,l.x,I),Ou(m.y,l.y,I),this.setTargetDelta(m),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(ro(y,this.layout.layoutBox,this.relativeParent.layout.layoutBox),kb(this.relativeTarget,this.relativeTargetOrigin,y,I),A&&hb(this.relativeTarget,A)&&(this.isProjectionDirty=!1),A||(A=Le()),Dn(A,this.relativeTarget)),p&&(this.animationValues=c,sb(c,f,this.latestValues,I,k,T)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=I},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(l){this.notifyListeners("animationStart"),this.currentAnimation&&this.currentAnimation.stop(),this.resumingFrom&&this.resumingFrom.currentAnimation&&this.resumingFrom.currentAnimation.stop(),this.pendingAnimation&&(ls(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=ge.update(()=>{ca.hasAnimatedSinceResize=!0,this.currentAnimation=Qv(0,Du,{...l,onUpdate:h=>{this.mixTargetDelta(h),l.onUpdate&&l.onUpdate(h)},onComplete:()=>{l.onComplete&&l.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const l=this.getStack();l&&l.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Du),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const l=this.getLead();let{targetWithTransforms:h,target:u,layout:f,latestValues:c}=l;if(!(!h||!u||!f)){if(this!==l&&this.layout&&f&&Om(this.options.animationType,this.layout.layoutBox,f.layoutBox)){u=this.target||Le();const m=kn(this.layout.layoutBox.x);u.x.min=l.target.x.min,u.x.max=u.x.min+m;const y=kn(this.layout.layoutBox.y);u.y.min=l.target.y.min,u.y.max=u.y.min+y}Dn(h,u),fr(h,c),so(this.projectionDeltaWithTransform,this.layoutCorrected,h,c)}}registerSharedNode(l,h){this.sharedNodes.has(l)||this.sharedNodes.set(l,new ub),this.sharedNodes.get(l).add(h);const f=h.options.initialPromotionConfig;h.promote({transition:f?f.transition:void 0,preserveFollowOpacity:f&&f.shouldPreserveFollowOpacity?f.shouldPreserveFollowOpacity(h):void 0})}isLead(){const l=this.getStack();return l?l.lead===this:!0}getLead(){var l;const{layoutId:h}=this.options;return h?((l=this.getStack())===null||l===void 0?void 0:l.lead)||this:this}getPrevLead(){var l;const{layoutId:h}=this.options;return h?(l=this.getStack())===null||l===void 0?void 0:l.prevLead:void 0}getStack(){const{layoutId:l}=this.options;if(l)return this.root.sharedNodes.get(l)}promote({needsReset:l,transition:h,preserveFollowOpacity:u}={}){const f=this.getStack();f&&f.promote(this,u),l&&(this.projectionDelta=void 0,this.needsReset=!0),h&&this.setOptions({transition:h})}relegate(){const l=this.getStack();return l?l.relegate(this):!1}resetSkewAndRotation(){const{visualElement:l}=this.options;if(!l)return;let h=!1;const{latestValues:u}=l;if((u.z||u.rotate||u.rotateX||u.rotateY||u.rotateZ||u.skewX||u.skewY)&&(h=!0),!h)return;const f={};u.z&&ml("z",l,f,this.animationValues);for(let c=0;c<fl.length;c++)ml(`rotate${fl[c]}`,l,f,this.animationValues),ml(`skew${fl[c]}`,l,f,this.animationValues);l.render();for(const c in f)l.setStaticValue(c,f[c]),this.animationValues&&(this.animationValues[c]=f[c]);l.scheduleRender()}getProjectionStyles(l){var h,u;if(!this.instance||this.isSVG)return;if(!this.isVisible)return fb;const f={visibility:""},c=this.getTransformTemplate();if(this.needsReset)return this.needsReset=!1,f.opacity="",f.pointerEvents=aa(l==null?void 0:l.pointerEvents)||"",f.transform=c?c(this.latestValues,""):"none",f;const m=this.getLead();if(!this.projectionDelta||!this.layout||!m.target){const p={};return this.options.layoutId&&(p.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,p.pointerEvents=aa(l==null?void 0:l.pointerEvents)||""),this.hasProjected&&!Ls(this.latestValues)&&(p.transform=c?c({},""):"none",this.hasProjected=!1),p}const y=m.animationValues||m.latestValues;this.applyTransformsToTarget(),f.transform=db(this.projectionDeltaWithTransform,this.treeScale,y),c&&(f.transform=c(y,f.transform));const{x,y:_}=this.projectionDelta;f.transformOrigin=`${x.origin*100}% ${_.origin*100}% 0`,m.animationValues?f.opacity=m===this?(u=(h=y.opacity)!==null&&h!==void 0?h:this.latestValues.opacity)!==null&&u!==void 0?u:1:this.preserveOpacity?this.latestValues.opacity:y.opacityExit:f.opacity=m===this?y.opacity!==void 0?y.opacity:"":y.opacityExit!==void 0?y.opacityExit:0;for(const p in ya){if(y[p]===void 0)continue;const{correct:E,applyTo:T}=ya[p],k=f.transform==="none"?y[p]:E(y[p],m);if(T){const A=T.length;for(let P=0;P<A;P++)f[T[P]]=k}else f[p]=k}return this.options.layoutId&&(f.pointerEvents=m===this?aa(l==null?void 0:l.pointerEvents)||"":"none"),f}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(l=>{var h;return(h=l.currentAnimation)===null||h===void 0?void 0:h.stop()}),this.root.nodes.forEach($u),this.root.sharedNodes.clear()}}}function pb(e){e.updateLayout()}function gb(e){var t;const n=((t=e.resumeFrom)===null||t===void 0?void 0:t.snapshot)||e.snapshot;if(e.isLead()&&e.layout&&n&&e.hasListeners("didUpdate")){const{layoutBox:i,measuredBox:r}=e.layout,{animationType:o}=e.options,l=n.source!==e.layout.source;o==="size"?$n(m=>{const y=l?n.measuredBox[m]:n.layoutBox[m],x=kn(y);y.min=i[m].min,y.max=y.min+x}):Om(o,n.layoutBox,i)&&$n(m=>{const y=l?n.measuredBox[m]:n.layoutBox[m],x=kn(i[m]);y.max=y.min+x,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[m].max=e.relativeTarget[m].min+x)});const h=ur();so(h,i,n.layoutBox);const u=ur();l?so(u,e.applyTransform(r,!0),n.measuredBox):so(u,i,n.layoutBox);const f=!zm(h);let c=!1;if(!e.resumeFrom){const m=e.getClosestProjectingParent();if(m&&!m.resumeFrom){const{snapshot:y,layout:x}=m;if(y&&x){const _=Le();ro(_,n.layoutBox,y.layoutBox);const p=Le();ro(p,i,x.layoutBox),Dm(_,p)||(c=!0),m.options.layoutRoot&&(e.relativeTarget=p,e.relativeTargetOrigin=_,e.relativeParent=m)}}}e.notifyListeners("didUpdate",{layout:i,snapshot:n,delta:u,layoutDelta:h,hasLayoutChanged:f,hasRelativeTargetChanged:c})}else if(e.isLead()){const{onExitComplete:i}=e.options;i&&i()}e.options.transition=void 0}function yb(e){Qr&&As.totalNodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function vb(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function bb(e){e.clearSnapshot()}function $u(e){e.clearMeasurements()}function xb(e){e.isLayoutDirty=!1}function _b(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function Bu(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function wb(e){e.resolveTargetDelta()}function Sb(e){e.calcProjection()}function Cb(e){e.resetSkewAndRotation()}function Mb(e){e.removeLeadSnapshot()}function Ou(e,t,n){e.translate=Te(t.translate,0,n),e.scale=Te(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function Fu(e,t,n,i){e.min=Te(t.min,n.min,i),e.max=Te(t.max,n.max,i)}function kb(e,t,n,i){Fu(e.x,t.x,n.x,i),Fu(e.y,t.y,n.y,i)}function Tb(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const Pb={duration:.45,ease:[.4,0,.1,1]},Wu=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),Vu=Wu("applewebkit/")&&!Wu("chrome/")?Math.round:bn;function ju(e){e.min=Vu(e.min),e.max=Vu(e.max)}function Eb(e){ju(e.x),ju(e.y)}function Om(e,t,n){return e==="position"||e==="preserve-aspect"&&!Rv(Iu(t),Iu(n),.2)}function Lb(e){var t;return e!==e.root&&((t=e.scroll)===null||t===void 0?void 0:t.wasRoot)}const Ab=Bm({attachResizeListener:(e,t)=>yo(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),pl={current:void 0},Fm=Bm({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!pl.current){const e=new Ab({});e.mount(window),e.setOptions({layoutScroll:!0}),pl.current=e}return pl.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),Rb={pan:{Feature:Gv},drag:{Feature:qv,ProjectionNode:Fm,MeasureLayout:Rm}};function Hu(e,t,n){const{props:i}=e;e.animationState&&i.whileHover&&e.animationState.setActive("whileHover",n==="Start");const r="onHover"+n,o=i[r];o&&ge.postRender(()=>o(t,Co(t)))}class Nb extends us{mount(){const{current:t}=this.node;t&&(this.unmount=Ry(t,n=>(Hu(this.node,n,"Start"),i=>Hu(this.node,i,"End"))))}unmount(){}}class Ib extends us{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=So(yo(this.node.current,"focus",()=>this.onFocus()),yo(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Zu(e,t,n){const{props:i}=e;e.animationState&&i.whileTap&&e.animationState.setActive("whileTap",n==="Start");const r="onTap"+(n==="End"?"":n),o=i[r];o&&ge.postRender(()=>o(t,Co(t)))}class zb extends us{mount(){const{current:t}=this.node;t&&(this.unmount=Dy(t,n=>(Zu(this.node,n,"Start"),(i,{success:r})=>Zu(this.node,i,r?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const sc=new WeakMap,gl=new WeakMap,Db=e=>{const t=sc.get(e.target);t&&t(e)},$b=e=>{e.forEach(Db)};function Bb({root:e,...t}){const n=e||document;gl.has(n)||gl.set(n,{});const i=gl.get(n),r=JSON.stringify(t);return i[r]||(i[r]=new IntersectionObserver($b,{root:e,...t})),i[r]}function Ob(e,t,n){const i=Bb(t);return sc.set(e,n),i.observe(e),()=>{sc.delete(e),i.unobserve(e)}}const Fb={some:0,all:1};class Wb extends us{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:i,amount:r="some",once:o}=t,l={root:n?n.current:void 0,rootMargin:i,threshold:typeof r=="number"?r:Fb[r]},h=u=>{const{isIntersecting:f}=u;if(this.isInView===f||(this.isInView=f,o&&!f&&this.hasEnteredView))return;f&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",f);const{onViewportEnter:c,onViewportLeave:m}=this.node.getProps(),y=f?c:m;y&&y(u)};return Ob(this.node.current,l,h)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(Vb(t,n))&&this.startObserver()}unmount(){}}function Vb({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const jb={inView:{Feature:Wb},tap:{Feature:zb},focus:{Feature:Ib},hover:{Feature:Nb}},Hb={layout:{ProjectionNode:Fm,MeasureLayout:Rm}},rc={current:null},Wm={current:!1};function Zb(){if(Wm.current=!0,!!Lc)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>rc.current=e.matches;e.addListener(t),t()}else rc.current=!1}const Ub=[...dm,nn,cs],qb=e=>Ub.find(um(e)),Uu=new WeakMap;function Gb(e,t,n){for(const i in t){const r=t[i],o=n[i];if(sn(r))e.addValue(i,r),process.env.NODE_ENV==="development"&&Ra(r.version==="11.18.2",`Attempting to mix Motion versions ${r.version} with 11.18.2 may not work as expected.`);else if(sn(o))e.addValue(i,po(r,{owner:e}));else if(o!==r)if(e.hasValue(i)){const l=e.getValue(i);l.liveStyle===!0?l.jump(r):l.hasAnimated||l.set(r)}else{const l=e.getStaticValue(i);e.addValue(i,po(l!==void 0?l:r,{owner:e}))}}for(const i in n)t[i]===void 0&&e.removeValue(i);return t}const qu=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Yb{scrapeMotionValuesFromProps(t,n,i){return{}}constructor({parent:t,props:n,presenceContext:i,reducedMotionConfig:r,blockInitialAnimation:o,visualState:l},h={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=ih,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const x=ci.now();this.renderScheduledAt<x&&(this.renderScheduledAt=x,ge.render(this.render,!1,!0))};const{latestValues:u,renderState:f,onUpdate:c}=l;this.onUpdate=c,this.latestValues=u,this.baseTarget={...u},this.initialValues=n.initial?{...u}:{},this.renderState=f,this.parent=t,this.props=n,this.presenceContext=i,this.depth=t?t.depth+1:0,this.reducedMotionConfig=r,this.options=h,this.blockInitialAnimation=!!o,this.isControllingVariants=za(n),this.isVariantNode=xf(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:m,...y}=this.scrapeMotionValuesFromProps(n,{},this);for(const x in y){const _=y[x];u[x]!==void 0&&sn(_)&&_.set(u[x],!1)}}mount(t){this.current=t,Uu.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,i)=>this.bindToMotionValue(i,n)),Wm.current||Zb(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:rc.current,process.env.NODE_ENV!=="production"&&Ra(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected."),this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){Uu.delete(this.current),this.projection&&this.projection.unmount(),ls(this.notifyUpdate),ls(this.render),this.valueSubscriptions.forEach(t=>t()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(const t in this.events)this.events[t].clear();for(const t in this.features){const n=this.features[t];n&&(n.unmount(),n.isMounted=!1)}this.current=null}bindToMotionValue(t,n){this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)();const i=Fs.has(t),r=n.on("change",h=>{this.latestValues[t]=h,this.props.onUpdate&&ge.preRender(this.notifyUpdate),i&&this.projection&&(this.projection.isTransformDirty=!0)}),o=n.on("renderRequest",this.scheduleRender);let l;window.MotionCheckAppearSync&&(l=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{r(),o(),l&&l(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in _r){const n=_r[t];if(!n)continue;const{isEnabled:i,Feature:r}=n;if(!this.features[t]&&r&&i(this.props)&&(this.features[t]=new r(this)),this.features[t]){const o=this.features[t];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Le()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let i=0;i<qu.length;i++){const r=qu[i];this.propEventSubscriptions[r]&&(this.propEventSubscriptions[r](),delete this.propEventSubscriptions[r]);const o="on"+r,l=t[o];l&&(this.propEventSubscriptions[r]=this.on(r,l))}this.prevMotionValues=Gb(this,this.scrapeMotionValuesFromProps(t,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue(),this.onUpdate&&this.onUpdate(this)}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(t){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(t),()=>n.variantChildren.delete(t)}addValue(t,n){const i=this.values.get(t);n!==i&&(i&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let i=this.values.get(t);return i===void 0&&n!==void 0&&(i=po(n===null?void 0:n,{owner:this}),this.addValue(t,i)),i}readValue(t,n){var i;let r=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:(i=this.getBaseTargetFromProps(this.props,t))!==null&&i!==void 0?i:this.readValueFromInstance(this.current,t,this.options);return r!=null&&(typeof r=="string"&&(cm(r)||tm(r))?r=parseFloat(r):!qb(r)&&cs.test(n)&&(r=om(t,n)),this.setBaseTarget(t,sn(r)?r.get():r)),sn(r)?r.get():r}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){var n;const{initial:i}=this.props;let r;if(typeof i=="string"||typeof i=="object"){const l=$c(this.props,i,(n=this.presenceContext)===null||n===void 0?void 0:n.custom);l&&(r=l[t])}if(i&&r!==void 0)return r;const o=this.getBaseTargetFromProps(this.props,t);return o!==void 0&&!sn(o)?o:this.initialValues[t]!==void 0&&r===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new Jc),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}}class Vm extends Yb{constructor(){super(...arguments),this.KeyframeResolver=fm}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){return t.style?t.style[n]:void 0}removeValueFromRenderState(t,{vars:n,style:i}){delete n[t],delete i[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;sn(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Xb(e){return window.getComputedStyle(e)}class Jb extends Vm{constructor(){super(...arguments),this.type="html",this.renderInstance=Ef}readValueFromInstance(t,n){if(Fs.has(n)){const i=nh(n);return i&&i.default||0}else{const i=Xb(t),r=(kf(n)?i.getPropertyValue(n):i[n])||0;return typeof r=="string"?r.trim():r}}measureInstanceViewportBox(t,{transformPagePoint:n}){return Lm(t,n)}build(t,n,i){Fc(t,n,i.transformTemplate)}scrapeMotionValuesFromProps(t,n,i){return Hc(t,n,i)}}class Qb extends Vm{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Le}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(Fs.has(n)){const i=nh(n);return i&&i.default||0}return n=Lf.has(n)?n:Ic(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,i){return Nf(t,n,i)}build(t,n,i){Wc(t,n,this.isSVGTag,i.transformTemplate)}renderInstance(t,n,i,r){Af(t,n,i,r)}mount(t){this.isSVGTag=jc(t.tagName),super.mount(t)}}const Kb=(e,t)=>Dc(e)?new Qb(t):new Jb(t,{allowProjection:e!==v.Fragment}),tx=My({...Sv,...jb,...Rb,...Hb},Kb),Sa=Fg(tx),ex={div:"div",span:"span",p:"p",hr:"hr",a:"a",strong:"strong",em:"em",del:"del",li:"li",ul:"ul",ol:"ol",form:"form",img:"img",header:"header",footer:"footer",section:"section",nav:"nav",main:"main",article:"article",aside:"aside",figure:"figure",figcaption:"figcaption",th:"th",td:"td",caption:"caption",blockquote:"blockquote",address:"address",time:"time",legend:"legend",label:"label",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",code:"code"},nx=new Set(["motion","initial","animate","exit","transition","variants","whileHover","whileTap","whileFocus","whileInView","animateLayout"]);function N(e,t,...n){const{style:i,className:r,...o}=t||{};if(o.motion){const h={};for(const f of nx)if(f in o){const c=f==="animateLayout"?"layout":f;let m=o[f];c==="transition"&&m&&typeof m=="object"&&(m={...m,repeat:Math.max(0,Number(m.repeat)||0)}),h[c]=m,delete o[f]}const u=Sa[e]||Sa.div;return v.createElement(u,{...o,className:r,style:i||{},...h},...n)}delete o.animateLayout;const l=ex[e];return l?v.createElement(l,{...o,className:r,style:i||{}},...n):v.createElement(e,{...o,className:r,style:i||{}},...n)}const ix={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},jm={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Hm=["base","sm","md","lg","xl","2xl"],We={0:"0px","0.5":"0.125rem",1:"0.25rem","1.5":"0.375rem",2:"0.5rem","2.5":"0.625rem",3:"0.75rem","3.5":"0.875rem",4:"1rem",5:"1.25rem",6:"1.5rem",7:"1.75rem",8:"2rem",9:"2.25rem",10:"2.5rem",11:"2.75rem",12:"3rem",14:"3.5rem",16:"4rem",20:"5rem",24:"6rem",28:"7rem",32:"8rem",36:"9rem",40:"10rem",44:"11rem",48:"12rem",52:"13rem",56:"14rem",60:"15rem",64:"16rem",72:"18rem",80:"20rem",96:"24rem"},Zo={xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem","4xl":"2.25rem","5xl":"3rem","6xl":"3.75rem","7xl":"4.5rem","8xl":"6rem","9xl":"8rem"},Gu={"1/2":"50%","1/3":"33.333333%","2/3":"66.666667%","1/4":"25%","2/4":"50%","3/4":"75%","1/5":"20%","2/5":"40%","3/5":"60%","4/5":"80%","1/6":"16.666667%","2/6":"33.333333%","3/6":"50%","4/6":"66.666667%","5/6":"83.333333%","1/12":"8.333333%","2/12":"16.666667%","3/12":"25%","4/12":"33.333333%","5/12":"41.666667%","6/12":"50%","7/12":"58.333333%","8/12":"66.666667%","9/12":"75%","10/12":"83.333333%","11/12":"91.666667%",full:"100%",auto:"auto",screen:"100vw",fit:"fit-content",max:"max-content",min:"min-content"},Uo={"flex-row":"row","flex-row-reverse":"row-reverse","flex-col":"column","flex-col-reverse":"column-reverse"},qo={"items-start":"flex-start","items-end":"flex-end","items-center":"center","items-baseline":"baseline","items-stretch":"stretch"},Go={"justify-start":"flex-start","justify-end":"flex-end","justify-center":"center","justify-between":"space-between","justify-around":"space-around","justify-evenly":"space-evenly"},Yo={"rounded-none":"0px","rounded-sm":"0.125rem",rounded:"0.25rem","rounded-md":"0.375rem","rounded-lg":"0.5rem","rounded-xl":"0.75rem","rounded-2xl":"1rem","rounded-3xl":"1.5rem","rounded-full":"9999px"},sx=["hidden","block","flex","grid","inline","inline-block","inline-flex"];function rx(e,t,n,i){const r=new Map,o=e.split(/\s+/).filter(Boolean);for(const l of o){const h=new RegExp(n.source).exec(l);if(h){r.set(h[1],i(h));continue}const u=new RegExp(t.source).exec(l);u&&r.set("base",i([null,null,u[1]]))}return r}function Zm(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const i of n){const r=i.match(/^(sm|md|lg|xl|2xl):(flex-row|flex-row-reverse|flex-col|flex-col-reverse)$/);if(r&&Uo[r[2]]){t.set(r[1],Uo[r[2]]);continue}Uo[i]&&t.set("base",Uo[i])}return t}function Um(e){return rx(e,/^gap-(\d+(?:\.\d+)?)$/,/^(sm|md|lg|xl|2xl):gap-(\d+(?:\.\d+)?)$/,t=>We[t[2]]||`${t[2]}px`)}function qm(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const i of n){const r=i.match(/^(sm|md|lg|xl|2xl):w-(.+)$/);if(r){const l=Gu[r[2]]||We[r[2]]||r[2];l&&t.set(r[1],l);continue}const o=i.match(/^w-(.+)$/);if(o){const l=Gu[o[1]]||We[o[1]]||o[1];l&&t.set("base",l)}}return t}function Gm(e){const t=new Map,n=new Map,i=new Map,r=new Map,o=new Map,l=new Map,h=new Map,u=e.split(/\s+/).filter(Boolean);for(const f of u)for(const[c,m]of[["m-",t],["mt-",n],["mr-",i],["mb-",r],["ml-",o],["mx-",l],["my-",h]]){const y=f.match(new RegExp(`^(sm|md|lg|xl|2xl):${c}(\\d+(?:\\.\\d+)?)$`));if(y&&We[y[2]]){m.set(y[1],We[y[2]]);break}const x=f.match(new RegExp(`^${c}(\\d+(?:\\.\\d+)?)$`));if(x&&We[x[1]]){m.set("base",We[x[1]]);break}}return{all:t,t:n,r:i,b:r,l:o,x:l,y:h}}function Ym(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const i of n){const r=i.match(/^(sm|md|lg|xl|2xl):(items-start|items-end|items-center|items-baseline|items-stretch)$/);if(r&&qo[r[2]]){t.set(r[1],qo[r[2]]);continue}qo[i]&&t.set("base",qo[i])}return t}function Xm(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const i of n){const r=i.match(/^(sm|md|lg|xl|2xl):(justify-start|justify-end|justify-center|justify-between|justify-around|justify-evenly)$/);if(r&&Go[r[2]]){t.set(r[1],Go[r[2]]);continue}Go[i]&&t.set("base",Go[i])}return t}function Jm(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const i of n){const r=i.match(/^(sm|md|lg|xl|2xl):(rounded-none|rounded-sm|rounded|rounded-md|rounded-lg|rounded-xl|rounded-2xl|rounded-3xl|rounded-full)$/);if(r&&Yo[r[2]]){t.set(r[1],Yo[r[2]]);continue}Yo[i]&&t.set("base",Yo[i])}return t}function ah(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const i of n){const r=i.match(/^(sm|md|lg|xl|2xl):(hidden|block|flex|grid|inline|inline-block|inline-flex)$/);if(r){t.set(r[1],r[2]==="hidden"?"none":r[2]);continue}sx.includes(i)&&t.set("base",i==="hidden"?"none":i)}return t}function lh(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const i of n){const r=i.match(/^(sm|md|lg|xl|2xl):grid-cols-(\d+)$/);if(r){t.set(r[1],parseInt(r[2],10));continue}const o=i.match(/^grid-cols-(\d+)$/);o&&t.set("base",parseInt(o[1],10))}return t}function ch(e){const t=new Map,n=e.split(/\s+/).filter(Boolean);for(const i of n){const r=i.match(/^(sm|md|lg|xl|2xl):text-(xs|sm|base|lg|xl|2xl|3xl|4xl|5xl|6xl|7xl|8xl|9xl)$/);if(r&&Zo[r[2]]){t.set(r[1],Zo[r[2]]);continue}const o=i.match(/^text-(xs|sm|base|lg|xl|2xl|3xl|4xl|5xl|6xl|7xl|8xl|9xl)$/);o&&Zo[o[1]]&&t.set("base",Zo[o[1]])}return t}function hh(e){const t=new Map,n=new Map,i=new Map,r=e.split(/\s+/).filter(Boolean);for(const o of r){const l=o.match(/^(sm|md|lg|xl|2xl):px-(\d+(?:\.\d+)?)$/);if(l&&We[l[2]]){t.set(l[1],We[l[2]]);continue}const h=o.match(/^px-(\d+(?:\.\d+)?)$/);if(h&&We[h[1]]){t.set("base",We[h[1]]);continue}const u=o.match(/^(sm|md|lg|xl|2xl):py-(\d+(?:\.\d+)?)$/);if(u&&We[u[2]]){n.set(u[1],We[u[2]]);continue}const f=o.match(/^py-(\d+(?:\.\d+)?)$/);if(f&&We[f[1]]){n.set("base",We[f[1]]);continue}const c=o.match(/^(sm|md|lg|xl|2xl):p-(\d+(?:\.\d+)?)$/);if(c&&We[c[2]]){i.set(c[1],We[c[2]]);continue}const m=o.match(/^p-(\d+(?:\.\d+)?)$/);m&&We[m[1]]&&i.set("base",We[m[1]])}return{px:t,py:n,p:i}}function oc(e){return e.flexDirection.size>0||e.gap.size>0||e.width.size>0||e.alignItems.size>0||e.justifyContent.size>0||e.padding.px.size>0||e.padding.py.size>0||e.padding.p.size>0||e.display.size>0||e.gridCols.size>0||e.textSize.size>0||e.borderRadius.size>0||e.margin.all.size>0||e.margin.t.size>0||e.margin.r.size>0||e.margin.b.size>0||e.margin.l.size>0||e.margin.x.size>0||e.margin.y.size>0}function ac(e){return{flexDirection:Zm(e),gap:Um(e),width:qm(e),margin:Gm(e),alignItems:Ym(e),justifyContent:Xm(e),padding:hh(e),display:ah(e),gridCols:lh(e),textSize:ch(e),borderRadius:Jm(e),any:!1}}const vo=ix;function ox(e){return lh(e)}function ax(e,t){let n=e.get("base")??1;const i=["2xl","xl","lg","md","sm"];if(t<=0){for(const r of i)if(e.has(r))return e.get(r);return n}for(const r of["sm","md","lg","xl","2xl"])t>=(vo[r]||0)&&e.has(r)&&(n=e.get(r));return n}function uh(e){return ch(e)}function It(e,t,n){let i=e.get("base")??n;for(const r of["sm","md","lg","xl","2xl"])t>=(vo[r]||0)&&e.has(r)&&(i=e.get(r));return i}function Mo(e){return hh(e)}function Er(e){return ah(e)}function Qm(e){const[t,n]=v.useState(()=>{var r;return((r=e.current)==null?void 0:r.offsetWidth)??0}),i=v.useRef(t);return v.useEffect(()=>{const r=e.current;if(!r)return;const o=r.offsetWidth;o>0&&o!==i.current&&(i.current=o,n(o));const l=new ResizeObserver(h=>{for(const u of h){const f=Math.round(u.contentRect.width);f>0&&f!==i.current&&(i.current=f,n(f))}});return l.observe(r),()=>{l.disconnect()}},[e]),t}function lx(e,t,n){var f,c,m;const r=(Array.isArray(t.tabItems)?t.tabItems:Array.isArray(t.tabs)?t.tabs:[]).filter(y=>!y.condition||!e.evaluateCondition||e.evaluateCondition(y.condition));if(r.length===0)return null;const o=`__tab_${n}`,l=e.sceneData[o]??(t.defaultTab||0),h={width:"100%",display:"flex",flexDirection:"column",...t.className?((f=e.parseClassNameResponsive)==null?void 0:f.call(e,t.className,n))??e.parseClassName(t.className):{}},u=e.getCommonProps(n,h,t);return v.createElement("div",{key:n,...u},v.createElement("div",{style:{display:"flex",borderBottom:`1px solid ${e.cfg.colors.borderSubtle}`,gap:"0"}},r.map((y,x)=>v.createElement("button",{key:`${n}-tab-${x}`,onClick:()=>e.setSceneData(_=>({..._,[o]:x})),style:{padding:"8px 16px",fontSize:"13px",fontWeight:l===x?600:400,color:l===x?e.cfg.colors.primary:e.cfg.colors.textMuted,borderBottom:l===x?`2px solid ${e.cfg.colors.primary}`:"2px solid transparent",background:"none",border:"none",borderBottomStyle:"solid",borderBottomWidth:"2px",borderBottomColor:l===x?e.cfg.colors.primary:"transparent",cursor:"pointer",transition:e.cfg.effects.transition}},y.label||y.title))),v.createElement("div",{style:{padding:"12px 0"}},(Array.isArray((c=r[l])==null?void 0:c.content)?r[l].content:Array.isArray((m=r[l])==null?void 0:m.children)?r[l].children:[]).map((y,x)=>e.renderComponent(y,x,`${n}-tabcontent-${l}`))))}function cx(e,t,n){var l;Array.isArray(t.items)&&!Array.isArray(t.accordionItems)&&(t.accordionItems=t.items);const i=Array.isArray(t.accordionItems)?t.accordionItems:[];if(i.length===0)return null;const r={width:"100%",display:"flex",flexDirection:"column",gap:"1px",...t.className?((l=e.parseClassNameResponsive)==null?void 0:l.call(e,t.className,n))??e.parseClassName(t.className):{}},o=e.getCommonProps(n,r,t);return v.createElement("div",{key:n,...o},i.map((h,u)=>{const f=`__acc_${n}_${u}`,c=e.sceneData[f]??(h.defaultOpen||!1);return v.createElement("div",{key:`${n}-acc-${u}`},v.createElement("button",{onClick:()=>e.setSceneData(m=>({...m,[f]:!c})),style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 12px",background:"none",border:"none",borderBottom:`1px solid ${e.cfg.colors.borderSubtle}`,color:e.cfg.colors.textSecondary,fontSize:e.cfg.typography.baseFontSize,fontWeight:500,cursor:"pointer",transition:e.cfg.effects.transition}},N("span",{style:{display:"flex",alignItems:"center",gap:"8px"}},h.icon?e.renderIcon(h.icon,14,{color:e.cfg.colors.primary}):null,N("span",null,h.title)),N("span",{style:{transform:c?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s",fontSize:"24px"}},"▾")),v.createElement(Rg,{initial:!1},c&&v.createElement(Sa.div,{key:`${n}-acc-body-${u}`,initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{height:{duration:.3,ease:"easeInOut"},opacity:{duration:.25}},style:{overflow:"hidden"}},v.createElement("div",{style:{padding:"8px 12px",display:"flex",flexDirection:"column",gap:"8px"}},(Array.isArray(h.content)?h.content:typeof h.content=="string"?[{type:"text",text:h.content}]:Array.isArray(h.children)?h.children:[]).map((y,x)=>e.renderComponent(y,x,`${n}-acc-${u}-content`))))))}))}function hx(e,t,n){var x,_,p,E,T;const i=(x=e.paginationState)==null?void 0:x[n],r=t.pagination===!0&&i&&i.total>i.limit,o=t.pagination==="scroll",l=i?Math.ceil(i.total/i.limit):0,h=t.className||"flex flex-col gap-3 w-full",u=((_=e.parseClassNameResponsive)==null?void 0:_.call(e,h,n))??e.parseClassName(h);t.rawStyle&&Object.assign(u,t.rawStyle);const f=(p=e.loading)==null?void 0:p[n],c=(E=e.listData)==null?void 0:E[n],m=Array.isArray(c)?c:[],y=e.renderMode==="css-driven"?{"data-bf-r":`${e.scopeId}-${n}`}:{};return v.createElement("div",{key:n,className:h,style:u,"data-component-key":n,...y},f&&(t.loadingComponent?e.renderComponent(t.loadingComponent,0,n):v.createElement("div",{className:"flex justify-center py-4"},N("div",{className:"w-6 h-6 border-2 border-primary border-t-transparent rounded-full animate-spin"}))),!f&&m.length===0&&t.emptyComponent&&e.renderComponent(t.emptyComponent,0,`${n}-empty`),!f&&t.selectable&&e.sceneData._selectMode&&m.length>0&&N("div",{key:`${n}-sel-hdr`,style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:((T=t.selectionStyle)==null?void 0:T.headerPadding)||"0.5rem 2rem"}},N("button",{type:"button",onClick:()=>{const k=Array.isArray(e.sceneData._selIds)?e.sceneData._selIds:[],A=m.map((I,$)=>String(I.id||$)),P=A.length>0&&A.every(I=>k.includes(I));e.setSceneData(I=>({...I,_selIds:P?[]:A}))},style:{background:"none",border:"none",cursor:"pointer",color:e.cfg.colors.textSecondary,fontSize:"12px",fontFamily:"inherit",padding:"4px 0"}},(Array.isArray(e.sceneData._selIds)?e.sceneData._selIds:[]).filter(k=>m.some(A=>String(A.id)===k)).length===m.filter(k=>k.id).length&&m.length>0?"Deselect all":"Select all"),(Array.isArray(e.sceneData._selIds)?e.sceneData._selIds:[]).length>0?N("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},...(Array.isArray(t.selectActions)?t.selectActions:[]).map((k,A)=>N("button",{key:A,type:"button",onClick:()=>{var I;const P=Array.isArray(e.sceneData._selIds)?e.sceneData._selIds:[];P.length!==0&&((I=e.runBulkSelectAction)==null||I.call(e,k,t.dataSource,n,P))},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"28px",height:"28px",border:"none",borderRadius:"4px",cursor:"pointer",backgroundColor:"transparent",color:e.cfg.colors.textSecondary,transition:"all 0.15s ease",padding:"0"},onMouseEnter:P=>{P.currentTarget.style.backgroundColor=e.cfg.colors.border,P.currentTarget.style.color=e.cfg.colors.text},onMouseLeave:P=>{P.currentTarget.style.backgroundColor="transparent",P.currentTarget.style.color=e.cfg.colors.textSecondary}},e.renderIcon(k.icon,12))),N("span",{style:{fontSize:"12px",color:e.cfg.colors.textMuted}},`${(Array.isArray(e.sceneData._selIds)?e.sceneData._selIds:[]).length} selected`)):null),!f&&m.length>0&&(()=>{var tt,st,J,bt;const k=(tt=t.groupBy)==null?void 0:tt.field,A=et=>{const ht=et==null?void 0:et[k];if(ht&&typeof ht=="object"&&ht._seconds)return ht._seconds*1e3;const kt=Date.parse(ht);return isNaN(kt)?0:kt},P=et=>{if(!et)return"Earlier";const ht=new Date(et),kt=new Date,St=Rt=>`${Rt.getFullYear()}-${Rt.getMonth()}-${Rt.getDate()}`;if(St(ht)===St(kt))return"Today";const Tt=new Date(kt);return Tt.setDate(kt.getDate()-1),St(ht)===St(Tt)?"Yesterday":ht.toLocaleDateString()},$=((st=t.sort)==null?void 0:st.field)||k?[...m].sort((et,ht)=>{var St;const kt=A(ht)-A(et);return((St=t.sort)==null?void 0:St.direction)==="asc"?-kt:kt}):m,j=String(e.sceneData.recordingSearchApplied||"").trim().toLowerCase(),[U,nt]=String(e.sceneData.recordingDateFilterApplied||"").split("|"),ot=U?Date.parse(`${U}T00:00:00`):0,q=nt?Date.parse(`${nt}T23:59:59.999`):Number.POSITIVE_INFINITY,ct=((J=t.itemsFilter)!=null&&J.field?$.filter(et=>String(et==null?void 0:et[t.itemsFilter.field])===String(t.itemsFilter.eq)):$).filter(et=>{const ht=!j||[et.url,et.title,et.prompt].some(St=>String(St||"").toLowerCase().includes(j)),kt=A(et);return ht&&kt>=ot&&kt<=q}),K={};if(k)for(const et of ct)(K[bt=P(A(et))]||(K[bt]=[])).push(et);const Z=(et,ht)=>{var kt,St,Tt,Rt,Et,re,oe,Ot;if(t.renderItem){const Re=JSON.parse(JSON.stringify(t.renderItem)),Qe={...et};if(t.labelField&&t.labelMap){const Ft=String(t.labelField.split(".").reduce((qt,fe)=>qt==null?void 0:qt[fe],et)??"");Qe.label=t.labelMap[Ft]??""}const ye={};if(Array.isArray(Re.children)){for(const Ft of Re.children)if(Ft.content){const qt=Ft.content.match(/^\{\{(\w+)\}\}$/);if(qt){const fe=qt[1],Kt=et[fe];Array.isArray(Kt)&&(ye[fe]=Kt)}}}const ui=JSON.stringify(Re).replace(/\{\{([\w.]+)(?:\|(date|time|datetime|timeago))?\}\}/g,(Ft,qt,fe)=>{const Kt=qt.split(".").reduce((Lt,jt)=>Lt==null?void 0:Lt[jt],Qe);if(Array.isArray(Kt))return Ft;if(Kt==null)return"";if(fe){const Lt=Kt&&typeof Kt=="object"&&"_seconds"in Kt?new Date(Kt._seconds*1e3):new Date(Kt);if(!isNaN(Lt.getTime())){if(fe==="timeago"){const jt=Math.floor((Date.now()-Lt.getTime())/6e4);if(jt<1)return"just now";if(jt<60)return`${jt}m ago`;const $t=Math.floor(jt/60);if($t<24)return`${$t}h ago`;const Se=Math.floor($t/24);return Se<7?`${Se}d ago`:Lt.toLocaleDateString()}return fe==="date"?Lt.toLocaleDateString():fe==="time"?Lt.toLocaleTimeString():Lt.toLocaleString()}}return typeof Kt=="string"?Kt.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t"):Kt!==void 0?JSON.stringify(Kt):""}),Ee=JSON.parse(ui);if(Ee.children&&(Ee.children=Ee.children.map(Ft=>{var Kt;const qt=Ft.fieldType||"text",fe=(Kt=Ft.content)==null?void 0:Kt.match(/^\{\{(\w+)\}\}$/);if(fe){const Lt=fe[1],jt=ye[Lt];if(jt)return qt==="dropdown"?{...Ft,type:"select",content:void 0,placeholder:Ft.fieldPlaceholder||`Select ${Lt}...`,options:jt.map($t=>({label:typeof $t=="object"?$t.label||$t.name||JSON.stringify($t):String($t),value:typeof $t=="object"?$t.value||$t.id||JSON.stringify($t):String($t)})),name:`${n}-${ht}-${Lt}`,className:Ft.className||"w-full text-sm bg-slate-700 border border-slate-500 text-white rounded-lg px-3 py-1.5"}:qt==="multiselect"?{...Ft,type:"container",content:void 0,className:Ft.className||"flex flex-col gap-1 w-full",children:[...Ft.fieldPlaceholder?[{type:"text",content:Ft.fieldPlaceholder,className:"text-xs text-gray-400 mb-1"}]:[{type:"text",content:`Select ${Lt}`,className:"text-xs text-gray-400 mb-1"}],...jt.map(($t,Se)=>({type:"checkbox",label:typeof $t=="object"?$t.label||$t.name||JSON.stringify($t):String($t),name:`${n}-${ht}-${Lt}-${Se}`,className:"text-sm text-gray-200"}))]}:qt==="image-grid"?{...Ft,type:"container",content:void 0,className:"flex flex-row gap-2 w-full overflow-x-auto py-1",children:jt.slice(0,10).map(($t,Se)=>({type:"image",src:typeof $t=="string"?$t:$t.url||$t.src||"",alt:`${Lt} ${Se+1}`,className:"w-12 h-12 rounded-lg object-cover flex-shrink-0"}))}:{...Ft,type:"container",content:void 0,className:"flex flex-col gap-1 w-full",children:[{type:"text",content:`⚠ "${Lt}" is an array (${jt.length} items)`,className:"text-xs font-semibold text-amber-400"},{type:"text",content:"Use ⚡ to fetch fields, then set type in sidebar",className:"text-xs text-amber-300 opacity-75"}]}}return qt==="image"&&Ft.content&&!Ft.content.includes("{{")?{...Ft,type:"image",src:Ft.content,alt:Ft.content,content:void 0,className:Ft.className||"w-full h-32 rounded-lg object-cover"}:Ft})),t.selectable&&e.sceneData._selectMode){const Ft=String(et.id||ht),qt=Array.isArray(e.sceneData._selIds)&&e.sceneData._selIds.map(String).includes(Ft),fe=Lt=>Lt?[Lt.text,Lt.content,...Lt.children?Lt.children.flatMap(fe):[]].filter(jt=>typeof jt=="string"&&jt.trim()&&!jt.includes("{{")):[],Kt=Ee.text||Ee.label||fe(Ee).slice(0,2).join(" — ")||String(et.id||ht);return N("button",{key:`${n}-item-${ht}`,className:(kt=t.selectionStyle)==null?void 0:kt.className,type:"button",onClick:()=>{e.setSceneData(Lt=>({...Lt,_selIds:(()=>{const jt=Array.isArray(Lt._selIds)?Lt._selIds.map(String):[];return jt.includes(Ft)?jt.filter($t=>$t!==Ft):[...jt,Ft]})()}))},style:{width:"100%",textAlign:"left",padding:"1rem 2rem",border:`1px solid ${qt?((St=t.selectionStyle)==null?void 0:St.selectedBorderColor)||e.cfg.colors.accent||"#fff":((Tt=t.selectionStyle)==null?void 0:Tt.borderColor)||e.cfg.colors.border}`,borderRadius:((Rt=t.selectionStyle)==null?void 0:Rt.borderRadius)||e.cfg.components.inputRadius||"8px",marginBottom:"0.5rem",backgroundColor:qt?((Et=t.selectionStyle)==null?void 0:Et.selectedBackgroundColor)||e.cfg.colors.surface:"transparent",color:e.cfg.colors.text,cursor:"pointer",fontFamily:"inherit",fontSize:"14px",fontWeight:qt?600:400,transition:"all 0.15s ease",outline:"none"},onMouseEnter:Lt=>{var $t,Se;const jt=Lt.currentTarget.firstElementChild;!qt&&jt&&(jt.style.borderColor=(($t=t.selectionStyle)==null?void 0:$t.selectedBorderColor)||e.cfg.colors.accent||"#fff",jt.style.backgroundColor=((Se=t.selectionStyle)==null?void 0:Se.selectedBackgroundColor)||e.cfg.colors.surface,Lt.currentTarget.style.borderColor=e.cfg.colors.textMuted)},onMouseLeave:Lt=>{var $t,Se,_n;const jt=Lt.currentTarget.firstElementChild;!qt&&jt&&(jt.style.borderColor=(($t=t.selectionStyle)==null?void 0:$t.borderColor)||e.cfg.colors.border,jt.style.backgroundColor="transparent"),Lt.currentTarget.style.borderColor=qt?((Se=t.selectionStyle)==null?void 0:Se.selectedBorderColor)||e.cfg.colors.accent||"#fff":((_n=t.selectionStyle)==null?void 0:_n.borderColor)||e.cfg.colors.border}},N("span",{"aria-hidden":!0,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"18px",height:"18px",marginRight:"10px",border:`1px solid ${qt?((re=t.selectionStyle)==null?void 0:re.selectedBorderColor)||e.cfg.colors.accent||"#fff":((oe=t.selectionStyle)==null?void 0:oe.borderColor)||e.cfg.colors.border}`,borderRadius:"5px",backgroundColor:qt?((Ot=t.selectionStyle)==null?void 0:Ot.selectedBorderColor)||e.cfg.colors.accent||"#fff":"transparent",color:qt?e.cfg.colors.background:"transparent",transition:"all 0.15s ease"}},qt?e.renderIcon("check",12):null),Kt)}return N("div",{key:`${n}-row-${ht}`,style:{display:"contents"},onClickCapture:()=>{e.rowContextRef&&(e.rowContextRef.current=et)}},e.renderComponent(Ee,ht,`${n}-item`))}return null};return k?Object.entries(K).map(([et,ht],kt)=>N("div",{key:`${n}-group-${kt}`,style:{display:"flex",flexDirection:"column",gap:"6px"}},N("div",{key:`${n}-group-hdr-${kt}`,style:{fontSize:"11px",fontWeight:600,letterSpacing:"0.05em",textTransform:"uppercase",color:e.cfg.colors.textMuted,padding:"10px 4px 2px"}},et),ht.map(Z))):ct.map(Z)})(),o&&(i==null?void 0:i.hasMore)&&N("div",{"data-bf-scroll-load":n,style:{height:"48px",width:"100%",display:"flex",alignItems:"center",justifyContent:"center",...f&&((i==null?void 0:i.page)??0)>0?{}:{pointerEvents:"none",opacity:.55}}},f&&((i==null?void 0:i.page)??0)>0?N("div",{style:{width:"18px",height:"18px",border:"2px solid rgba(128,128,128,0.25)",borderTopColor:e.cfg.colors.primary,borderRadius:"50%",animation:"bf-spin 0.7s linear infinite"}}):N("div",{style:{width:"18px",height:"2px",borderRadius:"2px",background:e.cfg.colors.textMuted,opacity:.4}})),r&&v.createElement("div",{className:"flex items-center justify-center gap-3 mt-4 py-2"},v.createElement("button",{onClick:()=>e.fetchListData(t.dataSource,n,i.page-1,i.limit),disabled:i.page===0||f,className:"flex items-center justify-center w-7 h-7 text-xs text-gray-400 hover:text-white hover:bg-[#222222] rounded border border-[#333333] disabled:opacity-30 disabled:cursor-not-allowed transition-all bg-transparent"},"◀"),N("span",{className:"text-xs text-gray-500"},`${i.page+1} / ${l}`),v.createElement("button",{onClick:()=>e.fetchListData(t.dataSource,n,i.page+1,i.limit),disabled:!i.hasMore||f,className:"flex items-center justify-center w-7 h-7 text-xs text-gray-400 hover:text-white hover:bg-[#222222] rounded border border-[#333333] disabled:opacity-30 disabled:cursor-not-allowed transition-all bg-transparent"},"▶")))}function ux({api:e,c:t,componentKey:n}){var ot,q,it,ct;const i=(ot=e.paginationState)==null?void 0:ot[n],r=t.pagination!==!1&&i&&i.total>i.limit,o=i?Math.ceil(i.total/i.limit):0,l=t.className||"w-full overflow-x-auto rounded-xl bg-gray-800/50 border border-gray-700/50",h=((q=e.parseClassNameResponsive)==null?void 0:q.call(e,l,n))??e.parseClassName(l);t.rawStyle&&Object.assign(h,t.rawStyle);const u=(it=e.loading)==null?void 0:it[n],f=(ct=e.listData)==null?void 0:ct[n],c=Array.isArray(f)?f:[],m=e.renderMode==="css-driven"?{"data-bf-r":`${e.scopeId}-${n}`}:{},y=!!t.sortable,x=t.sortMode==="client"?"client":"server",[_,p]=v.useState(null),[E,T]=v.useState({}),k=v.useMemo(()=>{if(!_||x!=="client")return c;const K=_.dir==="asc"?1:-1;return[...c].sort((Z,tt)=>{const st=Z[_.key],J=tt[_.key];return st===J?0:st==null?1:J==null?-1:String(st).localeCompare(String(J),void 0,{numeric:!0})*K})},[c,_,x]),A=K=>{if(!y&&!K.sortable)return;const Z=K.field||K.key;let tt=null;!_||_.key!==Z?tt={key:Z,dir:"asc"}:_.dir==="asc"&&(tt={key:Z,dir:"desc"}),p(tt),x==="server"&&tt&&e.fetchListData(t.dataSource,n,0,(i==null?void 0:i.limit)||t.pageSize||10,tt.key,tt.dir)},P=(K,Z)=>K.replace(/\{\{([\w.]+)(?:\s*\|\|\s*([^}]+))?\}\}/g,(tt,st,J)=>{const bt=st.split(".").reduce((et,ht)=>et==null?void 0:et[ht],Z);return bt==null||bt===""?J??"":String(bt)}),I=async(K,Z)=>{var J;const tt=E[K.id??""]||{},st=Z.filter(bt=>bt.editable&&tt[bt.field||bt.key]!==void 0);for(const bt of st){const et=bt.field||bt.key,ht=bt.onCellChange||t.onSave;if(!ht)continue;const kt=ht.replace(/\{\{field\}\}/g,JSON.stringify(tt[et]));if(kt.startsWith("sdk:"))await e.handleButtonClick(P(kt,K),{});else{const St=P(kt,K);await fetch(St,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[et]:tt[et]})})}}st.length&&((J=e.showToast)==null||J.call(e,(st.length===1,"Saved"),"success"),T(bt=>{const et={...bt};return delete et[K.id??""],et}),e.fetchListData(t.dataSource,n,(i==null?void 0:i.page)||0,(i==null?void 0:i.limit)||t.pageSize||10))},$=(K,Z,tt)=>{const st=Z.field||Z.key,J=K.id??"";T(bt=>({...bt,[J]:{...bt[J]||{},[st]:tt}}))},j=(K,Z)=>{const tt=K.field||K.key,st=Z.id??"",J=E[st]||{},bt=J[tt]!==void 0?J[tt]:Z[tt],et=K.fieldType||"text",ht={style:{width:"100%",background:"transparent",color:e.cfg.colors.text,border:`1px solid ${e.cfg.colors.border}`,borderRadius:"4px",padding:"2px 6px",fontSize:"13px",fontFamily:"inherit"}},kt=()=>{K.onCellChange&&J[K.key]!==void 0&&I(Z,[K])};if(et==="select"||et==="dropdown")return N("select",{...ht,value:String(bt??""),onChange:St=>{$(Z,K,St.target.value),K.onCellChange&&I(Z,[K])},children:(Array.isArray(K.fieldOptions)?K.fieldOptions:[]).map((St,Tt)=>N("option",{key:Tt,value:St.value,children:St.label??St.value}))});if(et==="multiselect"){const St=Array.isArray(bt)?bt:[];return N("div",{style:{display:"flex",flexDirection:"column",gap:2}},(Array.isArray(K.fieldOptions)?K.fieldOptions:[]).map((Tt,Rt)=>{const Et=St.includes(Tt.value);return N("label",{key:Rt,style:{display:"flex",alignItems:"center",gap:4,fontSize:12}},N("input",{type:"checkbox",checked:Et,onChange:re=>{const oe=re.target.checked?[...St,Tt.value]:St.filter(Ot=>Ot!==Tt.value);$(Z,K,oe),K.onCellChange&&I(Z,[K])}}),N("span",{children:Tt.label??Tt.value}))}))}return et==="image"?N("div",{style:{display:"flex",alignItems:"center",gap:6}},bt?N("img",{src:String(bt),alt:K.label,style:{width:32,height:32,borderRadius:4,objectFit:"cover"}}):null,N("input",{...ht,value:String(bt??""),placeholder:K.fieldPlaceholder||"Image URL",onChange:St=>$(Z,K,St.target.value),onBlur:kt})):N("input",{...ht,type:et==="number"?"number":"text",value:String(bt??""),placeholder:K.fieldPlaceholder||"",onChange:St=>$(Z,K,et==="number"?Number(St.target.value):St.target.value),onBlur:kt})},U=K=>{const Z=E[K.id??""];return!!Z&&Object.keys(Z).some(tt=>{var st;return(st=t.columns)==null?void 0:st.some(J=>J.editable&&(J.field||J.key)===tt)})},nt=!!t.onSave;return v.createElement("div",{key:n,className:l,style:h,"data-component-key":n,...m},u&&(t.loadingComponent?e.renderComponent(t.loadingComponent,0,n):v.createElement("div",{className:"flex justify-center py-4"},N("div",{className:"w-6 h-6 border-2 border-primary border-t-transparent rounded-full animate-spin"}))),v.createElement("table",{className:"w-full"},Array.isArray(t.columns)&&v.createElement("thead",{className:"bg-gray-900/50"},v.createElement("tr",{},t.columns.map(K=>v.createElement("th",{key:K.key,className:"px-4 py-3 text-left text-sm font-medium text-gray-400"},(y||K.sortable)&&K.sortable!==!1?(()=>{const Z=_&&_.key===K.key?_:null;return N("button",{type:"button",onClick:()=>A(K),style:{background:"none",border:"none",color:"inherit",fontFamily:"inherit",fontSize:"inherit",cursor:"pointer",padding:0},children:`${K.label||K.key}${Z?Z.dir==="asc"?" ↑":" ↓":" ⇅"}`})})():K.label||K.key)),nt&&v.createElement("th",{key:"__save",className:"px-4 py-3 text-left text-sm font-medium text-gray-400"},""))),v.createElement("tbody",{className:"divide-y divide-gray-700/50"},k.map((K,Z)=>{var tt;return v.createElement("tr",{key:K.id??Z,className:"hover:bg-gray-700/30 transition-colors"},(tt=t.columns)==null?void 0:tt.map(st=>v.createElement("td",{key:st.key,className:"px-4 py-3 text-sm text-white"},st.editable?j(st,K):st.template?P(st.template,K):(()=>{const bt=(st.field||st.key).split(".").reduce((et,ht)=>et==null?void 0:et[ht],K);return bt==null||bt===""?"":String(bt)})())),nt&&v.createElement("td",{key:"__save-cell",className:"px-4 py-3 text-sm"},N("button",{type:"button",disabled:!U(K)||u,onClick:()=>I(K,t.columns||[]),className:"px-3 py-1 rounded text-xs font-semibold border transition-all disabled:opacity-40 disabled:cursor-not-allowed",style:{background:U(K)?e.cfg.colors.primary:"transparent",color:U(K)?"#ffffff":e.cfg.colors.textSecondary,borderColor:e.cfg.colors.border},children:"Save"})))}))),r&&v.createElement("div",{className:"flex items-center justify-center gap-3 mt-4 py-2"},v.createElement("button",{onClick:()=>e.fetchListData(t.dataSource,n,i.page-1,i.limit),disabled:i.page===0||u,className:"flex items-center justify-center w-7 h-7 text-xs text-gray-400 hover:text-white hover:bg-[#222222] rounded border border-[#333333] disabled:opacity-30 disabled:cursor-not-allowed transition-all bg-transparent"},"◀"),N("span",{className:"text-xs text-gray-500"},`${i.page+1} / ${o}`),v.createElement("button",{onClick:()=>e.fetchListData(t.dataSource,n,i.page+1,i.limit),disabled:!i.hasMore||u,className:"flex items-center justify-center w-7 h-7 text-xs text-gray-400 hover:text-white hover:bg-[#222222] rounded border border-[#333333] disabled:opacity-30 disabled:cursor-not-allowed transition-all bg-transparent"},"▶")))}function dx(e,t,n){return v.createElement(ux,{api:e,c:t,componentKey:n})}function de(e){var t=e.width,n=e.height;if(t<0)throw new Error("Negative width is not allowed for Size");if(n<0)throw new Error("Negative height is not allowed for Size");return{width:t,height:n}}function Is(e,t){return e.width===t.width&&e.height===t.height}var fx=function(){function e(t){var n=this;this._resolutionListener=function(){return n._onResolutionChanged()},this._resolutionMediaQueryList=null,this._observers=[],this._window=t,this._installResolutionListener()}return e.prototype.dispose=function(){this._uninstallResolutionListener(),this._window=null},Object.defineProperty(e.prototype,"value",{get:function(){return this._window.devicePixelRatio},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(t){var n=this,i={next:t};return this._observers.push(i),{unsubscribe:function(){n._observers=n._observers.filter(function(r){return r!==i})}}},e.prototype._installResolutionListener=function(){if(this._resolutionMediaQueryList!==null)throw new Error("Resolution listener is already installed");var t=this._window.devicePixelRatio;this._resolutionMediaQueryList=this._window.matchMedia("all and (resolution: ".concat(t,"dppx)")),this._resolutionMediaQueryList.addListener(this._resolutionListener)},e.prototype._uninstallResolutionListener=function(){this._resolutionMediaQueryList!==null&&(this._resolutionMediaQueryList.removeListener(this._resolutionListener),this._resolutionMediaQueryList=null)},e.prototype._reinstallResolutionListener=function(){this._uninstallResolutionListener(),this._installResolutionListener()},e.prototype._onResolutionChanged=function(){var t=this;this._observers.forEach(function(n){return n.next(t._window.devicePixelRatio)}),this._reinstallResolutionListener()},e}();function mx(e){return new fx(e)}var px=function(){function e(t,n,i){var r;this._canvasElement=null,this._bitmapSizeChangedListeners=[],this._suggestedBitmapSize=null,this._suggestedBitmapSizeChangedListeners=[],this._devicePixelRatioObservable=null,this._canvasElementResizeObserver=null,this._canvasElement=t,this._canvasElementClientSize=de({width:this._canvasElement.clientWidth,height:this._canvasElement.clientHeight}),this._transformBitmapSize=n??function(o){return o},this._allowResizeObserver=(r=i==null?void 0:i.allowResizeObserver)!==null&&r!==void 0?r:!0,this._chooseAndInitObserver()}return e.prototype.dispose=function(){var t,n;if(this._canvasElement===null)throw new Error("Object is disposed");(t=this._canvasElementResizeObserver)===null||t===void 0||t.disconnect(),this._canvasElementResizeObserver=null,(n=this._devicePixelRatioObservable)===null||n===void 0||n.dispose(),this._devicePixelRatioObservable=null,this._suggestedBitmapSizeChangedListeners.length=0,this._bitmapSizeChangedListeners.length=0,this._canvasElement=null},Object.defineProperty(e.prototype,"canvasElement",{get:function(){if(this._canvasElement===null)throw new Error("Object is disposed");return this._canvasElement},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"canvasElementClientSize",{get:function(){return this._canvasElementClientSize},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bitmapSize",{get:function(){return de({width:this.canvasElement.width,height:this.canvasElement.height})},enumerable:!1,configurable:!0}),e.prototype.resizeCanvasElement=function(t){this._canvasElementClientSize=de(t),this.canvasElement.style.width="".concat(this._canvasElementClientSize.width,"px"),this.canvasElement.style.height="".concat(this._canvasElementClientSize.height,"px"),this._invalidateBitmapSize()},e.prototype.subscribeBitmapSizeChanged=function(t){this._bitmapSizeChangedListeners.push(t)},e.prototype.unsubscribeBitmapSizeChanged=function(t){this._bitmapSizeChangedListeners=this._bitmapSizeChangedListeners.filter(function(n){return n!==t})},Object.defineProperty(e.prototype,"suggestedBitmapSize",{get:function(){return this._suggestedBitmapSize},enumerable:!1,configurable:!0}),e.prototype.subscribeSuggestedBitmapSizeChanged=function(t){this._suggestedBitmapSizeChangedListeners.push(t)},e.prototype.unsubscribeSuggestedBitmapSizeChanged=function(t){this._suggestedBitmapSizeChangedListeners=this._suggestedBitmapSizeChangedListeners.filter(function(n){return n!==t})},e.prototype.applySuggestedBitmapSize=function(){if(this._suggestedBitmapSize!==null){var t=this._suggestedBitmapSize;this._suggestedBitmapSize=null,this._resizeBitmap(t),this._emitSuggestedBitmapSizeChanged(t,this._suggestedBitmapSize)}},e.prototype._resizeBitmap=function(t){var n=this.bitmapSize;Is(n,t)||(this.canvasElement.width=t.width,this.canvasElement.height=t.height,this._emitBitmapSizeChanged(n,t))},e.prototype._emitBitmapSizeChanged=function(t,n){var i=this;this._bitmapSizeChangedListeners.forEach(function(r){return r.call(i,t,n)})},e.prototype._suggestNewBitmapSize=function(t){var n=this._suggestedBitmapSize,i=de(this._transformBitmapSize(t,this._canvasElementClientSize)),r=Is(this.bitmapSize,i)?null:i;n===null&&r===null||n!==null&&r!==null&&Is(n,r)||(this._suggestedBitmapSize=r,this._emitSuggestedBitmapSizeChanged(n,r))},e.prototype._emitSuggestedBitmapSizeChanged=function(t,n){var i=this;this._suggestedBitmapSizeChangedListeners.forEach(function(r){return r.call(i,t,n)})},e.prototype._chooseAndInitObserver=function(){var t=this;if(!this._allowResizeObserver){this._initDevicePixelRatioObservable();return}yx().then(function(n){return n?t._initResizeObserver():t._initDevicePixelRatioObservable()})},e.prototype._initDevicePixelRatioObservable=function(){var t=this;if(this._canvasElement!==null){var n=Yu(this._canvasElement);if(n===null)throw new Error("No window is associated with the canvas");this._devicePixelRatioObservable=mx(n),this._devicePixelRatioObservable.subscribe(function(){return t._invalidateBitmapSize()}),this._invalidateBitmapSize()}},e.prototype._invalidateBitmapSize=function(){var t,n;if(this._canvasElement!==null){var i=Yu(this._canvasElement);if(i!==null){var r=(n=(t=this._devicePixelRatioObservable)===null||t===void 0?void 0:t.value)!==null&&n!==void 0?n:i.devicePixelRatio,o=this._canvasElement.getClientRects(),l=o[0]!==void 0?vx(o[0],r):de({width:this._canvasElementClientSize.width*r,height:this._canvasElementClientSize.height*r});this._suggestNewBitmapSize(l)}}},e.prototype._initResizeObserver=function(){var t=this;this._canvasElement!==null&&(this._canvasElementResizeObserver=new ResizeObserver(function(n){var i=n.find(function(l){return l.target===t._canvasElement});if(!(!i||!i.devicePixelContentBoxSize||!i.devicePixelContentBoxSize[0])){var r=i.devicePixelContentBoxSize[0],o=de({width:r.inlineSize,height:r.blockSize});t._suggestNewBitmapSize(o)}}),this._canvasElementResizeObserver.observe(this._canvasElement,{box:"device-pixel-content-box"}))},e}();function gx(e,t){return new px(e,t.transform,t.options)}function Yu(e){return e.ownerDocument.defaultView}function yx(){return new Promise(function(e){var t=new ResizeObserver(function(n){e(n.every(function(i){return"devicePixelContentBoxSize"in i})),t.disconnect()});t.observe(document.body,{box:"device-pixel-content-box"})}).catch(function(){return!1})}function vx(e,t){return de({width:Math.round(e.left*t+e.width*t)-Math.round(e.left*t),height:Math.round(e.top*t+e.height*t)-Math.round(e.top*t)})}var bx=function(){function e(t,n,i){if(n.width===0||n.height===0)throw new TypeError("Rendering target could only be created on a media with positive width and height");if(this._mediaSize=n,i.width===0||i.height===0)throw new TypeError("Rendering target could only be created using a bitmap with positive integer width and height");this._bitmapSize=i,this._context=t}return e.prototype.useMediaCoordinateSpace=function(t){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),this._context.scale(this._horizontalPixelRatio,this._verticalPixelRatio),t({context:this._context,mediaSize:this._mediaSize})}finally{this._context.restore()}},e.prototype.useBitmapCoordinateSpace=function(t){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),t({context:this._context,mediaSize:this._mediaSize,bitmapSize:this._bitmapSize,horizontalPixelRatio:this._horizontalPixelRatio,verticalPixelRatio:this._verticalPixelRatio})}finally{this._context.restore()}},Object.defineProperty(e.prototype,"_horizontalPixelRatio",{get:function(){return this._bitmapSize.width/this._mediaSize.width},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_verticalPixelRatio",{get:function(){return this._bitmapSize.height/this._mediaSize.height},enumerable:!1,configurable:!0}),e}();function zs(e,t){var n=e.canvasElementClientSize;if(n.width===0||n.height===0)return null;var i=e.bitmapSize;if(i.width===0||i.height===0)return null;var r=e.canvasElement.getContext("2d",t);return r===null?null:new bx(r,n,i)}/*!
11
11
  * @license
12
12
  * TradingView Lightweight Charts™ v5.2.1
13
13
  * Copyright (c) 2026 TradingView, Inc.
14
14
  * Licensed under Apache License 2.0 https://www.apache.org/licenses/LICENSE-2.0
15
- */const Ff={title:"",visible:!0,hitTestTolerance:3,lastValueVisible:!0,priceLineVisible:!0,priceLineSource:0,priceLineWidth:1,priceLineColor:"",priceLineStyle:2,baseLineVisible:!0,baseLineWidth:1,baseLineColor:"#B2B5BE",baseLineStyle:0,priceFormat:{type:"price",precision:2,minMove:.01}};var Dh,Lh;function _n(e,t){const n=function(s,i){switch(s){case 0:default:return[];case 1:return[i,i];case 2:return[2*i,2*i];case 3:return[6*i,6*i];case 4:return[i,4*i]}}(t,e.lineWidth);return e.setLineDash(n),n}function Bf(e,t,n,s){e.beginPath();const i=e.lineWidth%2?.5:0;e.moveTo(n,t+i),e.lineTo(s,t+i),e.stroke()}function pe(e,t){if(!e)throw new Error("Assertion failed"+(t?": "+t:""))}function Re(e){if(e===void 0)throw new Error("Value is undefined");return e}function K(e){if(e===null)throw new Error("Value is null");return e}function Mn(e){return K(Re(e))}(function(e){e[e.Simple=0]="Simple",e[e.WithSteps=1]="WithSteps",e[e.Curved=2]="Curved"})(Dh||(Dh={})),function(e){e[e.Solid=0]="Solid",e[e.Dotted=1]="Dotted",e[e.Dashed=2]="Dashed",e[e.LargeDashed=3]="LargeDashed",e[e.SparseDotted=4]="SparseDotted"}(Lh||(Lh={}));class Zt{constructor(){this.t=[]}i(t,n,s){const i={h:t,l:n,o:s===!0};this.t.push(i)}_(t){const n=this.t.findIndex(s=>t===s.h);n>-1&&this.t.splice(n,1)}u(t){this.t=this.t.filter(n=>n.l!==t)}p(t,n,s){const i=[...this.t];this.t=this.t.filter(r=>!r.o),i.forEach(r=>r.h(t,n,s))}v(){return this.t.length>0}m(){this.t=[]}}function $e(e,...t){for(const n of t)for(const s in n)n[s]!==void 0&&Object.prototype.hasOwnProperty.call(n,s)&&!["__proto__","constructor","prototype"].includes(s)&&(typeof n[s]!="object"||e[s]===void 0||Array.isArray(n[s])?e[s]=n[s]:$e(e[s],n[s]));return e}function js(e){return typeof e=="number"&&isFinite(e)}function $i(e){return typeof e=="number"&&e%1==0}function Bi(e){return typeof e=="string"}function or(e){return typeof e=="boolean"}function an(e){const t=e;if(!t||typeof t!="object")return t;let n,s,i;for(s in n=Array.isArray(t)?[]:{},t)t.hasOwnProperty(s)&&(i=t[s],n[s]=i&&typeof i=="object"?an(i):i);return n}function zh(e){return e!==null}function Ni(e){return e===null?void 0:e}const Wf="-apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif";function Ir(e,t,n){return t===void 0&&(t=Wf),`${n=n!==void 0?`${n} `:""}${e}px ${t}`}class Cv{constructor(t){this.M={S:1,C:5,P:NaN,k:"",T:"",R:"",D:"",I:0,V:0,B:0,A:0,L:0},this.O=t}N(){const t=this.M,n=this.F(),s=this.W();return t.P===n&&t.T===s||(t.P=n,t.T=s,t.k=Ir(n,s),t.A=2.5/12*n,t.I=t.A,t.V=n/12*t.C,t.B=n/12*t.C,t.L=0),t.R=this.H(),t.D=this.U(),this.M}H(){return this.O.N().layout.textColor}U(){return this.O.$()}F(){return this.O.N().layout.fontSize}W(){return this.O.N().layout.fontFamily}}function Po(e){return e<0?0:e>255?255:Math.round(e)||0}function Fh(e){return .199*e[0]+.687*e[1]+.114*e[2]}class kv{constructor(t,n){this.j=new Map,this.q=t,n&&(this.j=n)}Y(t,n){if(t==="transparent")return t;const s=this.K(t),i=s[3];return`rgba(${s[0]}, ${s[1]}, ${s[2]}, ${n*i})`}G(t){const n=this.K(t);return{Z:`rgb(${n[0]}, ${n[1]}, ${n[2]})`,X:Fh(n)>160?"black":"white"}}J(t){return Fh(this.K(t))}tt(t,n,s){const[i,r,o,l]=this.K(t),[c,h,a,u]=this.K(n),f=[Po(i+s*(c-i)),Po(r+s*(h-r)),Po(o+s*(a-o)),(p=l+s*(u-l),p<=0||p>1?Math.min(Math.max(p,0),1):Math.round(1e4*p)/1e4)];var p;return`rgba(${f[0]}, ${f[1]}, ${f[2]}, ${f[3]})`}K(t){const n=this.j.get(t);if(n)return n;const s=function(o){const l=document.createElement("div");l.style.display="none",document.body.appendChild(l),l.style.color=o;const c=window.getComputedStyle(l).color;return document.body.removeChild(l),c}(t),i=s.match(/^rgba?\s*\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d*\.?\d+))?\)$/);if(!i){if(this.q.length)for(const o of this.q){const l=o(t);if(l)return this.j.set(t,l),l}throw new Error(`Failed to parse color: ${t}`)}const r=[parseInt(i[1],10),parseInt(i[2],10),parseInt(i[3],10),i[4]?parseFloat(i[4]):1];return this.j.set(t,r),r}}class Mv{constructor(){this.it=[]}nt(t){this.it=t}st(t,n,s){this.it.forEach(i=>{i.st(t,n,s)})}}class Nn{st(t,n,s){t.useBitmapCoordinateSpace(i=>this.et(i,n,s))}}class Ev extends Nn{constructor(){super(...arguments),this.rt=null}ht(t){this.rt=t}et({context:t,horizontalPixelRatio:n,verticalPixelRatio:s}){if(this.rt===null||this.rt.lt===null)return;const i=this.rt.lt,r=this.rt,o=Math.max(1,Math.floor(n))%2/2,l=c=>{t.beginPath();for(let h=i.to-1;h>=i.from;--h){const a=r.ot[h],u=Math.round(a._t*n)+o,f=a.ut*s,p=c*s+o;t.moveTo(u,f),t.arc(u,f,p,0,2*Math.PI)}t.fill()};r.ct>0&&(t.fillStyle=r.dt,l(r.ft+r.ct)),t.fillStyle=r.vt,l(r.ft)}}function Tv(){return{ot:[{_t:0,ut:0,wt:0,Mt:0}],vt:"",dt:"",ft:0,ct:0,lt:null}}const Av={from:0,to:1};class Rv{constructor(t,n,s){this.gt=new Mv,this.bt=[],this.St=[],this.xt=!0,this.O=t,this.Ct=n,this.yt=s,this.gt.nt(this.bt)}Pt(t){this.kt(),this.xt=!0}Tt(){return this.xt&&(this.Rt(),this.xt=!1),this.gt}kt(){const t=this.yt.Dt();t.length!==this.bt.length&&(this.St=t.map(Tv),this.bt=this.St.map(n=>{const s=new Ev;return s.ht(n),s}),this.gt.nt(this.bt))}Rt(){const t=this.Ct.N().mode===2||!this.Ct.It(),n=this.yt.Vt(),s=this.Ct.Bt(),i=this.O.Et();this.kt(),n.forEach((r,o)=>{const l=this.St[o],c=r.At(s),h=r.Lt();!t&&c!==null&&r.It()&&h!==null?(l.vt=c.zt,l.ft=c.ft,l.ct=c.Ot,l.ot[0].Mt=c.Mt,l.ot[0].ut=r.Ft().Nt(c.Mt,h.Wt),l.dt=c.Ht??this.O.Ut(l.ot[0].ut/r.Ft().$t()),l.ot[0].wt=s,l.ot[0]._t=i.jt(s),l.lt=Av):l.lt=null})}}class Pv extends Nn{constructor(t){super(),this.qt=t}et({context:t,bitmapSize:n,horizontalPixelRatio:s,verticalPixelRatio:i}){if(this.qt===null)return;const r=this.qt.Yt.It,o=this.qt.Kt.It;if(!r&&!o)return;const l=Math.round(this.qt._t*s),c=Math.round(this.qt.ut*i);t.lineCap="butt",r&&l>=0&&(t.lineWidth=Math.floor(this.qt.Yt.ct*s),t.strokeStyle=this.qt.Yt.R,t.fillStyle=this.qt.Yt.R,_n(t,this.qt.Yt.Gt),function(h,a,u,f){h.beginPath();const p=h.lineWidth%2?.5:0;h.moveTo(a+p,u),h.lineTo(a+p,f),h.stroke()}(t,l,0,n.height)),o&&c>=0&&(t.lineWidth=Math.floor(this.qt.Kt.ct*i),t.strokeStyle=this.qt.Kt.R,t.fillStyle=this.qt.Kt.R,_n(t,this.qt.Kt.Gt),Bf(t,c,0,n.width))}}class _v{constructor(t,n){this.xt=!0,this.Zt={Yt:{ct:1,Gt:0,R:"",It:!1},Kt:{ct:1,Gt:0,R:"",It:!1},_t:0,ut:0},this.Xt=new Pv(this.Zt),this.Jt=t,this.yt=n}Pt(){this.xt=!0}Tt(t){return this.xt&&(this.Rt(),this.xt=!1),this.Xt}Rt(){const t=this.Jt.It(),n=this.yt.Qt().N().crosshair,s=this.Zt;if(n.mode===2)return s.Kt.It=!1,void(s.Yt.It=!1);s.Kt.It=t&&this.Jt.ti(this.yt),s.Yt.It=t&&this.Jt.ii(),s.Kt.ct=n.horzLine.width,s.Kt.Gt=n.horzLine.style,s.Kt.R=n.horzLine.color,s.Yt.ct=n.vertLine.width,s.Yt.Gt=n.vertLine.style,s.Yt.R=n.vertLine.color,s._t=this.Jt.ni(),s.ut=this.Jt.si()}}function $v(e,t,n,s,i,r){e.fillRect(t+r,n,s-2*r,r),e.fillRect(t+r,n+i-r,s-2*r,r),e.fillRect(t,n,r,i),e.fillRect(t+s-r,n,r,i)}function Yr(e,t,n,s,i,r){e.save(),e.globalCompositeOperation="copy",e.fillStyle=r,e.fillRect(t,n,s,i),e.restore()}function Bh(e,t,n,s,i,r){e.beginPath(),e.roundRect?e.roundRect(t,n,s,i,r):(e.lineTo(t+s-r[1],n),r[1]!==0&&e.arcTo(t+s,n,t+s,n+r[1],r[1]),e.lineTo(t+s,n+i-r[2]),r[2]!==0&&e.arcTo(t+s,n+i,t+s-r[2],n+i,r[2]),e.lineTo(t+r[3],n+i),r[3]!==0&&e.arcTo(t,n+i,t,n+i-r[3],r[3]),e.lineTo(t,n+r[0]),r[0]!==0&&e.arcTo(t,n,t+r[0],n,r[0]))}function Wh(e,t,n,s,i,r,o=0,l=[0,0,0,0],c=""){if(e.save(),!o||!c||c===r)return Bh(e,t,n,s,i,l),e.fillStyle=r,e.fill(),void e.restore();const h=o/2;var a;Bh(e,t+h,n+h,s-o,i-o,(a=-h,l.map(u=>u===0?u:u+a))),r!=="transparent"&&(e.fillStyle=r,e.fill()),c!=="transparent"&&(e.lineWidth=o,e.strokeStyle=c,e.closePath(),e.stroke()),e.restore()}function jf(e,t,n,s,i,r,o){e.save(),e.globalCompositeOperation="copy";const l=e.createLinearGradient(0,0,0,i);l.addColorStop(0,r),l.addColorStop(1,o),e.fillStyle=l,e.fillRect(t,n,s,i),e.restore()}class jh{constructor(t,n){this.ht(t,n)}ht(t,n){this.qt=t,this.ei=n}$t(t,n){return this.qt.It?t.P+t.A+t.I:0}st(t,n,s,i){if(!this.qt.It||this.qt.ri.length===0)return;const r=this.qt.R,o=this.ei.Z,l=t.useBitmapCoordinateSpace(c=>{const h=c.context;h.font=n.k;const a=this.hi(c,n,s,i),u=a.ai;return a.li?Wh(h,u.oi,u._i,u.ui,u.ci,o,u.di,[u.ft,0,0,u.ft],o):Wh(h,u.fi,u._i,u.ui,u.ci,o,u.di,[0,u.ft,u.ft,0],o),this.qt.pi&&(h.fillStyle=r,h.fillRect(u.fi,u.mi,u.wi-u.fi,u.Mi)),this.qt.gi&&(h.fillStyle=n.D,h.fillRect(a.li?u.bi-u.di:0,u._i,u.di,u.Si-u._i)),a});t.useMediaCoordinateSpace(({context:c})=>{const h=l.xi;c.font=n.k,c.textAlign=l.li?"right":"left",c.textBaseline="middle",c.fillStyle=r,c.fillText(this.qt.ri,h.Ci,(h._i+h.Si)/2+h.yi)})}hi(t,n,s,i){const{context:r,bitmapSize:o,mediaSize:l,horizontalPixelRatio:c,verticalPixelRatio:h}=t,a=this.qt.pi||!this.qt.Pi?n.C:0,u=this.qt.ki?n.S:0,f=n.A+this.ei.Ti,p=n.I+this.ei.Ri,g=n.V,d=n.B,w=this.qt.ri,C=n.P,x=s.Di(r,w),k=Math.ceil(s.Ii(r,w)),S=C+f+p,T=n.S+g+d+k+a,P=Math.max(1,Math.floor(h));let I=Math.round(S*h);I%2!=P%2&&(I+=1);const L=u>0?Math.max(1,Math.floor(u*c)):0,O=Math.round(T*c),H=Math.round(a*c),U=this.ei.Vi??this.ei.Bi??this.ei.Ei,q=Math.round(U*h)-Math.floor(.5*h),X=Math.floor(q+P/2-I/2),j=X+I,D=i==="right",V=D?l.width-u:u,J=D?o.width-L:L;let nt,it,Q;return D?(nt=J-O,it=J-H,Q=V-a-g-u):(nt=J+O,it=J+H,Q=V+a+g),{li:D,ai:{_i:X,mi:q,Si:j,ui:O,ci:I,ft:2*c,di:L,oi:nt,fi:J,wi:it,Mi:P,bi:o.width},xi:{_i:X/h,Si:j/h,Ci:Q,yi:x}}}}class Xr{constructor(t){this.Ai={Ei:0,Z:"#000",Ri:0,Ti:0},this.Li={ri:"",It:!1,pi:!0,Pi:!1,Ht:"",R:"#FFF",gi:!1,ki:!1},this.zi={ri:"",It:!1,pi:!1,Pi:!0,Ht:"",R:"#FFF",gi:!0,ki:!0},this.xt=!0,this.Oi=new(t||jh)(this.Li,this.Ai),this.Ni=new(t||jh)(this.zi,this.Ai)}ri(){return this.Fi(),this.Li.ri}Ei(){return this.Fi(),this.Ai.Ei}Pt(){this.xt=!0}$t(t,n=!1){return Math.max(this.Oi.$t(t,n),this.Ni.$t(t,n))}Wi(){return this.Ai.Vi??null}Hi(){return this.Ai.Vi??this.Ai.Bi??this.Ei()}Ui(t){this.Ai.Bi=t??void 0}$i(){return this.Fi(),this.Li.It||this.zi.It}ji(){return this.Fi(),this.Li.It}Tt(t){return this.Fi(),this.Li.pi=this.Li.pi&&t.N().ticksVisible,this.zi.pi=this.zi.pi&&t.N().ticksVisible,this.Oi.ht(this.Li,this.Ai),this.Ni.ht(this.zi,this.Ai),this.Oi}qi(){return this.Fi(),this.Oi.ht(this.Li,this.Ai),this.Ni.ht(this.zi,this.Ai),this.Ni}Fi(){this.xt&&(this.Li.pi=!0,this.zi.pi=!1,this.Yi(this.Li,this.zi,this.Ai))}}class Nv extends Xr{constructor(t,n,s){super(),this.Jt=t,this.Ki=n,this.Gi=s}Yi(t,n,s){if(t.It=!1,this.Jt.N().mode===2)return;const i=this.Jt.N().horzLine;if(!i.labelVisible)return;const r=this.Ki.Lt();if(!this.Jt.It()||this.Ki.Zi()||r===null)return;const o=this.Ki.Xi().G(i.labelBackgroundColor);s.Z=o.Z,t.R=o.X;const l=2/12*this.Ki.P();s.Ti=l,s.Ri=l;const c=this.Gi(this.Ki);s.Ei=c.Ei,t.ri=this.Ki.Ji(c.Mt,r),t.It=!0}}const Iv=/[1-9]/g;class Vf{constructor(){this.qt=null}ht(t){this.qt=t}st(t,n){if(this.qt===null||this.qt.It===!1||this.qt.ri.length===0)return;const s=t.useMediaCoordinateSpace(({context:f})=>(f.font=n.k,Math.round(n.Qi.Ii(f,K(this.qt).ri,Iv))));if(s<=0)return;const i=n.tn,r=s+2*i,o=r/2,l=this.qt.nn;let c=this.qt.Ei,h=Math.floor(c-o)+.5;h<0?(c+=Math.abs(0-h),h=Math.floor(c-o)+.5):h+r>l&&(c-=Math.abs(l-(h+r)),h=Math.floor(c-o)+.5);const a=h+r,u=Math.ceil(0+n.S+n.C+n.A+n.P+n.I);t.useBitmapCoordinateSpace(({context:f,horizontalPixelRatio:p,verticalPixelRatio:g})=>{const d=K(this.qt);f.fillStyle=d.Z;const w=Math.round(h*p),C=Math.round(0*g),x=Math.round(a*p),k=Math.round(u*g),S=Math.round(2*p);if(f.beginPath(),f.moveTo(w,C),f.lineTo(w,k-S),f.arcTo(w,k,w+S,k,S),f.lineTo(x-S,k),f.arcTo(x,k,x,k-S,S),f.lineTo(x,C),f.fill(),d.pi){const T=Math.round(d.Ei*p),P=C,I=Math.round((P+n.C)*g);f.fillStyle=d.R;const L=Math.max(1,Math.floor(p)),O=Math.floor(.5*p);f.fillRect(T-O,P,L,I-P)}}),t.useMediaCoordinateSpace(({context:f})=>{const p=K(this.qt),g=0+n.S+n.C+n.A+n.P/2;f.font=n.k,f.textAlign="left",f.textBaseline="middle",f.fillStyle=p.R;const d=n.Qi.Di(f,"Apr0");f.translate(h+i,g+d),f.fillText(p.ri,0,0)})}}class Dv{constructor(t,n,s){this.xt=!0,this.Xt=new Vf,this.Zt={It:!1,Z:"#4c525e",R:"white",ri:"",nn:0,Ei:NaN,pi:!0},this.Ct=t,this.sn=n,this.Gi=s}Pt(){this.xt=!0}Tt(){return this.xt&&(this.Rt(),this.xt=!1),this.Xt.ht(this.Zt),this.Xt}Rt(){const t=this.Zt;if(t.It=!1,this.Ct.N().mode===2)return;const n=this.Ct.N().vertLine;if(!n.labelVisible)return;const s=this.sn.Et();if(s.Zi())return;t.nn=s.nn();const i=this.Gi();if(i===null)return;t.Ei=i.Ei;const r=s.en(this.Ct.Bt());t.ri=s.rn(K(r)),t.It=!0;const o=this.sn.Xi().G(n.labelBackgroundColor);t.Z=o.Z,t.R=o.X,t.pi=s.N().ticksVisible}}class Of{constructor(){this.hn=null,this.an=0}ln(){return this.an}_n(t){this.an=t}Ft(){return this.hn}un(t){this.hn=t}cn(t){return[]}dn(){return[]}It(){return!0}}var Vh;(function(e){e[e.Normal=0]="Normal",e[e.Magnet=1]="Magnet",e[e.Hidden=2]="Hidden",e[e.MagnetOHLC=3]="MagnetOHLC"})(Vh||(Vh={}));class Lv extends Of{constructor(t,n){super(),this.yt=null,this.fn=NaN,this.pn=0,this.vn=!1,this.mn=new Map,this.wn=!1,this.Mn=new WeakMap,this.gn=new WeakMap,this.bn=NaN,this.Sn=NaN,this.xn=NaN,this.Cn=NaN,this.sn=t,this.yn=n,this.Pn=((i,r)=>o=>{const l=r(),c=i();if(o===K(this.yt).kn())return{Mt:c,Ei:l};{const h=K(o.Lt());return{Mt:o.Tn(l,h),Ei:l}}})(()=>this.fn,()=>this.Sn);const s=((i,r)=>()=>{const o=this.sn.Et().Rn(i()),l=r();return o&&Number.isFinite(l)?{wt:o,Ei:l}:null})(()=>this.pn,()=>this.ni());this.Dn=new Dv(this,t,s)}N(){return this.yn}In(t,n){this.xn=t,this.Cn=n}Vn(){this.xn=NaN,this.Cn=NaN}Bn(){return this.xn}En(){return this.Cn}An(t,n,s){this.wn||(this.wn=!0),this.vn=!0,this.Ln(t,n,s)}Bt(){return this.pn}ni(){return this.bn}si(){return this.Sn}It(){return this.vn}zn(){this.vn=!1,this.On(),this.fn=NaN,this.bn=NaN,this.Sn=NaN,this.yt=null,this.Vn(),this.Nn()}Fn(t){if(!this.yn.doNotSnapToHiddenSeriesIndices)return t;const n=this.sn,s=n.Et();let i=null,r=null;for(const h of n.Wn()){const a=h.Un().Hn(t,-1);if(a){if(a.$n===t)return t;(i===null||a.$n>i)&&(i=a.$n)}const u=h.Un().Hn(t,1);if(u){if(u.$n===t)return t;(r===null||u.$n<r)&&(r=u.$n)}}const o=[i,r].filter(zh);if(o.length===0)return t;const l=s.jt(t),c=o.map(h=>Math.abs(l-s.jt(h)));return o[c.indexOf(Math.min(...c))]}jn(t){let n=this.Mn.get(t);n||(n=new _v(this,t),this.Mn.set(t,n));let s=this.gn.get(t);return s||(s=new Rv(this.sn,this,t),this.gn.set(t,s)),[n,s]}ti(t){return t===this.yt&&this.yn.horzLine.visible}ii(){return this.yn.vertLine.visible}qn(t,n){this.vn&&this.yt===t||this.mn.clear();const s=[];return this.yt===t&&s.push(this.Yn(this.mn,n,this.Pn)),s}dn(){return this.vn?[this.Dn]:[]}Kn(){return this.yt}Nn(){this.sn.Gn().forEach(t=>{var n,s;(n=this.Mn.get(t))==null||n.Pt(),(s=this.gn.get(t))==null||s.Pt()}),this.mn.forEach(t=>t.Pt()),this.Dn.Pt()}Zn(t){return t&&!t.kn().Zi()?t.kn():null}Ln(t,n,s){this.Xn(t,n,s)&&this.Nn()}Xn(t,n,s){const i=this.bn,r=this.Sn,o=this.fn,l=this.pn,c=this.yt,h=this.Zn(s);this.pn=t,this.bn=isNaN(t)?NaN:this.sn.Et().jt(t),this.yt=s;const a=h!==null?h.Lt():null;return h!==null&&a!==null?(this.fn=n,this.Sn=h.Nt(n,a)):(this.fn=NaN,this.Sn=NaN),i!==this.bn||r!==this.Sn||l!==this.pn||o!==this.fn||c!==this.yt}On(){const t=this.sn.Jn().map(s=>s.Un().Qn()).filter(zh),n=t.length===0?null:Math.max(...t);this.pn=n!==null?n:NaN}Yn(t,n,s){let i=t.get(n);return i===void 0&&(i=new Nv(this,n,s),t.set(n,i)),i}}function Qr(e){return e==="left"||e==="right"}class fe{constructor(t){this.ts=new Map,this.ns=[],this.ss=t}es(t,n){const s=function(i,r){return i===void 0?r:{rs:Math.max(i.rs,r.rs),hs:i.hs||r.hs}}(this.ts.get(t),n);this.ts.set(t,s)}ls(){return this.ss}_s(t){const n=this.ts.get(t);return n===void 0?{rs:this.ss}:{rs:Math.max(this.ss,n.rs),hs:n.hs}}us(){this.cs(),this.ns=[{ds:0}]}fs(t){this.cs(),this.ns=[{ds:1,Wt:t}]}ps(t){this.vs(),this.ns.push({ds:5,Wt:t})}cs(){this.vs(),this.ns.push({ds:6})}ws(){this.cs(),this.ns=[{ds:4}]}Ms(t){this.cs(),this.ns.push({ds:2,Wt:t})}gs(t){this.cs(),this.ns.push({ds:3,Wt:t})}bs(){return this.ns}Ss(t){for(const n of t.ns)this.xs(n);this.ss=Math.max(this.ss,t.ss),t.ts.forEach((n,s)=>{this.es(s,n)})}static Cs(){return new fe(2)}static ys(){return new fe(3)}xs(t){switch(t.ds){case 0:this.us();break;case 1:this.fs(t.Wt);break;case 2:this.Ms(t.Wt);break;case 3:this.gs(t.Wt);break;case 4:this.ws();break;case 5:this.ps(t.Wt);break;case 6:this.vs()}}vs(){const t=this.ns.findIndex(n=>n.ds===5);t!==-1&&this.ns.splice(t,1)}}class Uf{formatTickmarks(t){return t.map(n=>this.format(n))}}const Oh=".";function ln(e,t){if(!js(e))return"n/a";if(!$i(t))throw new TypeError("invalid length");if(t<0||t>16)throw new TypeError("invalid length");return t===0?e.toString():("0000000000000000"+e.toString()).slice(-t)}class Jr extends Uf{constructor(t,n){if(super(),n||(n=1),js(t)&&$i(t)||(t=100),t<0)throw new TypeError("invalid base");this.Ki=t,this.Ps=n,this.ks()}format(t){const n=t<0?"−":"";return t=Math.abs(t),n+this.Ts(t)}ks(){if(this.Rs=0,this.Ki>0&&this.Ps>0){let t=this.Ki;for(;t>1;)t/=10,this.Rs++}}Ts(t){const n=this.Ki/this.Ps;let s=Math.floor(t),i="";const r=this.Rs!==void 0?this.Rs:NaN;if(n>1){let o=+(Math.round(t*n)-s*n).toFixed(this.Rs);o>=n&&(o-=n,s+=1),i=Oh+ln(+o.toFixed(this.Rs)*this.Ps,r)}else s=Math.round(s*n)/n,r>0&&(i=Oh+ln(0,r));return s.toFixed(0)+i}}class Hf extends Jr{constructor(t=100){super(t)}format(t){return`${super.format(t)}%`}}class zv extends Uf{constructor(t){super(),this.Ds=t}format(t){let n="";return t<0&&(n="-",t=-t),t<995?n+this.Is(t):t<999995?n+this.Is(t/1e3)+"K":t<999999995?(t=1e3*Math.round(t/1e3),n+this.Is(t/1e6)+"M"):(t=1e6*Math.round(t/1e6),n+this.Is(t/1e9)+"B")}Is(t){let n;const s=Math.pow(10,this.Ds);return n=(t=Math.round(t*s)/s)>=1e-15&&t<1?t.toFixed(this.Ds).replace(/\.?0+$/,""):String(t),n.replace(/(\.[1-9]*)0+$/,(i,r)=>r)}}const Fv=/[2-9]/g;class Dr{constructor(t=50){this.Vs=0,this.Bs=1,this.Es=1,this.As={},this.Ls=new Map,this.zs=t}Os(){this.Vs=0,this.Ls.clear(),this.Bs=1,this.Es=1,this.As={}}Ii(t,n,s){return this.Ns(t,n,s).width}Di(t,n,s){const i=this.Ns(t,n,s);return((i.actualBoundingBoxAscent||0)-(i.actualBoundingBoxDescent||0))/2}Ns(t,n,s){const i=s||Fv,r=String(n).replace(i,"0");if(this.Ls.has(r))return Re(this.Ls.get(r)).Fs;if(this.Vs===this.zs){const l=this.As[this.Es];delete this.As[this.Es],this.Ls.delete(l),this.Es++,this.Vs--}t.save(),t.textBaseline="middle";const o=t.measureText(r);return t.restore(),o.width===0&&n.length||(this.Ls.set(r,{Fs:o,Ws:this.Bs}),this.As[this.Bs]=r,this.Vs++,this.Bs++),o}}class Bv{constructor(t){this.Hs=null,this.M=null,this.Us="right",this.$s=t}js(t,n,s){this.Hs=t,this.M=n,this.Us=s}st(t){this.M!==null&&this.Hs!==null&&this.Hs.st(t,this.M,this.$s,this.Us)}}class qf{constructor(t,n,s){this.qs=t,this.$s=new Dr(50),this.Ys=n,this.O=s,this.F=-1,this.Xt=new Bv(this.$s)}Tt(){const t=this.O.Ks(this.Ys);if(t===null)return null;const n=t.Gs(this.Ys)?t.Zs():this.Ys.Ft();if(n===null)return null;const s=t.Xs(n);if(s==="overlay")return null;const i=this.O.Js();return i.P!==this.F&&(this.F=i.P,this.$s.Os()),this.Xt.js(this.qs.qi(),i,s),this.Xt}}class Wv extends Nn{constructor(){super(...arguments),this.qt=null}ht(t){this.qt=t}Qs(t,n){var o;if(!((o=this.qt)!=null&&o.It))return null;const{ut:s,ct:i,te:r}=this.qt;return n>=s-i-7&&n<=s+i+7?{ie:this.qt,ne:Math.abs(n-s),se:2,ee:"price-line",te:r}:null}et({context:t,bitmapSize:n,horizontalPixelRatio:s,verticalPixelRatio:i}){if(this.qt===null||this.qt.It===!1)return;const r=Math.round(this.qt.ut*i);r<0||r>n.height||(t.lineCap="butt",t.strokeStyle=this.qt.R,t.lineWidth=Math.floor(this.qt.ct*s),_n(t,this.qt.Gt),Bf(t,r,0,n.width))}}class vl{constructor(t){this.re={ut:0,R:"rgba(0, 0, 0, 0)",ct:1,Gt:0,It:!1},this.he=new Wv,this.xt=!0,this.ae=t,this.le=t.Qt(),this.he.ht(this.re)}Pt(){this.xt=!0}Tt(){return this.ae.It()?(this.xt&&(this.oe(),this.xt=!1),this.he):null}}class jv extends vl{constructor(t){super(t)}oe(){this.re.It=!1;const t=this.ae.Ft(),n=t._e()._e;if(n!==2&&n!==3)return;const s=this.ae.N();if(!s.baseLineVisible||!this.ae.It())return;const i=this.ae.Lt();i!==null&&(this.re.It=!0,this.re.ut=t.Nt(i.Wt,i.Wt),this.re.R=s.baseLineColor,this.re.ct=s.baseLineWidth,this.re.Gt=s.baseLineStyle)}}class Vv extends Nn{constructor(){super(...arguments),this.qt=null}ht(t){this.qt=t}ue(){return this.qt}et({context:t,horizontalPixelRatio:n,verticalPixelRatio:s}){const i=this.qt;if(i===null)return;const r=Math.max(1,Math.floor(n)),o=r%2/2,l=Math.round(i.ce.x*n)+o,c=i.ce.y*s;t.fillStyle=i.de,t.beginPath();const h=Math.max(2,1.5*i.fe)*n;t.arc(l,c,h,0,2*Math.PI,!1),t.fill(),t.fillStyle=i.pe,t.beginPath(),t.arc(l,c,i.ft*n,0,2*Math.PI,!1),t.fill(),t.lineWidth=r,t.strokeStyle=i.ve,t.beginPath(),t.arc(l,c,i.ft*n+r/2,0,2*Math.PI,!1),t.stroke()}}const Ov=[{me:0,we:.25,Me:4,ge:10,be:.25,Se:0,xe:.4,Ce:.8},{me:.25,we:.525,Me:10,ge:14,be:0,Se:0,xe:.8,Ce:0},{me:.525,we:1,Me:14,ge:14,be:0,Se:0,xe:0,Ce:0}];class Uv{constructor(t){this.Xt=new Vv,this.xt=!0,this.ye=!0,this.Pe=performance.now(),this.ke=this.Pe-1,this.Te=t}Re(){this.ke=this.Pe-1,this.Pt()}De(){if(this.Pt(),this.Te.N().lastPriceAnimation===2){const t=performance.now(),n=this.ke-t;if(n>0)return void(n<650&&(this.ke+=2600));this.Pe=t,this.ke=t+2600}}Pt(){this.xt=!0}Ie(){this.ye=!0}It(){return this.Te.N().lastPriceAnimation!==0}Ve(){switch(this.Te.N().lastPriceAnimation){case 0:return!1;case 1:return!0;case 2:return performance.now()<=this.ke}}Tt(){return this.xt?(this.Rt(),this.xt=!1,this.ye=!1):this.ye&&(this.Be(),this.ye=!1),this.Xt}Rt(){this.Xt.ht(null);const t=this.Te.Qt().Et(),n=t.Ee(),s=this.Te.Lt();if(n===null||s===null)return;const i=this.Te.Ae(!0);if(i.Le||!n.ze(i.$n))return;const r={x:t.jt(i.$n),y:this.Te.Ft().Nt(i.Mt,s.Wt)},o=i.R,l=this.Te.N().lineWidth,c=this.Oe(this.Ne(),o);this.Xt.ht({de:o,fe:l,pe:c.pe,ve:c.ve,ft:c.ft,ce:r})}Be(){const t=this.Xt.ue();if(t!==null){const n=this.Oe(this.Ne(),t.de);t.pe=n.pe,t.ve=n.ve,t.ft=n.ft}}Ne(){return this.Ve()?performance.now()-this.Pe:2599}Fe(t,n,s,i){const r=s+(i-s)*n;return this.Te.Qt().Xi().Y(t,r)}Oe(t,n){const s=t%2600/2600;let i;for(const h of Ov)if(s>=h.me&&s<=h.we){i=h;break}pe(i!==void 0,"Last price animation internal logic error");const r=(s-i.me)/(i.we-i.me);return{pe:this.Fe(n,r,i.be,i.Se),ve:this.Fe(n,r,i.xe,i.Ce),ft:(o=r,l=i.Me,c=i.ge,l+(c-l)*o)};var o,l,c}}class Hv extends vl{constructor(t){super(t)}oe(){const t=this.re;t.It=!1;const n=this.ae.N();if(!n.priceLineVisible||!this.ae.It())return;const s=this.ae.Ae(n.priceLineSource===0);s.Le||(t.It=!0,t.ut=s.Ei,t.R=this.ae.We(s.R),t.ct=n.priceLineWidth,t.Gt=n.priceLineStyle)}}class qv extends Xr{constructor(t){super(),this.Jt=t}Yi(t,n,s){t.It=!1,n.It=!1;const i=this.Jt;if(!i.It())return;const r=i.N(),o=r.lastValueVisible,l=i.He()!=="",c=r.seriesLastValueMode===0,h=i.Ae(!1);if(h.Le)return;o&&(t.ri=this.Ue(h,o,c),t.It=t.ri.length!==0),(l||c)&&(n.ri=this.$e(h,o,l,c),n.It=n.ri.length>0);const a=i.We(h.R),u=this.Jt.Qt().Xi().G(a);s.Z=u.Z,s.Ei=h.Ei,n.Ht=i.Qt().Ut(h.Ei/i.Ft().$t()),t.Ht=a,t.R=u.X,n.R=u.X}$e(t,n,s,i){let r="";const o=this.Jt.He();return s&&o.length!==0&&(r+=`${o} `),n&&i&&(r+=this.Jt.Ft().je()?t.qe:t.Ye),r.trim()}Ue(t,n,s){return n?s?this.Jt.Ft().je()?t.Ye:t.qe:t.ri:""}}function Uh(e,t,n,s){const i=Number.isFinite(t),r=Number.isFinite(n);return i&&r?e(t,n):i||r?i?t:n:s}class ke{constructor(t,n){this.Ke=t,this.Ge=n}Ze(t){return t!==null&&this.Ke===t.Ke&&this.Ge===t.Ge}Xe(){return new ke(this.Ke,this.Ge)}Je(){return this.Ke}Qe(){return this.Ge}tr(){return this.Ge-this.Ke}Zi(){return this.Ge===this.Ke||Number.isNaN(this.Ge)||Number.isNaN(this.Ke)}Ss(t){return t===null?this:new ke(Uh(Math.min,this.Je(),t.Je(),-1/0),Uh(Math.max,this.Qe(),t.Qe(),1/0))}ir(t){if(!js(t)||this.Ge-this.Ke===0)return;const n=.5*(this.Ge+this.Ke);let s=this.Ge-n,i=this.Ke-n;s*=t,i*=t,this.Ge=n+s,this.Ke=n+i}nr(t){js(t)&&(this.Ge+=t,this.Ke+=t)}sr(){return{minValue:this.Ke,maxValue:this.Ge}}static er(t){return t===null?null:new ke(t.minValue,t.maxValue)}}class Lr{constructor(t,n){this.rr=t,this.hr=n||null}ar(){return this.rr}lr(){return this.hr}sr(){return{priceRange:this.rr===null?null:this.rr.sr(),margins:this.hr||void 0}}static er(t){return t===null?null:new Lr(ke.er(t.priceRange),t.margins)}}const Gv=[2,4,8,16,32,64,128,256,512],Yv="Custom series with conflation reducer must have a priceValueBuilder method";class Xv extends vl{constructor(t,n){super(t),this._r=n}oe(){const t=this.re;t.It=!1;const n=this._r.N();if(!this.ae.It()||!n.lineVisible)return;const s=this._r.ur();s!==null&&(t.It=!0,t.ut=s,t.R=n.color,t.ct=n.lineWidth,t.Gt=n.lineStyle,t.te=this._r.N().id)}}class Qv extends Xr{constructor(t,n){super(),this.Te=t,this._r=n}Yi(t,n,s){t.It=!1,n.It=!1;const i=this._r.N(),r=i.axisLabelVisible,o=i.title!=="",l=this.Te;if(!r||!l.It())return;const c=this._r.ur();if(c===null)return;o&&(n.ri=i.title,n.It=!0),n.Ht=l.Qt().Ut(c/l.Ft().$t()),t.ri=this.cr(i.price),t.It=!0;const h=this.Te.Qt().Xi().G(i.axisLabelColor||i.color);s.Z=h.Z;const a=i.axisLabelTextColor||h.X;t.R=a,n.R=a,s.Ei=c}cr(t){const n=this.Te.Lt();return n===null?"":this.Te.Ft().Ji(t,n.Wt)}}class Jv{constructor(t,n){this.Te=t,this.yn=n,this.dr=new Xv(t,this),this.qs=new Qv(t,this),this.pr=new qf(this.qs,t,t.Qt())}vr(t){$e(this.yn,t),this.Pt(),this.Te.Qt().mr()}N(){return this.yn}wr(){return this.dr}Mr(){return this.pr}gr(){return this.qs}Pt(){this.dr.Pt(),this.qs.Pt()}ur(){const t=this.Te,n=t.Ft();if(t.Qt().Et().Zi()||n.Zi())return null;const s=t.Lt();return s===null?null:n.Nt(this.yn.price,s.Wt)}}class Kv{constructor(){this.br=new WeakMap}Sr(t,n,s){const i=1/n*s;if(t>=i)return 1;const r=i/t,o=Math.pow(2,Math.floor(Math.log2(r)));return Math.min(o,512)}Cr(t,n,s,i=!1,r){if(t.length===0||n<=1)return t;const o=this.yr(n);if(o<=1)return t;const l=this.Pr(t);let c=l.kr.get(o);return c!==void 0||(c=this.Tr(t,o,s,i,r,l.kr),l.kr.set(o,c)),c}Rr(t,n,s,i,r=!1,o){if(s<1||t.length===0)return t;const l=this.Pr(t),c=l.kr.get(s);if(!c)return this.Cr(t,s,i,r,o);const h=this.Dr(t,n,s,c,r,i,o);return l.kr.set(s,h),h}yr(t){if(t<=2)return 2;for(const n of Gv)if(t<=n)return n;return 512}Ir(t){if(t.length===0)return 0;const n=t[0],s=t[t.length-1];return 31*t.length+17*n.$n+13*s.$n}Tr(t,n,s,i=!1,r,o=new Map){if(n===2)return this.Vr(t,2,s,i,r);const l=n/2;let c=o.get(l);return c||(c=this.Tr(t,l,s,i,r,o),o.set(l,c)),this.Br(c,s,i,r)}Vr(t,n,s,i=!1,r){const o=this.Er(t,n,s,i,r);return this.Ar(o,i)}Br(t,n,s=!1,i){const r=this.Er(t,2,n,s,i);return this.Ar(r,s)}Er(t,n,s,i=!1,r){const o=[];for(let l=0;l<t.length;l+=n)if(t.length-l>=n){const c=this.Lr(t[l],t[l+1],s,i,r);c.zr=!1,o.push(c)}else if(o.length===0)o.push(this.Or(t[l],!0));else{const c=o[o.length-1];o[o.length-1]=this.Nr(c,t[l],s,i,r)}return o}Fr(t,n){return(t??1)+(n??1)}Lr(t,n,s,i=!1,r){if(!i||!s||!r){const h=t.Wt[1]>n.Wt[1]?t.Wt[1]:n.Wt[1],a=t.Wt[2]<n.Wt[2]?t.Wt[2]:n.Wt[2];return{Wr:t.$n,Hr:n.$n,Ur:t.wt,$r:n.wt,jr:t.Wt[0],qr:h,Yr:a,Kr:n.Wt[3],Gr:this.Fr(t.Gr,n.Gr),Zr:void 0,zr:!1}}const o=s(this.Xr(t,r),this.Xr(n,r)),l=r(o),c=l.length?l[l.length-1]:0;return{Wr:t.$n,Hr:n.$n,Ur:t.wt,$r:n.wt,jr:t.Wt[0],qr:Math.max(t.Wt[1],c),Yr:Math.min(t.Wt[2],c),Kr:c,Gr:this.Fr(t.Gr,n.Gr),Zr:o,zr:!1}}Nr(t,n,s,i=!1,r){if(!i||!s||!r)return{Wr:t.Wr,Hr:n.$n,Ur:t.Ur,$r:n.wt,jr:t.jr,qr:t.qr>n.Wt[1]?t.qr:n.Wt[1],Yr:t.Yr<n.Wt[2]?t.Yr:n.Wt[2],Kr:n.Wt[3],Gr:t.Gr+(n.Gr??1),Zr:t.Zr,zr:!1};const o=t.Zr,l=this.Xr(n,r),c=o?{data:o,index:t.Wr,originalTime:t.Ur,time:t.Ur,priceValues:r(o)}:null,h=c?s(c,l):l.data,a=c?r(h):l.priceValues,u=a.length?a[a.length-1]:0;return{Wr:t.Wr,Hr:n.$n,Ur:t.Ur,$r:n.wt,jr:t.jr,qr:Math.max(t.qr,u),Yr:Math.min(t.Yr,u),Kr:u,Gr:t.Gr+(n.Gr??1),Zr:h,zr:!1}}Jr(t,n,s,i,r,o,l=!1,c){const h=n===i?r:t[n];if(s-n==1)return this.Or(h,!0);const a=n+1===i?r:t[n+1];let u=this.Lr(h,a,o,l,c);for(let f=n+2;f<s;f++){const p=f===i?r:t[f];u=this.Nr(u,p,o,l,c)}return u}Xr(t,n){const s=t.ue??{};return{data:t.ue,index:t.$n,originalTime:t.Qr,time:t.wt,priceValues:n(s)}}th(t,n=!1){const s=n===!0,i=!!t.Zr;return{$n:t.Wr,wt:t.Ur,Qr:t.Ur,Wt:[s?t.Kr:t.jr,t.qr,t.Yr,t.Kr],Gr:t.Gr,ue:s?i?t.Zr:{wt:t.Ur}:void 0}}Ar(t,n=!1){return t.map(s=>this.th(s,n))}Dr(t,n,s,i,r=!1,o,l){if(i.length===0)return i;const c=t.length-1,h=Math.floor(c/s)*s;if(Math.min(h+s,t.length)-h<s&&t.length>s){const a=t.slice();return a[a.length-1]=n,this.Cr(a,s,o,r,l)}if(Math.floor((c-1)/s)===Math.floor(c/s)||i.length===1){const a=Math.min(h+s,t.length),u=a-h;if(u<=0)return i;const f=u===1?this.Or(h===c?n:t[h],!0):this.Jr(t,h,a,c,n,o,r,l);return i[i.length-1]=this.th(f,r),i}{const a=t.slice();return a[a.length-1]=n,this.Cr(a,s,o,r,l)}}Or(t,n=!1){return{Wr:t.$n,Hr:t.$n,Ur:t.wt,$r:t.wt,jr:t.Wt[0],qr:t.Wt[1],Yr:t.Wt[2],Kr:t.Wt[3],Gr:t.Gr??1,Zr:t.ue,zr:n}}Pr(t){const n=this.ih(t),s=this.Ir(t);return n.nh!==s&&(n.kr.clear(),n.nh=s),n}ih(t){let n=this.br.get(t);return n===void 0&&(n={nh:this.Ir(t),kr:new Map},this.br.set(t,n)),n}}class Zv extends Of{constructor(t){super(),this.sn=t}Qt(){return this.sn}}const tx={Bar:(e,t,n,s)=>{const i=t.upColor,r=t.downColor,o=K(e(n,s)),l=Mn(o.Wt[0])<=Mn(o.Wt[3]);return{sh:o.R??(l?i:r)}},Candlestick:(e,t,n,s)=>{const i=t.upColor,r=t.downColor,o=t.borderUpColor,l=t.borderDownColor,c=t.wickUpColor,h=t.wickDownColor,a=K(e(n,s)),u=Mn(a.Wt[0])<=Mn(a.Wt[3]);return{sh:a.R??(u?i:r),eh:a.Ht??(u?o:l),rh:a.hh??(u?c:h)}},Custom:(e,t,n,s)=>({sh:K(e(n,s)).R??t.color}),Area:(e,t,n,s)=>{const i=K(e(n,s));return{sh:i.vt??t.lineColor,vt:i.vt??t.lineColor,ah:i.ah??t.topColor,oh:i.oh??t.bottomColor}},Baseline:(e,t,n,s)=>{const i=K(e(n,s));return{sh:i.Wt[3]>=t.baseValue.price?t.topLineColor:t.bottomLineColor,_h:i._h??t.topLineColor,uh:i.uh??t.bottomLineColor,dh:i.dh??t.topFillColor1,fh:i.fh??t.topFillColor2,ph:i.ph??t.bottomFillColor1,mh:i.mh??t.bottomFillColor2}},Line:(e,t,n,s)=>{const i=K(e(n,s));return{sh:i.R??t.color,vt:i.R??t.color}},Histogram:(e,t,n,s)=>({sh:K(e(n,s)).R??t.color})};class ex{constructor(t){this.wh=(n,s)=>s!==void 0?s.Wt:this.Te.Un().Mh(n),this.Te=t,this.gh=tx[t.bh()]}Sh(t,n){return this.gh(this.wh,this.Te.N(),t,n)}}function Gf(e,t,n,s,i=0,r=t.length){let o=r-i;for(;0<o;){const l=o>>1,c=i+l;s(t[c],n)===e?(i=c+1,o-=l+1):o=l}return i}const es=Gf.bind(null,!0),xl=Gf.bind(null,!1);var Hh;(function(e){e[e.NearestLeft=-1]="NearestLeft",e[e.None=0]="None",e[e.NearestRight=1]="NearestRight"})(Hh||(Hh={}));const Sn=30;class nx{constructor(){this.xh=[],this.Ch=new Map,this.yh=new Map,this.Ph=[]}kh(){return this.Th()>0?this.xh[this.xh.length-1]:null}Rh(){return this.Th()>0?this.Dh(0):null}Qn(){return this.Th()>0?this.Dh(this.xh.length-1):null}Th(){return this.xh.length}Zi(){return this.Th()===0}ze(t){return this.Ih(t,0)!==null}Mh(t){return this.Hn(t)}Hn(t,n=0){const s=this.Ih(t,n);return s===null?null:{...this.Vh(s),$n:this.Dh(s)}}Bh(){return this.xh}Eh(t,n,s){if(this.Zi())return null;let i=null;for(const r of s)i=ar(i,this.Ah(t,n,r));return i}ht(t){this.yh.clear(),this.Ch.clear(),this.xh=t,this.Ph=t.map(n=>n.$n)}Lh(){return this.Ph}Dh(t){return this.xh[t].$n}Vh(t){return this.xh[t]}Ih(t,n){const s=this.zh(t);if(s===null&&n!==0)switch(n){case-1:return this.Oh(t);case 1:return this.Nh(t);default:throw new TypeError("Unknown search mode")}return s}Oh(t){let n=this.Fh(t);return n>0&&(n-=1),n!==this.xh.length&&this.Dh(n)<t?n:null}Nh(t){const n=this.Wh(t);return n!==this.xh.length&&t<this.Dh(n)?n:null}zh(t){const n=this.Fh(t);return n===this.xh.length||t<this.xh[n].$n?null:n}Fh(t){return es(this.xh,t,(n,s)=>n.$n<s)}Wh(t){return xl(this.xh,t,(n,s)=>n.$n>s)}Hh(t,n,s){let i=null;for(let r=t;r<n;r++){const o=this.xh[r].Wt[s];Number.isNaN(o)||(i===null?i={Uh:o,$h:o}:(o<i.Uh&&(i.Uh=o),o>i.$h&&(i.$h=o)))}return i}Ah(t,n,s){if(this.Zi())return null;let i=null;const r=K(this.Rh()),o=K(this.Qn()),l=Math.max(t,r),c=Math.min(n,o),h=Math.ceil(l/Sn)*Sn,a=Math.max(h,Math.floor(c/Sn)*Sn);{const f=this.Fh(l),p=this.Wh(Math.min(c,h,n));i=ar(i,this.Hh(f,p,s))}let u=this.Ch.get(s);u===void 0&&(u=new Map,this.Ch.set(s,u));for(let f=Math.max(h+1,l);f<a;f+=Sn){const p=Math.floor(f/Sn);let g=u.get(p);if(g===void 0){const d=this.Fh(p*Sn),w=this.Wh((p+1)*Sn-1);g=this.Hh(d,w,s),u.set(p,g)}i=ar(i,g)}{const f=this.Fh(a),p=this.Wh(c);i=ar(i,this.Hh(f,p,s))}return i}}function ar(e,t){return e===null?t:t===null?e:{Uh:Math.min(e.Uh,t.Uh),$h:Math.max(e.$h,t.$h)}}function _o(){return new nx}const zr={setLineStyle:_n};class sx{constructor(t){this.jh=t}st(t,n,s){this.jh.draw(t,zr)}qh(t,n,s){var i,r;(r=(i=this.jh).drawBackground)==null||r.call(i,t,zr)}}class ix{constructor(t){this.Ls=null,this.Yh=t}Tt(){var s;const t=this.Yh.renderer();if(t===null)return null;if(((s=this.Ls)==null?void 0:s.Kh)===t)return this.Ls.Gh;const n=new sx(t);return this.Ls={Kh:t,Gh:n},n}Zh(){var t,n;return((n=(t=this.Yh).zOrder)==null?void 0:n.call(t))??"normal"}}class Yf{constructor(t){this.Xh=null,this.Jh=t}Qh(){return this.Jh}Nn(){var t,n;(n=(t=this.Jh).updateAllViews)==null||n.call(t)}jn(){var s,i,r;const t=((i=(s=this.Jh).paneViews)==null?void 0:i.call(s))??[];if(((r=this.Xh)==null?void 0:r.Kh)===t)return this.Xh.Gh;const n=t.map(o=>new ix(o));return this.Xh={Kh:t,Gh:n},n}Qs(t,n){var s,i;return((i=(s=this.Jh).hitTest)==null?void 0:i.call(s,t,n))??null}}let rx=class extends Yf{cn(){return[]}};class ox{constructor(t){this.jh=t}st(t,n,s){this.jh.draw(t,zr)}qh(t,n,s){var i,r;(r=(i=this.jh).drawBackground)==null||r.call(i,t,zr)}}class qh{constructor(t){this.Ls=null,this.Yh=t}Tt(){var s;const t=this.Yh.renderer();if(t===null)return null;if(((s=this.Ls)==null?void 0:s.Kh)===t)return this.Ls.Gh;const n=new ox(t);return this.Ls={Kh:t,Gh:n},n}Zh(){var t,n;return((n=(t=this.Yh).zOrder)==null?void 0:n.call(t))??"normal"}}function Xf(e){var t,n,s;return{ri:e.text(),Ei:e.coordinate(),Vi:(t=e.fixedCoordinate)==null?void 0:t.call(e),R:e.textColor(),Z:e.backColor(),It:((n=e.visible)==null?void 0:n.call(e))??!0,pi:((s=e.tickVisible)==null?void 0:s.call(e))??!0}}class ax{constructor(t,n){this.Xt=new Vf,this.ta=t,this.ia=n}Tt(){return this.Xt.ht({nn:this.ia.nn(),...Xf(this.ta)}),this.Xt}}class lx extends Xr{constructor(t,n){super(),this.ta=t,this.Ki=n}Yi(t,n,s){const i=Xf(this.ta);s.Z=i.Z,t.R=i.R;const r=2/12*this.Ki.P();s.Ti=r,s.Ri=r,s.Ei=i.Ei,s.Vi=i.Vi,t.ri=i.ri,t.It=i.It,t.pi=i.pi}}class cx extends Yf{constructor(t,n){super(t),this.na=null,this.sa=null,this.ea=null,this.ra=null,this.Te=n}dn(){var i,r,o;const t=((r=(i=this.Jh).timeAxisViews)==null?void 0:r.call(i))??[];if(((o=this.na)==null?void 0:o.Kh)===t)return this.na.Gh;const n=this.Te.Qt().Et(),s=t.map(l=>new ax(l,n));return this.na={Kh:t,Gh:s},s}qn(){var i,r,o;const t=((r=(i=this.Jh).priceAxisViews)==null?void 0:r.call(i))??[];if(((o=this.sa)==null?void 0:o.Kh)===t)return this.sa.Gh;const n=this.Te.Ft(),s=t.map(l=>new lx(l,n));return this.sa={Kh:t,Gh:s},s}ha(){var s,i,r;const t=((i=(s=this.Jh).priceAxisPaneViews)==null?void 0:i.call(s))??[];if(((r=this.ea)==null?void 0:r.Kh)===t)return this.ea.Gh;const n=t.map(o=>new qh(o));return this.ea={Kh:t,Gh:n},n}aa(){var s,i,r;const t=((i=(s=this.Jh).timeAxisPaneViews)==null?void 0:i.call(s))??[];if(((r=this.ra)==null?void 0:r.Kh)===t)return this.ra.Gh;const n=t.map(o=>new qh(o));return this.ra={Kh:t,Gh:n},n}la(t,n){var s,i;return((i=(s=this.Jh).autoscaleInfo)==null?void 0:i.call(s,t,n))??null}}function lr(e,t,n,s){e.forEach(i=>{t(i).forEach(r=>{r.Zh()===n&&s.push(r)})})}function cr(e){return e.jn()}function hx(e){return e.ha()}function ux(e){return e.aa()}const dx=["Area","Line","Baseline"];class Kr extends Zv{constructor(t,n,s,i,r){super(t),this.qt=_o(),this.dr=new Hv(this),this.oa=[],this._a=new jv(this),this.ua=null,this.ca=null,this.da=null,this.fa=[],this.pa=new Kv,this.va=new Map,this.ma=null,this.yn=s,this.wa=n;const o=new qv(this);if(this.mn=[o],this.pr=new qf(o,this,t),dx.includes(this.wa)&&(this.ua=new Uv(this)),this.Ma(),this.Yh=i(this,this.Qt(),r),this.wa==="Custom"){const l=this.Yh;l.ga&&this.ba(l.ga)}}m(){this.da!==null&&clearTimeout(this.da)}We(t){return this.yn.priceLineColor||t}Ae(t){const n={Le:!0},s=this.Ft();if(this.Qt().Et().Zi()||s.Zi()||this.qt.Zi())return n;const i=this.Qt().Et().Ee(),r=this.Lt();if(i===null||r===null)return n;let o,l;if(t){const u=this.qt.kh();if(u===null)return n;o=u,l=u.$n}else{const u=this.qt.Hn(i.bi(),-1);if(u===null||(o=this.qt.Mh(u.$n),o===null))return n;l=u.$n}const c=o.Wt[3],h=this.Sa().Sh(l,{Wt:o}),a=s.Nt(c,r.Wt);return{Le:!1,Mt:c,ri:s.Ji(c,r.Wt),qe:s.xa(c),Ye:s.Ca(c,r.Wt),R:h.sh,Ei:a,$n:l}}Sa(){return this.ca!==null||(this.ca=new ex(this)),this.ca}N(){return this.yn}vr(t){const n=this.Qt(),{priceScaleId:s,visible:i,priceFormat:r}=t;s!==void 0&&s!==this.yn.priceScaleId&&n.ya(this,s),i!==void 0&&i!==this.yn.visible&&n.Pa();const o=t.conflationThresholdFactor!==void 0;$e(this.yn,t),Object.prototype.hasOwnProperty.call(t,"autoscaleInfoProvider")&&t.autoscaleInfoProvider===void 0&&(this.yn.autoscaleInfoProvider=void 0),o&&(this.va.clear(),this.Qt().mr()),r!==void 0&&(this.Ma(),n.ka()),n.Ta(this),n.Ra(),this.Yh.Pt("options")}ht(t,n){this.qt.ht(t),this.va.clear();const s=this.Qt().Et().N();s.enableConflation&&s.precomputeConflationOnInit&&this.Da(s.precomputeConflationPriority),this.Ia(),this.ua!==null&&(n&&n.Va?this.ua.De():t.length===0&&this.ua.Re());const i=this.Qt().Ks(this);this.Qt().Ba(i),this.Qt().Ta(this),this.Qt().Ra(),this.Qt().mr()}Ia(){this.Yh.Pt("data")}Ea(t){const n=new Jv(this,t);return this.oa.push(n),this.Qt().Ta(this),n}Aa(t){const n=this.oa.indexOf(t);n!==-1&&this.oa.splice(n,1),this.Qt().Ta(this)}La(){return this.oa}bh(){return this.wa}Lt(){const t=this.za();return t===null?null:{Wt:t.Wt[3],Oa:t.wt}}za(){const t=this.Qt().Et().Ee();if(t===null)return null;const n=t.Na();return this.qt.Hn(n,1)}Un(){return this.qt}ba(t){this.ma=t,this.va.clear()}Fa(){return!!this.Qt().Et().N().enableConflation&&this.Wa()>1}Rr(t){if(!this.Fa())return;const n=this.Wa();if(!this.va.has(n))return;const s=this.wa==="Custom",i=s&&this.ma||void 0,r=s&&this.Yh.Ha?c=>{const h=c,a=this.Yh.Ha(h);return Array.isArray(a)?a:[typeof a=="number"?a:0]}:void 0,o=this.pa.Rr(this.qt.Bh(),t,n,i,s,r),l=_o();l.ht(o),this.va.set(n,l)}Ua(){const t=this.Qt().Et().N().enableConflation;if(this.wa==="Custom"&&this.ma===null)return this.qt;if(!t)return this.qt;const n=this.Wa(),s=this.va.get(n);return s||(this.$a(n),this.va.get(n)??this.qt)}ja(t){const n=this.qt.Mh(t);return n===null?null:this.wa==="Bar"||this.wa==="Candlestick"||this.wa==="Custom"?{jr:n.Wt[0],qr:n.Wt[1],Yr:n.Wt[2],Kr:n.Wt[3]}:n.Wt[3]}qa(t){const n=[];lr(this.fa,cr,"top",n);const s=this.ua;return s!==null&&s.It()&&(this.da===null&&s.Ve()&&(this.da=setTimeout(()=>{this.da=null,this.Qt().Ya()},0)),s.Ie(),n.unshift(s)),n}jn(){const t=[];this.Ka()||t.push(this._a),t.push(this.Yh,this.dr);const n=this.oa.map(s=>s.wr());return t.push(...n),lr(this.fa,cr,"normal",t),t}Ga(){var r,o;const t=((o=(r=this.Yh).Ga)==null?void 0:o.call(r))??null;if(t===null)return null;const n=[];this.Ka()||n.push(this._a),n.push(...t.Za),lr(this.fa,cr,"normal",n);const s=[];s.push(...t.qa,this.dr);const i=this.oa.map(l=>l.wr());return s.push(...i),{Za:n,qa:s}}Xa(){return this.Ja(cr,"bottom")}Qa(t){return this.Ja(hx,t)}tl(t){return this.Ja(ux,t)}il(t,n){return this.fa.map(s=>s.Qs(t,n)).filter(s=>s!==null)}cn(){return[this.pr,...this.oa.map(t=>t.Mr())]}qn(t,n){if(n!==this.hn&&!this.Ka())return[];const s=[...this.mn];for(const i of this.oa)s.push(i.gr());return this.fa.forEach(i=>{s.push(...i.qn())}),s}dn(){const t=[];return this.fa.forEach(n=>{t.push(...n.dn())}),t}la(t,n){if(this.yn.autoscaleInfoProvider!==void 0){const s=this.yn.autoscaleInfoProvider(()=>{const i=this.nl(t,n);return i===null?null:i.sr()});return Lr.er(s)}return this.nl(t,n)}Kh(){const t=this.yn.priceFormat;return t.base??1/t.minMove}sl(){return this.el}Nn(){var t;this.Yh.Pt();for(const n of this.mn)n.Pt();for(const n of this.oa)n.Pt();this.dr.Pt(),this._a.Pt(),(t=this.ua)==null||t.Pt(),this.fa.forEach(n=>n.Nn())}Ft(){return K(super.Ft())}At(t){if(!((this.wa==="Line"||this.wa==="Area"||this.wa==="Baseline")&&this.yn.crosshairMarkerVisible))return null;const n=this.qt.Mh(t);return n===null?null:{Mt:n.Wt[3],ft:this.rl(),Ht:this.hl(),Ot:this.al(),zt:this.ll(t)}}He(){return this.yn.title}It(){return this.yn.visible}ol(t){this.fa.push(new cx(t,this))}_l(t){this.fa=this.fa.filter(n=>n.Qh()!==t)}ul(){if(this.wa==="Custom")return t=>this.Yh.Ha(t)}cl(){if(this.wa==="Custom")return t=>this.Yh.dl(t)}fl(){return this.qt.Lh()}Ka(){return!Qr(this.Ft().pl())}nl(t,n){if(!$i(t)||!$i(n)||this.qt.Zi())return null;const s=this.wa==="Line"||this.wa==="Area"||this.wa==="Baseline"||this.wa==="Histogram"?[3]:[2,1],i=this.qt.Eh(t,n,s);let r=i!==null?new ke(i.Uh,i.$h):null,o=null;if(this.bh()==="Histogram"){const l=this.yn.base,c=new ke(l,l);r=r!==null?r.Ss(c):c}return this.fa.forEach(l=>{const c=l.la(t,n);if(c!=null&&c.priceRange){const h=new ke(c.priceRange.minValue,c.priceRange.maxValue);r=r!==null?r.Ss(h):h}c!=null&&c.margins&&(o=c.margins)}),new Lr(r,o)}rl(){switch(this.wa){case"Line":case"Area":case"Baseline":return this.yn.crosshairMarkerRadius}return 0}hl(){switch(this.wa){case"Line":case"Area":case"Baseline":{const t=this.yn.crosshairMarkerBorderColor;if(t.length!==0)return t}}return null}al(){switch(this.wa){case"Line":case"Area":case"Baseline":return this.yn.crosshairMarkerBorderWidth}return 0}ll(t){switch(this.wa){case"Line":case"Area":case"Baseline":{const n=this.yn.crosshairMarkerBackgroundColor;if(n.length!==0)return n}}return this.Sa().Sh(t).sh}Ma(){switch(this.yn.priceFormat.type){case"custom":{const t=this.yn.priceFormat.formatter;this.el={format:t,formatTickmarks:this.yn.priceFormat.tickmarksFormatter??(n=>n.map(t))};break}case"volume":this.el=new zv(this.yn.priceFormat.precision);break;case"percent":this.el=new Hf(this.yn.priceFormat.precision);break;default:{const t=Math.pow(10,this.yn.priceFormat.precision);this.el=new Jr(t,this.yn.priceFormat.minMove*t)}}this.hn!==null&&this.hn.vl()}Ja(t,n){const s=[];return lr(this.fa,t,n,s),s}Wa(){const{ml:t,wl:n,Ml:s}=this.gl();return this.pa.Sr(t,n,s)}gl(){const t=this.Qt().Et(),n=t.ml(),s=window.devicePixelRatio||1,i=t.N().conflationThresholdFactor;return{ml:n,wl:s,Ml:this.yn.conflationThresholdFactor??i??1}}bl(t){const n=this.qt.Bh();let s;if(this.wa==="Custom"&&this.ma!==null){const r=this.ul();if(!r)throw new Error(Yv);s=this.pa.Cr(n,t,this.ma,!0,o=>r(o))}else s=this.pa.Cr(n,t);const i=_o();return i.ht(s),i}$a(t){const n=this.bl(t);this.va.set(t,n)}Da(t){var s;if(this.wa==="Custom"&&(this.ma===null||!this.ul()))return;this.va.clear();const n=this.Qt().Et().Sl();for(const i of n){const r=()=>{this.xl(i)},o=typeof window=="object"&&window||typeof self=="object"&&self;(s=o==null?void 0:o.yl)!=null&&s.Cl?o.yl.Cl(()=>{r()},{se:t}):Promise.resolve().then(()=>r())}}xl(t){if(this.va.has(t)||this.qt.Bh().length===0)return;const n=this.bl(t);this.va.set(t,n)}}const fx=[3],mx=[0,1,2,3];class px{constructor(t){this.yn=t}Pl(t,n,s){let i=t;if(this.yn.mode===0)return i;const r=s.kn(),o=r.Lt();if(o===null)return i;const l=r.Nt(t,o),c=s.kl().filter(a=>a instanceof Kr).reduce((a,u)=>{if(s.Gs(u)||!u.It())return a;const f=u.Ft(),p=u.Un();if(f.Zi()||!p.ze(n))return a;const g=p.Mh(n);if(g===null)return a;const d=Mn(u.Lt()),w=this.yn.mode===3?mx:fx;return a.concat(w.map(C=>f.Nt(g.Wt[C],d.Wt)))},[]);if(c.length===0)return i;c.sort((a,u)=>Math.abs(a-l)-Math.abs(u-l));const h=c[0];return i=r.Tn(h,o),i}}function Ls(e,t,n){return Math.min(Math.max(e,t),n)}function hr(e,t,n){return t-e<=n}class gx extends Nn{constructor(){super(...arguments),this.qt=null}ht(t){this.qt=t}et({context:t,bitmapSize:n,horizontalPixelRatio:s,verticalPixelRatio:i}){if(this.qt===null)return;const r=Math.max(1,Math.floor(s));t.lineWidth=r,function(o,l){o.save(),o.lineWidth%2&&o.translate(.5,.5),l(),o.restore()}(t,()=>{const o=K(this.qt);if(o.Tl){t.strokeStyle=o.Rl,_n(t,o.Dl),t.beginPath();for(const l of o.Il){const c=Math.round(l.Vl*s);t.moveTo(c,-r),t.lineTo(c,n.height+r)}t.stroke()}if(o.Bl){t.strokeStyle=o.El,_n(t,o.Al),t.beginPath();for(const l of o.Ll){const c=Math.round(l.Vl*i);t.moveTo(-r,c),t.lineTo(n.width+r,c)}t.stroke()}})}}class yx{constructor(t){this.Xt=new gx,this.xt=!0,this.yt=t}Pt(){this.xt=!0}Tt(){if(this.xt){const t=this.yt.Qt().N().grid,n={Bl:t.horzLines.visible,Tl:t.vertLines.visible,El:t.horzLines.color,Rl:t.vertLines.color,Al:t.horzLines.style,Dl:t.vertLines.style,Ll:this.yt.kn().zl(),Il:(this.yt.Qt().Et().zl()||[]).map(s=>({Vl:s.coord}))};this.Xt.ht(n),this.xt=!1}return this.Xt}}class bx{constructor(t){this.Yh=new yx(t)}wr(){return this.Yh}}const $o={Ol:4,Nl:1e-4};function Ns(e,t){const n=100*(e-t)/t;return t<0?-n:n}function vx(e,t){const n=Ns(e.Je(),t),s=Ns(e.Qe(),t);return new ke(n,s)}function xi(e,t){const n=100*(e-t)/t+100;return t<0?-n:n}function xx(e,t){const n=xi(e.Je(),t),s=xi(e.Qe(),t);return new ke(n,s)}function Fr(e,t){const n=Math.abs(e);if(n<1e-15)return 0;const s=Math.log10(n+t.Nl)+t.Ol;return e<0?-s:s}function wi(e,t){const n=Math.abs(e);if(n<1e-15)return 0;const s=Math.pow(10,n-t.Ol)-t.Nl;return e<0?-s:s}function ai(e,t){if(e===null)return null;const n=Fr(e.Je(),t),s=Fr(e.Qe(),t);return new ke(n,s)}function Is(e,t){if(e===null)return null;const n=wi(e.Je(),t),s=wi(e.Qe(),t);return new ke(n,s)}function No(e){if(e===null)return $o;const t=Math.abs(e.Qe()-e.Je());if(t>=1||t<1e-15)return $o;const n=Math.ceil(Math.abs(Math.log10(t))),s=$o.Ol+n;return{Ol:s,Nl:1/Math.pow(10,s)}}class Io{constructor(t,n){if(this.Fl=t,this.Wl=n,function(s){if(s<0)return!1;if(s>1e18)return!0;for(let i=s;i>1;i/=10)if(i%10!=0)return!1;return!0}(this.Fl))this.Hl=[2,2.5,2];else{this.Hl=[];for(let s=this.Fl;s!==1;){if(s%2==0)this.Hl.push(2),s/=2;else{if(s%5!=0)throw new Error("unexpected base");this.Hl.push(2,2.5),s/=5}if(this.Hl.length>100)throw new Error("something wrong with base")}}}Ul(t,n,s){const i=this.Fl===0?0:1/this.Fl;let r=Math.pow(10,Math.max(0,Math.ceil(Math.log10(t-n)))),o=0,l=this.Wl[0];for(;;){const u=hr(r,i,1e-14)&&r>i+1e-14,f=hr(r,s*l,1e-14),p=hr(r,1,1e-14);if(!(u&&f&&p))break;r/=l,l=this.Wl[++o%this.Wl.length]}if(r<=i+1e-14&&(r=i),r=Math.max(1,r),this.Hl.length>0&&(c=r,h=1,a=1e-14,Math.abs(c-h)<a))for(o=0,l=this.Hl[0];hr(r,s*l,1e-14)&&r>i+1e-14;)r/=l,l=this.Hl[++o%this.Hl.length];var c,h,a;return r}}class Gh{constructor(t,n,s,i){this.$l=[],this.Ki=t,this.Fl=n,this.jl=s,this.ql=i}Ul(t,n){if(t<n)throw new Error("high < low");const s=this.Ki.$t(),i=(t-n)*this.Yl()/s,r=new Io(this.Fl,[2,2.5,2]),o=new Io(this.Fl,[2,2,2.5]),l=new Io(this.Fl,[2.5,2,2]),c=[];return c.push(r.Ul(t,n,i),o.Ul(t,n,i),l.Ul(t,n,i)),function(h){if(h.length<1)throw Error("array is empty");let a=h[0];for(let u=1;u<h.length;++u)h[u]<a&&(a=h[u]);return a}(c)}Kl(){const t=this.Ki,n=t.Lt();if(n===null)return void(this.$l=[]);const s=t.$t(),i=this.jl(s-1,n),r=this.jl(0,n),o=this.Ki.N().entireTextOnly?this.Gl()/2:0,l=o,c=s-1-o,h=Math.max(i,r),a=Math.min(i,r);if(h===a)return void(this.$l=[]);const u=this.Ul(h,a);if(this.Zl(n,u,h,a,l,c),t.Xl()&&this.Jl(u,a,h)){const g=this.Ki.Ql();this.io(n,u,l,c,g,2*g)}const f=this.$l.map(g=>g.no),p=this.Ki.so(f);for(let g=0;g<this.$l.length;g++)this.$l[g].eo=p[g]}zl(){return this.$l}Gl(){return this.Ki.P()}Yl(){return Math.ceil(this.Gl()*this.Ki.N().tickMarkDensity)}Zl(t,n,s,i,r,o){const l=this.$l,c=this.Ki;let h=s%n;h+=h<0?n:0;const a=s>=i?1:-1;let u=null,f=0;for(let p=s-h;p>i;p-=n){const g=this.ql(p,t,!0);u!==null&&Math.abs(g-u)<this.Yl()||g<r||g>o||(f<l.length?(l[f].Vl=g,l[f].eo=c.ro(p),l[f].no=p):l.push({Vl:g,eo:c.ro(p),no:p}),f++,u=g,c.ho()&&(n=this.Ul(p*a,i)))}l.length=f}io(t,n,s,i,r,o){const l=this.$l,c=this.ao(t,s,r,o),h=this.ao(t,i,-o,-r),a=this.ql(0,t,!0)-this.ql(n,t,!0);l.length>0&&l[0].Vl-c.Vl<a/2&&l.shift(),l.length>0&&h.Vl-l[l.length-1].Vl<a/2&&l.pop(),l.unshift(c),l.push(h)}ao(t,n,s,i){const r=(s+i)/2,o=this.jl(n+s,t),l=this.jl(n+i,t),c=Math.min(o,l),h=Math.max(o,l),a=Math.max(.1,this.Ul(h,c)),u=this.jl(n+r,t),f=u-u%a,p=this.ql(f,t,!0);return{eo:this.Ki.ro(f),Vl:p,no:f}}Jl(t,n,s){let i=Mn(this.Ki.ar());return this.Ki.ho()&&(i=Is(i,this.Ki.lo())),i.Je()-n<t&&s-i.Qe()<t}}function Qf(e){return e.slice().sort((t,n)=>K(t.ln())-K(n.ln()))}var Yh;(function(e){e[e.Normal=0]="Normal",e[e.Logarithmic=1]="Logarithmic",e[e.Percentage=2]="Percentage",e[e.IndexedTo100=3]="IndexedTo100"})(Yh||(Yh={}));const Xh=new Hf,Qh=new Jr(100,1);class wx{constructor(t,n,s,i,r){this.oo=0,this._o=null,this.rr=null,this.uo=null,this.co={do:!1,fo:null},this.po=!1,this.vo=0,this.mo=0,this.wo=new Zt,this.Mo=new Zt,this.bo=[],this.So=null,this.xo=null,this.Co=null,this.yo=null,this.Po=null,this.el=Qh,this.ko=No(null),this.To=t,this.yn=n,this.Ro=s,this.Do=i,this.Io=r,this.Vo=new Gh(this,100,this.Bo.bind(this),this.Eo.bind(this))}pl(){return this.To}N(){return this.yn}vr(t){if($e(this.yn,t),this.vl(),t.mode!==void 0&&this.Ao({_e:t.mode}),t.scaleMargins!==void 0){const n=Re(t.scaleMargins.top),s=Re(t.scaleMargins.bottom);if(n<0||n>1)throw new Error(`Invalid top margin - expect value between 0 and 1, given=${n}`);if(s<0||s>1)throw new Error(`Invalid bottom margin - expect value between 0 and 1, given=${s}`);if(n+s>1)throw new Error(`Invalid margins - sum of margins must be less than 1, given=${n+s}`);this.Lo(),this.Co=null}}zo(){return this.yn.autoScale}Oo(){return this.po}ho(){return this.yn.mode===1}je(){return this.yn.mode===2}No(){return this.yn.mode===3}lo(){return this.ko}_e(){return{hs:this.yn.autoScale,Fo:this.yn.invertScale,_e:this.yn.mode}}Ao(t){const n=this._e();let s=null;t.hs!==void 0&&(this.yn.autoScale=t.hs),t._e!==void 0&&(this.yn.mode=t._e,t._e!==2&&t._e!==3||(this.yn.autoScale=!0),this.co.do=!1),n._e===1&&t._e!==n._e&&(function(r,o){if(r===null)return!1;const l=wi(r.Je(),o),c=wi(r.Qe(),o);return isFinite(l)&&isFinite(c)}(this.rr,this.ko)?(s=Is(this.rr,this.ko),s!==null&&this.Wo(s)):this.yn.autoScale=!0),t._e===1&&t._e!==n._e&&(s=ai(this.rr,this.ko),s!==null&&this.Wo(s));const i=n._e!==this.yn.mode;i&&(n._e===2||this.je())&&this.vl(),i&&(n._e===3||this.No())&&this.vl(),t.Fo!==void 0&&n.Fo!==t.Fo&&(this.yn.invertScale=t.Fo,this.Ho()),this.Mo.p(n,this._e())}Uo(){return this.Mo}P(){return this.Ro.fontSize}$t(){return this.oo}$o(t){this.oo!==t&&(this.oo=t,this.Lo(),this.Co=null)}jo(){if(this._o)return this._o;const t=this.$t()-this.qo()-this.Yo();return this._o=t,t}ar(){return this.Ko(),this.rr}Wo(t,n){const s=this.rr;(n||s===null&&t!==null||s!==null&&!s.Ze(t))&&(this.Co=null,this.rr=t)}Go(t){this.Wo(t),this.Zo(t!==null)}Zi(){return this.Ko(),this.oo===0||!this.rr||this.rr.Zi()}Xo(t){return this.Fo()?t:this.$t()-1-t}Nt(t,n){return this.je()?t=Ns(t,n):this.No()&&(t=xi(t,n)),this.Eo(t,n)}Jo(t,n,s){this.Ko();const i=this.Yo(),r=K(this.ar()),o=r.Je(),l=r.Qe(),c=this.jo()-1,h=this.Fo(),a=c/(l-o),u=s===void 0?0:s.from,f=s===void 0?t.length:s.to,p=this.Qo();for(let g=u;g<f;g++){const d=t[g],w=d.Mt;if(isNaN(w))continue;let C=w;p!==null&&(C=p(d.Mt,n));const x=i+a*(C-o),k=h?x:this.oo-1-x;d.ut=k}}t_(t,n,s){this.Ko();const i=this.Yo(),r=K(this.ar()),o=r.Je(),l=r.Qe(),c=this.jo()-1,h=this.Fo(),a=c/(l-o),u=s===void 0?0:s.from,f=s===void 0?t.length:s.to,p=this.Qo();for(let g=u;g<f;g++){const d=t[g];let w=d.jr,C=d.qr,x=d.Yr,k=d.Kr;p!==null&&(w=p(d.jr,n),C=p(d.qr,n),x=p(d.Yr,n),k=p(d.Kr,n));let S=i+a*(w-o),T=h?S:this.oo-1-S;d.i_=T,S=i+a*(C-o),T=h?S:this.oo-1-S,d.n_=T,S=i+a*(x-o),T=h?S:this.oo-1-S,d.s_=T,S=i+a*(k-o),T=h?S:this.oo-1-S,d.e_=T}}Tn(t,n){const s=this.Bo(t,n);return this.r_(s,n)}r_(t,n){let s=t;return this.je()?s=function(i,r){return r<0&&(i=-i),i/100*r+r}(s,n):this.No()&&(s=function(i,r){return i-=100,r<0&&(i=-i),i/100*r+r}(s,n)),s}kl(){return this.bo}Dt(){return this.xo||(this.xo=Qf(this.bo)),this.xo}h_(t){this.bo.indexOf(t)===-1&&(this.bo.push(t),this.vl(),this.a_())}l_(t){const n=this.bo.indexOf(t);if(n===-1)throw new Error("source is not attached to scale");this.bo.splice(n,1),this.bo.length===0&&(this.Ao({hs:!0}),this.Wo(null)),this.vl(),this.a_()}Lt(){let t=null;for(const n of this.bo){const s=n.Lt();s!==null&&(t===null||s.Oa<t.Oa)&&(t=s)}return t===null?null:t.Wt}Fo(){return this.yn.invertScale}zl(){const t=this.Lt()===null;if(this.Co!==null&&(t||this.Co.o_===t))return this.Co.zl;this.Vo.Kl();const n=this.Vo.zl();return this.Co={zl:n,o_:t},this.wo.p(),n}__(){return this.wo}u_(t){this.je()||this.No()||this.yo===null&&this.uo===null&&(this.Zi()||(this.yo=this.oo-t,this.uo=K(this.ar()).Xe()))}c_(t){if(this.je()||this.No()||this.yo===null)return;this.Ao({hs:!1}),(t=this.oo-t)<0&&(t=0);let n=(this.yo+.2*(this.oo-1))/(t+.2*(this.oo-1));const s=K(this.uo).Xe();n=Math.max(n,.1),s.ir(n),this.Wo(s)}d_(){this.je()||this.No()||(this.yo=null,this.uo=null)}f_(t){this.zo()||this.Po===null&&this.uo===null&&(this.Zi()||(this.Po=t,this.uo=K(this.ar()).Xe()))}p_(t){if(this.zo()||this.Po===null)return;const n=K(this.ar()).tr()/(this.jo()-1);let s=t-this.Po;this.Fo()&&(s*=-1);const i=s*n,r=K(this.uo).Xe();r.nr(i),this.Wo(r,!0),this.Co=null}v_(){this.zo()||this.Po!==null&&(this.Po=null,this.uo=null)}sl(){return this.el||this.vl(),this.el}Ji(t,n){switch(this.yn.mode){case 2:return this.m_(Ns(t,n));case 3:return this.sl().format(xi(t,n));default:return this.cr(t)}}ro(t){switch(this.yn.mode){case 2:return this.m_(t);case 3:return this.sl().format(t);default:return this.cr(t)}}so(t){switch(this.yn.mode){case 2:return this.w_(t);case 3:return this.sl().formatTickmarks(t);default:return this.M_(t)}}xa(t){return this.cr(t,K(this.So).sl())}Ca(t,n){return t=Ns(t,n),this.m_(t,Xh)}g_(){return this.bo}b_(t){this.co={fo:t,do:!1}}Nn(){this.bo.forEach(t=>t.Nn())}Xl(){return this.yn.ensureEdgeTickMarksVisible&&this.zo()}Ql(){return this.P()/2}vl(){this.Co=null;let t=1/0;this.So=null;for(const s of this.bo)s.ln()<t&&(t=s.ln(),this.So=s);let n=100;this.So!==null&&(n=Math.round(this.So.Kh())),this.el=Qh,this.je()?(this.el=Xh,n=100):this.No()?(this.el=new Jr(100,1),n=100):this.So!==null&&(this.el=this.So.sl()),this.Vo=new Gh(this,n,this.Bo.bind(this),this.Eo.bind(this)),this.Vo.Kl()}a_(){this.xo=null}S_(){return this.So===null||this.je()||this.No()?1:1/this.So.Kh()}Xi(){return this.Io}Zo(t){this.po=t}qo(){return this.Fo()?this.yn.scaleMargins.bottom*this.$t()+this.mo:this.yn.scaleMargins.top*this.$t()+this.vo}Yo(){return this.Fo()?this.yn.scaleMargins.top*this.$t()+this.vo:this.yn.scaleMargins.bottom*this.$t()+this.mo}Ko(){this.co.do||(this.co.do=!0,this.x_())}Lo(){this._o=null}Eo(t,n){if(this.Ko(),this.Zi())return 0;t=this.ho()&&t?Fr(t,this.ko):t;const s=K(this.ar()),i=this.Yo()+(this.jo()-1)*(t-s.Je())/s.tr();return this.Xo(i)}Bo(t,n){if(this.Ko(),this.Zi())return 0;const s=this.Xo(t),i=K(this.ar()),r=i.Je()+i.tr()*((s-this.Yo())/(this.jo()-1));return this.ho()?wi(r,this.ko):r}Ho(){this.Co=null,this.Vo.Kl()}x_(){if(this.Oo()&&!this.zo())return;const t=this.co.fo;if(t===null)return;let n=null;const s=this.g_();let i=0,r=0;for(const c of s){if(!c.It())continue;const h=c.Lt();if(h===null)continue;const a=c.la(t.Na(),t.bi());let u=a&&a.ar();if(u!==null){switch(this.yn.mode){case 1:u=ai(u,this.ko);break;case 2:u=vx(u,h.Wt);break;case 3:u=xx(u,h.Wt)}if(n=n===null?u:n.Ss(K(u)),a!==null){const f=a.lr();f!==null&&(i=Math.max(i,f.above),r=Math.max(r,f.below))}}}if(this.Xl()&&(i=Math.max(i,this.Ql()),r=Math.max(r,this.Ql())),i===this.vo&&r===this.mo||(this.vo=i,this.mo=r,this.Co=null,this.Lo()),n!==null){if(n.Je()===n.Qe()){const c=5*this.S_();this.ho()&&(n=Is(n,this.ko)),n=new ke(n.Je()-c,n.Qe()+c),this.ho()&&(n=ai(n,this.ko))}if(this.ho()){const c=Is(n,this.ko),h=No(c);if(o=h,l=this.ko,o.Ol!==l.Ol||o.Nl!==l.Nl){const a=this.uo!==null?Is(this.uo,this.ko):null;this.ko=h,n=ai(c,h),a!==null&&(this.uo=ai(a,h))}}this.Wo(n)}else this.rr===null&&(this.Wo(new ke(-.5,.5)),this.ko=No(null));var o,l}Qo(){return this.je()?Ns:this.No()?xi:this.ho()?t=>Fr(t,this.ko):null}C_(t,n,s){return n===void 0?(s===void 0&&(s=this.sl()),s.format(t)):n(t)}y_(t,n,s){return n===void 0?(s===void 0&&(s=this.sl()),s.formatTickmarks(t)):n(t)}cr(t,n){return this.C_(t,this.Do.priceFormatter,n)}M_(t,n){const s=this.Do.priceFormatter;return this.y_(t,this.Do.tickmarksPriceFormatter??(s?i=>i.map(s):void 0),n)}m_(t,n){return this.C_(t,this.Do.percentageFormatter,n)}w_(t,n){const s=this.Do.percentageFormatter;return this.y_(t,this.Do.tickmarksPercentageFormatter??(s?i=>i.map(s):void 0),n)}}function Jh(e){return e instanceof Kr}class va{constructor(t,n){this.bo=[],this.P_=new Map,this.oo=0,this.k_=0,this.T_=1,this.xo=null,this.R_=null,this.D_=!1,this.I_=new Zt,this.fa=[],this.ia=t,this.sn=n,this.V_=new bx(this);const s=n.N();this.B_=this.E_("left",s.leftPriceScale),this.A_=this.E_("right",s.rightPriceScale),this.B_.Uo().i(this.L_.bind(this,this.B_),this),this.A_.Uo().i(this.L_.bind(this,this.A_),this),this.z_(s)}z_(t){if(t.leftPriceScale&&this.B_.vr(t.leftPriceScale),t.rightPriceScale&&this.A_.vr(t.rightPriceScale),t.localization&&(this.B_.vl(),this.A_.vl()),t.overlayPriceScales){const n=Array.from(this.P_.values());for(const s of n){const i=K(s[0].Ft());i.vr(t.overlayPriceScales),t.localization&&i.vl()}}}O_(t){switch(t){case"left":return this.B_;case"right":return this.A_}return this.P_.has(t)?Re(this.P_.get(t))[0].Ft():null}m(){this.Qt().N_().u(this),this.B_.Uo().u(this),this.A_.Uo().u(this),this.bo.forEach(t=>{t.m&&t.m()}),this.fa=this.fa.filter(t=>{const n=t.Qh();return n.detached&&n.detached(),!1}),this.I_.p()}F_(){return this.T_}W_(t){this.T_=t}Qt(){return this.sn}nn(){return this.k_}$t(){return this.oo}H_(t){this.k_=t,this.U_()}$o(t){this.oo=t,this.B_.$o(t),this.A_.$o(t),this.bo.forEach(n=>{if(this.Gs(n)){const s=n.Ft();s!==null&&s.$o(t)}}),this.U_()}j_(t){this.D_=t}q_(){return this.D_}Y_(){return this.bo.filter(Jh)}kl(){return this.bo}Gs(t){const n=t.Ft();return n===null||this.B_!==n&&this.A_!==n}h_(t,n,s){this.K_(t,n,s?t.ln():this.bo.length)}l_(t,n){const s=this.bo.indexOf(t);pe(s!==-1,"removeDataSource: invalid data source"),this.bo.splice(s,1),n||this.bo.forEach((o,l)=>o._n(l));const i=K(t.Ft()).pl();if(this.P_.has(i)){const o=Re(this.P_.get(i)),l=o.indexOf(t);l!==-1&&(o.splice(l,1),o.length===0&&this.P_.delete(i))}const r=t.Ft();r&&r.kl().indexOf(t)>=0&&(r.l_(t),this.G_(r)),this.Z_()}Xs(t){return t===this.B_?"left":t===this.A_?"right":"overlay"}X_(){return this.B_}J_(){return this.A_}Q_(t,n){t.u_(n)}tu(t,n){t.c_(n),this.U_()}iu(t){t.d_()}nu(t,n){t.f_(n)}su(t,n){t.p_(n),this.U_()}eu(t){t.v_()}U_(){this.bo.forEach(t=>{t.Nn()})}kn(){const[t,n]=this.ru();let s=null;return t.N().visible&&t.kl().length!==0?s=t:n.N().visible&&n.kl().length!==0?s=n:this.bo.length!==0&&(s=this.bo[0].Ft()),s===null&&(s=this.Zs()??t),s}Zs(){const[t,n]=this.ru();return t.N().visible?t:n.N().visible?n:null}G_(t){t!==null&&t.zo()&&this.hu(t)}au(t){const n=this.ia.Ee();t.Ao({hs:!0}),n!==null&&t.b_(n),this.U_()}lu(){this.hu(this.B_),this.hu(this.A_)}ou(){this.G_(this.B_),this.G_(this.A_),this.bo.forEach(t=>{this.Gs(t)&&this.G_(t.Ft())}),this.U_(),this.sn.mr()}Dt(){return this.xo===null&&(this.xo=Qf(this.bo)),this.xo}_u(){var o;const t=this.Dt(),n=(o=this.sn.cu())==null?void 0:o.uu,s=this.sn.N().hoveredSeriesOnTop,i=this.R_;if(i!==null&&i.Kh===t&&i.du===n&&i.fu===s)return i.pu;const r=function(l,c,h){if(!h)return l;const a=l.indexOf(c);if(a===-1||a===l.length-1)return l;const u=[];for(let f=0;f<l.length;f++)f!==a&&u.push(l[f]);return u.push(l[a]),u}(t,n,s);return this.R_={Kh:t,du:n,fu:s,pu:r},r}vu(t,n){n=Ls(n,0,this.bo.length-1);const s=this.bo.indexOf(t);pe(s!==-1,"setSeriesOrder: invalid data source"),this.bo.splice(s,1),this.bo.splice(n,0,t),this.bo.forEach((i,r)=>i._n(r)),this.Z_();for(const i of[this.B_,this.A_])i.a_(),i.vl();this.sn.mr()}Vt(){return this.Dt().filter(Jh)}mu(){return this.I_}wu(){return this.V_}ol(t){this.fa.push(new rx(t))}_l(t){this.fa=this.fa.filter(n=>n.Qh()!==t),t.detached&&t.detached(),this.sn.mr()}Mu(){return this.fa}il(t,n){return this.fa.map(s=>s.Qs(t,n)).filter(s=>s!==null)}hu(t){const n=t.g_();if(n&&n.length>0&&!this.ia.Zi()){const s=this.ia.Ee();s!==null&&t.b_(s)}t.Nn()}K_(t,n,s){let i=this.O_(n);if(i===null&&(i=this.E_(n,this.sn.N().overlayPriceScales)),this.bo.splice(s,0,t),!Qr(n)){const r=this.P_.get(n)||[];r.push(t),this.P_.set(n,r)}t._n(s),i.h_(t),t.un(i),this.G_(i),this.Z_()}Z_(){this.xo=null,this.R_=null}ru(){return this.sn.N().defaultVisiblePriceScaleId==="left"?[this.B_,this.A_]:[this.A_,this.B_]}L_(t,n,s){n._e!==s._e&&this.hu(t)}E_(t,n){const s={visible:!0,autoScale:!0,...an(n)},i=new wx(t,s,this.sn.N().layout,this.sn.N().localization,this.sn.Xi());return i.$o(this.$t()),i}}function xa(e,t){return t===null||e.se===2&&t.se!==2||(t.se!==2||e.se===2)&&e.ne!==t.ne&&e.ne<t.ne}function Jf(e){return{te:e.te,ie:e.ie}}function Sx(e){return{ne:e.distance??0,se:e.hitTestPriority??(e.itemType==="marker"?2:0),ee:e.itemType??"primitive",gu:e.cursorStyle,te:e.externalId}}function ur(e){return{uu:e.uu,bu:Jf(e.Su),gu:e.Su.gu,ee:e.Su.ee??"primitive"}}function Cx(e,t,n,s){var r;let i=null;for(const o of e){let l=((r=o.Qs)==null?void 0:r.call(o,t,n,s))??null;if(l===null){const c=o.Tt(s);l=c!==null&&c.Qs?c.Qs(t,n):null}if(l!==null){const c={xu:o,Su:l};(i===null||xa(c.Su,i.Su))&&(i=c)}}return i}function kx(e){return e.jn!==void 0}function Kf(e,t,n){const s=[e,...e.Dt()].reverse(),i=function(l,c,h){var d;let a,u,f;for(const w of l){const C=((d=w.il)==null?void 0:d.call(w,c,h))??[];for(const x of C){const k=Sx(x);p=x.zOrder,g=a==null?void 0:a.zOrder,(!g||p==="top"&&g!=="top"||p==="normal"&&g==="bottom"||x.zOrder===(a==null?void 0:a.zOrder)&&u!==void 0&&xa(k,u)||x.zOrder===(a==null?void 0:a.zOrder)&&u===void 0)&&(a=x,u=k,f=w)}}var p,g;return a&&f&&u?{Su:u,Cu:a,uu:f}:null}(s,t,n);if((i==null?void 0:i.Cu.zOrder)==="top")return ur(i);let r=null,o=null;for(const l of s){if(i&&i.uu===l&&i.Cu.zOrder!=="bottom"&&!i.Cu.isBackground)return r??ur(i);if(kx(l)){const c=Cx(l.jn(e),t,n,e);if(c!==null){const h={uu:l,xu:c.xu,bu:Jf(c.Su),gu:c.Su.gu,ee:c.Su.ee??"primitive"};(r===null||xa(c.Su,o))&&(r=h,o=c.Su)}}if(i&&i.uu===l&&i.Cu.zOrder!=="bottom"&&i.Cu.isBackground)return r??ur(i)}return r!==null?r:i!=null&&i.Cu?ur(i):null}class Mx{constructor(t,n,s=50){this.Vs=0,this.Bs=1,this.Es=1,this.Ls=new Map,this.As=new Map,this.yu=t,this.Pu=n,this.zs=s}ku(t){const n=t.time,s=this.Pu.cacheKey(n),i=this.Ls.get(s);if(i!==void 0)return i.Tu;if(this.Vs===this.zs){const o=this.As.get(this.Es);this.As.delete(this.Es),this.Ls.delete(Re(o)),this.Es++,this.Vs--}const r=this.yu(t);return this.Ls.set(s,{Tu:r,Ws:this.Bs}),this.As.set(this.Bs,s),this.Vs++,this.Bs++,r}}class Si{constructor(t,n){pe(t<=n,"right should be >= left"),this.Ru=t,this.Du=n}Na(){return this.Ru}bi(){return this.Du}Iu(){return this.Du-this.Ru+1}ze(t){return this.Ru<=t&&t<=this.Du}Ze(t){return this.Ru===t.Na()&&this.Du===t.bi()}}function Kh(e,t){return e===null||t===null?e===t:e.Ze(t)}class Ex{constructor(){this.Vu=new Map,this.Ls=null,this.Bu=!1}Eu(t){this.Bu=t,this.Ls=null}Au(t,n){this.Lu(n),this.Ls=null;for(let s=n;s<t.length;++s){const i=t[s];let r=this.Vu.get(i.timeWeight);r===void 0&&(r=[],this.Vu.set(i.timeWeight,r)),r.push({index:s,time:i.time,weight:i.timeWeight,originalTime:i.originalTime})}}zu(t,n,s,i,r){const o=Math.ceil(n/t);return this.Ls!==null&&this.Ls.Ou===o&&r===this.Ls.Nu&&s===this.Ls.Fu||(this.Ls={Nu:r,Fu:s,zl:this.Wu(o,s,i),Ou:o}),this.Ls.zl}Lu(t){if(t===0)return void this.Vu.clear();const n=[];this.Vu.forEach((s,i)=>{t<=s[0].index?n.push(i):s.splice(es(s,t,r=>r.index<t),1/0)});for(const s of n)this.Vu.delete(s)}Wu(t,n,s){let i=[];const r=o=>!n||s.has(o.index);for(const o of Array.from(this.Vu.keys()).sort((l,c)=>c-l)){if(!this.Vu.get(o))continue;const l=i;i=[];const c=l.length;let h=0;const a=Re(this.Vu.get(o)),u=a.length;let f=1/0,p=-1/0;for(let g=0;g<u;g++){const d=a[g],w=d.index;for(;h<c;){const C=l[h],x=C.index;if(!(x<w&&r(C))){f=x;break}h++,i.push(C),p=x,f=1/0}if(f-w>=t&&w-p>=t&&r(d))i.push(d),p=w;else if(this.Bu)return l}for(;h<c;h++)r(l[h])&&i.push(l[h])}return i}}class zs{constructor(t){this.Hu=t}Uu(){return this.Hu===null?null:new Si(Math.floor(this.Hu.Na()),Math.ceil(this.Hu.bi()))}$u(){return this.Hu}static ju(){return new zs(null)}}function Tx(e,t){return e.weight>t.weight?e:t}class Ax{constructor(t,n,s,i){this.k_=0,this.qu=null,this.Yu=[],this.Po=null,this.yo=null,this.Ku=new Ex,this.Gu=new Map,this.Zu=zs.ju(),this.Xu=!0,this.Ju=new Zt,this.Qu=new Zt,this.tc=new Zt,this.nc=null,this.sc=null,this.ec=new Map,this.rc=-1,this.hc=[],this.ac=1,this.yn=n,this.Do=s,this.lc=n.rightOffset,this.oc=n.barSpacing,this.sn=t,this._c(n),this.Pu=i,this.uc(),this.Ku.Eu(n.uniformDistribution),this.cc(),this.dc()}N(){return this.yn}fc(t){$e(this.Do,t),this.vc(),this.uc()}vr(t,n){$e(this.yn,t),this.yn.fixLeftEdge&&this.mc(),this.yn.fixRightEdge&&this.wc(),t.barSpacing!==void 0&&this.sn.Ms(t.barSpacing),t.rightOffset!==void 0&&this.sn.gs(t.rightOffset),this._c(t),t.minBarSpacing===void 0&&t.maxBarSpacing===void 0||this.sn.Ms(t.barSpacing??this.oc),t.ignoreWhitespaceIndices!==void 0&&t.ignoreWhitespaceIndices!==this.yn.ignoreWhitespaceIndices&&this.dc(),this.vc(),this.uc(),t.enableConflation===void 0&&t.conflationThresholdFactor===void 0||this.cc(),this.tc.p()}Rn(t){var n;return((n=this.Yu[t])==null?void 0:n.time)??null}en(t){return this.Yu[t]??null}Mc(t,n){if(this.Yu.length<1)return null;if(this.Pu.key(t)>this.Pu.key(this.Yu[this.Yu.length-1].time))return n?this.Yu.length-1:null;const s=es(this.Yu,this.Pu.key(t),(i,r)=>this.Pu.key(i.time)<r);return this.Pu.key(t)<this.Pu.key(this.Yu[s].time)?n?s:null:s}Zi(){return this.k_===0||this.Yu.length===0||this.qu===null}gc(){return this.Yu.length>0}Ee(){return this.bc(),this.Zu.Uu()}Sc(){return this.bc(),this.Zu.$u()}xc(){const t=this.Ee();if(t===null)return null;const n={from:t.Na(),to:t.bi()};return this.Cc(n)}Cc(t){const n=Math.round(t.from),s=Math.round(t.to),i=K(this.yc()),r=K(this.Pc());return{from:K(this.en(Math.max(i,n))),to:K(this.en(Math.min(r,s)))}}kc(t){return{from:K(this.Mc(t.from,!0)),to:K(this.Mc(t.to,!0))}}nn(){return this.k_}H_(t){if(!isFinite(t)||t<=0||this.k_===t)return;const n=this.Sc(),s=this.k_;if(this.k_=t,this.Xu=!0,this.yn.lockVisibleTimeRangeOnResize&&s!==0){const i=this.oc*t/s;this.oc=i}if(this.yn.fixLeftEdge&&n!==null&&n.Na()<=0){const i=s-t;this.lc-=Math.round(i/this.oc)+1,this.Xu=!0}this.Tc(),this.Rc()}jt(t){if(this.Zi()||!$i(t))return 0;const n=this.Dc()+this.lc-t;return this.k_-(n+.5)*this.oc-1}Ic(t,n){const s=this.Dc(),i=n===void 0?0:n.from,r=n===void 0?t.length:n.to;for(let o=i;o<r;o++){const l=t[o].wt,c=s+this.lc-l,h=this.k_-(c+.5)*this.oc-1;t[o]._t=h}}Vc(t,n){const s=Math.ceil(this.Bc(t));return n&&this.yn.ignoreWhitespaceIndices&&!this.Ec(s)?this.Ac(s):s}gs(t){this.Xu=!0,this.lc=t,this.Rc(),this.sn.Lc(),this.sn.mr()}ml(){return this.oc}Ms(t){const n=this.oc;if(this.zc(t),this.yn.rightOffsetPixels!==void 0&&n!==0){const s=this.lc*n/this.oc;this.lc=s}this.Rc(),this.sn.Lc(),this.sn.mr()}Oc(){return this.lc}zl(){if(this.Zi())return null;if(this.sc!==null)return this.sc;const t=this.oc,n=5*(this.sn.N().layout.fontSize+4)/8*(this.yn.tickMarkMaxCharacterLength||8),s=Math.round(n/t),i=K(this.Ee()),r=Math.max(i.Na(),i.Na()-s),o=Math.max(i.bi(),i.bi()-s),l=this.Ku.zu(t,n,this.yn.ignoreWhitespaceIndices,this.ec,this.rc),c=this.yc()+s,h=this.Pc()-s,a=this.Nc(),u=this.yn.fixLeftEdge||a,f=this.yn.fixRightEdge||a;let p=0;for(const g of l){if(!(r<=g.index&&g.index<=o))continue;let d;p<this.hc.length?(d=this.hc[p],d.coord=this.jt(g.index),d.label=this.Fc(g),d.weight=g.weight):(d={needAlignCoordinate:!1,coord:this.jt(g.index),label:this.Fc(g),weight:g.weight},this.hc.push(d)),this.oc>n/2&&!a?d.needAlignCoordinate=!1:d.needAlignCoordinate=u&&g.index<=c||f&&g.index>=h,p++}return this.hc.length=p,this.sc=this.hc,this.hc}Wc(){let t;this.Xu=!0,this.Ms(this.yn.barSpacing),t=this.yn.rightOffsetPixels!==void 0?this.yn.rightOffsetPixels/this.ml():this.yn.rightOffset,this.gs(t)}Hc(t){this.Xu=!0,this.qu=t,this.Rc(),this.mc()}Uc(t,n){const s=this.Bc(t),i=this.ml(),r=i+n*(i/10);this.Ms(r),this.yn.rightBarStaysOnScroll||this.gs(this.Oc()+(s-this.Bc(t)))}u_(t){this.Po&&this.v_(),this.yo===null&&this.nc===null&&(this.Zi()||(this.yo=t,this.$c()))}c_(t){if(this.nc===null)return;const n=Ls(this.k_-t,0,this.k_),s=Ls(this.k_-K(this.yo),0,this.k_);n!==0&&s!==0&&this.Ms(this.nc.ml*n/s)}d_(){this.yo!==null&&(this.yo=null,this.jc())}f_(t){this.Po===null&&this.nc===null&&(this.Zi()||(this.Po=t,this.$c()))}p_(t){if(this.Po===null)return;const n=(this.Po-t)/this.ml();this.lc=K(this.nc).Oc+n,this.Xu=!0,this.Rc()}v_(){this.Po!==null&&(this.Po=null,this.jc())}qc(){this.Yc(this.yn.rightOffset)}Yc(t,n=400){if(!isFinite(t))throw new RangeError("offset is required and must be finite number");if(!isFinite(n)||n<=0)throw new RangeError("animationDuration (optional) must be finite positive number");const s=this.lc,i=performance.now();this.sn.ps({Kc:r=>(r-i)/n>=1,Gc:r=>{const o=(r-i)/n;return o>=1?t:s+(t-s)*o}})}Pt(t,n){this.Xu=!0,this.Yu=t,this.Ku.Au(t,n),this.Rc()}Zc(){return this.Ju}Xc(){return this.Qu}Jc(){return this.tc}Dc(){return this.qu||0}Qc(t,n){const s=t.Iu(),i=n&&this.yn.rightOffsetPixels||0;this.zc((this.k_-i)/s),this.lc=t.bi()-this.Dc(),n&&(this.lc=i?i/this.ml():this.yn.rightOffset),this.Rc(),this.Xu=!0,this.sn.Lc(),this.sn.mr()}td(){const t=this.yc(),n=this.Pc();if(t===null||n===null)return;const s=!this.yn.rightOffsetPixels&&this.yn.rightOffset||0;this.Qc(new Si(t,n+s),!0)}nd(t){const n=new Si(t.from,t.to);this.Qc(n)}rn(t){return this.Do.timeFormatter!==void 0?this.Do.timeFormatter(t.originalTime):this.Pu.formatHorzItem(t.time)}dc(){if(!this.yn.ignoreWhitespaceIndices)return;this.ec.clear();const t=this.sn.Jn();for(const n of t)for(const s of n.fl())this.ec.set(s,!0);this.rc++}sd(){return this.ac}Sl(){const t=1/(window.devicePixelRatio||1),n=this.yn.minBarSpacing;if(n>=t)return[1];const s=[1];let i=2;for(;i<=512;)n<t/i&&s.push(i),i*=2;return s}Nc(){const t=this.sn.N().handleScroll,n=this.sn.N().handleScale;return!(t.horzTouchDrag||t.mouseWheel||t.pressedMouseMove||t.vertTouchDrag||n.axisDoubleClickReset.time||n.axisPressedMouseMove.time||n.mouseWheel||n.pinch)}yc(){return this.Yu.length===0?null:0}Pc(){return this.Yu.length===0?null:this.Yu.length-1}ed(t){return(this.k_-1-t)/this.oc}Bc(t){const n=this.ed(t),s=this.Dc()+this.lc-n;return Math.round(1e6*s)/1e6}zc(t){const n=this.oc;this.oc=t,this.Tc(),n!==this.oc&&(this.Xu=!0,this.rd(),this.cc())}bc(){if(!this.Xu)return;if(this.Xu=!1,this.Zi())return void this.hd(zs.ju());const t=this.Dc(),n=this.k_/this.oc,s=this.lc+t,i=new Si(s-n+1,s);this.hd(new zs(i))}Tc(){const t=Ls(this.oc,this.ad(),this.ld());this.oc!==t&&(this.oc=t,this.Xu=!0)}ld(){return this.yn.maxBarSpacing>0?this.yn.maxBarSpacing:.5*this.k_}ad(){return this.yn.fixLeftEdge&&this.yn.fixRightEdge&&this.Yu.length!==0?this.k_/this.Yu.length:this.yn.minBarSpacing}cc(){if(!this.yn.enableConflation)return void(this.ac=1);const t=1/(window.devicePixelRatio||1)*(this.yn.conflationThresholdFactor??1);if(this.oc>=t)return void(this.ac=1);const n=t/this.oc,s=Math.pow(2,Math.floor(Math.log2(n)));this.ac=Math.min(s,512)}Rc(){const t=this.od();t!==null&&this.lc<t&&(this.lc=t,this.Xu=!0);const n=this._d();this.lc>n&&(this.lc=n,this.Xu=!0)}od(){const t=this.yc(),n=this.qu;return t===null||n===null?null:t-n-1+(this.yn.fixLeftEdge?this.k_/this.oc:Math.min(2,this.Yu.length))}_d(){return this.yn.fixRightEdge?0:this.k_/this.oc-Math.min(2,this.Yu.length)}$c(){this.nc={ml:this.ml(),Oc:this.Oc()}}jc(){this.nc=null}Fc(t){let n=this.Gu.get(t.weight);return n===void 0&&(n=new Mx(s=>this.ud(s),this.Pu),this.Gu.set(t.weight,n)),n.ku(t)}ud(t){return this.Pu.formatTickmark(t,this.Do)}hd(t){const n=this.Zu;this.Zu=t,Kh(n.Uu(),this.Zu.Uu())||this.Ju.p(),Kh(n.$u(),this.Zu.$u())||this.Qu.p(),this.rd()}rd(){this.sc=null}vc(){this.rd(),this.Gu.clear()}uc(){this.Pu.updateFormatter(this.Do)}mc(){if(!this.yn.fixLeftEdge)return;const t=this.yc();if(t===null)return;const n=this.Ee();if(n===null)return;const s=n.Na()-t;if(s<0){const i=this.lc-s-1;this.gs(i)}this.Tc()}wc(){this.Rc(),this.Tc()}Ec(t){return!this.yn.ignoreWhitespaceIndices||this.ec.get(t)||!1}Ac(t){const n=function*(i){const r=Math.round(i),o=r<i;let l=1;for(;;)o?(yield r+l,yield r-l):(yield r-l,yield r+l),l++}(t),s=this.Pc();for(;s;){const i=n.next().value;if(this.ec.get(i))return i;if(i<0||i>s)break}return t}_c(t){if(t.rightOffsetPixels!==void 0){const n=t.rightOffsetPixels/(t.barSpacing||this.oc);this.sn.gs(n)}}}var Zh,tu,eu,nu,su;(function(e){e[e.OnTouchEnd=0]="OnTouchEnd",e[e.OnNextTap=1]="OnNextTap"})(Zh||(Zh={}));class Rx{constructor(t,n,s){this.dd=[],this.fd=[],this.pd=null,this.k_=0,this.vd=null,this.md=new Zt,this.wd=new Zt,this.Md=null,this.gd=t,this.yn=n,this.Pu=s,this.Io=new kv(this.yn.layout.colorParsers),this.bd=new Cv(this),this.ia=new Ax(this,n.timeScale,this.yn.localization,s),this.Ct=new Lv(this,n.crosshair),this.Sd=new px(n.crosshair),n.addDefaultPane&&(this.xd(0),this.dd[0].W_(2)),this.Cd=this.yd(0),this.Pd=this.yd(1)}ka(){this.kd(fe.ys())}mr(){this.kd(fe.Cs())}Ya(){this.kd(new fe(1))}Ta(t){const n=this.Td(t);this.kd(n)}cu(){return this.vd}Rd(t){var s,i,r,o,l,c,h,a,u;if(((s=this.vd)==null?void 0:s.uu)===(t==null?void 0:t.uu)&&((r=(i=this.vd)==null?void 0:i.bu)==null?void 0:r.te)===((o=t==null?void 0:t.bu)==null?void 0:o.te)&&((c=(l=this.vd)==null?void 0:l.bu)==null?void 0:c.ie)===((h=t==null?void 0:t.bu)==null?void 0:h.ie)&&((a=this.vd)==null?void 0:a.gu)===(t==null?void 0:t.gu)&&((u=this.vd)==null?void 0:u.ee)===(t==null?void 0:t.ee))return;const n=this.vd;this.vd=t,n!==null&&this.Ta(n.uu),t!==null&&t.uu!==(n==null?void 0:n.uu)&&this.Ta(t.uu)}N(){return this.yn}vr(t){$e(this.yn,t),this.dd.forEach(n=>n.z_(t)),t.timeScale!==void 0&&this.ia.vr(t.timeScale),t.localization!==void 0&&this.ia.fc(t.localization),(t.leftPriceScale||t.rightPriceScale)&&this.md.p(),this.Cd=this.yd(0),this.Pd=this.yd(1),this.ka()}Dd(t,n,s=0){const i=this.dd[s];if(i===void 0)return;if(t==="left")return $e(this.yn,{leftPriceScale:n}),i.z_({leftPriceScale:n}),this.md.p(),void this.ka();if(t==="right")return $e(this.yn,{rightPriceScale:n}),i.z_({rightPriceScale:n}),this.md.p(),void this.ka();const r=this.Id(t,s);r!==null&&(r.Ft.vr(n),this.md.p())}Id(t,n){const s=this.dd[n];if(s===void 0)return null;const i=s.O_(t);return i!==null?{Kn:s,Ft:i}:null}Et(){return this.ia}Gn(){return this.dd}Vd(){return this.Ct}Bd(){return this.wd}Ed(t,n){t.$o(n),this.Lc()}H_(t){this.k_=t,this.ia.H_(this.k_),this.dd.forEach(n=>n.H_(t)),this.Lc()}Ad(t){this.dd.length!==1&&(pe(t>=0&&t<this.dd.length,"Invalid pane index"),this.dd.splice(t,1),this.ka())}Ld(t,n){if(this.dd.length<2)return;pe(t>=0&&t<this.dd.length,"Invalid pane index");const s=this.dd[t],i=this.dd.reduce((u,f)=>u+f.F_(),0),r=this.dd.reduce((u,f)=>u+f.$t(),0),o=r-30*(this.dd.length-1);n=Math.min(o,Math.max(30,n));const l=i/r,c=s.$t();s.W_(n*l);let h=n-c,a=this.dd.length-1;for(const u of this.dd)if(u!==s){const f=Math.min(o,Math.max(30,u.$t()-h/a));h-=u.$t()-f,a-=1;const p=f*l;u.W_(p)}this.ka()}zd(t,n){pe(t>=0&&t<this.dd.length&&n>=0&&n<this.dd.length,"Invalid pane index");const s=this.dd[t],i=this.dd[n];this.dd[t]=i,this.dd[n]=s,this.ka()}Od(t,n){if(pe(t>=0&&t<this.dd.length&&n>=0&&n<this.dd.length,"Invalid pane index"),t===n)return;const[s]=this.dd.splice(t,1);this.dd.splice(n,0,s),this.ka()}Q_(t,n,s){t.Q_(n,s)}tu(t,n,s){t.tu(n,s),this.Ra(),this.kd(this.Nd(t,2))}iu(t,n){t.iu(n),this.kd(this.Nd(t,2))}nu(t,n,s){n.zo()||t.nu(n,s)}su(t,n,s){n.zo()||(t.su(n,s),this.Ra(),this.kd(this.Nd(t,2)))}eu(t,n){n.zo()||(t.eu(n),this.kd(this.Nd(t,2)))}au(t,n){t.au(n),this.kd(this.Nd(t,2))}Fd(t){this.ia.u_(t)}Wd(t,n){const s=this.Et();if(s.Zi()||n===0)return;const i=s.nn();t=Math.max(1,Math.min(t,i)),s.Uc(t,n),this.Lc()}Hd(t){this.Ud(0),this.$d(t),this.jd()}qd(t){this.ia.c_(t),this.Lc()}Yd(){this.ia.d_(),this.mr()}Ud(t){this.ia.f_(t)}$d(t){this.ia.p_(t),this.Lc()}jd(){this.ia.v_(),this.mr()}Jn(){return this.fd}Wn(){return this.pd===null&&(this.pd=this.fd.filter(t=>t.It())),this.pd}Pa(){this.pd=null}Kd(t,n,s,i,r){this.Ct.In(t,n);let o=NaN,l=this.ia.Vc(t,!0);const c=this.ia.Ee();c!==null&&(l=Math.min(Math.max(c.Na(),l),c.bi())),l=this.Ct.Fn(l);const h=i.kn(),a=h.Lt();if(a!==null&&(o=h.Tn(n,a)),o=this.Sd.Pl(o,l,i),this.Ct.An(l,o,i),this.Ya(),!r){const u=Kf(i,t,n);this.Rd(u&&{uu:u.uu,bu:u.bu,gu:u.gu||null,ee:u.ee}),this.wd.p(this.Ct.Bt(),{x:t,y:n},s)}}Gd(t,n,s){const i=s.kn(),r=i.Lt(),o=i.Nt(t,K(r)),l=this.ia.Mc(n,!0),c=this.ia.jt(K(l));this.Kd(c,o,null,s,!0)}Zd(t){this.Vd().zn(),this.Ya(),t||this.wd.p(null,null,null)}Ra(){const t=this.Ct.Kn();if(t!==null){const n=this.Ct.Bn(),s=this.Ct.En();this.Kd(n,s,null,t)}this.Ct.Nn()}Xd(t,n,s){const i=this.ia.Rn(0);n!==void 0&&s!==void 0&&this.ia.Pt(n,s);const r=this.ia.Rn(0),o=this.ia.Dc(),l=this.ia.Ee();if(l!==null&&i!==null&&r!==null){const c=l.ze(o),h=this.Pu.key(i)>this.Pu.key(r),a=t!==null&&t>o&&!h,u=this.ia.N().allowShiftVisibleRangeOnWhitespaceReplacement,f=c&&(s!==void 0||u)&&this.ia.N().shiftVisibleRangeOnNewBar;if(a&&!f){const p=t-o;this.ia.gs(this.ia.Oc()-p)}}this.ia.Hc(t)}Ba(t){t!==null&&t.ou()}Ks(t){if(function(s){return s instanceof va}(t))return t;const n=this.dd.find(s=>s.Dt().includes(t));return n===void 0?null:n}Lc(){this.dd.forEach(t=>t.ou()),this.Ra()}m(){this.dd.forEach(t=>t.m()),this.dd.length=0,this.yn.localization.priceFormatter=void 0,this.yn.localization.percentageFormatter=void 0,this.yn.localization.timeFormatter=void 0}Jd(){return this.bd}Js(){return this.bd.N()}N_(){return this.md}Qd(t,n){const s=this.xd(n);this.tf(t,s),this.fd.push(t),this.Pa(),this.fd.length===1?this.ka():this.mr()}if(t){const n=this.Ks(t),s=this.fd.indexOf(t);pe(s!==-1,"Series not found");const i=K(n);this.fd.splice(s,1),i.l_(t),t.m&&t.m(),this.Pa(),this.ia.dc(),this.nf(i)}ya(t,n){const s=K(this.Ks(t));s.l_(t,!0),s.h_(t,n,!0)}td(){const t=fe.Cs();t.us(),this.kd(t)}sf(t){const n=fe.Cs();n.fs(t),this.kd(n)}ws(){const t=fe.Cs();t.ws(),this.kd(t)}Ms(t){const n=fe.Cs();n.Ms(t),this.kd(n)}gs(t){const n=fe.Cs();n.gs(t),this.kd(n)}ps(t){const n=fe.Cs();n.ps(t),this.kd(n)}cs(){const t=fe.Cs();t.cs(),this.kd(t)}ef(){const t=this.yn.defaultVisiblePriceScaleId,n=this.yn.leftPriceScale.visible;return n!==this.yn.rightPriceScale.visible?n?"left":"right":t}rf(t,n){if(pe(n>=0,"Index should be greater or equal to 0"),n===this.hf(t))return;const s=K(this.Ks(t));s.l_(t);const i=this.xd(n);this.tf(t,i);let r=!1;s.kl().length===0&&(r=this.nf(s)),r||this.ka()}af(){return this.Pd}$(){return this.Cd}Ut(t){const n=this.Pd,s=this.Cd;if(n===s)return n;if(t=Math.max(0,Math.min(100,Math.round(100*t))),this.Md===null||this.Md.ah!==s||this.Md.oh!==n)this.Md={ah:s,oh:n,lf:new Map};else{const r=this.Md.lf.get(t);if(r!==void 0)return r}const i=this.Io.tt(s,n,t/100);return this.Md.lf.set(t,i),i}_f(t){return this.dd.indexOf(t)}Xi(){return this.Io}uf(){return this.cf()}cf(t){const n=new va(this.ia,this);this.dd.push(n);const s=t??this.dd.length-1,i=fe.ys();return i.es(s,{rs:0,hs:!0}),this.kd(i),n}xd(t){return pe(t>=0,"Index should be greater or equal to 0"),(t=Math.min(this.dd.length,t))<this.dd.length?this.dd[t]:this.cf(t)}hf(t){return this.dd.findIndex(n=>n.Y_().includes(t))}Nd(t,n){const s=new fe(n);if(t!==null){const i=this.dd.indexOf(t);s.es(i,{rs:n})}return s}Td(t,n){return n===void 0&&(n=2),this.Nd(this.Ks(t),n)}kd(t){this.gd&&this.gd(t),this.dd.forEach(n=>n.wu().wr().Pt())}tf(t,n){const s=t.N().priceScaleId,i=s!==void 0?s:this.ef();n.h_(t,i),Qr(i)||t.vr(t.N())}yd(t){const n=this.yn.layout;return n.background.type==="gradient"?t===0?n.background.topColor:n.background.bottomColor:n.background.color}nf(t){return!t.q_()&&t.kl().length===0&&this.dd.length>1&&(this.dd.splice(this._f(t),1),this.ka(),!0)}}function Zf(e){if(e>=1)return 0;let t=0;for(;t<8;t++){const n=Math.round(e);if(Math.abs(n-e)<1e-8)return t;e*=10}return t}function wa(e){return!js(e)&&!Bi(e)}function tm(e){return js(e)}(function(e){e[e.Disabled=0]="Disabled",e[e.Continuous=1]="Continuous",e[e.OnDataUpdate=2]="OnDataUpdate"})(tu||(tu={})),function(e){e[e.LastBar=0]="LastBar",e[e.LastVisible=1]="LastVisible"}(eu||(eu={})),function(e){e.Solid="solid",e.VerticalGradient="gradient"}(nu||(nu={})),function(e){e[e.Year=0]="Year",e[e.Month=1]="Month",e[e.DayOfMonth=2]="DayOfMonth",e[e.Time=3]="Time",e[e.TimeWithSeconds=4]="TimeWithSeconds"}(su||(su={}));const iu=e=>e.getUTCFullYear();function Px(e,t,n){return t.replace(/yyyy/g,(s=>ln(iu(s),4))(e)).replace(/yy/g,(s=>ln(iu(s)%100,2))(e)).replace(/MMMM/g,((s,i)=>new Date(s.getUTCFullYear(),s.getUTCMonth(),1).toLocaleString(i,{month:"long"}))(e,n)).replace(/MMM/g,((s,i)=>new Date(s.getUTCFullYear(),s.getUTCMonth(),1).toLocaleString(i,{month:"short"}))(e,n)).replace(/MM/g,(s=>ln((i=>i.getUTCMonth()+1)(s),2))(e)).replace(/dd/g,(s=>ln((i=>i.getUTCDate())(s),2))(e))}class em{constructor(t="yyyy-MM-dd",n="default"){this.df=t,this.ff=n}ku(t){return Px(t,this.df,this.ff)}}class _x{constructor(t){this.pf=t||"%h:%m:%s"}ku(t){return this.pf.replace("%h",ln(t.getUTCHours(),2)).replace("%m",ln(t.getUTCMinutes(),2)).replace("%s",ln(t.getUTCSeconds(),2))}}const $x={vf:"yyyy-MM-dd",mf:"%h:%m:%s",wf:" ",Mf:"default"};class Nx{constructor(t={}){const n={...$x,...t};this.gf=new em(n.vf,n.Mf),this.bf=new _x(n.mf),this.Sf=n.wf}ku(t){return`${this.gf.ku(t)}${this.Sf}${this.bf.ku(t)}`}}function dr(e){return 60*e*60*1e3}function Do(e){return 60*e*1e3}const fr=[{xf:(ru=1,1e3*ru),Cf:10},{xf:Do(1),Cf:20},{xf:Do(5),Cf:21},{xf:Do(30),Cf:22},{xf:dr(1),Cf:30},{xf:dr(3),Cf:31},{xf:dr(6),Cf:32},{xf:dr(12),Cf:33}];var ru;function ou(e,t){if(e.getUTCFullYear()!==t.getUTCFullYear())return 70;if(e.getUTCMonth()!==t.getUTCMonth())return 60;if(e.getUTCDate()!==t.getUTCDate())return 50;for(let n=fr.length-1;n>=0;--n)if(Math.floor(t.getTime()/fr[n].xf)!==Math.floor(e.getTime()/fr[n].xf))return fr[n].Cf;return 0}function Lo(e){let t=e;if(Bi(e)&&(t=wl(e)),!wa(t))throw new Error("time must be of type BusinessDay");const n=new Date(Date.UTC(t.year,t.month-1,t.day,0,0,0,0));return{yf:Math.round(n.getTime()/1e3),Pf:t}}function au(e){if(!tm(e))throw new Error("time must be of type isUTCTimestamp");return{yf:e}}function wl(e){const t=new Date(e);if(isNaN(t.getTime()))throw new Error(`Invalid date string=${e}, expected format=yyyy-mm-dd`);return{day:t.getUTCDate(),month:t.getUTCMonth()+1,year:t.getUTCFullYear()}}function lu(e){Bi(e.time)&&(e.time=wl(e.time))}class cu{options(){return this.yn}setOptions(t){this.yn=t,this.updateFormatter(t.localization)}preprocessData(t){Array.isArray(t)?function(n){n.forEach(lu)}(t):lu(t)}createConverterToInternalObj(t){return K(function(n){return n.length===0?null:wa(n[0].time)||Bi(n[0].time)?Lo:au}(t))}key(t){return typeof t=="object"&&"yf"in t?t.yf:this.key(this.convertHorzItemToInternal(t))}cacheKey(t){const n=t;return n.Pf===void 0?new Date(1e3*n.yf).getTime():new Date(Date.UTC(n.Pf.year,n.Pf.month-1,n.Pf.day)).getTime()}convertHorzItemToInternal(t){return tm(n=t)?au(n):wa(n)?Lo(n):Lo(wl(n));var n}updateFormatter(t){if(!this.yn)return;const n=t.dateFormat;this.yn.timeScale.timeVisible?this.kf=new Nx({vf:n,mf:this.yn.timeScale.secondsVisible?"%h:%m:%s":"%h:%m",wf:" ",Mf:t.locale}):this.kf=new em(n,t.locale)}formatHorzItem(t){const n=t;return this.kf.ku(new Date(1e3*n.yf))}formatTickmark(t,n){const s=function(r,o,l){switch(r){case 0:case 10:return o?l?4:3:2;case 20:case 21:case 22:case 30:case 31:case 32:case 33:return o?3:2;case 50:return 2;case 60:return 1;case 70:return 0}}(t.weight,this.yn.timeScale.timeVisible,this.yn.timeScale.secondsVisible),i=this.yn.timeScale;if(i.tickMarkFormatter!==void 0){const r=i.tickMarkFormatter(t.originalTime,s,n.locale);if(r!==null)return r}return function(r,o,l){const c={};switch(o){case 0:c.year="numeric";break;case 1:c.month="short";break;case 2:c.day="numeric";break;case 3:c.hour12=!1,c.hour="2-digit",c.minute="2-digit";break;case 4:c.hour12=!1,c.hour="2-digit",c.minute="2-digit",c.second="2-digit"}const h=r.Pf===void 0?new Date(1e3*r.yf):new Date(Date.UTC(r.Pf.year,r.Pf.month-1,r.Pf.day));return new Date(h.getUTCFullYear(),h.getUTCMonth(),h.getUTCDate(),h.getUTCHours(),h.getUTCMinutes(),h.getUTCSeconds(),h.getUTCMilliseconds()).toLocaleString(l,c)}(t.time,s,n.locale)}maxTickMarkWeight(t){let n=t.reduce(Tx,t[0]).weight;return n>30&&n<50&&(n=30),n}fillWeightsForPoints(t,n){(function(s,i=0){if(s.length===0)return;let r=i===0?null:s[i-1].time.yf,o=r!==null?new Date(1e3*r):null,l=0;for(let c=i;c<s.length;++c){const h=s[c],a=new Date(1e3*h.time.yf);o!==null&&(h.timeWeight=ou(a,o)),l+=h.time.yf-(r||h.time.yf),r=h.time.yf,o=a}if(i===0&&s.length>1){const c=Math.ceil(l/(s.length-1)),h=new Date(1e3*(s[0].time.yf-c));s[0].timeWeight=ou(new Date(1e3*s[0].time.yf),h)}})(t,n)}static Tf(t){return $e({localization:{dateFormat:"dd MMM 'yy"}},t??{})}}const Vs=typeof window<"u";function hu(){return!!Vs&&window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1}function zo(){return!!Vs&&/iPhone|iPad|iPod/.test(window.navigator.platform)}function Ix(e,t){switch(e){case"custom":return t!==void 0?"custom-object":"series";case"price-line":return"custom-price-line";case"marker":return"series-marker";case"primitive":return"primitive";default:return"series"}}function Sa(e){return e+e%2}function Dx(e){Vs&&window.chrome!==void 0&&e.addEventListener("mousedown",t=>{if(t.button===1)return t.preventDefault(),!1})}class Zr{constructor(t,n,s){this.Rf=0,this.Df=null,this.If={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY},this.Vf=0,this.Bf=null,this.Ef={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY},this.Af=null,this.Lf=!1,this.zf=null,this.Of=null,this.Nf=!1,this.Ff=!1,this.Wf=!1,this.Hf=null,this.Uf=null,this.$f=null,this.jf=null,this.qf=null,this.Yf=null,this.Kf=null,this.Gf=0,this.Zf=!1,this.Xf=!1,this.Jf=!1,this.Qf=0,this.tp=null,this.ip=!zo(),this.np=i=>{this.sp(i)},this.ep=i=>{if(this.rp(i)){const r=this.hp(i);if(++this.Vf,this.Bf&&this.Vf>1){const{ap:o}=this.lp(Xe(i),this.Ef);o<30&&!this.Wf&&this.op(r,this.up._p),this.cp()}}else{const r=this.hp(i);if(++this.Rf,this.Df&&this.Rf>1){const{ap:o}=this.lp(Xe(i),this.If);o<5&&!this.Ff&&this.dp(r,this.up.fp),this.pp()}}},this.vp=t,this.up=n,this.yn=s,this.mp()}m(){this.Hf!==null&&(this.Hf(),this.Hf=null),this.Uf!==null&&(this.Uf(),this.Uf=null),this.jf!==null&&(this.jf(),this.jf=null),this.qf!==null&&(this.qf(),this.qf=null),this.Yf!==null&&(this.Yf(),this.Yf=null),this.$f!==null&&(this.$f(),this.$f=null),this.wp(),this.pp()}Mp(t){this.jf&&this.jf();const n=this.gp.bind(this);if(this.jf=()=>{this.vp.removeEventListener("mousemove",n)},this.vp.addEventListener("mousemove",n),this.rp(t))return;const s=this.hp(t);this.dp(s,this.up.bp),this.ip=!0}pp(){this.Df!==null&&clearTimeout(this.Df),this.Rf=0,this.Df=null,this.If={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY}}cp(){this.Bf!==null&&clearTimeout(this.Bf),this.Vf=0,this.Bf=null,this.Ef={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY}}gp(t){if(this.Jf||this.Of!==null||this.rp(t))return;const n=this.hp(t);this.dp(n,this.up.Sp),this.ip=!0}xp(t){const n=Fo(t.changedTouches,K(this.tp));if(n===null||(this.Qf=mr(t),this.Kf!==null)||this.Xf)return;this.Zf=!0;const s=this.lp(Xe(n),K(this.Of)),{Cp:i,yp:r,ap:o}=s;if(this.Nf||!(o<5)){if(!this.Nf){const l=.5*i,c=r>=l&&!this.yn.Pp(),h=l>r&&!this.yn.kp();c||h||(this.Xf=!0),this.Nf=!0,this.Wf=!0,this.wp(),this.cp()}if(!this.Xf){const l=this.hp(t,n);this.op(l,this.up.Tp),Ms(t)}}}Rp(t){if(t.button!==0)return;const n=this.lp(Xe(t),K(this.zf)),{ap:s}=n;if(s>=5&&(this.Ff=!0,this.pp()),this.Ff){const i=this.hp(t);this.dp(i,this.up.Dp)}}lp(t,n){const s=Math.abs(n._t-t._t),i=Math.abs(n.ut-t.ut);return{Cp:s,yp:i,ap:s+i}}Ip(t){let n=Fo(t.changedTouches,K(this.tp));if(n===null&&t.touches.length===0&&(n=t.changedTouches[0]),n===null)return;this.tp=null,this.Qf=mr(t),this.wp(),this.Of=null,this.Yf&&(this.Yf(),this.Yf=null);const s=this.hp(t,n);if(this.op(s,this.up.Vp),++this.Vf,this.Bf&&this.Vf>1){const{ap:i}=this.lp(Xe(n),this.Ef);i<30&&!this.Wf&&this.op(s,this.up._p),this.cp()}else this.Wf||(this.op(s,this.up.Bp),this.up.Bp&&Ms(t));this.Vf===0&&Ms(t),t.touches.length===0&&this.Lf&&(this.Lf=!1,Ms(t))}sp(t){if(t.button!==0)return;const n=this.hp(t);if(this.zf=null,this.Jf=!1,this.qf&&(this.qf(),this.qf=null),hu()&&this.vp.ownerDocument.documentElement.removeEventListener("mouseleave",this.np),!this.rp(t))if(this.dp(n,this.up.Ep),++this.Rf,this.Df&&this.Rf>1){const{ap:s}=this.lp(Xe(t),this.If);s<5&&!this.Ff&&this.dp(n,this.up.fp),this.pp()}else this.Ff||this.dp(n,this.up.Ap)}wp(){this.Af!==null&&(clearTimeout(this.Af),this.Af=null)}Lp(t){if(this.tp!==null)return;const n=t.changedTouches[0];this.tp=n.identifier,this.Qf=mr(t);const s=this.vp.ownerDocument.documentElement;this.Wf=!1,this.Nf=!1,this.Xf=!1,this.Of=Xe(n),this.Yf&&(this.Yf(),this.Yf=null);{const r=this.xp.bind(this),o=this.Ip.bind(this);this.Yf=()=>{s.removeEventListener("touchmove",r),s.removeEventListener("touchend",o)},s.addEventListener("touchmove",r,{passive:!1}),s.addEventListener("touchend",o,{passive:!1}),this.wp(),this.Af=setTimeout(this.zp.bind(this,t),240)}const i=this.hp(t,n);this.op(i,this.up.Op),this.Bf||(this.Vf=0,this.Bf=setTimeout(this.cp.bind(this),500),this.Ef=Xe(n))}Np(t){if(t.button!==0)return;const n=this.vp.ownerDocument.documentElement;hu()&&n.addEventListener("mouseleave",this.np),this.Ff=!1,this.zf=Xe(t),this.qf&&(this.qf(),this.qf=null);{const i=this.Rp.bind(this),r=this.sp.bind(this);this.qf=()=>{n.removeEventListener("mousemove",i),n.removeEventListener("mouseup",r)},n.addEventListener("mousemove",i),n.addEventListener("mouseup",r)}if(this.Jf=!0,this.rp(t))return;const s=this.hp(t);this.dp(s,this.up.Fp),this.Df||(this.Rf=0,this.Df=setTimeout(this.pp.bind(this),500),this.If=Xe(t))}mp(){this.vp.addEventListener("mouseenter",this.Mp.bind(this)),this.vp.addEventListener("touchcancel",this.wp.bind(this));{const t=this.vp.ownerDocument,n=s=>{this.up.Wp&&(s.composed&&this.vp.contains(s.composedPath()[0])||s.target&&this.vp.contains(s.target)||this.up.Wp())};this.Uf=()=>{t.removeEventListener("touchstart",n)},this.Hf=()=>{t.removeEventListener("mousedown",n)},t.addEventListener("mousedown",n),t.addEventListener("touchstart",n,{passive:!0})}zo()&&(this.$f=()=>{this.vp.removeEventListener("dblclick",this.ep)},this.vp.addEventListener("dblclick",this.ep)),this.vp.addEventListener("mouseleave",this.Hp.bind(this)),this.vp.addEventListener("touchstart",this.Lp.bind(this),{passive:!0}),Dx(this.vp),this.vp.addEventListener("mousedown",this.Np.bind(this)),this.Up(),this.vp.addEventListener("touchmove",()=>{},{passive:!1})}Up(){this.up.$p===void 0&&this.up.jp===void 0&&this.up.qp===void 0||(this.vp.addEventListener("touchstart",t=>this.Yp(t.touches),{passive:!0}),this.vp.addEventListener("touchmove",t=>{if(t.touches.length===2&&this.Kf!==null&&this.up.jp!==void 0){const n=uu(t.touches[0],t.touches[1])/this.Gf;this.up.jp(this.Kf,n),Ms(t)}},{passive:!1}),this.vp.addEventListener("touchend",t=>{this.Yp(t.touches)}))}Yp(t){t.length===1&&(this.Zf=!1),t.length!==2||this.Zf||this.Lf?this.Kp():this.Gp(t)}Gp(t){const n=this.vp.getBoundingClientRect()||{left:0,top:0};this.Kf={_t:(t[0].clientX-n.left+(t[1].clientX-n.left))/2,ut:(t[0].clientY-n.top+(t[1].clientY-n.top))/2},this.Gf=uu(t[0],t[1]),this.up.$p!==void 0&&this.up.$p(),this.wp()}Kp(){this.Kf!==null&&(this.Kf=null,this.up.qp!==void 0&&this.up.qp())}Hp(t){if(this.jf&&this.jf(),this.rp(t)||!this.ip)return;const n=this.hp(t);this.dp(n,this.up.Zp),this.ip=!zo()}zp(t){const n=Fo(t.touches,K(this.tp));if(n===null)return;const s=this.hp(t,n);this.op(s,this.up.Xp),this.Wf=!0,this.Lf=!0}rp(t){return t.sourceCapabilities&&t.sourceCapabilities.firesTouchEvents!==void 0?t.sourceCapabilities.firesTouchEvents:mr(t)<this.Qf+500}op(t,n){n&&n.call(this.up,t)}dp(t,n){n&&n.call(this.up,t)}hp(t,n){const s=n||t,i=this.vp.getBoundingClientRect()||{left:0,top:0};return{clientX:s.clientX,clientY:s.clientY,pageX:s.pageX,pageY:s.pageY,screenX:s.screenX,screenY:s.screenY,localX:s.clientX-i.left,localY:s.clientY-i.top,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey,metaKey:t.metaKey,Jp:!t.type.startsWith("mouse")&&t.type!=="contextmenu"&&t.type!=="click",Qp:t.type,tv:s.target,xu:t.view,iv:()=>{t.type!=="touchstart"&&Ms(t)}}}}function uu(e,t){const n=e.clientX-t.clientX,s=e.clientY-t.clientY;return Math.sqrt(n*n+s*s)}function Ms(e){e.cancelable&&e.preventDefault()}function Xe(e){return{_t:e.pageX,ut:e.pageY}}function mr(e){return e.timeStamp||performance.now()}function Fo(e,t){for(let n=0;n<e.length;++n)if(e[n].identifier===t)return e[n];return null}class Lx{constructor(t,n,s){this.nv=null,this.sv=null,this.ev=!0,this.rv=null,this.hv=t,this.av=t.lv()[n],this.ov=t.lv()[s],this._v=document.createElement("tr"),this._v.style.height="1px",this.uv=document.createElement("td"),this.uv.style.position="relative",this.uv.style.padding="0",this.uv.style.margin="0",this.uv.setAttribute("colspan","3"),this.cv(),this._v.appendChild(this.uv),this.ev=this.hv.N().layout.panes.enableResize,this.ev?this.dv():(this.nv=null,this.sv=null)}m(){this.sv!==null&&this.sv.m()}fv(){return this._v}pv(){return Nt({width:this.av.pv().width,height:1})}vv(){return Nt({width:this.av.vv().width,height:1*window.devicePixelRatio})}mv(t,n,s){const i=this.vv();t.fillStyle=this.hv.N().layout.panes.separatorColor,t.fillRect(n,s,i.width,i.height)}Pt(){this.cv(),this.hv.N().layout.panes.enableResize!==this.ev&&(this.ev=this.hv.N().layout.panes.enableResize,this.ev?this.dv():(this.nv!==null&&(this.uv.removeChild(this.nv.wv),this.uv.removeChild(this.nv.Mv),this.nv=null),this.sv!==null&&(this.sv.m(),this.sv=null)))}dv(){const t=document.createElement("div"),n=t.style;n.position="fixed",n.display="none",n.zIndex="49",n.top="0",n.left="0",n.width="100%",n.height="100%",n.cursor="row-resize",this.uv.appendChild(t);const s=document.createElement("div"),i=s.style;i.position="absolute",i.zIndex="50",i.top="-4px",i.height="9px",i.width="100%",i.backgroundColor="",i.cursor="row-resize",this.uv.appendChild(s);const r={bp:this.gv.bind(this),Zp:this.bv.bind(this),Fp:this.Sv.bind(this),Op:this.Sv.bind(this),Dp:this.xv.bind(this),Tp:this.xv.bind(this),Ep:this.Cv.bind(this),Vp:this.Cv.bind(this)};this.sv=new Zr(s,r,{Pp:()=>!1,kp:()=>!0}),this.nv={Mv:s,wv:t}}cv(){this.uv.style.background=this.hv.N().layout.panes.separatorColor}gv(t){this.nv!==null&&(this.nv.Mv.style.backgroundColor=this.hv.N().layout.panes.separatorHoverColor)}bv(t){this.nv!==null&&this.rv===null&&(this.nv.Mv.style.backgroundColor="")}Sv(t){if(this.nv===null)return;const n=this.av.yv().F_()+this.ov.yv().F_(),s=n/(this.av.pv().height+this.ov.pv().height),i=30*s;n<=2*i||(this.rv={Pv:t.pageY,kv:this.av.yv().F_(),Tv:n-i,Rv:n,Dv:s,Iv:i},this.nv.wv.style.display="block")}xv(t){const n=this.rv;if(n===null)return;const s=(t.pageY-n.Pv)*n.Dv,i=Ls(n.kv+s,n.Iv,n.Tv);this.av.yv().W_(i),this.ov.yv().W_(n.Rv-i),this.hv.Qt().ka()}Cv(t){this.rv!==null&&this.nv!==null&&(this.rv=null,this.nv.wv.style.display="none")}}function Bo(e,t){return e.Vv-t.Vv}function Wo(e,t,n){const s=(e.Vv-t.Vv)/(e.wt-t.wt);return Math.sign(s)*Math.min(Math.abs(s),n)}class zx{constructor(t,n,s,i){this.Bv=null,this.Ev=null,this.Av=null,this.Lv=null,this.zv=null,this.Ov=0,this.Nv=0,this.Fv=t,this.Wv=n,this.Hv=s,this.Ps=i}Uv(t,n){if(this.Bv!==null){if(this.Bv.wt===n)return void(this.Bv.Vv=t);if(Math.abs(this.Bv.Vv-t)<this.Ps)return}this.Lv=this.Av,this.Av=this.Ev,this.Ev=this.Bv,this.Bv={wt:n,Vv:t}}me(t,n){if(this.Bv===null||this.Ev===null||n-this.Bv.wt>50)return;let s=0;const i=Wo(this.Bv,this.Ev,this.Wv),r=Bo(this.Bv,this.Ev),o=[i],l=[r];if(s+=r,this.Av!==null){const h=Wo(this.Ev,this.Av,this.Wv);if(Math.sign(h)===Math.sign(i)){const a=Bo(this.Ev,this.Av);if(o.push(h),l.push(a),s+=a,this.Lv!==null){const u=Wo(this.Av,this.Lv,this.Wv);if(Math.sign(u)===Math.sign(i)){const f=Bo(this.Av,this.Lv);o.push(u),l.push(f),s+=f}}}}let c=0;for(let h=0;h<o.length;++h)c+=l[h]/s*o[h];Math.abs(c)<this.Fv||(this.zv={Vv:t,wt:n},this.Nv=c,this.Ov=function(h,a){const u=Math.log(a);return Math.log(1*u/-h)/u}(Math.abs(c),this.Hv))}Gc(t){const n=K(this.zv),s=t-n.wt;return n.Vv+this.Nv*(Math.pow(this.Hv,s)-1)/Math.log(this.Hv)}Kc(t){return this.zv===null||this.$v(t)===this.Ov}$v(t){const n=t-K(this.zv).wt;return Math.min(n,this.Ov)}}class Fx{constructor(t,n){this.jv=void 0,this.qv=void 0,this.Yv=void 0,this.vn=!1,this.Kv=t,this.Gv=n,this.Zv()}Pt(){this.Zv()}Xv(){this.jv&&this.Kv.removeChild(this.jv),this.qv&&this.Kv.removeChild(this.qv),this.jv=void 0,this.qv=void 0}Jv(){return this.vn!==this.Qv()||this.Yv!==this.tm()}tm(){return this.Gv.Qt().Xi().J(this.Gv.N().layout.textColor)>160?"dark":"light"}Qv(){return this.Gv.N().layout.attributionLogo}im(){const t=new URL(location.href);return t.hostname?"&utm_source="+t.hostname+t.pathname:""}Zv(){this.Jv()&&(this.Xv(),this.vn=this.Qv(),this.vn&&(this.Yv=this.tm(),this.qv=document.createElement("style"),this.qv.innerText="a#tv-attr-logo{--fill:#131722;--stroke:#fff;position:absolute;left:10px;bottom:10px;height:19px;width:35px;margin:0;padding:0;border:0;z-index:3;}a#tv-attr-logo[data-dark]{--fill:#D1D4DC;--stroke:#131722;}",this.jv=document.createElement("a"),this.jv.href=`https://www.tradingview.com/?utm_medium=lwc-link&utm_campaign=lwc-chart${this.im()}`,this.jv.title="Charting by TradingView",this.jv.id="tv-attr-logo",this.jv.target="_blank",this.jv.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="35" height="19" fill="none"><g fill-rule="evenodd" clip-path="url(#a)" clip-rule="evenodd"><path fill="var(--stroke)" d="M2 0H0v10h6v9h21.4l.5-1.3 6-15 1-2.7H23.7l-.5 1.3-.2.6a5 5 0 0 0-7-.9V0H2Zm20 17h4l5.2-13 .8-2h-7l-1 2.5-.2.5-1.5 3.8-.3.7V17Zm-.8-10a3 3 0 0 0 .7-2.7A3 3 0 1 0 16.8 7h4.4ZM14 7V2H2v6h6v9h4V7h2Z"/><path fill="var(--fill)" d="M14 2H2v6h6v9h6V2Zm12 15h-7l6-15h7l-6 15Zm-7-9a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"/></g><defs><clipPath id="a"><path fill="var(--stroke)" d="M0 0h35v19H0z"/></clipPath></defs></svg>',this.jv.toggleAttribute("data-dark",this.Yv==="dark"),this.Kv.appendChild(this.qv),this.Kv.appendChild(this.jv)))}}function ns(e,t){const n=K(e.ownerDocument).createElement("canvas");e.appendChild(n);const s=vv(n,{options:{allowResizeObserver:!0},transform:(i,r)=>({width:Math.max(i.width,r.width),height:Math.max(i.height,r.height)})});return s.resizeCanvasElement(t),s}function ss(e){var t;e.width=1,e.height=1,(t=e.getContext("2d"))==null||t.clearRect(0,0,1,1)}function xr(e,t,n,s){e.qh&&e.qh(t,n,s)}function fi(e,t,n,s){e.st(t,n,s)}function Ca(e,t,n,s){nm(e(n,s),t,s)}function nm(e,t,n){for(const s of e){const i=s.Tt(n);i!==null&&t(i)}}function jo(e,t){return n=>{var s,i;return function(r){return r.Ft!==void 0}(n)?(((s=n.Ft())==null?void 0:s.pl())??"")!==t?[]:((i=n.Qa)==null?void 0:i.call(n,e))??[]:[]}}function du(e,t,n,s){if(!e.length)return;let i=0;const r=e[0].$t(s,!0);let o=t===1?n/2-(e[0].Hi()-r/2):e[0].Hi()-r/2-n/2;o=Math.max(0,o);for(let l=1;l<e.length;l++){const c=e[l],h=e[l-1],a=h.$t(s,!1),u=c.Hi(),f=h.Hi();if(t===1?u>f-a:u<f+a){const p=f-a*t;c.Ui(p);const g=p-t*a/2;if((t===1?g<0:g>n)&&o>0){const d=t===1?-1-g:g-n,w=Math.min(d,o);for(let C=i;C<e.length;C++)e[C].Ui(e[C].Hi()+t*w);o-=w}}else i=l,o=t===1?f-a-u:u-(f+a)}}class fu{constructor(t,n,s,i){this.Ki=null,this.nm=null,this.sm=!1,this.rm=new Dr(200),this.hm=null,this.am=0,this.lm=!1,this.om=()=>{this.lm||this.yt._m().Qt().mr()},this.um=()=>{this.lm||this.yt._m().Qt().mr()},this.yt=t,this.yn=n,this.Ro=n.layout,this.bd=s,this.dm=i==="left",this.fm=jo("normal",i),this.pm=jo("top",i),this.vm=jo("bottom",i),this.uv=document.createElement("div"),this.uv.style.height="100%",this.uv.style.overflow="hidden",this.uv.style.width="25px",this.uv.style.left="0",this.uv.style.position="relative",this.wm=ns(this.uv,Nt({width:16,height:16})),this.wm.subscribeSuggestedBitmapSizeChanged(this.om);const r=this.wm.canvasElement;r.style.position="absolute",r.style.zIndex="1",r.style.left="0",r.style.top="0",this.Mm=ns(this.uv,Nt({width:16,height:16})),this.Mm.subscribeSuggestedBitmapSizeChanged(this.um);const o=this.Mm.canvasElement;o.style.position="absolute",o.style.zIndex="2",o.style.left="0",o.style.top="0";const l={Fp:this.Sv.bind(this),Op:this.Sv.bind(this),Dp:this.xv.bind(this),Tp:this.xv.bind(this),Wp:this.gm.bind(this),Ep:this.Cv.bind(this),Vp:this.Cv.bind(this),fp:this.bm.bind(this),_p:this.bm.bind(this),bp:this.Sm.bind(this),Zp:this.bv.bind(this)};this.sv=new Zr(this.Mm.canvasElement,l,{Pp:()=>!this.yn.handleScroll.vertTouchDrag,kp:()=>!0})}m(){this.sv.m(),this.Mm.unsubscribeSuggestedBitmapSizeChanged(this.um),ss(this.Mm.canvasElement),this.Mm.dispose(),this.wm.unsubscribeSuggestedBitmapSizeChanged(this.om),ss(this.wm.canvasElement),this.wm.dispose(),this.Ki!==null&&this.Ki.__().u(this),this.Ki=null}fv(){return this.uv}P(){return this.Ro.fontSize}xm(){const t=this.bd.N();return this.hm!==t.k&&(this.rm.Os(),this.hm=t.k),t}Cm(){if(this.Ki===null)return 0;let t=0;const n=this.xm(),s=K(this.wm.canvasElement.getContext("2d",{colorSpace:this.yt._m().N().layout.colorSpace}));s.save();const i=this.Ki.zl();s.font=this.ym(),i.length>0&&(t=Math.max(this.rm.Ii(s,i[0].eo),this.rm.Ii(s,i[i.length-1].eo)));const r=this.Pm();for(let h=r.length;h--;){const a=this.rm.Ii(s,r[h].ri());a>t&&(t=a)}const o=this.Ki.Lt();if(o!==null&&this.nm!==null&&(l=this.yn.crosshair).mode!==2&&l.horzLine.visible&&l.horzLine.labelVisible){const h=this.Ki.Tn(1,o),a=this.Ki.Tn(this.nm.height-2,o);t=Math.max(t,this.rm.Ii(s,this.Ki.Ji(Math.floor(Math.min(h,a))+.11111111111111,o)),this.rm.Ii(s,this.Ki.Ji(Math.ceil(Math.max(h,a))-.11111111111111,o)))}var l;s.restore();const c=t||34;return Sa(Math.ceil(n.S+n.C+n.V+n.B+5+c))}km(t){this.nm!==null&&Zn(this.nm,t)||(this.nm=t,this.lm=!0,this.wm.resizeCanvasElement(t),this.Mm.resizeCanvasElement(t),this.lm=!1,this.uv.style.width=`${t.width}px`,this.uv.style.height=`${t.height}px`)}Tm(){return K(this.nm).width}un(t){this.Ki!==t&&(this.Ki!==null&&this.Ki.__().u(this),this.Ki=t,t.__().i(this.wo.bind(this),this))}Ft(){return this.Ki}Os(){const t=this.yt.yv();this.yt._m().Qt().au(t,K(this.Ft()))}Rm(t){if(this.nm===null)return;const n={colorSpace:this.yt._m().N().layout.colorSpace};if(t!==1){this.Dm(),this.wm.applySuggestedBitmapSize();const i=ts(this.wm,n);i!==null&&(i.useBitmapCoordinateSpace(r=>{this.Im(r),this.Vm(r)}),this.yt.Bm(i,this.vm),this.Em(i),this.yt.Bm(i,this.fm),this.Am(i))}this.Mm.applySuggestedBitmapSize();const s=ts(this.Mm,n);s!==null&&(s.useBitmapCoordinateSpace(({context:i,bitmapSize:r})=>{i.clearRect(0,0,r.width,r.height)}),this.Lm(s),this.yt.Bm(s,this.pm))}vv(){return this.wm.bitmapSize}mv(t,n,s,i){const r=this.vv();if(r.width>0&&r.height>0&&(t.drawImage(this.wm.canvasElement,n,s),i)){const o=this.Mm.canvasElement;t.drawImage(o,n,s)}}Pt(){var t;(t=this.Ki)==null||t.zl()}Sv(t){if(this.Ki===null||this.Ki.Zi()||!this.yn.handleScale.axisPressedMouseMove.price)return;const n=this.yt._m().Qt(),s=this.yt.yv();this.sm=!0,n.Q_(s,this.Ki,t.localY)}xv(t){if(this.Ki===null||!this.yn.handleScale.axisPressedMouseMove.price)return;const n=this.yt._m().Qt(),s=this.yt.yv(),i=this.Ki;n.tu(s,i,t.localY)}gm(){if(this.Ki===null||!this.yn.handleScale.axisPressedMouseMove.price)return;const t=this.yt._m().Qt(),n=this.yt.yv(),s=this.Ki;this.sm&&(this.sm=!1,t.iu(n,s))}Cv(t){if(this.Ki===null||!this.yn.handleScale.axisPressedMouseMove.price)return;const n=this.yt._m().Qt(),s=this.yt.yv();this.sm=!1,n.iu(s,this.Ki)}bm(t){this.yn.handleScale.axisDoubleClickReset.price&&this.Os()}Sm(t){this.Ki!==null&&(!this.yt._m().Qt().N().handleScale.axisPressedMouseMove.price||this.Ki.je()||this.Ki.No()||this.zm(1))}bv(t){this.zm(0)}Pm(){const t=[],n=this.Ki===null?void 0:this.Ki;return(s=>{for(let i=0;i<s.length;++i){const r=s[i].qn(this.yt.yv(),n);for(let o=0;o<r.length;o++)t.push(r[o])}})(this.yt.yv().Dt()),t}Im({context:t,bitmapSize:n}){const{width:s,height:i}=n,r=this.yt.yv().Qt(),o=r.$(),l=r.af();o===l?Yr(t,0,0,s,i,o):jf(t,0,0,s,i,o,l)}Vm({context:t,bitmapSize:n,horizontalPixelRatio:s}){if(this.nm===null||this.Ki===null||!this.Ki.N().borderVisible)return;t.fillStyle=this.Ki.N().borderColor;const i=Math.max(1,Math.floor(this.xm().S*s));let r;r=this.dm?n.width-i:0,t.fillRect(r,0,i,n.height)}Em(t){if(this.nm===null||this.Ki===null)return;const n=this.Ki.zl(),s=this.Ki.N(),i=this.xm(),r=this.dm?this.nm.width-i.C:0;s.borderVisible&&s.ticksVisible&&t.useBitmapCoordinateSpace(({context:o,horizontalPixelRatio:l,verticalPixelRatio:c})=>{o.fillStyle=s.borderColor;const h=Math.max(1,Math.floor(c)),a=Math.floor(.5*c),u=Math.round(i.C*l);o.beginPath();for(const f of n)o.rect(Math.floor(r*l),Math.round(f.Vl*c)-a,u,h);o.fill()}),t.useMediaCoordinateSpace(({context:o})=>{o.font=this.ym(),o.fillStyle=s.textColor??this.Ro.textColor,o.textAlign=this.dm?"right":"left",o.textBaseline="middle";const l=this.dm?Math.round(r-i.V):Math.round(r+i.C+i.V),c=n.map(h=>this.rm.Di(o,h.eo));for(let h=n.length;h--;){const a=n[h];o.fillText(a.eo,l,a.Vl+c[h])}})}Dm(){if(this.nm===null||this.Ki===null)return;let t=this.nm.height/2;const n=[],s=this.Ki.Dt().slice(),i=this.yt.yv(),r=this.xm();this.Ki===i.Zs()&&this.yt.yv().Dt().forEach(c=>{i.Gs(c)&&s.push(c)});const o=this.Ki.kl()[0],l=this.Ki;s.forEach(c=>{const h=c.qn(i,l);h.forEach(a=>{a.$i()&&a.Wi()===null&&(a.Ui(null),n.push(a))}),o===c&&h.length>0&&(t=h[0].Ei())}),this.Ki.N().alignLabels&&this.Om(n,r,t)}Om(t,n,s){if(this.nm===null)return;const i=t.filter(o=>o.Ei()<=s),r=t.filter(o=>o.Ei()>s);i.sort((o,l)=>l.Ei()-o.Ei()),i.length&&r.length&&r.push(i[0]),r.sort((o,l)=>o.Ei()-l.Ei());for(const o of t){const l=Math.floor(o.$t(n)/2),c=o.Ei();c>-l&&c<l&&o.Ui(l),c>this.nm.height-l&&c<this.nm.height+l&&o.Ui(this.nm.height-l)}du(i,1,this.nm.height,n),du(r,-1,this.nm.height,n)}Am(t){if(this.nm===null)return;const n=this.Pm(),s=this.xm(),i=this.dm?"right":"left";n.forEach(r=>{r.ji()&&r.Tt(K(this.Ki)).st(t,s,this.rm,i)})}Lm(t){if(this.nm===null||this.Ki===null)return;const n=this.yt._m().Qt(),s=[],i=this.yt.yv(),r=n.Vd().qn(i,this.Ki);r.length&&s.push(r);const o=this.xm(),l=this.dm?"right":"left";s.forEach(c=>{c.forEach(h=>{h.Tt(K(this.Ki)).st(t,o,this.rm,l)})})}zm(t){this.uv.style.cursor=t===1?"ns-resize":"default"}wo(){const t=this.Cm();this.am<t&&this.yt._m().Qt().ka(),this.am=t}ym(){return Ir(this.Ro.fontSize,this.Ro.fontFamily)}}function Bx(e,t){var n;return((n=e.Xa)==null?void 0:n.call(e,t))??[]}function Vo(e,t){var n;return((n=e.jn)==null?void 0:n.call(e,t))??[]}function mu(e,t){var n;return((n=e.cn)==null?void 0:n.call(e,t))??[]}function Wx(e,t){var n;return((n=e.qa)==null?void 0:n.call(e,t))??[]}class Sl{constructor(t,n){this.nm=Nt({width:0,height:0}),this.Nm=null,this.Fm=null,this.Wm=null,this.Hm=null,this.Um=!1,this.$m=new Zt,this.jm=new Zt,this.qm=0,this.Ym=!1,this.Km=null,this.Gm=!1,this.Zm=null,this.Xm=null,this.lm=!1,this.om=()=>{this.lm||this.Jm===null||this.sn().mr()},this.um=()=>{this.lm||this.Jm===null||this.sn().mr()},this.Gv=t,this.Jm=n,this.Jm.mu().i(this.Qm.bind(this),this,!0),this.tw=document.createElement("td"),this.tw.style.padding="0",this.tw.style.position="relative";const s=document.createElement("div");s.style.width="100%",s.style.height="100%",s.style.position="relative",s.style.overflow="hidden",this.iw=document.createElement("td"),this.iw.style.padding="0",this.nw=document.createElement("td"),this.nw.style.padding="0",this.tw.appendChild(s),this.wm=ns(s,Nt({width:16,height:16})),this.wm.subscribeSuggestedBitmapSizeChanged(this.om);const i=this.wm.canvasElement;i.style.position="absolute",i.style.zIndex="1",i.style.left="0",i.style.top="0",this.Mm=ns(s,Nt({width:16,height:16})),this.Mm.subscribeSuggestedBitmapSizeChanged(this.um);const r=this.Mm.canvasElement;r.style.position="absolute",r.style.zIndex="2",r.style.left="0",r.style.top="0",this._v=document.createElement("tr"),this._v.appendChild(this.iw),this._v.appendChild(this.tw),this._v.appendChild(this.nw),this.sw(),this.sv=new Zr(this.Mm.canvasElement,this,{Pp:()=>this.Km===null&&!this.Gv.N().handleScroll.vertTouchDrag,kp:()=>this.Km===null&&!this.Gv.N().handleScroll.horzTouchDrag})}m(){this.Nm!==null&&this.Nm.m(),this.Fm!==null&&this.Fm.m(),this.Wm=null,this.Mm.unsubscribeSuggestedBitmapSizeChanged(this.um),ss(this.Mm.canvasElement),this.Mm.dispose(),this.wm.unsubscribeSuggestedBitmapSizeChanged(this.om),ss(this.wm.canvasElement),this.wm.dispose(),this.Jm!==null&&(this.Jm.mu().u(this),this.Jm.m()),this.sv.m()}yv(){return K(this.Jm)}ew(t){var n;this.Jm!==null&&this.Jm.mu().u(this),this.Jm=t,this.Jm!==null&&this.Jm.mu().i(Sl.prototype.Qm.bind(this),this,!0),this.sw(),this.Gv.lv().indexOf(this)===this.Gv.lv().length-1?(this.Wm=this.Wm??new Fx(this.tw,this.Gv),this.Wm.Pt()):((n=this.Wm)==null||n.Xv(),this.Wm=null)}_m(){return this.Gv}fv(){return this._v}sw(){if(this.Jm!==null&&(this.rw(),this.sn().Jn().length!==0)){if(this.Nm!==null){const t=this.Jm.X_();this.Nm.un(K(t))}if(this.Fm!==null){const t=this.Jm.J_();this.Fm.un(K(t))}}}hw(){this.Nm!==null&&this.Nm.Pt(),this.Fm!==null&&this.Fm.Pt()}F_(){return this.Jm!==null?this.Jm.F_():0}W_(t){this.Jm&&this.Jm.W_(t)}bp(t){if(!this.Jm)return;this.aw();const n=t.localX,s=t.localY;this.lw(n,s,t)}Fp(t){this.aw(),this.ow(),this.lw(t.localX,t.localY,t)}Sp(t){if(!this.Jm)return;this.aw();const n=t.localX,s=t.localY;this.lw(n,s,t)}Ap(t){this.Jm!==null&&(this.aw(),this.lw(t.localX,t.localY,t),this._w(t))}fp(t){this.Jm!==null&&this.uw(this.jm,t)}_p(t){this.fp(t)}Dp(t){this.aw(),this.cw(t),this.lw(t.localX,t.localY,t)}Ep(t){this.Jm!==null&&(this.aw(),this.Ym=!1,this.dw(t))}Bp(t){this.Jm!==null&&this._w(t)}Xp(t){if(this.Ym=!0,this.Km===null){const n={x:t.localX,y:t.localY};this.fw(n,n,t)}}Zp(t){this.Jm!==null&&(this.aw(),this.Jm.Qt().Rd(null),this.pw())}mw(){return this.$m}ww(){return this.jm}$p(){this.qm=1,this.sn().cs()}jp(t,n){if(!this.Gv.N().handleScale.pinch)return;const s=5*(n-this.qm);this.qm=n,this.sn().Wd(t._t,s)}Op(t){this.Ym=!1,this.Gm=this.Km!==null,this.ow();const n=this.sn().Vd();this.Km!==null&&n.It()&&(this.Zm={x:n.ni(),y:n.si()},this.Km={x:t.localX,y:t.localY})}Tp(t){if(this.Jm===null)return;const n=t.localX,s=t.localY;if(this.Km===null)this.cw(t);else{this.Gm=!1;const i=K(this.Zm),r=i.x+(n-this.Km.x),o=i.y+(s-this.Km.y);this.lw(r,o,t)}}Vp(t){this._m().N().trackingMode.exitMode===0&&(this.Gm=!0),this.Mw(),this.dw(t)}Qs(t,n){const s=this.Jm;return s===null?null:Kf(s,t,n)}gw(t,n){K(n==="left"?this.Nm:this.Fm).km(Nt({width:t,height:this.nm.height}))}pv(){return this.nm}km(t){Zn(this.nm,t)||(this.nm=t,this.lm=!0,this.wm.resizeCanvasElement(t),this.Mm.resizeCanvasElement(t),this.lm=!1,this.tw.style.width=t.width+"px",this.tw.style.height=t.height+"px")}bw(){const t=K(this.Jm);t.G_(t.X_()),t.G_(t.J_());for(const n of t.kl())if(t.Gs(n)){const s=n.Ft();s!==null&&t.G_(s),n.Nn()}for(const n of t.Mu())n.Nn()}vv(){return this.wm.bitmapSize}mv(t,n,s,i){const r=this.vv();if(r.width>0&&r.height>0&&(t.drawImage(this.wm.canvasElement,n,s),i)){const o=this.Mm.canvasElement;t!==null&&t.drawImage(o,n,s)}}Rm(t){if(t===0||this.Jm===null)return;t>1&&this.bw(),this.Nm!==null&&this.Nm.Rm(t),this.Fm!==null&&this.Fm.Rm(t);const n={colorSpace:this.Gv.N().layout.colorSpace};if(t!==1){this.wm.applySuggestedBitmapSize();const i=ts(this.wm,n);i!==null&&(i.useBitmapCoordinateSpace(r=>{this.Im(r)}),this.Jm&&(this.Sw(i,Bx),this.xw(i),this.Sw(i,Vo),this.Sw(i,mu)))}this.Mm.applySuggestedBitmapSize();const s=ts(this.Mm,n);s!==null&&(s.useBitmapCoordinateSpace(({context:i,bitmapSize:r})=>{i.clearRect(0,0,r.width,r.height)}),this.Cw(s),this.Sw(s,Wx),this.Sw(s,mu))}yw(){return this.Nm}Pw(){return this.Fm}Bm(t,n){this.Sw(t,n)}Qm(){this.Jm!==null&&this.Jm.mu().u(this),this.Jm=null}_w(t){this.uw(this.$m,t)}uw(t,n){const s=n.localX,i=n.localY;t.v()&&t.p(this.sn().Et().Vc(s),{x:s,y:i},n)}Im({context:t,bitmapSize:n}){const{width:s,height:i}=n,r=this.sn(),o=r.$(),l=r.af();o===l?Yr(t,0,0,s,i,l):jf(t,0,0,s,i,o,l)}xw(t){const n=K(this.Jm),s=n.wu().wr().Tt(n);s!==null&&s.st(t,!1)}Cw(t){this.kw(t,Vo,fi,this.sn().Vd())}Sw(t,n){const s=K(this.Jm),i=n===Vo?this.Tw():null,r=i===null?null:this.Rw(i,s),o=s.Mu();if(r===null||i===null){const h=s._u();return this.Dw(t,n,xr,o,h),void this.Dw(t,n,fi,o,h)}const l=s.Dt(),c=h=>h===i?r.Za:void 0;this.Dw(t,n,xr,o,l,c),this.Dw(t,n,fi,o,l,c),this.kw(t,n,xr,i,r.qa),this.kw(t,n,fi,i,r.qa)}Dw(t,n,s,i,r,o){for(const l of i)this.kw(t,n,s,l);if(o!==void 0)for(const l of r)this.kw(t,n,s,l,o(l));else for(const l of r)this.kw(t,n,s,l)}Tw(){var s;const t=K(this.Jm),n=(s=t.Qt().cu())==null?void 0:s.uu;if(!t.Qt().N().hoveredSeriesOnTop||n===void 0)return null;for(const i of t.Dt())if(i===n)return i;return null}Rw(t,n){var i;const s=((i=t.Ga)==null?void 0:i.call(t,n))??null;return s===null||s.qa.length===0?null:s}kw(t,n,s,i,r){const o=K(this.Jm),l=o.Qt().cu(),c=l!==null&&l.uu===i,h=l!==null&&c&&l.bu!==void 0?l.bu.ie:void 0,a=u=>s(u,t,c,h);r===void 0?Ca(n,a,i,o):nm(r,a,o)}rw(){if(this.Jm===null)return;const t=this.Gv,n=this.Jm.X_().N().visible,s=this.Jm.J_().N().visible;n||this.Nm===null||(this.iw.removeChild(this.Nm.fv()),this.Nm.m(),this.Nm=null),s||this.Fm===null||(this.nw.removeChild(this.Fm.fv()),this.Fm.m(),this.Fm=null);const i=t.Qt().Jd();n&&this.Nm===null&&(this.Nm=new fu(this,t.N(),i,"left"),this.iw.appendChild(this.Nm.fv())),s&&this.Fm===null&&(this.Fm=new fu(this,t.N(),i,"right"),this.nw.appendChild(this.Fm.fv()))}Iw(t){return t.Jp&&this.Ym||this.Km!==null}lw(t,n,s){t=Math.max(0,Math.min(t,this.nm.width-1)),n=Math.max(0,Math.min(n,this.nm.height-1)),this.sn().Kd(t,n,s,K(this.Jm))}pw(){this.sn().Zd()}Mw(){this.Gm&&(this.Km=null,this.pw())}fw(t,n,s){this.Km=t,this.Gm=!1,this.lw(n.x,n.y,s);const i=this.sn().Vd();this.Zm={x:i.ni(),y:i.si()}}sn(){return this.Gv.Qt()}dw(t){if(!this.Um)return;const n=this.sn(),s=this.yv();if(n.eu(s,s.kn()),this.Hm=null,this.Um=!1,n.jd(),this.Xm!==null){const i=performance.now(),r=n.Et();this.Xm.me(r.Oc(),i),this.Xm.Kc(i)||n.ps(this.Xm)}}aw(){this.Km=null}ow(){if(this.Jm){if(this.sn().cs(),document.activeElement!==document.body&&document.activeElement!==document.documentElement)K(document.activeElement).blur();else{const t=document.getSelection();t!==null&&t.removeAllRanges()}!this.Jm.kn().Zi()&&this.sn().Et().Zi()}}cw(t){if(this.Jm===null)return;const n=this.sn(),s=n.Et();if(s.Zi())return;const i=this.Gv.N(),r=i.handleScroll,o=i.kineticScroll;if((!r.pressedMouseMove||t.Jp)&&(!r.horzTouchDrag&&!r.vertTouchDrag||!t.Jp))return;const l=this.Jm.kn(),c=performance.now();if(this.Hm!==null||this.Iw(t)||(this.Hm={x:t.clientX,y:t.clientY,yf:c,Vw:t.localX,Bw:t.localY}),this.Hm!==null&&!this.Um&&(this.Hm.x!==t.clientX||this.Hm.y!==t.clientY)){if(t.Jp&&o.touch||!t.Jp&&o.mouse){const h=s.ml();this.Xm=new zx(.2/h,7/h,.997,15/h),this.Xm.Uv(s.Oc(),this.Hm.yf)}else this.Xm=null;l.Zi()||n.nu(this.Jm,l,t.localY),n.Ud(t.localX),this.Um=!0}this.Um&&(l.Zi()||n.su(this.Jm,l,t.localY),n.$d(t.localX),this.Xm!==null&&this.Xm.Uv(s.Oc(),c))}}class pu{constructor(t,n,s,i,r){this.xt=!0,this.nm=Nt({width:0,height:0}),this.om=()=>this.Rm(3),this.dm=t==="left",this.bd=s.Jd,this.yn=n,this.Ew=i,this.Aw=r,this.uv=document.createElement("div"),this.uv.style.width="25px",this.uv.style.height="100%",this.uv.style.overflow="hidden",this.wm=ns(this.uv,Nt({width:16,height:16})),this.wm.subscribeSuggestedBitmapSizeChanged(this.om)}m(){this.wm.unsubscribeSuggestedBitmapSizeChanged(this.om),ss(this.wm.canvasElement),this.wm.dispose()}fv(){return this.uv}pv(){return this.nm}km(t){Zn(this.nm,t)||(this.nm=t,this.wm.resizeCanvasElement(t),this.uv.style.width=`${t.width}px`,this.uv.style.height=`${t.height}px`,this.xt=!0)}Rm(t){if(t<3&&!this.xt||this.nm.width===0||this.nm.height===0)return;this.xt=!1,this.wm.applySuggestedBitmapSize();const n=ts(this.wm,{colorSpace:this.yn.layout.colorSpace});n!==null&&n.useBitmapCoordinateSpace(s=>{this.Im(s),this.Vm(s)})}vv(){return this.wm.bitmapSize}mv(t,n,s){const i=this.vv();i.width>0&&i.height>0&&t.drawImage(this.wm.canvasElement,n,s)}Vm({context:t,bitmapSize:n,horizontalPixelRatio:s,verticalPixelRatio:i}){if(!this.Ew())return;t.fillStyle=this.yn.timeScale.borderColor;const r=Math.floor(this.bd.N().S*s),o=Math.floor(this.bd.N().S*i),l=this.dm?n.width-r:0;t.fillRect(l,0,r,o)}Im({context:t,bitmapSize:n}){Yr(t,0,0,n.width,n.height,this.Aw())}}function Cl(e){return t=>{var n;return((n=t.tl)==null?void 0:n.call(t,e))??[]}}const jx=Cl("normal"),Vx=Cl("top"),Ox=Cl("bottom");class Ux{constructor(t,n){this.Lw=null,this.zw=null,this.M=null,this.Ow=!1,this.nm=Nt({width:0,height:0}),this.Nw=new Zt,this.rm=new Dr(5),this.lm=!1,this.om=()=>{this.lm||this.Gv.Qt().mr()},this.um=()=>{this.lm||this.Gv.Qt().mr()},this.Gv=t,this.Pu=n,this.yn=t.N().layout,this.jv=document.createElement("tr"),this.Fw=document.createElement("td"),this.Fw.style.padding="0",this.Ww=document.createElement("td"),this.Ww.style.padding="0",this.uv=document.createElement("td"),this.uv.style.height="25px",this.uv.style.padding="0",this.Hw=document.createElement("div"),this.Hw.style.width="100%",this.Hw.style.height="100%",this.Hw.style.position="relative",this.Hw.style.overflow="hidden",this.uv.appendChild(this.Hw),this.wm=ns(this.Hw,Nt({width:16,height:16})),this.wm.subscribeSuggestedBitmapSizeChanged(this.om);const s=this.wm.canvasElement;s.style.position="absolute",s.style.zIndex="1",s.style.left="0",s.style.top="0",this.Mm=ns(this.Hw,Nt({width:16,height:16})),this.Mm.subscribeSuggestedBitmapSizeChanged(this.um);const i=this.Mm.canvasElement;i.style.position="absolute",i.style.zIndex="2",i.style.left="0",i.style.top="0",this.jv.appendChild(this.Fw),this.jv.appendChild(this.uv),this.jv.appendChild(this.Ww),this.Uw(),this.Gv.Qt().N_().i(this.Uw.bind(this),this),this.sv=new Zr(this.Mm.canvasElement,this,{Pp:()=>!0,kp:()=>!this.Gv.N().handleScroll.horzTouchDrag})}m(){this.sv.m(),this.Lw!==null&&this.Lw.m(),this.zw!==null&&this.zw.m(),this.Mm.unsubscribeSuggestedBitmapSizeChanged(this.um),ss(this.Mm.canvasElement),this.Mm.dispose(),this.wm.unsubscribeSuggestedBitmapSizeChanged(this.om),ss(this.wm.canvasElement),this.wm.dispose()}fv(){return this.jv}$w(){return this.Lw}jw(){return this.zw}Fp(t){if(this.Ow)return;this.Ow=!0;const n=this.Gv.Qt();!n.Et().Zi()&&this.Gv.N().handleScale.axisPressedMouseMove.time&&n.Fd(t.localX)}Op(t){this.Fp(t)}Wp(){const t=this.Gv.Qt();!t.Et().Zi()&&this.Ow&&(this.Ow=!1,this.Gv.N().handleScale.axisPressedMouseMove.time&&t.Yd())}Dp(t){const n=this.Gv.Qt();!n.Et().Zi()&&this.Gv.N().handleScale.axisPressedMouseMove.time&&n.qd(t.localX)}Tp(t){this.Dp(t)}Ep(){this.Ow=!1;const t=this.Gv.Qt();t.Et().Zi()&&!this.Gv.N().handleScale.axisPressedMouseMove.time||t.Yd()}Vp(){this.Ep()}fp(){this.Gv.N().handleScale.axisDoubleClickReset.time&&this.Gv.Qt().ws()}_p(){this.fp()}bp(){this.Gv.Qt().N().handleScale.axisPressedMouseMove.time&&this.zm(1)}Zp(){this.zm(0)}pv(){return this.nm}qw(){return this.Nw}Yw(t,n,s){Zn(this.nm,t)||(this.nm=t,this.lm=!0,this.wm.resizeCanvasElement(t),this.Mm.resizeCanvasElement(t),this.lm=!1,this.uv.style.width=`${t.width}px`,this.uv.style.height=`${t.height}px`,this.Nw.p(t)),this.Lw!==null&&this.Lw.km(Nt({width:n,height:t.height})),this.zw!==null&&this.zw.km(Nt({width:s,height:t.height}))}Kw(){const t=this.Gw();return Math.ceil(t.S+t.C+t.P+t.A+t.I+t.Zw)}Pt(){this.Gv.Qt().Et().zl()}vv(){return this.wm.bitmapSize}mv(t,n,s,i){const r=this.vv();if(r.width>0&&r.height>0&&(t.drawImage(this.wm.canvasElement,n,s),i)){const o=this.Mm.canvasElement;t.drawImage(o,n,s)}}Rm(t){if(t===0)return;const n={colorSpace:this.yn.colorSpace};if(t!==1){this.wm.applySuggestedBitmapSize();const i=ts(this.wm,n);i!==null&&(i.useBitmapCoordinateSpace(r=>{this.Im(r),this.Vm(r),this.Xw(i,Ox)}),this.Em(i),this.Xw(i,jx)),this.Lw!==null&&this.Lw.Rm(t),this.zw!==null&&this.zw.Rm(t)}this.Mm.applySuggestedBitmapSize();const s=ts(this.Mm,n);s!==null&&(s.useBitmapCoordinateSpace(({context:i,bitmapSize:r})=>{i.clearRect(0,0,r.width,r.height)}),this.Jw([...this.Gv.Qt().Jn(),this.Gv.Qt().Vd()],s),this.Xw(s,Vx))}Xw(t,n){const s=this.Gv.Qt().Jn();for(const i of s)Ca(n,r=>xr(r,t,!1,void 0),i,void 0);for(const i of s)Ca(n,r=>fi(r,t,!1,void 0),i,void 0)}Im({context:t,bitmapSize:n}){Yr(t,0,0,n.width,n.height,this.Gv.Qt().af())}Vm({context:t,bitmapSize:n,verticalPixelRatio:s}){if(this.Gv.N().timeScale.borderVisible){t.fillStyle=this.Qw();const i=Math.max(1,Math.floor(this.Gw().S*s));t.fillRect(0,0,n.width,i)}}Em(t){const n=this.Gv.Qt().Et(),s=n.zl();if(!s||s.length===0)return;const i=this.Pu.maxTickMarkWeight(s),r=this.Gw(),o=n.N();o.borderVisible&&o.ticksVisible&&t.useBitmapCoordinateSpace(({context:l,horizontalPixelRatio:c,verticalPixelRatio:h})=>{l.strokeStyle=this.Qw(),l.fillStyle=this.Qw();const a=Math.max(1,Math.floor(c)),u=Math.floor(.5*c);l.beginPath();const f=Math.round(r.C*h);for(let p=s.length;p--;){const g=Math.round(s[p].coord*c);l.rect(g-u,0,a,f)}l.fill()}),t.useMediaCoordinateSpace(({context:l})=>{const c=r.S+r.C+r.A+r.P/2;l.textAlign="center",l.textBaseline="middle",l.fillStyle=this.H(),l.font=this.ym();for(const h of s)if(h.weight<i){const a=h.needAlignCoordinate?this.tM(l,h.coord,h.label):h.coord;l.fillText(h.label,a,c)}this.Gv.N().timeScale.allowBoldLabels&&(l.font=this.iM());for(const h of s)if(h.weight>=i){const a=h.needAlignCoordinate?this.tM(l,h.coord,h.label):h.coord;l.fillText(h.label,a,c)}})}tM(t,n,s){const i=this.rm.Ii(t,s),r=i/2,o=Math.floor(n-r)+.5;return o<0?n+=Math.abs(0-o):o+i>this.nm.width&&(n-=Math.abs(this.nm.width-(o+i))),n}Jw(t,n){const s=this.Gw();for(const i of t)for(const r of i.dn())r.Tt().st(n,s)}Qw(){return this.Gv.N().timeScale.borderColor}H(){return this.yn.textColor}F(){return this.yn.fontSize}ym(){return Ir(this.F(),this.yn.fontFamily)}iM(){return Ir(this.F(),this.yn.fontFamily,"bold")}Gw(){this.M===null&&(this.M={S:1,L:NaN,A:NaN,I:NaN,tn:NaN,C:5,P:NaN,k:"",Qi:new Dr,Zw:0});const t=this.M,n=this.ym();if(t.k!==n){const s=this.F();t.P=s,t.k=n,t.A=3*s/12,t.I=3*s/12,t.tn=9*s/12,t.L=0,t.Zw=4*s/12,t.Qi.Os()}return this.M}zm(t){this.uv.style.cursor=t===1?"ew-resize":"default"}Uw(){const t=this.Gv.Qt(),n=t.N();n.leftPriceScale.visible||this.Lw===null||(this.Fw.removeChild(this.Lw.fv()),this.Lw.m(),this.Lw=null),n.rightPriceScale.visible||this.zw===null||(this.Ww.removeChild(this.zw.fv()),this.zw.m(),this.zw=null);const s={Jd:this.Gv.Qt().Jd()},i=()=>n.leftPriceScale.borderVisible&&t.Et().N().borderVisible,r=()=>t.af();n.leftPriceScale.visible&&this.Lw===null&&(this.Lw=new pu("left",n,s,i,r),this.Fw.appendChild(this.Lw.fv())),n.rightPriceScale.visible&&this.zw===null&&(this.zw=new pu("right",n,s,i,r),this.Ww.appendChild(this.zw.fv()))}}var Bu;const Hx=!!Vs&&!!navigator.userAgentData&&navigator.userAgentData.brands.some(e=>e.brand.includes("Chromium"))&&!!Vs&&((Bu=navigator==null?void 0:navigator.userAgentData)!=null&&Bu.platform?navigator.userAgentData.platform==="Windows":navigator.userAgent.toLowerCase().indexOf("win")>=0);class qx{constructor(t,n,s){var i;this.nM=[],this.sM=[],this.eM=0,this.oo=0,this.k_=0,this.rM=0,this.hM=0,this.aM=null,this.lM=!1,this.$m=new Zt,this.jm=new Zt,this.wd=new Zt,this.oM=null,this._M=null,this.Kv=t,this.yn=n,this.Pu=s,this.jv=document.createElement("div"),this.jv.classList.add("tv-lightweight-charts"),this.jv.style.overflow="hidden",this.jv.style.direction="ltr",this.jv.style.width="100%",this.jv.style.height="100%",(i=this.jv).style.userSelect="none",i.style.webkitUserSelect="none",i.style.msUserSelect="none",i.style.MozUserSelect="none",i.style.webkitTapHighlightColor="transparent",this.uM=document.createElement("table"),this.uM.setAttribute("cellspacing","0"),this.jv.appendChild(this.uM),this.cM=this.dM.bind(this),Oo(this.yn)&&this.fM(!0),this.sn=new Rx(this.gd.bind(this),this.yn,s),this.Qt().Bd().i(this.pM.bind(this),this),this.vM=new Ux(this,this.Pu),this.uM.appendChild(this.vM.fv());const r=n.autoSize&&this.mM();let o=this.yn.width,l=this.yn.height;if(r||o===0||l===0){const c=t.getBoundingClientRect();o=o||c.width,l=l||c.height}this.wM(o,l),this.MM(),t.appendChild(this.jv),this.gM(),this.sn.Et().Jc().i(this.sn.ka.bind(this.sn),this),this.sn.N_().i(this.sn.ka.bind(this.sn),this)}Qt(){return this.sn}N(){return this.yn}lv(){return this.nM}bM(){return this.vM}m(){this.fM(!1),this.eM!==0&&window.cancelAnimationFrame(this.eM),this.sn.Bd().u(this),this.sn.Et().Jc().u(this),this.sn.N_().u(this),this.sn.m();for(const t of this.nM)this.uM.removeChild(t.fv()),t.mw().u(this),t.ww().u(this),t.m();this.nM=[];for(const t of this.sM)this.SM(t);this.sM=[],K(this.vM).m(),this.jv.parentElement!==null&&this.jv.parentElement.removeChild(this.jv),this.wd.m(),this.$m.m(),this.jm.m(),this.xM()}wM(t,n,s=!1){if(this.oo===n&&this.k_===t)return;const i=function(l){const c=Math.floor(l.width),h=Math.floor(l.height);return Nt({width:c-c%2,height:h-h%2})}(Nt({width:t,height:n}));this.oo=i.height,this.k_=i.width;const r=this.oo+"px",o=this.k_+"px";if(this.CM()||(K(this.jv).style.height=r,K(this.jv).style.width=o),this.uM.style.height=r,this.uM.style.width=o,s){this.eM!==0&&(window.cancelAnimationFrame(this.eM),this.eM=0),this.lM=!1;const l=fe.ys();this.aM!==null&&(l.Ss(this.aM),this.aM=null),this.yM(l,performance.now())}else this.sn.ka()}Rm(t){t===void 0&&(t=fe.ys());for(let n=0;n<this.nM.length;n++)this.nM[n].Rm(t._s(n).rs);this.yn.timeScale.visible&&this.vM.Rm(t.ls())}vr(t){var i;const n=Oo(this.yn);this.sn.vr(t);const s=Oo(this.yn);s!==n&&this.fM(s),(i=t.layout)!=null&&i.panes&&this.PM(),this.gM(),this.kM(t)}mw(){return this.$m}ww(){return this.jm}Bd(){return this.wd}TM(t=!1){this.aM!==null&&(this.yM(this.aM,performance.now()),this.aM=null);const n=this.RM(null),s=document.createElement("canvas");s.width=n.width,s.height=n.height;const i=K(s.getContext("2d"));return this.RM(i,t),s}DM(t){return t==="left"&&!this.IM()||t==="right"&&!this.VM()||this.nM.length===0?0:K(t==="left"?this.nM[0].yw():this.nM[0].Pw()).Tm()}CM(){return this.yn.autoSize&&this.oM!==null}Mv(){return this.jv}BM(t){this._M=t,this._M?this.Mv().style.setProperty("cursor",t):this.Mv().style.removeProperty("cursor")}EM(){return this._M}AM(t){return Re(this.nM[t]).pv()}PM(){this.sM.forEach(t=>{t.Pt()})}kM(t){(t.autoSize!==void 0||!this.oM||t.width===void 0&&t.height===void 0)&&(t.autoSize&&!this.oM&&this.mM(),t.autoSize===!1&&this.oM!==null&&this.xM(),t.autoSize||t.width===void 0&&t.height===void 0||this.wM(t.width||this.k_,t.height||this.oo))}RM(t,n){let s=0,i=0;const r=this.nM[0],o=(c,h)=>{let a=0;for(let u=0;u<this.nM.length;u++){const f=this.nM[u],p=K(c==="left"?f.yw():f.Pw()),g=p.vv();if(t!==null&&p.mv(t,h,a,n),a+=g.height,u<this.nM.length-1){const d=this.sM[u],w=d.vv();t!==null&&d.mv(t,h,a),a+=w.height}}};this.IM()&&(o("left",0),s+=K(r.yw()).vv().width);for(let c=0;c<this.nM.length;c++){const h=this.nM[c],a=h.vv();if(t!==null&&h.mv(t,s,i,n),i+=a.height,c<this.nM.length-1){const u=this.sM[c],f=u.vv();t!==null&&u.mv(t,s,i),i+=f.height}}s+=r.vv().width,this.VM()&&(o("right",s),s+=K(r.Pw()).vv().width);const l=(c,h,a)=>{K(c==="left"?this.vM.$w():this.vM.jw()).mv(K(t),h,a)};if(this.yn.timeScale.visible){const c=this.vM.vv();if(t!==null){let h=0;this.IM()&&(l("left",h,i),h=K(r.yw()).vv().width),this.vM.mv(t,h,i,n),h+=c.width,this.VM()&&l("right",h,i)}i+=c.height}return Nt({width:s,height:i})}LM(){let t=0,n=0,s=0;for(const w of this.nM)this.IM()&&(n=Math.max(n,K(w.yw()).Cm(),this.yn.leftPriceScale.minimumWidth)),this.VM()&&(s=Math.max(s,K(w.Pw()).Cm(),this.yn.rightPriceScale.minimumWidth)),t+=w.F_();n=Sa(n),s=Sa(s);const i=this.k_,r=this.oo,o=Math.max(i-n-s,0),l=1*this.sM.length,c=this.yn.timeScale.visible;let h=c?Math.max(this.vM.Kw(),this.yn.timeScale.minimumHeight):0;var a;h=(a=h)+a%2;const u=l+h,f=r<u?0:r-u,p=f/t;let g=0;const d=window.devicePixelRatio||1;for(let w=0;w<this.nM.length;++w){const C=this.nM[w];C.ew(this.sn.Gn()[w]);let x=0,k=0;k=w===this.nM.length-1?Math.ceil((f-g)*d)/d:Math.round(C.F_()*p*d)/d,x=Math.max(k,2),g+=x,C.km(Nt({width:o,height:x})),this.IM()&&C.gw(n,"left"),this.VM()&&C.gw(s,"right"),C.yv()&&this.sn.Ed(C.yv(),x)}this.vM.Yw(Nt({width:c?o:0,height:h}),c?n:0,c?s:0),this.sn.H_(o),this.rM!==n&&(this.rM=n),this.hM!==s&&(this.hM=s)}fM(t){t?this.jv.addEventListener("wheel",this.cM,{passive:!1}):this.jv.removeEventListener("wheel",this.cM)}zM(t){switch(t.deltaMode){case t.DOM_DELTA_PAGE:return 120;case t.DOM_DELTA_LINE:return 32}return Hx?1/window.devicePixelRatio:1}dM(t){if(!(t.deltaX!==0&&this.yn.handleScroll.mouseWheel||t.deltaY!==0&&this.yn.handleScale.mouseWheel))return;const n=this.zM(t),s=n*t.deltaX/100,i=-n*t.deltaY/100;if(t.cancelable&&t.preventDefault(),i!==0&&this.yn.handleScale.mouseWheel){const r=Math.sign(i)*Math.min(1,Math.abs(i)),o=t.clientX-this.jv.getBoundingClientRect().left;this.Qt().Wd(o,r)}s!==0&&this.yn.handleScroll.mouseWheel&&this.Qt().Hd(-80*s)}yM(t,n){var i;const s=t.ls();s===3&&this.OM(),s!==3&&s!==2||(this.NM(t),this.FM(t,n),this.vM.Pt(),this.nM.forEach(r=>{r.hw()}),((i=this.aM)==null?void 0:i.ls())===3&&(this.aM.Ss(t),this.OM(),this.NM(this.aM),this.FM(this.aM,n),t=this.aM,this.aM=null)),this.Rm(t)}FM(t,n){for(const s of t.bs())this.xs(s,n)}NM(t){const n=this.sn.Gn();for(let s=0;s<n.length;s++)t._s(s).hs&&n[s].lu()}xs(t,n){const s=this.sn.Et();switch(t.ds){case 0:s.td();break;case 1:s.nd(t.Wt);break;case 2:s.Ms(t.Wt);break;case 3:s.gs(t.Wt);break;case 4:s.Wc();break;case 5:t.Wt.Kc(n)||s.gs(t.Wt.Gc(n))}}gd(t){this.aM!==null?this.aM.Ss(t):this.aM=t,this.lM||(this.lM=!0,this.eM=window.requestAnimationFrame(n=>{if(this.lM=!1,this.eM=0,this.aM!==null){const s=this.aM;this.aM=null,this.yM(s,n);for(const i of s.bs())if(i.ds===5&&!i.Wt.Kc(n)){this.Qt().ps(i.Wt);break}}}))}OM(){this.MM()}SM(t){this.uM.removeChild(t.fv()),t.m()}MM(){const t=this.sn.Gn(),n=t.length,s=this.nM.length;for(let i=n;i<s;i++){const r=Re(this.nM.pop());this.uM.removeChild(r.fv()),r.mw().u(this),r.ww().u(this),r.m();const o=this.sM.pop();o!==void 0&&this.SM(o)}for(let i=s;i<n;i++){const r=new Sl(this,t[i]);if(r.mw().i(this.WM.bind(this,r),this),r.ww().i(this.HM.bind(this,r),this),this.nM.push(r),i>0){const o=new Lx(this,i-1,i);this.sM.push(o),this.uM.insertBefore(o.fv(),this.vM.fv())}this.uM.insertBefore(r.fv(),this.vM.fv())}for(let i=0;i<n;i++){const r=t[i],o=this.nM[i];o.yv()!==r?o.ew(r):o.sw()}this.gM(),this.LM()}UM(t,n,s,i){var a;const r=new Map;t!==null&&this.sn.Jn().forEach(u=>{const f=u.Un().Hn(t);f!==null&&r.set(u,f)});let o;if(t!==null){const u=(a=this.sn.Et().en(t))==null?void 0:a.originalTime;u!==void 0&&(o=u)}const l=this.Qt().cu(),c=this.$M(i),h=function(u,f){var x;const p=u!==null&&u.uu instanceof Kr?u.uu:void 0,g=(x=u==null?void 0:u.bu)==null?void 0:x.te,d=f!==void 0&&f!==-1?f:void 0;return u===null||u.ee===void 0?{jM:p,qM:g}:{jM:p,qM:g,YM:{ds:u.ee,KM:(w=u.uu,C=u.ee,w instanceof va?"pane-primitive":C==="marker"||C==="primitive"?"series-primitive":"series"),GM:Ix(u.ee,g),Y_:p,ZM:g,XM:d}};var w,C}(l,c);return{Qr:o,$n:t??void 0,JM:n??void 0,XM:c!==-1?c:void 0,jM:h.jM,QM:r,qM:h.qM,YM:h.YM,tg:s??void 0}}$M(t){let n=-1;if(t)n=this.nM.indexOf(t);else{const s=this.Qt().Vd().Kn();s!==null&&(n=this.Qt().Gn().indexOf(s))}return n}WM(t,n,s,i){this.$m.p(()=>this.UM(n,s,i,t))}HM(t,n,s,i){this.jm.p(()=>this.UM(n,s,i,t))}pM(t,n,s){var i;this.BM(((i=this.Qt().cu())==null?void 0:i.gu)??null),this.wd.p(()=>this.UM(t,n,s))}gM(){const t=this.yn.timeScale.visible?"":"none";this.vM.fv().style.display=t}IM(){return this.nM[0].yv().X_().N().visible}VM(){return this.nM[0].yv().J_().N().visible}mM(){return"ResizeObserver"in window&&(this.oM=new ResizeObserver(t=>{const n=t[t.length-1];if(!n)return;const s=n.contentRect.width,i=n.contentRect.height;this.wM(s,i,!0)}),this.oM.observe(this.Kv,{box:"border-box"}),!0)}xM(){this.oM!==null&&this.oM.disconnect(),this.oM=null}}function Oo(e){return!!(e.handleScroll.mouseWheel||e.handleScale.mouseWheel)}function Gx(e){return e.open===void 0&&e.value===void 0}function Yx(e){return function(t){return t.open!==void 0}(e)||function(t){return t.value!==void 0}(e)}function gu(e,t,n,s){const i=n.value,r={$n:t,wt:e,Wt:[i,i,i,i],Qr:s};return n.color!==void 0&&(r.R=n.color),r}function Xx(e,t,n,s){const i=n.value,r={$n:t,wt:e,Wt:[i,i,i,i],Qr:s};return n.lineColor!==void 0&&(r.vt=n.lineColor),n.topColor!==void 0&&(r.ah=n.topColor),n.bottomColor!==void 0&&(r.oh=n.bottomColor),r}function Qx(e,t,n,s){const i=n.value,r={$n:t,wt:e,Wt:[i,i,i,i],Qr:s};return n.topLineColor!==void 0&&(r._h=n.topLineColor),n.bottomLineColor!==void 0&&(r.uh=n.bottomLineColor),n.topFillColor1!==void 0&&(r.dh=n.topFillColor1),n.topFillColor2!==void 0&&(r.fh=n.topFillColor2),n.bottomFillColor1!==void 0&&(r.ph=n.bottomFillColor1),n.bottomFillColor2!==void 0&&(r.mh=n.bottomFillColor2),r}function Jx(e,t,n,s){const i={$n:t,wt:e,Wt:[n.open,n.high,n.low,n.close],Qr:s};return n.color!==void 0&&(i.R=n.color),i}function Kx(e,t,n,s){const i={$n:t,wt:e,Wt:[n.open,n.high,n.low,n.close],Qr:s};return n.color!==void 0&&(i.R=n.color),n.borderColor!==void 0&&(i.Ht=n.borderColor),n.wickColor!==void 0&&(i.hh=n.wickColor),i}function Zx(e,t,n,s,i){const r=Re(i)(n),o=Math.max(...r),l=Math.min(...r),c=r[r.length-1],h=[c,o,l,c],{time:a,color:u,...f}=n;return{$n:t,wt:e,Wt:h,Qr:s,ue:f,R:u}}function Es(e){return e.Wt!==void 0}function yu(e,t){return t.customValues!==void 0&&(e.ig=t.customValues),e}function Gn(e){return(t,n,s,i,r,o)=>function(l,c){return c?c(l):Gx(l)}(s,o)?yu({wt:t,$n:n,Qr:i},s):yu(e(t,n,s,i,r),s)}function bu(e){return{Candlestick:Gn(Kx),Bar:Gn(Jx),Area:Gn(Xx),Baseline:Gn(Qx),Histogram:Gn(gu),Line:Gn(gu),Custom:Gn(Zx)}[e]}function vu(e){return{$n:0,ng:new Map,Oa:e}}function xu(e,t){if(e!==void 0&&e.length!==0)return{sg:t.key(e[0].wt),eg:t.key(e[e.length-1].wt)}}function wu(e){let t;return e.forEach(n=>{t===void 0&&(t=n.Qr)}),Re(t)}class tw{constructor(t){this.rg=new Map,this.hg=new Map,this.ag=new Map,this.lg=[],this.Pu=t}m(){this.rg.clear(),this.hg.clear(),this.ag.clear(),this.lg=[]}og(t,n){let s=this.rg.size!==0,i=!1;const r=this.hg.get(t);if(r!==void 0)if(this.hg.size===1)s=!1,i=!0,this.rg.clear();else for(const c of this.lg)c.pointData.ng.delete(t)&&(i=!0);let o=[];if(n.length!==0){const c=n.map(p=>p.time),h=this.Pu.createConverterToInternalObj(n),a=bu(t.bh()),u=t.ul(),f=t.cl();o=n.map((p,g)=>{const d=h(p.time),w=this.Pu.key(d);let C=this.rg.get(w);C===void 0&&(C=vu(d),this.rg.set(w,C),i=!0);const x=a(d,C.$n,p,c[g],u,f);return C.ng.set(t,x),x})}s&&this._g(),this.ug(t,o);let l=-1;if(i){const c=[];this.rg.forEach(h=>{c.push({timeWeight:0,time:h.Oa,pointData:h,originalTime:wu(h.ng)})}),c.sort((h,a)=>this.Pu.key(h.time)-this.Pu.key(a.time)),l=this.cg(c)}return this.dg(t,l,function(c,h,a){const u=xu(c,a),f=xu(h,a);if(u!==void 0&&f!==void 0)return{fg:!1,Va:u.eg>=f.eg&&u.sg>=f.sg}}(this.hg.get(t),r,this.Pu))}if(t){return this.og(t,[])}pg(t,n,s){if(s&&t.Fa())throw new Error("Historical updates are not supported when conflation is enabled. Conflation requires data to be processed in order.");const i=n;(function(C){C.Qr===void 0&&(C.Qr=C.time)})(i),this.Pu.preprocessData(n);const r=this.Pu.createConverterToInternalObj([n])(n.time),o=this.ag.get(t);if(!s&&o!==void 0&&this.Pu.key(r)<this.Pu.key(o))throw new Error(`Cannot update oldest data, last time=${o}, new time=${r}`);let l=this.rg.get(this.Pu.key(r));if(s&&l===void 0)throw new Error("Cannot update non-existing data point when historicalUpdate is true");const c=l===void 0;l===void 0&&(l=vu(r),this.rg.set(this.Pu.key(r),l));const h=bu(t.bh()),a=t.ul(),u=t.cl(),f=h(r,l.$n,n,i.Qr,a,u),p=!s&&!c&&o!==void 0&&this.Pu.key(r)===this.Pu.key(o);l.ng.set(t,f),s?this.vg(t,f,l.$n):p&&t.Fa()&&Es(f)?(t.Rr(f),this.mg(t,f)):this.mg(t,f);const g={Va:Es(f),fg:s};if(!c)return this.dg(t,-1,g);const d={timeWeight:0,time:l.Oa,pointData:l,originalTime:wu(l.ng)},w=es(this.lg,this.Pu.key(d.time),(C,x)=>this.Pu.key(C.time)<x);this.lg.splice(w,0,d);for(let C=w;C<this.lg.length;++C)pr(this.lg[C].pointData,C);return this.Pu.fillWeightsForPoints(this.lg,w),this.dg(t,w,g)}wg(t,n){const s=this.hg.get(t);if(s===void 0||n<=0)return[[],this.Mg()];n=Math.min(n,s.length);const i=s.splice(-n).reverse();s.length===0?this.ag.delete(t):this.ag.set(t,s[s.length-1].wt);for(const r of i){const o=this.rg.get(this.Pu.key(r.wt));if(o&&(o.ng.delete(t),o.ng.size===0)){this.rg.delete(this.Pu.key(o.Oa)),this.lg.splice(o.$n,1);for(let l=o.$n;l<this.lg.length;++l)pr(this.lg[l].pointData,l)}}return[i,this.dg(t,this.lg.length-1,{fg:!1,Va:!1})]}mg(t,n){let s=this.hg.get(t);s===void 0&&(s=[],this.hg.set(t,s));const i=s.length!==0?s[s.length-1]:null;i===null||this.Pu.key(n.wt)>this.Pu.key(i.wt)?Es(n)&&s.push(n):Es(n)?s[s.length-1]=n:s.splice(-1,1),this.ag.set(t,n.wt)}vg(t,n,s){const i=this.hg.get(t);if(i===void 0)return;const r=es(i,s,(o,l)=>o.$n<l);Es(n)?i[r]=n:i.splice(r,1)}ug(t,n){n.length!==0?(this.hg.set(t,n.filter(Es)),this.ag.set(t,n[n.length-1].wt)):(this.hg.delete(t),this.ag.delete(t))}_g(){for(const t of this.lg)t.pointData.ng.size===0&&this.rg.delete(this.Pu.key(t.time))}cg(t){let n=-1;for(let s=0;s<this.lg.length&&s<t.length;++s){const i=this.lg[s],r=t[s];if(this.Pu.key(i.time)!==this.Pu.key(r.time)){n=s;break}r.timeWeight=i.timeWeight,pr(r.pointData,s)}if(n===-1&&this.lg.length!==t.length&&(n=Math.min(this.lg.length,t.length)),n===-1)return-1;for(let s=n;s<t.length;++s)pr(t[s].pointData,s);return this.Pu.fillWeightsForPoints(t,n),this.lg=t,n}gg(){if(this.hg.size===0)return null;let t=0;return this.hg.forEach(n=>{n.length!==0&&(t=Math.max(t,n[n.length-1].$n))}),t}dg(t,n,s){const i=this.Mg();if(n!==-1)this.hg.forEach((r,o)=>{i.Y_.set(o,{ue:r,bg:o===t?s:void 0})}),this.hg.has(t)||i.Y_.set(t,{ue:[],bg:s}),i.Et.Sg=this.lg,i.Et.xg=n;else{const r=this.hg.get(t);i.Y_.set(t,{ue:r||[],bg:s})}return i}Mg(){return{Y_:new Map,Et:{Dc:this.gg()}}}}function pr(e,t){e.$n=t,e.ng.forEach(n=>{n.$n=t})}function ew(e,t){return e._t<t}function nw(e,t){return t<e._t}function ka(e,t,n,s){return es(e,t,ew,n,s)}function Ma(e,t,n,s){return xl(e,t,nw,n,s)}function wr(e,t,n){return{ne:e,se:t,ee:n}}function Su(e,t,n,s){return e>=t-s&&e<=n+s}function mi(e,t,n,s,i,r){const o=i-n,l=r-s;if(o===0&&l===0)return Math.hypot(e-n,t-s);const c=((e-n)*o+(t-s)*l)/(o*o+l*l),h=Math.max(0,Math.min(1,c)),a=n+o*h,u=s+l*h;return Math.hypot(e-a,t-u)}const Uo=[0,0];function sw(e,t,n){return t===void 0||t.wt!==e.wt-1?e._t-n/2:(t._t+e._t)/2}function iw(e,t,n){return t===void 0||t.wt!==e.wt+1?e._t+n/2:(e._t+t._t)/2}function sm(e,t,n,s,i,r,o){if(t===null||t.from>=t.to||e.length===0)return null;const l=i/2+r,c=ka(e,n-l,t.from,t.to),h=Ma(e,n+l,c,t.to);if(c>=h)return null;let a=Number.POSITIVE_INFINITY;for(let u=c;u<h;u++){const f=e[u],p=u>t.from?e[u-1]:void 0,g=u<t.to-1?e[u+1]:void 0,d=sw(f,p,i)-r,w=iw(f,g,i)+r;if(n<d||n>w)continue;o(f,Uo);const C=Uo[0],x=Uo[1],k=Math.min(C,x),S=Math.max(C,x),T=k-r,P=S+r;if(s>=k&&s<=S)a=Math.min(a,0);else if(s>=T&&s<=P){const I=Math.min(Math.abs(s-k),Math.abs(S-s));a=Math.min(a,I)}}return Number.isFinite(a)?wr(a,0,"series-range"):null}function rw(e,t){return e.wt<t}function ow(e,t){return t<e.wt}function aw(e,t,n){const s=t.Na(),i=t.bi(),r=es(e,s,rw),o=xl(e,i,ow);if(!n)return{from:r,to:o};let l=r,c=o;return r>0&&r<e.length&&e[r].wt>=s&&(l=r-1),o>0&&o<e.length&&e[o-1].wt<=i&&(c=o+1),{from:l,to:c}}class kl{constructor(t,n,s){this.Cg=!0,this.yg=!0,this.Pg=!0,this.kg=[],this.Tg=null,this.Rg=-1,this.ae=t,this.le=n,this.Dg=s}Pt(t){this.Cg=!0,t==="data"&&(this.yg=!0),t==="options"&&(this.Pg=!0)}Tt(){return this.ae.It()?(this.Ig(),this.Tg===null?null:this.Vg):null}Qs(t,n){return this.ae.It()?(this.Ig(),this.Tg===null?null:this.Bg(t,n)):null}Bg(t,n){return null}Eg(){this.kg=this.kg.map(t=>({...t,...this.ae.Sa().Sh(t.wt)}))}Ag(){this.Tg=null}Ig(){const t=this.le.Et(),n=t.N().enableConflation?t.sd():0;n!==this.Rg&&(this.yg=!0,this.Rg=n),this.yg&&(this.Lg(),this.yg=!1),this.Pg&&(this.Eg(),this.Pg=!1),this.Cg&&(this.zg(),this.Cg=!1)}zg(){const t=this.ae.Ft(),n=this.le.Et();if(this.Ag(),n.Zi()||t.Zi())return;const s=n.Ee();if(s===null||this.ae.Un().Th()===0)return;const i=this.ae.Lt();i!==null&&(this.Tg=aw(this.kg,s,this.Dg),this.Og(t,n,i.Wt),this.Ng())}}class lw{constructor(t,n){this.Fg=t,this.Ki=n}st(t,n,s){this.Fg.draw(t,this.Ki,n,s)}}function cw(e){switch(e){case"point":return 2;case"range":return 0;default:return 1}}class hw extends kl{constructor(t,n,s){super(t,n,!1),this.Yh=s,this.Fg=this.Yh.renderer(),this.Vg=new lw(this.Fg,i=>this.Wg(i))}get ga(){return this.Yh.conflationReducer}Ha(t){return this.Yh.priceValueBuilder(t)}dl(t){return this.Yh.isWhitespace(t)}Bg(t,n){var o,l;const s=(l=(o=this.Fg).hitTest)==null?void 0:l.call(o,t,n,c=>this.Wg(c));if(s!=null)return{ne:(i=s).distance,se:cw(i.type),ee:"custom",gu:i.cursorStyle,te:i.objectId,ie:i.hitTestData};var i;const r=sm(this.kg,this.Tg,t,n,this.le.Et().ml(),this.ae.N().hitTestTolerance,(c,h)=>{const a=c.Hg;let u=NaN,f=NaN;if(a!==void 0&&!this.Yh.isWhitespace(a))for(const p of this.Yh.priceValueBuilder(a)){const g=this.Wg(p);g!==null&&(u=Number.isNaN(u)?g:Math.min(u,g),f=Number.isNaN(f)?g:Math.max(f,g))}h[0]=u,h[1]=f});return r===null?null:{...r,ee:"custom"}}Lg(){const t=this.ae.Sa();this.kg=this.ae.Ua().Bh().map(n=>({wt:n.$n,_t:NaN,...t.Sh(n.$n),Hg:n.ue}))}Og(t,n){n.Ic(this.kg,Ni(this.Tg))}Ng(){this.Yh.update({bars:this.kg.map(uw),barSpacing:this.le.Et().ml(),visibleRange:this.Tg,conflationFactor:this.le.Et().sd()},this.ae.N())}Wg(t){const n=this.ae.Lt();return n===null?null:this.ae.Ft().Nt(t,n.Wt)}}function uw(e){return{x:e._t,time:e.wt,originalData:e.Hg,barColor:e.sh}}const dw={color:"#2196f3"},fw=(e,t,n)=>{const s=Mn(n);return new hw(e,t,s)};function Ml(e){const t={value:e.Wt[3],time:e.Qr};return e.ig!==void 0&&(t.customValues=e.ig),t}function Cu(e){const t=Ml(e);return e.R!==void 0&&(t.color=e.R),t}function mw(e){const t=Ml(e);return e.vt!==void 0&&(t.lineColor=e.vt),e.ah!==void 0&&(t.topColor=e.ah),e.oh!==void 0&&(t.bottomColor=e.oh),t}function pw(e){const t=Ml(e);return e._h!==void 0&&(t.topLineColor=e._h),e.uh!==void 0&&(t.bottomLineColor=e.uh),e.dh!==void 0&&(t.topFillColor1=e.dh),e.fh!==void 0&&(t.topFillColor2=e.fh),e.ph!==void 0&&(t.bottomFillColor1=e.ph),e.mh!==void 0&&(t.bottomFillColor2=e.mh),t}function im(e){const t={open:e.Wt[0],high:e.Wt[1],low:e.Wt[2],close:e.Wt[3],time:e.Qr};return e.ig!==void 0&&(t.customValues=e.ig),t}function gw(e){const t=im(e);return e.R!==void 0&&(t.color=e.R),t}function yw(e){const t=im(e),{R:n,Ht:s,hh:i}=e;return n!==void 0&&(t.color=n),s!==void 0&&(t.borderColor=s),i!==void 0&&(t.wickColor=i),t}function Sr(e){return{Area:mw,Line:Cu,Baseline:pw,Histogram:Cu,Bar:gw,Candlestick:yw,Custom:bw}[e]}function bw(e){const t=e.Qr;return{...e.ue,time:t}}const vw={vertLine:{color:"#9598A1",width:1,style:3,visible:!0,labelVisible:!0,labelBackgroundColor:"#131722"},horzLine:{color:"#9598A1",width:1,style:3,visible:!0,labelVisible:!0,labelBackgroundColor:"#131722"},mode:1,doNotSnapToHiddenSeriesIndices:!1},xw={vertLines:{color:"#D6DCDE",style:0,visible:!0},horzLines:{color:"#D6DCDE",style:0,visible:!0}},ww={background:{type:"solid",color:"#FFFFFF"},textColor:"#191919",fontSize:12,fontFamily:Wf,panes:{enableResize:!0,separatorColor:"#E0E3EB",separatorHoverColor:"rgba(178, 181, 189, 0.2)"},attributionLogo:!0,colorSpace:"srgb",colorParsers:[]},Ho={autoScale:!0,mode:0,invertScale:!1,alignLabels:!0,borderVisible:!0,borderColor:"#2B2B43",entireTextOnly:!1,visible:!1,ticksVisible:!1,scaleMargins:{bottom:.1,top:.2},minimumWidth:0,ensureEdgeTickMarksVisible:!1,tickMarkDensity:2.5},Sw={rightOffset:0,barSpacing:6,minBarSpacing:.5,maxBarSpacing:0,fixLeftEdge:!1,fixRightEdge:!1,lockVisibleTimeRangeOnResize:!1,rightBarStaysOnScroll:!1,borderVisible:!0,borderColor:"#2B2B43",visible:!0,timeVisible:!1,secondsVisible:!0,shiftVisibleRangeOnNewBar:!0,allowShiftVisibleRangeOnWhitespaceReplacement:!1,ticksVisible:!1,uniformDistribution:!1,minimumHeight:0,allowBoldLabels:!0,ignoreWhitespaceIndices:!1,enableConflation:!1,conflationThresholdFactor:1,precomputeConflationOnInit:!1,precomputeConflationPriority:"background"};function ku(){return{addDefaultPane:!0,hoveredSeriesOnTop:!0,width:0,height:0,autoSize:!1,layout:ww,crosshair:vw,grid:xw,overlayPriceScales:{...Ho},leftPriceScale:{...Ho,visible:!1},rightPriceScale:{...Ho,visible:!0},defaultVisiblePriceScaleId:"right",timeScale:Sw,localization:{locale:Vs?navigator.language:"",dateFormat:"dd MMM 'yy"},handleScroll:{mouseWheel:!0,pressedMouseMove:!0,horzTouchDrag:!0,vertTouchDrag:!0},handleScale:{axisPressedMouseMove:{time:!0,price:!0},axisDoubleClickReset:{time:!0,price:!0},mouseWheel:!0,pinch:!0},kineticScroll:{mouse:!1,touch:!0},trackingMode:{exitMode:1}}}class rm{constructor(t,n,s){this.hv=t,this.Ug=n,this.$g=s??0}applyOptions(t){this.hv.Qt().Dd(this.Ug,t,this.$g)}options(){return this.Ki().N()}width(){return Qr(this.Ug)?this.hv.DM(this.Ug):0}setVisibleRange(t){this.setAutoScale(!1),this.Ki().Go(new ke(t.from,t.to))}getVisibleRange(){let t,n,s=this.Ki().ar();if(s===null)return null;if(this.Ki().ho()){const i=this.Ki().S_(),r=Zf(i);s=Is(s,this.Ki().lo()),t=Number((Math.round(s.Je()/i)*i).toFixed(r)),n=Number((Math.round(s.Qe()/i)*i).toFixed(r))}else t=s.Je(),n=s.Qe();return{from:t,to:n}}setAutoScale(t){this.applyOptions({autoScale:t})}Ki(){return K(this.hv.Qt().Id(this.Ug,this.$g)).Ft}}class Cw{constructor(t,n,s,i){this.hv=t,this.yt=s,this.jg=n,this.qg=i}getHeight(){return this.yt.$t()}setHeight(t){const n=this.hv.Qt(),s=n._f(this.yt);n.Ld(s,t)}getStretchFactor(){return this.yt.F_()}setStretchFactor(t){this.yt.W_(t),this.hv.Qt().ka()}paneIndex(){return this.hv.Qt()._f(this.yt)}moveTo(t){const n=this.paneIndex();n!==t&&(pe(t>=0&&t<this.hv.lv().length,"Invalid pane index"),this.hv.Qt().Od(n,t))}getSeries(){return this.yt.Y_().map(t=>this.jg(t))??[]}getHTMLElement(){const t=this.hv.lv();return t&&t.length!==0&&t[this.paneIndex()]?t[this.paneIndex()].fv():null}attachPrimitive(t){this.yt.ol(t),t.attached&&t.attached({chart:this.qg,requestUpdate:()=>this.yt.Qt().ka()})}detachPrimitive(t){this.yt._l(t)}priceScale(t){if(this.yt.O_(t)===null)throw new Error(`Cannot find price scale with id: ${t}`);return new rm(this.hv,t,this.paneIndex())}setPreserveEmptyPane(t){this.yt.j_(t)}preserveEmptyPane(){return this.yt.q_()}addCustomSeries(t,n={},s=0){return this.qg.addCustomSeries(t,n,s)}addSeries(t,n={}){return this.qg.addSeries(t,n,this.paneIndex())}}const kw={color:"#FF0000",price:0,lineStyle:2,lineWidth:1,lineVisible:!0,axisLabelVisible:!0,title:"",axisLabelColor:"",axisLabelTextColor:""};class Mu{constructor(t){this._r=t}applyOptions(t){this._r.vr(t)}options(){return this._r.N()}Yg(){return this._r}}class Mw{constructor(t,n,s,i,r,o){this.Kg=new Zt,this.ae=t,this.Gg=n,this.Zg=s,this.Pu=r,this.qg=i,this.Xg=o}m(){this.Kg.m()}priceFormatter(){return this.ae.sl()}priceToCoordinate(t){const n=this.ae.Lt();return n===null?null:this.ae.Ft().Nt(t,n.Wt)}coordinateToPrice(t){const n=this.ae.Lt();return n===null?null:this.ae.Ft().Tn(t,n.Wt)}barsInLogicalRange(t){if(t===null)return null;const n=new zs(new Si(t.from,t.to)).Uu(),s=this.ae.Un();if(s.Zi())return null;const i=s.Hn(n.Na(),1),r=s.Hn(n.bi(),-1),o=K(s.Rh()),l=K(s.Qn());if(i!==null&&r!==null&&i.$n>r.$n)return{barsBefore:t.from-o,barsAfter:l-t.to};const c={barsBefore:i===null||i.$n===o?t.from-o:i.$n-o,barsAfter:r===null||r.$n===l?l-t.to:l-r.$n};return i!==null&&r!==null&&(c.from=i.Qr,c.to=r.Qr),c}setData(t){this.Pu,this.ae.bh(),this.Gg.Jg(this.ae,t),this.Qg("full")}update(t,n=!1){this.ae.bh(),this.Gg.tb(this.ae,t,n),this.Qg("update")}pop(t=1){const n=this.Gg.ib(this.ae,t);n.length!==0&&this.Qg("update");const s=Sr(this.seriesType());return n.map(i=>s(i))}dataByIndex(t,n){const s=this.ae.Un().Hn(t,n);return s===null?null:Sr(this.seriesType())(s)}data(){const t=Sr(this.seriesType());return this.ae.Un().Bh().map(n=>t(n))}subscribeDataChanged(t){this.Kg.i(t)}unsubscribeDataChanged(t){this.Kg._(t)}applyOptions(t){this.ae.vr(t)}options(){return an(this.ae.N())}priceScale(){return this.Zg.priceScale(this.ae.Ft().pl(),this.getPane().paneIndex())}createPriceLine(t){const n=$e(an(kw),t),s=this.ae.Ea(n);return new Mu(s)}removePriceLine(t){this.ae.Aa(t.Yg())}priceLines(){return this.ae.La().map(t=>new Mu(t))}seriesType(){return this.ae.bh()}lastValueData(t){const n=this.ae.Ae(t);return n.Le?{noData:!0}:{noData:!1,price:n.Mt,color:n.R}}attachPrimitive(t){this.ae.ol(t),t.attached&&t.attached({chart:this.qg,series:this,requestUpdate:()=>this.ae.Qt().ka(),horzScaleBehavior:this.Pu})}detachPrimitive(t){this.ae._l(t),t.detached&&t.detached(),this.ae.Qt().ka()}getPane(){const t=this.ae,n=K(this.ae.Qt().Ks(t));return this.Xg(n)}moveToPane(t){this.ae.Qt().rf(this.ae,t)}seriesOrder(){const t=this.ae.Qt().Ks(this.ae);return t===null?-1:t.Y_().indexOf(this.ae)}setSeriesOrder(t){const n=this.ae.Qt().Ks(this.ae);n!==null&&n.vu(this.ae,t)}Qg(t){this.Kg.v()&&this.Kg.p(t)}}class Ew{constructor(t,n,s){this.nb=new Zt,this.Qu=new Zt,this.Nw=new Zt,this.sn=t,this.ia=t.Et(),this.vM=n,this.ia.Zc().i(this.sb.bind(this)),this.ia.Xc().i(this.eb.bind(this)),this.vM.qw().i(this.rb.bind(this)),this.Pu=s}m(){this.ia.Zc().u(this),this.ia.Xc().u(this),this.vM.qw().u(this),this.nb.m(),this.Qu.m(),this.Nw.m()}scrollPosition(){return this.ia.Oc()}scrollToPosition(t,n){n?this.ia.Yc(t,1e3):this.sn.gs(t)}scrollToRealTime(){this.ia.qc()}getVisibleRange(){const t=this.ia.xc();return t===null?null:{from:t.from.originalTime,to:t.to.originalTime}}setVisibleRange(t){const n={from:this.Pu.convertHorzItemToInternal(t.from),to:this.Pu.convertHorzItemToInternal(t.to)},s=this.ia.kc(n);this.sn.sf(s)}getVisibleLogicalRange(){const t=this.ia.Sc();return t===null?null:{from:t.Na(),to:t.bi()}}setVisibleLogicalRange(t){pe(t.from<=t.to,"The from index cannot be after the to index."),this.sn.sf(t)}resetTimeScale(){this.sn.ws()}fitContent(){this.sn.td()}logicalToCoordinate(t){const n=this.sn.Et();return n.Zi()?null:n.jt(t)}coordinateToLogical(t){return this.ia.Zi()?null:this.ia.Vc(t)}timeToIndex(t,n){const s=this.Pu.convertHorzItemToInternal(t);return this.ia.Mc(s,n)}timeToCoordinate(t){const n=this.timeToIndex(t,!1);return n===null?null:this.ia.jt(n)}coordinateToTime(t){const n=this.sn.Et(),s=n.Vc(t),i=n.en(s);return i===null?null:i.originalTime}width(){return this.vM.pv().width}height(){return this.vM.pv().height}subscribeVisibleTimeRangeChange(t){this.nb.i(t)}unsubscribeVisibleTimeRangeChange(t){this.nb._(t)}subscribeVisibleLogicalRangeChange(t){this.Qu.i(t)}unsubscribeVisibleLogicalRangeChange(t){this.Qu._(t)}subscribeSizeChange(t){this.Nw.i(t)}unsubscribeSizeChange(t){this.Nw._(t)}applyOptions(t){this.ia.vr(t)}options(){return{...an(this.ia.N()),barSpacing:this.ia.ml()}}sb(){this.nb.v()&&this.nb.p(this.getVisibleRange())}eb(){this.Qu.v()&&this.Qu.p(this.getVisibleLogicalRange())}rb(t){this.Nw.p(t.width,t.height)}}function Eu(e){return function(t){if(or(t.handleScale)){const s=t.handleScale;t.handleScale={axisDoubleClickReset:{time:s,price:s},axisPressedMouseMove:{time:s,price:s},mouseWheel:s,pinch:s}}else if(t.handleScale!==void 0){const{axisPressedMouseMove:s,axisDoubleClickReset:i}=t.handleScale;or(s)&&(t.handleScale.axisPressedMouseMove={time:s,price:s}),or(i)&&(t.handleScale.axisDoubleClickReset={time:i,price:i})}const n=t.handleScroll;or(n)&&(t.handleScroll={horzTouchDrag:n,vertTouchDrag:n,mouseWheel:n,pressedMouseMove:n})}(e),e}class Tw{constructor(t,n,s){this.hb=new Map,this.ab=new Map,this.lb=new Zt,this.ob=new Zt,this._b=new Zt,this.dd=new WeakMap,this.ub=new tw(n);const i=s===void 0?an(ku()):$e(an(ku()),Eu(s));this.cb=n,this.hv=new qx(t,i,n),this.hv.mw().i(o=>{this.lb.v()&&this.lb.p(this.fb(o()))},this),this.hv.ww().i(o=>{this.ob.v()&&this.ob.p(this.fb(o()))},this),this.hv.Bd().i(o=>{this._b.v()&&this._b.p(this.fb(o()))},this);const r=this.hv.Qt();this.pb=new Ew(r,this.hv.bM(),this.cb)}remove(){this.hv.mw().u(this),this.hv.ww().u(this),this.hv.Bd().u(this),this.pb.m(),this.hv.m(),this.hb.clear(),this.ab.clear(),this.lb.m(),this.ob.m(),this._b.m(),this.ub.m()}resize(t,n,s){this.autoSizeActive()||this.hv.wM(t,n,s)}addCustomSeries(t,n={},s=0){const i=(r=>({type:"Custom",isBuiltIn:!1,defaultOptions:{...dw,...r.defaultOptions()},mb:fw,wb:r}))(Mn(t));return this.Mb(i,n,s)}addSeries(t,n={},s=0){return this.Mb(t,n,s)}removeSeries(t){const n=Re(this.hb.get(t)),s=this.ub.if(n);this.hv.Qt().if(n),this.gb(s),this.hb.delete(t),this.ab.delete(n)}Jg(t,n){this.gb(this.ub.og(t,n))}tb(t,n,s){this.gb(this.ub.pg(t,n,s))}ib(t,n){const[s,i]=this.ub.wg(t,n);return s.length!==0&&this.gb(i),s}subscribeClick(t){this.lb.i(t)}unsubscribeClick(t){this.lb._(t)}subscribeCrosshairMove(t){this._b.i(t)}unsubscribeCrosshairMove(t){this._b._(t)}subscribeDblClick(t){this.ob.i(t)}unsubscribeDblClick(t){this.ob._(t)}priceScale(t,n=0){return new rm(this.hv,t,n)}timeScale(){return this.pb}applyOptions(t){this.hv.vr(Eu(t))}options(){return this.hv.N()}takeScreenshot(t=!1,n=!1){let s,i;try{n||(s=this.hv.Qt().N().crosshair.mode,this.hv.vr({crosshair:{mode:2}})),i=this.hv.TM(t)}finally{n||s===void 0||this.hv.Qt().vr({crosshair:{mode:s}})}return i}addPane(t=!1){const n=this.hv.Qt().uf();return n.j_(t),this.bb(n)}removePane(t){this.hv.Qt().Ad(t)}swapPanes(t,n){this.hv.Qt().zd(t,n)}autoSizeActive(){return this.hv.CM()}chartElement(){return this.hv.Mv()}panes(){return this.hv.Qt().Gn().map(t=>this.bb(t))}paneSize(t=0){const n=this.hv.AM(t);return{height:n.height,width:n.width}}setCrosshairPosition(t,n,s){const i=this.hb.get(s);if(i===void 0)return;const r=this.hv.Qt().Ks(i);r!==null&&this.hv.Qt().Gd(t,n,r)}clearCrosshairPosition(){this.hv.Qt().Zd(!0)}horzBehaviour(){return this.cb}Mb(t,n={},s=0){pe(t.mb!==void 0),function(c){if(c===void 0||c.type==="custom")return;const h=c;h.minMove!==void 0&&h.precision===void 0&&(h.precision=Zf(h.minMove))}(n.priceFormat),t.type==="Candlestick"&&function(c){c.borderColor!==void 0&&(c.borderUpColor=c.borderColor,c.borderDownColor=c.borderColor),c.wickColor!==void 0&&(c.wickUpColor=c.wickColor,c.wickDownColor=c.wickColor)}(n);const i=$e(an(Ff),an(t.defaultOptions),n),r=t.mb,o=new Kr(this.hv.Qt(),t.type,i,r,t.wb);this.hv.Qt().Qd(o,s);const l=new Mw(o,this,this,this,this.cb,c=>this.bb(c));return this.hb.set(l,o),this.ab.set(o,l),l}gb(t){const n=this.hv.Qt();for(const s of t.Y_.keys())s.Ia();n.Xd(t.Et.Dc,t.Et.Sg,t.Et.xg),t.Y_.forEach((s,i)=>i.ht(s.ue,s.bg)),n.Et().dc(),n.Lc()}Sb(t){return Re(this.ab.get(t))}xb(t){return t!==void 0&&this.ab.has(t)?this.Sb(t):void 0}fb(t){const n=new Map;t.QM.forEach((r,o)=>{const l=o.bh(),c=Sr(l)(r);if(l!=="Custom")pe(Yx(c));else{const h=o.cl();pe(!h||h(c)===!1)}n.set(this.Sb(o),c)});const s=this.xb(t.jM),i=t.YM===void 0?void 0:{type:t.YM.ds,sourceKind:t.YM.KM,objectKind:t.YM.GM,series:this.xb(t.YM.Y_),objectId:t.YM.ZM,paneIndex:t.YM.XM};return{time:t.Qr,logical:t.$n,point:t.JM,paneIndex:t.XM,hoveredInfo:i,hoveredSeries:s,hoveredObjectId:t.qM,seriesData:n,sourceEvent:t.tg}}bb(t){let n=this.dd.get(t);return n||(n=new Cw(this.hv,s=>this.Sb(s),t,this),this.dd.set(t,n)),n}}function Aw(e){if(Bi(e)){const t=document.getElementById(e);return pe(t!==null,`Cannot find element in DOM with id=${e}`),t}return e}function Rw(e,t,n){const s=Aw(e),i=new Tw(s,t,n);return t.setOptions(i.options()),i}function Pw(e,t){return Rw(e,new cu,cu.Tf(t))}function li(e,t,n,s){return Math.hypot(n-e,s-t)}function om(e,t,n,s,i,r,o,l=0){if(t.length===0||s.from>=t.length||s.to<=0)return;const{context:c,horizontalPixelRatio:h,verticalPixelRatio:a}=e,u=t[s.from];let f=r(e,u),p=u;if(s.to-s.from<2){const g=i/2;c.beginPath();const d={_t:u._t-g,ut:u.ut},w={_t:u._t+g,ut:u.ut};c.moveTo(d._t*h,d.ut*a),c.lineTo(w._t*h,w.ut*a),o(e,f,d,w)}else{const g=l>0;let d=0;const w=(x,k)=>{if(o(e,f,p,k),c.beginPath(),f=x,p=k,g){const S=d%l;c.lineDashOffset=S,d=S}};let C=p;c.beginPath(),c.moveTo(u._t*h,u.ut*a);for(let x=s.from+1;x<s.to;++x){C=t[x];const k=C._t*h,S=C.ut*a,T=r(e,C);switch(n){case 0:if(c.lineTo(k,S),g){const P=t[x-1],I=P._t*h,L=P.ut*a;d+=li(I,L,k,S)}break;case 1:{const P=t[x-1],I=P.ut*a;c.lineTo(k,I),g&&(d+=Math.abs(C._t-P._t)*h),T!==f&&(w(T,C),c.lineTo(k,I)),c.lineTo(k,S),g&&(d+=Math.abs(C.ut-P.ut)*a);break}case 2:{const[P,I]=El(t,x-1,x),L=P._t*h,O=P.ut*a,H=I._t*h,U=I.ut*a;if(c.bezierCurveTo(L,O,H,U,k,S),g){const q=t[x-1],X=q._t*h,j=q.ut*a,D=li(X,j,k,S),V=li(X,j,L,O)+li(L,O,H,U)+li(H,U,k,S);d+=(D+V)/2}break}}n!==1&&T!==f&&(w(T,C),c.moveTo(k,S))}(p!==C||p===C&&n===1)&&o(e,f,p,C),g&&(c.lineDashOffset=0)}}const Tu=6;function qo(e,t){return{_t:e._t-t._t,ut:e.ut-t.ut}}function Au(e,t){return{_t:e._t/t,ut:e.ut/t}}function El(e,t,n){const s=Math.max(0,t-1),i=Math.min(e.length-1,n+1);var r,o;return[(r=e[t],o=Au(qo(e[n],e[s]),Tu),{_t:r._t+o._t,ut:r.ut+o.ut}),qo(e[n],Au(qo(e[i],e[t]),Tu))]}function _w(e,t){const n=e.context;n.strokeStyle=t,n.stroke()}class $w extends Nn{constructor(){super(...arguments),this.rt=null}ht(t){this.rt=t}et(t){if(this.rt===null)return;const{ot:n,lt:s,Cb:i,yb:r,ct:o,Gt:l,Pb:c}=this.rt;if(s===null)return;const h=t.context;h.lineCap="butt",h.lineWidth=o*t.verticalPixelRatio;const a=_n(h,l);h.lineJoin="round";const u=this.kb.bind(this),f=function(p){return p.reduce((g,d)=>g+d,0)}(a);r!==void 0&&om(t,n,r,s,i,u,_w,f),c&&function(p,g,d,w,C){if(w.to-w.from<=0)return;const{horizontalPixelRatio:x,verticalPixelRatio:k,context:S}=p;let T=null;const P=Math.max(1,Math.floor(x))%2/2,I=d*k+P;for(let L=w.to-1;L>=w.from;--L){const O=g[L];if(O){const H=C(p,O);H!==T&&(T!==null&&S.fill(),S.beginPath(),S.fillStyle=H,T=H);const U=Math.round(O._t*x)+P,q=O.ut*k;S.moveTo(U,q),S.arc(U,q,I,0,2*Math.PI)}}S.fill()}(t,n,c,s,u)}}class am extends $w{kb(t,n){return n.vt}}function Ru(e,t,n,s,i){const r=1-i;return r*r*r*e+3*r*r*i*t+3*r*i*i*n+i*i*i*s}function Nw(e,t,n,s,i){if(n===2){const[r,o]=El(s,i-1,i);return[Math.min(e._t,t._t,r._t,o._t),Math.max(e._t,t._t,r._t,o._t)]}return[Math.min(e._t,t._t),Math.max(e._t,t._t)]}function Iw(e,t,n,s,i,r,o,l){switch(i){case 1:{const c=mi(e,t,n._t,n.ut,s._t,n.ut),h=mi(e,t,s._t,n.ut,s._t,s.ut),a=Math.min(c,h);return a<=l?a:null}case 2:{const[c,h]=El(r,o-1,o),a=function(u,f,p){let g=Number.POSITIVE_INFINITY,d=p[0];for(let w=1;w<=12;w++){const C=w/12,x={_t:Ru(p[0]._t,p[1]._t,p[2]._t,p[3]._t,C),ut:Ru(p[0].ut,p[1].ut,p[2].ut,p[3].ut,C)};g=Math.min(g,mi(u,f,d._t,d.ut,x._t,x.ut)),d=x}return g}(e,t,[n,c,h,s]);return a<=l?a:null}default:{const c=mi(e,t,n._t,n.ut,s._t,s.ut);return c<=l?c:null}}}class Dw extends kl{constructor(t,n){super(t,n,!0)}Og(t,n,s){n.Ic(this.kg,Ni(this.Tg)),t.Jo(this.kg,s,Ni(this.Tg))}Tb(t,n){return{wt:t,Mt:n,_t:NaN,ut:NaN}}Lg(){const t=this.ae.Sa();this.kg=this.ae.Ua().Bh().map(n=>{let s;if((n.Gr??1)>1){const i=n.Wt[1],r=n.Wt[2],o=n.Wt[3];s=Math.abs(i-o)>Math.abs(r-o)?i:r}else s=n.Wt[3];return this.Rb(n.$n,s,t)})}}class lm extends Dw{Bg(t,n){const s=this.ae.N();return function(i,r,o,l,c,h,a,u=0,f=0){if(r===null||r.from>=r.to||i.length===0)return null;const p=Math.max(h/2,a??0)+f;let g=Number.POSITIVE_INFINITY;if(a!==void 0){const S=a+f,T=ka(i,o-S,r.from,r.to),P=Ma(i,o+S,T,r.to);for(let I=T;I<P;I++){const L=i[I];if(!Su(o,L._t,L._t,a+f))continue;const O=Math.hypot(o-L._t,l-L.ut);O<=a+f&&(g=Math.min(g,O))}}if(r.to-r.from<2){const S=i[r.from],T=Math.max(u/2,p),P=mi(o,l,S._t-T,S.ut,S._t+T,S.ut);return P<=p&&(g=Math.min(g,P)),Number.isFinite(g)?wr(g,2,"series-point"):null}let d=Number.POSITIVE_INFINITY;const w=ka(i,o-p,r.from,r.to),C=Ma(i,o+p,w,r.to),x=Math.max(r.from+1,w),k=Math.min(r.to,C+1);for(let S=x;S<k;S++){const T=i[S-1],P=i[S],[I,L]=Nw(T,P,c,i,S);if(!Su(o,I,L,p))continue;const O=Iw(o,l,T,P,c,i,S,p);O!==null&&(d=Math.min(d,O))}return Number.isFinite(g)?wr(g,2,"series-point"):Number.isFinite(d)?wr(d,1,"series-line"):null}(this.kg,this.Tg,t,n,s.lineType,s.lineVisible?s.lineWidth:1,s.pointMarkersVisible?s.pointMarkersRadius||s.lineWidth/2+2:void 0,this.le.Et().ml(),s.hitTestTolerance)}}class Lw extends lm{constructor(){super(...arguments),this.Vg=new am}Rb(t,n,s){return{...this.Tb(t,n),...s.Sh(t)}}Ng(){const t=this.ae.N(),n={ot:this.kg,Gt:t.lineStyle,yb:t.lineVisible?t.lineType:void 0,ct:t.lineWidth,Pb:t.pointMarkersVisible?t.pointMarkersRadius||t.lineWidth/2+2:void 0,lt:this.Tg,Cb:this.le.Et().ml()};this.Vg.ht(n)}}const zw={type:"Line",isBuiltIn:!0,defaultOptions:{color:"#2196f3",lineStyle:0,lineWidth:3,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},mb:(e,t)=>new Lw(e,t)};function Fw(e,t,n,s,i){const{context:r,horizontalPixelRatio:o,verticalPixelRatio:l}=t;r.lineTo(i._t*o,e*l),r.lineTo(s._t*o,e*l),r.closePath(),r.fillStyle=n,r.fill()}class Bw extends Nn{constructor(){super(...arguments),this.rt=null}ht(t){this.rt=t}et(t){if(this.rt===null)return;const{ot:n,lt:s,Cb:i,ct:r,Gt:o,yb:l}=this.rt,c=this.rt.Lb??(this.rt.zb?0:t.mediaSize.height);if(s===null)return;const h=t.context;h.lineCap="butt",h.lineJoin="round",h.lineWidth=r,_n(h,o),h.lineWidth=1,om(t,n,l,s,i,this.Ob.bind(this),Fw.bind(null,c))}}class Ww{Nb(t,n){const s=this.Fb,{Wb:i,Hb:r,Ub:o,$b:l,Lb:c,jb:h,qb:a}=n;if(this.Yb===void 0||s===void 0||s.Wb!==i||s.Hb!==r||s.Ub!==o||s.$b!==l||s.Lb!==c||s.jb!==h||s.qb!==a){const{verticalPixelRatio:u}=t,f=c||h>0?u:1,p=h*f,g=a===t.bitmapSize.height?a:a*f,d=(c??0)*f,w=t.context.createLinearGradient(0,p,0,g);if(w.addColorStop(0,i),c!=null){const C=Ls((d-p)/(g-p),0,1);w.addColorStop(C,r),w.addColorStop(C,o)}w.addColorStop(1,l),this.Yb=w,this.Fb=n}return this.Yb}}class jw{constructor(t,n,s,i){this.Zb=t,this.Xb=n,this.Jb=s,this.Qb=i}st(t,n,s){this.Zb.st(t,n,s),!this.Jb()||n&&this.Qb()||this.Xb.st(t,n,s)}}class Vw{constructor(t,n){this.Xb=t,this.tS=n}Tt(){return this.tS()?this.Xb:null}}class Ow extends Bw{constructor(){super(...arguments),this.Kb=new Ww}Ob(t,n){var s;return this.Kb.Nb(t,{Wb:n.ah,Hb:"",Ub:"",$b:n.oh,jb:((s=this.rt)==null?void 0:s.jb)??0,qb:t.bitmapSize.height})}}class Uw extends lm{constructor(t,n){super(t,n),this.lS=new Ow,this.Xb=new am,this.sS=new Vw(this.Xb,()=>this.Jb()),this.eS=[this],this.rS=[this.sS],this.hS={Za:this.eS,qa:this.rS},this.Vg=new jw(this.lS,this.Xb,()=>this.Jb(),()=>this.le.N().hoveredSeriesOnTop)}Ga(){return this.hS}Rb(t,n,s){return{...this.Tb(t,n),...s.Sh(t)}}Ng(){const t=this.ae.N();if(this.Tg===null||this.kg.length===0)return;let n;if(t.relativeGradient){n=this.kg[this.Tg.from].ut;for(let s=this.Tg.from;s<this.Tg.to;s++){const i=this.kg[s];i.ut<n&&(n=i.ut)}}this.lS.ht({yb:t.lineType,ot:this.kg,Gt:t.lineStyle,ct:t.lineWidth,Lb:null,jb:n,zb:t.invertFilledArea,lt:this.Tg,Cb:this.le.Et().ml()}),this.Xb.ht({yb:t.lineVisible?t.lineType:void 0,ot:this.kg,Gt:t.lineStyle,ct:t.lineWidth,lt:this.Tg,Cb:this.le.Et().ml(),Pb:t.pointMarkersVisible?t.pointMarkersRadius||t.lineWidth/2+2:void 0})}Jb(){return this.ae.It()&&this.Tg!==null&&this.aS()}aS(){const t=this.ae.N();return t.lineVisible||t.pointMarkersVisible}}const Hw={type:"Area",isBuiltIn:!0,defaultOptions:{topColor:"rgba( 46, 220, 135, 0.4)",bottomColor:"rgba( 40, 221, 100, 0)",invertFilledArea:!1,relativeGradient:!1,lineColor:"#33D778",lineStyle:0,lineWidth:3,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},mb:(e,t)=>new Uw(e,t)};class qw extends kl{constructor(t,n){super(t,n,!1)}Bg(t,n){return sm(this.kg,this.Tg,t,n,this.le.Et().ml(),this.ae.N().hitTestTolerance,(s,i)=>{i[0]=s.n_,i[1]=s.s_})}Og(t,n,s){n.Ic(this.kg,Ni(this.Tg)),t.t_(this.kg,s,Ni(this.Tg))}fS(t,n,s){return{wt:t,jr:n.Wt[0],qr:n.Wt[1],Yr:n.Wt[2],Kr:n.Wt[3],_t:NaN,i_:NaN,n_:NaN,s_:NaN,e_:NaN}}Lg(){const t=this.ae.Sa();this.kg=this.ae.Ua().Bh().map(n=>this.Rb(n.$n,n,t))}}class Gw extends Nn{constructor(){super(...arguments),this.qt=null,this.oS=0}ht(t){this.qt=t}et(t){if(this.qt===null||this.qt.Un.length===0||this.qt.lt===null)return;const{horizontalPixelRatio:n}=t;this.oS=function(r,o){if(r>=2.5&&r<=4)return Math.floor(3*o);const l=1-.2*Math.atan(Math.max(4,r)-4)/(.5*Math.PI),c=Math.floor(r*l*o),h=Math.floor(r*o),a=Math.min(c,h);return Math.max(Math.floor(o),a)}(this.qt.ml,n),this.oS>=2&&Math.floor(n)%2!=this.oS%2&&this.oS--;const s=this.qt.Un;this.qt.pS&&this.vS(t,s,this.qt.lt),this.qt.gi&&this.Vm(t,s,this.qt.lt);const i=this.mS(n);(!this.qt.gi||this.oS>2*i)&&this.wS(t,s,this.qt.lt)}vS(t,n,s){if(this.qt===null)return;const{context:i,horizontalPixelRatio:r,verticalPixelRatio:o}=t;let l="",c=Math.min(Math.floor(r),Math.floor(this.qt.ml*r));c=Math.max(Math.floor(r),Math.min(c,this.oS));const h=Math.floor(.5*c);let a=null;for(let u=s.from;u<s.to;u++){const f=n[u];f.rh!==l&&(i.fillStyle=f.rh,l=f.rh);const p=Math.round(Math.min(f.i_,f.e_)*o),g=Math.round(Math.max(f.i_,f.e_)*o),d=Math.round(f.n_*o),w=Math.round(f.s_*o);let C=Math.round(r*f._t)-h;const x=C+c-1;a!==null&&(C=Math.max(a+1,C),C=Math.min(C,x));const k=x-C+1;i.fillRect(C,d,k,p-d),i.fillRect(C,g+1,k,w-g),a=x}}mS(t){let n=Math.floor(1*t);this.oS<=2*n&&(n=Math.floor(.5*(this.oS-1)));const s=Math.max(Math.floor(t),n);return this.oS<=2*s?Math.max(Math.floor(t),Math.floor(1*t)):s}Vm(t,n,s){if(this.qt===null)return;const{context:i,horizontalPixelRatio:r,verticalPixelRatio:o}=t;let l="";const c=this.mS(r);let h=null;for(let a=s.from;a<s.to;a++){const u=n[a];u.eh!==l&&(i.fillStyle=u.eh,l=u.eh);let f=Math.round(u._t*r)-Math.floor(.5*this.oS);const p=f+this.oS-1,g=Math.round(Math.min(u.i_,u.e_)*o),d=Math.round(Math.max(u.i_,u.e_)*o);if(h!==null&&(f=Math.max(h+1,f),f=Math.min(f,p)),this.qt.ml*r>2*c)$v(i,f,g,p-f+1,d-g+1,c);else{const w=p-f+1;i.fillRect(f,g,w,d-g+1)}h=p}}wS(t,n,s){if(this.qt===null)return;const{context:i,horizontalPixelRatio:r,verticalPixelRatio:o}=t;let l="";const c=this.mS(r);for(let h=s.from;h<s.to;h++){const a=n[h];let u=Math.round(Math.min(a.i_,a.e_)*o),f=Math.round(Math.max(a.i_,a.e_)*o),p=Math.round(a._t*r)-Math.floor(.5*this.oS),g=p+this.oS-1;if(a.sh!==l){const d=a.sh;i.fillStyle=d,l=d}this.qt.gi&&(p+=c,u+=c,g-=c,f-=c),u>f||i.fillRect(p,u,g-p+1,f-u+1)}}}class Yw extends qw{constructor(){super(...arguments),this.Vg=new Gw}Rb(t,n,s){return{...this.fS(t,n,s),...s.Sh(t)}}Ng(){const t=this.ae.N();this.Vg.ht({Un:this.kg,ml:this.le.Et().ml(),pS:t.wickVisible,gi:t.borderVisible,lt:this.Tg})}}const Xw={type:"Candlestick",isBuiltIn:!0,defaultOptions:{upColor:"#26a69a",downColor:"#ef5350",wickVisible:!0,borderVisible:!0,borderColor:"#378658",borderUpColor:"#26a69a",borderDownColor:"#ef5350",wickColor:"#737375",wickUpColor:"#26a69a",wickDownColor:"#ef5350"},mb:(e,t)=>new Yw(e,t)};({...Ff});const Qw=()=>{try{if(typeof window<"u")return window.localStorage.getItem("backflow_dev_diagnostics")==="1"}catch{}return!1},Br=(...e)=>{Qw()&&console.warn(...e)};function Jw(e,t,n){var o,l;const s=t.expression?((o=e.evaluateExpression)==null?void 0:o.call(e,t.expression,t.expressionUrl,n,t.expressionKey))??e.interpolateText(t.expression):e.interpolateText(t.text||"");if(t.className){const c=((l=e.parseClassNameResponsive)==null?void 0:l.call(e,t.className,n))??e.parseClassName(t.className);if(e.renderMode!=="css-driven"){const a=bl(t.className);if(a.size>0){const f=ht(a,e.containerWidth,"1rem");c.fontSize=f}const u=Gs(t.className);u.size>0&&(c.display=ht(u,e.containerWidth,"block"))}const h=e.getCommonProps(n,c,t);return E("p",{key:n,className:t.className,...h},s)}const i={color:e.cfg.colors.text};t.fontSize!==void 0&&(i.fontSize=`${t.fontSize}px`),t.fontWeight!==void 0&&(i.fontWeight=t.fontWeight),t.color!==void 0&&(i.color=t.color),t.textAlign!==void 0&&(i.textAlign=t.textAlign);const r=e.getCommonProps(n,i,t);return E("p",{key:n,...r},s)}function Kw(e){return e.replace(/<script[\s\S]*?<\/script>/gi,"").replace(/<iframe[\s\S]*?<\/iframe>/gi,"").replace(/\son\w+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi,"")}function Zw(e,t,n){const s=String(e.apiUrl||"").replace(/\/$/,""),i=e.interpolateText(t.text||t.html||"").replace(/(src|href)=("|')\/(?!\/)/g,s?`$1=$2${s}/`:"$1=$2/"),r=e.getCommonProps(n,{color:e.cfg.colors.text},t);return E("div",{key:n,className:t.className,...r,dangerouslySetInnerHTML:{__html:Kw(i)}})}function t1(e,t,n){var l,c,h,a,u;const s=()=>{t.onClick?e.handleButtonClick(t.onClick,{onSuccess:t.onSuccess,onError:t.onError},{optimistic:t.optimistic,feedback:t.feedback}):t.href&&(t.href.startsWith("http")||e.previewMode?window.open(t.href,"_blank","noopener,noreferrer"):window.location.href=t.href)},i=()=>{var f;if(!e.interactionDisabled){if((f=t.confirmation)!=null&&f.enabled){(e.setOverlayModal||e.setActiveModal)({id:"__confirm",definition:{title:t.confirmation.title||"Confirm Action",size:"sm",components:[{type:"text",text:t.confirmation.message||"Are you sure you want to proceed?",color:e.cfg.colorMode==="light"?"rgba(0,0,0,0.65)":"rgba(255,255,255,0.6)",fontSize:14}],actions:[{label:"Cancel",variant:"ghost",dismiss:!0},{label:"Confirm",variant:"primary",dismiss:!0}]},legacyOnConfirm:()=>{s()}});return}s()}};if(t.className){const f=((l=e.parseClassNameResponsive)==null?void 0:l.call(e,t.className,n))??e.parseClassName(t.className);if(e.renderMode!=="css-driven"){const g=Gs(t.className);g.size>0&&(f.display=ht(g,e.containerWidth,"inline"));const d=bl(t.className);if(d.size>0){const w=ht(d,e.containerWidth,"1rem");f.fontSize=w}}t.icon&&(f.display="inline-flex",f.alignItems="center",f.gap=6);const p=e.getCommonProps(n,f,t);return E("a",{key:n,className:t.className,...p,onClick:e.interactionDisabled?void 0:i,href:e.interactionDisabled?void 0:t.href&&!t.onClick?t.href:void 0,target:(c=t.href)!=null&&c.startsWith("http")?"_blank":void 0,rel:(h=t.href)!=null&&h.startsWith("http")?"noopener noreferrer":void 0},t.icon?e.renderIcon(t.icon,16):null,e.interpolateText(t.text||t.label||""))}const r={cursor:"pointer",textDecoration:"none",transition:"all 0.2s",display:"inline-flex",alignItems:"center",gap:6},o=e.getCommonProps(n,r,t);return E("a",{key:n,...o,onClick:e.interactionDisabled?void 0:i,href:e.interactionDisabled?void 0:t.href&&!t.onClick?t.href:void 0,target:(a=t.href)!=null&&a.startsWith("http")?"_blank":void 0,rel:(u=t.href)!=null&&u.startsWith("http")?"noopener noreferrer":void 0},t.icon?e.renderIcon(t.icon,16):null,e.interpolateText(t.text||t.label||""))}function e1(e,t,n){var g,d,w,C,x;let s=!1;if(t.activeWhen){if(t.activeWhen===e.currentSceneId)s=!0;else if(typeof t.activeWhen=="string"){const k=t.activeWhen.split("=",2);k.length===2&&(s=String(((g=e.sceneData)==null?void 0:g[k[0]])??"")===k[1])}}const i=s?{onClick:t.activeOnClick||t.onClick,onSuccess:t.activeOnSuccess||t.onSuccess,onError:t.activeOnError||t.onError,icon:t.activeIcon||t.icon,text:t.activeText||t.text,label:t.activeText||t.label}:{onClick:t.onClick,onSuccess:t.onSuccess,onError:t.onError,icon:t.icon,text:t.text,label:t.label},r=t.disabled?((d=e.evaluateCondition)==null?void 0:d.call(e,t.disabled))??!1:!1,o=k=>{const S=()=>e.handleButtonClick(i.onClick||"",{onSuccess:i.onSuccess,onError:i.onError},{optimistic:t.optimistic,feedback:t.feedback,refetchScope:t.refetchScope,mergeResponse:t.mergeResponse,anchorElement:k==null?void 0:k.currentTarget});(e.withLoading?e.withLoading(n,S):S()).catch(P=>{var L,O;const I=((L=t.onError)==null?void 0:L.message)||(P==null?void 0:P.message)||"An error occurred";(O=e.showToast)==null||O.call(e,I,"error")})},l=k=>{var S;if((S=t.confirmation)!=null&&S.enabled){(e.setOverlayModal||e.setActiveModal)({id:"__confirm",definition:{title:t.confirmation.title||"Confirm Action",size:"sm",components:[{type:"text",text:t.confirmation.message||"Are you sure you want to proceed?",color:e.cfg.colorMode==="light"?"rgba(0,0,0,0.65)":"rgba(255,255,255,0.6)",fontSize:16}],actions:[{label:"Cancel",variant:"ghost",dismiss:!0},{label:"Confirm",variant:"primary",dismiss:!0}]},legacyOnConfirm:()=>{o(k)}});return}o(k)},c=(w=e.buttonLoading)==null?void 0:w[n];if(t.className){let k=((C=e.parseClassNameResponsive)==null?void 0:C.call(e,t.className,n))??e.parseClassName(t.className);if(e.renderMode!=="css-driven"){const U=Gs(t.className);U.size>0&&(k.display=ht(U,e.containerWidth,"inline-flex"));const q=bl(t.className);q.size>0&&(k.fontSize=ht(q,e.containerWidth,"1rem"))}let S=t.className;if(s&&t.activeClass){const U=((x=e.parseClassNameResponsive)==null?void 0:x.call(e,t.activeClass,n))??e.parseClassName(t.activeClass);k={...k,...U},S=`${t.className} ${t.activeClass}`}const T={display:"inline-flex",alignItems:"center",justifyContent:k.textAlign==="left"?"flex-start":k.textAlign==="right"?"flex-end":"center",gap:"6px",...k,...t.color&&{color:t.color},...t.background&&{background:t.background},...t.borderRadius!==void 0&&{borderRadius:typeof t.borderRadius=="number"?`${t.borderRadius}px`:t.borderRadius},...t.borderColor&&{borderColor:t.borderColor},...c&&{opacity:.6,pointerEvents:"none"}},P={},I=(t.className||"").split(/\s+/).filter(Boolean);for(const U of I)if(U.startsWith("hover:")){const q=U.replace("hover:","");if(q.startsWith("bg-")||q.startsWith("text-")||q.startsWith("border-")){const X=e.parseClassName(q);Object.assign(P,X)}}const L=e.getCommonProps(n,T,t),O=[];i.icon&&!c&&O.push(E("span",{key:"icon",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,...i.text?{marginRight:"6px"}:{}}},e.renderIcon(i.icon,t.iconSize||16))),c&&O.unshift(E("div",{key:"spinner",className:"bf-btn-spinner",style:{width:"14px",height:"14px",border:"2px solid currentColor",borderTopColor:"transparent",borderRadius:"50%",flexShrink:0}})),Array.isArray(t.children)&&t.children.length>0?t.children.forEach((U,q)=>{O.push(e.renderComponent(U,q,n))}):O.push(i.label||i.text||(i.icon?"":"Button"));const H={};return Object.keys(P).length>0&&(H.onMouseEnter=U=>{P.backgroundColor&&(U.currentTarget.style.backgroundColor=P.backgroundColor),P.color&&(U.currentTarget.style.color=P.color),P.borderColor&&(U.currentTarget.style.borderColor=P.borderColor)},H.onMouseLeave=U=>{P.backgroundColor&&(U.currentTarget.style.backgroundColor=T.backgroundColor||""),P.color&&(U.currentTarget.style.color=T.color||""),P.borderColor&&(U.currentTarget.style.borderColor=T.borderColor||"")}),E("button",{key:n,className:S,title:e.interpolateText(t.tooltip||t.ariaLabel||i.label||i.text||"Button"),...L,...H,onClick:e.interactionDisabled?void 0:l,disabled:c||r||void 0},...O)}const h=e.cfg.colors.primary,a=e.cfg.colors.accent,u={display:"inline-flex",alignItems:"center",gap:"6px",padding:"0.75rem 1.5rem",borderRadius:"0.75rem",fontWeight:600,transition:e.cfg.effects.transition,color:e.cfg.colorMode==="light"?"#ffffff":e.cfg.colors.text,background:s?e.cfg.colors.primary:`linear-gradient(to right, ${h}, ${a})`,boxShadow:s?"none":`0 10px 15px -3px ${h}40`,...c&&{opacity:.6,pointerEvents:"none"}},f=e.getCommonProps(n,u,t),p=[];return c&&p.push(E("div",{key:"spinner",className:"bf-btn-spinner",style:{width:"14px",height:"14px",border:"2px solid currentColor",borderTopColor:"transparent",borderRadius:"50%",flexShrink:0}})),i.icon&&!c&&p.push(E("span",{key:"icon",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginRight:"6px"}},e.renderIcon(i.icon,t.iconSize||16))),p.push(i.label||i.text||(i.icon?"":"Button")),E("button",{key:n,title:e.interpolateText(t.tooltip||t.ariaLabel||i.label||i.text||"Button"),...f,onClick:e.interactionDisabled?void 0:l,disabled:c||r||void 0},...p)}function n1(e,t,n){var h;const s=e.interpolateText(t.src||""),i=!s||s==="placeholder",r=e.imageErrors[n];if(t.skipEmpty&&i)return null;const o={border:`1px dashed ${e.cfg.colors.borderSubtle}`,display:"flex",alignItems:"center",justifyContent:"center",padding:10,height:"200px",borderRadius:"0.75rem"};if(i){const a=e.getCommonProps(n,o,t);return E("div",{key:n,...a},E("span",{style:{color:e.cfg.colors.textPlaceholder,fontSize:"0.875rem"}},"Image"))}if(r)return null;if(t.className){const a=((h=e.parseClassNameResponsive)==null?void 0:h.call(e,t.className,n))??e.parseClassName(t.className),u=e.getCommonProps(n,a,t),f={key:`${n}-${s}`,src:s,alt:t.alt||"",className:t.className,...u,onError:()=>e.setImageErrors(p=>({...p,[n]:!0}))};return t.onClick&&!e.interactionDisabled&&(f.onClick=()=>e.handleButtonClick(t.onClick)),E("img",f)}const l={width:t.w||t.width||"100%",height:t.h||t.height||"auto",objectFit:"cover",borderRadius:"0.75rem"};t.onClick&&(l.cursor="pointer");const c={key:`${n}-${s}`,src:s,alt:t.alt||"",...e.getCommonProps(n,l,t),onError:()=>e.setImageErrors(a=>({...a,[n]:!0}))};return t.onClick&&!e.interactionDisabled&&(c.onClick=()=>e.handleButtonClick(t.onClick)),E("img",c)}function s1(e,t,n){var r;if(t.className){const o=((r=e.parseClassNameResponsive)==null?void 0:r.call(e,t.className,n))??e.parseClassName(t.className),l=e.getCommonProps(n,o,t);return E("input",{key:n,className:t.className,...l,name:t.name,placeholder:t.placeholder,type:t.inputType||"text",value:e.sceneData[t.name||""]??"",onChange:c=>e.setSceneData(h=>({...h,[t.name||""]:c.target.value})),onKeyDown:t.onKeyDown?c=>{c.key==="Enter"&&e.handleButtonClick(t.onKeyDown)}:void 0})}const s={width:"100%",padding:"8px 8px",borderRadius:e.cfg.components.inputRadius||void 0,backgroundColor:e.cfg.colors.surface,color:e.cfg.colors.text,border:`1px solid ${e.cfg.colors.border}`,outline:"none",transition:e.cfg.effects.transition},i=e.getCommonProps(n,s,t);if(t.label){const o=e.getCommonProps(n,{width:"100%"},t);return E("div",{key:n,...o},E("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem"}},t.label),E("input",{...i,name:t.name,placeholder:t.placeholder,type:t.inputType||"text",value:e.sceneData[t.name||""]??"",onChange:l=>e.setSceneData(c=>({...c,[t.name||""]:l.target.value}))}))}return E("input",{key:n,...i,name:t.name,placeholder:t.placeholder,type:t.inputType||"text",value:e.sceneData[t.name||""]??"",onChange:o=>e.setSceneData(l=>({...l,[t.name||""]:o.target.value}))})}function i1(e,t,n){const s=t.value?e.interpolateText(String(t.value)):e.sceneData[t.name||""]??"";return E("input",{key:n,type:"hidden",name:t.name,value:s})}function r1(e,t,n){var o;const s=()=>{var l;return[t.placeholder&&E("option",{key:"__placeholder",value:""},t.placeholder),...((l=t.options)==null?void 0:l.map(c=>E("option",{key:c.value,value:c.value},c.label)))||[]]};if(t.className){const l=((o=e.parseClassNameResponsive)==null?void 0:o.call(e,t.className,n))??e.parseClassName(t.className),c=e.getCommonProps(n,l,t);return E("select",{key:n,className:t.className,...c,name:t.name,value:e.sceneData[t.name||""]??"",onChange:h=>e.setSceneData(a=>({...a,[t.name||""]:h.target.value}))},...s())}const i={width:"100%",padding:"8px 8px",borderRadius:e.cfg.components.inputRadius||void 0,backgroundColor:e.cfg.colors.surface,color:e.cfg.colors.text,border:`1px solid ${e.cfg.colors.border}`,outline:"none",transition:e.cfg.effects.transition,cursor:"pointer",appearance:"none"},r=e.getCommonProps(n,i,t);if(t.label){const l=e.getCommonProps(n,{width:"100%"},t);return E("div",{key:n,...l},E("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem"}},t.label),E("select",{...r,name:t.name,value:e.sceneData[t.name||""]??"",onChange:c=>e.setSceneData(h=>({...h,[t.name||""]:c.target.value}))},...s()))}return E("select",{key:n,...r,name:t.name,value:e.sceneData[t.name||""]??"",onChange:l=>e.setSceneData(c=>({...c,[t.name||""]:l.target.value}))},...s())}function o1(e,t,n){const s=t.className||"flex items-center gap-3 cursor-pointer text-white",i=e.parseClassName(s),r="w-5 h-5 rounded border-gray-600 bg-gray-800 accent-primary",o=e.parseClassName(r),l=e.getCommonProps(n,i,t);return E("label",{key:n,className:s,...l},E("input",{type:"checkbox",className:r,style:o,checked:e.sceneData[t.name||""]||!1,onChange:c=>e.setSceneData(h=>({...h,[t.name||""]:c.target.checked}))}),E("span",{},t.label||""))}function a1(e,t,n){const s={green:{bg:"#065f4620",color:"#22c55e",border:"#22c55e40"},blue:{bg:"#1e40af20",color:"#3b82f6",border:"#3b82f640"},red:{bg:"#7f1d1d20",color:"#ef4444",border:"#ef444440"},yellow:{bg:"#71370220",color:"#eab308",border:"#eab30840"},purple:{bg:"#581c8720",color:"#a855f7",border:"#a855f740"},orange:{bg:"#7c2d1220",color:"#f97316",border:"#f9731640"},gray:{bg:"#37415120",color:"#9ca3af",border:"#9ca3af40"},cyan:{bg:"#0e727020",color:"#06b6d4",border:"#06b6d440"},pink:{bg:"#83184420",color:"#ec4899",border:"#ec489940"}};let r=t.colorScheme||"gray";if(t.colorBy&&typeof t.colorBy=="object"){const a=(e.interpolateText(t.text||t.label||"")||"").trim().toLowerCase();t.colorBy[a]&&(r=t.colorBy[a])}const o=s[r]||s.gray,l=t.variant||"subtle";let c={display:"inline-flex",alignItems:"center",padding:"2px 8px",borderRadius:"4px",fontSize:"11px",fontWeight:600,letterSpacing:"0.025em",textTransform:"uppercase",whiteSpace:"nowrap"};l==="solid"?(c.backgroundColor=o.color,c.color="#fff"):l==="outline"?(c.backgroundColor="transparent",c.color=o.color,c.border=`1px solid ${o.border||o.color}`):(c.backgroundColor=o.bg,c.color=o.color,t.bordered&&(c.border=`1px solid ${o.border||o.color}`)),t.pill&&(c.borderRadius="9999px"),t.className&&(c={...c,...e.parseClassName(t.className)});const h=e.getCommonProps(n,c,t);return E("span",{key:n,...h},e.interpolateText(t.text||t.label||""))}function l1(e,t,n){const s={display:"inline-flex",alignItems:"center",gap:"4px",padding:"4px 10px",borderRadius:"9999px",fontSize:"12px",fontWeight:500,backgroundColor:t.bg||e.cfg.colors.surfaceHover,color:t.color||e.cfg.colors.textSecondary,...t.className?e.parseClassName(t.className):{}},i=e.getCommonProps(n,s,t);return E("span",{key:n,...i},e.interpolateText(t.text||t.label||""))}function c1(e,t,n){const i={sm:32,md:40,lg:48,xl:64}[t.size||"md"]||40,r=i*.4;if(t.src){const h={width:`${i}px`,height:`${i}px`,borderRadius:"50%",objectFit:"cover",...t.className?e.parseClassName(t.className):{}},a=e.getCommonProps(n,h,t);return E("img",{key:n,src:t.src,alt:t.alt||t.label||"",...a})}const o=t.initials||(t.label||t.text||"").split(" ").map(h=>h[0]).join("").slice(0,2).toUpperCase()||"?",l={width:`${i}px`,height:`${i}px`,borderRadius:"50%",backgroundColor:t.bg||e.cfg.colors.primary,color:t.color||e.cfg.colors.text,display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${r}px`,fontWeight:600,flexShrink:0,...t.className?e.parseClassName(t.className):{}},c=e.getCommonProps(n,l,t);return E("div",{key:n,...c},o)}function h1(e,t,n){const s=t.progressValue??t.value??0,i=t.progressMax??100,r=(p,g)=>{if(typeof p=="string")return Number(e.interpolateText(p))||g;const d=Number(p);return Number.isFinite(d)?d:g},o=r(s,0),l=r(i,100),c=Math.min(100,Math.max(0,o/l*100)),a=o>l?e.cfg.colors.danger:t.color||e.cfg.colors.primary,u={width:"100%",display:"flex",flexDirection:"column",gap:"4px",...t.className?e.parseClassName(t.className):{}},f=e.getCommonProps(n,u,t);return E("div",{key:n,...f},(t.progressLabel||t.label)&&m.createElement("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"12px",color:e.cfg.colors.textMuted}},E("span",null,e.interpolateText(t.progressLabel||t.label||"")),E("span",null,`${o}/${l}`)),m.createElement("div",{style:{width:"100%",height:"8px",backgroundColor:e.cfg.colors.surfaceHover,borderRadius:"4px",overflow:"hidden"}},E("div",{style:{width:`${Math.min(c,100)}%`,height:"100%",backgroundColor:a,borderRadius:"4px",transition:"width 0.3s ease"}})))}function u1(e,t,n){const s={position:"relative",width:"100%",...t.className?e.parseClassName(t.className):{}},i=e.getCommonProps(n,s,t);return E("div",{key:n,...i},E("span",{style:{position:"absolute",left:"12px",top:"50%",transform:"translateY(-50%)",color:e.cfg.colors.textPlaceholder,fontSize:"14px",pointerEvents:"none"}},e.renderIcon("search",14)),E("input",{type:"text",name:t.name||"search",placeholder:t.placeholder||"Search...",value:e.sceneData[t.name||"search"]??"",onChange:r=>{e.setSceneData(o=>({...o,[t.name||"search"]:r.target.value}))},style:{width:"100%",padding:"8px 12px 8px 36px",borderRadius:e.cfg.layout.borderRadius,backgroundColor:e.cfg.colors.surface,color:e.cfg.colors.text,border:`1px solid ${e.cfg.colors.border}`,outline:"none",fontSize:e.cfg.typography.baseFontSize,transition:e.cfg.effects.transition}}))}function d1(e,t,n){const s=Array.isArray(t.breadcrumbItems)?t.breadcrumbItems:[],i={display:"flex",alignItems:"center",gap:"4px",fontSize:"14px",...t.className?e.parseClassName(t.className):{}},r=e.getCommonProps(n,i,t);return E("nav",{key:n,...r,"aria-label":"Breadcrumb"},s.map((o,l)=>{const c=l===s.length-1;return m.createElement(m.Fragment,{key:`${n}-bc-${l}`},m.createElement(c?"span":"a",{style:{color:c?e.cfg.colors.textSecondary:e.cfg.colors.textMuted,fontWeight:c?600:400,cursor:c?"default":"pointer",textDecoration:"none",transition:e.cfg.effects.transition},...!c&&o.href?{href:o.href}:{},...!c&&o.onClick?{onClick:()=>e.handleButtonClick(o.onClick,{})}:{}},o.label),!c&&E("span",{style:{color:e.cfg.colors.border,margin:"0 2px"}},"/"))}))}function f1(e,t,n){const s=Array.isArray(t.items)?t.items:[],[i,r]=m.useState(0),o=t.autoplay!==!1&&s.length>1,l=t.interval||4e3,c=t.effect==="fade"?"fade":"slide";m.useEffect(()=>{if(!o||s.length<2)return;const x=setInterval(()=>r(k=>(k+1)%s.length),l);return()=>clearInterval(x)},[o,l,s.length]);const h=x=>r((x%s.length+s.length)%s.length),a=t.showArrows!==!1&&s.length>1,u=t.showDots!==!1&&s.length>1,f={position:"relative",overflow:"hidden",...t.className?e.parseClassName(t.className):{}};t.aspectRatio&&(f.aspectRatio=t.aspectRatio),!t.aspectRatio&&!t.height&&(f.height="320px");const p=e.getCommonProps(n,f,t),g=x=>typeof x=="string"?{type:"text",text:x}:x&&x.image?{type:"image",src:x.image,alt:x.alt||"",title:x.title}:x,d=s.map((x,k)=>{const S=e.renderComponent({...g(x),key:void 0},k,`${n}-slide`),T={width:"100%",height:"100%",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center"};return c==="fade"?(T.position="absolute",T.inset="0",T.opacity=k===i?1:0,T.transition="opacity .5s ease",T.pointerEvents=k===i?"auto":"none"):T.flexShrink=0,E("div",{key:`${n}-item-${k}`,style:T},S)}),w=c==="fade"?{position:"relative",width:"100%",height:"100%"}:{display:"flex",height:"100%",transition:"transform .5s ease",transform:`translateX(-${i*100}%)`},C={position:"absolute",top:"50%",transform:"translateY(-50%)",zIndex:2,width:"36px",height:"36px",borderRadius:"50%",border:"none",background:"rgba(0,0,0,0.45)",color:"#fff",fontSize:"18px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"};return E("div",{key:n,...p},E("div",{style:w},d),a&&E("div",{style:{...C,left:"8px"}},E("button",{style:{background:"transparent",border:"none",color:"inherit",fontSize:"18px",cursor:"pointer"},onClick:()=>h(i-1),"aria-label":"Previous slide"},"<")),a&&E("div",{style:{...C,right:"8px"}},E("button",{style:{background:"transparent",border:"none",color:"inherit",fontSize:"18px",cursor:"pointer"},onClick:()=>h(i+1),"aria-label":"Next slide"},">")),u&&E("div",{style:{position:"absolute",bottom:"10px",left:"50%",transform:"translateX(-50%)",display:"flex",gap:"6px",zIndex:2}},s.map((x,k)=>E("button",{key:`${n}-dot-${k}`,"aria-label":`Slide ${k+1}`,onClick:()=>h(k),style:{width:"10px",height:"10px",borderRadius:"50%",border:"none",cursor:"pointer",padding:0,background:k===i?"rgba(255,255,255,0.95)":"rgba(255,255,255,0.4)",transition:"background .3s ease"}}))))}function m1(e,t,n){const s=Array.isArray(t.items)?t.items:[],i=t.speed||20,r={overflow:"hidden",width:"100%",...t.className?e.parseClassName(t.className):{}},o=e.getCommonProps(n,r,t),l=c=>E("div",{key:c,style:{display:"inline-flex",alignItems:"center",gap:t.gap||"24px",paddingRight:t.gap||"24px",animation:`bf-marquee ${i}s linear infinite`,willChange:"transform",flexShrink:0}},s.map((h,a)=>{const u=typeof h=="string"?{type:"text",text:h}:h&&h.image?{type:"image",src:h.image,alt:h.alt||"",height:t.itemHeight||"48px"}:h;return e.renderComponent(u,a,`${c}-${n}-marq`)}));return E("div",{key:n,...o},E("div",{style:{display:"flex",width:"max-content"}},l("a"),l("b")))}function p1(e,t,n){const s=m.useRef(null),i=m.useRef(null),r=m.useRef(null),[o,l]=m.useState("idle"),[c,h]=m.useState(""),[a,u]=m.useState(!1),f=t.fieldName||"capture",p=t.captureMode==="qr",g=e.apiUrl||window.location.origin,d=t.uploadPath||"/api/files/upload",w=()=>{var H;(H=i.current)==null||H.getTracks().forEach(U=>U.stop()),i.current=null},C=async H=>{var j,D,V;const U=new FormData;U.append("file",H,`${f}-${Date.now()}.jpg`);const q=await fetch(new URL(d,g).toString(),{method:"POST",headers:{Authorization:`Bearer ${localStorage.getItem("token")||""}`},body:U});if(!q.ok)throw new Error("Upload failed");const X=await q.json();return((j=X==null?void 0:X.file)==null?void 0:j.url)||((D=X==null?void 0:X.file)==null?void 0:D.publicUrl)||((V=X==null?void 0:X.file)==null?void 0:V.path)||(X==null?void 0:X.url)||(X==null?void 0:X.path)||""},x=async(H,U)=>{var q,X;if(o!=="done"){w();try{u(!0);const j=U||await C(H);e.setSceneData(D=>({...D,[f]:j})),h(j),l("done"),(q=e.showToast)==null||q.call(e,t.successMessage||(U?"Scanned!":"Captured & uploaded"),"success")}catch{l("error"),(X=e.showToast)==null||X.call(e,"Capture failed","error")}finally{u(!1)}}},k=()=>{var q;const H=s.current;if(!H||!H.videoWidth)return;const U=document.createElement("canvas");U.width=H.videoWidth,U.height=H.videoHeight,(q=U.getContext("2d"))==null||q.drawImage(H,0,0),U.toBlob(X=>X&&x(X),"image/jpeg",t.quality||.85)},S=async()=>{var H,U;try{const q=await navigator.mediaDevices.getUserMedia({video:{facingMode:t.facingMode||"user",...t.aspectRatio?{aspectRatio:Number(t.aspectRatio)}:{}},audio:!1});if(i.current=q,s.current&&(s.current.srcObject=q,await s.current.play().catch(()=>{})),l("running"),p){const j=window.BarcodeDetector;if(!j){l("error"),(H=e.showToast)==null||H.call(e,"QR scanning not supported in this browser","error");return}const D=new j;r.current=window.setInterval(async()=>{const V=s.current;if(!(!V||!V.videoWidth||o==="done"))try{const J=await D.detect(V);J!=null&&J.length&&x(new Blob,J[0].rawValue)}catch{}},400)}}catch{l("error"),(U=e.showToast)==null||U.call(e,"Camera access denied","error")}};m.useEffect(()=>(S(),()=>{r.current&&window.clearInterval(r.current),w()}),[]);const T={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",width:"100%",...t.className?e.parseClassName(t.className):{}},P=e.getCommonProps(n,T,t),I=E("video",{key:"cam-video",ref:s,autoPlay:!0,playsInline:!0,muted:!0,style:{width:"100%",maxWidth:t.maxWidth||"480px",borderRadius:"12px",aspectRatio:t.aspectRatio||"4 / 3",objectFit:"cover",background:"#0f172a",display:p||o!=="done"?void 0:"none"}}),L=c?E("img",{key:"cam-result",src:c,alt:"captured",style:{width:"100%",maxWidth:t.maxWidth||"480px",borderRadius:"12px",aspectRatio:t.aspectRatio||"4 / 3",objectFit:"cover",background:"#0f172a"}}):null,O=E("div",{key:"cam-actions",style:{display:"flex",gap:"10px",flexWrap:"wrap",justifyContent:"center"}},o!=="done"?E("button",{key:"cam-capture",onClick:k,disabled:a||o!=="running",style:{padding:"10px 22px",borderRadius:"9999px",border:"none",cursor:a?"wait":"pointer",background:"#3B82F6",color:"#fff",fontWeight:600}},a?"Uploading...":p?t.captureLabel||"Scan QR":t.captureLabel||"Capture"):E("button",{key:"cam-retake",onClick:()=>{h(""),l("idle"),S()},style:{padding:"10px 22px",borderRadius:"9999px",border:"1px solid #94a3b8",cursor:"pointer",background:"transparent"}},"Retake"));return E("div",{key:n,...P},I,L,t.captureLabel===!1?null:O,o==="error"?E("p",{key:"cam-err",style:{color:"#EF4444",fontSize:"13px"}},"Camera unavailable — check permissions"):null)}function g1(e,t,n){var i;if(t.className){const r=((i=e.parseClassNameResponsive)==null?void 0:i.call(e,t.className,n))??e.parseClassName(t.className),o=e.getCommonProps(n,r,t);return E("div",{key:n,className:t.className,...o})}const s=e.getCommonProps(n,{height:t.h||t.height||"24px"},t);return E("div",{key:n,...s})}function y1(e,t,n){const s=t.className||"border-gray-700 my-4",i=e.parseClassName(s),r=e.getCommonProps(n,i,t);return E("hr",{key:n,className:s,...r})}function b1(e,t,n){var a;const s=t.loaderVariant||"spinner",i=t.rows||3,r=t.className?((a=e.parseClassNameResponsive)==null?void 0:a.call(e,t.className,n))??e.parseClassName(t.className):{};t.rawStyle&&Object.assign(r,t.rawStyle);const o=e.getCommonProps(n,r,t),l=`${e.scopeId}-${n}`,c=e.renderMode==="css-driven"?{"data-bf-r":l}:{};if(s==="skeleton"){const u=[];for(let f=0;f<i;f++){const p=t.width||(f===i-1?"60%":"100%");u.push(E("div",{key:f,className:"bf-loader-skeleton",style:{height:t.height||"16px",width:p,borderRadius:"6px",marginBottom:f<i-1?"12px":"0"}}))}return E("div",{key:n,className:t.className,style:r,...o,...c},...u)}if(s==="shimmer"){const u=[];for(let f=0;f<i;f++){const p=t.width||(f===i-1?"60%":"100%");u.push(E("div",{key:f,className:"bf-loader-shimmer",style:{height:t.height||"16px",width:p,borderRadius:"6px",marginBottom:f<i-1?"12px":"0"}}))}return E("div",{key:n,className:t.className,style:r,...o,...c},...u)}if(s==="dots"){const u=t.color||"currentColor";return E("div",{key:n,className:t.className,style:{display:"flex",alignItems:"center",gap:"6px",...r},...o,...c},[0,1,2].map(f=>E("div",{key:f,className:"bf-loader-dot",style:{width:t.size||"8px",height:t.size||"8px",borderRadius:"50%",backgroundColor:u,animationDelay:`${f*.16}s`}})))}if(s==="pulse")return E("div",{key:n,className:t.className,style:{display:"flex",alignItems:"center",justifyContent:"center",...r},...o,...c},E("div",{className:"bf-loader-pulse",style:{width:t.size||"32px",height:t.size||"32px",borderRadius:"50%",border:`3px solid ${t.color||"currentColor"}`}}));if(s==="progress")return E("div",{key:n,className:t.className,style:{width:"100%",...r},...o,...c},E("div",{style:{height:t.height||"4px",width:"100%",backgroundColor:"rgba(128,128,128,0.2)",borderRadius:"4px",overflow:"hidden"}},E("div",{className:"bf-loader-progress-bar",style:{height:"100%",width:"30%",backgroundColor:t.color||"currentColor",borderRadius:"4px"}})));const h=t.size||"24px";return E("div",{key:n,className:t.className,style:{display:"flex",alignItems:"center",justifyContent:"center",...r},...o,...c},E("div",{className:"bf-loader-spinner",style:{width:h,height:h,border:`3px solid ${t.color?t.color+"33":"rgba(128,128,128,0.2)"}`,borderTopColor:t.color||"currentColor",borderRadius:"50%"}}))}function v1(e,t,n){const s=t.rows||4;if(t.className){const o=e.parseClassName(t.className),l=e.getCommonProps(n,o,t);return E("textarea",{key:n,className:t.className,...l,name:t.name,placeholder:t.placeholder,rows:s})}const i={width:"100%",padding:"0.75rem 1rem",borderRadius:e.cfg.components.inputRadius,backgroundColor:e.cfg.colors.surface,color:e.cfg.colors.text,border:`1px solid ${e.cfg.colors.border}`,outline:"none",transition:e.cfg.effects.transition,resize:"vertical",fontFamily:"inherit"},r=e.getCommonProps(n,i,t);if(t.label){const o=e.getCommonProps(n,{width:"100%"},t);return E("div",{key:n,...o},E("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem"}},t.label),E("textarea",{...r,name:t.name,placeholder:t.placeholder,rows:s}))}return E("textarea",{key:n,...r,name:t.name,placeholder:t.placeholder,rows:s})}function x1(e,t,n){const s=t.icon||t.name||"",i=t.size||24,r=e.renderIcon(s,i);if(t.className){const o=e.parseClassName(t.className),l=e.getCommonProps(n,o,t);return E("span",{key:n,className:t.className,...l},r)}return m.cloneElement(r,{key:n})}function w1(e,t,n){const s=t.metricSize||"md",i=s==="sm"?"1.25rem":s==="lg"?"2.5rem":"1.75rem",r=s==="sm"?"0.75rem":s==="lg"?"1rem":"0.875rem",o=t.color||e.cfg.colors.primary,l=t.trend==="up"?"↑":t.trend==="down"?"↓":"",c=t.trendColor||(t.trend==="up"?e.cfg.colors.success:t.trend==="down"?e.cfg.colors.danger:e.cfg.colors.textMuted),h={display:"flex",flexDirection:"column",gap:"2px",padding:t.padding!==void 0?`${t.padding}px`:"0.75rem",backgroundColor:e.cfg.colors.surface,borderRadius:e.cfg.layout.borderRadiusLg,border:`1px solid ${e.cfg.colors.borderSubtle}`,...t.className?e.parseClassName(t.className):{}},a=e.getCommonProps(n,h,t);return E("div",{key:n,...a},t.label&&E("span",{style:{fontSize:r,color:e.cfg.colors.textSecondary,fontWeight:500}},e.interpolateText(t.label)),m.createElement("div",{style:{display:"flex",alignItems:"baseline",gap:"6px",marginTop:"4px"}},t.prefix&&E("span",{style:{fontSize:i,fontWeight:700,color:o}},t.prefix),E("span",{style:{fontSize:i,fontWeight:700,color:e.cfg.colors.text}},typeof t.value=="number"?t.value.toLocaleString():e.interpolateText(String(t.value??""))),t.suffix&&E("span",{style:{fontSize:i,fontWeight:700,color:o}},t.suffix),t.delta&&E("span",{style:{fontSize:"0.75rem",fontWeight:600,color:c,marginLeft:"4px"}},`${l} ${t.delta}`)))}function S1(e,t,n){const s=t.chartData||t.data||[];if(!Array.isArray(s)||s.length===0)return null;const i=t.height||200,r=t.barColor||e.cfg.colors.primary,o=t.showValues!==!1,l=t.horizontal===!0,c=t.maxValue||Math.max(...s.map(f=>f.value),1),h=l?8:Math.max(4,Math.min(20,300/s.length)),a={width:"100%",padding:t.padding!==void 0?`${t.padding}px`:"0.75rem",backgroundColor:e.cfg.colors.surface,borderRadius:e.cfg.layout.borderRadiusLg,border:`1px solid ${e.cfg.colors.borderSubtle}`,...t.title?{}:{},...t.className?e.parseClassName(t.className):{}},u=e.getCommonProps(n,a,t);return E("div",{key:n,...u},t.title&&E("div",{style:{fontSize:"0.875rem",fontWeight:600,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem",textAlign:"center"}},t.title),E("div",{style:{display:"flex",flexDirection:l?"column":"row",alignItems:l?"stretch":"flex-end",justifyContent:"center",gap:`${h}px`,height:l?void 0:`${i}px`,width:l?"100%":void 0,minHeight:l?void 0:`${i}px`,padding:"4px 0"}},...s.map((f,p)=>{const g=c>0?f.value/c*100:0,d=f.color||r;return l?E("div",{key:p,style:{display:"flex",alignItems:"center",gap:"8px",width:"100%"}},E("span",{style:{fontSize:"0.75rem",color:e.cfg.colors.textSecondary,minWidth:"60px",textAlign:"right",flexShrink:0}},f.label),E("div",{style:{flex:1,height:"20px",backgroundColor:e.cfg.colors.surfaceHover,borderRadius:"4px",overflow:"hidden",position:"relative"}},E("div",{style:{width:`${g}%`,height:"100%",backgroundColor:d,borderRadius:"4px",transition:"width 0.5s ease"}})),o&&E("span",{style:{fontSize:"0.7rem",color:e.cfg.colors.textMuted,minWidth:"32px",fontVariantNumeric:"tabular-nums"}},typeof f.value=="number"?f.value.toLocaleString():String(f.value))):E("div",{key:p,style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-end",flex:1,height:"100%",maxWidth:"60px"}},o&&E("span",{style:{fontSize:"0.65rem",color:e.cfg.colors.textMuted,marginBottom:"2px",fontVariantNumeric:"tabular-nums"}},typeof f.value=="number"?f.value.toLocaleString():String(f.value)),E("div",{style:{width:"100%",height:`${g}%`,backgroundColor:d,borderRadius:"4px 4px 0 0",transition:"height 0.5s ease",minHeight:g>0?"4px":"0px"}}),E("span",{style:{fontSize:"0.65rem",color:e.cfg.colors.textSecondary,marginTop:"4px",textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%"}},f.label))})))}function Go(e,t,n,s=!1,i=!1){const r=Array.isArray(t.chartData)?t.chartData:[];if(r.length===0)return null;const o=r.flatMap(k=>i?[k.low,k.high]:[k.value]).map(Number).filter(Number.isFinite);if(o.length===0)return null;const l=Math.min(...o),h=Math.max(...o)-l||1,a=Number(t.height)||220,u=640,f=k=>r.length===1?u/2:k/(r.length-1)*u,p=k=>a-(k-l)/h*a,g=r.map((k,S)=>`${f(S)},${p(Number(k.value))}`).join(" "),d=t.lineColor||e.cfg.colors.accent,w=t.fillColor||`${d}33`,C={width:"100%",padding:"0.75rem",backgroundColor:e.cfg.colors.surface,borderRadius:e.cfg.layout.borderRadiusLg,border:`1px solid ${e.cfg.colors.borderSubtle}`,...t.className?e.parseClassName(t.className):{}},x=i?r.map((k,S)=>{const T=Number(k.open),P=Number(k.close),I=Number(k.high),L=Number(k.low),O=P>=T;return E("div",{key:S,style:{flex:1,height:"100%",position:"relative"}},E("div",{style:{position:"absolute",left:"50%",top:`${p(I)}px`,height:`${Math.max(1,p(L)-p(I))}px`,borderLeft:`1px solid ${O?"#22c55e":"#ef4444"}`}}),E("div",{style:{position:"absolute",left:"25%",right:"25%",top:`${p(Math.max(T,P))}px`,height:`${Math.max(3,Math.abs(p(P)-p(T)))}px`,background:O?"#22c55e":"#ef4444",borderRadius:"2px"}}))}):m.createElement("svg",{viewBox:`0 0 ${u} ${a}`,preserveAspectRatio:"none",style:{width:"100%",height:a}},t.showGrid!==!1&&[25,50,75].map(k=>m.createElement("line",{key:k,x1:0,x2:u,y1:a*k/100,y2:a*k/100,stroke:e.cfg.colors.borderSubtle,strokeDasharray:"3 4"})),s&&m.createElement("polygon",{points:`0,${a} ${g} ${u},${a}`,fill:w}),m.createElement("polyline",{points:g,fill:"none",stroke:d,strokeWidth:3,strokeLinecap:"round",strokeLinejoin:"round"}));return E("div",{key:n,style:e.getCommonProps(n,C,t)},t.title&&E("div",{style:{color:e.cfg.colors.textSecondary,fontWeight:600,marginBottom:"0.75rem"}},t.title),E("div",{style:{display:"flex",alignItems:"stretch",gap:i?"4px":void 0,height:a}},x),E("div",{style:{display:"flex",justifyContent:"space-between",color:e.cfg.colors.textMuted,fontSize:"0.7rem",marginTop:"4px"}},...r.map((k,S)=>E("span",{key:S},k.label||""))))}function C1(e,t,n){const s=Array.isArray(t.chartData)?t.chartData[0]||{}:{},i=t.ticker||s.ticker||s.symbol||"EUR/USD",r=t.bid??s.bid??s.price,o=t.ask??s.ask,l=t.change??s.change,c=Number(l),h=Number.isFinite(c)&&c>=0,a=e.getCommonProps(n,{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"1rem",width:"100%",padding:"0.9rem 1rem",backgroundColor:e.cfg.colors.surface,border:`1px solid ${e.cfg.colors.borderSubtle}`,borderRadius:e.cfg.layout.borderRadiusLg,...t.className?e.parseClassName(t.className):{}},t);return E("div",{key:n,...a},E("div",{},E("div",{style:{color:e.cfg.colors.text,fontWeight:700}},i),t.label&&E("div",{style:{color:e.cfg.colors.textMuted,fontSize:"0.75rem"}},t.label)),E("div",{style:{display:"flex",gap:"1rem",alignItems:"baseline",fontVariantNumeric:"tabular-nums"}},r!=null&&E("span",{style:{color:e.cfg.colors.text,fontWeight:700}},String(r)),o!=null&&E("span",{style:{color:e.cfg.colors.textSecondary}},String(o)),l!=null&&E("span",{style:{color:h?"#22c55e":"#ef4444",fontSize:"0.8rem",fontWeight:600}},`${h?"+":""}${l}`)))}function k1({api:e,c:t,componentKey:n}){var w,C,x,k;const s=m.useRef(null),i=m.useRef(null),r=m.useRef(null),[o,l]=m.useState(null),c=m.useRef(null),[h,a]=m.useState(()=>Array.isArray(t.chartData)?t.chartData:[]);m.useEffect(()=>{Array.isArray(t.chartData)&&a(t.chartData)},[t.chartData]);const u=e.interpolateText(((w=t.realtime)==null?void 0:w.channel)||""),f=e.interpolateText(((C=t.timeRange)==null?void 0:C.from)||""),p=e.interpolateText(((x=t.timeRange)==null?void 0:x.to)||""),g=Array.isArray(t.timeframes)?t.timeframes:[];m.useEffect(()=>{var I,L;const S=e.sdk;if(!(((I=t.realtime)==null?void 0:I.mode)==="ws"&&e.isAuthenticated&&u&&((L=S==null?void 0:S.client)==null?void 0:L.createWebSocket)))return;const P=S.client.createWebSocket(u);return P.onmessage=O=>{var H;try{const U=typeof O.data=="string"?JSON.parse(O.data):O.data,q=(U==null?void 0:U.tick)||((H=U==null?void 0:U.data)==null?void 0:H.tick)||(U==null?void 0:U.data)||U,X=Number((q==null?void 0:q.quote)??(q==null?void 0:q.price)??(q==null?void 0:q.close));if(!Number.isFinite(X))return;const j=Number((q==null?void 0:q.epoch)??(q==null?void 0:q.timestamp)??Date.now()/1e3),D=Math.floor(j/60)*60;a(V=>{const J=V[V.length-1];if((J==null?void 0:J.time)===D)return[...V.slice(0,-1),{...J,high:Math.max(Number(J.high),X),low:Math.min(Number(J.low),X),close:X}];const nt=Number((J==null?void 0:J.close)??X);return[...V.slice(-99),{time:D,open:nt,high:X,low:X,close:X}]})}catch{}},()=>{var O;return(O=P.close)==null?void 0:O.call(P)}},[e.isAuthenticated,(k=t.realtime)==null?void 0:k.mode,u]);const d=m.useMemo(()=>h.map((S,T)=>{const P=S.time||S.timestamp;return{time:typeof P=="string"&&P.includes("T")?Math.floor(new Date(P).getTime()/1e3):P||`2024-01-${String(T+1).padStart(2,"0")}`,...t.chartType==="candlestick"?{open:Number(S.open),high:Number(S.high),low:Number(S.low),close:Number(S.close)}:{value:Number(S.value??S.close)}}}),[t.chartType,h]);return c.current=d[d.length-1],m.useEffect(()=>{const S=s.current;if(!S)return;const T=Pw(S,{autoSize:!0,height:Number(t.height)||280,layout:{background:{color:"transparent"},textColor:e.cfg.colors.textSecondary},grid:{vertLines:{color:e.cfg.colors.borderSubtle},horzLines:{color:e.cfg.colors.borderSubtle}},rightPriceScale:{borderColor:e.cfg.colors.borderSubtle},timeScale:{borderColor:e.cfg.colors.borderSubtle,timeVisible:!0}}),P=t.chartType||"candlestick",I=P==="line"?T.addSeries(zw,{color:t.lineColor||e.cfg.colors.accent}):P==="area"?T.addSeries(Hw,{lineColor:t.lineColor||e.cfg.colors.accent,topColor:t.fillColor||`${e.cfg.colors.accent}66`,bottomColor:"transparent"}):T.addSeries(Xw,{upColor:"#22c55e",downColor:"#ef4444",borderVisible:!1,wickUpColor:"#22c55e",wickDownColor:"#ef4444"});return r.current=T,i.current=I,()=>{i.current=null,r.current=null,T.remove()}},[e.cfg.colors.accent,e.cfg.colors.borderSubtle,e.cfg.colors.textSecondary,t.chartType,t.height,t.lineColor,t.fillColor]),m.useEffect(()=>{var S,T;!i.current||d.length===0||(i.current.setData(d),f&&p?(S=r.current)==null||S.timeScale().setVisibleRange({from:f,to:p}):(T=r.current)!=null&&T.timeScale().getVisibleLogicalRange()||r.current.timeScale().fitContent())},[d,f,p]),m.useEffect(()=>{if(!o||!r.current||!c.current)return;const S={"1H":3600,"4H":14400,"1D":86400,"1W":604800}[o],T=Number(c.current.time);S&&Number.isFinite(T)&&r.current.timeScale().setVisibleRange({from:T-S,to:T})},[o]),E("div",{key:n,style:{width:"100%",padding:"0.75rem",backgroundColor:e.cfg.colors.surface,borderRadius:e.cfg.layout.borderRadiusLg,border:`1px solid ${e.cfg.colors.borderSubtle}`,...t.className?e.parseClassName(t.className):{}}},g.length>0&&E("div",{style:{display:"flex",gap:"0.35rem",marginBottom:"0.5rem"}},...g.map(S=>E("button",{key:S,type:"button",onClick:()=>l(S),style:{padding:"0.3rem 0.6rem",border:`1px solid ${e.cfg.colors.borderSubtle}`,borderRadius:4,color:e.cfg.colors.text,background:o===S?e.cfg.colors.surfaceHover:"transparent",cursor:"pointer"}},S))),E("div",{ref:s,style:{width:"100%",height:Number(t.height)||280}}))}function M1(e,t,n){return m.createElement(k1,{api:e,c:t,componentKey:n})}function E1(e,t,n){const s=t.json||t.data||t.diagram||{},i=e.getCommonProps(n,{display:"flex",flexDirection:"column",minHeight:"300px"},t);return E("div",{key:n,className:t.className,...i},m.createElement("pre",{style:{fontSize:"12px",whiteSpace:"pre-wrap",margin:0}},typeof s=="string"?s:JSON.stringify(s,null,2)))}function T1({api:e,c:t,componentKey:n}){const s=t.data||t.json||t.diagram||{},{_config:i,...r}=s||{},o=Object.keys(r).length?r:s,{nodes:l,edges:c}=m.useMemo(()=>dc.createFlowDiagram(o),[o]),[h,a]=m.useState("LR"),u=e.cfg.fullscreen===!0,f=t.height||(u?"100%":320),p=e.getCommonProps(n,{width:"100%",height:f,...u?{minHeight:0}:{}},t);return E("div",{key:n,className:t.className,...p},m.createElement(dc.FlowDiagram,{nodes:l,edges:c,config:{direction:h,layout:(i==null?void 0:i.layout)||"dagre",colorMode:(i==null?void 0:i.colorMode)||(e.cfg.colorMode==="dark"?"dark":"light"),backgroundPattern:(i==null?void 0:i.backgroundPattern)||"dot"},callbacks:{onDirectionChange:g=>a(g)},showBottomBar:(i==null?void 0:i.showBottomBar)||!1,style:{width:"100%",height:"100%"}}))}function A1(e,t,n){return m.createElement(T1,{api:e,c:t,componentKey:n})}function R1(e,t,n){var s;if(t.className){const i=((s=e.parseClassNameResponsive)==null?void 0:s.call(e,t.className,n))??e.parseClassName(t.className);i.display==null&&(i.display="flex"),i.flexDirection==null&&(i.flexDirection=/(^|\s)flex(\s|$)/.test(t.className||"")||t.layout==="row"?"row":"column");const r=e.getCommonProps(n,i,t);return m.createElement("div",{key:n,className:t.className,...r},(Array.isArray(t.children)?t.children:[]).map((o,l)=>e.renderComponent(o,l,n)))}return null}const P1=m.memo(({api:e,field:t,fieldName:n,value:s,onChange:i})=>{m.useEffect(()=>{s!==void 0&&s!==""&&i&&i(s)},[]);const r=m.useRef(null),[o,l]=m.useState(!1),c=m.useRef(null),h=m.useRef(null),[a,u]=m.useState(!1),[f,p]=m.useState(""),[g,d]=m.useState(!1),w=t.html!==!1,C=x=>w?x:x.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/\n/g,"<br>");return m.useEffect(()=>{r.current&&!r.current.innerHTML&&(r.current.innerHTML=C(s))},[]),m.useEffect(()=>{r.current&&document.activeElement!==r.current&&r.current.innerHTML!==s&&(r.current.innerHTML=C(s))},[s]),m.createElement("div",{style:{width:"100%",marginBottom:"1rem"}},t.label?E("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem"}},t.label):null,m.createElement("div",{style:{border:`1px solid ${o?e.cfg.colors.primary:e.cfg.colors.border}`,borderRadius:e.cfg.components.inputRadius,overflow:"hidden",transition:"border-color 0.2s",position:"relative"}},m.createElement("div",{style:{display:"flex",gap:"4px",padding:"6px 8px",borderBottom:`1px solid ${e.cfg.colors.border}`,backgroundColor:e.cfg.colors.surface}},...[{cmd:"bold",label:"B"},{cmd:"italic",label:"I"},{cmd:"underline",label:"U"}].map(x=>E("button",{key:x.cmd,type:"button",onMouseDown:k=>{var S;k.preventDefault(),document.execCommand(x.cmd,!1),(S=r.current)==null||S.focus()},style:{padding:"2px 8px",borderRadius:"4px",border:"1px solid transparent",cursor:"pointer",backgroundColor:"transparent",color:e.cfg.colors.text,fontWeight:600,fontSize:"13px"},onMouseEnter:k=>k.target.style.borderColor=e.cfg.colors.border,onMouseLeave:k=>k.target.style.borderColor="transparent"},x.label)),E("span",{key:"spacer",style:{flex:1}}),E("button",{key:"list-btn",type:"button",onMouseDown:x=>{var k;x.preventDefault(),document.execCommand("insertUnorderedList",!1),(k=r.current)==null||k.focus()},style:{padding:"2px 8px",borderRadius:"4px",border:"1px solid transparent",cursor:"pointer",backgroundColor:"transparent",color:e.cfg.colors.text,fontSize:"13px"},onMouseEnter:x=>x.target.style.borderColor=e.cfg.colors.border,onMouseLeave:x=>x.target.style.borderColor="transparent"},"☰"),E("span",{key:"divider",style:{width:"1px",height:"16px",backgroundColor:e.cfg.colors.border,margin:"0 4px",alignSelf:"center"}}),E("button",{key:"img-btn",type:"button",onMouseDown:x=>{var k;x.preventDefault(),(k=c.current)==null||k.click()},style:{padding:"2px 6px",borderRadius:"4px",border:"1px solid transparent",cursor:"pointer",backgroundColor:"transparent",color:e.cfg.colors.text,fontSize:"13px",display:"inline-flex",alignItems:"center",justifyContent:"center"},onMouseEnter:x=>x.target.style.borderColor=e.cfg.colors.border,onMouseLeave:x=>x.target.style.borderColor="transparent"},e.renderIcon("image",14)),E("button",{key:"att-btn",type:"button",onMouseDown:x=>{var k;x.preventDefault(),(k=h.current)==null||k.click()},style:{padding:"2px 6px",borderRadius:"4px",border:"1px solid transparent",cursor:"pointer",backgroundColor:"transparent",color:e.cfg.colors.text,fontSize:"13px",display:"inline-flex",alignItems:"center",justifyContent:"center"},onMouseEnter:x=>x.target.style.borderColor=e.cfg.colors.border,onMouseLeave:x=>x.target.style.borderColor="transparent"},e.renderIcon("paperclip",14)),E("button",{key:"ai-btn",type:"button",onMouseDown:x=>{x.preventDefault(),u(!a)},style:{padding:"2px 6px",borderRadius:"4px",border:"1px solid transparent",cursor:"pointer",backgroundColor:a?e.cfg.colors.border:"transparent",color:e.cfg.colors.text,fontSize:"13px",display:"inline-flex",alignItems:"center",justifyContent:"center"},onMouseEnter:x=>x.target.style.borderColor=e.cfg.colors.border,onMouseLeave:x=>x.target.style.borderColor="transparent"},e.renderIcon("sparkles",14))),E("div",{ref:r,contentEditable:!0,suppressContentEditableWarning:!0,onInput:x=>i(x.currentTarget.innerHTML),onFocus:()=>l(!0),onBlur:()=>l(!1),style:{minHeight:(t.rows||10)*20+"px",padding:"0.75rem 1rem",backgroundColor:e.cfg.colors.surface,color:e.cfg.colors.text,outline:"none",fontSize:"0.875rem",lineHeight:"1.6"}}),t.expandAction?m.createElement("button",{type:"button",key:"expand",style:{position:"absolute",bottom:"6px",left:"6px",background:"rgba(0,0,0,0.55)",border:`1px solid ${e.cfg.colors.border}`,borderRadius:"4px",cursor:"pointer",color:e.cfg.colors.textMuted,padding:"3px 5px",display:"flex",alignItems:"center",justifyContent:"center",opacity:.5,transition:"opacity 0.2s",zIndex:1},onMouseEnter:x=>{x.currentTarget.style.opacity="0.85"},onMouseLeave:x=>{x.currentTarget.style.opacity="0.5"},onClick:x=>{x.preventDefault(),x.stopPropagation(),e.handleButtonClick(t.expandAction,{})}},e.renderIcon("maximize-2",13)):null,E("input",{key:"img-input",ref:c,type:"file",accept:"image/*",style:{display:"none"},onChange:async x=>{var S,T,P,I,L,O;const k=(S=x.target.files)==null?void 0:S[0];if(k){try{const H=(T=e.showToast)==null?void 0:T.call(e,"Uploading image (0%)…","success",0),U=e.uploadFile?await e.uploadFile(k,t.upload,q=>{var X;return(X=H==null?void 0:H.update)==null?void 0:X.call(H,`Uploading image (${q}%)`)}):"";if((P=H==null?void 0:H.dismiss)==null||P.call(H),!U)throw Error();(I=r.current)==null||I.focus(),document.execCommand("insertImage",!1,U),i(((L=r.current)==null?void 0:L.innerHTML)||"")}catch{(O=e.showToast)==null||O.call(e,"Failed to upload image","error")}x.target.value=""}}}),E("input",{key:"att-input",ref:h,type:"file",multiple:!0,style:{display:"none"},onChange:async x=>{var I,L,O,H,U;const k=Array.from(x.target.files||[]);x.target.value="";const S=[];let T=0;const P=(I=e.showToast)==null?void 0:I.call(e,`Uploading 0/${k.length}…`,"success",0);for(const q of k){try{const X=e.uploadFile?await e.uploadFile(q,t.upload,j=>{var D;return(D=P==null?void 0:P.update)==null?void 0:D.call(P,`Uploading ${q.name} (${j}%)`)}):"";if(!X)throw Error();S.push(`<a href="${X}">${q.name}</a>`)}catch{(L=e.showToast)==null||L.call(e,`Failed to upload ${q.name}`,"error")}T++,(O=P==null?void 0:P.update)==null||O.call(P,`Uploading ${T}/${k.length}…`)}if((H=P==null?void 0:P.dismiss)==null||H.call(P),S.length>0&&r.current){r.current.focus();const q=window.getSelection();if(q){q.removeAllRanges();const X=document.createRange();X.selectNodeContents(r.current),X.collapse(!1),q.addRange(X)}document.execCommand("insertHTML",!1,`<br><br>${S.join(", ")}`),i(((U=r.current)==null?void 0:U.innerHTML)||"")}}}),a?E("div",{key:"ai-popup",style:{position:"absolute",bottom:"100%",left:"8px",right:"8px",backgroundColor:e.cfg.colors.surfaceHover,border:`1px solid ${e.cfg.colors.borderSubtle}`,borderRadius:"8px",padding:"12px",zIndex:10,boxShadow:"0 -4px 24px rgba(0,0,0,0.4)"}},E("textarea",{value:f,onChange:x=>p(x.target.value),placeholder:"Ask AI to draft a reply...",rows:3,style:{width:"100%",padding:"8px 12px",borderRadius:"4px",border:`1px solid ${e.cfg.colors.borderSubtle}`,backgroundColor:e.cfg.colors.surface,color:e.cfg.colors.text,fontSize:"13px",outline:"none",fontFamily:"inherit",resize:"none",boxSizing:"border-box"}}),E("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end",marginTop:"8px"}},E("button",{type:"button",onClick:()=>{u(!1),p("")},style:{padding:"6px 14px",borderRadius:"6px",border:`1px solid ${e.cfg.colors.borderSubtle}`,cursor:"pointer",backgroundColor:"transparent",color:e.cfg.colors.textMuted,fontSize:"12px",fontFamily:"inherit"}},"Cancel"),E("button",{type:"button",disabled:g||!f.trim(),onClick:async()=>{var x,k,S,T;if(!(!f.trim()||g)){d(!0);try{const P=((x=r.current)==null?void 0:x.innerHTML)||"",I=await fetch("/api/tenant/email/ai/complete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:f,context:P})});if(!I.ok)throw Error();const L=await I.json(),O=L.response||L.text||L.content||"";(k=r.current)==null||k.focus(),document.execCommand("insertText",!1,O),i(((S=r.current)==null?void 0:S.innerHTML)||""),u(!1),p("")}catch{(T=e.showToast)==null||T.call(e,"AI request failed","error")}d(!1)}},style:{padding:"6px 14px",borderRadius:"6px",border:"none",cursor:g||!f.trim()?"not-allowed":"pointer",backgroundColor:g||!f.trim()?e.cfg.colors.surfaceHover:e.cfg.colors.background,color:g||!f.trim()?e.cfg.colors.textSecondary:e.cfg.colors.text,fontSize:"12px",fontWeight:600,fontFamily:"inherit"}},g?"Thinking...":"Generate"))):null))}),_1=m.memo(({api:e,c:t,componentKey:n})=>{const[s,i]=m.useState(!1),r=m.useRef(null),[o,l]=m.useState([]),c=t.name?`bf_persist_${t.name}`:null;m.useEffect(()=>{t.dataSource&&(async()=>{var u;try{const f=e.interpolateText(t.dataSource),p=(u=e.selectDynamicOptions)==null?void 0:u[f];if(p&&p.length>0){l(p);return}En[f]||(En[f]=(async()=>{var d;try{const w=await fetch(f,{headers:{Authorization:`Bearer ${localStorage.getItem("token")||""}`}});if(!w.ok)return[];const C=await w.json(),x=t.dataField||"configs",k=t.optionLabel||"label",S=t.optionValue||"value",T=C[x]||C.data||C,P=Array.isArray(T)?T.map(I=>({label:I[k]||I.name||I.label,value:I[S]||I.id||I.name||I.label})):[];return(d=e.setSelectDynamicOptions)==null||d.call(e,I=>({...I,[f]:P})),P}catch{return delete En[f],[]}})());const g=await En[f];g.length>0&&l(g)}catch{}})()},[t.dataSource]),m.useEffect(()=>{if(c&&t.name&&!e.sceneData[t.name]){const f=localStorage.getItem(c);f&&e.setSceneData(p=>({...p,[t.name]:f}))}},[c,t.name,e.sceneData[t.name]]),m.useEffect(()=>{if(!s)return;const u=p=>{r.current&&!r.current.contains(p.target)&&i(!1)},f=setTimeout(()=>{document.addEventListener("mousedown",u)},0);return()=>{clearTimeout(f),document.removeEventListener("mousedown",u)}},[s]);const h=t.variant==="selector",a=Array.isArray(t.items)?t.items:o;if(h){const u=t.name&&(e.sceneData[t.name||""]||c&&localStorage.getItem(c))||"",f=u||t.placeholder||"Select...";return E("div",{ref:r,style:{position:"relative",display:"inline-flex"}},m.createElement("button",{type:"button",style:{display:"inline-flex",alignItems:"center",gap:"6px",background:"none",border:"none",cursor:"pointer",fontFamily:"inherit",fontSize:t.fontSize||"1rem",fontWeight:t.fontWeight||600,color:t.color||e.cfg.colors.text,padding:"2px 0",outline:"none",lineHeight:"1.5"},onClick:p=>{p.preventDefault(),i(!s)}},E("span",{key:"text"},f),E("span",{key:"caret",style:{display:"flex",alignItems:"center",opacity:.6,marginLeft:"2px"}},e.renderIcon("chevron-down",14))),s?m.createElement("div",{style:{position:"absolute",top:"100%",left:"0",marginTop:"4px",backgroundColor:e.cfg.colors.surfaceHover,border:`1px solid ${e.cfg.colors.borderSubtle}`,borderRadius:"8px",boxShadow:"0 8px 24px rgba(0,0,0,0.4)",zIndex:9999,overflow:"hidden",minWidth:"200px"}},...a.map((p,g)=>m.createElement("button",{key:g,type:"button",style:{display:"flex",alignItems:"center",gap:"8px",width:"100%",padding:"10px 16px",backgroundColor:"transparent",color:e.cfg.colors.text,border:"none",cursor:"pointer",fontSize:"14px",textAlign:"left",fontFamily:"inherit",transition:"background-color 0.15s ease",outline:"none",whiteSpace:"nowrap"},onMouseEnter:d=>{d.currentTarget.style.backgroundColor=e.cfg.colors.borderSubtle},onMouseLeave:d=>{d.currentTarget.style.backgroundColor="transparent"},onClick:d=>{d.preventDefault(),d.stopPropagation(),i(!1),t.name&&p.value!==u&&e.setSceneData(w=>({...w,[t.name]:p.value}))}},p.label||""))):null)}return m.createElement("div",{ref:r,style:{position:"relative",display:"flex",width:"100%"}},(()=>{var p;const u=!!((p=e.buttonLoading)!=null&&p[n]),f=[];return u?f.push(E("span",{key:"spinner",className:"bf-btn-spinner",style:{width:"14px",height:"14px",border:"2px solid currentColor",borderTopColor:"transparent",borderRadius:"50%",flexShrink:0}})):t.icon&&f.push(E("span",{key:"icon",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginRight:"6px"}},e.renderIcon(t.icon,t.iconSize||16))),f.push(E("span",{key:"text",style:{lineHeight:"1"}},t.text||"Button")),m.createElement("button",{type:"button",style:{flex:1,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"0.75rem 1.5rem",backgroundColor:e.cfg.colorMode==="light"?e.cfg.colors.primary:"transparent",color:e.cfg.colorMode==="light"?"#ffffff":e.cfg.colors.textSecondary,border:`1px solid ${e.cfg.colors.border}`,cursor:"pointer",fontSize:"0.875rem",fontWeight:600,fontFamily:"inherit",lineHeight:"1.25rem",transition:"all 0.15s ease",outline:"none"},onMouseEnter:g=>{g.currentTarget.style.backgroundColor=e.cfg.colors.border,g.currentTarget.style.color=e.cfg.colorMode==="light"?"#111827":e.cfg.colors.text},onMouseLeave:g=>{g.currentTarget.style.backgroundColor=e.cfg.colorMode==="light"?e.cfg.colors.primary:"transparent",g.currentTarget.style.color=e.cfg.colorMode==="light"?"#ffffff":e.cfg.colors.textSecondary},onClick:g=>{if(g.preventDefault(),a.length>0&&a[0].onClick){const d=()=>e.handleButtonClick(a[0].onClick,{onSuccess:a[0].onSuccess,onError:a[0].onError},{feedback:a[0].feedback,optimistic:a[0].optimistic,payload:a[0].payload});(e.withLoading?e.withLoading(n,d):d()).catch(()=>{})}}},...f)})(),a.length>0?m.createElement("button",{type:"button",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"0.75rem 0.5rem",backgroundColor:"transparent",color:e.cfg.colors.textSecondary,border:`1px solid ${e.cfg.colors.border}`,borderLeft:`1px solid ${e.cfg.colors.border}`,cursor:"pointer",fontFamily:"inherit",transition:"all 0.15s ease",outline:"none"},onMouseEnter:u=>{u.currentTarget.style.backgroundColor=e.cfg.colors.border,u.currentTarget.style.color=e.cfg.colors.text},onMouseLeave:u=>{u.currentTarget.style.backgroundColor="transparent",u.currentTarget.style.color=e.cfg.colors.textSecondary},onClick:u=>{u.preventDefault(),u.stopPropagation(),i(!s)}},e.renderIcon("chevron-down",16)):null,s?m.createElement("div",{style:{position:"absolute",bottom:"100%",left:"0",right:"0",marginBottom:"4px",backgroundColor:e.cfg.colors.surfaceHover,border:`1px solid ${e.cfg.colors.borderSubtle}`,borderRadius:"8px",boxShadow:"0 -8px 24px rgba(0,0,0,0.4)",zIndex:9999,overflow:"hidden"}},...a.map((u,f)=>{var w;const p=`${n}-item-${f}`,g=!!((w=e.buttonLoading)!=null&&w[p]),d=[];return g?d.push(E("span",{key:"spinner",className:"bf-btn-spinner",style:{width:"12px",height:"12px",border:"2px solid currentColor",borderTopColor:"transparent",borderRadius:"50%",flexShrink:0}})):u.icon&&d.push(E("span",{key:"icon",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginRight:"8px"}},e.renderIcon(u.icon,14))),d.push(u.label||""),m.createElement("button",{key:f,type:"button",style:{display:"flex",alignItems:"center",gap:"8px",width:"100%",padding:"10px 16px",backgroundColor:"transparent",color:e.cfg.colors.text,border:"none",cursor:"pointer",fontSize:"14px",textAlign:"left",fontFamily:"inherit",transition:"background-color 0.15s ease",outline:"none"},onMouseEnter:C=>{C.currentTarget.style.backgroundColor=e.cfg.colors.borderSubtle},onMouseLeave:C=>{C.currentTarget.style.backgroundColor="transparent"},onClick:C=>{if(C.preventDefault(),C.stopPropagation(),!u.onClick)return;const x=u.loading==="self"?p:n;u.loading==="self"?i(!0):i(!1);const k=()=>e.handleButtonClick(u.onClick,{onSuccess:u.onSuccess,onError:u.onError},{feedback:u.feedback,optimistic:u.optimistic,payload:u.payload});(e.withLoading?e.withLoading(x,k):k()).finally(()=>{u.loading==="self"&&i(!1)}).catch(()=>{})}},...d)})):null)});function $1(e,t,n){return m.createElement(_1,{api:e,c:t,componentKey:n})}function N1(e,t,n){var c,h;const s=t.widgetId;if(!s)return null;const r=(e.widgets||[]).find(a=>a.id===s);if(!r||!Array.isArray(r.components))return Br(`[renderer] widget "${s}" not found`),null;if(e.widgetStack&&e.widgetStack.includes(s))return Br(`[renderer] circular widget reference "${s}"`),null;(c=e.widgetStack)==null||c.push(s);const o=t.props||{},l=Ea(r.components,o).map((a,u)=>e.renderComponent(a,u,`${n}-${s}`));return(h=e.widgetStack)==null||h.pop(),m.createElement(m.Fragment,null,...l)}function Ea(e,t){if(!t||Object.keys(t).length===0)return e;if(Array.isArray(e))return e.map(n=>Ea(n,t));if(e&&typeof e=="object"){const n={};for(const[s,i]of Object.entries(e))typeof i=="string"&&i.includes("{{")?n[s]=i.replace(/\{\{\s*props\.([\w.]+)\s*\}\}/g,(r,o)=>{let l=t;for(const c of o.split("."))l=l==null?void 0:l[c];return l==null?"":String(l)}):n[s]=Ea(i,t);return n}return e}const cm=m.memo(({api:e,c:t,componentKey:n})=>{const[s,i]=m.useState(!1),[r,o]=m.useState(""),l=m.useRef(null),c=m.useMemo(()=>(Array.isArray(t.options)?t.options:[]).map(d=>typeof d=="string"?{label:d,value:d}:{label:d.label||d.value,value:d.value||d.label}),[t.options]),h=e.sceneData[t.name||""]??"",a=c.find(g=>g.value===h),u=m.useMemo(()=>{if(!r)return c;const g=r.toLowerCase();return c.filter(d=>d.label.toLowerCase().includes(g))},[c,r]),f=t.custom&&r&&!c.find(g=>g.value===r||g.label===r);m.useEffect(()=>{if(!s){o("");return}const g=d=>{l.current&&!l.current.contains(d.target)&&i(!1)};return setTimeout(()=>document.addEventListener("mousedown",g),0),()=>document.removeEventListener("mousedown",g)},[s]);const p=g=>{e.setSceneData(d=>({...d,[t.name||""]:g})),i(!1)};return E("div",{key:n,ref:l,style:{position:"relative",width:"100%"}},t.label&&E("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem"}},t.label),E("button",{style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 8px",borderRadius:"6px",border:"1px solid",borderColor:e.cfg.colors.border,background:"transparent",color:e.cfg.colors.text,cursor:"pointer",fontSize:"14px",textAlign:"left",gap:"8px"},onClick:()=>i(!s)},E("span",null,a?a.label:t.placeholder||"Select..."),E("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2"},E("path",{d:"m6 9 6 6 6-6"}))),s&&E("div",{style:{position:"absolute",top:"100%",left:0,right:0,zIndex:50,marginTop:"4px",borderRadius:"6px",border:"1px solid",borderColor:e.cfg.colors.border,background:e.cfg.colors.surface,overflow:"hidden",maxHeight:"260px",display:"flex",flexDirection:"column"}},t.searchable!==!1&&E("input",{style:{width:"100%",padding:"8px",border:"none",borderBottom:"1px solid",borderColor:e.cfg.colors.borderSubtle,background:"transparent",color:e.cfg.colors.text,outline:"none",fontSize:"13px"},placeholder:"Search...",value:r,onChange:g=>{o(g.target.value),g.stopPropagation()},onClick:g=>g.stopPropagation()}),E("div",{style:{overflow:"auto",flex:1}},u.map(g=>E("button",{key:g.value,style:{width:"100%",display:"block",textAlign:"left",padding:"8px",border:"none",background:g.value===h?"rgba(59,130,246,0.2)":"transparent",color:g.value===h?e.cfg.colors.primary:e.cfg.colors.text,cursor:"pointer",fontSize:"13px"},onMouseEnter:d=>{d.currentTarget.style.background=e.cfg.colors.surfaceHover},onMouseLeave:d=>{d.currentTarget.style.background=g.value===h?"rgba(59,130,246,0.2)":"transparent"},onClick:()=>p(g.value)},g.label)),f&&E("button",{style:{width:"100%",display:"block",textAlign:"left",padding:"8px",border:"none",borderTop:"1px solid",borderColor:e.cfg.colors.borderSubtle,background:"transparent",color:e.cfg.colors.primary,cursor:"pointer",fontSize:"13px",fontStyle:"italic"},onClick:()=>p(r)},`+ Add "${r}"`))))});function I1(e,t,n){return m.createElement(cm,{api:e,c:t,componentKey:n})}const En={},D1=m.memo(({api:e,field:t,fieldName:n,fieldKey:s,fieldStyle:i,fieldWrapperStyle:r})=>{const[o,l]=m.useState([]);m.useEffect(()=>{t.dataSource&&(async()=>{var a;try{const u=e.interpolateText(t.dataSource),f=(a=e.selectDynamicOptions)==null?void 0:a[u];if(f&&f.length>0){l(f);return}En[u]||(En[u]=(async()=>{var g;try{const d=await fetch(u,{headers:{Authorization:`Bearer ${localStorage.getItem("token")||""}`}});if(!d.ok)return[];const w=await d.json(),C=t.dataField||"configs",x=t.optionLabel||"label",k=t.optionValue||"value",S=w[C]||w.data||w,T=Array.isArray(S)?S.map(P=>({label:P[x]||P.name||P.label,value:P[k]||P.id||P.name||P.label})):[];return(g=e.setSelectDynamicOptions)==null||g.call(e,P=>({...P,[u]:T})),T}catch{return delete En[u],[]}})());const p=await En[u];p.length>0&&l(p)}catch{}})()},[t.dataSource]);const c=o.length>0?o:Array.isArray(t.options)?t.options:[],h=t.placeholder||t.label||"Select...";return m.createElement("div",{key:s,style:r||{width:"100%"}},t.label?E("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem"}},t.label):null,E("select",{name:n,value:e.sceneData[n]??"",required:t.required,className:t.className,style:{...i,fontSize:"0.875rem"},size:"md",onChange:a=>e.setSceneData(u=>({...u,[n]:a.target.value}))},E("option",{key:"__placeholder",value:"",disabled:!0,hidden:!0},h),c.map((a,u)=>E("option",{key:u,value:typeof a=="string"?a:a.value},typeof a=="string"?a:a.label))))});function L1(e,t,n){var c;const s=t.className||"",i=((c=e.parseClassNameResponsive)==null?void 0:c.call(e,s,n))??e.parseClassName(s),r=e.getCommonProps(n,i,t),o=Array.isArray(t.fields)?t.fields:[],l=t.submitButton;return t.collection&&e.fetchEntitySchema?m.createElement(z1,{api:e,c:t,componentKey:n,formClassName:s,parsedStyle:i,formProps:r,fields:o,submitBtn:l}):hm(e,t,n,s,i,r,o,l)}function z1({api:e,c:t,componentKey:n,formClassName:s,parsedStyle:i,formProps:r,fields:o,submitBtn:l}){const[c,h]=m.useState(o),[a,u]=m.useState(!0);return m.useEffect(()=>{if(!e.fetchEntitySchema){u(!1);return}e.fetchEntitySchema(t.collection).then(f=>{if(!Array.isArray(f==null?void 0:f.fields)){u(!1);return}const p=new Map(f.fields.map(d=>[d.name,d])),g=o.map(d=>{var C;const w=p.get(d.name||((C=d.label)==null?void 0:C.toLowerCase()));return w?{...d,required:d.required??w.required,validation:d.validation??(w.validation?{...w.validation}:void 0),placeholder:d.placeholder??w.placeholder}:d});h(g),u(!1)}).catch(()=>u(!1))},[t.collection]),a?E("div",{key:n,style:{padding:"1rem",textAlign:"center",color:e.cfg.colors.textMuted,fontSize:"0.8rem"}},"Loading fields..."):hm(e,t,n,s,i,r,c,l)}const F1=m.memo(function({name:t,value:n,onChange:s,placeholder:i,required:r,inputType:o,label:l,fieldStyle:c,onKeyDown:h}){m.useEffect(()=>{n!==void 0&&n!==""&&s&&s(n)},[]);const a=m.useRef(s);a.current=s;const u=m.useRef(c);u.current=c;const f=m.useCallback(g=>{a.current(g.target.value)},[]),p=m.createElement("input",{name:t,placeholder:i,required:r,type:o||"text",value:n??"",onChange:f,onKeyDown:h?g=>{g.key==="Enter"&&h()}:void 0,style:u.current});return l?m.createElement("div",{style:{width:"100%",marginBottom:"1rem"}},m.createElement("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:c.color,marginBottom:"0.75rem"}},l),p):p}),B1=m.memo(function({api:t,field:n,fieldName:s,label:i,fieldStyle:r}){const o=m.useRef(null),[l,c]=m.useState(!1),h=t.sceneData[s]||"",a=t.sceneData[s+"_name"]||"",u=async f=>{var g,d,w,C;const p=(g=f.target.files)==null?void 0:g[0];if(f.target.value="",!!p){c(!0);try{const x=(d=t.showToast)==null?void 0:d.call(t,"Uploading test case (0%)…","success",0),k=t.uploadFile?await t.uploadFile(p,n.upload,S=>{var T;return(T=x==null?void 0:x.update)==null?void 0:T.call(x,`Uploading test case (${S}%)`)}):"";if((w=x==null?void 0:x.dismiss)==null||w.call(x),!k)throw new Error;t.setSceneData(S=>({...S,[s]:k,[s+"_name"]:p.name}))}catch{(C=t.showToast)==null||C.call(t,"Upload failed","error")}finally{c(!1)}}};return m.createElement("div",{style:{width:"100%"}},i&&E("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:t.cfg.colors.textSecondary,marginBottom:"0.75rem"}},i),h?m.createElement("div",{style:{...r,display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"}},E("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},"📎 "+(a||"Test case uploaded")),E("button",{type:"button",style:{background:"none",border:"none",cursor:"pointer",color:t.cfg.colors.danger,fontSize:"13px"},onClick:()=>t.setSceneData(f=>{const p={...f};return delete p[s],delete p[s+"_name"],p})},"Remove")):m.createElement("button",{type:"button",onClick:()=>{var f;return(f=o.current)==null?void 0:f.click()},style:{...r,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",cursor:"pointer",color:t.cfg.colors.textMuted,fontSize:"14px"}},l?"Uploading…":"⬆ Upload a test case"),E("input",{key:"file-input",ref:o,type:"file",accept:n.accept||".pdf,.docx,.txt,.md,.csv,.json",style:{display:"none"},onChange:u}))}),W1=m.memo(function({name:t,value:n,onChange:s,placeholder:i,required:r,options:o,label:l,fieldStyle:c}){m.useEffect(()=>{n!==void 0&&n!==""&&s&&s(n)},[]);const h=m.useRef(s);h.current=s;const a=m.useRef(c);a.current=c;const u=m.useCallback(p=>{h.current(p.target.value)},[]),f=m.createElement("select",{name:t,required:r,value:n??"",onChange:u,style:{...a.current,cursor:"pointer",appearance:"none"}},i?m.createElement("option",{key:"__placeholder",value:""},i):null,...o.map((p,g)=>m.createElement("option",{key:g,value:typeof p=="string"?p:p.value},typeof p=="string"?p:p.label)));return l?m.createElement("div",{style:{width:"100%",marginBottom:"1rem"}},m.createElement("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,marginBottom:"0.75rem"}},l),f):f}),j1=m.memo(function({name:t,value:n,onChange:s,placeholder:i,required:r,rows:o,label:l,fieldStyle:c}){m.useEffect(()=>{n!==void 0&&n!==""&&s&&s(n)},[]);const h=m.useRef(s);h.current=s;const a=m.useRef(c);a.current=c;const u=m.useCallback(p=>{h.current(p.target.value)},[]),f=m.createElement("textarea",{name:t,placeholder:i,required:r,rows:o||4,value:n??"",onChange:u,style:{...a.current,resize:"vertical",fontFamily:"inherit"}});return l?m.createElement("div",{style:{width:"100%",marginBottom:"1rem"}},m.createElement("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,marginBottom:"0.75rem"}},l),f):f});function hm(e,t,n,s,i,r,o,l){var h,a;const c=[];if(o.forEach((u,f)=>{var x;const p=`${n}-field-${f}`,g=u.name||((x=u.label)==null?void 0:x.toLowerCase())||"",d={width:"100%",padding:"8px 8px",borderRadius:e.cfg.components.inputRadius||void 0,backgroundColor:u.borderless?u.backgroundColor||"transparent":e.cfg.colors.surface,color:u.textColor||e.cfg.colors.text,colorScheme:e.cfg.colorMode==="light"?"light":"dark",border:u.borderless?"none":`1px solid ${e.cfg.colors.border}`,outline:"none",transition:e.cfg.effects.transition},w={width:"100%",marginBottom:"1rem"},C=k=>k.value?e.interpolateText(String(k.value)):"";if(u.type==="richtext")c.push(m.createElement(P1,{key:p,api:e,field:u,fieldName:g,value:e.sceneData[g]??C(u),onChange:k=>e.setSceneData(S=>({...S,[g]:k}))}));else if(u.type==="textarea"){const k=u.rows||4;c.push(m.createElement(j1,{key:p,name:g,value:e.sceneData[g]??C(u),onChange:S=>e.setSceneData(T=>({...T,[g]:S})),placeholder:u.placeholder||u.label,required:u.required,rows:k,label:u.label,fieldStyle:d}))}else if(u.type==="select")if(u.dataSource)c.push(m.createElement(D1,{key:p,api:e,field:u,fieldName:g,fieldKey:p,fieldStyle:d,fieldWrapperStyle:w}));else{const k=Array.isArray(u.options)?u.options:[];c.push(m.createElement(W1,{key:p,name:g,value:e.sceneData[g]??C(u),onChange:S=>e.setSceneData(T=>({...T,[g]:S})),placeholder:u.placeholder||u.label||"Select...",required:u.required,options:k,label:u.label,fieldStyle:d}))}else if(u.type==="advanced-select")c.push(m.createElement("div",{key:`${p}-wrap`,style:w},m.createElement(cm,{key:p,api:e,c:{...u,name:g,options:u.options},componentKey:p})));else if(u.type==="file")c.push(m.createElement("div",{key:`${p}-wrap`,style:w},m.createElement(B1,{key:p,api:e,field:u,fieldName:g,label:u.label,fieldStyle:d})));else if(u.tags)c.push(m.createElement(V1,{key:p,api:e,field:u,value:e.sceneData[g]??C(u),onChange:k=>e.setSceneData(S=>({...S,[g]:k}))}));else{const k=u.type==="email"?"email":u.type==="password"?"password":u.type==="number"?"number":u.type==="date"?"date":"text";c.push(m.createElement(F1,{key:p,name:g,value:e.sceneData[g]??C(u),onChange:S=>e.setSceneData(T=>({...T,[g]:S})),placeholder:u.placeholder||u.label,required:u.required,inputType:k,label:u.label,fieldStyle:d,onKeyDown:u.onKeyDown?()=>e.handleButtonClick(u.onKeyDown):void 0}))}}),l){const u={padding:"0.75rem 1.5rem",borderRadius:e.cfg.components.inputRadius,cursor:"pointer",fontWeight:600,width:"100%",marginTop:"1rem"},f=l.className?((h=e.parseClassNameResponsive)==null?void 0:h.call(e,l.className,`${n}-submit`))??e.parseClassName(l.className):{},p=!!l.className&&/(^|\s)bg-[^\s]+/.test(l.className),g=!!l.className&&/(^|\s)text-[^\s]+/.test(l.className),d={...u,...f,...!p&&{backgroundColor:e.cfg.colors.primary},...!g&&{color:"#fff",border:"none"}},w=`${n}-submit`,C=!!((a=e.buttonLoading)!=null&&a[w]),x=()=>{var L,O,H,U,q;const P=[],I=e.sceneData||{};for(const X of o){const j=X.name||((L=X.label)==null?void 0:L.toLowerCase()),D=I[j],V=X.label||j;if(X.required&&(D==null||String(D).trim()==="")){P.push(`${V} is required`);continue}D==null||String(D).trim()===""||((O=X.validation)!=null&&O.pattern&&!new RegExp(X.validation.pattern).test(String(D))&&P.push(`${V} is invalid`),((H=X.validation)==null?void 0:H.min)!==void 0&&Number(D)<Number(X.validation.min)&&P.push(`${V} must be at least ${X.validation.min}`),((U=X.validation)==null?void 0:U.max)!==void 0&&Number(D)>Number(X.validation.max)&&P.push(`${V} must be at most ${X.validation.max}`),((q=X.validation)==null?void 0:q.minLength)!==void 0&&String(D).length<Number(X.validation.minLength)&&P.push(`${V} must be at least ${X.validation.minLength} characters`))}return P},k=()=>{var O,H;const P=x();if(P.length){(O=e.showToast)==null||O.call(e,P,"error");return}const I=()=>l.onClick?e.handleButtonClick(l.onClick,{onSuccess:l.onSuccess,onError:l.onError},{optimistic:l.optimistic,feedback:l.feedback}):Promise.resolve(),L=e.withLoading?e.withLoading(w,I):I();(H=L==null?void 0:L.catch)==null||H.call(L,()=>{})},S=l.onClick?()=>k():void 0,T=[];C?T.push(E("span",{key:"spinner",className:"bf-btn-spinner",style:{display:"inline-flex",width:"14px",height:"14px",marginRight:"6px",border:"2px solid currentColor",borderTopColor:"transparent",borderRadius:"50%",flexShrink:0}})):l.icon&&T.push(E("span",{key:"icon",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginRight:"6px"}},e.renderIcon(l.icon,l.iconSize||16))),T.push(E("span",{key:"text"},l.text||"Submit")),c.push(E("button",{key:w,type:l.type||"submit",className:l.className,...e.getCommonProps(w,d,l),disabled:C||void 0,onClick:S},...T))}return E("form",{key:n,className:s,...r,onSubmit:u=>u.preventDefault()},...c)}const V1=m.memo(({api:e,field:t,value:n,onChange:s})=>{m.useEffect(()=>{n!==void 0&&n!==""&&s&&s(n)},[]);const i=m.useRef(null),r=(n||"").split(",").filter(Boolean).map(p=>p.trim()),[o,l]=m.useState(""),[c,h]=m.useState(!1),a=p=>{const g=p.target.value;if(g.includes(",")||g.includes(";")){const d=g.split(/[,;]+/).map(w=>w.trim()).filter(Boolean);if(d.length>0){const w=[...new Set([...r,...d])].join(", ");s(w)}l("")}else l(g)},u=p=>{if(p.key==="Enter"||p.key===","||p.key===";"){p.preventDefault();const g=o.trim();g&&(s([...new Set([...r,g])].join(", ")),l(""))}else p.key==="Backspace"&&!o&&r.length>0&&s(r.slice(0,-1).join(", "))},f=()=>{const p=o.trim();p&&(s([...new Set([...r,p])].join(", ")),l(""))};return E("div",{key:"tags",style:{width:"100%",marginBottom:"1rem"}},t.label?E("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem"}},t.label):null,E("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px",padding:"0.5rem 0.75rem",borderRadius:e.cfg.components.inputRadius||"8px",backgroundColor:e.cfg.colors.surface,border:`1px solid ${c?e.cfg.colors.primary:e.cfg.colors.border}`,cursor:"text",outline:"none",transition:"border-color 0.2s"},onClick:()=>{var p;return(p=i.current)==null?void 0:p.focus()}},...r.map((p,g)=>E("span",{key:g,style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"4px",backgroundColor:e.cfg.colors.background,border:`1px solid ${e.cfg.colors.borderSubtle}`,color:e.cfg.colors.text,fontSize:"13px",lineHeight:"1.4"}},E("span",null,p),E("button",{type:"button",onMouseDown:d=>{d.preventDefault(),d.stopPropagation(),s(r.filter((w,C)=>C!==g).join(", "))},style:{background:"none",border:"none",cursor:"pointer",color:e.cfg.colors.textMuted,padding:"0",fontSize:"14px",lineHeight:"1",display:"flex",alignItems:"center",fontFamily:"inherit"}},"×"))),E("input",{ref:i,type:"text",value:o,onChange:a,onKeyDown:u,onFocus:()=>h(!0),onBlur:()=>{h(!1),f()},placeholder:t.placeholder||(r.length>0?"":"Add email..."),style:{flex:1,minWidth:"100px",border:"none",outline:"none",backgroundColor:"transparent",color:e.cfg.colors.text,fontSize:"14px",fontFamily:"inherit",padding:"2px 0"}})))});function O1(e,t,n){const s=e.interpolateText(t.text||t.content||"");if(!s)return null;const i=d=>{const w=[],C=/(\*\*(.+?)\*\*)|(\*(.+?)\*)|(`(.+?)`)|(\[(.+?)\]\((.+?)\))|(~~(.+?)~~)/g;let x=0,k;for(;(k=C.exec(d))!==null;)k.index>x&&w.push(d.slice(x,k.index)),k[2]?w.push(E("strong",{key:w.length},k[2])):k[4]?w.push(E("em",{key:w.length},k[4])):k[6]?w.push(E("code",{key:w.length},k[6])):k[8]?w.push(E("a",{key:w.length,href:k[9],target:"_blank",rel:"noopener noreferrer"},k[8])):k[11]&&w.push(E("del",{key:w.length},k[11])),x=k.index+k[0].length;return x<d.length&&w.push(d.slice(x)),w},r=s.split(`
16
- `),o=[];let l=null,c=!1,h=[];const a=d=>{l&&(o.push(m.createElement(l.type,{key:d,style:{paddingLeft:"1.5rem",margin:"0.5rem 0"}},l.items.map((w,C)=>E("li",{key:`${d}-${C}`},w)))),l=null)},u=d=>{if(h.length===0)return;const w=h.join(`
17
- `);o.push(E("div",{key:d,style:{position:"relative",background:"#1e1e2e",borderRadius:"8px",margin:"0.5rem 0"}},E("button",{style:{position:"absolute",top:"8px",right:"8px",background:"transparent",border:"none",color:"#666",cursor:"pointer",padding:"4px",borderRadius:"4px",lineHeight:"1",zIndex:1,display:"inline-flex",alignItems:"center",fontSize:"14px"},onClick:C=>{C.preventDefault(),C.stopPropagation(),(k=>{navigator.clipboard.writeText(k).catch(()=>{const S=document.createElement("textarea");S.value=k,S.style.position="fixed",S.style.opacity="0",document.body.appendChild(S),S.select(),document.execCommand("copy"),document.body.removeChild(S)})})(w)}},E("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},E("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),E("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"}))),E("pre",{style:{padding:"16px 12px",margin:0,overflow:"auto",fontSize:"13px",lineHeight:"1.5",color:"#e2e8f0"}},E("code",null,w)))),h=[]};for(let d=0;d<r.length;d++){const w=r[d],C=w.trim();if(C==="```"){c?(u(`code-${d}`),c=!1):(a(`list-${d}`),c=!0,h=[]);continue}if(c){h.push(w);continue}if(!C){a(`list-${d}`);continue}const x=C.match(/^(#{1,3})\s+(.+)/);if(x){a(`list-${d}`);const T=`h${x[1].length}`;o.push(m.createElement(T,{key:d,style:{margin:"0.75rem 0 0.25rem"}},...i(x[2])));continue}if(C.startsWith("- ")||C.startsWith("* ")){const S=C.slice(2);l?l.type!=="ul"&&(a(`list-${d}`),l={type:"ul",items:[]}):l={type:"ul",items:[]},l.items.push(m.createElement(m.Fragment,{},...i(S)));continue}const k=C.match(/^\d+\.\s+(.+)/);if(k){l?l.type!=="ol"&&(a(`list-${d}`),l={type:"ol",items:[]}):l={type:"ol",items:[]},l.items.push(m.createElement(m.Fragment,{},...i(k[1])));continue}a(`list-${d}`),o.push(E("p",{key:d,style:{margin:"0.25rem 0"}},...i(C)))}c&&u("code-end"),a("list-end");const f={};t.fontSize!==void 0&&(f.fontSize=`${t.fontSize}px`),t.fontWeight!==void 0&&(f.fontWeight=t.fontWeight),t.color!==void 0&&(f.color=t.color),t.textAlign!==void 0&&(f.textAlign=t.textAlign);const p=t.className?{...f,...e.parseClassName(t.className)}:f,g=e.getCommonProps(n,p,t);return E("div",{key:n,...g},...o)}function U1(e,t,n){const s=e.cfg.colors,i={position:"relative",marginTop:"auto",bottom:0,left:0,right:0,zIndex:40,display:"flex",justifyContent:"space-around",alignItems:"stretch",backgroundColor:s.surfaceHover,borderTop:`1px solid ${s.border}`,padding:"6px 0",boxShadow:"0 -2px 8px rgba(0,0,0,0.08)"},o=(Array.isArray(t.items)?t.items:[]).map((c,h)=>{const a=c.active||!1,u=()=>{const f=()=>e.handleButtonClick(c.onClick||"");(e.withLoading?e.withLoading(`${n}-bn-${h}`,f):f()).catch(()=>{})};return E("button",{key:`${n}-bn-${h}`,onClick:u,style:{background:"none",border:"none",cursor:"pointer",flex:1,display:"flex",flexDirection:"column",alignItems:"center",gap:2,padding:"6px 0",color:a?s.primary:s.textMuted,fontSize:11,fontFamily:"inherit"},"aria-label":c.label||c.icon||"nav item"},c.icon?e.renderIcon(c.icon,20):null,c.label?E("span",{},c.label):null)}),l=e.getCommonProps(n,i,t);return E("div",{key:n,...l},...o)}function H1(e,t,n){const s=Array.isArray(t.panes)?t.panes:[],i=t.className?{display:"flex",flexDirection:"row",alignItems:"stretch",...e.parseClassName(t.className)}:{display:"flex",flexDirection:"row",alignItems:"stretch",width:"100%",flex:1,minHeight:0},r=s.map((l,c)=>{const a={width:l.width!==void 0?l.width:c===s.length-1?"1fr":"50%",minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},u=`${n}-split-${c}`;return E("div",{key:u,style:a},l.component?e.renderComponent(l.component,c,`${n}-split`):null)}),o=e.getCommonProps(n,i,t);return E("div",{key:n,...o},...r)}function q1(e,t,n){const s=e.cfg.colorMode!=="light",i=()=>{var l;return(l=e.setColorMode)==null?void 0:l.call(e,s?"light":"dark")},r=t.className?e.parseClassName(t.className):{background:"none",border:`1px solid ${e.cfg.colors.border}`,borderRadius:8,cursor:"pointer",display:"flex",alignItems:"center",gap:6,padding:"6px 10px",color:e.cfg.colors.text,fontSize:14,fontFamily:"inherit"},o=e.getCommonProps(n,r,t);return E("button",{key:n,...o,onClick:i,"aria-label":s?"Switch to light mode":"Switch to dark mode"},E("span",{},s?"☀️":"🌙"),t.text?E("span",{},t.text):null)}function G1(e){var r;const{api:t,config:n}=e,s=t.interpolateText(n.channel||""),i=t.interpolateText(n.entityId||"");return m.useEffect(()=>{var w;const o=t.sdk;if(!t.isAuthenticated||!((w=o==null?void 0:o.client)!=null&&w.createWebSocket)||!s)return;let l=null,c=null,h=[],a=!1,u=null;const f=()=>{const C=t.interpolateText(n.resolution||"")||"",x=String(C).match(/(\d+)\s*x\s*(\d+)/);return x?{width:Number(x[1]),height:Number(x[2])}:{width:Number(t.interpolateText(n.width))||1280,height:Number(t.interpolateText(n.height))||720}},p=Number(t.interpolateText(n.fps))||10,g=async()=>{var x;if(a)return;a=!0,c&&c.state!=="inactive"&&await new Promise(k=>{c.onstop=()=>k(),c.stop()}),(x=l==null?void 0:l.close)==null||x.call(l);const C=new Blob(h,{type:"video/webm"});if(h=[],C.size!==0)try{const k=t.interpolateText(n.entityId||"")||"cast",S=t.interpolateText(n.fileName||"")||`${n.entityType||"video"}-${k}.webm`,T=new File([C],S,{type:"video/webm"}),P=await o.files.upload(T,{bucket:n.bucket||"backflow-storage",entityType:n.entityType||"video",entityId:k});t.setSceneData(I=>({...I,sessionId:k,[n.assetField||"asset_id"]:P==null?void 0:P.id,_recorded:P})),n.onRecorded&&t.handleButtonClick(String(n.onRecorded),{})}catch(k){Br("[recorder] upload failed:",k)}},d=()=>{if(c)return;const{width:C,height:x}=f(),k=document.createElement("canvas");k.width=C,k.height=x;const S=k.getContext("2d");if(S){u=T=>{const P=new Image;P.onload=()=>S.drawImage(P,0,0,C,x),P.src=T};try{const T=k.captureStream(p);c=new MediaRecorder(T,{mimeType:"video/webm",videoBitsPerSecond:5e6}),c.ondataavailable=P=>{P.data.size&&h.push(P.data)},c.start(500)}catch(T){Br("[recorder] start failed:",T),c=null}}};return l=o.client.createWebSocket(s),l.onmessage=C=>{let x=C==null?void 0:C.data;if(typeof x=="string")try{x=JSON.parse(x)}catch{return}(x==null?void 0:x.type)==="screencast_frame"&&x.frame?(d(),u==null||u(x.frame)):((x==null?void 0:x.status)==="completed"||(x==null?void 0:x.status)==="failed"||(x==null?void 0:x.type)==="workflow_completed"||(x==null?void 0:x.type)==="workflow_failed")&&g()},l.onclose=()=>g(),l.onerror=()=>g(),()=>{var C,x;a=!0,(C=c==null?void 0:c.stop)==null||C.call(c),(x=l==null?void 0:l.close)==null||x.call(l)}},[t.isAuthenticated,s,i,(r=e.config)==null?void 0:r.channel]),null}function Y1(e){const{api:t,config:n,componentKey:s}=e,i=t.interpolateText(n.channel||""),r=m.useRef(null),o=m.useRef(null),[l,c]=m.useState(!1);m.useEffect(()=>{const a=()=>c(document.fullscreenElement===r.current);return document.addEventListener("fullscreenchange",a),()=>document.removeEventListener("fullscreenchange",a)},[]);const h=async a=>{var f,p;a.preventDefault(),a.stopPropagation();const u=r.current;if(u){if(document.fullscreenElement){await((f=document.exitFullscreen)==null?void 0:f.call(document));return}await((p=u.requestFullscreen)==null?void 0:p.call(u))}};return m.useEffect(()=>{var d;const a=t.sdk;if(!t.isAuthenticated||!((d=a==null?void 0:a.client)!=null&&d.createWebSocket)||!i)return;let u=null,f=!1;const p=w=>{const C=o.current;if(!C)return;const x=new Image;x.onload=()=>{if(f)return;const k=C.getContext("2d");k&&(C.width=x.width,C.height=x.height,k.drawImage(x,0,0,C.width,C.height))},x.src=w},g=()=>{f||(u=a.client.createWebSocket(i),u.onmessage=w=>{let C=w==null?void 0:w.data;if(typeof C=="string")try{C=JSON.parse(C)}catch{return}(C==null?void 0:C.type)==="screencast_frame"&&C.frame&&p(C.frame)},u.onclose=()=>{f||setTimeout(g,3e3)},u.onerror=()=>{var w;(w=u==null?void 0:u.close)==null||w.call(u)})};return g(),()=>{var w;f=!0,(w=u==null?void 0:u.close)==null||w.call(u)}},[t.isAuthenticated,i,s]),m.createElement("div",{key:s,ref:r,className:"relative w-full h-full bg-black group",style:{width:"100%",height:"100%"}},m.createElement("canvas",{ref:o,className:t.parseClassName(n.className||"w-full h-full object-contain bg-black [aspect-ratio:16/9]"),style:{width:"100%",height:"100%",objectFit:"contain"}}),n.fullscreen===!1?null:m.createElement("button",{type:"button",onClick:h,title:l?"Exit fullscreen":"Open fullscreen","aria-label":l?"Exit fullscreen":"Open fullscreen",className:"absolute top-2 right-2 z-20 inline-flex h-8 w-8 items-center justify-center rounded-full bg-black/55 text-white transition-opacity hover:bg-black/75"},t.renderIcon(l?"minimize-2":"maximize-2",16)))}function Os(e,t,n,s,i){if(!Array.isArray(t)||t.length===0)return null;if(s==="row")return t.map((h,a)=>e.renderComponent(h,a,n));const r=[];let o=[];const l=h=>h&&(h.type==="button"||i&&(h.type==="link"||h.type==="a")),c=h=>{o.length!==0&&(o.length===1?r.push(e.renderComponent(o[0],h,n)):r.push(E("div",{key:`${n}-btns-${h}`,style:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"center",gap:"0.75rem"}},...o.map((a,u)=>e.renderComponent(a,h+u,n)))),o=[])};return t.forEach((h,a)=>{l(h)?o.push(h):(c(a),r.push(e.renderComponent(h,a,n)))}),c(t.length),r}function um(e){return e.className?/\bhidden\b/.test(e.className)&&/\b(sm|md|lg|xl):(?:block|flex|inline|inline-block|inline-flex)\b/.test(e.className):!1}function dm(e){return e.children?e.children.filter(t=>um(t)):[]}function X1(e){return e.children?e.children.filter(t=>!um(t)):[]}function fm(e){var t;return Array.isArray((t=e==null?void 0:e.mobileMenu)==null?void 0:t.items)?e.mobileMenu.items:[]}function Q1(e){if(!(e.layout==="row"||e.className&&/\bflex-row\b/.test(e.className)))return!1;const n=dm(e),s=fm(e);if(n.length===0&&s.length===0)return!1;const i=["text","link","button","accordion"];if(!(n.length===0||n.every(c=>i.includes(c.type))))return!1;const o=e.className||"";return/\b(sticky|fixed)\b/.test(o)||/\btop-0\b/.test(o)||/\bz-(10|20|30|40|50)\b/.test(o)||/\bjustify-between\b/.test(o)||e.justify==="space-between"}function Pu(e){const t=fm(e);return t.length>0?t:dm(e)}function _u(e){return X1(e)}function $u(e,t){return m.createElement("button",{key:"hamburger-icon",onClick:()=>t(!e),style:{background:"none",border:"none",cursor:"pointer",padding:"8px",display:"flex",alignItems:"center",justifyContent:"center",color:"inherit",fontSize:"24px",lineHeight:1},"aria-label":e?"Close menu":"Open menu"},e?"✕":"☰")}function mm(e){return e=String(e??""),e.replace(/\bhidden\b/g,"").replace(/\b(sm|md|lg|xl|2xl):(block|flex|inline|inline-block|inline-flex)\b/g,"").replace(/\s+/g," ").trim()}function Nu(e){const t=(e==null?void 0:e.className)||"";return/\bdrawer\b/.test(t)&&!/\bdrawer-(item|item-[a-z]+)\b/.test(t)}function Ts(e){return/\bburger-first\b/.test((e==null?void 0:e.className)||"")}function Iu({navLinks:e,parentKey:t,renderComponentFn:n,open:s,onClose:i,colorMode:r,portalTarget:o,mobileMenu:l,parseMenuClassName:c}){const[h,a]=m.useState(s);if(m.useEffect(()=>{s&&a(!0)},[s]),!s&&!h)return null;const u=e.map(C=>({...C,className:C.className?mm(C.className):void 0})),f=r!=="light"?"rgba(17, 24, 39, 0.98)":"rgba(255, 255, 255, 0.98)",p=l!=null&&l.className&&c?c(l.className,`${t}-side-drawer-class`):{},g=l!=null&&l.headerClassName&&c?c(l.headerClassName,`${t}-side-header-class`):{},d=()=>{a(!1),i()},w=m.createElement(m.Fragment,null,m.createElement("div",{key:`${t}-side-backdrop`,onClick:d,style:{position:"absolute",inset:0,backgroundColor:"rgba(0, 0, 0, 0.45)",zIndex:90,opacity:s?1:0,transition:"opacity 0.25s ease",pointerEvents:s?"auto":"none"}}),m.createElement("div",{key:`${t}-side-drawer`,className:l==null?void 0:l.className,style:{position:"absolute",top:0,bottom:0,left:0,width:"min(300px, 85%)",backgroundColor:f,zIndex:100,overflowY:"auto",transform:s?"translateX(0)":"translateX(-100%)",transition:"transform 0.25s ease",boxShadow:"2px 0 12px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column",gap:"4px",padding:"16px 12px",...p}},m.createElement("div",{key:`${t}-side-header`,className:l==null?void 0:l.headerClassName,style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"4px 8px 12px",borderBottom:"1px solid rgba(128, 128, 128, 0.2)",marginBottom:"8px",fontSize:18,fontWeight:700,...g}},(l==null?void 0:l.title)||"Menu",m.createElement("button",{onClick:d,"aria-label":"Close menu",style:{background:"none",border:"none",cursor:"pointer",fontSize:22,color:"inherit",lineHeight:1}},"✕")),u.map((C,x)=>m.createElement(pm,{key:`${t}-drawer-item-${x}`,link:C,idx:x,parentKey:t,renderComponentFn:n,onClose:d,itemClassName:l==null?void 0:l.itemClassName,itemStyle:l!=null&&l.itemClassName&&c?c(l.itemClassName,`${t}-drawer-item-class-${x}`):void 0}))));return o?Wu.createPortal(w,o):w}function pm({link:e,idx:t,parentKey:n,renderComponentFn:s,onClose:i,itemClassName:r,itemStyle:o}){const[l,c]=m.useState(!1),h=e.type==="link"||e.type==="button";return m.createElement("div",{key:`${n}-drawer-item-${t}`,className:r,style:{display:"flex",flexDirection:"row",alignItems:"center",gap:10,width:"100%",padding:"10px 12px",borderRadius:8,cursor:h?"pointer":"default",backgroundColor:l?"rgba(128, 128, 128, 0.12)":"transparent",transition:"background-color 0.15s ease",...o},onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onClick:()=>{h&&i()}},s(e,t+1,`${n}-drawer`))}function Du(e,t,n,s,i,r,o,l){if(!s)return null;const c=e.map(f=>({...f,className:f.className?mm(f.className):void 0})),h=i!=="light"?"rgba(17, 24, 39, 0.98)":"rgba(255, 255, 255, 0.98)",a=i!=="light"?"rgba(75, 85, 99, 0.5)":"rgba(209, 213, 219, 0.5)",u=o!=null&&o.className&&l?l(o.className,`${t}-mobile-drawer-class`):{};return m.createElement("div",{key:`${t}-mobile-drawer`,className:o==null?void 0:o.className,style:{position:"absolute",top:"100%",left:0,right:0,backgroundColor:h,borderTop:`1px solid ${a}`,padding:"12px",display:"flex",flexDirection:"column",gap:"4px",zIndex:50,boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",...u}},c.map((f,p)=>m.createElement(pm,{key:`${t}-drawer-item-${p}`,link:f,idx:p,parentKey:t,renderComponentFn:n,onClose:()=>r==null?void 0:r(!1),itemClassName:o==null?void 0:o.itemClassName,itemStyle:o!=null&&o.itemClassName&&l?l(o.itemClassName,`${t}-drawer-item-class-${p}`):void 0})))}function J1(e,t,n){var o;if(t.className){const l=((o=e.parseClassNameResponsive)==null?void 0:o.call(e,t.className,n))??e.parseClassName(t.className);if(l.display==null&&(l.display="flex"),l.flexDirection==null){const h=t.className||"",a=h.match(/\b((sm|md|lg|xl|2xl):)?flex-(row|row-reverse|col|col-reverse)\b/);if(a)l.flexDirection=a[3].startsWith("row")?"row":"column";else if(/(^|\s)((sm|md|lg|xl|2xl):)?flex(\s|$)/.test(h)){const u=/\bmin-h-(screen|\[[^\]]+\])/.test(h)&&/\bitems-center\b/.test(h),f=Array.isArray(t.children)&&t.children.length>0&&t.children.every(p=>p&&["h1","h2","h3","h4","p","text"].includes(p.type));l.flexDirection=u||f?"column":"row"}else l.flexDirection=t.layout==="row"?"row":"column"}if(e.renderMode!=="css-driven"){const h=Fi(t.className);if(h.px.size>0){const u=ht(h.px,e.containerWidth,"0px");l.paddingLeft=u,l.paddingRight=u}if(h.py.size>0){const u=ht(h.py,e.containerWidth,"0px");l.paddingTop=u,l.paddingBottom=u}if(h.p.size>0){const u=ht(h.p,e.containerWidth,"0px");l.padding=u}const a=Gs(t.className);a.size>0&&(l.display=ht(a,e.containerWidth,"flex"))}const c=e.getCommonProps(n,l,t);return m.createElement("div",{key:n,className:t.className,...c},Os(e,Array.isArray(t.children)?t.children:[],n,l.flexDirection))}const s=e.cfg.colorMode==="light",i={display:"flex",flexDirection:t.layout==="row"?"row":"column",gap:t.gap!==void 0?`${t.gap}px`:"1rem",padding:"1.5rem",borderRadius:"1rem",backdropFilter:"blur(8px)",border:s?"1px solid rgba(0, 0, 0, 0.1)":"1px solid rgba(55, 65, 81, 0.5)"},r=e.getCommonProps(n,i,t);return m.createElement("div",{key:n,...r},Os(e,t.children,n,i.flexDirection))}function K1(e,t,n){var l;const s=e.isMobileView&&Q1(t);if(t.className){const c=((l=e.parseClassNameResponsive)==null?void 0:l.call(e,t.className,n))??e.parseClassName(t.className);if(c.display==null&&(c.display="flex"),c.flexDirection==null){const u=t.className||"",f=u.match(/\b((sm|md|lg|xl|2xl):)?flex-(row|row-reverse|col|col-reverse)\b/);if(f)c.flexDirection=f[3].startsWith("row")?"row":"column";else if(/(^|\s)((sm|md|lg|xl|2xl):)?flex(\s|$)/.test(u)){const p=/\bmin-h-(screen|\[[^\]]+\])/.test(u)&&/\bitems-center\b/.test(u),g=Array.isArray(t.children)&&t.children.length>0&&t.children.every(d=>d&&["h1","h2","h3","h4","p","text"].includes(d.type));c.flexDirection=p||g?"column":"row"}else c.flexDirection=t.layout==="row"?"row":"column"}if(e.renderMode!=="css-driven"){const u=Fi(t.className);if(u.px.size>0){const p=ht(u.px,e.containerWidth,"0px");c.paddingLeft=p,c.paddingRight=p}if(u.py.size>0){const p=ht(u.py,e.containerWidth,"0px");c.paddingTop=p,c.paddingBottom=p}if(u.p.size>0){const p=ht(u.p,e.containerWidth,"0px");c.padding=p}const f=Gs(t.className);f.size>0&&(c.display=ht(f,e.containerWidth,"flex"))}if(s&&t.children&&t.children.length>0){const u=_u(t),f=Pu(t);c.position="relative",c.display="flex",c.alignItems="center",c.justifyContent=Ts(t)?"flex-start":"space-between",Ts(t)&&(c.gap=10);const p=e.getCommonProps(n,c,t),g=$u(e.mobileMenuOpen,e.setMobileMenuOpen),d=(C,x)=>{var k;return((k=e.parseClassNameResponsive)==null?void 0:k.call(e,C,x))??e.parseClassName(C)},w=u.map((C,x)=>e.renderComponent(C,x,n));return m.createElement("div",{key:n,className:t.className,...t.scrollTarget?{id:t.scrollTarget}:{},...p},...Ts(t)?[g,...w]:[...w,g],Nu(t)?m.createElement(Iu,{navLinks:f,parentKey:n,renderComponentFn:e.renderComponent,open:e.mobileMenuOpen,onClose:()=>e.setMobileMenuOpen(!1),colorMode:e.cfg.colorMode,portalTarget:e.portalTarget,mobileMenu:t.mobileMenu,parseMenuClassName:d}):Du(f,n,e.renderComponent,e.mobileMenuOpen,e.cfg.colorMode,e.setMobileMenuOpen,t.mobileMenu,d))}const h=e.getCommonProps(n,c,t),a=t.onClick?{onClick:u=>{u.stopPropagation(),e.handleButtonClick(t.onClick,{})},style:{cursor:"pointer"}}:{};return m.createElement("div",{key:n,className:t.className,...t.scrollTarget?{id:t.scrollTarget}:{},...h,...a},Os(e,Array.isArray(t.children)?t.children:[],n,c.flexDirection))}const i={display:"flex",flexDirection:t.layout==="row"?"row":"column",gap:t.gap!==void 0?`${t.gap}px`:"16px"};if(t.align){const c={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"};i.alignItems=c[t.align]}if(t.justify){const c={start:"flex-start",center:"center",end:"flex-end","space-between":"space-between"};i.justifyContent=c[t.justify]}if(t.padding!==void 0&&(i.padding=`${t.padding}px`),s&&t.children&&t.children.length>0){const c=_u(t),h=Pu(t);i.position="relative",i.display="flex",i.alignItems="center",i.justifyContent=Ts(t)?"flex-start":"space-between",Ts(t)&&(i.gap=10);const a=e.getCommonProps(n,i,t),u=$u(e.mobileMenuOpen,e.setMobileMenuOpen),f=(g,d)=>{var w;return((w=e.parseClassNameResponsive)==null?void 0:w.call(e,g,d))??e.parseClassName(g)},p=c.map((g,d)=>e.renderComponent(g,d,n));return m.createElement("div",{key:n,...a},...Ts(t)?[u,...p]:[...p,u],Nu(t)?m.createElement(Iu,{navLinks:h,parentKey:n,renderComponentFn:e.renderComponent,open:e.mobileMenuOpen,onClose:()=>e.setMobileMenuOpen(!1),colorMode:e.cfg.colorMode,portalTarget:e.portalTarget,mobileMenu:t.mobileMenu,parseMenuClassName:f}):Du(h,n,e.renderComponent,e.mobileMenuOpen,e.cfg.colorMode,e.setMobileMenuOpen,t.mobileMenu,f))}const r=e.getCommonProps(n,i,t),o=t.onClick?{onClick:c=>{c.stopPropagation(),e.handleButtonClick(t.onClick,{})},style:{cursor:"pointer"}}:{};return m.createElement("div",{key:n,...r,...o},Os(e,t.children,n,i.flexDirection))}function Z1(e,t,n){var r,o;if(t.className){const l=((r=e.parseClassNameResponsive)==null?void 0:r.call(e,t.className,n))??e.parseClassName(t.className);let c;if(e.renderMode!=="css-driven"){const a=cv(t.className),u=a.size>0?hv(a,e.containerWidth):void 0;c={display:"grid",...l,...u!==void 0&&{gridTemplateColumns:`repeat(${u}, minmax(0, 1fr))`}}}else c={display:"grid",...l};const h=e.getCommonProps(n,c,t);return m.createElement("div",{key:n,className:t.className,...h},(Array.isArray(t.children)?t.children:[]).map((a,u)=>e.renderComponent(a,u,n)))}const s={display:"grid",width:"100%",gridTemplateColumns:`repeat(${t.cols||2}, minmax(0, 1fr))`,gap:t.gap!==void 0?`${t.gap}px`:"16px"},i=e.getCommonProps(n,s,t);return m.createElement("div",{key:n,...i},(o=t.children)==null?void 0:o.map((l,c)=>e.renderComponent(l,c,n)))}function tS(e,t,n){var l,c;if(t.className){const a={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",minHeight:e.containerWidth>0&&e.containerWidth<_i.md?"300px":"500px",gap:"24px"};(t.bg||t.backgroundColor)&&(a.background=t.bg||t.backgroundColor),t.bgImage&&(a.backgroundImage=`url(${t.bgImage})`,a.backgroundSize="cover",a.backgroundPosition="center");const u={...a,...((l=e.parseClassNameResponsive)==null?void 0:l.call(e,t.className,n))??e.parseClassName(t.className)};if(Array.isArray(t.children)&&t.children.some(g=>g.type==="grid")||(u.textAlign="center"),e.renderMode!=="css-driven"){const g=Fi(t.className);if(g.px.size>0){const d=ht(g.px,e.containerWidth,"0px");u.paddingLeft=d,u.paddingRight=d}if(g.py.size>0){const d=ht(g.py,e.containerWidth,"0px");u.paddingTop=d,u.paddingBottom=d}if(g.p.size>0){const d=ht(g.p,e.containerWidth,"0px");u.padding=d}}const p=e.getCommonProps(n,u,t);return m.createElement("div",{key:n,className:t.className,...p},Os(e,Array.isArray(t.children)?t.children:[],n,u.flexDirection))}const s=e.containerWidth<_i.md,i={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",minHeight:s?"300px":"500px",padding:s?"1.5rem":"3rem",background:t.bg||t.backgroundColor,gap:"24px"};t.bgImage&&(i.backgroundImage=`url(${t.bgImage})`,i.backgroundSize="cover",i.backgroundPosition="center"),Array.isArray(t.children)&&t.children.some(h=>h.type==="grid")||(i.textAlign="center");const o=e.getCommonProps(n,i,t);return m.createElement("div",{key:n,...o},(c=t.children)==null?void 0:c.map((h,a)=>e.renderComponent(h,a,n)))}function eS(e,t,n){var o;const s={display:"flex",flexDirection:"row",alignItems:"center",width:"100%",flexShrink:0,position:"sticky",top:0,zIndex:50,gap:"1.25rem",padding:"0.75rem 1.5rem",backgroundColor:e.cfg.colors.surface,borderBottom:`1px solid ${e.cfg.colors.border}`};if(t.className&&(Object.assign(s,((o=e.parseClassNameResponsive)==null?void 0:o.call(e,t.className,n))??e.parseClassName(t.className)),e.renderMode!=="css-driven")){const l=Fi(t.className);l.px.size>0&&(s.paddingLeft=ht(l.px,e.containerWidth,"0px"),s.paddingRight=ht(l.px,e.containerWidth,"0px")),l.py.size>0&&(s.paddingTop=ht(l.py,e.containerWidth,"0px"),s.paddingBottom=ht(l.py,e.containerWidth,"0px"));const c=Gs(t.className);c.size>0&&(s.display=ht(c,e.containerWidth,"flex"))}const i=e.getCommonProps(n,s,t),r=t.className?{key:n,className:t.className,...i}:{key:n,...i};return m.createElement("header",r,(Array.isArray(t.children)?t.children:[]).filter(l=>Array.isArray(l.visibleOn)?l.visibleOn.includes(e.currentSceneId):Array.isArray(l.hiddenOn)?!l.hiddenOn.includes(e.currentSceneId):!0).map((l,c)=>e.renderComponent(l,c,n)))}function nS(e,t,n){var c;const s={display:"flex",flexDirection:t.layout==="row"?"row":"column",width:"100%",flexShrink:0,marginTop:"auto",gap:"1rem",padding:"2.5rem 1.5rem",backgroundColor:e.cfg.colors.surfaceHover,borderTop:`1px solid ${e.cfg.colors.border}`};if(t.className&&(Object.assign(s,((c=e.parseClassNameResponsive)==null?void 0:c.call(e,t.className,n))??e.parseClassName(t.className)),e.renderMode!=="css-driven")){const h=Fi(t.className);h.px.size>0&&(s.paddingLeft=ht(h.px,e.containerWidth,"0px"),s.paddingRight=ht(h.px,e.containerWidth,"0px")),h.py.size>0&&(s.paddingTop=ht(h.py,e.containerWidth,"0px"),s.paddingBottom=ht(h.py,e.containerWidth,"0px"))}const i=e.getCommonProps(n,s,t),r=t.className?{key:n,className:t.className,...i}:{key:n,...i};let o=Array.isArray(t.children)?t.children:[];const l=o[0];return l&&l.type==="text"&&/^(\u00a9|\(c\)|copyright)/i.test(String(l.text).trim())&&(o=[...o.slice(1),l]),m.createElement("footer",r,Os(e,o,n,s.flexDirection,!0))}const Lu=new Map;function sS(e){let t=Lu.get(e);return t||(t=Nr.create(e),Lu.set(e,t)),t}function lt(e,t){if(!(e!=null&&e.motion)||!m.isValidElement(t))return t;const n=t,s=n.props,i=sS(n.type);return m.createElement(i,{key:n.key,...s,initial:e.initial,animate:e.animate,exit:e.exit,transition:e.transition,variants:e.variants,whileHover:e.whileHover,whileTap:e.whileTap,whileFocus:e.whileFocus,whileInView:e.whileInView,layout:e.animateLayout},s==null?void 0:s.children)}function Cr(e,t,n,s=""){var o;const i=t,r=`${s}-${n}`;if(Array.isArray(i.hiddenOn)&&i.hiddenOn.includes(e.currentSceneId)||Array.isArray(i.visibleOn)&&!i.visibleOn.includes(e.currentSceneId)||i.condition&&e.evaluateCondition&&!e.evaluateCondition(i.condition))return null;if(!Array.isArray(i.children)&&Array.isArray(i.components)&&(i.children=i.components),i.type==="custom"){const l=i.tagName||"div",c=((o=e.parseClassNameResponsive)==null?void 0:o.call(e,i.className||"",r))??(i.className?e.parseClassName(i.className):{});i.rawStyle&&Object.assign(c,i.rawStyle);const h=e.getCommonProps(r,c,i),a=Array.isArray(i.children)?i.children.map((f,p)=>e.renderComponent(f,p,r)):[],u=i.motion?{motion:i.motion,initial:i.initial,animate:i.animate,exit:i.exit,transition:i.transition,variants:i.variants,whileHover:i.whileHover,whileTap:i.whileTap,whileFocus:i.whileFocus,whileInView:i.whileInView,animateLayout:i.animateLayout}:{};return E(l,{key:r,className:i.className,...h,...u},...a)}if(/^h[1-6]$/.test(i.type)||i.type==="p"||i.type==="span"||i.type==="label"||i.type==="blockquote"||i.type==="strong"||i.type==="em"||i.type==="li"||i.type==="figcaption"||i.type==="th"||i.type==="td"||i.type==="heading"||i.type==="paragraph"||i.type==="address"||i.type==="time"||i.type==="legend"||i.type==="caption"?i.type="text":i.type==="div"||i.type==="article"||i.type==="aside"||i.type==="main"||i.type==="figure"?i.type=i.children?"section":"text":i.type==="a"?i.type="link":i.type==="img"?i.type="image":i.type==="ul"||i.type==="ol"?i.type="list":i.type==="table"||i.type==="thead"||i.type==="tbody"||i.type==="tfoot"||i.type==="tr"?i.type="table":i.type==="br"?i.type="spacer":i.type==="hr"?i.type="divider":i.type==="details"||i.type==="summary"?i.type=i.children?"section":"text":i.type==="nav"?i.type="section":(i.type==="form"&&!i.fields||i.type==="listItem")&&(i.type=i.children?"section":"text"),i.type==="select"&&Array.isArray(i.options)&&typeof i.options[0]=="string"&&(i.options=i.options.map(l=>({label:l,value:l}))),i.type==="dropdown-button"&&!i.items&&i.options&&(i.items=Array.isArray(i.options)&&typeof i.options[0]=="string"?i.options.map(l=>({label:l,value:l})):i.options),(i.type==="input"||i.type==="textarea")&&!i.placeholder&&i.label&&(i.placeholder=i.label),e.imageReplacements&&e.imageReplacements.size>0){const l=e.imageReplacements.get(r);if(l&&l.url){const c={width:"100%",height:"auto",maxHeight:"300px",objectFit:"cover",borderRadius:"0.75rem"},h=e.getCommonProps(r,c,i),a=i.motion?{motion:i.motion,initial:i.initial,animate:i.animate,whileHover:i.whileHover,whileTap:i.whileTap,transition:i.transition,animateLayout:i.animateLayout}:{};return E("img",{key:`${r}-${l.url}`,src:l.url,alt:l.name||"Replacement image",...h,...a})}}switch(i.type){case"text":return lt(i,Jw(e,i,r));case"html":return lt(i,Zw(e,i,r));case"link":return lt(i,t1(e,i,r));case"button":return lt(i,e1(e,i,r));case"image":return lt(i,n1(e,i,r));case"input":return lt(i,s1(e,i,r));case"hidden":return lt(i,i1(e,i,r));case"select":return lt(i,r1(e,i,r));case"checkbox":return lt(i,o1(e,i,r));case"card":return lt(i,J1(e,i,r));case"section":case"container":case"cta_section":return lt(i,K1(e,i,r));case"header":return lt(i,eS(e,i,r));case"grid":case"features_grid":return lt(i,Z1(e,i,r));case"hero":return lt(i,tS(e,i,r));case"footer":return lt(i,nS(e,i,r));case"spacer":return lt(i,g1(e,i,r));case"divider":return lt(i,y1(e,i,r));case"list":return lt(i,fv(e,i,r));case"table":return lt(i,pv(e,i,r));case"badge":return lt(i,a1(e,i,r));case"tag":return lt(i,l1(e,i,r));case"avatar":return lt(i,c1(e,i,r));case"progress":return lt(i,h1(e,i,r));case"recorder":return m.createElement(G1,{api:e,config:i,key:r});case"live-cast":return m.createElement(Y1,{api:e,config:i,componentKey:r,key:r});case"tabs":return lt(i,uv(e,i,r));case"accordion":return lt(i,dv(e,i,r));case"bottom_nav":return lt(i,U1(e,i,r));case"split":return lt(i,H1(e,i,r));case"theme_toggle":return lt(i,q1(e,i,r));case"slider":case"carousel":return lt(i,f1(e,i,r));case"marquee":return lt(i,m1(e,i,r));case"camera":case"capture":return lt(i,p1(e,i,r));case"phaser_game":return lt(i,e.renderPhaserGame?e.renderPhaserGame(i,r):null);case"search":return lt(i,u1(e,i,r));case"breadcrumb":return lt(i,d1(e,i,r));case"form":return lt(i,L1(e,i,r));case"textarea":return lt(i,v1(e,i,r));case"icon":return lt(i,x1(e,i,r));case"markdown":return lt(i,O1(e,i,r));case"dropdown-button":return lt(i,$1(e,i,r));case"widget":return lt(i,N1(e,i,r));case"advanced-select":return lt(i,I1(e,i,r));case"metric_display":return lt(i,w1(e,i,r));case"bar_chart":return lt(i,S1(e,i,r));case"line_chart":return lt(i,Go(e,i,r,!1));case"area_chart":return lt(i,Go(e,i,r,!0));case"candlestick":return lt(i,Go(e,i,r,!1,!0));case"fx_ticker":return lt(i,C1(e,i,r));case"trading_view":return lt(i,M1(e,i,r));case"loader":return lt(i,b1(e,i,r));case"flow_diagram":return lt(i,E1(e,i,r));case"flow":return lt(i,A1(e,i,r));default:return lt(i,R1(e,i,r))}}function gm(e){const t=new Map,n=new Map;for(const s of e)if(s.type==="render_scene"&&s.route){const i=s.route.startsWith("/")?s.route:`/${s.route}`;t.set(s.id,i),n.set(i,s.id)}for(const s of e)if(s.type==="render_scene"&&!t.has(s.id)){const i=`/${s.id}`;t.set(s.id,i),n.set(i,s.id)}return{sceneToRoute:t,routeToScene:n}}function Ta(e){if(typeof window>"u")return null;const t=window.location.hash;if(!t||t==="#")return null;const n=t.slice(1);return e.get(n)||null}function kr(e,t,n=!1){if(typeof window>"u")return;const s=t.get(e);if(!s)return;const i=`#${s}`;window.location.hash!==i&&(n?window.history.replaceState({sceneId:e},"",i):window.history.pushState({sceneId:e},"",i))}const iS=()=>{try{if(typeof window<"u")return window.localStorage.getItem("backflow_dev_diagnostics")==="1"}catch{}return!1};async function Mr(e,t,n={},s){var i;try{const r=t.indexOf(".");if(r===-1)throw new Error(`Invalid SDK call syntax: ${t}`);const o=t.slice(0,r),l=t.slice(r+1),c=l.indexOf("(");if(c===-1)throw new Error(`Invalid SDK call syntax (missing parentheses): ${t}`);const h=l.slice(0,c),a=l.slice(c+1,-1),u=rS(a,n);let f=e[o];if(!f)throw new Error(`Unknown SDK resource: ${String(o)}`);const p=h.split(".");for(let w=0;w<p.length-1;w++){const C=p[w];if(C&&(f=f[C],!f))throw new Error(`Unknown path ${p.slice(0,w+1).join(".")} on resource ${String(o)}`)}const g=p[p.length-1],d=f[g];if(typeof d!="function")throw new Error(`Unknown method ${g} on ${String(o)}.${p.slice(0,-1).join(".")}`);return await d.apply(f,u)}catch(r){throw iS()&&console.error("[SDK Executor] Error:",r),(i=s==null?void 0:s.onError)==null||i.call(s,r),r}}function rS(e,t){if(!e.trim())return[];const s=e.replace(/\{\{([\w.]+)\}\}/g,(i,r)=>{if(r==="now")return JSON.stringify(new Date().toISOString());const o=aS(t,r);return o===void 0?"null":typeof o=="string"?`"${o}"`:JSON.stringify(o)}).replace(/([{,]\s*)([A-Za-z_$][\w$]*)\s*:/g,'$1"$2":').replace(/'((?:[^'\\]|\\.)*)'/g,(i,r)=>`"${r.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}"`);try{return JSON.parse(`[${s}]`)}catch{return oS(s).map(i=>{const r=i.trim();if(r.startsWith("'")&&r.endsWith("'")||r.startsWith('"')&&r.endsWith('"'))return r.slice(1,-1);if(!isNaN(Number(r)))return Number(r);if(r==="true")return!0;if(r==="false")return!1;if(r==="null")return null;try{return JSON.parse(r)}catch{return r}})}}function oS(e){const t=[];let n="",s=0,i=null;for(let r=0;r<e.length;r++){const o=e[r],l=e[r-1];if((o==='"'||o==="'")&&l!=="\\"&&(i===o?i=null:i||(i=o)),!i&&((o==="{"||o==="["||o==="(")&&s++,(o==="}"||o==="]"||o===")")&&s--,o===","&&s===0)){t.push(n),n="";continue}n+=o}return n.trim()&&t.push(n),t}function aS(e,t){const n=t.split(".");let s=e;for(const i of n){if(s==null)return;s=s[i]}return s}function Ci(e){return e.startsWith("sdk:")}function pi(e){return Ci(e)?e.slice(4):e}function lS(e,t,...n){const s=n.map(i=>typeof i=="string"?`'${i}'`:JSON.stringify(i)).join(", ");return`sdk:${e}.${t}(${s})`}function cS(e,t){const n=new Map,s=(i,r)=>{r.size>0&&n.set(i,r)};return s("--bf-fd",e.flexDirection),s("--bf-gap",e.gap),s("--bf-w",e.width),s("--bf-items",e.alignItems),s("--bf-justify",e.justifyContent),s("--bf-display",e.display),s("--bf-cols",e.gridCols),s("--bf-text",e.textSize),s("--bf-radius",e.borderRadius),e.padding.p.size>0&&s("--bf-p",e.padding.p),e.padding.px.size>0&&s("--bf-px",e.padding.px),e.padding.py.size>0&&s("--bf-py",e.padding.py),e.margin.all.size>0&&s("--bf-m",e.margin.all),e.margin.t.size>0&&s("--bf-mt",e.margin.t),e.margin.r.size>0&&s("--bf-mr",e.margin.r),e.margin.b.size>0&&s("--bf-mb",e.margin.b),e.margin.l.size>0&&s("--bf-ml",e.margin.l),e.margin.x.size>0&&s("--bf-mx",e.margin.x),e.margin.y.size>0&&s("--bf-my",e.margin.y),n}function hS(e,t){const n=String(t).replace(/[^a-zA-Z0-9_-]/g,"_");return`${e}-${n}`}function ym(e,t,n){const s=cS(n);if(s.size===0)return"";const i=`[data-bf-r="${e}-${t}"]`,r=[];for(const o of Rf){if(o==="base")continue;const l=Af[o],c=[];for(const[h,a]of s)a.has(o)&&(hS(h,t),c.push(` ${h.replace("--bf-","--bf-")}: ${a.get(o)};`));c.length>0&&r.push(`@media (min-width: ${l}px) {
18
- ${i} {
19
- ${c.join(`
15
+ */const Km={title:"",visible:!0,hitTestTolerance:3,lastValueVisible:!0,priceLineVisible:!0,priceLineSource:0,priceLineWidth:1,priceLineColor:"",priceLineStyle:2,baseLineVisible:!0,baseLineWidth:1,baseLineColor:"#B2B5BE",baseLineStyle:0,priceFormat:{type:"price",precision:2,minMove:.01}};var Xu,Ju;function hs(e,t){const n=function(i,r){switch(i){case 0:default:return[];case 1:return[r,r];case 2:return[2*r,2*r];case 3:return[6*r,6*r];case 4:return[r,4*r]}}(t,e.lineWidth);return e.setLineDash(n),n}function tp(e,t,n,i){e.beginPath();const r=e.lineWidth%2?.5:0;e.moveTo(n,t+r),e.lineTo(i,t+r),e.stroke()}function Je(e,t){if(!e)throw new Error("Assertion failed"+(t?": "+t:""))}function xn(e){if(e===void 0)throw new Error("Value is undefined");return e}function ut(e){if(e===null)throw new Error("Value is null");return e}function ss(e){return ut(xn(e))}(function(e){e[e.Simple=0]="Simple",e[e.WithSteps=1]="WithSteps",e[e.Curved=2]="Curved"})(Xu||(Xu={})),function(e){e[e.Solid=0]="Solid",e[e.Dotted=1]="Dotted",e[e.Dashed=2]="Dashed",e[e.LargeDashed=3]="LargeDashed",e[e.SparseDotted=4]="SparseDotted"}(Ju||(Ju={}));class Ae{constructor(){this.t=[]}i(t,n,i){const r={h:t,l:n,o:i===!0};this.t.push(r)}_(t){const n=this.t.findIndex(i=>t===i.h);n>-1&&this.t.splice(n,1)}u(t){this.t=this.t.filter(n=>n.l!==t)}p(t,n,i){const r=[...this.t];this.t=this.t.filter(o=>!o.o),r.forEach(o=>o.h(t,n,i))}v(){return this.t.length>0}m(){this.t=[]}}function Mn(e,...t){for(const n of t)for(const i in n)n[i]!==void 0&&Object.prototype.hasOwnProperty.call(n,i)&&!["__proto__","constructor","prototype"].includes(i)&&(typeof n[i]!="object"||e[i]===void 0||Array.isArray(n[i])?e[i]=n[i]:Mn(e[i],n[i]));return e}function Sr(e){return typeof e=="number"&&isFinite(e)}function bo(e){return typeof e=="number"&&e%1==0}function ko(e){return typeof e=="string"}function Xo(e){return typeof e=="boolean"}function Ei(e){const t=e;if(!t||typeof t!="object")return t;let n,i,r;for(i in n=Array.isArray(t)?[]:{},t)t.hasOwnProperty(i)&&(r=t[i],n[i]=r&&typeof r=="object"?Ei(r):r);return n}function Qu(e){return e!==null}function xo(e){return e===null?void 0:e}const ep="-apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif";function Ca(e,t,n){return t===void 0&&(t=ep),`${n=n!==void 0?`${n} `:""}${e}px ${t}`}class xx{constructor(t){this.M={S:1,C:5,P:NaN,k:"",T:"",R:"",D:"",I:0,V:0,B:0,A:0,L:0},this.O=t}N(){const t=this.M,n=this.F(),i=this.W();return t.P===n&&t.T===i||(t.P=n,t.T=i,t.k=Ca(n,i),t.A=2.5/12*n,t.I=t.A,t.V=n/12*t.C,t.B=n/12*t.C,t.L=0),t.R=this.H(),t.D=this.U(),this.M}H(){return this.O.N().layout.textColor}U(){return this.O.$()}F(){return this.O.N().layout.fontSize}W(){return this.O.N().layout.fontFamily}}function yl(e){return e<0?0:e>255?255:Math.round(e)||0}function Ku(e){return .199*e[0]+.687*e[1]+.114*e[2]}class _x{constructor(t,n){this.j=new Map,this.q=t,n&&(this.j=n)}Y(t,n){if(t==="transparent")return t;const i=this.K(t),r=i[3];return`rgba(${i[0]}, ${i[1]}, ${i[2]}, ${n*r})`}G(t){const n=this.K(t);return{Z:`rgb(${n[0]}, ${n[1]}, ${n[2]})`,X:Ku(n)>160?"black":"white"}}J(t){return Ku(this.K(t))}tt(t,n,i){const[r,o,l,h]=this.K(t),[u,f,c,m]=this.K(n),y=[yl(r+i*(u-r)),yl(o+i*(f-o)),yl(l+i*(c-l)),(x=h+i*(m-h),x<=0||x>1?Math.min(Math.max(x,0),1):Math.round(1e4*x)/1e4)];var x;return`rgba(${y[0]}, ${y[1]}, ${y[2]}, ${y[3]})`}K(t){const n=this.j.get(t);if(n)return n;const i=function(l){const h=document.createElement("div");h.style.display="none",document.body.appendChild(h),h.style.color=l;const u=window.getComputedStyle(h).color;return document.body.removeChild(h),u}(t),r=i.match(/^rgba?\s*\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d*\.?\d+))?\)$/);if(!r){if(this.q.length)for(const l of this.q){const h=l(t);if(h)return this.j.set(t,h),h}throw new Error(`Failed to parse color: ${t}`)}const o=[parseInt(r[1],10),parseInt(r[2],10),parseInt(r[3],10),r[4]?parseFloat(r[4]):1];return this.j.set(t,o),o}}class wx{constructor(){this.it=[]}nt(t){this.it=t}st(t,n,i){this.it.forEach(r=>{r.st(t,n,i)})}}class ds{st(t,n,i){t.useBitmapCoordinateSpace(r=>this.et(r,n,i))}}class Sx extends ds{constructor(){super(...arguments),this.rt=null}ht(t){this.rt=t}et({context:t,horizontalPixelRatio:n,verticalPixelRatio:i}){if(this.rt===null||this.rt.lt===null)return;const r=this.rt.lt,o=this.rt,l=Math.max(1,Math.floor(n))%2/2,h=u=>{t.beginPath();for(let f=r.to-1;f>=r.from;--f){const c=o.ot[f],m=Math.round(c._t*n)+l,y=c.ut*i,x=u*i+l;t.moveTo(m,y),t.arc(m,y,x,0,2*Math.PI)}t.fill()};o.ct>0&&(t.fillStyle=o.dt,h(o.ft+o.ct)),t.fillStyle=o.vt,h(o.ft)}}function Cx(){return{ot:[{_t:0,ut:0,wt:0,Mt:0}],vt:"",dt:"",ft:0,ct:0,lt:null}}const Mx={from:0,to:1};class kx{constructor(t,n,i){this.gt=new wx,this.bt=[],this.St=[],this.xt=!0,this.O=t,this.Ct=n,this.yt=i,this.gt.nt(this.bt)}Pt(t){this.kt(),this.xt=!0}Tt(){return this.xt&&(this.Rt(),this.xt=!1),this.gt}kt(){const t=this.yt.Dt();t.length!==this.bt.length&&(this.St=t.map(Cx),this.bt=this.St.map(n=>{const i=new Sx;return i.ht(n),i}),this.gt.nt(this.bt))}Rt(){const t=this.Ct.N().mode===2||!this.Ct.It(),n=this.yt.Vt(),i=this.Ct.Bt(),r=this.O.Et();this.kt(),n.forEach((o,l)=>{const h=this.St[l],u=o.At(i),f=o.Lt();!t&&u!==null&&o.It()&&f!==null?(h.vt=u.zt,h.ft=u.ft,h.ct=u.Ot,h.ot[0].Mt=u.Mt,h.ot[0].ut=o.Ft().Nt(u.Mt,f.Wt),h.dt=u.Ht??this.O.Ut(h.ot[0].ut/o.Ft().$t()),h.ot[0].wt=i,h.ot[0]._t=r.jt(i),h.lt=Mx):h.lt=null})}}class Tx extends ds{constructor(t){super(),this.qt=t}et({context:t,bitmapSize:n,horizontalPixelRatio:i,verticalPixelRatio:r}){if(this.qt===null)return;const o=this.qt.Yt.It,l=this.qt.Kt.It;if(!o&&!l)return;const h=Math.round(this.qt._t*i),u=Math.round(this.qt.ut*r);t.lineCap="butt",o&&h>=0&&(t.lineWidth=Math.floor(this.qt.Yt.ct*i),t.strokeStyle=this.qt.Yt.R,t.fillStyle=this.qt.Yt.R,hs(t,this.qt.Yt.Gt),function(f,c,m,y){f.beginPath();const x=f.lineWidth%2?.5:0;f.moveTo(c+x,m),f.lineTo(c+x,y),f.stroke()}(t,h,0,n.height)),l&&u>=0&&(t.lineWidth=Math.floor(this.qt.Kt.ct*r),t.strokeStyle=this.qt.Kt.R,t.fillStyle=this.qt.Kt.R,hs(t,this.qt.Kt.Gt),tp(t,u,0,n.width))}}class Px{constructor(t,n){this.xt=!0,this.Zt={Yt:{ct:1,Gt:0,R:"",It:!1},Kt:{ct:1,Gt:0,R:"",It:!1},_t:0,ut:0},this.Xt=new Tx(this.Zt),this.Jt=t,this.yt=n}Pt(){this.xt=!0}Tt(t){return this.xt&&(this.Rt(),this.xt=!1),this.Xt}Rt(){const t=this.Jt.It(),n=this.yt.Qt().N().crosshair,i=this.Zt;if(n.mode===2)return i.Kt.It=!1,void(i.Yt.It=!1);i.Kt.It=t&&this.Jt.ti(this.yt),i.Yt.It=t&&this.Jt.ii(),i.Kt.ct=n.horzLine.width,i.Kt.Gt=n.horzLine.style,i.Kt.R=n.horzLine.color,i.Yt.ct=n.vertLine.width,i.Yt.Gt=n.vertLine.style,i.Yt.R=n.vertLine.color,i._t=this.Jt.ni(),i.ut=this.Jt.si()}}function Ex(e,t,n,i,r,o){e.fillRect(t+o,n,i-2*o,o),e.fillRect(t+o,n+r-o,i-2*o,o),e.fillRect(t,n,o,r),e.fillRect(t+i-o,n,o,r)}function Ba(e,t,n,i,r,o){e.save(),e.globalCompositeOperation="copy",e.fillStyle=o,e.fillRect(t,n,i,r),e.restore()}function td(e,t,n,i,r,o){e.beginPath(),e.roundRect?e.roundRect(t,n,i,r,o):(e.lineTo(t+i-o[1],n),o[1]!==0&&e.arcTo(t+i,n,t+i,n+o[1],o[1]),e.lineTo(t+i,n+r-o[2]),o[2]!==0&&e.arcTo(t+i,n+r,t+i-o[2],n+r,o[2]),e.lineTo(t+o[3],n+r),o[3]!==0&&e.arcTo(t,n+r,t,n+r-o[3],o[3]),e.lineTo(t,n+o[0]),o[0]!==0&&e.arcTo(t,n,t+o[0],n,o[0]))}function ed(e,t,n,i,r,o,l=0,h=[0,0,0,0],u=""){if(e.save(),!l||!u||u===o)return td(e,t,n,i,r,h),e.fillStyle=o,e.fill(),void e.restore();const f=l/2;var c;td(e,t+f,n+f,i-l,r-l,(c=-f,h.map(m=>m===0?m:m+c))),o!=="transparent"&&(e.fillStyle=o,e.fill()),u!=="transparent"&&(e.lineWidth=l,e.strokeStyle=u,e.closePath(),e.stroke()),e.restore()}function np(e,t,n,i,r,o,l){e.save(),e.globalCompositeOperation="copy";const h=e.createLinearGradient(0,0,0,r);h.addColorStop(0,o),h.addColorStop(1,l),e.fillStyle=h,e.fillRect(t,n,i,r),e.restore()}class nd{constructor(t,n){this.ht(t,n)}ht(t,n){this.qt=t,this.ei=n}$t(t,n){return this.qt.It?t.P+t.A+t.I:0}st(t,n,i,r){if(!this.qt.It||this.qt.ri.length===0)return;const o=this.qt.R,l=this.ei.Z,h=t.useBitmapCoordinateSpace(u=>{const f=u.context;f.font=n.k;const c=this.hi(u,n,i,r),m=c.ai;return c.li?ed(f,m.oi,m._i,m.ui,m.ci,l,m.di,[m.ft,0,0,m.ft],l):ed(f,m.fi,m._i,m.ui,m.ci,l,m.di,[0,m.ft,m.ft,0],l),this.qt.pi&&(f.fillStyle=o,f.fillRect(m.fi,m.mi,m.wi-m.fi,m.Mi)),this.qt.gi&&(f.fillStyle=n.D,f.fillRect(c.li?m.bi-m.di:0,m._i,m.di,m.Si-m._i)),c});t.useMediaCoordinateSpace(({context:u})=>{const f=h.xi;u.font=n.k,u.textAlign=h.li?"right":"left",u.textBaseline="middle",u.fillStyle=o,u.fillText(this.qt.ri,f.Ci,(f._i+f.Si)/2+f.yi)})}hi(t,n,i,r){const{context:o,bitmapSize:l,mediaSize:h,horizontalPixelRatio:u,verticalPixelRatio:f}=t,c=this.qt.pi||!this.qt.Pi?n.C:0,m=this.qt.ki?n.S:0,y=n.A+this.ei.Ti,x=n.I+this.ei.Ri,_=n.V,p=n.B,E=this.qt.ri,T=n.P,k=i.Di(o,E),A=Math.ceil(i.Ii(o,E)),P=T+y+x,I=n.S+_+p+A+c,$=Math.max(1,Math.floor(f));let j=Math.round(P*f);j%2!=$%2&&(j+=1);const U=m>0?Math.max(1,Math.floor(m*u)):0,nt=Math.round(I*u),ot=Math.round(c*u),q=this.ei.Vi??this.ei.Bi??this.ei.Ei,it=Math.round(q*f)-Math.floor(.5*f),ct=Math.floor(it+$/2-j/2),K=ct+j,Z=r==="right",tt=Z?h.width-m:m,st=Z?l.width-U:U;let J,bt,et;return Z?(J=st-nt,bt=st-ot,et=tt-c-_-m):(J=st+nt,bt=st+ot,et=tt+c+_),{li:Z,ai:{_i:ct,mi:it,Si:K,ui:nt,ci:j,ft:2*u,di:U,oi:J,fi:st,wi:bt,Mi:$,bi:l.width},xi:{_i:ct/f,Si:K/f,Ci:et,yi:k}}}}class Oa{constructor(t){this.Ai={Ei:0,Z:"#000",Ri:0,Ti:0},this.Li={ri:"",It:!1,pi:!0,Pi:!1,Ht:"",R:"#FFF",gi:!1,ki:!1},this.zi={ri:"",It:!1,pi:!1,Pi:!0,Ht:"",R:"#FFF",gi:!0,ki:!0},this.xt=!0,this.Oi=new(t||nd)(this.Li,this.Ai),this.Ni=new(t||nd)(this.zi,this.Ai)}ri(){return this.Fi(),this.Li.ri}Ei(){return this.Fi(),this.Ai.Ei}Pt(){this.xt=!0}$t(t,n=!1){return Math.max(this.Oi.$t(t,n),this.Ni.$t(t,n))}Wi(){return this.Ai.Vi??null}Hi(){return this.Ai.Vi??this.Ai.Bi??this.Ei()}Ui(t){this.Ai.Bi=t??void 0}$i(){return this.Fi(),this.Li.It||this.zi.It}ji(){return this.Fi(),this.Li.It}Tt(t){return this.Fi(),this.Li.pi=this.Li.pi&&t.N().ticksVisible,this.zi.pi=this.zi.pi&&t.N().ticksVisible,this.Oi.ht(this.Li,this.Ai),this.Ni.ht(this.zi,this.Ai),this.Oi}qi(){return this.Fi(),this.Oi.ht(this.Li,this.Ai),this.Ni.ht(this.zi,this.Ai),this.Ni}Fi(){this.xt&&(this.Li.pi=!0,this.zi.pi=!1,this.Yi(this.Li,this.zi,this.Ai))}}class Lx extends Oa{constructor(t,n,i){super(),this.Jt=t,this.Ki=n,this.Gi=i}Yi(t,n,i){if(t.It=!1,this.Jt.N().mode===2)return;const r=this.Jt.N().horzLine;if(!r.labelVisible)return;const o=this.Ki.Lt();if(!this.Jt.It()||this.Ki.Zi()||o===null)return;const l=this.Ki.Xi().G(r.labelBackgroundColor);i.Z=l.Z,t.R=l.X;const h=2/12*this.Ki.P();i.Ti=h,i.Ri=h;const u=this.Gi(this.Ki);i.Ei=u.Ei,t.ri=this.Ki.Ji(u.Mt,o),t.It=!0}}const Ax=/[1-9]/g;class ip{constructor(){this.qt=null}ht(t){this.qt=t}st(t,n){if(this.qt===null||this.qt.It===!1||this.qt.ri.length===0)return;const i=t.useMediaCoordinateSpace(({context:y})=>(y.font=n.k,Math.round(n.Qi.Ii(y,ut(this.qt).ri,Ax))));if(i<=0)return;const r=n.tn,o=i+2*r,l=o/2,h=this.qt.nn;let u=this.qt.Ei,f=Math.floor(u-l)+.5;f<0?(u+=Math.abs(0-f),f=Math.floor(u-l)+.5):f+o>h&&(u-=Math.abs(h-(f+o)),f=Math.floor(u-l)+.5);const c=f+o,m=Math.ceil(0+n.S+n.C+n.A+n.P+n.I);t.useBitmapCoordinateSpace(({context:y,horizontalPixelRatio:x,verticalPixelRatio:_})=>{const p=ut(this.qt);y.fillStyle=p.Z;const E=Math.round(f*x),T=Math.round(0*_),k=Math.round(c*x),A=Math.round(m*_),P=Math.round(2*x);if(y.beginPath(),y.moveTo(E,T),y.lineTo(E,A-P),y.arcTo(E,A,E+P,A,P),y.lineTo(k-P,A),y.arcTo(k,A,k,A-P,P),y.lineTo(k,T),y.fill(),p.pi){const I=Math.round(p.Ei*x),$=T,j=Math.round(($+n.C)*_);y.fillStyle=p.R;const U=Math.max(1,Math.floor(x)),nt=Math.floor(.5*x);y.fillRect(I-nt,$,U,j-$)}}),t.useMediaCoordinateSpace(({context:y})=>{const x=ut(this.qt),_=0+n.S+n.C+n.A+n.P/2;y.font=n.k,y.textAlign="left",y.textBaseline="middle",y.fillStyle=x.R;const p=n.Qi.Di(y,"Apr0");y.translate(f+r,_+p),y.fillText(x.ri,0,0)})}}class Rx{constructor(t,n,i){this.xt=!0,this.Xt=new ip,this.Zt={It:!1,Z:"#4c525e",R:"white",ri:"",nn:0,Ei:NaN,pi:!0},this.Ct=t,this.sn=n,this.Gi=i}Pt(){this.xt=!0}Tt(){return this.xt&&(this.Rt(),this.xt=!1),this.Xt.ht(this.Zt),this.Xt}Rt(){const t=this.Zt;if(t.It=!1,this.Ct.N().mode===2)return;const n=this.Ct.N().vertLine;if(!n.labelVisible)return;const i=this.sn.Et();if(i.Zi())return;t.nn=i.nn();const r=this.Gi();if(r===null)return;t.Ei=r.Ei;const o=i.en(this.Ct.Bt());t.ri=i.rn(ut(o)),t.It=!0;const l=this.sn.Xi().G(n.labelBackgroundColor);t.Z=l.Z,t.R=l.X,t.pi=i.N().ticksVisible}}class sp{constructor(){this.hn=null,this.an=0}ln(){return this.an}_n(t){this.an=t}Ft(){return this.hn}un(t){this.hn=t}cn(t){return[]}dn(){return[]}It(){return!0}}var id;(function(e){e[e.Normal=0]="Normal",e[e.Magnet=1]="Magnet",e[e.Hidden=2]="Hidden",e[e.MagnetOHLC=3]="MagnetOHLC"})(id||(id={}));class Nx extends sp{constructor(t,n){super(),this.yt=null,this.fn=NaN,this.pn=0,this.vn=!1,this.mn=new Map,this.wn=!1,this.Mn=new WeakMap,this.gn=new WeakMap,this.bn=NaN,this.Sn=NaN,this.xn=NaN,this.Cn=NaN,this.sn=t,this.yn=n,this.Pn=((r,o)=>l=>{const h=o(),u=r();if(l===ut(this.yt).kn())return{Mt:u,Ei:h};{const f=ut(l.Lt());return{Mt:l.Tn(h,f),Ei:h}}})(()=>this.fn,()=>this.Sn);const i=((r,o)=>()=>{const l=this.sn.Et().Rn(r()),h=o();return l&&Number.isFinite(h)?{wt:l,Ei:h}:null})(()=>this.pn,()=>this.ni());this.Dn=new Rx(this,t,i)}N(){return this.yn}In(t,n){this.xn=t,this.Cn=n}Vn(){this.xn=NaN,this.Cn=NaN}Bn(){return this.xn}En(){return this.Cn}An(t,n,i){this.wn||(this.wn=!0),this.vn=!0,this.Ln(t,n,i)}Bt(){return this.pn}ni(){return this.bn}si(){return this.Sn}It(){return this.vn}zn(){this.vn=!1,this.On(),this.fn=NaN,this.bn=NaN,this.Sn=NaN,this.yt=null,this.Vn(),this.Nn()}Fn(t){if(!this.yn.doNotSnapToHiddenSeriesIndices)return t;const n=this.sn,i=n.Et();let r=null,o=null;for(const f of n.Wn()){const c=f.Un().Hn(t,-1);if(c){if(c.$n===t)return t;(r===null||c.$n>r)&&(r=c.$n)}const m=f.Un().Hn(t,1);if(m){if(m.$n===t)return t;(o===null||m.$n<o)&&(o=m.$n)}}const l=[r,o].filter(Qu);if(l.length===0)return t;const h=i.jt(t),u=l.map(f=>Math.abs(h-i.jt(f)));return l[u.indexOf(Math.min(...u))]}jn(t){let n=this.Mn.get(t);n||(n=new Px(this,t),this.Mn.set(t,n));let i=this.gn.get(t);return i||(i=new kx(this.sn,this,t),this.gn.set(t,i)),[n,i]}ti(t){return t===this.yt&&this.yn.horzLine.visible}ii(){return this.yn.vertLine.visible}qn(t,n){this.vn&&this.yt===t||this.mn.clear();const i=[];return this.yt===t&&i.push(this.Yn(this.mn,n,this.Pn)),i}dn(){return this.vn?[this.Dn]:[]}Kn(){return this.yt}Nn(){this.sn.Gn().forEach(t=>{var n,i;(n=this.Mn.get(t))==null||n.Pt(),(i=this.gn.get(t))==null||i.Pt()}),this.mn.forEach(t=>t.Pt()),this.Dn.Pt()}Zn(t){return t&&!t.kn().Zi()?t.kn():null}Ln(t,n,i){this.Xn(t,n,i)&&this.Nn()}Xn(t,n,i){const r=this.bn,o=this.Sn,l=this.fn,h=this.pn,u=this.yt,f=this.Zn(i);this.pn=t,this.bn=isNaN(t)?NaN:this.sn.Et().jt(t),this.yt=i;const c=f!==null?f.Lt():null;return f!==null&&c!==null?(this.fn=n,this.Sn=f.Nt(n,c)):(this.fn=NaN,this.Sn=NaN),r!==this.bn||o!==this.Sn||h!==this.pn||l!==this.fn||u!==this.yt}On(){const t=this.sn.Jn().map(i=>i.Un().Qn()).filter(Qu),n=t.length===0?null:Math.max(...t);this.pn=n!==null?n:NaN}Yn(t,n,i){let r=t.get(n);return r===void 0&&(r=new Lx(this,n,i),t.set(n,r)),r}}function Fa(e){return e==="left"||e==="right"}class Ye{constructor(t){this.ts=new Map,this.ns=[],this.ss=t}es(t,n){const i=function(r,o){return r===void 0?o:{rs:Math.max(r.rs,o.rs),hs:r.hs||o.hs}}(this.ts.get(t),n);this.ts.set(t,i)}ls(){return this.ss}_s(t){const n=this.ts.get(t);return n===void 0?{rs:this.ss}:{rs:Math.max(this.ss,n.rs),hs:n.hs}}us(){this.cs(),this.ns=[{ds:0}]}fs(t){this.cs(),this.ns=[{ds:1,Wt:t}]}ps(t){this.vs(),this.ns.push({ds:5,Wt:t})}cs(){this.vs(),this.ns.push({ds:6})}ws(){this.cs(),this.ns=[{ds:4}]}Ms(t){this.cs(),this.ns.push({ds:2,Wt:t})}gs(t){this.cs(),this.ns.push({ds:3,Wt:t})}bs(){return this.ns}Ss(t){for(const n of t.ns)this.xs(n);this.ss=Math.max(this.ss,t.ss),t.ts.forEach((n,i)=>{this.es(i,n)})}static Cs(){return new Ye(2)}static ys(){return new Ye(3)}xs(t){switch(t.ds){case 0:this.us();break;case 1:this.fs(t.Wt);break;case 2:this.Ms(t.Wt);break;case 3:this.gs(t.Wt);break;case 4:this.ws();break;case 5:this.ps(t.Wt);break;case 6:this.vs()}}vs(){const t=this.ns.findIndex(n=>n.ds===5);t!==-1&&this.ns.splice(t,1)}}class rp{formatTickmarks(t){return t.map(n=>this.format(n))}}const sd=".";function Li(e,t){if(!Sr(e))return"n/a";if(!bo(t))throw new TypeError("invalid length");if(t<0||t>16)throw new TypeError("invalid length");return t===0?e.toString():("0000000000000000"+e.toString()).slice(-t)}class Wa extends rp{constructor(t,n){if(super(),n||(n=1),Sr(t)&&bo(t)||(t=100),t<0)throw new TypeError("invalid base");this.Ki=t,this.Ps=n,this.ks()}format(t){const n=t<0?"−":"";return t=Math.abs(t),n+this.Ts(t)}ks(){if(this.Rs=0,this.Ki>0&&this.Ps>0){let t=this.Ki;for(;t>1;)t/=10,this.Rs++}}Ts(t){const n=this.Ki/this.Ps;let i=Math.floor(t),r="";const o=this.Rs!==void 0?this.Rs:NaN;if(n>1){let l=+(Math.round(t*n)-i*n).toFixed(this.Rs);l>=n&&(l-=n,i+=1),r=sd+Li(+l.toFixed(this.Rs)*this.Ps,o)}else i=Math.round(i*n)/n,o>0&&(r=sd+Li(0,o));return i.toFixed(0)+r}}class op extends Wa{constructor(t=100){super(t)}format(t){return`${super.format(t)}%`}}class Ix extends rp{constructor(t){super(),this.Ds=t}format(t){let n="";return t<0&&(n="-",t=-t),t<995?n+this.Is(t):t<999995?n+this.Is(t/1e3)+"K":t<999999995?(t=1e3*Math.round(t/1e3),n+this.Is(t/1e6)+"M"):(t=1e6*Math.round(t/1e6),n+this.Is(t/1e9)+"B")}Is(t){let n;const i=Math.pow(10,this.Ds);return n=(t=Math.round(t*i)/i)>=1e-15&&t<1?t.toFixed(this.Ds).replace(/\.?0+$/,""):String(t),n.replace(/(\.[1-9]*)0+$/,(r,o)=>o)}}const zx=/[2-9]/g;class Ma{constructor(t=50){this.Vs=0,this.Bs=1,this.Es=1,this.As={},this.Ls=new Map,this.zs=t}Os(){this.Vs=0,this.Ls.clear(),this.Bs=1,this.Es=1,this.As={}}Ii(t,n,i){return this.Ns(t,n,i).width}Di(t,n,i){const r=this.Ns(t,n,i);return((r.actualBoundingBoxAscent||0)-(r.actualBoundingBoxDescent||0))/2}Ns(t,n,i){const r=i||zx,o=String(n).replace(r,"0");if(this.Ls.has(o))return xn(this.Ls.get(o)).Fs;if(this.Vs===this.zs){const h=this.As[this.Es];delete this.As[this.Es],this.Ls.delete(h),this.Es++,this.Vs--}t.save(),t.textBaseline="middle";const l=t.measureText(o);return t.restore(),l.width===0&&n.length||(this.Ls.set(o,{Fs:l,Ws:this.Bs}),this.As[this.Bs]=o,this.Vs++,this.Bs++),l}}class Dx{constructor(t){this.Hs=null,this.M=null,this.Us="right",this.$s=t}js(t,n,i){this.Hs=t,this.M=n,this.Us=i}st(t){this.M!==null&&this.Hs!==null&&this.Hs.st(t,this.M,this.$s,this.Us)}}class ap{constructor(t,n,i){this.qs=t,this.$s=new Ma(50),this.Ys=n,this.O=i,this.F=-1,this.Xt=new Dx(this.$s)}Tt(){const t=this.O.Ks(this.Ys);if(t===null)return null;const n=t.Gs(this.Ys)?t.Zs():this.Ys.Ft();if(n===null)return null;const i=t.Xs(n);if(i==="overlay")return null;const r=this.O.Js();return r.P!==this.F&&(this.F=r.P,this.$s.Os()),this.Xt.js(this.qs.qi(),r,i),this.Xt}}class $x extends ds{constructor(){super(...arguments),this.qt=null}ht(t){this.qt=t}Qs(t,n){var l;if(!((l=this.qt)!=null&&l.It))return null;const{ut:i,ct:r,te:o}=this.qt;return n>=i-r-7&&n<=i+r+7?{ie:this.qt,ne:Math.abs(n-i),se:2,ee:"price-line",te:o}:null}et({context:t,bitmapSize:n,horizontalPixelRatio:i,verticalPixelRatio:r}){if(this.qt===null||this.qt.It===!1)return;const o=Math.round(this.qt.ut*r);o<0||o>n.height||(t.lineCap="butt",t.strokeStyle=this.qt.R,t.lineWidth=Math.floor(this.qt.ct*i),hs(t,this.qt.Gt),tp(t,o,0,n.width))}}class dh{constructor(t){this.re={ut:0,R:"rgba(0, 0, 0, 0)",ct:1,Gt:0,It:!1},this.he=new $x,this.xt=!0,this.ae=t,this.le=t.Qt(),this.he.ht(this.re)}Pt(){this.xt=!0}Tt(){return this.ae.It()?(this.xt&&(this.oe(),this.xt=!1),this.he):null}}class Bx extends dh{constructor(t){super(t)}oe(){this.re.It=!1;const t=this.ae.Ft(),n=t._e()._e;if(n!==2&&n!==3)return;const i=this.ae.N();if(!i.baseLineVisible||!this.ae.It())return;const r=this.ae.Lt();r!==null&&(this.re.It=!0,this.re.ut=t.Nt(r.Wt,r.Wt),this.re.R=i.baseLineColor,this.re.ct=i.baseLineWidth,this.re.Gt=i.baseLineStyle)}}class Ox extends ds{constructor(){super(...arguments),this.qt=null}ht(t){this.qt=t}ue(){return this.qt}et({context:t,horizontalPixelRatio:n,verticalPixelRatio:i}){const r=this.qt;if(r===null)return;const o=Math.max(1,Math.floor(n)),l=o%2/2,h=Math.round(r.ce.x*n)+l,u=r.ce.y*i;t.fillStyle=r.de,t.beginPath();const f=Math.max(2,1.5*r.fe)*n;t.arc(h,u,f,0,2*Math.PI,!1),t.fill(),t.fillStyle=r.pe,t.beginPath(),t.arc(h,u,r.ft*n,0,2*Math.PI,!1),t.fill(),t.lineWidth=o,t.strokeStyle=r.ve,t.beginPath(),t.arc(h,u,r.ft*n+o/2,0,2*Math.PI,!1),t.stroke()}}const Fx=[{me:0,we:.25,Me:4,ge:10,be:.25,Se:0,xe:.4,Ce:.8},{me:.25,we:.525,Me:10,ge:14,be:0,Se:0,xe:.8,Ce:0},{me:.525,we:1,Me:14,ge:14,be:0,Se:0,xe:0,Ce:0}];class Wx{constructor(t){this.Xt=new Ox,this.xt=!0,this.ye=!0,this.Pe=performance.now(),this.ke=this.Pe-1,this.Te=t}Re(){this.ke=this.Pe-1,this.Pt()}De(){if(this.Pt(),this.Te.N().lastPriceAnimation===2){const t=performance.now(),n=this.ke-t;if(n>0)return void(n<650&&(this.ke+=2600));this.Pe=t,this.ke=t+2600}}Pt(){this.xt=!0}Ie(){this.ye=!0}It(){return this.Te.N().lastPriceAnimation!==0}Ve(){switch(this.Te.N().lastPriceAnimation){case 0:return!1;case 1:return!0;case 2:return performance.now()<=this.ke}}Tt(){return this.xt?(this.Rt(),this.xt=!1,this.ye=!1):this.ye&&(this.Be(),this.ye=!1),this.Xt}Rt(){this.Xt.ht(null);const t=this.Te.Qt().Et(),n=t.Ee(),i=this.Te.Lt();if(n===null||i===null)return;const r=this.Te.Ae(!0);if(r.Le||!n.ze(r.$n))return;const o={x:t.jt(r.$n),y:this.Te.Ft().Nt(r.Mt,i.Wt)},l=r.R,h=this.Te.N().lineWidth,u=this.Oe(this.Ne(),l);this.Xt.ht({de:l,fe:h,pe:u.pe,ve:u.ve,ft:u.ft,ce:o})}Be(){const t=this.Xt.ue();if(t!==null){const n=this.Oe(this.Ne(),t.de);t.pe=n.pe,t.ve=n.ve,t.ft=n.ft}}Ne(){return this.Ve()?performance.now()-this.Pe:2599}Fe(t,n,i,r){const o=i+(r-i)*n;return this.Te.Qt().Xi().Y(t,o)}Oe(t,n){const i=t%2600/2600;let r;for(const f of Fx)if(i>=f.me&&i<=f.we){r=f;break}Je(r!==void 0,"Last price animation internal logic error");const o=(i-r.me)/(r.we-r.me);return{pe:this.Fe(n,o,r.be,r.Se),ve:this.Fe(n,o,r.xe,r.Ce),ft:(l=o,h=r.Me,u=r.ge,h+(u-h)*l)};var l,h,u}}class Vx extends dh{constructor(t){super(t)}oe(){const t=this.re;t.It=!1;const n=this.ae.N();if(!n.priceLineVisible||!this.ae.It())return;const i=this.ae.Ae(n.priceLineSource===0);i.Le||(t.It=!0,t.ut=i.Ei,t.R=this.ae.We(i.R),t.ct=n.priceLineWidth,t.Gt=n.priceLineStyle)}}class jx extends Oa{constructor(t){super(),this.Jt=t}Yi(t,n,i){t.It=!1,n.It=!1;const r=this.Jt;if(!r.It())return;const o=r.N(),l=o.lastValueVisible,h=r.He()!=="",u=o.seriesLastValueMode===0,f=r.Ae(!1);if(f.Le)return;l&&(t.ri=this.Ue(f,l,u),t.It=t.ri.length!==0),(h||u)&&(n.ri=this.$e(f,l,h,u),n.It=n.ri.length>0);const c=r.We(f.R),m=this.Jt.Qt().Xi().G(c);i.Z=m.Z,i.Ei=f.Ei,n.Ht=r.Qt().Ut(f.Ei/r.Ft().$t()),t.Ht=c,t.R=m.X,n.R=m.X}$e(t,n,i,r){let o="";const l=this.Jt.He();return i&&l.length!==0&&(o+=`${l} `),n&&r&&(o+=this.Jt.Ft().je()?t.qe:t.Ye),o.trim()}Ue(t,n,i){return n?i?this.Jt.Ft().je()?t.Ye:t.qe:t.ri:""}}function rd(e,t,n,i){const r=Number.isFinite(t),o=Number.isFinite(n);return r&&o?e(t,n):r||o?r?t:n:i}class hn{constructor(t,n){this.Ke=t,this.Ge=n}Ze(t){return t!==null&&this.Ke===t.Ke&&this.Ge===t.Ge}Xe(){return new hn(this.Ke,this.Ge)}Je(){return this.Ke}Qe(){return this.Ge}tr(){return this.Ge-this.Ke}Zi(){return this.Ge===this.Ke||Number.isNaN(this.Ge)||Number.isNaN(this.Ke)}Ss(t){return t===null?this:new hn(rd(Math.min,this.Je(),t.Je(),-1/0),rd(Math.max,this.Qe(),t.Qe(),1/0))}ir(t){if(!Sr(t)||this.Ge-this.Ke===0)return;const n=.5*(this.Ge+this.Ke);let i=this.Ge-n,r=this.Ke-n;i*=t,r*=t,this.Ge=n+i,this.Ke=n+r}nr(t){Sr(t)&&(this.Ge+=t,this.Ke+=t)}sr(){return{minValue:this.Ke,maxValue:this.Ge}}static er(t){return t===null?null:new hn(t.minValue,t.maxValue)}}class ka{constructor(t,n){this.rr=t,this.hr=n||null}ar(){return this.rr}lr(){return this.hr}sr(){return{priceRange:this.rr===null?null:this.rr.sr(),margins:this.hr||void 0}}static er(t){return t===null?null:new ka(hn.er(t.priceRange),t.margins)}}const Hx=[2,4,8,16,32,64,128,256,512],Zx="Custom series with conflation reducer must have a priceValueBuilder method";class Ux extends dh{constructor(t,n){super(t),this._r=n}oe(){const t=this.re;t.It=!1;const n=this._r.N();if(!this.ae.It()||!n.lineVisible)return;const i=this._r.ur();i!==null&&(t.It=!0,t.ut=i,t.R=n.color,t.ct=n.lineWidth,t.Gt=n.lineStyle,t.te=this._r.N().id)}}class qx extends Oa{constructor(t,n){super(),this.Te=t,this._r=n}Yi(t,n,i){t.It=!1,n.It=!1;const r=this._r.N(),o=r.axisLabelVisible,l=r.title!=="",h=this.Te;if(!o||!h.It())return;const u=this._r.ur();if(u===null)return;l&&(n.ri=r.title,n.It=!0),n.Ht=h.Qt().Ut(u/h.Ft().$t()),t.ri=this.cr(r.price),t.It=!0;const f=this.Te.Qt().Xi().G(r.axisLabelColor||r.color);i.Z=f.Z;const c=r.axisLabelTextColor||f.X;t.R=c,n.R=c,i.Ei=u}cr(t){const n=this.Te.Lt();return n===null?"":this.Te.Ft().Ji(t,n.Wt)}}class Gx{constructor(t,n){this.Te=t,this.yn=n,this.dr=new Ux(t,this),this.qs=new qx(t,this),this.pr=new ap(this.qs,t,t.Qt())}vr(t){Mn(this.yn,t),this.Pt(),this.Te.Qt().mr()}N(){return this.yn}wr(){return this.dr}Mr(){return this.pr}gr(){return this.qs}Pt(){this.dr.Pt(),this.qs.Pt()}ur(){const t=this.Te,n=t.Ft();if(t.Qt().Et().Zi()||n.Zi())return null;const i=t.Lt();return i===null?null:n.Nt(this.yn.price,i.Wt)}}class Yx{constructor(){this.br=new WeakMap}Sr(t,n,i){const r=1/n*i;if(t>=r)return 1;const o=r/t,l=Math.pow(2,Math.floor(Math.log2(o)));return Math.min(l,512)}Cr(t,n,i,r=!1,o){if(t.length===0||n<=1)return t;const l=this.yr(n);if(l<=1)return t;const h=this.Pr(t);let u=h.kr.get(l);return u!==void 0||(u=this.Tr(t,l,i,r,o,h.kr),h.kr.set(l,u)),u}Rr(t,n,i,r,o=!1,l){if(i<1||t.length===0)return t;const h=this.Pr(t),u=h.kr.get(i);if(!u)return this.Cr(t,i,r,o,l);const f=this.Dr(t,n,i,u,o,r,l);return h.kr.set(i,f),f}yr(t){if(t<=2)return 2;for(const n of Hx)if(t<=n)return n;return 512}Ir(t){if(t.length===0)return 0;const n=t[0],i=t[t.length-1];return 31*t.length+17*n.$n+13*i.$n}Tr(t,n,i,r=!1,o,l=new Map){if(n===2)return this.Vr(t,2,i,r,o);const h=n/2;let u=l.get(h);return u||(u=this.Tr(t,h,i,r,o,l),l.set(h,u)),this.Br(u,i,r,o)}Vr(t,n,i,r=!1,o){const l=this.Er(t,n,i,r,o);return this.Ar(l,r)}Br(t,n,i=!1,r){const o=this.Er(t,2,n,i,r);return this.Ar(o,i)}Er(t,n,i,r=!1,o){const l=[];for(let h=0;h<t.length;h+=n)if(t.length-h>=n){const u=this.Lr(t[h],t[h+1],i,r,o);u.zr=!1,l.push(u)}else if(l.length===0)l.push(this.Or(t[h],!0));else{const u=l[l.length-1];l[l.length-1]=this.Nr(u,t[h],i,r,o)}return l}Fr(t,n){return(t??1)+(n??1)}Lr(t,n,i,r=!1,o){if(!r||!i||!o){const f=t.Wt[1]>n.Wt[1]?t.Wt[1]:n.Wt[1],c=t.Wt[2]<n.Wt[2]?t.Wt[2]:n.Wt[2];return{Wr:t.$n,Hr:n.$n,Ur:t.wt,$r:n.wt,jr:t.Wt[0],qr:f,Yr:c,Kr:n.Wt[3],Gr:this.Fr(t.Gr,n.Gr),Zr:void 0,zr:!1}}const l=i(this.Xr(t,o),this.Xr(n,o)),h=o(l),u=h.length?h[h.length-1]:0;return{Wr:t.$n,Hr:n.$n,Ur:t.wt,$r:n.wt,jr:t.Wt[0],qr:Math.max(t.Wt[1],u),Yr:Math.min(t.Wt[2],u),Kr:u,Gr:this.Fr(t.Gr,n.Gr),Zr:l,zr:!1}}Nr(t,n,i,r=!1,o){if(!r||!i||!o)return{Wr:t.Wr,Hr:n.$n,Ur:t.Ur,$r:n.wt,jr:t.jr,qr:t.qr>n.Wt[1]?t.qr:n.Wt[1],Yr:t.Yr<n.Wt[2]?t.Yr:n.Wt[2],Kr:n.Wt[3],Gr:t.Gr+(n.Gr??1),Zr:t.Zr,zr:!1};const l=t.Zr,h=this.Xr(n,o),u=l?{data:l,index:t.Wr,originalTime:t.Ur,time:t.Ur,priceValues:o(l)}:null,f=u?i(u,h):h.data,c=u?o(f):h.priceValues,m=c.length?c[c.length-1]:0;return{Wr:t.Wr,Hr:n.$n,Ur:t.Ur,$r:n.wt,jr:t.jr,qr:Math.max(t.qr,m),Yr:Math.min(t.Yr,m),Kr:m,Gr:t.Gr+(n.Gr??1),Zr:f,zr:!1}}Jr(t,n,i,r,o,l,h=!1,u){const f=n===r?o:t[n];if(i-n==1)return this.Or(f,!0);const c=n+1===r?o:t[n+1];let m=this.Lr(f,c,l,h,u);for(let y=n+2;y<i;y++){const x=y===r?o:t[y];m=this.Nr(m,x,l,h,u)}return m}Xr(t,n){const i=t.ue??{};return{data:t.ue,index:t.$n,originalTime:t.Qr,time:t.wt,priceValues:n(i)}}th(t,n=!1){const i=n===!0,r=!!t.Zr;return{$n:t.Wr,wt:t.Ur,Qr:t.Ur,Wt:[i?t.Kr:t.jr,t.qr,t.Yr,t.Kr],Gr:t.Gr,ue:i?r?t.Zr:{wt:t.Ur}:void 0}}Ar(t,n=!1){return t.map(i=>this.th(i,n))}Dr(t,n,i,r,o=!1,l,h){if(r.length===0)return r;const u=t.length-1,f=Math.floor(u/i)*i;if(Math.min(f+i,t.length)-f<i&&t.length>i){const c=t.slice();return c[c.length-1]=n,this.Cr(c,i,l,o,h)}if(Math.floor((u-1)/i)===Math.floor(u/i)||r.length===1){const c=Math.min(f+i,t.length),m=c-f;if(m<=0)return r;const y=m===1?this.Or(f===u?n:t[f],!0):this.Jr(t,f,c,u,n,l,o,h);return r[r.length-1]=this.th(y,o),r}{const c=t.slice();return c[c.length-1]=n,this.Cr(c,i,l,o,h)}}Or(t,n=!1){return{Wr:t.$n,Hr:t.$n,Ur:t.wt,$r:t.wt,jr:t.Wt[0],qr:t.Wt[1],Yr:t.Wt[2],Kr:t.Wt[3],Gr:t.Gr??1,Zr:t.ue,zr:n}}Pr(t){const n=this.ih(t),i=this.Ir(t);return n.nh!==i&&(n.kr.clear(),n.nh=i),n}ih(t){let n=this.br.get(t);return n===void 0&&(n={nh:this.Ir(t),kr:new Map},this.br.set(t,n)),n}}class Xx extends sp{constructor(t){super(),this.sn=t}Qt(){return this.sn}}const Jx={Bar:(e,t,n,i)=>{const r=t.upColor,o=t.downColor,l=ut(e(n,i)),h=ss(l.Wt[0])<=ss(l.Wt[3]);return{sh:l.R??(h?r:o)}},Candlestick:(e,t,n,i)=>{const r=t.upColor,o=t.downColor,l=t.borderUpColor,h=t.borderDownColor,u=t.wickUpColor,f=t.wickDownColor,c=ut(e(n,i)),m=ss(c.Wt[0])<=ss(c.Wt[3]);return{sh:c.R??(m?r:o),eh:c.Ht??(m?l:h),rh:c.hh??(m?u:f)}},Custom:(e,t,n,i)=>({sh:ut(e(n,i)).R??t.color}),Area:(e,t,n,i)=>{const r=ut(e(n,i));return{sh:r.vt??t.lineColor,vt:r.vt??t.lineColor,ah:r.ah??t.topColor,oh:r.oh??t.bottomColor}},Baseline:(e,t,n,i)=>{const r=ut(e(n,i));return{sh:r.Wt[3]>=t.baseValue.price?t.topLineColor:t.bottomLineColor,_h:r._h??t.topLineColor,uh:r.uh??t.bottomLineColor,dh:r.dh??t.topFillColor1,fh:r.fh??t.topFillColor2,ph:r.ph??t.bottomFillColor1,mh:r.mh??t.bottomFillColor2}},Line:(e,t,n,i)=>{const r=ut(e(n,i));return{sh:r.R??t.color,vt:r.R??t.color}},Histogram:(e,t,n,i)=>({sh:ut(e(n,i)).R??t.color})};class Qx{constructor(t){this.wh=(n,i)=>i!==void 0?i.Wt:this.Te.Un().Mh(n),this.Te=t,this.gh=Jx[t.bh()]}Sh(t,n){return this.gh(this.wh,this.Te.N(),t,n)}}function lp(e,t,n,i,r=0,o=t.length){let l=o-r;for(;0<l;){const h=l>>1,u=r+h;i(t[u],n)===e?(r=u+1,l-=h+1):l=h}return r}const Ds=lp.bind(null,!0),fh=lp.bind(null,!1);var od;(function(e){e[e.NearestLeft=-1]="NearestLeft",e[e.None=0]="None",e[e.NearestRight=1]="NearestRight"})(od||(od={}));const es=30;class Kx{constructor(){this.xh=[],this.Ch=new Map,this.yh=new Map,this.Ph=[]}kh(){return this.Th()>0?this.xh[this.xh.length-1]:null}Rh(){return this.Th()>0?this.Dh(0):null}Qn(){return this.Th()>0?this.Dh(this.xh.length-1):null}Th(){return this.xh.length}Zi(){return this.Th()===0}ze(t){return this.Ih(t,0)!==null}Mh(t){return this.Hn(t)}Hn(t,n=0){const i=this.Ih(t,n);return i===null?null:{...this.Vh(i),$n:this.Dh(i)}}Bh(){return this.xh}Eh(t,n,i){if(this.Zi())return null;let r=null;for(const o of i)r=Jo(r,this.Ah(t,n,o));return r}ht(t){this.yh.clear(),this.Ch.clear(),this.xh=t,this.Ph=t.map(n=>n.$n)}Lh(){return this.Ph}Dh(t){return this.xh[t].$n}Vh(t){return this.xh[t]}Ih(t,n){const i=this.zh(t);if(i===null&&n!==0)switch(n){case-1:return this.Oh(t);case 1:return this.Nh(t);default:throw new TypeError("Unknown search mode")}return i}Oh(t){let n=this.Fh(t);return n>0&&(n-=1),n!==this.xh.length&&this.Dh(n)<t?n:null}Nh(t){const n=this.Wh(t);return n!==this.xh.length&&t<this.Dh(n)?n:null}zh(t){const n=this.Fh(t);return n===this.xh.length||t<this.xh[n].$n?null:n}Fh(t){return Ds(this.xh,t,(n,i)=>n.$n<i)}Wh(t){return fh(this.xh,t,(n,i)=>n.$n>i)}Hh(t,n,i){let r=null;for(let o=t;o<n;o++){const l=this.xh[o].Wt[i];Number.isNaN(l)||(r===null?r={Uh:l,$h:l}:(l<r.Uh&&(r.Uh=l),l>r.$h&&(r.$h=l)))}return r}Ah(t,n,i){if(this.Zi())return null;let r=null;const o=ut(this.Rh()),l=ut(this.Qn()),h=Math.max(t,o),u=Math.min(n,l),f=Math.ceil(h/es)*es,c=Math.max(f,Math.floor(u/es)*es);{const y=this.Fh(h),x=this.Wh(Math.min(u,f,n));r=Jo(r,this.Hh(y,x,i))}let m=this.Ch.get(i);m===void 0&&(m=new Map,this.Ch.set(i,m));for(let y=Math.max(f+1,h);y<c;y+=es){const x=Math.floor(y/es);let _=m.get(x);if(_===void 0){const p=this.Fh(x*es),E=this.Wh((x+1)*es-1);_=this.Hh(p,E,i),m.set(x,_)}r=Jo(r,_)}{const y=this.Fh(c),x=this.Wh(u);r=Jo(r,this.Hh(y,x,i))}return r}}function Jo(e,t){return e===null?t:t===null?e:{Uh:Math.min(e.Uh,t.Uh),$h:Math.max(e.$h,t.$h)}}function vl(){return new Kx}const Ta={setLineStyle:hs};class t_{constructor(t){this.jh=t}st(t,n,i){this.jh.draw(t,Ta)}qh(t,n,i){var r,o;(o=(r=this.jh).drawBackground)==null||o.call(r,t,Ta)}}class e_{constructor(t){this.Ls=null,this.Yh=t}Tt(){var i;const t=this.Yh.renderer();if(t===null)return null;if(((i=this.Ls)==null?void 0:i.Kh)===t)return this.Ls.Gh;const n=new t_(t);return this.Ls={Kh:t,Gh:n},n}Zh(){var t,n;return((n=(t=this.Yh).zOrder)==null?void 0:n.call(t))??"normal"}}class cp{constructor(t){this.Xh=null,this.Jh=t}Qh(){return this.Jh}Nn(){var t,n;(n=(t=this.Jh).updateAllViews)==null||n.call(t)}jn(){var i,r,o;const t=((r=(i=this.Jh).paneViews)==null?void 0:r.call(i))??[];if(((o=this.Xh)==null?void 0:o.Kh)===t)return this.Xh.Gh;const n=t.map(l=>new e_(l));return this.Xh={Kh:t,Gh:n},n}Qs(t,n){var i,r;return((r=(i=this.Jh).hitTest)==null?void 0:r.call(i,t,n))??null}}let n_=class extends cp{cn(){return[]}};class i_{constructor(t){this.jh=t}st(t,n,i){this.jh.draw(t,Ta)}qh(t,n,i){var r,o;(o=(r=this.jh).drawBackground)==null||o.call(r,t,Ta)}}class ad{constructor(t){this.Ls=null,this.Yh=t}Tt(){var i;const t=this.Yh.renderer();if(t===null)return null;if(((i=this.Ls)==null?void 0:i.Kh)===t)return this.Ls.Gh;const n=new i_(t);return this.Ls={Kh:t,Gh:n},n}Zh(){var t,n;return((n=(t=this.Yh).zOrder)==null?void 0:n.call(t))??"normal"}}function hp(e){var t,n,i;return{ri:e.text(),Ei:e.coordinate(),Vi:(t=e.fixedCoordinate)==null?void 0:t.call(e),R:e.textColor(),Z:e.backColor(),It:((n=e.visible)==null?void 0:n.call(e))??!0,pi:((i=e.tickVisible)==null?void 0:i.call(e))??!0}}class s_{constructor(t,n){this.Xt=new ip,this.ta=t,this.ia=n}Tt(){return this.Xt.ht({nn:this.ia.nn(),...hp(this.ta)}),this.Xt}}class r_ extends Oa{constructor(t,n){super(),this.ta=t,this.Ki=n}Yi(t,n,i){const r=hp(this.ta);i.Z=r.Z,t.R=r.R;const o=2/12*this.Ki.P();i.Ti=o,i.Ri=o,i.Ei=r.Ei,i.Vi=r.Vi,t.ri=r.ri,t.It=r.It,t.pi=r.pi}}class o_ extends cp{constructor(t,n){super(t),this.na=null,this.sa=null,this.ea=null,this.ra=null,this.Te=n}dn(){var r,o,l;const t=((o=(r=this.Jh).timeAxisViews)==null?void 0:o.call(r))??[];if(((l=this.na)==null?void 0:l.Kh)===t)return this.na.Gh;const n=this.Te.Qt().Et(),i=t.map(h=>new s_(h,n));return this.na={Kh:t,Gh:i},i}qn(){var r,o,l;const t=((o=(r=this.Jh).priceAxisViews)==null?void 0:o.call(r))??[];if(((l=this.sa)==null?void 0:l.Kh)===t)return this.sa.Gh;const n=this.Te.Ft(),i=t.map(h=>new r_(h,n));return this.sa={Kh:t,Gh:i},i}ha(){var i,r,o;const t=((r=(i=this.Jh).priceAxisPaneViews)==null?void 0:r.call(i))??[];if(((o=this.ea)==null?void 0:o.Kh)===t)return this.ea.Gh;const n=t.map(l=>new ad(l));return this.ea={Kh:t,Gh:n},n}aa(){var i,r,o;const t=((r=(i=this.Jh).timeAxisPaneViews)==null?void 0:r.call(i))??[];if(((o=this.ra)==null?void 0:o.Kh)===t)return this.ra.Gh;const n=t.map(l=>new ad(l));return this.ra={Kh:t,Gh:n},n}la(t,n){var i,r;return((r=(i=this.Jh).autoscaleInfo)==null?void 0:r.call(i,t,n))??null}}function Qo(e,t,n,i){e.forEach(r=>{t(r).forEach(o=>{o.Zh()===n&&i.push(o)})})}function Ko(e){return e.jn()}function a_(e){return e.ha()}function l_(e){return e.aa()}const c_=["Area","Line","Baseline"];class Va extends Xx{constructor(t,n,i,r,o){super(t),this.qt=vl(),this.dr=new Vx(this),this.oa=[],this._a=new Bx(this),this.ua=null,this.ca=null,this.da=null,this.fa=[],this.pa=new Yx,this.va=new Map,this.ma=null,this.yn=i,this.wa=n;const l=new jx(this);if(this.mn=[l],this.pr=new ap(l,this,t),c_.includes(this.wa)&&(this.ua=new Wx(this)),this.Ma(),this.Yh=r(this,this.Qt(),o),this.wa==="Custom"){const h=this.Yh;h.ga&&this.ba(h.ga)}}m(){this.da!==null&&clearTimeout(this.da)}We(t){return this.yn.priceLineColor||t}Ae(t){const n={Le:!0},i=this.Ft();if(this.Qt().Et().Zi()||i.Zi()||this.qt.Zi())return n;const r=this.Qt().Et().Ee(),o=this.Lt();if(r===null||o===null)return n;let l,h;if(t){const m=this.qt.kh();if(m===null)return n;l=m,h=m.$n}else{const m=this.qt.Hn(r.bi(),-1);if(m===null||(l=this.qt.Mh(m.$n),l===null))return n;h=m.$n}const u=l.Wt[3],f=this.Sa().Sh(h,{Wt:l}),c=i.Nt(u,o.Wt);return{Le:!1,Mt:u,ri:i.Ji(u,o.Wt),qe:i.xa(u),Ye:i.Ca(u,o.Wt),R:f.sh,Ei:c,$n:h}}Sa(){return this.ca!==null||(this.ca=new Qx(this)),this.ca}N(){return this.yn}vr(t){const n=this.Qt(),{priceScaleId:i,visible:r,priceFormat:o}=t;i!==void 0&&i!==this.yn.priceScaleId&&n.ya(this,i),r!==void 0&&r!==this.yn.visible&&n.Pa();const l=t.conflationThresholdFactor!==void 0;Mn(this.yn,t),Object.prototype.hasOwnProperty.call(t,"autoscaleInfoProvider")&&t.autoscaleInfoProvider===void 0&&(this.yn.autoscaleInfoProvider=void 0),l&&(this.va.clear(),this.Qt().mr()),o!==void 0&&(this.Ma(),n.ka()),n.Ta(this),n.Ra(),this.Yh.Pt("options")}ht(t,n){this.qt.ht(t),this.va.clear();const i=this.Qt().Et().N();i.enableConflation&&i.precomputeConflationOnInit&&this.Da(i.precomputeConflationPriority),this.Ia(),this.ua!==null&&(n&&n.Va?this.ua.De():t.length===0&&this.ua.Re());const r=this.Qt().Ks(this);this.Qt().Ba(r),this.Qt().Ta(this),this.Qt().Ra(),this.Qt().mr()}Ia(){this.Yh.Pt("data")}Ea(t){const n=new Gx(this,t);return this.oa.push(n),this.Qt().Ta(this),n}Aa(t){const n=this.oa.indexOf(t);n!==-1&&this.oa.splice(n,1),this.Qt().Ta(this)}La(){return this.oa}bh(){return this.wa}Lt(){const t=this.za();return t===null?null:{Wt:t.Wt[3],Oa:t.wt}}za(){const t=this.Qt().Et().Ee();if(t===null)return null;const n=t.Na();return this.qt.Hn(n,1)}Un(){return this.qt}ba(t){this.ma=t,this.va.clear()}Fa(){return!!this.Qt().Et().N().enableConflation&&this.Wa()>1}Rr(t){if(!this.Fa())return;const n=this.Wa();if(!this.va.has(n))return;const i=this.wa==="Custom",r=i&&this.ma||void 0,o=i&&this.Yh.Ha?u=>{const f=u,c=this.Yh.Ha(f);return Array.isArray(c)?c:[typeof c=="number"?c:0]}:void 0,l=this.pa.Rr(this.qt.Bh(),t,n,r,i,o),h=vl();h.ht(l),this.va.set(n,h)}Ua(){const t=this.Qt().Et().N().enableConflation;if(this.wa==="Custom"&&this.ma===null)return this.qt;if(!t)return this.qt;const n=this.Wa(),i=this.va.get(n);return i||(this.$a(n),this.va.get(n)??this.qt)}ja(t){const n=this.qt.Mh(t);return n===null?null:this.wa==="Bar"||this.wa==="Candlestick"||this.wa==="Custom"?{jr:n.Wt[0],qr:n.Wt[1],Yr:n.Wt[2],Kr:n.Wt[3]}:n.Wt[3]}qa(t){const n=[];Qo(this.fa,Ko,"top",n);const i=this.ua;return i!==null&&i.It()&&(this.da===null&&i.Ve()&&(this.da=setTimeout(()=>{this.da=null,this.Qt().Ya()},0)),i.Ie(),n.unshift(i)),n}jn(){const t=[];this.Ka()||t.push(this._a),t.push(this.Yh,this.dr);const n=this.oa.map(i=>i.wr());return t.push(...n),Qo(this.fa,Ko,"normal",t),t}Ga(){var o,l;const t=((l=(o=this.Yh).Ga)==null?void 0:l.call(o))??null;if(t===null)return null;const n=[];this.Ka()||n.push(this._a),n.push(...t.Za),Qo(this.fa,Ko,"normal",n);const i=[];i.push(...t.qa,this.dr);const r=this.oa.map(h=>h.wr());return i.push(...r),{Za:n,qa:i}}Xa(){return this.Ja(Ko,"bottom")}Qa(t){return this.Ja(a_,t)}tl(t){return this.Ja(l_,t)}il(t,n){return this.fa.map(i=>i.Qs(t,n)).filter(i=>i!==null)}cn(){return[this.pr,...this.oa.map(t=>t.Mr())]}qn(t,n){if(n!==this.hn&&!this.Ka())return[];const i=[...this.mn];for(const r of this.oa)i.push(r.gr());return this.fa.forEach(r=>{i.push(...r.qn())}),i}dn(){const t=[];return this.fa.forEach(n=>{t.push(...n.dn())}),t}la(t,n){if(this.yn.autoscaleInfoProvider!==void 0){const i=this.yn.autoscaleInfoProvider(()=>{const r=this.nl(t,n);return r===null?null:r.sr()});return ka.er(i)}return this.nl(t,n)}Kh(){const t=this.yn.priceFormat;return t.base??1/t.minMove}sl(){return this.el}Nn(){var t;this.Yh.Pt();for(const n of this.mn)n.Pt();for(const n of this.oa)n.Pt();this.dr.Pt(),this._a.Pt(),(t=this.ua)==null||t.Pt(),this.fa.forEach(n=>n.Nn())}Ft(){return ut(super.Ft())}At(t){if(!((this.wa==="Line"||this.wa==="Area"||this.wa==="Baseline")&&this.yn.crosshairMarkerVisible))return null;const n=this.qt.Mh(t);return n===null?null:{Mt:n.Wt[3],ft:this.rl(),Ht:this.hl(),Ot:this.al(),zt:this.ll(t)}}He(){return this.yn.title}It(){return this.yn.visible}ol(t){this.fa.push(new o_(t,this))}_l(t){this.fa=this.fa.filter(n=>n.Qh()!==t)}ul(){if(this.wa==="Custom")return t=>this.Yh.Ha(t)}cl(){if(this.wa==="Custom")return t=>this.Yh.dl(t)}fl(){return this.qt.Lh()}Ka(){return!Fa(this.Ft().pl())}nl(t,n){if(!bo(t)||!bo(n)||this.qt.Zi())return null;const i=this.wa==="Line"||this.wa==="Area"||this.wa==="Baseline"||this.wa==="Histogram"?[3]:[2,1],r=this.qt.Eh(t,n,i);let o=r!==null?new hn(r.Uh,r.$h):null,l=null;if(this.bh()==="Histogram"){const h=this.yn.base,u=new hn(h,h);o=o!==null?o.Ss(u):u}return this.fa.forEach(h=>{const u=h.la(t,n);if(u!=null&&u.priceRange){const f=new hn(u.priceRange.minValue,u.priceRange.maxValue);o=o!==null?o.Ss(f):f}u!=null&&u.margins&&(l=u.margins)}),new ka(o,l)}rl(){switch(this.wa){case"Line":case"Area":case"Baseline":return this.yn.crosshairMarkerRadius}return 0}hl(){switch(this.wa){case"Line":case"Area":case"Baseline":{const t=this.yn.crosshairMarkerBorderColor;if(t.length!==0)return t}}return null}al(){switch(this.wa){case"Line":case"Area":case"Baseline":return this.yn.crosshairMarkerBorderWidth}return 0}ll(t){switch(this.wa){case"Line":case"Area":case"Baseline":{const n=this.yn.crosshairMarkerBackgroundColor;if(n.length!==0)return n}}return this.Sa().Sh(t).sh}Ma(){switch(this.yn.priceFormat.type){case"custom":{const t=this.yn.priceFormat.formatter;this.el={format:t,formatTickmarks:this.yn.priceFormat.tickmarksFormatter??(n=>n.map(t))};break}case"volume":this.el=new Ix(this.yn.priceFormat.precision);break;case"percent":this.el=new op(this.yn.priceFormat.precision);break;default:{const t=Math.pow(10,this.yn.priceFormat.precision);this.el=new Wa(t,this.yn.priceFormat.minMove*t)}}this.hn!==null&&this.hn.vl()}Ja(t,n){const i=[];return Qo(this.fa,t,n,i),i}Wa(){const{ml:t,wl:n,Ml:i}=this.gl();return this.pa.Sr(t,n,i)}gl(){const t=this.Qt().Et(),n=t.ml(),i=window.devicePixelRatio||1,r=t.N().conflationThresholdFactor;return{ml:n,wl:i,Ml:this.yn.conflationThresholdFactor??r??1}}bl(t){const n=this.qt.Bh();let i;if(this.wa==="Custom"&&this.ma!==null){const o=this.ul();if(!o)throw new Error(Zx);i=this.pa.Cr(n,t,this.ma,!0,l=>o(l))}else i=this.pa.Cr(n,t);const r=vl();return r.ht(i),r}$a(t){const n=this.bl(t);this.va.set(t,n)}Da(t){var i;if(this.wa==="Custom"&&(this.ma===null||!this.ul()))return;this.va.clear();const n=this.Qt().Et().Sl();for(const r of n){const o=()=>{this.xl(r)},l=typeof window=="object"&&window||typeof self=="object"&&self;(i=l==null?void 0:l.yl)!=null&&i.Cl?l.yl.Cl(()=>{o()},{se:t}):Promise.resolve().then(()=>o())}}xl(t){if(this.va.has(t)||this.qt.Bh().length===0)return;const n=this.bl(t);this.va.set(t,n)}}const h_=[3],u_=[0,1,2,3];class d_{constructor(t){this.yn=t}Pl(t,n,i){let r=t;if(this.yn.mode===0)return r;const o=i.kn(),l=o.Lt();if(l===null)return r;const h=o.Nt(t,l),u=i.kl().filter(c=>c instanceof Va).reduce((c,m)=>{if(i.Gs(m)||!m.It())return c;const y=m.Ft(),x=m.Un();if(y.Zi()||!x.ze(n))return c;const _=x.Mh(n);if(_===null)return c;const p=ss(m.Lt()),E=this.yn.mode===3?u_:h_;return c.concat(E.map(T=>y.Nt(_.Wt[T],p.Wt)))},[]);if(u.length===0)return r;u.sort((c,m)=>Math.abs(c-h)-Math.abs(m-h));const f=u[0];return r=o.Tn(f,l),r}}function vr(e,t,n){return Math.min(Math.max(e,t),n)}function ta(e,t,n){return t-e<=n}class f_ extends ds{constructor(){super(...arguments),this.qt=null}ht(t){this.qt=t}et({context:t,bitmapSize:n,horizontalPixelRatio:i,verticalPixelRatio:r}){if(this.qt===null)return;const o=Math.max(1,Math.floor(i));t.lineWidth=o,function(l,h){l.save(),l.lineWidth%2&&l.translate(.5,.5),h(),l.restore()}(t,()=>{const l=ut(this.qt);if(l.Tl){t.strokeStyle=l.Rl,hs(t,l.Dl),t.beginPath();for(const h of l.Il){const u=Math.round(h.Vl*i);t.moveTo(u,-o),t.lineTo(u,n.height+o)}t.stroke()}if(l.Bl){t.strokeStyle=l.El,hs(t,l.Al),t.beginPath();for(const h of l.Ll){const u=Math.round(h.Vl*r);t.moveTo(-o,u),t.lineTo(n.width+o,u)}t.stroke()}})}}class m_{constructor(t){this.Xt=new f_,this.xt=!0,this.yt=t}Pt(){this.xt=!0}Tt(){if(this.xt){const t=this.yt.Qt().N().grid,n={Bl:t.horzLines.visible,Tl:t.vertLines.visible,El:t.horzLines.color,Rl:t.vertLines.color,Al:t.horzLines.style,Dl:t.vertLines.style,Ll:this.yt.kn().zl(),Il:(this.yt.Qt().Et().zl()||[]).map(i=>({Vl:i.coord}))};this.Xt.ht(n),this.xt=!1}return this.Xt}}class p_{constructor(t){this.Yh=new m_(t)}wr(){return this.Yh}}const bl={Ol:4,Nl:1e-4};function mr(e,t){const n=100*(e-t)/t;return t<0?-n:n}function g_(e,t){const n=mr(e.Je(),t),i=mr(e.Qe(),t);return new hn(n,i)}function oo(e,t){const n=100*(e-t)/t+100;return t<0?-n:n}function y_(e,t){const n=oo(e.Je(),t),i=oo(e.Qe(),t);return new hn(n,i)}function Pa(e,t){const n=Math.abs(e);if(n<1e-15)return 0;const i=Math.log10(n+t.Nl)+t.Ol;return e<0?-i:i}function ao(e,t){const n=Math.abs(e);if(n<1e-15)return 0;const i=Math.pow(10,n-t.Ol)-t.Nl;return e<0?-i:i}function qr(e,t){if(e===null)return null;const n=Pa(e.Je(),t),i=Pa(e.Qe(),t);return new hn(n,i)}function pr(e,t){if(e===null)return null;const n=ao(e.Je(),t),i=ao(e.Qe(),t);return new hn(n,i)}function xl(e){if(e===null)return bl;const t=Math.abs(e.Qe()-e.Je());if(t>=1||t<1e-15)return bl;const n=Math.ceil(Math.abs(Math.log10(t))),i=bl.Ol+n;return{Ol:i,Nl:1/Math.pow(10,i)}}class _l{constructor(t,n){if(this.Fl=t,this.Wl=n,function(i){if(i<0)return!1;if(i>1e18)return!0;for(let r=i;r>1;r/=10)if(r%10!=0)return!1;return!0}(this.Fl))this.Hl=[2,2.5,2];else{this.Hl=[];for(let i=this.Fl;i!==1;){if(i%2==0)this.Hl.push(2),i/=2;else{if(i%5!=0)throw new Error("unexpected base");this.Hl.push(2,2.5),i/=5}if(this.Hl.length>100)throw new Error("something wrong with base")}}}Ul(t,n,i){const r=this.Fl===0?0:1/this.Fl;let o=Math.pow(10,Math.max(0,Math.ceil(Math.log10(t-n)))),l=0,h=this.Wl[0];for(;;){const m=ta(o,r,1e-14)&&o>r+1e-14,y=ta(o,i*h,1e-14),x=ta(o,1,1e-14);if(!(m&&y&&x))break;o/=h,h=this.Wl[++l%this.Wl.length]}if(o<=r+1e-14&&(o=r),o=Math.max(1,o),this.Hl.length>0&&(u=o,f=1,c=1e-14,Math.abs(u-f)<c))for(l=0,h=this.Hl[0];ta(o,i*h,1e-14)&&o>r+1e-14;)o/=h,h=this.Hl[++l%this.Hl.length];var u,f,c;return o}}class ld{constructor(t,n,i,r){this.$l=[],this.Ki=t,this.Fl=n,this.jl=i,this.ql=r}Ul(t,n){if(t<n)throw new Error("high < low");const i=this.Ki.$t(),r=(t-n)*this.Yl()/i,o=new _l(this.Fl,[2,2.5,2]),l=new _l(this.Fl,[2,2,2.5]),h=new _l(this.Fl,[2.5,2,2]),u=[];return u.push(o.Ul(t,n,r),l.Ul(t,n,r),h.Ul(t,n,r)),function(f){if(f.length<1)throw Error("array is empty");let c=f[0];for(let m=1;m<f.length;++m)f[m]<c&&(c=f[m]);return c}(u)}Kl(){const t=this.Ki,n=t.Lt();if(n===null)return void(this.$l=[]);const i=t.$t(),r=this.jl(i-1,n),o=this.jl(0,n),l=this.Ki.N().entireTextOnly?this.Gl()/2:0,h=l,u=i-1-l,f=Math.max(r,o),c=Math.min(r,o);if(f===c)return void(this.$l=[]);const m=this.Ul(f,c);if(this.Zl(n,m,f,c,h,u),t.Xl()&&this.Jl(m,c,f)){const _=this.Ki.Ql();this.io(n,m,h,u,_,2*_)}const y=this.$l.map(_=>_.no),x=this.Ki.so(y);for(let _=0;_<this.$l.length;_++)this.$l[_].eo=x[_]}zl(){return this.$l}Gl(){return this.Ki.P()}Yl(){return Math.ceil(this.Gl()*this.Ki.N().tickMarkDensity)}Zl(t,n,i,r,o,l){const h=this.$l,u=this.Ki;let f=i%n;f+=f<0?n:0;const c=i>=r?1:-1;let m=null,y=0;for(let x=i-f;x>r;x-=n){const _=this.ql(x,t,!0);m!==null&&Math.abs(_-m)<this.Yl()||_<o||_>l||(y<h.length?(h[y].Vl=_,h[y].eo=u.ro(x),h[y].no=x):h.push({Vl:_,eo:u.ro(x),no:x}),y++,m=_,u.ho()&&(n=this.Ul(x*c,r)))}h.length=y}io(t,n,i,r,o,l){const h=this.$l,u=this.ao(t,i,o,l),f=this.ao(t,r,-l,-o),c=this.ql(0,t,!0)-this.ql(n,t,!0);h.length>0&&h[0].Vl-u.Vl<c/2&&h.shift(),h.length>0&&f.Vl-h[h.length-1].Vl<c/2&&h.pop(),h.unshift(u),h.push(f)}ao(t,n,i,r){const o=(i+r)/2,l=this.jl(n+i,t),h=this.jl(n+r,t),u=Math.min(l,h),f=Math.max(l,h),c=Math.max(.1,this.Ul(f,u)),m=this.jl(n+o,t),y=m-m%c,x=this.ql(y,t,!0);return{eo:this.Ki.ro(y),Vl:x,no:y}}Jl(t,n,i){let r=ss(this.Ki.ar());return this.Ki.ho()&&(r=pr(r,this.Ki.lo())),r.Je()-n<t&&i-r.Qe()<t}}function up(e){return e.slice().sort((t,n)=>ut(t.ln())-ut(n.ln()))}var cd;(function(e){e[e.Normal=0]="Normal",e[e.Logarithmic=1]="Logarithmic",e[e.Percentage=2]="Percentage",e[e.IndexedTo100=3]="IndexedTo100"})(cd||(cd={}));const hd=new op,ud=new Wa(100,1);class v_{constructor(t,n,i,r,o){this.oo=0,this._o=null,this.rr=null,this.uo=null,this.co={do:!1,fo:null},this.po=!1,this.vo=0,this.mo=0,this.wo=new Ae,this.Mo=new Ae,this.bo=[],this.So=null,this.xo=null,this.Co=null,this.yo=null,this.Po=null,this.el=ud,this.ko=xl(null),this.To=t,this.yn=n,this.Ro=i,this.Do=r,this.Io=o,this.Vo=new ld(this,100,this.Bo.bind(this),this.Eo.bind(this))}pl(){return this.To}N(){return this.yn}vr(t){if(Mn(this.yn,t),this.vl(),t.mode!==void 0&&this.Ao({_e:t.mode}),t.scaleMargins!==void 0){const n=xn(t.scaleMargins.top),i=xn(t.scaleMargins.bottom);if(n<0||n>1)throw new Error(`Invalid top margin - expect value between 0 and 1, given=${n}`);if(i<0||i>1)throw new Error(`Invalid bottom margin - expect value between 0 and 1, given=${i}`);if(n+i>1)throw new Error(`Invalid margins - sum of margins must be less than 1, given=${n+i}`);this.Lo(),this.Co=null}}zo(){return this.yn.autoScale}Oo(){return this.po}ho(){return this.yn.mode===1}je(){return this.yn.mode===2}No(){return this.yn.mode===3}lo(){return this.ko}_e(){return{hs:this.yn.autoScale,Fo:this.yn.invertScale,_e:this.yn.mode}}Ao(t){const n=this._e();let i=null;t.hs!==void 0&&(this.yn.autoScale=t.hs),t._e!==void 0&&(this.yn.mode=t._e,t._e!==2&&t._e!==3||(this.yn.autoScale=!0),this.co.do=!1),n._e===1&&t._e!==n._e&&(function(o,l){if(o===null)return!1;const h=ao(o.Je(),l),u=ao(o.Qe(),l);return isFinite(h)&&isFinite(u)}(this.rr,this.ko)?(i=pr(this.rr,this.ko),i!==null&&this.Wo(i)):this.yn.autoScale=!0),t._e===1&&t._e!==n._e&&(i=qr(this.rr,this.ko),i!==null&&this.Wo(i));const r=n._e!==this.yn.mode;r&&(n._e===2||this.je())&&this.vl(),r&&(n._e===3||this.No())&&this.vl(),t.Fo!==void 0&&n.Fo!==t.Fo&&(this.yn.invertScale=t.Fo,this.Ho()),this.Mo.p(n,this._e())}Uo(){return this.Mo}P(){return this.Ro.fontSize}$t(){return this.oo}$o(t){this.oo!==t&&(this.oo=t,this.Lo(),this.Co=null)}jo(){if(this._o)return this._o;const t=this.$t()-this.qo()-this.Yo();return this._o=t,t}ar(){return this.Ko(),this.rr}Wo(t,n){const i=this.rr;(n||i===null&&t!==null||i!==null&&!i.Ze(t))&&(this.Co=null,this.rr=t)}Go(t){this.Wo(t),this.Zo(t!==null)}Zi(){return this.Ko(),this.oo===0||!this.rr||this.rr.Zi()}Xo(t){return this.Fo()?t:this.$t()-1-t}Nt(t,n){return this.je()?t=mr(t,n):this.No()&&(t=oo(t,n)),this.Eo(t,n)}Jo(t,n,i){this.Ko();const r=this.Yo(),o=ut(this.ar()),l=o.Je(),h=o.Qe(),u=this.jo()-1,f=this.Fo(),c=u/(h-l),m=i===void 0?0:i.from,y=i===void 0?t.length:i.to,x=this.Qo();for(let _=m;_<y;_++){const p=t[_],E=p.Mt;if(isNaN(E))continue;let T=E;x!==null&&(T=x(p.Mt,n));const k=r+c*(T-l),A=f?k:this.oo-1-k;p.ut=A}}t_(t,n,i){this.Ko();const r=this.Yo(),o=ut(this.ar()),l=o.Je(),h=o.Qe(),u=this.jo()-1,f=this.Fo(),c=u/(h-l),m=i===void 0?0:i.from,y=i===void 0?t.length:i.to,x=this.Qo();for(let _=m;_<y;_++){const p=t[_];let E=p.jr,T=p.qr,k=p.Yr,A=p.Kr;x!==null&&(E=x(p.jr,n),T=x(p.qr,n),k=x(p.Yr,n),A=x(p.Kr,n));let P=r+c*(E-l),I=f?P:this.oo-1-P;p.i_=I,P=r+c*(T-l),I=f?P:this.oo-1-P,p.n_=I,P=r+c*(k-l),I=f?P:this.oo-1-P,p.s_=I,P=r+c*(A-l),I=f?P:this.oo-1-P,p.e_=I}}Tn(t,n){const i=this.Bo(t,n);return this.r_(i,n)}r_(t,n){let i=t;return this.je()?i=function(r,o){return o<0&&(r=-r),r/100*o+o}(i,n):this.No()&&(i=function(r,o){return r-=100,o<0&&(r=-r),r/100*o+o}(i,n)),i}kl(){return this.bo}Dt(){return this.xo||(this.xo=up(this.bo)),this.xo}h_(t){this.bo.indexOf(t)===-1&&(this.bo.push(t),this.vl(),this.a_())}l_(t){const n=this.bo.indexOf(t);if(n===-1)throw new Error("source is not attached to scale");this.bo.splice(n,1),this.bo.length===0&&(this.Ao({hs:!0}),this.Wo(null)),this.vl(),this.a_()}Lt(){let t=null;for(const n of this.bo){const i=n.Lt();i!==null&&(t===null||i.Oa<t.Oa)&&(t=i)}return t===null?null:t.Wt}Fo(){return this.yn.invertScale}zl(){const t=this.Lt()===null;if(this.Co!==null&&(t||this.Co.o_===t))return this.Co.zl;this.Vo.Kl();const n=this.Vo.zl();return this.Co={zl:n,o_:t},this.wo.p(),n}__(){return this.wo}u_(t){this.je()||this.No()||this.yo===null&&this.uo===null&&(this.Zi()||(this.yo=this.oo-t,this.uo=ut(this.ar()).Xe()))}c_(t){if(this.je()||this.No()||this.yo===null)return;this.Ao({hs:!1}),(t=this.oo-t)<0&&(t=0);let n=(this.yo+.2*(this.oo-1))/(t+.2*(this.oo-1));const i=ut(this.uo).Xe();n=Math.max(n,.1),i.ir(n),this.Wo(i)}d_(){this.je()||this.No()||(this.yo=null,this.uo=null)}f_(t){this.zo()||this.Po===null&&this.uo===null&&(this.Zi()||(this.Po=t,this.uo=ut(this.ar()).Xe()))}p_(t){if(this.zo()||this.Po===null)return;const n=ut(this.ar()).tr()/(this.jo()-1);let i=t-this.Po;this.Fo()&&(i*=-1);const r=i*n,o=ut(this.uo).Xe();o.nr(r),this.Wo(o,!0),this.Co=null}v_(){this.zo()||this.Po!==null&&(this.Po=null,this.uo=null)}sl(){return this.el||this.vl(),this.el}Ji(t,n){switch(this.yn.mode){case 2:return this.m_(mr(t,n));case 3:return this.sl().format(oo(t,n));default:return this.cr(t)}}ro(t){switch(this.yn.mode){case 2:return this.m_(t);case 3:return this.sl().format(t);default:return this.cr(t)}}so(t){switch(this.yn.mode){case 2:return this.w_(t);case 3:return this.sl().formatTickmarks(t);default:return this.M_(t)}}xa(t){return this.cr(t,ut(this.So).sl())}Ca(t,n){return t=mr(t,n),this.m_(t,hd)}g_(){return this.bo}b_(t){this.co={fo:t,do:!1}}Nn(){this.bo.forEach(t=>t.Nn())}Xl(){return this.yn.ensureEdgeTickMarksVisible&&this.zo()}Ql(){return this.P()/2}vl(){this.Co=null;let t=1/0;this.So=null;for(const i of this.bo)i.ln()<t&&(t=i.ln(),this.So=i);let n=100;this.So!==null&&(n=Math.round(this.So.Kh())),this.el=ud,this.je()?(this.el=hd,n=100):this.No()?(this.el=new Wa(100,1),n=100):this.So!==null&&(this.el=this.So.sl()),this.Vo=new ld(this,n,this.Bo.bind(this),this.Eo.bind(this)),this.Vo.Kl()}a_(){this.xo=null}S_(){return this.So===null||this.je()||this.No()?1:1/this.So.Kh()}Xi(){return this.Io}Zo(t){this.po=t}qo(){return this.Fo()?this.yn.scaleMargins.bottom*this.$t()+this.mo:this.yn.scaleMargins.top*this.$t()+this.vo}Yo(){return this.Fo()?this.yn.scaleMargins.top*this.$t()+this.vo:this.yn.scaleMargins.bottom*this.$t()+this.mo}Ko(){this.co.do||(this.co.do=!0,this.x_())}Lo(){this._o=null}Eo(t,n){if(this.Ko(),this.Zi())return 0;t=this.ho()&&t?Pa(t,this.ko):t;const i=ut(this.ar()),r=this.Yo()+(this.jo()-1)*(t-i.Je())/i.tr();return this.Xo(r)}Bo(t,n){if(this.Ko(),this.Zi())return 0;const i=this.Xo(t),r=ut(this.ar()),o=r.Je()+r.tr()*((i-this.Yo())/(this.jo()-1));return this.ho()?ao(o,this.ko):o}Ho(){this.Co=null,this.Vo.Kl()}x_(){if(this.Oo()&&!this.zo())return;const t=this.co.fo;if(t===null)return;let n=null;const i=this.g_();let r=0,o=0;for(const u of i){if(!u.It())continue;const f=u.Lt();if(f===null)continue;const c=u.la(t.Na(),t.bi());let m=c&&c.ar();if(m!==null){switch(this.yn.mode){case 1:m=qr(m,this.ko);break;case 2:m=g_(m,f.Wt);break;case 3:m=y_(m,f.Wt)}if(n=n===null?m:n.Ss(ut(m)),c!==null){const y=c.lr();y!==null&&(r=Math.max(r,y.above),o=Math.max(o,y.below))}}}if(this.Xl()&&(r=Math.max(r,this.Ql()),o=Math.max(o,this.Ql())),r===this.vo&&o===this.mo||(this.vo=r,this.mo=o,this.Co=null,this.Lo()),n!==null){if(n.Je()===n.Qe()){const u=5*this.S_();this.ho()&&(n=pr(n,this.ko)),n=new hn(n.Je()-u,n.Qe()+u),this.ho()&&(n=qr(n,this.ko))}if(this.ho()){const u=pr(n,this.ko),f=xl(u);if(l=f,h=this.ko,l.Ol!==h.Ol||l.Nl!==h.Nl){const c=this.uo!==null?pr(this.uo,this.ko):null;this.ko=f,n=qr(u,f),c!==null&&(this.uo=qr(c,f))}}this.Wo(n)}else this.rr===null&&(this.Wo(new hn(-.5,.5)),this.ko=xl(null));var l,h}Qo(){return this.je()?mr:this.No()?oo:this.ho()?t=>Pa(t,this.ko):null}C_(t,n,i){return n===void 0?(i===void 0&&(i=this.sl()),i.format(t)):n(t)}y_(t,n,i){return n===void 0?(i===void 0&&(i=this.sl()),i.formatTickmarks(t)):n(t)}cr(t,n){return this.C_(t,this.Do.priceFormatter,n)}M_(t,n){const i=this.Do.priceFormatter;return this.y_(t,this.Do.tickmarksPriceFormatter??(i?r=>r.map(i):void 0),n)}m_(t,n){return this.C_(t,this.Do.percentageFormatter,n)}w_(t,n){const i=this.Do.percentageFormatter;return this.y_(t,this.Do.tickmarksPercentageFormatter??(i?r=>r.map(i):void 0),n)}}function dd(e){return e instanceof Va}class lc{constructor(t,n){this.bo=[],this.P_=new Map,this.oo=0,this.k_=0,this.T_=1,this.xo=null,this.R_=null,this.D_=!1,this.I_=new Ae,this.fa=[],this.ia=t,this.sn=n,this.V_=new p_(this);const i=n.N();this.B_=this.E_("left",i.leftPriceScale),this.A_=this.E_("right",i.rightPriceScale),this.B_.Uo().i(this.L_.bind(this,this.B_),this),this.A_.Uo().i(this.L_.bind(this,this.A_),this),this.z_(i)}z_(t){if(t.leftPriceScale&&this.B_.vr(t.leftPriceScale),t.rightPriceScale&&this.A_.vr(t.rightPriceScale),t.localization&&(this.B_.vl(),this.A_.vl()),t.overlayPriceScales){const n=Array.from(this.P_.values());for(const i of n){const r=ut(i[0].Ft());r.vr(t.overlayPriceScales),t.localization&&r.vl()}}}O_(t){switch(t){case"left":return this.B_;case"right":return this.A_}return this.P_.has(t)?xn(this.P_.get(t))[0].Ft():null}m(){this.Qt().N_().u(this),this.B_.Uo().u(this),this.A_.Uo().u(this),this.bo.forEach(t=>{t.m&&t.m()}),this.fa=this.fa.filter(t=>{const n=t.Qh();return n.detached&&n.detached(),!1}),this.I_.p()}F_(){return this.T_}W_(t){this.T_=t}Qt(){return this.sn}nn(){return this.k_}$t(){return this.oo}H_(t){this.k_=t,this.U_()}$o(t){this.oo=t,this.B_.$o(t),this.A_.$o(t),this.bo.forEach(n=>{if(this.Gs(n)){const i=n.Ft();i!==null&&i.$o(t)}}),this.U_()}j_(t){this.D_=t}q_(){return this.D_}Y_(){return this.bo.filter(dd)}kl(){return this.bo}Gs(t){const n=t.Ft();return n===null||this.B_!==n&&this.A_!==n}h_(t,n,i){this.K_(t,n,i?t.ln():this.bo.length)}l_(t,n){const i=this.bo.indexOf(t);Je(i!==-1,"removeDataSource: invalid data source"),this.bo.splice(i,1),n||this.bo.forEach((l,h)=>l._n(h));const r=ut(t.Ft()).pl();if(this.P_.has(r)){const l=xn(this.P_.get(r)),h=l.indexOf(t);h!==-1&&(l.splice(h,1),l.length===0&&this.P_.delete(r))}const o=t.Ft();o&&o.kl().indexOf(t)>=0&&(o.l_(t),this.G_(o)),this.Z_()}Xs(t){return t===this.B_?"left":t===this.A_?"right":"overlay"}X_(){return this.B_}J_(){return this.A_}Q_(t,n){t.u_(n)}tu(t,n){t.c_(n),this.U_()}iu(t){t.d_()}nu(t,n){t.f_(n)}su(t,n){t.p_(n),this.U_()}eu(t){t.v_()}U_(){this.bo.forEach(t=>{t.Nn()})}kn(){const[t,n]=this.ru();let i=null;return t.N().visible&&t.kl().length!==0?i=t:n.N().visible&&n.kl().length!==0?i=n:this.bo.length!==0&&(i=this.bo[0].Ft()),i===null&&(i=this.Zs()??t),i}Zs(){const[t,n]=this.ru();return t.N().visible?t:n.N().visible?n:null}G_(t){t!==null&&t.zo()&&this.hu(t)}au(t){const n=this.ia.Ee();t.Ao({hs:!0}),n!==null&&t.b_(n),this.U_()}lu(){this.hu(this.B_),this.hu(this.A_)}ou(){this.G_(this.B_),this.G_(this.A_),this.bo.forEach(t=>{this.Gs(t)&&this.G_(t.Ft())}),this.U_(),this.sn.mr()}Dt(){return this.xo===null&&(this.xo=up(this.bo)),this.xo}_u(){var l;const t=this.Dt(),n=(l=this.sn.cu())==null?void 0:l.uu,i=this.sn.N().hoveredSeriesOnTop,r=this.R_;if(r!==null&&r.Kh===t&&r.du===n&&r.fu===i)return r.pu;const o=function(h,u,f){if(!f)return h;const c=h.indexOf(u);if(c===-1||c===h.length-1)return h;const m=[];for(let y=0;y<h.length;y++)y!==c&&m.push(h[y]);return m.push(h[c]),m}(t,n,i);return this.R_={Kh:t,du:n,fu:i,pu:o},o}vu(t,n){n=vr(n,0,this.bo.length-1);const i=this.bo.indexOf(t);Je(i!==-1,"setSeriesOrder: invalid data source"),this.bo.splice(i,1),this.bo.splice(n,0,t),this.bo.forEach((r,o)=>r._n(o)),this.Z_();for(const r of[this.B_,this.A_])r.a_(),r.vl();this.sn.mr()}Vt(){return this.Dt().filter(dd)}mu(){return this.I_}wu(){return this.V_}ol(t){this.fa.push(new n_(t))}_l(t){this.fa=this.fa.filter(n=>n.Qh()!==t),t.detached&&t.detached(),this.sn.mr()}Mu(){return this.fa}il(t,n){return this.fa.map(i=>i.Qs(t,n)).filter(i=>i!==null)}hu(t){const n=t.g_();if(n&&n.length>0&&!this.ia.Zi()){const i=this.ia.Ee();i!==null&&t.b_(i)}t.Nn()}K_(t,n,i){let r=this.O_(n);if(r===null&&(r=this.E_(n,this.sn.N().overlayPriceScales)),this.bo.splice(i,0,t),!Fa(n)){const o=this.P_.get(n)||[];o.push(t),this.P_.set(n,o)}t._n(i),r.h_(t),t.un(r),this.G_(r),this.Z_()}Z_(){this.xo=null,this.R_=null}ru(){return this.sn.N().defaultVisiblePriceScaleId==="left"?[this.B_,this.A_]:[this.A_,this.B_]}L_(t,n,i){n._e!==i._e&&this.hu(t)}E_(t,n){const i={visible:!0,autoScale:!0,...Ei(n)},r=new v_(t,i,this.sn.N().layout,this.sn.N().localization,this.sn.Xi());return r.$o(this.$t()),r}}function cc(e,t){return t===null||e.se===2&&t.se!==2||(t.se!==2||e.se===2)&&e.ne!==t.ne&&e.ne<t.ne}function dp(e){return{te:e.te,ie:e.ie}}function b_(e){return{ne:e.distance??0,se:e.hitTestPriority??(e.itemType==="marker"?2:0),ee:e.itemType??"primitive",gu:e.cursorStyle,te:e.externalId}}function ea(e){return{uu:e.uu,bu:dp(e.Su),gu:e.Su.gu,ee:e.Su.ee??"primitive"}}function x_(e,t,n,i){var o;let r=null;for(const l of e){let h=((o=l.Qs)==null?void 0:o.call(l,t,n,i))??null;if(h===null){const u=l.Tt(i);h=u!==null&&u.Qs?u.Qs(t,n):null}if(h!==null){const u={xu:l,Su:h};(r===null||cc(u.Su,r.Su))&&(r=u)}}return r}function __(e){return e.jn!==void 0}function fp(e,t,n){const i=[e,...e.Dt()].reverse(),r=function(h,u,f){var p;let c,m,y;for(const E of h){const T=((p=E.il)==null?void 0:p.call(E,u,f))??[];for(const k of T){const A=b_(k);x=k.zOrder,_=c==null?void 0:c.zOrder,(!_||x==="top"&&_!=="top"||x==="normal"&&_==="bottom"||k.zOrder===(c==null?void 0:c.zOrder)&&m!==void 0&&cc(A,m)||k.zOrder===(c==null?void 0:c.zOrder)&&m===void 0)&&(c=k,m=A,y=E)}}var x,_;return c&&y&&m?{Su:m,Cu:c,uu:y}:null}(i,t,n);if((r==null?void 0:r.Cu.zOrder)==="top")return ea(r);let o=null,l=null;for(const h of i){if(r&&r.uu===h&&r.Cu.zOrder!=="bottom"&&!r.Cu.isBackground)return o??ea(r);if(__(h)){const u=x_(h.jn(e),t,n,e);if(u!==null){const f={uu:h,xu:u.xu,bu:dp(u.Su),gu:u.Su.gu,ee:u.Su.ee??"primitive"};(o===null||cc(u.Su,l))&&(o=f,l=u.Su)}}if(r&&r.uu===h&&r.Cu.zOrder!=="bottom"&&r.Cu.isBackground)return o??ea(r)}return o!==null?o:r!=null&&r.Cu?ea(r):null}class w_{constructor(t,n,i=50){this.Vs=0,this.Bs=1,this.Es=1,this.Ls=new Map,this.As=new Map,this.yu=t,this.Pu=n,this.zs=i}ku(t){const n=t.time,i=this.Pu.cacheKey(n),r=this.Ls.get(i);if(r!==void 0)return r.Tu;if(this.Vs===this.zs){const l=this.As.get(this.Es);this.As.delete(this.Es),this.Ls.delete(xn(l)),this.Es++,this.Vs--}const o=this.yu(t);return this.Ls.set(i,{Tu:o,Ws:this.Bs}),this.As.set(this.Bs,i),this.Vs++,this.Bs++,o}}class lo{constructor(t,n){Je(t<=n,"right should be >= left"),this.Ru=t,this.Du=n}Na(){return this.Ru}bi(){return this.Du}Iu(){return this.Du-this.Ru+1}ze(t){return this.Ru<=t&&t<=this.Du}Ze(t){return this.Ru===t.Na()&&this.Du===t.bi()}}function fd(e,t){return e===null||t===null?e===t:e.Ze(t)}class S_{constructor(){this.Vu=new Map,this.Ls=null,this.Bu=!1}Eu(t){this.Bu=t,this.Ls=null}Au(t,n){this.Lu(n),this.Ls=null;for(let i=n;i<t.length;++i){const r=t[i];let o=this.Vu.get(r.timeWeight);o===void 0&&(o=[],this.Vu.set(r.timeWeight,o)),o.push({index:i,time:r.time,weight:r.timeWeight,originalTime:r.originalTime})}}zu(t,n,i,r,o){const l=Math.ceil(n/t);return this.Ls!==null&&this.Ls.Ou===l&&o===this.Ls.Nu&&i===this.Ls.Fu||(this.Ls={Nu:o,Fu:i,zl:this.Wu(l,i,r),Ou:l}),this.Ls.zl}Lu(t){if(t===0)return void this.Vu.clear();const n=[];this.Vu.forEach((i,r)=>{t<=i[0].index?n.push(r):i.splice(Ds(i,t,o=>o.index<t),1/0)});for(const i of n)this.Vu.delete(i)}Wu(t,n,i){let r=[];const o=l=>!n||i.has(l.index);for(const l of Array.from(this.Vu.keys()).sort((h,u)=>u-h)){if(!this.Vu.get(l))continue;const h=r;r=[];const u=h.length;let f=0;const c=xn(this.Vu.get(l)),m=c.length;let y=1/0,x=-1/0;for(let _=0;_<m;_++){const p=c[_],E=p.index;for(;f<u;){const T=h[f],k=T.index;if(!(k<E&&o(T))){y=k;break}f++,r.push(T),x=k,y=1/0}if(y-E>=t&&E-x>=t&&o(p))r.push(p),x=E;else if(this.Bu)return h}for(;f<u;f++)o(h[f])&&r.push(h[f])}return r}}class br{constructor(t){this.Hu=t}Uu(){return this.Hu===null?null:new lo(Math.floor(this.Hu.Na()),Math.ceil(this.Hu.bi()))}$u(){return this.Hu}static ju(){return new br(null)}}function C_(e,t){return e.weight>t.weight?e:t}class M_{constructor(t,n,i,r){this.k_=0,this.qu=null,this.Yu=[],this.Po=null,this.yo=null,this.Ku=new S_,this.Gu=new Map,this.Zu=br.ju(),this.Xu=!0,this.Ju=new Ae,this.Qu=new Ae,this.tc=new Ae,this.nc=null,this.sc=null,this.ec=new Map,this.rc=-1,this.hc=[],this.ac=1,this.yn=n,this.Do=i,this.lc=n.rightOffset,this.oc=n.barSpacing,this.sn=t,this._c(n),this.Pu=r,this.uc(),this.Ku.Eu(n.uniformDistribution),this.cc(),this.dc()}N(){return this.yn}fc(t){Mn(this.Do,t),this.vc(),this.uc()}vr(t,n){Mn(this.yn,t),this.yn.fixLeftEdge&&this.mc(),this.yn.fixRightEdge&&this.wc(),t.barSpacing!==void 0&&this.sn.Ms(t.barSpacing),t.rightOffset!==void 0&&this.sn.gs(t.rightOffset),this._c(t),t.minBarSpacing===void 0&&t.maxBarSpacing===void 0||this.sn.Ms(t.barSpacing??this.oc),t.ignoreWhitespaceIndices!==void 0&&t.ignoreWhitespaceIndices!==this.yn.ignoreWhitespaceIndices&&this.dc(),this.vc(),this.uc(),t.enableConflation===void 0&&t.conflationThresholdFactor===void 0||this.cc(),this.tc.p()}Rn(t){var n;return((n=this.Yu[t])==null?void 0:n.time)??null}en(t){return this.Yu[t]??null}Mc(t,n){if(this.Yu.length<1)return null;if(this.Pu.key(t)>this.Pu.key(this.Yu[this.Yu.length-1].time))return n?this.Yu.length-1:null;const i=Ds(this.Yu,this.Pu.key(t),(r,o)=>this.Pu.key(r.time)<o);return this.Pu.key(t)<this.Pu.key(this.Yu[i].time)?n?i:null:i}Zi(){return this.k_===0||this.Yu.length===0||this.qu===null}gc(){return this.Yu.length>0}Ee(){return this.bc(),this.Zu.Uu()}Sc(){return this.bc(),this.Zu.$u()}xc(){const t=this.Ee();if(t===null)return null;const n={from:t.Na(),to:t.bi()};return this.Cc(n)}Cc(t){const n=Math.round(t.from),i=Math.round(t.to),r=ut(this.yc()),o=ut(this.Pc());return{from:ut(this.en(Math.max(r,n))),to:ut(this.en(Math.min(o,i)))}}kc(t){return{from:ut(this.Mc(t.from,!0)),to:ut(this.Mc(t.to,!0))}}nn(){return this.k_}H_(t){if(!isFinite(t)||t<=0||this.k_===t)return;const n=this.Sc(),i=this.k_;if(this.k_=t,this.Xu=!0,this.yn.lockVisibleTimeRangeOnResize&&i!==0){const r=this.oc*t/i;this.oc=r}if(this.yn.fixLeftEdge&&n!==null&&n.Na()<=0){const r=i-t;this.lc-=Math.round(r/this.oc)+1,this.Xu=!0}this.Tc(),this.Rc()}jt(t){if(this.Zi()||!bo(t))return 0;const n=this.Dc()+this.lc-t;return this.k_-(n+.5)*this.oc-1}Ic(t,n){const i=this.Dc(),r=n===void 0?0:n.from,o=n===void 0?t.length:n.to;for(let l=r;l<o;l++){const h=t[l].wt,u=i+this.lc-h,f=this.k_-(u+.5)*this.oc-1;t[l]._t=f}}Vc(t,n){const i=Math.ceil(this.Bc(t));return n&&this.yn.ignoreWhitespaceIndices&&!this.Ec(i)?this.Ac(i):i}gs(t){this.Xu=!0,this.lc=t,this.Rc(),this.sn.Lc(),this.sn.mr()}ml(){return this.oc}Ms(t){const n=this.oc;if(this.zc(t),this.yn.rightOffsetPixels!==void 0&&n!==0){const i=this.lc*n/this.oc;this.lc=i}this.Rc(),this.sn.Lc(),this.sn.mr()}Oc(){return this.lc}zl(){if(this.Zi())return null;if(this.sc!==null)return this.sc;const t=this.oc,n=5*(this.sn.N().layout.fontSize+4)/8*(this.yn.tickMarkMaxCharacterLength||8),i=Math.round(n/t),r=ut(this.Ee()),o=Math.max(r.Na(),r.Na()-i),l=Math.max(r.bi(),r.bi()-i),h=this.Ku.zu(t,n,this.yn.ignoreWhitespaceIndices,this.ec,this.rc),u=this.yc()+i,f=this.Pc()-i,c=this.Nc(),m=this.yn.fixLeftEdge||c,y=this.yn.fixRightEdge||c;let x=0;for(const _ of h){if(!(o<=_.index&&_.index<=l))continue;let p;x<this.hc.length?(p=this.hc[x],p.coord=this.jt(_.index),p.label=this.Fc(_),p.weight=_.weight):(p={needAlignCoordinate:!1,coord:this.jt(_.index),label:this.Fc(_),weight:_.weight},this.hc.push(p)),this.oc>n/2&&!c?p.needAlignCoordinate=!1:p.needAlignCoordinate=m&&_.index<=u||y&&_.index>=f,x++}return this.hc.length=x,this.sc=this.hc,this.hc}Wc(){let t;this.Xu=!0,this.Ms(this.yn.barSpacing),t=this.yn.rightOffsetPixels!==void 0?this.yn.rightOffsetPixels/this.ml():this.yn.rightOffset,this.gs(t)}Hc(t){this.Xu=!0,this.qu=t,this.Rc(),this.mc()}Uc(t,n){const i=this.Bc(t),r=this.ml(),o=r+n*(r/10);this.Ms(o),this.yn.rightBarStaysOnScroll||this.gs(this.Oc()+(i-this.Bc(t)))}u_(t){this.Po&&this.v_(),this.yo===null&&this.nc===null&&(this.Zi()||(this.yo=t,this.$c()))}c_(t){if(this.nc===null)return;const n=vr(this.k_-t,0,this.k_),i=vr(this.k_-ut(this.yo),0,this.k_);n!==0&&i!==0&&this.Ms(this.nc.ml*n/i)}d_(){this.yo!==null&&(this.yo=null,this.jc())}f_(t){this.Po===null&&this.nc===null&&(this.Zi()||(this.Po=t,this.$c()))}p_(t){if(this.Po===null)return;const n=(this.Po-t)/this.ml();this.lc=ut(this.nc).Oc+n,this.Xu=!0,this.Rc()}v_(){this.Po!==null&&(this.Po=null,this.jc())}qc(){this.Yc(this.yn.rightOffset)}Yc(t,n=400){if(!isFinite(t))throw new RangeError("offset is required and must be finite number");if(!isFinite(n)||n<=0)throw new RangeError("animationDuration (optional) must be finite positive number");const i=this.lc,r=performance.now();this.sn.ps({Kc:o=>(o-r)/n>=1,Gc:o=>{const l=(o-r)/n;return l>=1?t:i+(t-i)*l}})}Pt(t,n){this.Xu=!0,this.Yu=t,this.Ku.Au(t,n),this.Rc()}Zc(){return this.Ju}Xc(){return this.Qu}Jc(){return this.tc}Dc(){return this.qu||0}Qc(t,n){const i=t.Iu(),r=n&&this.yn.rightOffsetPixels||0;this.zc((this.k_-r)/i),this.lc=t.bi()-this.Dc(),n&&(this.lc=r?r/this.ml():this.yn.rightOffset),this.Rc(),this.Xu=!0,this.sn.Lc(),this.sn.mr()}td(){const t=this.yc(),n=this.Pc();if(t===null||n===null)return;const i=!this.yn.rightOffsetPixels&&this.yn.rightOffset||0;this.Qc(new lo(t,n+i),!0)}nd(t){const n=new lo(t.from,t.to);this.Qc(n)}rn(t){return this.Do.timeFormatter!==void 0?this.Do.timeFormatter(t.originalTime):this.Pu.formatHorzItem(t.time)}dc(){if(!this.yn.ignoreWhitespaceIndices)return;this.ec.clear();const t=this.sn.Jn();for(const n of t)for(const i of n.fl())this.ec.set(i,!0);this.rc++}sd(){return this.ac}Sl(){const t=1/(window.devicePixelRatio||1),n=this.yn.minBarSpacing;if(n>=t)return[1];const i=[1];let r=2;for(;r<=512;)n<t/r&&i.push(r),r*=2;return i}Nc(){const t=this.sn.N().handleScroll,n=this.sn.N().handleScale;return!(t.horzTouchDrag||t.mouseWheel||t.pressedMouseMove||t.vertTouchDrag||n.axisDoubleClickReset.time||n.axisPressedMouseMove.time||n.mouseWheel||n.pinch)}yc(){return this.Yu.length===0?null:0}Pc(){return this.Yu.length===0?null:this.Yu.length-1}ed(t){return(this.k_-1-t)/this.oc}Bc(t){const n=this.ed(t),i=this.Dc()+this.lc-n;return Math.round(1e6*i)/1e6}zc(t){const n=this.oc;this.oc=t,this.Tc(),n!==this.oc&&(this.Xu=!0,this.rd(),this.cc())}bc(){if(!this.Xu)return;if(this.Xu=!1,this.Zi())return void this.hd(br.ju());const t=this.Dc(),n=this.k_/this.oc,i=this.lc+t,r=new lo(i-n+1,i);this.hd(new br(r))}Tc(){const t=vr(this.oc,this.ad(),this.ld());this.oc!==t&&(this.oc=t,this.Xu=!0)}ld(){return this.yn.maxBarSpacing>0?this.yn.maxBarSpacing:.5*this.k_}ad(){return this.yn.fixLeftEdge&&this.yn.fixRightEdge&&this.Yu.length!==0?this.k_/this.Yu.length:this.yn.minBarSpacing}cc(){if(!this.yn.enableConflation)return void(this.ac=1);const t=1/(window.devicePixelRatio||1)*(this.yn.conflationThresholdFactor??1);if(this.oc>=t)return void(this.ac=1);const n=t/this.oc,i=Math.pow(2,Math.floor(Math.log2(n)));this.ac=Math.min(i,512)}Rc(){const t=this.od();t!==null&&this.lc<t&&(this.lc=t,this.Xu=!0);const n=this._d();this.lc>n&&(this.lc=n,this.Xu=!0)}od(){const t=this.yc(),n=this.qu;return t===null||n===null?null:t-n-1+(this.yn.fixLeftEdge?this.k_/this.oc:Math.min(2,this.Yu.length))}_d(){return this.yn.fixRightEdge?0:this.k_/this.oc-Math.min(2,this.Yu.length)}$c(){this.nc={ml:this.ml(),Oc:this.Oc()}}jc(){this.nc=null}Fc(t){let n=this.Gu.get(t.weight);return n===void 0&&(n=new w_(i=>this.ud(i),this.Pu),this.Gu.set(t.weight,n)),n.ku(t)}ud(t){return this.Pu.formatTickmark(t,this.Do)}hd(t){const n=this.Zu;this.Zu=t,fd(n.Uu(),this.Zu.Uu())||this.Ju.p(),fd(n.$u(),this.Zu.$u())||this.Qu.p(),this.rd()}rd(){this.sc=null}vc(){this.rd(),this.Gu.clear()}uc(){this.Pu.updateFormatter(this.Do)}mc(){if(!this.yn.fixLeftEdge)return;const t=this.yc();if(t===null)return;const n=this.Ee();if(n===null)return;const i=n.Na()-t;if(i<0){const r=this.lc-i-1;this.gs(r)}this.Tc()}wc(){this.Rc(),this.Tc()}Ec(t){return!this.yn.ignoreWhitespaceIndices||this.ec.get(t)||!1}Ac(t){const n=function*(r){const o=Math.round(r),l=o<r;let h=1;for(;;)l?(yield o+h,yield o-h):(yield o-h,yield o+h),h++}(t),i=this.Pc();for(;i;){const r=n.next().value;if(this.ec.get(r))return r;if(r<0||r>i)break}return t}_c(t){if(t.rightOffsetPixels!==void 0){const n=t.rightOffsetPixels/(t.barSpacing||this.oc);this.sn.gs(n)}}}var md,pd,gd,yd,vd;(function(e){e[e.OnTouchEnd=0]="OnTouchEnd",e[e.OnNextTap=1]="OnNextTap"})(md||(md={}));class k_{constructor(t,n,i){this.dd=[],this.fd=[],this.pd=null,this.k_=0,this.vd=null,this.md=new Ae,this.wd=new Ae,this.Md=null,this.gd=t,this.yn=n,this.Pu=i,this.Io=new _x(this.yn.layout.colorParsers),this.bd=new xx(this),this.ia=new M_(this,n.timeScale,this.yn.localization,i),this.Ct=new Nx(this,n.crosshair),this.Sd=new d_(n.crosshair),n.addDefaultPane&&(this.xd(0),this.dd[0].W_(2)),this.Cd=this.yd(0),this.Pd=this.yd(1)}ka(){this.kd(Ye.ys())}mr(){this.kd(Ye.Cs())}Ya(){this.kd(new Ye(1))}Ta(t){const n=this.Td(t);this.kd(n)}cu(){return this.vd}Rd(t){var i,r,o,l,h,u,f,c,m;if(((i=this.vd)==null?void 0:i.uu)===(t==null?void 0:t.uu)&&((o=(r=this.vd)==null?void 0:r.bu)==null?void 0:o.te)===((l=t==null?void 0:t.bu)==null?void 0:l.te)&&((u=(h=this.vd)==null?void 0:h.bu)==null?void 0:u.ie)===((f=t==null?void 0:t.bu)==null?void 0:f.ie)&&((c=this.vd)==null?void 0:c.gu)===(t==null?void 0:t.gu)&&((m=this.vd)==null?void 0:m.ee)===(t==null?void 0:t.ee))return;const n=this.vd;this.vd=t,n!==null&&this.Ta(n.uu),t!==null&&t.uu!==(n==null?void 0:n.uu)&&this.Ta(t.uu)}N(){return this.yn}vr(t){Mn(this.yn,t),this.dd.forEach(n=>n.z_(t)),t.timeScale!==void 0&&this.ia.vr(t.timeScale),t.localization!==void 0&&this.ia.fc(t.localization),(t.leftPriceScale||t.rightPriceScale)&&this.md.p(),this.Cd=this.yd(0),this.Pd=this.yd(1),this.ka()}Dd(t,n,i=0){const r=this.dd[i];if(r===void 0)return;if(t==="left")return Mn(this.yn,{leftPriceScale:n}),r.z_({leftPriceScale:n}),this.md.p(),void this.ka();if(t==="right")return Mn(this.yn,{rightPriceScale:n}),r.z_({rightPriceScale:n}),this.md.p(),void this.ka();const o=this.Id(t,i);o!==null&&(o.Ft.vr(n),this.md.p())}Id(t,n){const i=this.dd[n];if(i===void 0)return null;const r=i.O_(t);return r!==null?{Kn:i,Ft:r}:null}Et(){return this.ia}Gn(){return this.dd}Vd(){return this.Ct}Bd(){return this.wd}Ed(t,n){t.$o(n),this.Lc()}H_(t){this.k_=t,this.ia.H_(this.k_),this.dd.forEach(n=>n.H_(t)),this.Lc()}Ad(t){this.dd.length!==1&&(Je(t>=0&&t<this.dd.length,"Invalid pane index"),this.dd.splice(t,1),this.ka())}Ld(t,n){if(this.dd.length<2)return;Je(t>=0&&t<this.dd.length,"Invalid pane index");const i=this.dd[t],r=this.dd.reduce((m,y)=>m+y.F_(),0),o=this.dd.reduce((m,y)=>m+y.$t(),0),l=o-30*(this.dd.length-1);n=Math.min(l,Math.max(30,n));const h=r/o,u=i.$t();i.W_(n*h);let f=n-u,c=this.dd.length-1;for(const m of this.dd)if(m!==i){const y=Math.min(l,Math.max(30,m.$t()-f/c));f-=m.$t()-y,c-=1;const x=y*h;m.W_(x)}this.ka()}zd(t,n){Je(t>=0&&t<this.dd.length&&n>=0&&n<this.dd.length,"Invalid pane index");const i=this.dd[t],r=this.dd[n];this.dd[t]=r,this.dd[n]=i,this.ka()}Od(t,n){if(Je(t>=0&&t<this.dd.length&&n>=0&&n<this.dd.length,"Invalid pane index"),t===n)return;const[i]=this.dd.splice(t,1);this.dd.splice(n,0,i),this.ka()}Q_(t,n,i){t.Q_(n,i)}tu(t,n,i){t.tu(n,i),this.Ra(),this.kd(this.Nd(t,2))}iu(t,n){t.iu(n),this.kd(this.Nd(t,2))}nu(t,n,i){n.zo()||t.nu(n,i)}su(t,n,i){n.zo()||(t.su(n,i),this.Ra(),this.kd(this.Nd(t,2)))}eu(t,n){n.zo()||(t.eu(n),this.kd(this.Nd(t,2)))}au(t,n){t.au(n),this.kd(this.Nd(t,2))}Fd(t){this.ia.u_(t)}Wd(t,n){const i=this.Et();if(i.Zi()||n===0)return;const r=i.nn();t=Math.max(1,Math.min(t,r)),i.Uc(t,n),this.Lc()}Hd(t){this.Ud(0),this.$d(t),this.jd()}qd(t){this.ia.c_(t),this.Lc()}Yd(){this.ia.d_(),this.mr()}Ud(t){this.ia.f_(t)}$d(t){this.ia.p_(t),this.Lc()}jd(){this.ia.v_(),this.mr()}Jn(){return this.fd}Wn(){return this.pd===null&&(this.pd=this.fd.filter(t=>t.It())),this.pd}Pa(){this.pd=null}Kd(t,n,i,r,o){this.Ct.In(t,n);let l=NaN,h=this.ia.Vc(t,!0);const u=this.ia.Ee();u!==null&&(h=Math.min(Math.max(u.Na(),h),u.bi())),h=this.Ct.Fn(h);const f=r.kn(),c=f.Lt();if(c!==null&&(l=f.Tn(n,c)),l=this.Sd.Pl(l,h,r),this.Ct.An(h,l,r),this.Ya(),!o){const m=fp(r,t,n);this.Rd(m&&{uu:m.uu,bu:m.bu,gu:m.gu||null,ee:m.ee}),this.wd.p(this.Ct.Bt(),{x:t,y:n},i)}}Gd(t,n,i){const r=i.kn(),o=r.Lt(),l=r.Nt(t,ut(o)),h=this.ia.Mc(n,!0),u=this.ia.jt(ut(h));this.Kd(u,l,null,i,!0)}Zd(t){this.Vd().zn(),this.Ya(),t||this.wd.p(null,null,null)}Ra(){const t=this.Ct.Kn();if(t!==null){const n=this.Ct.Bn(),i=this.Ct.En();this.Kd(n,i,null,t)}this.Ct.Nn()}Xd(t,n,i){const r=this.ia.Rn(0);n!==void 0&&i!==void 0&&this.ia.Pt(n,i);const o=this.ia.Rn(0),l=this.ia.Dc(),h=this.ia.Ee();if(h!==null&&r!==null&&o!==null){const u=h.ze(l),f=this.Pu.key(r)>this.Pu.key(o),c=t!==null&&t>l&&!f,m=this.ia.N().allowShiftVisibleRangeOnWhitespaceReplacement,y=u&&(i!==void 0||m)&&this.ia.N().shiftVisibleRangeOnNewBar;if(c&&!y){const x=t-l;this.ia.gs(this.ia.Oc()-x)}}this.ia.Hc(t)}Ba(t){t!==null&&t.ou()}Ks(t){if(function(i){return i instanceof lc}(t))return t;const n=this.dd.find(i=>i.Dt().includes(t));return n===void 0?null:n}Lc(){this.dd.forEach(t=>t.ou()),this.Ra()}m(){this.dd.forEach(t=>t.m()),this.dd.length=0,this.yn.localization.priceFormatter=void 0,this.yn.localization.percentageFormatter=void 0,this.yn.localization.timeFormatter=void 0}Jd(){return this.bd}Js(){return this.bd.N()}N_(){return this.md}Qd(t,n){const i=this.xd(n);this.tf(t,i),this.fd.push(t),this.Pa(),this.fd.length===1?this.ka():this.mr()}if(t){const n=this.Ks(t),i=this.fd.indexOf(t);Je(i!==-1,"Series not found");const r=ut(n);this.fd.splice(i,1),r.l_(t),t.m&&t.m(),this.Pa(),this.ia.dc(),this.nf(r)}ya(t,n){const i=ut(this.Ks(t));i.l_(t,!0),i.h_(t,n,!0)}td(){const t=Ye.Cs();t.us(),this.kd(t)}sf(t){const n=Ye.Cs();n.fs(t),this.kd(n)}ws(){const t=Ye.Cs();t.ws(),this.kd(t)}Ms(t){const n=Ye.Cs();n.Ms(t),this.kd(n)}gs(t){const n=Ye.Cs();n.gs(t),this.kd(n)}ps(t){const n=Ye.Cs();n.ps(t),this.kd(n)}cs(){const t=Ye.Cs();t.cs(),this.kd(t)}ef(){const t=this.yn.defaultVisiblePriceScaleId,n=this.yn.leftPriceScale.visible;return n!==this.yn.rightPriceScale.visible?n?"left":"right":t}rf(t,n){if(Je(n>=0,"Index should be greater or equal to 0"),n===this.hf(t))return;const i=ut(this.Ks(t));i.l_(t);const r=this.xd(n);this.tf(t,r);let o=!1;i.kl().length===0&&(o=this.nf(i)),o||this.ka()}af(){return this.Pd}$(){return this.Cd}Ut(t){const n=this.Pd,i=this.Cd;if(n===i)return n;if(t=Math.max(0,Math.min(100,Math.round(100*t))),this.Md===null||this.Md.ah!==i||this.Md.oh!==n)this.Md={ah:i,oh:n,lf:new Map};else{const o=this.Md.lf.get(t);if(o!==void 0)return o}const r=this.Io.tt(i,n,t/100);return this.Md.lf.set(t,r),r}_f(t){return this.dd.indexOf(t)}Xi(){return this.Io}uf(){return this.cf()}cf(t){const n=new lc(this.ia,this);this.dd.push(n);const i=t??this.dd.length-1,r=Ye.ys();return r.es(i,{rs:0,hs:!0}),this.kd(r),n}xd(t){return Je(t>=0,"Index should be greater or equal to 0"),(t=Math.min(this.dd.length,t))<this.dd.length?this.dd[t]:this.cf(t)}hf(t){return this.dd.findIndex(n=>n.Y_().includes(t))}Nd(t,n){const i=new Ye(n);if(t!==null){const r=this.dd.indexOf(t);i.es(r,{rs:n})}return i}Td(t,n){return n===void 0&&(n=2),this.Nd(this.Ks(t),n)}kd(t){this.gd&&this.gd(t),this.dd.forEach(n=>n.wu().wr().Pt())}tf(t,n){const i=t.N().priceScaleId,r=i!==void 0?i:this.ef();n.h_(t,r),Fa(r)||t.vr(t.N())}yd(t){const n=this.yn.layout;return n.background.type==="gradient"?t===0?n.background.topColor:n.background.bottomColor:n.background.color}nf(t){return!t.q_()&&t.kl().length===0&&this.dd.length>1&&(this.dd.splice(this._f(t),1),this.ka(),!0)}}function mp(e){if(e>=1)return 0;let t=0;for(;t<8;t++){const n=Math.round(e);if(Math.abs(n-e)<1e-8)return t;e*=10}return t}function hc(e){return!Sr(e)&&!ko(e)}function pp(e){return Sr(e)}(function(e){e[e.Disabled=0]="Disabled",e[e.Continuous=1]="Continuous",e[e.OnDataUpdate=2]="OnDataUpdate"})(pd||(pd={})),function(e){e[e.LastBar=0]="LastBar",e[e.LastVisible=1]="LastVisible"}(gd||(gd={})),function(e){e.Solid="solid",e.VerticalGradient="gradient"}(yd||(yd={})),function(e){e[e.Year=0]="Year",e[e.Month=1]="Month",e[e.DayOfMonth=2]="DayOfMonth",e[e.Time=3]="Time",e[e.TimeWithSeconds=4]="TimeWithSeconds"}(vd||(vd={}));const bd=e=>e.getUTCFullYear();function T_(e,t,n){return t.replace(/yyyy/g,(i=>Li(bd(i),4))(e)).replace(/yy/g,(i=>Li(bd(i)%100,2))(e)).replace(/MMMM/g,((i,r)=>new Date(i.getUTCFullYear(),i.getUTCMonth(),1).toLocaleString(r,{month:"long"}))(e,n)).replace(/MMM/g,((i,r)=>new Date(i.getUTCFullYear(),i.getUTCMonth(),1).toLocaleString(r,{month:"short"}))(e,n)).replace(/MM/g,(i=>Li((r=>r.getUTCMonth()+1)(i),2))(e)).replace(/dd/g,(i=>Li((r=>r.getUTCDate())(i),2))(e))}class gp{constructor(t="yyyy-MM-dd",n="default"){this.df=t,this.ff=n}ku(t){return T_(t,this.df,this.ff)}}class P_{constructor(t){this.pf=t||"%h:%m:%s"}ku(t){return this.pf.replace("%h",Li(t.getUTCHours(),2)).replace("%m",Li(t.getUTCMinutes(),2)).replace("%s",Li(t.getUTCSeconds(),2))}}const E_={vf:"yyyy-MM-dd",mf:"%h:%m:%s",wf:" ",Mf:"default"};class L_{constructor(t={}){const n={...E_,...t};this.gf=new gp(n.vf,n.Mf),this.bf=new P_(n.mf),this.Sf=n.wf}ku(t){return`${this.gf.ku(t)}${this.Sf}${this.bf.ku(t)}`}}function na(e){return 60*e*60*1e3}function wl(e){return 60*e*1e3}const ia=[{xf:(xd=1,1e3*xd),Cf:10},{xf:wl(1),Cf:20},{xf:wl(5),Cf:21},{xf:wl(30),Cf:22},{xf:na(1),Cf:30},{xf:na(3),Cf:31},{xf:na(6),Cf:32},{xf:na(12),Cf:33}];var xd;function _d(e,t){if(e.getUTCFullYear()!==t.getUTCFullYear())return 70;if(e.getUTCMonth()!==t.getUTCMonth())return 60;if(e.getUTCDate()!==t.getUTCDate())return 50;for(let n=ia.length-1;n>=0;--n)if(Math.floor(t.getTime()/ia[n].xf)!==Math.floor(e.getTime()/ia[n].xf))return ia[n].Cf;return 0}function Sl(e){let t=e;if(ko(e)&&(t=mh(e)),!hc(t))throw new Error("time must be of type BusinessDay");const n=new Date(Date.UTC(t.year,t.month-1,t.day,0,0,0,0));return{yf:Math.round(n.getTime()/1e3),Pf:t}}function wd(e){if(!pp(e))throw new Error("time must be of type isUTCTimestamp");return{yf:e}}function mh(e){const t=new Date(e);if(isNaN(t.getTime()))throw new Error(`Invalid date string=${e}, expected format=yyyy-mm-dd`);return{day:t.getUTCDate(),month:t.getUTCMonth()+1,year:t.getUTCFullYear()}}function Sd(e){ko(e.time)&&(e.time=mh(e.time))}class Cd{options(){return this.yn}setOptions(t){this.yn=t,this.updateFormatter(t.localization)}preprocessData(t){Array.isArray(t)?function(n){n.forEach(Sd)}(t):Sd(t)}createConverterToInternalObj(t){return ut(function(n){return n.length===0?null:hc(n[0].time)||ko(n[0].time)?Sl:wd}(t))}key(t){return typeof t=="object"&&"yf"in t?t.yf:this.key(this.convertHorzItemToInternal(t))}cacheKey(t){const n=t;return n.Pf===void 0?new Date(1e3*n.yf).getTime():new Date(Date.UTC(n.Pf.year,n.Pf.month-1,n.Pf.day)).getTime()}convertHorzItemToInternal(t){return pp(n=t)?wd(n):hc(n)?Sl(n):Sl(mh(n));var n}updateFormatter(t){if(!this.yn)return;const n=t.dateFormat;this.yn.timeScale.timeVisible?this.kf=new L_({vf:n,mf:this.yn.timeScale.secondsVisible?"%h:%m:%s":"%h:%m",wf:" ",Mf:t.locale}):this.kf=new gp(n,t.locale)}formatHorzItem(t){const n=t;return this.kf.ku(new Date(1e3*n.yf))}formatTickmark(t,n){const i=function(o,l,h){switch(o){case 0:case 10:return l?h?4:3:2;case 20:case 21:case 22:case 30:case 31:case 32:case 33:return l?3:2;case 50:return 2;case 60:return 1;case 70:return 0}}(t.weight,this.yn.timeScale.timeVisible,this.yn.timeScale.secondsVisible),r=this.yn.timeScale;if(r.tickMarkFormatter!==void 0){const o=r.tickMarkFormatter(t.originalTime,i,n.locale);if(o!==null)return o}return function(o,l,h){const u={};switch(l){case 0:u.year="numeric";break;case 1:u.month="short";break;case 2:u.day="numeric";break;case 3:u.hour12=!1,u.hour="2-digit",u.minute="2-digit";break;case 4:u.hour12=!1,u.hour="2-digit",u.minute="2-digit",u.second="2-digit"}const f=o.Pf===void 0?new Date(1e3*o.yf):new Date(Date.UTC(o.Pf.year,o.Pf.month-1,o.Pf.day));return new Date(f.getUTCFullYear(),f.getUTCMonth(),f.getUTCDate(),f.getUTCHours(),f.getUTCMinutes(),f.getUTCSeconds(),f.getUTCMilliseconds()).toLocaleString(h,u)}(t.time,i,n.locale)}maxTickMarkWeight(t){let n=t.reduce(C_,t[0]).weight;return n>30&&n<50&&(n=30),n}fillWeightsForPoints(t,n){(function(i,r=0){if(i.length===0)return;let o=r===0?null:i[r-1].time.yf,l=o!==null?new Date(1e3*o):null,h=0;for(let u=r;u<i.length;++u){const f=i[u],c=new Date(1e3*f.time.yf);l!==null&&(f.timeWeight=_d(c,l)),h+=f.time.yf-(o||f.time.yf),o=f.time.yf,l=c}if(r===0&&i.length>1){const u=Math.ceil(h/(i.length-1)),f=new Date(1e3*(i[0].time.yf-u));i[0].timeWeight=_d(new Date(1e3*i[0].time.yf),f)}})(t,n)}static Tf(t){return Mn({localization:{dateFormat:"dd MMM 'yy"}},t??{})}}const Cr=typeof window<"u";function Md(){return!!Cr&&window.navigator.userAgent.toLowerCase().indexOf("firefox")>-1}function Cl(){return!!Cr&&/iPhone|iPad|iPod/.test(window.navigator.platform)}function A_(e,t){switch(e){case"custom":return t!==void 0?"custom-object":"series";case"price-line":return"custom-price-line";case"marker":return"series-marker";case"primitive":return"primitive";default:return"series"}}function uc(e){return e+e%2}function R_(e){Cr&&window.chrome!==void 0&&e.addEventListener("mousedown",t=>{if(t.button===1)return t.preventDefault(),!1})}class ja{constructor(t,n,i){this.Rf=0,this.Df=null,this.If={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY},this.Vf=0,this.Bf=null,this.Ef={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY},this.Af=null,this.Lf=!1,this.zf=null,this.Of=null,this.Nf=!1,this.Ff=!1,this.Wf=!1,this.Hf=null,this.Uf=null,this.$f=null,this.jf=null,this.qf=null,this.Yf=null,this.Kf=null,this.Gf=0,this.Zf=!1,this.Xf=!1,this.Jf=!1,this.Qf=0,this.tp=null,this.ip=!Cl(),this.np=r=>{this.sp(r)},this.ep=r=>{if(this.rp(r)){const o=this.hp(r);if(++this.Vf,this.Bf&&this.Vf>1){const{ap:l}=this.lp(oi(r),this.Ef);l<30&&!this.Wf&&this.op(o,this.up._p),this.cp()}}else{const o=this.hp(r);if(++this.Rf,this.Df&&this.Rf>1){const{ap:l}=this.lp(oi(r),this.If);l<5&&!this.Ff&&this.dp(o,this.up.fp),this.pp()}}},this.vp=t,this.up=n,this.yn=i,this.mp()}m(){this.Hf!==null&&(this.Hf(),this.Hf=null),this.Uf!==null&&(this.Uf(),this.Uf=null),this.jf!==null&&(this.jf(),this.jf=null),this.qf!==null&&(this.qf(),this.qf=null),this.Yf!==null&&(this.Yf(),this.Yf=null),this.$f!==null&&(this.$f(),this.$f=null),this.wp(),this.pp()}Mp(t){this.jf&&this.jf();const n=this.gp.bind(this);if(this.jf=()=>{this.vp.removeEventListener("mousemove",n)},this.vp.addEventListener("mousemove",n),this.rp(t))return;const i=this.hp(t);this.dp(i,this.up.bp),this.ip=!0}pp(){this.Df!==null&&clearTimeout(this.Df),this.Rf=0,this.Df=null,this.If={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY}}cp(){this.Bf!==null&&clearTimeout(this.Bf),this.Vf=0,this.Bf=null,this.Ef={_t:Number.NEGATIVE_INFINITY,ut:Number.POSITIVE_INFINITY}}gp(t){if(this.Jf||this.Of!==null||this.rp(t))return;const n=this.hp(t);this.dp(n,this.up.Sp),this.ip=!0}xp(t){const n=Ml(t.changedTouches,ut(this.tp));if(n===null||(this.Qf=sa(t),this.Kf!==null)||this.Xf)return;this.Zf=!0;const i=this.lp(oi(n),ut(this.Of)),{Cp:r,yp:o,ap:l}=i;if(this.Nf||!(l<5)){if(!this.Nf){const h=.5*r,u=o>=h&&!this.yn.Pp(),f=h>o&&!this.yn.kp();u||f||(this.Xf=!0),this.Nf=!0,this.Wf=!0,this.wp(),this.cp()}if(!this.Xf){const h=this.hp(t,n);this.op(h,this.up.Tp),or(t)}}}Rp(t){if(t.button!==0)return;const n=this.lp(oi(t),ut(this.zf)),{ap:i}=n;if(i>=5&&(this.Ff=!0,this.pp()),this.Ff){const r=this.hp(t);this.dp(r,this.up.Dp)}}lp(t,n){const i=Math.abs(n._t-t._t),r=Math.abs(n.ut-t.ut);return{Cp:i,yp:r,ap:i+r}}Ip(t){let n=Ml(t.changedTouches,ut(this.tp));if(n===null&&t.touches.length===0&&(n=t.changedTouches[0]),n===null)return;this.tp=null,this.Qf=sa(t),this.wp(),this.Of=null,this.Yf&&(this.Yf(),this.Yf=null);const i=this.hp(t,n);if(this.op(i,this.up.Vp),++this.Vf,this.Bf&&this.Vf>1){const{ap:r}=this.lp(oi(n),this.Ef);r<30&&!this.Wf&&this.op(i,this.up._p),this.cp()}else this.Wf||(this.op(i,this.up.Bp),this.up.Bp&&or(t));this.Vf===0&&or(t),t.touches.length===0&&this.Lf&&(this.Lf=!1,or(t))}sp(t){if(t.button!==0)return;const n=this.hp(t);if(this.zf=null,this.Jf=!1,this.qf&&(this.qf(),this.qf=null),Md()&&this.vp.ownerDocument.documentElement.removeEventListener("mouseleave",this.np),!this.rp(t))if(this.dp(n,this.up.Ep),++this.Rf,this.Df&&this.Rf>1){const{ap:i}=this.lp(oi(t),this.If);i<5&&!this.Ff&&this.dp(n,this.up.fp),this.pp()}else this.Ff||this.dp(n,this.up.Ap)}wp(){this.Af!==null&&(clearTimeout(this.Af),this.Af=null)}Lp(t){if(this.tp!==null)return;const n=t.changedTouches[0];this.tp=n.identifier,this.Qf=sa(t);const i=this.vp.ownerDocument.documentElement;this.Wf=!1,this.Nf=!1,this.Xf=!1,this.Of=oi(n),this.Yf&&(this.Yf(),this.Yf=null);{const o=this.xp.bind(this),l=this.Ip.bind(this);this.Yf=()=>{i.removeEventListener("touchmove",o),i.removeEventListener("touchend",l)},i.addEventListener("touchmove",o,{passive:!1}),i.addEventListener("touchend",l,{passive:!1}),this.wp(),this.Af=setTimeout(this.zp.bind(this,t),240)}const r=this.hp(t,n);this.op(r,this.up.Op),this.Bf||(this.Vf=0,this.Bf=setTimeout(this.cp.bind(this),500),this.Ef=oi(n))}Np(t){if(t.button!==0)return;const n=this.vp.ownerDocument.documentElement;Md()&&n.addEventListener("mouseleave",this.np),this.Ff=!1,this.zf=oi(t),this.qf&&(this.qf(),this.qf=null);{const r=this.Rp.bind(this),o=this.sp.bind(this);this.qf=()=>{n.removeEventListener("mousemove",r),n.removeEventListener("mouseup",o)},n.addEventListener("mousemove",r),n.addEventListener("mouseup",o)}if(this.Jf=!0,this.rp(t))return;const i=this.hp(t);this.dp(i,this.up.Fp),this.Df||(this.Rf=0,this.Df=setTimeout(this.pp.bind(this),500),this.If=oi(t))}mp(){this.vp.addEventListener("mouseenter",this.Mp.bind(this)),this.vp.addEventListener("touchcancel",this.wp.bind(this));{const t=this.vp.ownerDocument,n=i=>{this.up.Wp&&(i.composed&&this.vp.contains(i.composedPath()[0])||i.target&&this.vp.contains(i.target)||this.up.Wp())};this.Uf=()=>{t.removeEventListener("touchstart",n)},this.Hf=()=>{t.removeEventListener("mousedown",n)},t.addEventListener("mousedown",n),t.addEventListener("touchstart",n,{passive:!0})}Cl()&&(this.$f=()=>{this.vp.removeEventListener("dblclick",this.ep)},this.vp.addEventListener("dblclick",this.ep)),this.vp.addEventListener("mouseleave",this.Hp.bind(this)),this.vp.addEventListener("touchstart",this.Lp.bind(this),{passive:!0}),R_(this.vp),this.vp.addEventListener("mousedown",this.Np.bind(this)),this.Up(),this.vp.addEventListener("touchmove",()=>{},{passive:!1})}Up(){this.up.$p===void 0&&this.up.jp===void 0&&this.up.qp===void 0||(this.vp.addEventListener("touchstart",t=>this.Yp(t.touches),{passive:!0}),this.vp.addEventListener("touchmove",t=>{if(t.touches.length===2&&this.Kf!==null&&this.up.jp!==void 0){const n=kd(t.touches[0],t.touches[1])/this.Gf;this.up.jp(this.Kf,n),or(t)}},{passive:!1}),this.vp.addEventListener("touchend",t=>{this.Yp(t.touches)}))}Yp(t){t.length===1&&(this.Zf=!1),t.length!==2||this.Zf||this.Lf?this.Kp():this.Gp(t)}Gp(t){const n=this.vp.getBoundingClientRect()||{left:0,top:0};this.Kf={_t:(t[0].clientX-n.left+(t[1].clientX-n.left))/2,ut:(t[0].clientY-n.top+(t[1].clientY-n.top))/2},this.Gf=kd(t[0],t[1]),this.up.$p!==void 0&&this.up.$p(),this.wp()}Kp(){this.Kf!==null&&(this.Kf=null,this.up.qp!==void 0&&this.up.qp())}Hp(t){if(this.jf&&this.jf(),this.rp(t)||!this.ip)return;const n=this.hp(t);this.dp(n,this.up.Zp),this.ip=!Cl()}zp(t){const n=Ml(t.touches,ut(this.tp));if(n===null)return;const i=this.hp(t,n);this.op(i,this.up.Xp),this.Wf=!0,this.Lf=!0}rp(t){return t.sourceCapabilities&&t.sourceCapabilities.firesTouchEvents!==void 0?t.sourceCapabilities.firesTouchEvents:sa(t)<this.Qf+500}op(t,n){n&&n.call(this.up,t)}dp(t,n){n&&n.call(this.up,t)}hp(t,n){const i=n||t,r=this.vp.getBoundingClientRect()||{left:0,top:0};return{clientX:i.clientX,clientY:i.clientY,pageX:i.pageX,pageY:i.pageY,screenX:i.screenX,screenY:i.screenY,localX:i.clientX-r.left,localY:i.clientY-r.top,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey,metaKey:t.metaKey,Jp:!t.type.startsWith("mouse")&&t.type!=="contextmenu"&&t.type!=="click",Qp:t.type,tv:i.target,xu:t.view,iv:()=>{t.type!=="touchstart"&&or(t)}}}}function kd(e,t){const n=e.clientX-t.clientX,i=e.clientY-t.clientY;return Math.sqrt(n*n+i*i)}function or(e){e.cancelable&&e.preventDefault()}function oi(e){return{_t:e.pageX,ut:e.pageY}}function sa(e){return e.timeStamp||performance.now()}function Ml(e,t){for(let n=0;n<e.length;++n)if(e[n].identifier===t)return e[n];return null}class N_{constructor(t,n,i){this.nv=null,this.sv=null,this.ev=!0,this.rv=null,this.hv=t,this.av=t.lv()[n],this.ov=t.lv()[i],this._v=document.createElement("tr"),this._v.style.height="1px",this.uv=document.createElement("td"),this.uv.style.position="relative",this.uv.style.padding="0",this.uv.style.margin="0",this.uv.setAttribute("colspan","3"),this.cv(),this._v.appendChild(this.uv),this.ev=this.hv.N().layout.panes.enableResize,this.ev?this.dv():(this.nv=null,this.sv=null)}m(){this.sv!==null&&this.sv.m()}fv(){return this._v}pv(){return de({width:this.av.pv().width,height:1})}vv(){return de({width:this.av.vv().width,height:1*window.devicePixelRatio})}mv(t,n,i){const r=this.vv();t.fillStyle=this.hv.N().layout.panes.separatorColor,t.fillRect(n,i,r.width,r.height)}Pt(){this.cv(),this.hv.N().layout.panes.enableResize!==this.ev&&(this.ev=this.hv.N().layout.panes.enableResize,this.ev?this.dv():(this.nv!==null&&(this.uv.removeChild(this.nv.wv),this.uv.removeChild(this.nv.Mv),this.nv=null),this.sv!==null&&(this.sv.m(),this.sv=null)))}dv(){const t=document.createElement("div"),n=t.style;n.position="fixed",n.display="none",n.zIndex="49",n.top="0",n.left="0",n.width="100%",n.height="100%",n.cursor="row-resize",this.uv.appendChild(t);const i=document.createElement("div"),r=i.style;r.position="absolute",r.zIndex="50",r.top="-4px",r.height="9px",r.width="100%",r.backgroundColor="",r.cursor="row-resize",this.uv.appendChild(i);const o={bp:this.gv.bind(this),Zp:this.bv.bind(this),Fp:this.Sv.bind(this),Op:this.Sv.bind(this),Dp:this.xv.bind(this),Tp:this.xv.bind(this),Ep:this.Cv.bind(this),Vp:this.Cv.bind(this)};this.sv=new ja(i,o,{Pp:()=>!1,kp:()=>!0}),this.nv={Mv:i,wv:t}}cv(){this.uv.style.background=this.hv.N().layout.panes.separatorColor}gv(t){this.nv!==null&&(this.nv.Mv.style.backgroundColor=this.hv.N().layout.panes.separatorHoverColor)}bv(t){this.nv!==null&&this.rv===null&&(this.nv.Mv.style.backgroundColor="")}Sv(t){if(this.nv===null)return;const n=this.av.yv().F_()+this.ov.yv().F_(),i=n/(this.av.pv().height+this.ov.pv().height),r=30*i;n<=2*r||(this.rv={Pv:t.pageY,kv:this.av.yv().F_(),Tv:n-r,Rv:n,Dv:i,Iv:r},this.nv.wv.style.display="block")}xv(t){const n=this.rv;if(n===null)return;const i=(t.pageY-n.Pv)*n.Dv,r=vr(n.kv+i,n.Iv,n.Tv);this.av.yv().W_(r),this.ov.yv().W_(n.Rv-r),this.hv.Qt().ka()}Cv(t){this.rv!==null&&this.nv!==null&&(this.rv=null,this.nv.wv.style.display="none")}}function kl(e,t){return e.Vv-t.Vv}function Tl(e,t,n){const i=(e.Vv-t.Vv)/(e.wt-t.wt);return Math.sign(i)*Math.min(Math.abs(i),n)}class I_{constructor(t,n,i,r){this.Bv=null,this.Ev=null,this.Av=null,this.Lv=null,this.zv=null,this.Ov=0,this.Nv=0,this.Fv=t,this.Wv=n,this.Hv=i,this.Ps=r}Uv(t,n){if(this.Bv!==null){if(this.Bv.wt===n)return void(this.Bv.Vv=t);if(Math.abs(this.Bv.Vv-t)<this.Ps)return}this.Lv=this.Av,this.Av=this.Ev,this.Ev=this.Bv,this.Bv={wt:n,Vv:t}}me(t,n){if(this.Bv===null||this.Ev===null||n-this.Bv.wt>50)return;let i=0;const r=Tl(this.Bv,this.Ev,this.Wv),o=kl(this.Bv,this.Ev),l=[r],h=[o];if(i+=o,this.Av!==null){const f=Tl(this.Ev,this.Av,this.Wv);if(Math.sign(f)===Math.sign(r)){const c=kl(this.Ev,this.Av);if(l.push(f),h.push(c),i+=c,this.Lv!==null){const m=Tl(this.Av,this.Lv,this.Wv);if(Math.sign(m)===Math.sign(r)){const y=kl(this.Av,this.Lv);l.push(m),h.push(y),i+=y}}}}let u=0;for(let f=0;f<l.length;++f)u+=h[f]/i*l[f];Math.abs(u)<this.Fv||(this.zv={Vv:t,wt:n},this.Nv=u,this.Ov=function(f,c){const m=Math.log(c);return Math.log(1*m/-f)/m}(Math.abs(u),this.Hv))}Gc(t){const n=ut(this.zv),i=t-n.wt;return n.Vv+this.Nv*(Math.pow(this.Hv,i)-1)/Math.log(this.Hv)}Kc(t){return this.zv===null||this.$v(t)===this.Ov}$v(t){const n=t-ut(this.zv).wt;return Math.min(n,this.Ov)}}class z_{constructor(t,n){this.jv=void 0,this.qv=void 0,this.Yv=void 0,this.vn=!1,this.Kv=t,this.Gv=n,this.Zv()}Pt(){this.Zv()}Xv(){this.jv&&this.Kv.removeChild(this.jv),this.qv&&this.Kv.removeChild(this.qv),this.jv=void 0,this.qv=void 0}Jv(){return this.vn!==this.Qv()||this.Yv!==this.tm()}tm(){return this.Gv.Qt().Xi().J(this.Gv.N().layout.textColor)>160?"dark":"light"}Qv(){return this.Gv.N().layout.attributionLogo}im(){const t=new URL(location.href);return t.hostname?"&utm_source="+t.hostname+t.pathname:""}Zv(){this.Jv()&&(this.Xv(),this.vn=this.Qv(),this.vn&&(this.Yv=this.tm(),this.qv=document.createElement("style"),this.qv.innerText="a#tv-attr-logo{--fill:#131722;--stroke:#fff;position:absolute;left:10px;bottom:10px;height:19px;width:35px;margin:0;padding:0;border:0;z-index:3;}a#tv-attr-logo[data-dark]{--fill:#D1D4DC;--stroke:#131722;}",this.jv=document.createElement("a"),this.jv.href=`https://www.tradingview.com/?utm_medium=lwc-link&utm_campaign=lwc-chart${this.im()}`,this.jv.title="Charting by TradingView",this.jv.id="tv-attr-logo",this.jv.target="_blank",this.jv.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="35" height="19" fill="none"><g fill-rule="evenodd" clip-path="url(#a)" clip-rule="evenodd"><path fill="var(--stroke)" d="M2 0H0v10h6v9h21.4l.5-1.3 6-15 1-2.7H23.7l-.5 1.3-.2.6a5 5 0 0 0-7-.9V0H2Zm20 17h4l5.2-13 .8-2h-7l-1 2.5-.2.5-1.5 3.8-.3.7V17Zm-.8-10a3 3 0 0 0 .7-2.7A3 3 0 1 0 16.8 7h4.4ZM14 7V2H2v6h6v9h4V7h2Z"/><path fill="var(--fill)" d="M14 2H2v6h6v9h6V2Zm12 15h-7l6-15h7l-6 15Zm-7-9a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"/></g><defs><clipPath id="a"><path fill="var(--stroke)" d="M0 0h35v19H0z"/></clipPath></defs></svg>',this.jv.toggleAttribute("data-dark",this.Yv==="dark"),this.Kv.appendChild(this.qv),this.Kv.appendChild(this.jv)))}}function $s(e,t){const n=ut(e.ownerDocument).createElement("canvas");e.appendChild(n);const i=gx(n,{options:{allowResizeObserver:!0},transform:(r,o)=>({width:Math.max(r.width,o.width),height:Math.max(r.height,o.height)})});return i.resizeCanvasElement(t),i}function Bs(e){var t;e.width=1,e.height=1,(t=e.getContext("2d"))==null||t.clearRect(0,0,1,1)}function ha(e,t,n,i){e.qh&&e.qh(t,n,i)}function Kr(e,t,n,i){e.st(t,n,i)}function dc(e,t,n,i){yp(e(n,i),t,i)}function yp(e,t,n){for(const i of e){const r=i.Tt(n);r!==null&&t(r)}}function Pl(e,t){return n=>{var i,r;return function(o){return o.Ft!==void 0}(n)?(((i=n.Ft())==null?void 0:i.pl())??"")!==t?[]:((r=n.Qa)==null?void 0:r.call(n,e))??[]:[]}}function Td(e,t,n,i){if(!e.length)return;let r=0;const o=e[0].$t(i,!0);let l=t===1?n/2-(e[0].Hi()-o/2):e[0].Hi()-o/2-n/2;l=Math.max(0,l);for(let h=1;h<e.length;h++){const u=e[h],f=e[h-1],c=f.$t(i,!1),m=u.Hi(),y=f.Hi();if(t===1?m>y-c:m<y+c){const x=y-c*t;u.Ui(x);const _=x-t*c/2;if((t===1?_<0:_>n)&&l>0){const p=t===1?-1-_:_-n,E=Math.min(p,l);for(let T=r;T<e.length;T++)e[T].Ui(e[T].Hi()+t*E);l-=E}}else r=h,l=t===1?y-c-m:m-(y+c)}}class Pd{constructor(t,n,i,r){this.Ki=null,this.nm=null,this.sm=!1,this.rm=new Ma(200),this.hm=null,this.am=0,this.lm=!1,this.om=()=>{this.lm||this.yt._m().Qt().mr()},this.um=()=>{this.lm||this.yt._m().Qt().mr()},this.yt=t,this.yn=n,this.Ro=n.layout,this.bd=i,this.dm=r==="left",this.fm=Pl("normal",r),this.pm=Pl("top",r),this.vm=Pl("bottom",r),this.uv=document.createElement("div"),this.uv.style.height="100%",this.uv.style.overflow="hidden",this.uv.style.width="25px",this.uv.style.left="0",this.uv.style.position="relative",this.wm=$s(this.uv,de({width:16,height:16})),this.wm.subscribeSuggestedBitmapSizeChanged(this.om);const o=this.wm.canvasElement;o.style.position="absolute",o.style.zIndex="1",o.style.left="0",o.style.top="0",this.Mm=$s(this.uv,de({width:16,height:16})),this.Mm.subscribeSuggestedBitmapSizeChanged(this.um);const l=this.Mm.canvasElement;l.style.position="absolute",l.style.zIndex="2",l.style.left="0",l.style.top="0";const h={Fp:this.Sv.bind(this),Op:this.Sv.bind(this),Dp:this.xv.bind(this),Tp:this.xv.bind(this),Wp:this.gm.bind(this),Ep:this.Cv.bind(this),Vp:this.Cv.bind(this),fp:this.bm.bind(this),_p:this.bm.bind(this),bp:this.Sm.bind(this),Zp:this.bv.bind(this)};this.sv=new ja(this.Mm.canvasElement,h,{Pp:()=>!this.yn.handleScroll.vertTouchDrag,kp:()=>!0})}m(){this.sv.m(),this.Mm.unsubscribeSuggestedBitmapSizeChanged(this.um),Bs(this.Mm.canvasElement),this.Mm.dispose(),this.wm.unsubscribeSuggestedBitmapSizeChanged(this.om),Bs(this.wm.canvasElement),this.wm.dispose(),this.Ki!==null&&this.Ki.__().u(this),this.Ki=null}fv(){return this.uv}P(){return this.Ro.fontSize}xm(){const t=this.bd.N();return this.hm!==t.k&&(this.rm.Os(),this.hm=t.k),t}Cm(){if(this.Ki===null)return 0;let t=0;const n=this.xm(),i=ut(this.wm.canvasElement.getContext("2d",{colorSpace:this.yt._m().N().layout.colorSpace}));i.save();const r=this.Ki.zl();i.font=this.ym(),r.length>0&&(t=Math.max(this.rm.Ii(i,r[0].eo),this.rm.Ii(i,r[r.length-1].eo)));const o=this.Pm();for(let f=o.length;f--;){const c=this.rm.Ii(i,o[f].ri());c>t&&(t=c)}const l=this.Ki.Lt();if(l!==null&&this.nm!==null&&(h=this.yn.crosshair).mode!==2&&h.horzLine.visible&&h.horzLine.labelVisible){const f=this.Ki.Tn(1,l),c=this.Ki.Tn(this.nm.height-2,l);t=Math.max(t,this.rm.Ii(i,this.Ki.Ji(Math.floor(Math.min(f,c))+.11111111111111,l)),this.rm.Ii(i,this.Ki.Ji(Math.ceil(Math.max(f,c))-.11111111111111,l)))}var h;i.restore();const u=t||34;return uc(Math.ceil(n.S+n.C+n.V+n.B+5+u))}km(t){this.nm!==null&&Is(this.nm,t)||(this.nm=t,this.lm=!0,this.wm.resizeCanvasElement(t),this.Mm.resizeCanvasElement(t),this.lm=!1,this.uv.style.width=`${t.width}px`,this.uv.style.height=`${t.height}px`)}Tm(){return ut(this.nm).width}un(t){this.Ki!==t&&(this.Ki!==null&&this.Ki.__().u(this),this.Ki=t,t.__().i(this.wo.bind(this),this))}Ft(){return this.Ki}Os(){const t=this.yt.yv();this.yt._m().Qt().au(t,ut(this.Ft()))}Rm(t){if(this.nm===null)return;const n={colorSpace:this.yt._m().N().layout.colorSpace};if(t!==1){this.Dm(),this.wm.applySuggestedBitmapSize();const r=zs(this.wm,n);r!==null&&(r.useBitmapCoordinateSpace(o=>{this.Im(o),this.Vm(o)}),this.yt.Bm(r,this.vm),this.Em(r),this.yt.Bm(r,this.fm),this.Am(r))}this.Mm.applySuggestedBitmapSize();const i=zs(this.Mm,n);i!==null&&(i.useBitmapCoordinateSpace(({context:r,bitmapSize:o})=>{r.clearRect(0,0,o.width,o.height)}),this.Lm(i),this.yt.Bm(i,this.pm))}vv(){return this.wm.bitmapSize}mv(t,n,i,r){const o=this.vv();if(o.width>0&&o.height>0&&(t.drawImage(this.wm.canvasElement,n,i),r)){const l=this.Mm.canvasElement;t.drawImage(l,n,i)}}Pt(){var t;(t=this.Ki)==null||t.zl()}Sv(t){if(this.Ki===null||this.Ki.Zi()||!this.yn.handleScale.axisPressedMouseMove.price)return;const n=this.yt._m().Qt(),i=this.yt.yv();this.sm=!0,n.Q_(i,this.Ki,t.localY)}xv(t){if(this.Ki===null||!this.yn.handleScale.axisPressedMouseMove.price)return;const n=this.yt._m().Qt(),i=this.yt.yv(),r=this.Ki;n.tu(i,r,t.localY)}gm(){if(this.Ki===null||!this.yn.handleScale.axisPressedMouseMove.price)return;const t=this.yt._m().Qt(),n=this.yt.yv(),i=this.Ki;this.sm&&(this.sm=!1,t.iu(n,i))}Cv(t){if(this.Ki===null||!this.yn.handleScale.axisPressedMouseMove.price)return;const n=this.yt._m().Qt(),i=this.yt.yv();this.sm=!1,n.iu(i,this.Ki)}bm(t){this.yn.handleScale.axisDoubleClickReset.price&&this.Os()}Sm(t){this.Ki!==null&&(!this.yt._m().Qt().N().handleScale.axisPressedMouseMove.price||this.Ki.je()||this.Ki.No()||this.zm(1))}bv(t){this.zm(0)}Pm(){const t=[],n=this.Ki===null?void 0:this.Ki;return(i=>{for(let r=0;r<i.length;++r){const o=i[r].qn(this.yt.yv(),n);for(let l=0;l<o.length;l++)t.push(o[l])}})(this.yt.yv().Dt()),t}Im({context:t,bitmapSize:n}){const{width:i,height:r}=n,o=this.yt.yv().Qt(),l=o.$(),h=o.af();l===h?Ba(t,0,0,i,r,l):np(t,0,0,i,r,l,h)}Vm({context:t,bitmapSize:n,horizontalPixelRatio:i}){if(this.nm===null||this.Ki===null||!this.Ki.N().borderVisible)return;t.fillStyle=this.Ki.N().borderColor;const r=Math.max(1,Math.floor(this.xm().S*i));let o;o=this.dm?n.width-r:0,t.fillRect(o,0,r,n.height)}Em(t){if(this.nm===null||this.Ki===null)return;const n=this.Ki.zl(),i=this.Ki.N(),r=this.xm(),o=this.dm?this.nm.width-r.C:0;i.borderVisible&&i.ticksVisible&&t.useBitmapCoordinateSpace(({context:l,horizontalPixelRatio:h,verticalPixelRatio:u})=>{l.fillStyle=i.borderColor;const f=Math.max(1,Math.floor(u)),c=Math.floor(.5*u),m=Math.round(r.C*h);l.beginPath();for(const y of n)l.rect(Math.floor(o*h),Math.round(y.Vl*u)-c,m,f);l.fill()}),t.useMediaCoordinateSpace(({context:l})=>{l.font=this.ym(),l.fillStyle=i.textColor??this.Ro.textColor,l.textAlign=this.dm?"right":"left",l.textBaseline="middle";const h=this.dm?Math.round(o-r.V):Math.round(o+r.C+r.V),u=n.map(f=>this.rm.Di(l,f.eo));for(let f=n.length;f--;){const c=n[f];l.fillText(c.eo,h,c.Vl+u[f])}})}Dm(){if(this.nm===null||this.Ki===null)return;let t=this.nm.height/2;const n=[],i=this.Ki.Dt().slice(),r=this.yt.yv(),o=this.xm();this.Ki===r.Zs()&&this.yt.yv().Dt().forEach(u=>{r.Gs(u)&&i.push(u)});const l=this.Ki.kl()[0],h=this.Ki;i.forEach(u=>{const f=u.qn(r,h);f.forEach(c=>{c.$i()&&c.Wi()===null&&(c.Ui(null),n.push(c))}),l===u&&f.length>0&&(t=f[0].Ei())}),this.Ki.N().alignLabels&&this.Om(n,o,t)}Om(t,n,i){if(this.nm===null)return;const r=t.filter(l=>l.Ei()<=i),o=t.filter(l=>l.Ei()>i);r.sort((l,h)=>h.Ei()-l.Ei()),r.length&&o.length&&o.push(r[0]),o.sort((l,h)=>l.Ei()-h.Ei());for(const l of t){const h=Math.floor(l.$t(n)/2),u=l.Ei();u>-h&&u<h&&l.Ui(h),u>this.nm.height-h&&u<this.nm.height+h&&l.Ui(this.nm.height-h)}Td(r,1,this.nm.height,n),Td(o,-1,this.nm.height,n)}Am(t){if(this.nm===null)return;const n=this.Pm(),i=this.xm(),r=this.dm?"right":"left";n.forEach(o=>{o.ji()&&o.Tt(ut(this.Ki)).st(t,i,this.rm,r)})}Lm(t){if(this.nm===null||this.Ki===null)return;const n=this.yt._m().Qt(),i=[],r=this.yt.yv(),o=n.Vd().qn(r,this.Ki);o.length&&i.push(o);const l=this.xm(),h=this.dm?"right":"left";i.forEach(u=>{u.forEach(f=>{f.Tt(ut(this.Ki)).st(t,l,this.rm,h)})})}zm(t){this.uv.style.cursor=t===1?"ns-resize":"default"}wo(){const t=this.Cm();this.am<t&&this.yt._m().Qt().ka(),this.am=t}ym(){return Ca(this.Ro.fontSize,this.Ro.fontFamily)}}function D_(e,t){var n;return((n=e.Xa)==null?void 0:n.call(e,t))??[]}function El(e,t){var n;return((n=e.jn)==null?void 0:n.call(e,t))??[]}function Ed(e,t){var n;return((n=e.cn)==null?void 0:n.call(e,t))??[]}function $_(e,t){var n;return((n=e.qa)==null?void 0:n.call(e,t))??[]}class ph{constructor(t,n){this.nm=de({width:0,height:0}),this.Nm=null,this.Fm=null,this.Wm=null,this.Hm=null,this.Um=!1,this.$m=new Ae,this.jm=new Ae,this.qm=0,this.Ym=!1,this.Km=null,this.Gm=!1,this.Zm=null,this.Xm=null,this.lm=!1,this.om=()=>{this.lm||this.Jm===null||this.sn().mr()},this.um=()=>{this.lm||this.Jm===null||this.sn().mr()},this.Gv=t,this.Jm=n,this.Jm.mu().i(this.Qm.bind(this),this,!0),this.tw=document.createElement("td"),this.tw.style.padding="0",this.tw.style.position="relative";const i=document.createElement("div");i.style.width="100%",i.style.height="100%",i.style.position="relative",i.style.overflow="hidden",this.iw=document.createElement("td"),this.iw.style.padding="0",this.nw=document.createElement("td"),this.nw.style.padding="0",this.tw.appendChild(i),this.wm=$s(i,de({width:16,height:16})),this.wm.subscribeSuggestedBitmapSizeChanged(this.om);const r=this.wm.canvasElement;r.style.position="absolute",r.style.zIndex="1",r.style.left="0",r.style.top="0",this.Mm=$s(i,de({width:16,height:16})),this.Mm.subscribeSuggestedBitmapSizeChanged(this.um);const o=this.Mm.canvasElement;o.style.position="absolute",o.style.zIndex="2",o.style.left="0",o.style.top="0",this._v=document.createElement("tr"),this._v.appendChild(this.iw),this._v.appendChild(this.tw),this._v.appendChild(this.nw),this.sw(),this.sv=new ja(this.Mm.canvasElement,this,{Pp:()=>this.Km===null&&!this.Gv.N().handleScroll.vertTouchDrag,kp:()=>this.Km===null&&!this.Gv.N().handleScroll.horzTouchDrag})}m(){this.Nm!==null&&this.Nm.m(),this.Fm!==null&&this.Fm.m(),this.Wm=null,this.Mm.unsubscribeSuggestedBitmapSizeChanged(this.um),Bs(this.Mm.canvasElement),this.Mm.dispose(),this.wm.unsubscribeSuggestedBitmapSizeChanged(this.om),Bs(this.wm.canvasElement),this.wm.dispose(),this.Jm!==null&&(this.Jm.mu().u(this),this.Jm.m()),this.sv.m()}yv(){return ut(this.Jm)}ew(t){var n;this.Jm!==null&&this.Jm.mu().u(this),this.Jm=t,this.Jm!==null&&this.Jm.mu().i(ph.prototype.Qm.bind(this),this,!0),this.sw(),this.Gv.lv().indexOf(this)===this.Gv.lv().length-1?(this.Wm=this.Wm??new z_(this.tw,this.Gv),this.Wm.Pt()):((n=this.Wm)==null||n.Xv(),this.Wm=null)}_m(){return this.Gv}fv(){return this._v}sw(){if(this.Jm!==null&&(this.rw(),this.sn().Jn().length!==0)){if(this.Nm!==null){const t=this.Jm.X_();this.Nm.un(ut(t))}if(this.Fm!==null){const t=this.Jm.J_();this.Fm.un(ut(t))}}}hw(){this.Nm!==null&&this.Nm.Pt(),this.Fm!==null&&this.Fm.Pt()}F_(){return this.Jm!==null?this.Jm.F_():0}W_(t){this.Jm&&this.Jm.W_(t)}bp(t){if(!this.Jm)return;this.aw();const n=t.localX,i=t.localY;this.lw(n,i,t)}Fp(t){this.aw(),this.ow(),this.lw(t.localX,t.localY,t)}Sp(t){if(!this.Jm)return;this.aw();const n=t.localX,i=t.localY;this.lw(n,i,t)}Ap(t){this.Jm!==null&&(this.aw(),this.lw(t.localX,t.localY,t),this._w(t))}fp(t){this.Jm!==null&&this.uw(this.jm,t)}_p(t){this.fp(t)}Dp(t){this.aw(),this.cw(t),this.lw(t.localX,t.localY,t)}Ep(t){this.Jm!==null&&(this.aw(),this.Ym=!1,this.dw(t))}Bp(t){this.Jm!==null&&this._w(t)}Xp(t){if(this.Ym=!0,this.Km===null){const n={x:t.localX,y:t.localY};this.fw(n,n,t)}}Zp(t){this.Jm!==null&&(this.aw(),this.Jm.Qt().Rd(null),this.pw())}mw(){return this.$m}ww(){return this.jm}$p(){this.qm=1,this.sn().cs()}jp(t,n){if(!this.Gv.N().handleScale.pinch)return;const i=5*(n-this.qm);this.qm=n,this.sn().Wd(t._t,i)}Op(t){this.Ym=!1,this.Gm=this.Km!==null,this.ow();const n=this.sn().Vd();this.Km!==null&&n.It()&&(this.Zm={x:n.ni(),y:n.si()},this.Km={x:t.localX,y:t.localY})}Tp(t){if(this.Jm===null)return;const n=t.localX,i=t.localY;if(this.Km===null)this.cw(t);else{this.Gm=!1;const r=ut(this.Zm),o=r.x+(n-this.Km.x),l=r.y+(i-this.Km.y);this.lw(o,l,t)}}Vp(t){this._m().N().trackingMode.exitMode===0&&(this.Gm=!0),this.Mw(),this.dw(t)}Qs(t,n){const i=this.Jm;return i===null?null:fp(i,t,n)}gw(t,n){ut(n==="left"?this.Nm:this.Fm).km(de({width:t,height:this.nm.height}))}pv(){return this.nm}km(t){Is(this.nm,t)||(this.nm=t,this.lm=!0,this.wm.resizeCanvasElement(t),this.Mm.resizeCanvasElement(t),this.lm=!1,this.tw.style.width=t.width+"px",this.tw.style.height=t.height+"px")}bw(){const t=ut(this.Jm);t.G_(t.X_()),t.G_(t.J_());for(const n of t.kl())if(t.Gs(n)){const i=n.Ft();i!==null&&t.G_(i),n.Nn()}for(const n of t.Mu())n.Nn()}vv(){return this.wm.bitmapSize}mv(t,n,i,r){const o=this.vv();if(o.width>0&&o.height>0&&(t.drawImage(this.wm.canvasElement,n,i),r)){const l=this.Mm.canvasElement;t!==null&&t.drawImage(l,n,i)}}Rm(t){if(t===0||this.Jm===null)return;t>1&&this.bw(),this.Nm!==null&&this.Nm.Rm(t),this.Fm!==null&&this.Fm.Rm(t);const n={colorSpace:this.Gv.N().layout.colorSpace};if(t!==1){this.wm.applySuggestedBitmapSize();const r=zs(this.wm,n);r!==null&&(r.useBitmapCoordinateSpace(o=>{this.Im(o)}),this.Jm&&(this.Sw(r,D_),this.xw(r),this.Sw(r,El),this.Sw(r,Ed)))}this.Mm.applySuggestedBitmapSize();const i=zs(this.Mm,n);i!==null&&(i.useBitmapCoordinateSpace(({context:r,bitmapSize:o})=>{r.clearRect(0,0,o.width,o.height)}),this.Cw(i),this.Sw(i,$_),this.Sw(i,Ed))}yw(){return this.Nm}Pw(){return this.Fm}Bm(t,n){this.Sw(t,n)}Qm(){this.Jm!==null&&this.Jm.mu().u(this),this.Jm=null}_w(t){this.uw(this.$m,t)}uw(t,n){const i=n.localX,r=n.localY;t.v()&&t.p(this.sn().Et().Vc(i),{x:i,y:r},n)}Im({context:t,bitmapSize:n}){const{width:i,height:r}=n,o=this.sn(),l=o.$(),h=o.af();l===h?Ba(t,0,0,i,r,h):np(t,0,0,i,r,l,h)}xw(t){const n=ut(this.Jm),i=n.wu().wr().Tt(n);i!==null&&i.st(t,!1)}Cw(t){this.kw(t,El,Kr,this.sn().Vd())}Sw(t,n){const i=ut(this.Jm),r=n===El?this.Tw():null,o=r===null?null:this.Rw(r,i),l=i.Mu();if(o===null||r===null){const f=i._u();return this.Dw(t,n,ha,l,f),void this.Dw(t,n,Kr,l,f)}const h=i.Dt(),u=f=>f===r?o.Za:void 0;this.Dw(t,n,ha,l,h,u),this.Dw(t,n,Kr,l,h,u),this.kw(t,n,ha,r,o.qa),this.kw(t,n,Kr,r,o.qa)}Dw(t,n,i,r,o,l){for(const h of r)this.kw(t,n,i,h);if(l!==void 0)for(const h of o)this.kw(t,n,i,h,l(h));else for(const h of o)this.kw(t,n,i,h)}Tw(){var i;const t=ut(this.Jm),n=(i=t.Qt().cu())==null?void 0:i.uu;if(!t.Qt().N().hoveredSeriesOnTop||n===void 0)return null;for(const r of t.Dt())if(r===n)return r;return null}Rw(t,n){var r;const i=((r=t.Ga)==null?void 0:r.call(t,n))??null;return i===null||i.qa.length===0?null:i}kw(t,n,i,r,o){const l=ut(this.Jm),h=l.Qt().cu(),u=h!==null&&h.uu===r,f=h!==null&&u&&h.bu!==void 0?h.bu.ie:void 0,c=m=>i(m,t,u,f);o===void 0?dc(n,c,r,l):yp(o,c,l)}rw(){if(this.Jm===null)return;const t=this.Gv,n=this.Jm.X_().N().visible,i=this.Jm.J_().N().visible;n||this.Nm===null||(this.iw.removeChild(this.Nm.fv()),this.Nm.m(),this.Nm=null),i||this.Fm===null||(this.nw.removeChild(this.Fm.fv()),this.Fm.m(),this.Fm=null);const r=t.Qt().Jd();n&&this.Nm===null&&(this.Nm=new Pd(this,t.N(),r,"left"),this.iw.appendChild(this.Nm.fv())),i&&this.Fm===null&&(this.Fm=new Pd(this,t.N(),r,"right"),this.nw.appendChild(this.Fm.fv()))}Iw(t){return t.Jp&&this.Ym||this.Km!==null}lw(t,n,i){t=Math.max(0,Math.min(t,this.nm.width-1)),n=Math.max(0,Math.min(n,this.nm.height-1)),this.sn().Kd(t,n,i,ut(this.Jm))}pw(){this.sn().Zd()}Mw(){this.Gm&&(this.Km=null,this.pw())}fw(t,n,i){this.Km=t,this.Gm=!1,this.lw(n.x,n.y,i);const r=this.sn().Vd();this.Zm={x:r.ni(),y:r.si()}}sn(){return this.Gv.Qt()}dw(t){if(!this.Um)return;const n=this.sn(),i=this.yv();if(n.eu(i,i.kn()),this.Hm=null,this.Um=!1,n.jd(),this.Xm!==null){const r=performance.now(),o=n.Et();this.Xm.me(o.Oc(),r),this.Xm.Kc(r)||n.ps(this.Xm)}}aw(){this.Km=null}ow(){if(this.Jm){if(this.sn().cs(),document.activeElement!==document.body&&document.activeElement!==document.documentElement)ut(document.activeElement).blur();else{const t=document.getSelection();t!==null&&t.removeAllRanges()}!this.Jm.kn().Zi()&&this.sn().Et().Zi()}}cw(t){if(this.Jm===null)return;const n=this.sn(),i=n.Et();if(i.Zi())return;const r=this.Gv.N(),o=r.handleScroll,l=r.kineticScroll;if((!o.pressedMouseMove||t.Jp)&&(!o.horzTouchDrag&&!o.vertTouchDrag||!t.Jp))return;const h=this.Jm.kn(),u=performance.now();if(this.Hm!==null||this.Iw(t)||(this.Hm={x:t.clientX,y:t.clientY,yf:u,Vw:t.localX,Bw:t.localY}),this.Hm!==null&&!this.Um&&(this.Hm.x!==t.clientX||this.Hm.y!==t.clientY)){if(t.Jp&&l.touch||!t.Jp&&l.mouse){const f=i.ml();this.Xm=new I_(.2/f,7/f,.997,15/f),this.Xm.Uv(i.Oc(),this.Hm.yf)}else this.Xm=null;h.Zi()||n.nu(this.Jm,h,t.localY),n.Ud(t.localX),this.Um=!0}this.Um&&(h.Zi()||n.su(this.Jm,h,t.localY),n.$d(t.localX),this.Xm!==null&&this.Xm.Uv(i.Oc(),u))}}class Ld{constructor(t,n,i,r,o){this.xt=!0,this.nm=de({width:0,height:0}),this.om=()=>this.Rm(3),this.dm=t==="left",this.bd=i.Jd,this.yn=n,this.Ew=r,this.Aw=o,this.uv=document.createElement("div"),this.uv.style.width="25px",this.uv.style.height="100%",this.uv.style.overflow="hidden",this.wm=$s(this.uv,de({width:16,height:16})),this.wm.subscribeSuggestedBitmapSizeChanged(this.om)}m(){this.wm.unsubscribeSuggestedBitmapSizeChanged(this.om),Bs(this.wm.canvasElement),this.wm.dispose()}fv(){return this.uv}pv(){return this.nm}km(t){Is(this.nm,t)||(this.nm=t,this.wm.resizeCanvasElement(t),this.uv.style.width=`${t.width}px`,this.uv.style.height=`${t.height}px`,this.xt=!0)}Rm(t){if(t<3&&!this.xt||this.nm.width===0||this.nm.height===0)return;this.xt=!1,this.wm.applySuggestedBitmapSize();const n=zs(this.wm,{colorSpace:this.yn.layout.colorSpace});n!==null&&n.useBitmapCoordinateSpace(i=>{this.Im(i),this.Vm(i)})}vv(){return this.wm.bitmapSize}mv(t,n,i){const r=this.vv();r.width>0&&r.height>0&&t.drawImage(this.wm.canvasElement,n,i)}Vm({context:t,bitmapSize:n,horizontalPixelRatio:i,verticalPixelRatio:r}){if(!this.Ew())return;t.fillStyle=this.yn.timeScale.borderColor;const o=Math.floor(this.bd.N().S*i),l=Math.floor(this.bd.N().S*r),h=this.dm?n.width-o:0;t.fillRect(h,0,o,l)}Im({context:t,bitmapSize:n}){Ba(t,0,0,n.width,n.height,this.Aw())}}function gh(e){return t=>{var n;return((n=t.tl)==null?void 0:n.call(t,e))??[]}}const B_=gh("normal"),O_=gh("top"),F_=gh("bottom");class W_{constructor(t,n){this.Lw=null,this.zw=null,this.M=null,this.Ow=!1,this.nm=de({width:0,height:0}),this.Nw=new Ae,this.rm=new Ma(5),this.lm=!1,this.om=()=>{this.lm||this.Gv.Qt().mr()},this.um=()=>{this.lm||this.Gv.Qt().mr()},this.Gv=t,this.Pu=n,this.yn=t.N().layout,this.jv=document.createElement("tr"),this.Fw=document.createElement("td"),this.Fw.style.padding="0",this.Ww=document.createElement("td"),this.Ww.style.padding="0",this.uv=document.createElement("td"),this.uv.style.height="25px",this.uv.style.padding="0",this.Hw=document.createElement("div"),this.Hw.style.width="100%",this.Hw.style.height="100%",this.Hw.style.position="relative",this.Hw.style.overflow="hidden",this.uv.appendChild(this.Hw),this.wm=$s(this.Hw,de({width:16,height:16})),this.wm.subscribeSuggestedBitmapSizeChanged(this.om);const i=this.wm.canvasElement;i.style.position="absolute",i.style.zIndex="1",i.style.left="0",i.style.top="0",this.Mm=$s(this.Hw,de({width:16,height:16})),this.Mm.subscribeSuggestedBitmapSizeChanged(this.um);const r=this.Mm.canvasElement;r.style.position="absolute",r.style.zIndex="2",r.style.left="0",r.style.top="0",this.jv.appendChild(this.Fw),this.jv.appendChild(this.uv),this.jv.appendChild(this.Ww),this.Uw(),this.Gv.Qt().N_().i(this.Uw.bind(this),this),this.sv=new ja(this.Mm.canvasElement,this,{Pp:()=>!0,kp:()=>!this.Gv.N().handleScroll.horzTouchDrag})}m(){this.sv.m(),this.Lw!==null&&this.Lw.m(),this.zw!==null&&this.zw.m(),this.Mm.unsubscribeSuggestedBitmapSizeChanged(this.um),Bs(this.Mm.canvasElement),this.Mm.dispose(),this.wm.unsubscribeSuggestedBitmapSizeChanged(this.om),Bs(this.wm.canvasElement),this.wm.dispose()}fv(){return this.jv}$w(){return this.Lw}jw(){return this.zw}Fp(t){if(this.Ow)return;this.Ow=!0;const n=this.Gv.Qt();!n.Et().Zi()&&this.Gv.N().handleScale.axisPressedMouseMove.time&&n.Fd(t.localX)}Op(t){this.Fp(t)}Wp(){const t=this.Gv.Qt();!t.Et().Zi()&&this.Ow&&(this.Ow=!1,this.Gv.N().handleScale.axisPressedMouseMove.time&&t.Yd())}Dp(t){const n=this.Gv.Qt();!n.Et().Zi()&&this.Gv.N().handleScale.axisPressedMouseMove.time&&n.qd(t.localX)}Tp(t){this.Dp(t)}Ep(){this.Ow=!1;const t=this.Gv.Qt();t.Et().Zi()&&!this.Gv.N().handleScale.axisPressedMouseMove.time||t.Yd()}Vp(){this.Ep()}fp(){this.Gv.N().handleScale.axisDoubleClickReset.time&&this.Gv.Qt().ws()}_p(){this.fp()}bp(){this.Gv.Qt().N().handleScale.axisPressedMouseMove.time&&this.zm(1)}Zp(){this.zm(0)}pv(){return this.nm}qw(){return this.Nw}Yw(t,n,i){Is(this.nm,t)||(this.nm=t,this.lm=!0,this.wm.resizeCanvasElement(t),this.Mm.resizeCanvasElement(t),this.lm=!1,this.uv.style.width=`${t.width}px`,this.uv.style.height=`${t.height}px`,this.Nw.p(t)),this.Lw!==null&&this.Lw.km(de({width:n,height:t.height})),this.zw!==null&&this.zw.km(de({width:i,height:t.height}))}Kw(){const t=this.Gw();return Math.ceil(t.S+t.C+t.P+t.A+t.I+t.Zw)}Pt(){this.Gv.Qt().Et().zl()}vv(){return this.wm.bitmapSize}mv(t,n,i,r){const o=this.vv();if(o.width>0&&o.height>0&&(t.drawImage(this.wm.canvasElement,n,i),r)){const l=this.Mm.canvasElement;t.drawImage(l,n,i)}}Rm(t){if(t===0)return;const n={colorSpace:this.yn.colorSpace};if(t!==1){this.wm.applySuggestedBitmapSize();const r=zs(this.wm,n);r!==null&&(r.useBitmapCoordinateSpace(o=>{this.Im(o),this.Vm(o),this.Xw(r,F_)}),this.Em(r),this.Xw(r,B_)),this.Lw!==null&&this.Lw.Rm(t),this.zw!==null&&this.zw.Rm(t)}this.Mm.applySuggestedBitmapSize();const i=zs(this.Mm,n);i!==null&&(i.useBitmapCoordinateSpace(({context:r,bitmapSize:o})=>{r.clearRect(0,0,o.width,o.height)}),this.Jw([...this.Gv.Qt().Jn(),this.Gv.Qt().Vd()],i),this.Xw(i,O_))}Xw(t,n){const i=this.Gv.Qt().Jn();for(const r of i)dc(n,o=>ha(o,t,!1,void 0),r,void 0);for(const r of i)dc(n,o=>Kr(o,t,!1,void 0),r,void 0)}Im({context:t,bitmapSize:n}){Ba(t,0,0,n.width,n.height,this.Gv.Qt().af())}Vm({context:t,bitmapSize:n,verticalPixelRatio:i}){if(this.Gv.N().timeScale.borderVisible){t.fillStyle=this.Qw();const r=Math.max(1,Math.floor(this.Gw().S*i));t.fillRect(0,0,n.width,r)}}Em(t){const n=this.Gv.Qt().Et(),i=n.zl();if(!i||i.length===0)return;const r=this.Pu.maxTickMarkWeight(i),o=this.Gw(),l=n.N();l.borderVisible&&l.ticksVisible&&t.useBitmapCoordinateSpace(({context:h,horizontalPixelRatio:u,verticalPixelRatio:f})=>{h.strokeStyle=this.Qw(),h.fillStyle=this.Qw();const c=Math.max(1,Math.floor(u)),m=Math.floor(.5*u);h.beginPath();const y=Math.round(o.C*f);for(let x=i.length;x--;){const _=Math.round(i[x].coord*u);h.rect(_-m,0,c,y)}h.fill()}),t.useMediaCoordinateSpace(({context:h})=>{const u=o.S+o.C+o.A+o.P/2;h.textAlign="center",h.textBaseline="middle",h.fillStyle=this.H(),h.font=this.ym();for(const f of i)if(f.weight<r){const c=f.needAlignCoordinate?this.tM(h,f.coord,f.label):f.coord;h.fillText(f.label,c,u)}this.Gv.N().timeScale.allowBoldLabels&&(h.font=this.iM());for(const f of i)if(f.weight>=r){const c=f.needAlignCoordinate?this.tM(h,f.coord,f.label):f.coord;h.fillText(f.label,c,u)}})}tM(t,n,i){const r=this.rm.Ii(t,i),o=r/2,l=Math.floor(n-o)+.5;return l<0?n+=Math.abs(0-l):l+r>this.nm.width&&(n-=Math.abs(this.nm.width-(l+r))),n}Jw(t,n){const i=this.Gw();for(const r of t)for(const o of r.dn())o.Tt().st(n,i)}Qw(){return this.Gv.N().timeScale.borderColor}H(){return this.yn.textColor}F(){return this.yn.fontSize}ym(){return Ca(this.F(),this.yn.fontFamily)}iM(){return Ca(this.F(),this.yn.fontFamily,"bold")}Gw(){this.M===null&&(this.M={S:1,L:NaN,A:NaN,I:NaN,tn:NaN,C:5,P:NaN,k:"",Qi:new Ma,Zw:0});const t=this.M,n=this.ym();if(t.k!==n){const i=this.F();t.P=i,t.k=n,t.A=3*i/12,t.I=3*i/12,t.tn=9*i/12,t.L=0,t.Zw=4*i/12,t.Qi.Os()}return this.M}zm(t){this.uv.style.cursor=t===1?"ew-resize":"default"}Uw(){const t=this.Gv.Qt(),n=t.N();n.leftPriceScale.visible||this.Lw===null||(this.Fw.removeChild(this.Lw.fv()),this.Lw.m(),this.Lw=null),n.rightPriceScale.visible||this.zw===null||(this.Ww.removeChild(this.zw.fv()),this.zw.m(),this.zw=null);const i={Jd:this.Gv.Qt().Jd()},r=()=>n.leftPriceScale.borderVisible&&t.Et().N().borderVisible,o=()=>t.af();n.leftPriceScale.visible&&this.Lw===null&&(this.Lw=new Ld("left",n,i,r,o),this.Fw.appendChild(this.Lw.fv())),n.rightPriceScale.visible&&this.zw===null&&(this.zw=new Ld("right",n,i,r,o),this.Ww.appendChild(this.zw.fv()))}}var ef;const V_=!!Cr&&!!navigator.userAgentData&&navigator.userAgentData.brands.some(e=>e.brand.includes("Chromium"))&&!!Cr&&((ef=navigator==null?void 0:navigator.userAgentData)!=null&&ef.platform?navigator.userAgentData.platform==="Windows":navigator.userAgent.toLowerCase().indexOf("win")>=0);class j_{constructor(t,n,i){var r;this.nM=[],this.sM=[],this.eM=0,this.oo=0,this.k_=0,this.rM=0,this.hM=0,this.aM=null,this.lM=!1,this.$m=new Ae,this.jm=new Ae,this.wd=new Ae,this.oM=null,this._M=null,this.Kv=t,this.yn=n,this.Pu=i,this.jv=document.createElement("div"),this.jv.classList.add("tv-lightweight-charts"),this.jv.style.overflow="hidden",this.jv.style.direction="ltr",this.jv.style.width="100%",this.jv.style.height="100%",(r=this.jv).style.userSelect="none",r.style.webkitUserSelect="none",r.style.msUserSelect="none",r.style.MozUserSelect="none",r.style.webkitTapHighlightColor="transparent",this.uM=document.createElement("table"),this.uM.setAttribute("cellspacing","0"),this.jv.appendChild(this.uM),this.cM=this.dM.bind(this),Ll(this.yn)&&this.fM(!0),this.sn=new k_(this.gd.bind(this),this.yn,i),this.Qt().Bd().i(this.pM.bind(this),this),this.vM=new W_(this,this.Pu),this.uM.appendChild(this.vM.fv());const o=n.autoSize&&this.mM();let l=this.yn.width,h=this.yn.height;if(o||l===0||h===0){const u=t.getBoundingClientRect();l=l||u.width,h=h||u.height}this.wM(l,h),this.MM(),t.appendChild(this.jv),this.gM(),this.sn.Et().Jc().i(this.sn.ka.bind(this.sn),this),this.sn.N_().i(this.sn.ka.bind(this.sn),this)}Qt(){return this.sn}N(){return this.yn}lv(){return this.nM}bM(){return this.vM}m(){this.fM(!1),this.eM!==0&&window.cancelAnimationFrame(this.eM),this.sn.Bd().u(this),this.sn.Et().Jc().u(this),this.sn.N_().u(this),this.sn.m();for(const t of this.nM)this.uM.removeChild(t.fv()),t.mw().u(this),t.ww().u(this),t.m();this.nM=[];for(const t of this.sM)this.SM(t);this.sM=[],ut(this.vM).m(),this.jv.parentElement!==null&&this.jv.parentElement.removeChild(this.jv),this.wd.m(),this.$m.m(),this.jm.m(),this.xM()}wM(t,n,i=!1){if(this.oo===n&&this.k_===t)return;const r=function(h){const u=Math.floor(h.width),f=Math.floor(h.height);return de({width:u-u%2,height:f-f%2})}(de({width:t,height:n}));this.oo=r.height,this.k_=r.width;const o=this.oo+"px",l=this.k_+"px";if(this.CM()||(ut(this.jv).style.height=o,ut(this.jv).style.width=l),this.uM.style.height=o,this.uM.style.width=l,i){this.eM!==0&&(window.cancelAnimationFrame(this.eM),this.eM=0),this.lM=!1;const h=Ye.ys();this.aM!==null&&(h.Ss(this.aM),this.aM=null),this.yM(h,performance.now())}else this.sn.ka()}Rm(t){t===void 0&&(t=Ye.ys());for(let n=0;n<this.nM.length;n++)this.nM[n].Rm(t._s(n).rs);this.yn.timeScale.visible&&this.vM.Rm(t.ls())}vr(t){var r;const n=Ll(this.yn);this.sn.vr(t);const i=Ll(this.yn);i!==n&&this.fM(i),(r=t.layout)!=null&&r.panes&&this.PM(),this.gM(),this.kM(t)}mw(){return this.$m}ww(){return this.jm}Bd(){return this.wd}TM(t=!1){this.aM!==null&&(this.yM(this.aM,performance.now()),this.aM=null);const n=this.RM(null),i=document.createElement("canvas");i.width=n.width,i.height=n.height;const r=ut(i.getContext("2d"));return this.RM(r,t),i}DM(t){return t==="left"&&!this.IM()||t==="right"&&!this.VM()||this.nM.length===0?0:ut(t==="left"?this.nM[0].yw():this.nM[0].Pw()).Tm()}CM(){return this.yn.autoSize&&this.oM!==null}Mv(){return this.jv}BM(t){this._M=t,this._M?this.Mv().style.setProperty("cursor",t):this.Mv().style.removeProperty("cursor")}EM(){return this._M}AM(t){return xn(this.nM[t]).pv()}PM(){this.sM.forEach(t=>{t.Pt()})}kM(t){(t.autoSize!==void 0||!this.oM||t.width===void 0&&t.height===void 0)&&(t.autoSize&&!this.oM&&this.mM(),t.autoSize===!1&&this.oM!==null&&this.xM(),t.autoSize||t.width===void 0&&t.height===void 0||this.wM(t.width||this.k_,t.height||this.oo))}RM(t,n){let i=0,r=0;const o=this.nM[0],l=(u,f)=>{let c=0;for(let m=0;m<this.nM.length;m++){const y=this.nM[m],x=ut(u==="left"?y.yw():y.Pw()),_=x.vv();if(t!==null&&x.mv(t,f,c,n),c+=_.height,m<this.nM.length-1){const p=this.sM[m],E=p.vv();t!==null&&p.mv(t,f,c),c+=E.height}}};this.IM()&&(l("left",0),i+=ut(o.yw()).vv().width);for(let u=0;u<this.nM.length;u++){const f=this.nM[u],c=f.vv();if(t!==null&&f.mv(t,i,r,n),r+=c.height,u<this.nM.length-1){const m=this.sM[u],y=m.vv();t!==null&&m.mv(t,i,r),r+=y.height}}i+=o.vv().width,this.VM()&&(l("right",i),i+=ut(o.Pw()).vv().width);const h=(u,f,c)=>{ut(u==="left"?this.vM.$w():this.vM.jw()).mv(ut(t),f,c)};if(this.yn.timeScale.visible){const u=this.vM.vv();if(t!==null){let f=0;this.IM()&&(h("left",f,r),f=ut(o.yw()).vv().width),this.vM.mv(t,f,r,n),f+=u.width,this.VM()&&h("right",f,r)}r+=u.height}return de({width:i,height:r})}LM(){let t=0,n=0,i=0;for(const E of this.nM)this.IM()&&(n=Math.max(n,ut(E.yw()).Cm(),this.yn.leftPriceScale.minimumWidth)),this.VM()&&(i=Math.max(i,ut(E.Pw()).Cm(),this.yn.rightPriceScale.minimumWidth)),t+=E.F_();n=uc(n),i=uc(i);const r=this.k_,o=this.oo,l=Math.max(r-n-i,0),h=1*this.sM.length,u=this.yn.timeScale.visible;let f=u?Math.max(this.vM.Kw(),this.yn.timeScale.minimumHeight):0;var c;f=(c=f)+c%2;const m=h+f,y=o<m?0:o-m,x=y/t;let _=0;const p=window.devicePixelRatio||1;for(let E=0;E<this.nM.length;++E){const T=this.nM[E];T.ew(this.sn.Gn()[E]);let k=0,A=0;A=E===this.nM.length-1?Math.ceil((y-_)*p)/p:Math.round(T.F_()*x*p)/p,k=Math.max(A,2),_+=k,T.km(de({width:l,height:k})),this.IM()&&T.gw(n,"left"),this.VM()&&T.gw(i,"right"),T.yv()&&this.sn.Ed(T.yv(),k)}this.vM.Yw(de({width:u?l:0,height:f}),u?n:0,u?i:0),this.sn.H_(l),this.rM!==n&&(this.rM=n),this.hM!==i&&(this.hM=i)}fM(t){t?this.jv.addEventListener("wheel",this.cM,{passive:!1}):this.jv.removeEventListener("wheel",this.cM)}zM(t){switch(t.deltaMode){case t.DOM_DELTA_PAGE:return 120;case t.DOM_DELTA_LINE:return 32}return V_?1/window.devicePixelRatio:1}dM(t){if(!(t.deltaX!==0&&this.yn.handleScroll.mouseWheel||t.deltaY!==0&&this.yn.handleScale.mouseWheel))return;const n=this.zM(t),i=n*t.deltaX/100,r=-n*t.deltaY/100;if(t.cancelable&&t.preventDefault(),r!==0&&this.yn.handleScale.mouseWheel){const o=Math.sign(r)*Math.min(1,Math.abs(r)),l=t.clientX-this.jv.getBoundingClientRect().left;this.Qt().Wd(l,o)}i!==0&&this.yn.handleScroll.mouseWheel&&this.Qt().Hd(-80*i)}yM(t,n){var r;const i=t.ls();i===3&&this.OM(),i!==3&&i!==2||(this.NM(t),this.FM(t,n),this.vM.Pt(),this.nM.forEach(o=>{o.hw()}),((r=this.aM)==null?void 0:r.ls())===3&&(this.aM.Ss(t),this.OM(),this.NM(this.aM),this.FM(this.aM,n),t=this.aM,this.aM=null)),this.Rm(t)}FM(t,n){for(const i of t.bs())this.xs(i,n)}NM(t){const n=this.sn.Gn();for(let i=0;i<n.length;i++)t._s(i).hs&&n[i].lu()}xs(t,n){const i=this.sn.Et();switch(t.ds){case 0:i.td();break;case 1:i.nd(t.Wt);break;case 2:i.Ms(t.Wt);break;case 3:i.gs(t.Wt);break;case 4:i.Wc();break;case 5:t.Wt.Kc(n)||i.gs(t.Wt.Gc(n))}}gd(t){this.aM!==null?this.aM.Ss(t):this.aM=t,this.lM||(this.lM=!0,this.eM=window.requestAnimationFrame(n=>{if(this.lM=!1,this.eM=0,this.aM!==null){const i=this.aM;this.aM=null,this.yM(i,n);for(const r of i.bs())if(r.ds===5&&!r.Wt.Kc(n)){this.Qt().ps(r.Wt);break}}}))}OM(){this.MM()}SM(t){this.uM.removeChild(t.fv()),t.m()}MM(){const t=this.sn.Gn(),n=t.length,i=this.nM.length;for(let r=n;r<i;r++){const o=xn(this.nM.pop());this.uM.removeChild(o.fv()),o.mw().u(this),o.ww().u(this),o.m();const l=this.sM.pop();l!==void 0&&this.SM(l)}for(let r=i;r<n;r++){const o=new ph(this,t[r]);if(o.mw().i(this.WM.bind(this,o),this),o.ww().i(this.HM.bind(this,o),this),this.nM.push(o),r>0){const l=new N_(this,r-1,r);this.sM.push(l),this.uM.insertBefore(l.fv(),this.vM.fv())}this.uM.insertBefore(o.fv(),this.vM.fv())}for(let r=0;r<n;r++){const o=t[r],l=this.nM[r];l.yv()!==o?l.ew(o):l.sw()}this.gM(),this.LM()}UM(t,n,i,r){var c;const o=new Map;t!==null&&this.sn.Jn().forEach(m=>{const y=m.Un().Hn(t);y!==null&&o.set(m,y)});let l;if(t!==null){const m=(c=this.sn.Et().en(t))==null?void 0:c.originalTime;m!==void 0&&(l=m)}const h=this.Qt().cu(),u=this.$M(r),f=function(m,y){var k;const x=m!==null&&m.uu instanceof Va?m.uu:void 0,_=(k=m==null?void 0:m.bu)==null?void 0:k.te,p=y!==void 0&&y!==-1?y:void 0;return m===null||m.ee===void 0?{jM:x,qM:_}:{jM:x,qM:_,YM:{ds:m.ee,KM:(E=m.uu,T=m.ee,E instanceof lc?"pane-primitive":T==="marker"||T==="primitive"?"series-primitive":"series"),GM:A_(m.ee,_),Y_:x,ZM:_,XM:p}};var E,T}(h,u);return{Qr:l,$n:t??void 0,JM:n??void 0,XM:u!==-1?u:void 0,jM:f.jM,QM:o,qM:f.qM,YM:f.YM,tg:i??void 0}}$M(t){let n=-1;if(t)n=this.nM.indexOf(t);else{const i=this.Qt().Vd().Kn();i!==null&&(n=this.Qt().Gn().indexOf(i))}return n}WM(t,n,i,r){this.$m.p(()=>this.UM(n,i,r,t))}HM(t,n,i,r){this.jm.p(()=>this.UM(n,i,r,t))}pM(t,n,i){var r;this.BM(((r=this.Qt().cu())==null?void 0:r.gu)??null),this.wd.p(()=>this.UM(t,n,i))}gM(){const t=this.yn.timeScale.visible?"":"none";this.vM.fv().style.display=t}IM(){return this.nM[0].yv().X_().N().visible}VM(){return this.nM[0].yv().J_().N().visible}mM(){return"ResizeObserver"in window&&(this.oM=new ResizeObserver(t=>{const n=t[t.length-1];if(!n)return;const i=n.contentRect.width,r=n.contentRect.height;this.wM(i,r,!0)}),this.oM.observe(this.Kv,{box:"border-box"}),!0)}xM(){this.oM!==null&&this.oM.disconnect(),this.oM=null}}function Ll(e){return!!(e.handleScroll.mouseWheel||e.handleScale.mouseWheel)}function H_(e){return e.open===void 0&&e.value===void 0}function Z_(e){return function(t){return t.open!==void 0}(e)||function(t){return t.value!==void 0}(e)}function Ad(e,t,n,i){const r=n.value,o={$n:t,wt:e,Wt:[r,r,r,r],Qr:i};return n.color!==void 0&&(o.R=n.color),o}function U_(e,t,n,i){const r=n.value,o={$n:t,wt:e,Wt:[r,r,r,r],Qr:i};return n.lineColor!==void 0&&(o.vt=n.lineColor),n.topColor!==void 0&&(o.ah=n.topColor),n.bottomColor!==void 0&&(o.oh=n.bottomColor),o}function q_(e,t,n,i){const r=n.value,o={$n:t,wt:e,Wt:[r,r,r,r],Qr:i};return n.topLineColor!==void 0&&(o._h=n.topLineColor),n.bottomLineColor!==void 0&&(o.uh=n.bottomLineColor),n.topFillColor1!==void 0&&(o.dh=n.topFillColor1),n.topFillColor2!==void 0&&(o.fh=n.topFillColor2),n.bottomFillColor1!==void 0&&(o.ph=n.bottomFillColor1),n.bottomFillColor2!==void 0&&(o.mh=n.bottomFillColor2),o}function G_(e,t,n,i){const r={$n:t,wt:e,Wt:[n.open,n.high,n.low,n.close],Qr:i};return n.color!==void 0&&(r.R=n.color),r}function Y_(e,t,n,i){const r={$n:t,wt:e,Wt:[n.open,n.high,n.low,n.close],Qr:i};return n.color!==void 0&&(r.R=n.color),n.borderColor!==void 0&&(r.Ht=n.borderColor),n.wickColor!==void 0&&(r.hh=n.wickColor),r}function X_(e,t,n,i,r){const o=xn(r)(n),l=Math.max(...o),h=Math.min(...o),u=o[o.length-1],f=[u,l,h,u],{time:c,color:m,...y}=n;return{$n:t,wt:e,Wt:f,Qr:i,ue:y,R:m}}function ar(e){return e.Wt!==void 0}function Rd(e,t){return t.customValues!==void 0&&(e.ig=t.customValues),e}function Ps(e){return(t,n,i,r,o,l)=>function(h,u){return u?u(h):H_(h)}(i,l)?Rd({wt:t,$n:n,Qr:r},i):Rd(e(t,n,i,r,o),i)}function Nd(e){return{Candlestick:Ps(Y_),Bar:Ps(G_),Area:Ps(U_),Baseline:Ps(q_),Histogram:Ps(Ad),Line:Ps(Ad),Custom:Ps(X_)}[e]}function Id(e){return{$n:0,ng:new Map,Oa:e}}function zd(e,t){if(e!==void 0&&e.length!==0)return{sg:t.key(e[0].wt),eg:t.key(e[e.length-1].wt)}}function Dd(e){let t;return e.forEach(n=>{t===void 0&&(t=n.Qr)}),xn(t)}class J_{constructor(t){this.rg=new Map,this.hg=new Map,this.ag=new Map,this.lg=[],this.Pu=t}m(){this.rg.clear(),this.hg.clear(),this.ag.clear(),this.lg=[]}og(t,n){let i=this.rg.size!==0,r=!1;const o=this.hg.get(t);if(o!==void 0)if(this.hg.size===1)i=!1,r=!0,this.rg.clear();else for(const u of this.lg)u.pointData.ng.delete(t)&&(r=!0);let l=[];if(n.length!==0){const u=n.map(x=>x.time),f=this.Pu.createConverterToInternalObj(n),c=Nd(t.bh()),m=t.ul(),y=t.cl();l=n.map((x,_)=>{const p=f(x.time),E=this.Pu.key(p);let T=this.rg.get(E);T===void 0&&(T=Id(p),this.rg.set(E,T),r=!0);const k=c(p,T.$n,x,u[_],m,y);return T.ng.set(t,k),k})}i&&this._g(),this.ug(t,l);let h=-1;if(r){const u=[];this.rg.forEach(f=>{u.push({timeWeight:0,time:f.Oa,pointData:f,originalTime:Dd(f.ng)})}),u.sort((f,c)=>this.Pu.key(f.time)-this.Pu.key(c.time)),h=this.cg(u)}return this.dg(t,h,function(u,f,c){const m=zd(u,c),y=zd(f,c);if(m!==void 0&&y!==void 0)return{fg:!1,Va:m.eg>=y.eg&&m.sg>=y.sg}}(this.hg.get(t),o,this.Pu))}if(t){return this.og(t,[])}pg(t,n,i){if(i&&t.Fa())throw new Error("Historical updates are not supported when conflation is enabled. Conflation requires data to be processed in order.");const r=n;(function(T){T.Qr===void 0&&(T.Qr=T.time)})(r),this.Pu.preprocessData(n);const o=this.Pu.createConverterToInternalObj([n])(n.time),l=this.ag.get(t);if(!i&&l!==void 0&&this.Pu.key(o)<this.Pu.key(l))throw new Error(`Cannot update oldest data, last time=${l}, new time=${o}`);let h=this.rg.get(this.Pu.key(o));if(i&&h===void 0)throw new Error("Cannot update non-existing data point when historicalUpdate is true");const u=h===void 0;h===void 0&&(h=Id(o),this.rg.set(this.Pu.key(o),h));const f=Nd(t.bh()),c=t.ul(),m=t.cl(),y=f(o,h.$n,n,r.Qr,c,m),x=!i&&!u&&l!==void 0&&this.Pu.key(o)===this.Pu.key(l);h.ng.set(t,y),i?this.vg(t,y,h.$n):x&&t.Fa()&&ar(y)?(t.Rr(y),this.mg(t,y)):this.mg(t,y);const _={Va:ar(y),fg:i};if(!u)return this.dg(t,-1,_);const p={timeWeight:0,time:h.Oa,pointData:h,originalTime:Dd(h.ng)},E=Ds(this.lg,this.Pu.key(p.time),(T,k)=>this.Pu.key(T.time)<k);this.lg.splice(E,0,p);for(let T=E;T<this.lg.length;++T)ra(this.lg[T].pointData,T);return this.Pu.fillWeightsForPoints(this.lg,E),this.dg(t,E,_)}wg(t,n){const i=this.hg.get(t);if(i===void 0||n<=0)return[[],this.Mg()];n=Math.min(n,i.length);const r=i.splice(-n).reverse();i.length===0?this.ag.delete(t):this.ag.set(t,i[i.length-1].wt);for(const o of r){const l=this.rg.get(this.Pu.key(o.wt));if(l&&(l.ng.delete(t),l.ng.size===0)){this.rg.delete(this.Pu.key(l.Oa)),this.lg.splice(l.$n,1);for(let h=l.$n;h<this.lg.length;++h)ra(this.lg[h].pointData,h)}}return[r,this.dg(t,this.lg.length-1,{fg:!1,Va:!1})]}mg(t,n){let i=this.hg.get(t);i===void 0&&(i=[],this.hg.set(t,i));const r=i.length!==0?i[i.length-1]:null;r===null||this.Pu.key(n.wt)>this.Pu.key(r.wt)?ar(n)&&i.push(n):ar(n)?i[i.length-1]=n:i.splice(-1,1),this.ag.set(t,n.wt)}vg(t,n,i){const r=this.hg.get(t);if(r===void 0)return;const o=Ds(r,i,(l,h)=>l.$n<h);ar(n)?r[o]=n:r.splice(o,1)}ug(t,n){n.length!==0?(this.hg.set(t,n.filter(ar)),this.ag.set(t,n[n.length-1].wt)):(this.hg.delete(t),this.ag.delete(t))}_g(){for(const t of this.lg)t.pointData.ng.size===0&&this.rg.delete(this.Pu.key(t.time))}cg(t){let n=-1;for(let i=0;i<this.lg.length&&i<t.length;++i){const r=this.lg[i],o=t[i];if(this.Pu.key(r.time)!==this.Pu.key(o.time)){n=i;break}o.timeWeight=r.timeWeight,ra(o.pointData,i)}if(n===-1&&this.lg.length!==t.length&&(n=Math.min(this.lg.length,t.length)),n===-1)return-1;for(let i=n;i<t.length;++i)ra(t[i].pointData,i);return this.Pu.fillWeightsForPoints(t,n),this.lg=t,n}gg(){if(this.hg.size===0)return null;let t=0;return this.hg.forEach(n=>{n.length!==0&&(t=Math.max(t,n[n.length-1].$n))}),t}dg(t,n,i){const r=this.Mg();if(n!==-1)this.hg.forEach((o,l)=>{r.Y_.set(l,{ue:o,bg:l===t?i:void 0})}),this.hg.has(t)||r.Y_.set(t,{ue:[],bg:i}),r.Et.Sg=this.lg,r.Et.xg=n;else{const o=this.hg.get(t);r.Y_.set(t,{ue:o||[],bg:i})}return r}Mg(){return{Y_:new Map,Et:{Dc:this.gg()}}}}function ra(e,t){e.$n=t,e.ng.forEach(n=>{n.$n=t})}function Q_(e,t){return e._t<t}function K_(e,t){return t<e._t}function fc(e,t,n,i){return Ds(e,t,Q_,n,i)}function mc(e,t,n,i){return fh(e,t,K_,n,i)}function ua(e,t,n){return{ne:e,se:t,ee:n}}function $d(e,t,n,i){return e>=t-i&&e<=n+i}function to(e,t,n,i,r,o){const l=r-n,h=o-i;if(l===0&&h===0)return Math.hypot(e-n,t-i);const u=((e-n)*l+(t-i)*h)/(l*l+h*h),f=Math.max(0,Math.min(1,u)),c=n+l*f,m=i+h*f;return Math.hypot(e-c,t-m)}const Al=[0,0];function tw(e,t,n){return t===void 0||t.wt!==e.wt-1?e._t-n/2:(t._t+e._t)/2}function ew(e,t,n){return t===void 0||t.wt!==e.wt+1?e._t+n/2:(e._t+t._t)/2}function vp(e,t,n,i,r,o,l){if(t===null||t.from>=t.to||e.length===0)return null;const h=r/2+o,u=fc(e,n-h,t.from,t.to),f=mc(e,n+h,u,t.to);if(u>=f)return null;let c=Number.POSITIVE_INFINITY;for(let m=u;m<f;m++){const y=e[m],x=m>t.from?e[m-1]:void 0,_=m<t.to-1?e[m+1]:void 0,p=tw(y,x,r)-o,E=ew(y,_,r)+o;if(n<p||n>E)continue;l(y,Al);const T=Al[0],k=Al[1],A=Math.min(T,k),P=Math.max(T,k),I=A-o,$=P+o;if(i>=A&&i<=P)c=Math.min(c,0);else if(i>=I&&i<=$){const j=Math.min(Math.abs(i-A),Math.abs(P-i));c=Math.min(c,j)}}return Number.isFinite(c)?ua(c,0,"series-range"):null}function nw(e,t){return e.wt<t}function iw(e,t){return t<e.wt}function sw(e,t,n){const i=t.Na(),r=t.bi(),o=Ds(e,i,nw),l=fh(e,r,iw);if(!n)return{from:o,to:l};let h=o,u=l;return o>0&&o<e.length&&e[o].wt>=i&&(h=o-1),l>0&&l<e.length&&e[l-1].wt<=r&&(u=l+1),{from:h,to:u}}class yh{constructor(t,n,i){this.Cg=!0,this.yg=!0,this.Pg=!0,this.kg=[],this.Tg=null,this.Rg=-1,this.ae=t,this.le=n,this.Dg=i}Pt(t){this.Cg=!0,t==="data"&&(this.yg=!0),t==="options"&&(this.Pg=!0)}Tt(){return this.ae.It()?(this.Ig(),this.Tg===null?null:this.Vg):null}Qs(t,n){return this.ae.It()?(this.Ig(),this.Tg===null?null:this.Bg(t,n)):null}Bg(t,n){return null}Eg(){this.kg=this.kg.map(t=>({...t,...this.ae.Sa().Sh(t.wt)}))}Ag(){this.Tg=null}Ig(){const t=this.le.Et(),n=t.N().enableConflation?t.sd():0;n!==this.Rg&&(this.yg=!0,this.Rg=n),this.yg&&(this.Lg(),this.yg=!1),this.Pg&&(this.Eg(),this.Pg=!1),this.Cg&&(this.zg(),this.Cg=!1)}zg(){const t=this.ae.Ft(),n=this.le.Et();if(this.Ag(),n.Zi()||t.Zi())return;const i=n.Ee();if(i===null||this.ae.Un().Th()===0)return;const r=this.ae.Lt();r!==null&&(this.Tg=sw(this.kg,i,this.Dg),this.Og(t,n,r.Wt),this.Ng())}}class rw{constructor(t,n){this.Fg=t,this.Ki=n}st(t,n,i){this.Fg.draw(t,this.Ki,n,i)}}function ow(e){switch(e){case"point":return 2;case"range":return 0;default:return 1}}class aw extends yh{constructor(t,n,i){super(t,n,!1),this.Yh=i,this.Fg=this.Yh.renderer(),this.Vg=new rw(this.Fg,r=>this.Wg(r))}get ga(){return this.Yh.conflationReducer}Ha(t){return this.Yh.priceValueBuilder(t)}dl(t){return this.Yh.isWhitespace(t)}Bg(t,n){var l,h;const i=(h=(l=this.Fg).hitTest)==null?void 0:h.call(l,t,n,u=>this.Wg(u));if(i!=null)return{ne:(r=i).distance,se:ow(r.type),ee:"custom",gu:r.cursorStyle,te:r.objectId,ie:r.hitTestData};var r;const o=vp(this.kg,this.Tg,t,n,this.le.Et().ml(),this.ae.N().hitTestTolerance,(u,f)=>{const c=u.Hg;let m=NaN,y=NaN;if(c!==void 0&&!this.Yh.isWhitespace(c))for(const x of this.Yh.priceValueBuilder(c)){const _=this.Wg(x);_!==null&&(m=Number.isNaN(m)?_:Math.min(m,_),y=Number.isNaN(y)?_:Math.max(y,_))}f[0]=m,f[1]=y});return o===null?null:{...o,ee:"custom"}}Lg(){const t=this.ae.Sa();this.kg=this.ae.Ua().Bh().map(n=>({wt:n.$n,_t:NaN,...t.Sh(n.$n),Hg:n.ue}))}Og(t,n){n.Ic(this.kg,xo(this.Tg))}Ng(){this.Yh.update({bars:this.kg.map(lw),barSpacing:this.le.Et().ml(),visibleRange:this.Tg,conflationFactor:this.le.Et().sd()},this.ae.N())}Wg(t){const n=this.ae.Lt();return n===null?null:this.ae.Ft().Nt(t,n.Wt)}}function lw(e){return{x:e._t,time:e.wt,originalData:e.Hg,barColor:e.sh}}const cw={color:"#2196f3"},hw=(e,t,n)=>{const i=ss(n);return new aw(e,t,i)};function vh(e){const t={value:e.Wt[3],time:e.Qr};return e.ig!==void 0&&(t.customValues=e.ig),t}function Bd(e){const t=vh(e);return e.R!==void 0&&(t.color=e.R),t}function uw(e){const t=vh(e);return e.vt!==void 0&&(t.lineColor=e.vt),e.ah!==void 0&&(t.topColor=e.ah),e.oh!==void 0&&(t.bottomColor=e.oh),t}function dw(e){const t=vh(e);return e._h!==void 0&&(t.topLineColor=e._h),e.uh!==void 0&&(t.bottomLineColor=e.uh),e.dh!==void 0&&(t.topFillColor1=e.dh),e.fh!==void 0&&(t.topFillColor2=e.fh),e.ph!==void 0&&(t.bottomFillColor1=e.ph),e.mh!==void 0&&(t.bottomFillColor2=e.mh),t}function bp(e){const t={open:e.Wt[0],high:e.Wt[1],low:e.Wt[2],close:e.Wt[3],time:e.Qr};return e.ig!==void 0&&(t.customValues=e.ig),t}function fw(e){const t=bp(e);return e.R!==void 0&&(t.color=e.R),t}function mw(e){const t=bp(e),{R:n,Ht:i,hh:r}=e;return n!==void 0&&(t.color=n),i!==void 0&&(t.borderColor=i),r!==void 0&&(t.wickColor=r),t}function da(e){return{Area:uw,Line:Bd,Baseline:dw,Histogram:Bd,Bar:fw,Candlestick:mw,Custom:pw}[e]}function pw(e){const t=e.Qr;return{...e.ue,time:t}}const gw={vertLine:{color:"#9598A1",width:1,style:3,visible:!0,labelVisible:!0,labelBackgroundColor:"#131722"},horzLine:{color:"#9598A1",width:1,style:3,visible:!0,labelVisible:!0,labelBackgroundColor:"#131722"},mode:1,doNotSnapToHiddenSeriesIndices:!1},yw={vertLines:{color:"#D6DCDE",style:0,visible:!0},horzLines:{color:"#D6DCDE",style:0,visible:!0}},vw={background:{type:"solid",color:"#FFFFFF"},textColor:"#191919",fontSize:12,fontFamily:ep,panes:{enableResize:!0,separatorColor:"#E0E3EB",separatorHoverColor:"rgba(178, 181, 189, 0.2)"},attributionLogo:!0,colorSpace:"srgb",colorParsers:[]},Rl={autoScale:!0,mode:0,invertScale:!1,alignLabels:!0,borderVisible:!0,borderColor:"#2B2B43",entireTextOnly:!1,visible:!1,ticksVisible:!1,scaleMargins:{bottom:.1,top:.2},minimumWidth:0,ensureEdgeTickMarksVisible:!1,tickMarkDensity:2.5},bw={rightOffset:0,barSpacing:6,minBarSpacing:.5,maxBarSpacing:0,fixLeftEdge:!1,fixRightEdge:!1,lockVisibleTimeRangeOnResize:!1,rightBarStaysOnScroll:!1,borderVisible:!0,borderColor:"#2B2B43",visible:!0,timeVisible:!1,secondsVisible:!0,shiftVisibleRangeOnNewBar:!0,allowShiftVisibleRangeOnWhitespaceReplacement:!1,ticksVisible:!1,uniformDistribution:!1,minimumHeight:0,allowBoldLabels:!0,ignoreWhitespaceIndices:!1,enableConflation:!1,conflationThresholdFactor:1,precomputeConflationOnInit:!1,precomputeConflationPriority:"background"};function Od(){return{addDefaultPane:!0,hoveredSeriesOnTop:!0,width:0,height:0,autoSize:!1,layout:vw,crosshair:gw,grid:yw,overlayPriceScales:{...Rl},leftPriceScale:{...Rl,visible:!1},rightPriceScale:{...Rl,visible:!0},defaultVisiblePriceScaleId:"right",timeScale:bw,localization:{locale:Cr?navigator.language:"",dateFormat:"dd MMM 'yy"},handleScroll:{mouseWheel:!0,pressedMouseMove:!0,horzTouchDrag:!0,vertTouchDrag:!0},handleScale:{axisPressedMouseMove:{time:!0,price:!0},axisDoubleClickReset:{time:!0,price:!0},mouseWheel:!0,pinch:!0},kineticScroll:{mouse:!1,touch:!0},trackingMode:{exitMode:1}}}class xp{constructor(t,n,i){this.hv=t,this.Ug=n,this.$g=i??0}applyOptions(t){this.hv.Qt().Dd(this.Ug,t,this.$g)}options(){return this.Ki().N()}width(){return Fa(this.Ug)?this.hv.DM(this.Ug):0}setVisibleRange(t){this.setAutoScale(!1),this.Ki().Go(new hn(t.from,t.to))}getVisibleRange(){let t,n,i=this.Ki().ar();if(i===null)return null;if(this.Ki().ho()){const r=this.Ki().S_(),o=mp(r);i=pr(i,this.Ki().lo()),t=Number((Math.round(i.Je()/r)*r).toFixed(o)),n=Number((Math.round(i.Qe()/r)*r).toFixed(o))}else t=i.Je(),n=i.Qe();return{from:t,to:n}}setAutoScale(t){this.applyOptions({autoScale:t})}Ki(){return ut(this.hv.Qt().Id(this.Ug,this.$g)).Ft}}class xw{constructor(t,n,i,r){this.hv=t,this.yt=i,this.jg=n,this.qg=r}getHeight(){return this.yt.$t()}setHeight(t){const n=this.hv.Qt(),i=n._f(this.yt);n.Ld(i,t)}getStretchFactor(){return this.yt.F_()}setStretchFactor(t){this.yt.W_(t),this.hv.Qt().ka()}paneIndex(){return this.hv.Qt()._f(this.yt)}moveTo(t){const n=this.paneIndex();n!==t&&(Je(t>=0&&t<this.hv.lv().length,"Invalid pane index"),this.hv.Qt().Od(n,t))}getSeries(){return this.yt.Y_().map(t=>this.jg(t))??[]}getHTMLElement(){const t=this.hv.lv();return t&&t.length!==0&&t[this.paneIndex()]?t[this.paneIndex()].fv():null}attachPrimitive(t){this.yt.ol(t),t.attached&&t.attached({chart:this.qg,requestUpdate:()=>this.yt.Qt().ka()})}detachPrimitive(t){this.yt._l(t)}priceScale(t){if(this.yt.O_(t)===null)throw new Error(`Cannot find price scale with id: ${t}`);return new xp(this.hv,t,this.paneIndex())}setPreserveEmptyPane(t){this.yt.j_(t)}preserveEmptyPane(){return this.yt.q_()}addCustomSeries(t,n={},i=0){return this.qg.addCustomSeries(t,n,i)}addSeries(t,n={}){return this.qg.addSeries(t,n,this.paneIndex())}}const _w={color:"#FF0000",price:0,lineStyle:2,lineWidth:1,lineVisible:!0,axisLabelVisible:!0,title:"",axisLabelColor:"",axisLabelTextColor:""};class Fd{constructor(t){this._r=t}applyOptions(t){this._r.vr(t)}options(){return this._r.N()}Yg(){return this._r}}class ww{constructor(t,n,i,r,o,l){this.Kg=new Ae,this.ae=t,this.Gg=n,this.Zg=i,this.Pu=o,this.qg=r,this.Xg=l}m(){this.Kg.m()}priceFormatter(){return this.ae.sl()}priceToCoordinate(t){const n=this.ae.Lt();return n===null?null:this.ae.Ft().Nt(t,n.Wt)}coordinateToPrice(t){const n=this.ae.Lt();return n===null?null:this.ae.Ft().Tn(t,n.Wt)}barsInLogicalRange(t){if(t===null)return null;const n=new br(new lo(t.from,t.to)).Uu(),i=this.ae.Un();if(i.Zi())return null;const r=i.Hn(n.Na(),1),o=i.Hn(n.bi(),-1),l=ut(i.Rh()),h=ut(i.Qn());if(r!==null&&o!==null&&r.$n>o.$n)return{barsBefore:t.from-l,barsAfter:h-t.to};const u={barsBefore:r===null||r.$n===l?t.from-l:r.$n-l,barsAfter:o===null||o.$n===h?h-t.to:h-o.$n};return r!==null&&o!==null&&(u.from=r.Qr,u.to=o.Qr),u}setData(t){this.Pu,this.ae.bh(),this.Gg.Jg(this.ae,t),this.Qg("full")}update(t,n=!1){this.ae.bh(),this.Gg.tb(this.ae,t,n),this.Qg("update")}pop(t=1){const n=this.Gg.ib(this.ae,t);n.length!==0&&this.Qg("update");const i=da(this.seriesType());return n.map(r=>i(r))}dataByIndex(t,n){const i=this.ae.Un().Hn(t,n);return i===null?null:da(this.seriesType())(i)}data(){const t=da(this.seriesType());return this.ae.Un().Bh().map(n=>t(n))}subscribeDataChanged(t){this.Kg.i(t)}unsubscribeDataChanged(t){this.Kg._(t)}applyOptions(t){this.ae.vr(t)}options(){return Ei(this.ae.N())}priceScale(){return this.Zg.priceScale(this.ae.Ft().pl(),this.getPane().paneIndex())}createPriceLine(t){const n=Mn(Ei(_w),t),i=this.ae.Ea(n);return new Fd(i)}removePriceLine(t){this.ae.Aa(t.Yg())}priceLines(){return this.ae.La().map(t=>new Fd(t))}seriesType(){return this.ae.bh()}lastValueData(t){const n=this.ae.Ae(t);return n.Le?{noData:!0}:{noData:!1,price:n.Mt,color:n.R}}attachPrimitive(t){this.ae.ol(t),t.attached&&t.attached({chart:this.qg,series:this,requestUpdate:()=>this.ae.Qt().ka(),horzScaleBehavior:this.Pu})}detachPrimitive(t){this.ae._l(t),t.detached&&t.detached(),this.ae.Qt().ka()}getPane(){const t=this.ae,n=ut(this.ae.Qt().Ks(t));return this.Xg(n)}moveToPane(t){this.ae.Qt().rf(this.ae,t)}seriesOrder(){const t=this.ae.Qt().Ks(this.ae);return t===null?-1:t.Y_().indexOf(this.ae)}setSeriesOrder(t){const n=this.ae.Qt().Ks(this.ae);n!==null&&n.vu(this.ae,t)}Qg(t){this.Kg.v()&&this.Kg.p(t)}}class Sw{constructor(t,n,i){this.nb=new Ae,this.Qu=new Ae,this.Nw=new Ae,this.sn=t,this.ia=t.Et(),this.vM=n,this.ia.Zc().i(this.sb.bind(this)),this.ia.Xc().i(this.eb.bind(this)),this.vM.qw().i(this.rb.bind(this)),this.Pu=i}m(){this.ia.Zc().u(this),this.ia.Xc().u(this),this.vM.qw().u(this),this.nb.m(),this.Qu.m(),this.Nw.m()}scrollPosition(){return this.ia.Oc()}scrollToPosition(t,n){n?this.ia.Yc(t,1e3):this.sn.gs(t)}scrollToRealTime(){this.ia.qc()}getVisibleRange(){const t=this.ia.xc();return t===null?null:{from:t.from.originalTime,to:t.to.originalTime}}setVisibleRange(t){const n={from:this.Pu.convertHorzItemToInternal(t.from),to:this.Pu.convertHorzItemToInternal(t.to)},i=this.ia.kc(n);this.sn.sf(i)}getVisibleLogicalRange(){const t=this.ia.Sc();return t===null?null:{from:t.Na(),to:t.bi()}}setVisibleLogicalRange(t){Je(t.from<=t.to,"The from index cannot be after the to index."),this.sn.sf(t)}resetTimeScale(){this.sn.ws()}fitContent(){this.sn.td()}logicalToCoordinate(t){const n=this.sn.Et();return n.Zi()?null:n.jt(t)}coordinateToLogical(t){return this.ia.Zi()?null:this.ia.Vc(t)}timeToIndex(t,n){const i=this.Pu.convertHorzItemToInternal(t);return this.ia.Mc(i,n)}timeToCoordinate(t){const n=this.timeToIndex(t,!1);return n===null?null:this.ia.jt(n)}coordinateToTime(t){const n=this.sn.Et(),i=n.Vc(t),r=n.en(i);return r===null?null:r.originalTime}width(){return this.vM.pv().width}height(){return this.vM.pv().height}subscribeVisibleTimeRangeChange(t){this.nb.i(t)}unsubscribeVisibleTimeRangeChange(t){this.nb._(t)}subscribeVisibleLogicalRangeChange(t){this.Qu.i(t)}unsubscribeVisibleLogicalRangeChange(t){this.Qu._(t)}subscribeSizeChange(t){this.Nw.i(t)}unsubscribeSizeChange(t){this.Nw._(t)}applyOptions(t){this.ia.vr(t)}options(){return{...Ei(this.ia.N()),barSpacing:this.ia.ml()}}sb(){this.nb.v()&&this.nb.p(this.getVisibleRange())}eb(){this.Qu.v()&&this.Qu.p(this.getVisibleLogicalRange())}rb(t){this.Nw.p(t.width,t.height)}}function Wd(e){return function(t){if(Xo(t.handleScale)){const i=t.handleScale;t.handleScale={axisDoubleClickReset:{time:i,price:i},axisPressedMouseMove:{time:i,price:i},mouseWheel:i,pinch:i}}else if(t.handleScale!==void 0){const{axisPressedMouseMove:i,axisDoubleClickReset:r}=t.handleScale;Xo(i)&&(t.handleScale.axisPressedMouseMove={time:i,price:i}),Xo(r)&&(t.handleScale.axisDoubleClickReset={time:r,price:r})}const n=t.handleScroll;Xo(n)&&(t.handleScroll={horzTouchDrag:n,vertTouchDrag:n,mouseWheel:n,pressedMouseMove:n})}(e),e}class Cw{constructor(t,n,i){this.hb=new Map,this.ab=new Map,this.lb=new Ae,this.ob=new Ae,this._b=new Ae,this.dd=new WeakMap,this.ub=new J_(n);const r=i===void 0?Ei(Od()):Mn(Ei(Od()),Wd(i));this.cb=n,this.hv=new j_(t,r,n),this.hv.mw().i(l=>{this.lb.v()&&this.lb.p(this.fb(l()))},this),this.hv.ww().i(l=>{this.ob.v()&&this.ob.p(this.fb(l()))},this),this.hv.Bd().i(l=>{this._b.v()&&this._b.p(this.fb(l()))},this);const o=this.hv.Qt();this.pb=new Sw(o,this.hv.bM(),this.cb)}remove(){this.hv.mw().u(this),this.hv.ww().u(this),this.hv.Bd().u(this),this.pb.m(),this.hv.m(),this.hb.clear(),this.ab.clear(),this.lb.m(),this.ob.m(),this._b.m(),this.ub.m()}resize(t,n,i){this.autoSizeActive()||this.hv.wM(t,n,i)}addCustomSeries(t,n={},i=0){const r=(o=>({type:"Custom",isBuiltIn:!1,defaultOptions:{...cw,...o.defaultOptions()},mb:hw,wb:o}))(ss(t));return this.Mb(r,n,i)}addSeries(t,n={},i=0){return this.Mb(t,n,i)}removeSeries(t){const n=xn(this.hb.get(t)),i=this.ub.if(n);this.hv.Qt().if(n),this.gb(i),this.hb.delete(t),this.ab.delete(n)}Jg(t,n){this.gb(this.ub.og(t,n))}tb(t,n,i){this.gb(this.ub.pg(t,n,i))}ib(t,n){const[i,r]=this.ub.wg(t,n);return i.length!==0&&this.gb(r),i}subscribeClick(t){this.lb.i(t)}unsubscribeClick(t){this.lb._(t)}subscribeCrosshairMove(t){this._b.i(t)}unsubscribeCrosshairMove(t){this._b._(t)}subscribeDblClick(t){this.ob.i(t)}unsubscribeDblClick(t){this.ob._(t)}priceScale(t,n=0){return new xp(this.hv,t,n)}timeScale(){return this.pb}applyOptions(t){this.hv.vr(Wd(t))}options(){return this.hv.N()}takeScreenshot(t=!1,n=!1){let i,r;try{n||(i=this.hv.Qt().N().crosshair.mode,this.hv.vr({crosshair:{mode:2}})),r=this.hv.TM(t)}finally{n||i===void 0||this.hv.Qt().vr({crosshair:{mode:i}})}return r}addPane(t=!1){const n=this.hv.Qt().uf();return n.j_(t),this.bb(n)}removePane(t){this.hv.Qt().Ad(t)}swapPanes(t,n){this.hv.Qt().zd(t,n)}autoSizeActive(){return this.hv.CM()}chartElement(){return this.hv.Mv()}panes(){return this.hv.Qt().Gn().map(t=>this.bb(t))}paneSize(t=0){const n=this.hv.AM(t);return{height:n.height,width:n.width}}setCrosshairPosition(t,n,i){const r=this.hb.get(i);if(r===void 0)return;const o=this.hv.Qt().Ks(r);o!==null&&this.hv.Qt().Gd(t,n,o)}clearCrosshairPosition(){this.hv.Qt().Zd(!0)}horzBehaviour(){return this.cb}Mb(t,n={},i=0){Je(t.mb!==void 0),function(u){if(u===void 0||u.type==="custom")return;const f=u;f.minMove!==void 0&&f.precision===void 0&&(f.precision=mp(f.minMove))}(n.priceFormat),t.type==="Candlestick"&&function(u){u.borderColor!==void 0&&(u.borderUpColor=u.borderColor,u.borderDownColor=u.borderColor),u.wickColor!==void 0&&(u.wickUpColor=u.wickColor,u.wickDownColor=u.wickColor)}(n);const r=Mn(Ei(Km),Ei(t.defaultOptions),n),o=t.mb,l=new Va(this.hv.Qt(),t.type,r,o,t.wb);this.hv.Qt().Qd(l,i);const h=new ww(l,this,this,this,this.cb,u=>this.bb(u));return this.hb.set(h,l),this.ab.set(l,h),h}gb(t){const n=this.hv.Qt();for(const i of t.Y_.keys())i.Ia();n.Xd(t.Et.Dc,t.Et.Sg,t.Et.xg),t.Y_.forEach((i,r)=>r.ht(i.ue,i.bg)),n.Et().dc(),n.Lc()}Sb(t){return xn(this.ab.get(t))}xb(t){return t!==void 0&&this.ab.has(t)?this.Sb(t):void 0}fb(t){const n=new Map;t.QM.forEach((o,l)=>{const h=l.bh(),u=da(h)(o);if(h!=="Custom")Je(Z_(u));else{const f=l.cl();Je(!f||f(u)===!1)}n.set(this.Sb(l),u)});const i=this.xb(t.jM),r=t.YM===void 0?void 0:{type:t.YM.ds,sourceKind:t.YM.KM,objectKind:t.YM.GM,series:this.xb(t.YM.Y_),objectId:t.YM.ZM,paneIndex:t.YM.XM};return{time:t.Qr,logical:t.$n,point:t.JM,paneIndex:t.XM,hoveredInfo:r,hoveredSeries:i,hoveredObjectId:t.qM,seriesData:n,sourceEvent:t.tg}}bb(t){let n=this.dd.get(t);return n||(n=new xw(this.hv,i=>this.Sb(i),t,this),this.dd.set(t,n)),n}}function Mw(e){if(ko(e)){const t=document.getElementById(e);return Je(t!==null,`Cannot find element in DOM with id=${e}`),t}return e}function kw(e,t,n){const i=Mw(e),r=new Cw(i,t,n);return t.setOptions(r.options()),r}function Tw(e,t){return kw(e,new Cd,Cd.Tf(t))}function Gr(e,t,n,i){return Math.hypot(n-e,i-t)}function _p(e,t,n,i,r,o,l,h=0){if(t.length===0||i.from>=t.length||i.to<=0)return;const{context:u,horizontalPixelRatio:f,verticalPixelRatio:c}=e,m=t[i.from];let y=o(e,m),x=m;if(i.to-i.from<2){const _=r/2;u.beginPath();const p={_t:m._t-_,ut:m.ut},E={_t:m._t+_,ut:m.ut};u.moveTo(p._t*f,p.ut*c),u.lineTo(E._t*f,E.ut*c),l(e,y,p,E)}else{const _=h>0;let p=0;const E=(k,A)=>{if(l(e,y,x,A),u.beginPath(),y=k,x=A,_){const P=p%h;u.lineDashOffset=P,p=P}};let T=x;u.beginPath(),u.moveTo(m._t*f,m.ut*c);for(let k=i.from+1;k<i.to;++k){T=t[k];const A=T._t*f,P=T.ut*c,I=o(e,T);switch(n){case 0:if(u.lineTo(A,P),_){const $=t[k-1],j=$._t*f,U=$.ut*c;p+=Gr(j,U,A,P)}break;case 1:{const $=t[k-1],j=$.ut*c;u.lineTo(A,j),_&&(p+=Math.abs(T._t-$._t)*f),I!==y&&(E(I,T),u.lineTo(A,j)),u.lineTo(A,P),_&&(p+=Math.abs(T.ut-$.ut)*c);break}case 2:{const[$,j]=bh(t,k-1,k),U=$._t*f,nt=$.ut*c,ot=j._t*f,q=j.ut*c;if(u.bezierCurveTo(U,nt,ot,q,A,P),_){const it=t[k-1],ct=it._t*f,K=it.ut*c,Z=Gr(ct,K,A,P),tt=Gr(ct,K,U,nt)+Gr(U,nt,ot,q)+Gr(ot,q,A,P);p+=(Z+tt)/2}break}}n!==1&&I!==y&&(E(I,T),u.moveTo(A,P))}(x!==T||x===T&&n===1)&&l(e,y,x,T),_&&(u.lineDashOffset=0)}}const Vd=6;function Nl(e,t){return{_t:e._t-t._t,ut:e.ut-t.ut}}function jd(e,t){return{_t:e._t/t,ut:e.ut/t}}function bh(e,t,n){const i=Math.max(0,t-1),r=Math.min(e.length-1,n+1);var o,l;return[(o=e[t],l=jd(Nl(e[n],e[i]),Vd),{_t:o._t+l._t,ut:o.ut+l.ut}),Nl(e[n],jd(Nl(e[r],e[t]),Vd))]}function Pw(e,t){const n=e.context;n.strokeStyle=t,n.stroke()}class Ew extends ds{constructor(){super(...arguments),this.rt=null}ht(t){this.rt=t}et(t){if(this.rt===null)return;const{ot:n,lt:i,Cb:r,yb:o,ct:l,Gt:h,Pb:u}=this.rt;if(i===null)return;const f=t.context;f.lineCap="butt",f.lineWidth=l*t.verticalPixelRatio;const c=hs(f,h);f.lineJoin="round";const m=this.kb.bind(this),y=function(x){return x.reduce((_,p)=>_+p,0)}(c);o!==void 0&&_p(t,n,o,i,r,m,Pw,y),u&&function(x,_,p,E,T){if(E.to-E.from<=0)return;const{horizontalPixelRatio:k,verticalPixelRatio:A,context:P}=x;let I=null;const $=Math.max(1,Math.floor(k))%2/2,j=p*A+$;for(let U=E.to-1;U>=E.from;--U){const nt=_[U];if(nt){const ot=T(x,nt);ot!==I&&(I!==null&&P.fill(),P.beginPath(),P.fillStyle=ot,I=ot);const q=Math.round(nt._t*k)+$,it=nt.ut*A;P.moveTo(q,it),P.arc(q,it,j,0,2*Math.PI)}}P.fill()}(t,n,u,i,m)}}class wp extends Ew{kb(t,n){return n.vt}}function Hd(e,t,n,i,r){const o=1-r;return o*o*o*e+3*o*o*r*t+3*o*r*r*n+r*r*r*i}function Lw(e,t,n,i,r){if(n===2){const[o,l]=bh(i,r-1,r);return[Math.min(e._t,t._t,o._t,l._t),Math.max(e._t,t._t,o._t,l._t)]}return[Math.min(e._t,t._t),Math.max(e._t,t._t)]}function Aw(e,t,n,i,r,o,l,h){switch(r){case 1:{const u=to(e,t,n._t,n.ut,i._t,n.ut),f=to(e,t,i._t,n.ut,i._t,i.ut),c=Math.min(u,f);return c<=h?c:null}case 2:{const[u,f]=bh(o,l-1,l),c=function(m,y,x){let _=Number.POSITIVE_INFINITY,p=x[0];for(let E=1;E<=12;E++){const T=E/12,k={_t:Hd(x[0]._t,x[1]._t,x[2]._t,x[3]._t,T),ut:Hd(x[0].ut,x[1].ut,x[2].ut,x[3].ut,T)};_=Math.min(_,to(m,y,p._t,p.ut,k._t,k.ut)),p=k}return _}(e,t,[n,u,f,i]);return c<=h?c:null}default:{const u=to(e,t,n._t,n.ut,i._t,i.ut);return u<=h?u:null}}}class Rw extends yh{constructor(t,n){super(t,n,!0)}Og(t,n,i){n.Ic(this.kg,xo(this.Tg)),t.Jo(this.kg,i,xo(this.Tg))}Tb(t,n){return{wt:t,Mt:n,_t:NaN,ut:NaN}}Lg(){const t=this.ae.Sa();this.kg=this.ae.Ua().Bh().map(n=>{let i;if((n.Gr??1)>1){const r=n.Wt[1],o=n.Wt[2],l=n.Wt[3];i=Math.abs(r-l)>Math.abs(o-l)?r:o}else i=n.Wt[3];return this.Rb(n.$n,i,t)})}}class Sp extends Rw{Bg(t,n){const i=this.ae.N();return function(r,o,l,h,u,f,c,m=0,y=0){if(o===null||o.from>=o.to||r.length===0)return null;const x=Math.max(f/2,c??0)+y;let _=Number.POSITIVE_INFINITY;if(c!==void 0){const P=c+y,I=fc(r,l-P,o.from,o.to),$=mc(r,l+P,I,o.to);for(let j=I;j<$;j++){const U=r[j];if(!$d(l,U._t,U._t,c+y))continue;const nt=Math.hypot(l-U._t,h-U.ut);nt<=c+y&&(_=Math.min(_,nt))}}if(o.to-o.from<2){const P=r[o.from],I=Math.max(m/2,x),$=to(l,h,P._t-I,P.ut,P._t+I,P.ut);return $<=x&&(_=Math.min(_,$)),Number.isFinite(_)?ua(_,2,"series-point"):null}let p=Number.POSITIVE_INFINITY;const E=fc(r,l-x,o.from,o.to),T=mc(r,l+x,E,o.to),k=Math.max(o.from+1,E),A=Math.min(o.to,T+1);for(let P=k;P<A;P++){const I=r[P-1],$=r[P],[j,U]=Lw(I,$,u,r,P);if(!$d(l,j,U,x))continue;const nt=Aw(l,h,I,$,u,r,P,x);nt!==null&&(p=Math.min(p,nt))}return Number.isFinite(_)?ua(_,2,"series-point"):Number.isFinite(p)?ua(p,1,"series-line"):null}(this.kg,this.Tg,t,n,i.lineType,i.lineVisible?i.lineWidth:1,i.pointMarkersVisible?i.pointMarkersRadius||i.lineWidth/2+2:void 0,this.le.Et().ml(),i.hitTestTolerance)}}class Nw extends Sp{constructor(){super(...arguments),this.Vg=new wp}Rb(t,n,i){return{...this.Tb(t,n),...i.Sh(t)}}Ng(){const t=this.ae.N(),n={ot:this.kg,Gt:t.lineStyle,yb:t.lineVisible?t.lineType:void 0,ct:t.lineWidth,Pb:t.pointMarkersVisible?t.pointMarkersRadius||t.lineWidth/2+2:void 0,lt:this.Tg,Cb:this.le.Et().ml()};this.Vg.ht(n)}}const Iw={type:"Line",isBuiltIn:!0,defaultOptions:{color:"#2196f3",lineStyle:0,lineWidth:3,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},mb:(e,t)=>new Nw(e,t)};function zw(e,t,n,i,r){const{context:o,horizontalPixelRatio:l,verticalPixelRatio:h}=t;o.lineTo(r._t*l,e*h),o.lineTo(i._t*l,e*h),o.closePath(),o.fillStyle=n,o.fill()}class Dw extends ds{constructor(){super(...arguments),this.rt=null}ht(t){this.rt=t}et(t){if(this.rt===null)return;const{ot:n,lt:i,Cb:r,ct:o,Gt:l,yb:h}=this.rt,u=this.rt.Lb??(this.rt.zb?0:t.mediaSize.height);if(i===null)return;const f=t.context;f.lineCap="butt",f.lineJoin="round",f.lineWidth=o,hs(f,l),f.lineWidth=1,_p(t,n,h,i,r,this.Ob.bind(this),zw.bind(null,u))}}class $w{Nb(t,n){const i=this.Fb,{Wb:r,Hb:o,Ub:l,$b:h,Lb:u,jb:f,qb:c}=n;if(this.Yb===void 0||i===void 0||i.Wb!==r||i.Hb!==o||i.Ub!==l||i.$b!==h||i.Lb!==u||i.jb!==f||i.qb!==c){const{verticalPixelRatio:m}=t,y=u||f>0?m:1,x=f*y,_=c===t.bitmapSize.height?c:c*y,p=(u??0)*y,E=t.context.createLinearGradient(0,x,0,_);if(E.addColorStop(0,r),u!=null){const T=vr((p-x)/(_-x),0,1);E.addColorStop(T,o),E.addColorStop(T,l)}E.addColorStop(1,h),this.Yb=E,this.Fb=n}return this.Yb}}class Bw{constructor(t,n,i,r){this.Zb=t,this.Xb=n,this.Jb=i,this.Qb=r}st(t,n,i){this.Zb.st(t,n,i),!this.Jb()||n&&this.Qb()||this.Xb.st(t,n,i)}}class Ow{constructor(t,n){this.Xb=t,this.tS=n}Tt(){return this.tS()?this.Xb:null}}class Fw extends Dw{constructor(){super(...arguments),this.Kb=new $w}Ob(t,n){var i;return this.Kb.Nb(t,{Wb:n.ah,Hb:"",Ub:"",$b:n.oh,jb:((i=this.rt)==null?void 0:i.jb)??0,qb:t.bitmapSize.height})}}class Ww extends Sp{constructor(t,n){super(t,n),this.lS=new Fw,this.Xb=new wp,this.sS=new Ow(this.Xb,()=>this.Jb()),this.eS=[this],this.rS=[this.sS],this.hS={Za:this.eS,qa:this.rS},this.Vg=new Bw(this.lS,this.Xb,()=>this.Jb(),()=>this.le.N().hoveredSeriesOnTop)}Ga(){return this.hS}Rb(t,n,i){return{...this.Tb(t,n),...i.Sh(t)}}Ng(){const t=this.ae.N();if(this.Tg===null||this.kg.length===0)return;let n;if(t.relativeGradient){n=this.kg[this.Tg.from].ut;for(let i=this.Tg.from;i<this.Tg.to;i++){const r=this.kg[i];r.ut<n&&(n=r.ut)}}this.lS.ht({yb:t.lineType,ot:this.kg,Gt:t.lineStyle,ct:t.lineWidth,Lb:null,jb:n,zb:t.invertFilledArea,lt:this.Tg,Cb:this.le.Et().ml()}),this.Xb.ht({yb:t.lineVisible?t.lineType:void 0,ot:this.kg,Gt:t.lineStyle,ct:t.lineWidth,lt:this.Tg,Cb:this.le.Et().ml(),Pb:t.pointMarkersVisible?t.pointMarkersRadius||t.lineWidth/2+2:void 0})}Jb(){return this.ae.It()&&this.Tg!==null&&this.aS()}aS(){const t=this.ae.N();return t.lineVisible||t.pointMarkersVisible}}const Vw={type:"Area",isBuiltIn:!0,defaultOptions:{topColor:"rgba( 46, 220, 135, 0.4)",bottomColor:"rgba( 40, 221, 100, 0)",invertFilledArea:!1,relativeGradient:!1,lineColor:"#33D778",lineStyle:0,lineWidth:3,lineType:0,lineVisible:!0,crosshairMarkerVisible:!0,crosshairMarkerRadius:4,crosshairMarkerBorderColor:"",crosshairMarkerBorderWidth:2,crosshairMarkerBackgroundColor:"",lastPriceAnimation:0,pointMarkersVisible:!1},mb:(e,t)=>new Ww(e,t)};class jw extends yh{constructor(t,n){super(t,n,!1)}Bg(t,n){return vp(this.kg,this.Tg,t,n,this.le.Et().ml(),this.ae.N().hitTestTolerance,(i,r)=>{r[0]=i.n_,r[1]=i.s_})}Og(t,n,i){n.Ic(this.kg,xo(this.Tg)),t.t_(this.kg,i,xo(this.Tg))}fS(t,n,i){return{wt:t,jr:n.Wt[0],qr:n.Wt[1],Yr:n.Wt[2],Kr:n.Wt[3],_t:NaN,i_:NaN,n_:NaN,s_:NaN,e_:NaN}}Lg(){const t=this.ae.Sa();this.kg=this.ae.Ua().Bh().map(n=>this.Rb(n.$n,n,t))}}class Hw extends ds{constructor(){super(...arguments),this.qt=null,this.oS=0}ht(t){this.qt=t}et(t){if(this.qt===null||this.qt.Un.length===0||this.qt.lt===null)return;const{horizontalPixelRatio:n}=t;this.oS=function(o,l){if(o>=2.5&&o<=4)return Math.floor(3*l);const h=1-.2*Math.atan(Math.max(4,o)-4)/(.5*Math.PI),u=Math.floor(o*h*l),f=Math.floor(o*l),c=Math.min(u,f);return Math.max(Math.floor(l),c)}(this.qt.ml,n),this.oS>=2&&Math.floor(n)%2!=this.oS%2&&this.oS--;const i=this.qt.Un;this.qt.pS&&this.vS(t,i,this.qt.lt),this.qt.gi&&this.Vm(t,i,this.qt.lt);const r=this.mS(n);(!this.qt.gi||this.oS>2*r)&&this.wS(t,i,this.qt.lt)}vS(t,n,i){if(this.qt===null)return;const{context:r,horizontalPixelRatio:o,verticalPixelRatio:l}=t;let h="",u=Math.min(Math.floor(o),Math.floor(this.qt.ml*o));u=Math.max(Math.floor(o),Math.min(u,this.oS));const f=Math.floor(.5*u);let c=null;for(let m=i.from;m<i.to;m++){const y=n[m];y.rh!==h&&(r.fillStyle=y.rh,h=y.rh);const x=Math.round(Math.min(y.i_,y.e_)*l),_=Math.round(Math.max(y.i_,y.e_)*l),p=Math.round(y.n_*l),E=Math.round(y.s_*l);let T=Math.round(o*y._t)-f;const k=T+u-1;c!==null&&(T=Math.max(c+1,T),T=Math.min(T,k));const A=k-T+1;r.fillRect(T,p,A,x-p),r.fillRect(T,_+1,A,E-_),c=k}}mS(t){let n=Math.floor(1*t);this.oS<=2*n&&(n=Math.floor(.5*(this.oS-1)));const i=Math.max(Math.floor(t),n);return this.oS<=2*i?Math.max(Math.floor(t),Math.floor(1*t)):i}Vm(t,n,i){if(this.qt===null)return;const{context:r,horizontalPixelRatio:o,verticalPixelRatio:l}=t;let h="";const u=this.mS(o);let f=null;for(let c=i.from;c<i.to;c++){const m=n[c];m.eh!==h&&(r.fillStyle=m.eh,h=m.eh);let y=Math.round(m._t*o)-Math.floor(.5*this.oS);const x=y+this.oS-1,_=Math.round(Math.min(m.i_,m.e_)*l),p=Math.round(Math.max(m.i_,m.e_)*l);if(f!==null&&(y=Math.max(f+1,y),y=Math.min(y,x)),this.qt.ml*o>2*u)Ex(r,y,_,x-y+1,p-_+1,u);else{const E=x-y+1;r.fillRect(y,_,E,p-_+1)}f=x}}wS(t,n,i){if(this.qt===null)return;const{context:r,horizontalPixelRatio:o,verticalPixelRatio:l}=t;let h="";const u=this.mS(o);for(let f=i.from;f<i.to;f++){const c=n[f];let m=Math.round(Math.min(c.i_,c.e_)*l),y=Math.round(Math.max(c.i_,c.e_)*l),x=Math.round(c._t*o)-Math.floor(.5*this.oS),_=x+this.oS-1;if(c.sh!==h){const p=c.sh;r.fillStyle=p,h=p}this.qt.gi&&(x+=u,m+=u,_-=u,y-=u),m>y||r.fillRect(x,m,_-x+1,y-m+1)}}}class Zw extends jw{constructor(){super(...arguments),this.Vg=new Hw}Rb(t,n,i){return{...this.fS(t,n,i),...i.Sh(t)}}Ng(){const t=this.ae.N();this.Vg.ht({Un:this.kg,ml:this.le.Et().ml(),pS:t.wickVisible,gi:t.borderVisible,lt:this.Tg})}}const Uw={type:"Candlestick",isBuiltIn:!0,defaultOptions:{upColor:"#26a69a",downColor:"#ef5350",wickVisible:!0,borderVisible:!0,borderColor:"#378658",borderUpColor:"#26a69a",borderDownColor:"#ef5350",wickColor:"#737375",wickUpColor:"#26a69a",wickDownColor:"#ef5350"},mb:(e,t)=>new Zw(e,t)};({...Km});const qw=()=>{try{if(typeof window<"u")return window.localStorage.getItem("backflow_dev_diagnostics")==="1"}catch{}return!1},Ea=(...e)=>{qw()&&console.warn(...e)};function Gw(e,t,n){var l,h;const i=t.expression?((l=e.evaluateExpression)==null?void 0:l.call(e,t.expression,t.expressionUrl,n,t.expressionKey))??e.interpolateText(t.expression):e.interpolateText(t.text||"");if(t.className){const u=((h=e.parseClassNameResponsive)==null?void 0:h.call(e,t.className,n))??e.parseClassName(t.className);if(e.renderMode!=="css-driven"){const c=uh(t.className);if(c.size>0){const y=It(c,e.containerWidth,"1rem");u.fontSize=y}const m=Er(t.className);m.size>0&&(u.display=It(m,e.containerWidth,"block"))}const f=e.getCommonProps(n,u,t);return N("p",{key:n,className:t.className,...f},i)}const r={color:e.cfg.colors.text};t.fontSize!==void 0&&(r.fontSize=`${t.fontSize}px`),t.fontWeight!==void 0&&(r.fontWeight=t.fontWeight),t.color!==void 0&&(r.color=t.color),t.textAlign!==void 0&&(r.textAlign=t.textAlign);const o=e.getCommonProps(n,r,t);return N("p",{key:n,...o},i)}function Yw(e){return e.replace(/<script[\s\S]*?<\/script>/gi,"").replace(/<iframe[\s\S]*?<\/iframe>/gi,"").replace(/\son\w+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi,"")}function Xw(e,t,n){const i=String(e.apiUrl||"").replace(/\/$/,""),r=e.interpolateText(t.text||t.html||"").replace(/(src|href)=("|')\/(?!\/)/g,i?`$1=$2${i}/`:"$1=$2/"),o=e.getCommonProps(n,{color:e.cfg.colors.text},t);return N("div",{key:n,className:t.className,...o,dangerouslySetInnerHTML:{__html:Yw(r)}})}function Jw(e,t,n){var h,u,f,c,m;const i=()=>{t.onClick?e.handleButtonClick(t.onClick,{onSuccess:t.onSuccess,onError:t.onError},{optimistic:t.optimistic,feedback:t.feedback}):t.href&&(t.href.startsWith("http")||e.previewMode?window.open(t.href,"_blank","noopener,noreferrer"):window.location.href=t.href)},r=()=>{var y;if(!e.interactionDisabled){if((y=t.confirmation)!=null&&y.enabled){(e.setOverlayModal||e.setActiveModal)({id:"__confirm",definition:{title:t.confirmation.title||"Confirm Action",size:"sm",components:[{type:"text",text:t.confirmation.message||"Are you sure you want to proceed?",color:e.cfg.colorMode==="light"?"rgba(0,0,0,0.65)":"rgba(255,255,255,0.6)",fontSize:14}],actions:[{label:"Cancel",variant:"ghost",dismiss:!0},{label:"Confirm",variant:"primary",dismiss:!0}]},legacyOnConfirm:()=>{i()}});return}i()}};if(t.className){const y=((h=e.parseClassNameResponsive)==null?void 0:h.call(e,t.className,n))??e.parseClassName(t.className);if(e.renderMode!=="css-driven"){const _=Er(t.className);_.size>0&&(y.display=It(_,e.containerWidth,"inline"));const p=uh(t.className);if(p.size>0){const E=It(p,e.containerWidth,"1rem");y.fontSize=E}}t.icon&&(y.display="inline-flex",y.alignItems="center",y.gap=6);const x=e.getCommonProps(n,y,t);return N("a",{key:n,className:t.className,...x,onClick:e.interactionDisabled?void 0:r,href:e.interactionDisabled?void 0:t.href&&!t.onClick?t.href:void 0,target:(u=t.href)!=null&&u.startsWith("http")?"_blank":void 0,rel:(f=t.href)!=null&&f.startsWith("http")?"noopener noreferrer":void 0},t.icon?e.renderIcon(t.icon,16):null,e.interpolateText(t.text||t.label||""))}const o={cursor:"pointer",textDecoration:"none",transition:"all 0.2s",display:"inline-flex",alignItems:"center",gap:6},l=e.getCommonProps(n,o,t);return N("a",{key:n,...l,onClick:e.interactionDisabled?void 0:r,href:e.interactionDisabled?void 0:t.href&&!t.onClick?t.href:void 0,target:(c=t.href)!=null&&c.startsWith("http")?"_blank":void 0,rel:(m=t.href)!=null&&m.startsWith("http")?"noopener noreferrer":void 0},t.icon?e.renderIcon(t.icon,16):null,e.interpolateText(t.text||t.label||""))}function Qw(e,t,n){var _,p,E,T,k;let i=!1;if(t.activeWhen){if(t.activeWhen===e.currentSceneId)i=!0;else if(typeof t.activeWhen=="string"){const A=t.activeWhen.split("=",2);A.length===2&&(i=String(((_=e.sceneData)==null?void 0:_[A[0]])??"")===A[1])}}const r=i?{onClick:t.activeOnClick||t.onClick,onSuccess:t.activeOnSuccess||t.onSuccess,onError:t.activeOnError||t.onError,icon:t.activeIcon||t.icon,text:t.activeText||t.text,label:t.activeText||t.label}:{onClick:t.onClick,onSuccess:t.onSuccess,onError:t.onError,icon:t.icon,text:t.text,label:t.label},o=t.disabled?((p=e.evaluateCondition)==null?void 0:p.call(e,t.disabled))??!1:!1,l=A=>{const P=()=>e.handleButtonClick(r.onClick||"",{onSuccess:r.onSuccess,onError:r.onError},{optimistic:t.optimistic,feedback:t.feedback,refetchScope:t.refetchScope,mergeResponse:t.mergeResponse,anchorElement:A==null?void 0:A.currentTarget});(e.withLoading?e.withLoading(n,P):P()).catch($=>{var U,nt;const j=((U=t.onError)==null?void 0:U.message)||($==null?void 0:$.message)||"An error occurred";(nt=e.showToast)==null||nt.call(e,j,"error")})},h=A=>{var P;if((P=t.confirmation)!=null&&P.enabled){(e.setOverlayModal||e.setActiveModal)({id:"__confirm",definition:{title:t.confirmation.title||"Confirm Action",size:"sm",components:[{type:"text",text:t.confirmation.message||"Are you sure you want to proceed?",color:e.cfg.colorMode==="light"?"rgba(0,0,0,0.65)":"rgba(255,255,255,0.6)",fontSize:16}],actions:[{label:"Cancel",variant:"ghost",dismiss:!0},{label:"Confirm",variant:"primary",dismiss:!0}]},legacyOnConfirm:()=>{l(A)}});return}l(A)},u=(E=e.buttonLoading)==null?void 0:E[n];if(t.className){let A=((T=e.parseClassNameResponsive)==null?void 0:T.call(e,t.className,n))??e.parseClassName(t.className);if(e.renderMode!=="css-driven"){const q=Er(t.className);q.size>0&&(A.display=It(q,e.containerWidth,"inline-flex"));const it=uh(t.className);it.size>0&&(A.fontSize=It(it,e.containerWidth,"1rem"))}let P=t.className;if(i&&t.activeClass){const q=((k=e.parseClassNameResponsive)==null?void 0:k.call(e,t.activeClass,n))??e.parseClassName(t.activeClass);A={...A,...q},P=`${t.className} ${t.activeClass}`}const I={display:"inline-flex",alignItems:"center",justifyContent:A.textAlign==="left"?"flex-start":A.textAlign==="right"?"flex-end":"center",gap:"6px",...A,...t.color&&{color:t.color},...t.background&&{background:t.background},...t.borderRadius!==void 0&&{borderRadius:typeof t.borderRadius=="number"?`${t.borderRadius}px`:t.borderRadius},...t.borderColor&&{borderColor:t.borderColor},...u&&{opacity:.6,pointerEvents:"none"}},$={},j=(t.className||"").split(/\s+/).filter(Boolean);for(const q of j)if(q.startsWith("hover:")){const it=q.replace("hover:","");if(it.startsWith("bg-")||it.startsWith("text-")||it.startsWith("border-")){const ct=e.parseClassName(it);Object.assign($,ct)}}const U=e.getCommonProps(n,I,t),nt=[];r.icon&&!u&&nt.push(N("span",{key:"icon",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,...r.text?{marginRight:"6px"}:{}}},e.renderIcon(r.icon,t.iconSize||16))),u&&nt.unshift(N("div",{key:"spinner",className:"bf-btn-spinner",style:{width:"14px",height:"14px",border:"2px solid currentColor",borderTopColor:"transparent",borderRadius:"50%",flexShrink:0}})),Array.isArray(t.children)&&t.children.length>0?t.children.forEach((q,it)=>{nt.push(e.renderComponent(q,it,n))}):nt.push(r.label||r.text||(r.icon?"":"Button"));const ot={};return Object.keys($).length>0&&(ot.onMouseEnter=q=>{$.backgroundColor&&(q.currentTarget.style.backgroundColor=$.backgroundColor),$.color&&(q.currentTarget.style.color=$.color),$.borderColor&&(q.currentTarget.style.borderColor=$.borderColor)},ot.onMouseLeave=q=>{$.backgroundColor&&(q.currentTarget.style.backgroundColor=I.backgroundColor||""),$.color&&(q.currentTarget.style.color=I.color||""),$.borderColor&&(q.currentTarget.style.borderColor=I.borderColor||"")}),N("button",{key:n,className:P,title:e.interpolateText(t.tooltip||t.ariaLabel||r.label||r.text||"Button"),...U,...ot,onClick:e.interactionDisabled?void 0:h,disabled:u||o||void 0},...nt)}const f=e.cfg.colors.primary,c=e.cfg.colors.accent,m={display:"inline-flex",alignItems:"center",gap:"6px",padding:"0.75rem 1.5rem",borderRadius:"0.75rem",fontWeight:600,transition:e.cfg.effects.transition,color:e.cfg.colorMode==="light"?"#ffffff":e.cfg.colors.text,background:i?e.cfg.colors.primary:`linear-gradient(to right, ${f}, ${c})`,boxShadow:i?"none":`0 10px 15px -3px ${f}40`,...u&&{opacity:.6,pointerEvents:"none"}},y=e.getCommonProps(n,m,t),x=[];return u&&x.push(N("div",{key:"spinner",className:"bf-btn-spinner",style:{width:"14px",height:"14px",border:"2px solid currentColor",borderTopColor:"transparent",borderRadius:"50%",flexShrink:0}})),r.icon&&!u&&x.push(N("span",{key:"icon",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginRight:"6px"}},e.renderIcon(r.icon,t.iconSize||16))),x.push(r.label||r.text||(r.icon?"":"Button")),N("button",{key:n,title:e.interpolateText(t.tooltip||t.ariaLabel||r.label||r.text||"Button"),...y,onClick:e.interactionDisabled?void 0:h,disabled:u||o||void 0},...x)}function Kw(e,t,n){var f;const i=e.interpolateText(t.src||""),r=!i||i==="placeholder",o=e.imageErrors[n];if(t.skipEmpty&&r)return null;const l={border:`1px dashed ${e.cfg.colors.borderSubtle}`,display:"flex",alignItems:"center",justifyContent:"center",padding:10,height:"200px",borderRadius:"0.75rem"};if(r){const c=e.getCommonProps(n,l,t);return N("div",{key:n,...c},N("span",{style:{color:e.cfg.colors.textPlaceholder,fontSize:"0.875rem"}},"Image"))}if(o)return null;if(t.className){const c=((f=e.parseClassNameResponsive)==null?void 0:f.call(e,t.className,n))??e.parseClassName(t.className),m=e.getCommonProps(n,c,t),y={key:`${n}-${i}`,src:i,alt:t.alt||"",className:t.className,...m,onError:()=>e.setImageErrors(x=>({...x,[n]:!0}))};return t.onClick&&!e.interactionDisabled&&(y.onClick=()=>e.handleButtonClick(t.onClick)),N("img",y)}const h={width:t.w||t.width||"100%",height:t.h||t.height||"auto",objectFit:"cover",borderRadius:"0.75rem"};t.onClick&&(h.cursor="pointer");const u={key:`${n}-${i}`,src:i,alt:t.alt||"",...e.getCommonProps(n,h,t),onError:()=>e.setImageErrors(c=>({...c,[n]:!0}))};return t.onClick&&!e.interactionDisabled&&(u.onClick=()=>e.handleButtonClick(t.onClick)),N("img",u)}function t1(e,t,n){var o;if(t.className){const l=((o=e.parseClassNameResponsive)==null?void 0:o.call(e,t.className,n))??e.parseClassName(t.className),h=e.getCommonProps(n,l,t);return N("input",{key:n,className:t.className,...h,name:t.name,placeholder:t.placeholder,type:t.inputType||"text",value:e.sceneData[t.name||""]??"",onChange:u=>e.setSceneData(f=>({...f,[t.name||""]:u.target.value})),onKeyDown:t.onKeyDown?u=>{u.key==="Enter"&&e.handleButtonClick(t.onKeyDown)}:void 0})}const i={width:"100%",padding:"8px 8px",borderRadius:e.cfg.components.inputRadius||void 0,backgroundColor:e.cfg.colors.surface,color:e.cfg.colors.text,border:`1px solid ${e.cfg.colors.border}`,outline:"none",transition:e.cfg.effects.transition},r=e.getCommonProps(n,i,t);if(t.label){const l=e.getCommonProps(n,{width:"100%"},t);return N("div",{key:n,...l},N("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem"}},t.label),N("input",{...r,name:t.name,placeholder:t.placeholder,type:t.inputType||"text",value:e.sceneData[t.name||""]??"",onChange:h=>e.setSceneData(u=>({...u,[t.name||""]:h.target.value}))}))}return N("input",{key:n,...r,name:t.name,placeholder:t.placeholder,type:t.inputType||"text",value:e.sceneData[t.name||""]??"",onChange:l=>e.setSceneData(h=>({...h,[t.name||""]:l.target.value}))})}function e1(e,t,n){const i=t.value?e.interpolateText(String(t.value)):e.sceneData[t.name||""]??"";return N("input",{key:n,type:"hidden",name:t.name,value:i})}function n1(e,t,n){var l;const i=()=>{var h;return[t.placeholder&&N("option",{key:"__placeholder",value:""},t.placeholder),...((h=t.options)==null?void 0:h.map(u=>N("option",{key:u.value,value:u.value},u.label)))||[]]};if(t.className){const h=((l=e.parseClassNameResponsive)==null?void 0:l.call(e,t.className,n))??e.parseClassName(t.className),u=e.getCommonProps(n,h,t);return N("select",{key:n,className:t.className,...u,name:t.name,value:e.sceneData[t.name||""]??"",onChange:f=>e.setSceneData(c=>({...c,[t.name||""]:f.target.value}))},...i())}const r={width:"100%",padding:"8px 8px",borderRadius:e.cfg.components.inputRadius||void 0,backgroundColor:e.cfg.colors.surface,color:e.cfg.colors.text,border:`1px solid ${e.cfg.colors.border}`,outline:"none",transition:e.cfg.effects.transition,cursor:"pointer",appearance:"none"},o=e.getCommonProps(n,r,t);if(t.label){const h=e.getCommonProps(n,{width:"100%"},t);return N("div",{key:n,...h},N("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem"}},t.label),N("select",{...o,name:t.name,value:e.sceneData[t.name||""]??"",onChange:u=>e.setSceneData(f=>({...f,[t.name||""]:u.target.value}))},...i()))}return N("select",{key:n,...o,name:t.name,value:e.sceneData[t.name||""]??"",onChange:h=>e.setSceneData(u=>({...u,[t.name||""]:h.target.value}))},...i())}function i1(e,t,n){const i=t.className||"flex items-center gap-3 cursor-pointer text-white",r=e.parseClassName(i),o="w-5 h-5 rounded border-gray-600 bg-gray-800 accent-primary",l=e.parseClassName(o),h=e.getCommonProps(n,r,t);return N("label",{key:n,className:i,...h},N("input",{type:"checkbox",className:o,style:l,checked:e.sceneData[t.name||""]||!1,onChange:u=>e.setSceneData(f=>({...f,[t.name||""]:u.target.checked}))}),N("span",{},t.label||""))}function s1(e,t,n){const i={green:{bg:"#065f4620",color:"#22c55e",border:"#22c55e40"},blue:{bg:"#1e40af20",color:"#3b82f6",border:"#3b82f640"},red:{bg:"#7f1d1d20",color:"#ef4444",border:"#ef444440"},yellow:{bg:"#71370220",color:"#eab308",border:"#eab30840"},purple:{bg:"#581c8720",color:"#a855f7",border:"#a855f740"},orange:{bg:"#7c2d1220",color:"#f97316",border:"#f9731640"},gray:{bg:"#37415120",color:"#9ca3af",border:"#9ca3af40"},cyan:{bg:"#0e727020",color:"#06b6d4",border:"#06b6d440"},pink:{bg:"#83184420",color:"#ec4899",border:"#ec489940"}};let o=t.colorScheme||"gray";if(t.colorBy&&typeof t.colorBy=="object"){const c=(e.interpolateText(t.text||t.label||"")||"").trim().toLowerCase();t.colorBy[c]&&(o=t.colorBy[c])}const l=i[o]||i.gray,h=t.variant||"subtle";let u={display:"inline-flex",alignItems:"center",padding:"2px 8px",borderRadius:"4px",fontSize:"11px",fontWeight:600,letterSpacing:"0.025em",textTransform:"uppercase",whiteSpace:"nowrap"};h==="solid"?(u.backgroundColor=l.color,u.color="#fff"):h==="outline"?(u.backgroundColor="transparent",u.color=l.color,u.border=`1px solid ${l.border||l.color}`):(u.backgroundColor=l.bg,u.color=l.color,t.bordered&&(u.border=`1px solid ${l.border||l.color}`)),t.pill&&(u.borderRadius="9999px"),t.className&&(u={...u,...e.parseClassName(t.className)});const f=e.getCommonProps(n,u,t);return N("span",{key:n,...f},e.interpolateText(t.text||t.label||""))}function r1(e,t,n){const i={display:"inline-flex",alignItems:"center",gap:"4px",padding:"4px 10px",borderRadius:"9999px",fontSize:"12px",fontWeight:500,backgroundColor:t.bg||e.cfg.colors.surfaceHover,color:t.color||e.cfg.colors.textSecondary,...t.className?e.parseClassName(t.className):{}},r=e.getCommonProps(n,i,t);return N("span",{key:n,...r},e.interpolateText(t.text||t.label||""))}function o1(e,t,n){const r={sm:32,md:40,lg:48,xl:64}[t.size||"md"]||40,o=r*.4;if(t.src){const f={width:`${r}px`,height:`${r}px`,borderRadius:"50%",objectFit:"cover",...t.className?e.parseClassName(t.className):{}},c=e.getCommonProps(n,f,t);return N("img",{key:n,src:t.src,alt:t.alt||t.label||"",...c})}const l=t.initials||(t.label||t.text||"").split(" ").map(f=>f[0]).join("").slice(0,2).toUpperCase()||"?",h={width:`${r}px`,height:`${r}px`,borderRadius:"50%",backgroundColor:t.bg||e.cfg.colors.primary,color:t.color||e.cfg.colors.text,display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${o}px`,fontWeight:600,flexShrink:0,...t.className?e.parseClassName(t.className):{}},u=e.getCommonProps(n,h,t);return N("div",{key:n,...u},l)}function a1(e,t,n){const i=t.progressValue??t.value??0,r=t.progressMax??100,o=(x,_)=>{if(typeof x=="string")return Number(e.interpolateText(x))||_;const p=Number(x);return Number.isFinite(p)?p:_},l=o(i,0),h=o(r,100),u=Math.min(100,Math.max(0,l/h*100)),c=l>h?e.cfg.colors.danger:t.color||e.cfg.colors.primary,m={width:"100%",display:"flex",flexDirection:"column",gap:"4px",...t.className?e.parseClassName(t.className):{}},y=e.getCommonProps(n,m,t);return N("div",{key:n,...y},(t.progressLabel||t.label)&&v.createElement("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"12px",color:e.cfg.colors.textMuted}},N("span",null,e.interpolateText(t.progressLabel||t.label||"")),N("span",null,`${l}/${h}`)),v.createElement("div",{style:{width:"100%",height:"8px",backgroundColor:e.cfg.colors.surfaceHover,borderRadius:"4px",overflow:"hidden"}},N("div",{style:{width:`${Math.min(u,100)}%`,height:"100%",backgroundColor:c,borderRadius:"4px",transition:"width 0.3s ease"}})))}function l1(e,t,n){const i={position:"relative",width:"100%",...t.className?e.parseClassName(t.className):{}},r=e.getCommonProps(n,i,t);return N("div",{key:n,...r},N("span",{style:{position:"absolute",left:"12px",top:"50%",transform:"translateY(-50%)",color:e.cfg.colors.textPlaceholder,fontSize:"14px",pointerEvents:"none"}},e.renderIcon("search",14)),N("input",{type:"text",name:t.name||"search",placeholder:t.placeholder||"Search...",value:e.sceneData[t.name||"search"]??"",onChange:o=>{e.setSceneData(l=>({...l,[t.name||"search"]:o.target.value}))},style:{width:"100%",padding:"8px 12px 8px 36px",borderRadius:e.cfg.layout.borderRadius,backgroundColor:e.cfg.colors.surface,color:e.cfg.colors.text,border:`1px solid ${e.cfg.colors.border}`,outline:"none",fontSize:e.cfg.typography.baseFontSize,transition:e.cfg.effects.transition}}))}function c1(e,t,n){const i=Array.isArray(t.breadcrumbItems)?t.breadcrumbItems:[],r={display:"flex",alignItems:"center",gap:"4px",fontSize:"14px",...t.className?e.parseClassName(t.className):{}},o=e.getCommonProps(n,r,t);return N("nav",{key:n,...o,"aria-label":"Breadcrumb"},i.map((l,h)=>{const u=h===i.length-1;return v.createElement(v.Fragment,{key:`${n}-bc-${h}`},v.createElement(u?"span":"a",{style:{color:u?e.cfg.colors.textSecondary:e.cfg.colors.textMuted,fontWeight:u?600:400,cursor:u?"default":"pointer",textDecoration:"none",transition:e.cfg.effects.transition},...!u&&l.href?{href:l.href}:{},...!u&&l.onClick?{onClick:()=>e.handleButtonClick(l.onClick,{})}:{}},l.label),!u&&N("span",{style:{color:e.cfg.colors.border,margin:"0 2px"}},"/"))}))}function h1(e,t,n){const i=Array.isArray(t.items)?t.items:[],[r,o]=v.useState(0),l=t.autoplay!==!1&&i.length>1,h=t.interval||4e3,u=t.effect==="fade"?"fade":"slide";v.useEffect(()=>{if(!l||i.length<2)return;const k=setInterval(()=>o(A=>(A+1)%i.length),h);return()=>clearInterval(k)},[l,h,i.length]);const f=k=>o((k%i.length+i.length)%i.length),c=t.showArrows!==!1&&i.length>1,m=t.showDots!==!1&&i.length>1,y={position:"relative",overflow:"hidden",...t.className?e.parseClassName(t.className):{}};t.aspectRatio&&(y.aspectRatio=t.aspectRatio),!t.aspectRatio&&!t.height&&(y.height="320px");const x=e.getCommonProps(n,y,t),_=k=>typeof k=="string"?{type:"text",text:k}:k&&k.image?{type:"image",src:k.image,alt:k.alt||"",title:k.title}:k,p=i.map((k,A)=>{const P=e.renderComponent({..._(k),key:void 0},A,`${n}-slide`),I={width:"100%",height:"100%",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center"};return u==="fade"?(I.position="absolute",I.inset="0",I.opacity=A===r?1:0,I.transition="opacity .5s ease",I.pointerEvents=A===r?"auto":"none"):I.flexShrink=0,N("div",{key:`${n}-item-${A}`,style:I},P)}),E=u==="fade"?{position:"relative",width:"100%",height:"100%"}:{display:"flex",height:"100%",transition:"transform .5s ease",transform:`translateX(-${r*100}%)`},T={position:"absolute",top:"50%",transform:"translateY(-50%)",zIndex:2,width:"36px",height:"36px",borderRadius:"50%",border:"none",background:"rgba(0,0,0,0.45)",color:"#fff",fontSize:"18px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"};return N("div",{key:n,...x},N("div",{style:E},p),c&&N("div",{style:{...T,left:"8px"}},N("button",{style:{background:"transparent",border:"none",color:"inherit",fontSize:"18px",cursor:"pointer"},onClick:()=>f(r-1),"aria-label":"Previous slide"},"<")),c&&N("div",{style:{...T,right:"8px"}},N("button",{style:{background:"transparent",border:"none",color:"inherit",fontSize:"18px",cursor:"pointer"},onClick:()=>f(r+1),"aria-label":"Next slide"},">")),m&&N("div",{style:{position:"absolute",bottom:"10px",left:"50%",transform:"translateX(-50%)",display:"flex",gap:"6px",zIndex:2}},i.map((k,A)=>N("button",{key:`${n}-dot-${A}`,"aria-label":`Slide ${A+1}`,onClick:()=>f(A),style:{width:"10px",height:"10px",borderRadius:"50%",border:"none",cursor:"pointer",padding:0,background:A===r?"rgba(255,255,255,0.95)":"rgba(255,255,255,0.4)",transition:"background .3s ease"}}))))}function u1(e,t,n){const i=Array.isArray(t.items)?t.items:[],r=t.speed||20,o={overflow:"hidden",width:"100%",...t.className?e.parseClassName(t.className):{}},l=e.getCommonProps(n,o,t),h=u=>N("div",{key:u,style:{display:"inline-flex",alignItems:"center",gap:t.gap||"24px",paddingRight:t.gap||"24px",animation:`bf-marquee ${r}s linear infinite`,willChange:"transform",flexShrink:0}},i.map((f,c)=>{const m=typeof f=="string"?{type:"text",text:f}:f&&f.image?{type:"image",src:f.image,alt:f.alt||"",height:t.itemHeight||"48px"}:f;return e.renderComponent(m,c,`${u}-${n}-marq`)}));return N("div",{key:n,...l},N("div",{style:{display:"flex",width:"max-content"}},h("a"),h("b")))}function d1(e,t,n){const i=v.useRef(null),r=v.useRef(null),o=v.useRef(null),[l,h]=v.useState("idle"),[u,f]=v.useState(""),[c,m]=v.useState(!1),y=t.fieldName||"capture",x=t.captureMode==="qr",_=e.apiUrl||window.location.origin,p=t.uploadPath||"/api/files/upload",E=()=>{var ot;(ot=r.current)==null||ot.getTracks().forEach(q=>q.stop()),r.current=null},T=async ot=>{var K,Z,tt;const q=new FormData;q.append("file",ot,`${y}-${Date.now()}.jpg`);const it=await fetch(new URL(p,_).toString(),{method:"POST",headers:{Authorization:`Bearer ${localStorage.getItem("token")||""}`},body:q});if(!it.ok)throw new Error("Upload failed");const ct=await it.json();return((K=ct==null?void 0:ct.file)==null?void 0:K.url)||((Z=ct==null?void 0:ct.file)==null?void 0:Z.publicUrl)||((tt=ct==null?void 0:ct.file)==null?void 0:tt.path)||(ct==null?void 0:ct.url)||(ct==null?void 0:ct.path)||""},k=async(ot,q)=>{var it,ct;if(l!=="done"){E();try{m(!0);const K=q||await T(ot);e.setSceneData(Z=>({...Z,[y]:K})),f(K),h("done"),(it=e.showToast)==null||it.call(e,t.successMessage||(q?"Scanned!":"Captured & uploaded"),"success")}catch{h("error"),(ct=e.showToast)==null||ct.call(e,"Capture failed","error")}finally{m(!1)}}},A=()=>{var it;const ot=i.current;if(!ot||!ot.videoWidth)return;const q=document.createElement("canvas");q.width=ot.videoWidth,q.height=ot.videoHeight,(it=q.getContext("2d"))==null||it.drawImage(ot,0,0),q.toBlob(ct=>ct&&k(ct),"image/jpeg",t.quality||.85)},P=async()=>{var ot,q;try{const it=await navigator.mediaDevices.getUserMedia({video:{facingMode:t.facingMode||"user",...t.aspectRatio?{aspectRatio:Number(t.aspectRatio)}:{}},audio:!1});if(r.current=it,i.current&&(i.current.srcObject=it,await i.current.play().catch(()=>{})),h("running"),x){const K=window.BarcodeDetector;if(!K){h("error"),(ot=e.showToast)==null||ot.call(e,"QR scanning not supported in this browser","error");return}const Z=new K;o.current=window.setInterval(async()=>{const tt=i.current;if(!(!tt||!tt.videoWidth||l==="done"))try{const st=await Z.detect(tt);st!=null&&st.length&&k(new Blob,st[0].rawValue)}catch{}},400)}}catch{h("error"),(q=e.showToast)==null||q.call(e,"Camera access denied","error")}};v.useEffect(()=>(P(),()=>{o.current&&window.clearInterval(o.current),E()}),[]);const I={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",width:"100%",...t.className?e.parseClassName(t.className):{}},$=e.getCommonProps(n,I,t),j=N("video",{key:"cam-video",ref:i,autoPlay:!0,playsInline:!0,muted:!0,style:{width:"100%",maxWidth:t.maxWidth||"480px",borderRadius:"12px",aspectRatio:t.aspectRatio||"4 / 3",objectFit:"cover",background:"#0f172a",display:x||l!=="done"?void 0:"none"}}),U=u?N("img",{key:"cam-result",src:u,alt:"captured",style:{width:"100%",maxWidth:t.maxWidth||"480px",borderRadius:"12px",aspectRatio:t.aspectRatio||"4 / 3",objectFit:"cover",background:"#0f172a"}}):null,nt=N("div",{key:"cam-actions",style:{display:"flex",gap:"10px",flexWrap:"wrap",justifyContent:"center"}},l!=="done"?N("button",{key:"cam-capture",onClick:A,disabled:c||l!=="running",style:{padding:"10px 22px",borderRadius:"9999px",border:"none",cursor:c?"wait":"pointer",background:"#3B82F6",color:"#fff",fontWeight:600}},c?"Uploading...":x?t.captureLabel||"Scan QR":t.captureLabel||"Capture"):N("button",{key:"cam-retake",onClick:()=>{f(""),h("idle"),P()},style:{padding:"10px 22px",borderRadius:"9999px",border:"1px solid #94a3b8",cursor:"pointer",background:"transparent"}},"Retake"));return N("div",{key:n,...$},j,U,t.captureLabel===!1?null:nt,l==="error"?N("p",{key:"cam-err",style:{color:"#EF4444",fontSize:"13px"}},"Camera unavailable — check permissions"):null)}function f1(e,t,n){var r;if(t.className){const o=((r=e.parseClassNameResponsive)==null?void 0:r.call(e,t.className,n))??e.parseClassName(t.className),l=e.getCommonProps(n,o,t);return N("div",{key:n,className:t.className,...l})}const i=e.getCommonProps(n,{height:t.h||t.height||"24px"},t);return N("div",{key:n,...i})}function m1(e,t,n){const i=t.className||"border-gray-700 my-4",r=e.parseClassName(i),o=e.getCommonProps(n,r,t);return N("hr",{key:n,className:i,...o})}function p1(e,t,n){var c;const i=t.loaderVariant||"spinner",r=t.rows||3,o=t.className?((c=e.parseClassNameResponsive)==null?void 0:c.call(e,t.className,n))??e.parseClassName(t.className):{};t.rawStyle&&Object.assign(o,t.rawStyle);const l=e.getCommonProps(n,o,t),h=`${e.scopeId}-${n}`,u=e.renderMode==="css-driven"?{"data-bf-r":h}:{};if(i==="skeleton"){const m=[];for(let y=0;y<r;y++){const x=t.width||(y===r-1?"60%":"100%");m.push(N("div",{key:y,className:"bf-loader-skeleton",style:{height:t.height||"16px",width:x,borderRadius:"6px",marginBottom:y<r-1?"12px":"0"}}))}return N("div",{key:n,className:t.className,style:o,...l,...u},...m)}if(i==="shimmer"){const m=[];for(let y=0;y<r;y++){const x=t.width||(y===r-1?"60%":"100%");m.push(N("div",{key:y,className:"bf-loader-shimmer",style:{height:t.height||"16px",width:x,borderRadius:"6px",marginBottom:y<r-1?"12px":"0"}}))}return N("div",{key:n,className:t.className,style:o,...l,...u},...m)}if(i==="dots"){const m=t.color||"currentColor";return N("div",{key:n,className:t.className,style:{display:"flex",alignItems:"center",gap:"6px",...o},...l,...u},[0,1,2].map(y=>N("div",{key:y,className:"bf-loader-dot",style:{width:t.size||"8px",height:t.size||"8px",borderRadius:"50%",backgroundColor:m,animationDelay:`${y*.16}s`}})))}if(i==="pulse")return N("div",{key:n,className:t.className,style:{display:"flex",alignItems:"center",justifyContent:"center",...o},...l,...u},N("div",{className:"bf-loader-pulse",style:{width:t.size||"32px",height:t.size||"32px",borderRadius:"50%",border:`3px solid ${t.color||"currentColor"}`}}));if(i==="progress")return N("div",{key:n,className:t.className,style:{width:"100%",...o},...l,...u},N("div",{style:{height:t.height||"4px",width:"100%",backgroundColor:"rgba(128,128,128,0.2)",borderRadius:"4px",overflow:"hidden"}},N("div",{className:"bf-loader-progress-bar",style:{height:"100%",width:"30%",backgroundColor:t.color||"currentColor",borderRadius:"4px"}})));const f=t.size||"24px";return N("div",{key:n,className:t.className,style:{display:"flex",alignItems:"center",justifyContent:"center",...o},...l,...u},N("div",{className:"bf-loader-spinner",style:{width:f,height:f,border:`3px solid ${t.color?t.color+"33":"rgba(128,128,128,0.2)"}`,borderTopColor:t.color||"currentColor",borderRadius:"50%"}}))}function g1(e,t,n){const i=t.rows||4;if(t.className){const l=e.parseClassName(t.className),h=e.getCommonProps(n,l,t);return N("textarea",{key:n,className:t.className,...h,name:t.name,placeholder:t.placeholder,rows:i})}const r={width:"100%",padding:"0.75rem 1rem",borderRadius:e.cfg.components.inputRadius,backgroundColor:e.cfg.colors.surface,color:e.cfg.colors.text,border:`1px solid ${e.cfg.colors.border}`,outline:"none",transition:e.cfg.effects.transition,resize:"vertical",fontFamily:"inherit"},o=e.getCommonProps(n,r,t);if(t.label){const l=e.getCommonProps(n,{width:"100%"},t);return N("div",{key:n,...l},N("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem"}},t.label),N("textarea",{...o,name:t.name,placeholder:t.placeholder,rows:i}))}return N("textarea",{key:n,...o,name:t.name,placeholder:t.placeholder,rows:i})}function y1(e,t,n){const i=t.icon||t.name||"",r=t.size||24,o=e.renderIcon(i,r);if(t.className){const l=e.parseClassName(t.className),h=e.getCommonProps(n,l,t);return N("span",{key:n,className:t.className,...h},o)}return v.cloneElement(o,{key:n})}function v1(e,t,n){const i=t.metricSize||"md",r=i==="sm"?"1.25rem":i==="lg"?"2.5rem":"1.75rem",o=i==="sm"?"0.75rem":i==="lg"?"1rem":"0.875rem",l=t.color||e.cfg.colors.primary,h=t.trend==="up"?"↑":t.trend==="down"?"↓":"",u=t.trendColor||(t.trend==="up"?e.cfg.colors.success:t.trend==="down"?e.cfg.colors.danger:e.cfg.colors.textMuted),f={display:"flex",flexDirection:"column",gap:"2px",padding:t.padding!==void 0?`${t.padding}px`:"0.75rem",backgroundColor:e.cfg.colors.surface,borderRadius:e.cfg.layout.borderRadiusLg,border:`1px solid ${e.cfg.colors.borderSubtle}`,...t.className?e.parseClassName(t.className):{}},c=e.getCommonProps(n,f,t);return N("div",{key:n,...c},t.label&&N("span",{style:{fontSize:o,color:e.cfg.colors.textSecondary,fontWeight:500}},e.interpolateText(t.label)),v.createElement("div",{style:{display:"flex",alignItems:"baseline",gap:"6px",marginTop:"4px"}},t.prefix&&N("span",{style:{fontSize:r,fontWeight:700,color:l}},t.prefix),N("span",{style:{fontSize:r,fontWeight:700,color:e.cfg.colors.text}},typeof t.value=="number"?t.value.toLocaleString():e.interpolateText(String(t.value??""))),t.suffix&&N("span",{style:{fontSize:r,fontWeight:700,color:l}},t.suffix),t.delta&&N("span",{style:{fontSize:"0.75rem",fontWeight:600,color:u,marginLeft:"4px"}},`${h} ${t.delta}`)))}function b1(e,t,n){const i=t.chartData||t.data||[];if(!Array.isArray(i)||i.length===0)return null;const r=t.height||200,o=t.barColor||e.cfg.colors.primary,l=t.showValues!==!1,h=t.horizontal===!0,u=t.maxValue||Math.max(...i.map(y=>y.value),1),f=h?8:Math.max(4,Math.min(20,300/i.length)),c={width:"100%",padding:t.padding!==void 0?`${t.padding}px`:"0.75rem",backgroundColor:e.cfg.colors.surface,borderRadius:e.cfg.layout.borderRadiusLg,border:`1px solid ${e.cfg.colors.borderSubtle}`,...t.title?{}:{},...t.className?e.parseClassName(t.className):{}},m=e.getCommonProps(n,c,t);return N("div",{key:n,...m},t.title&&N("div",{style:{fontSize:"0.875rem",fontWeight:600,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem",textAlign:"center"}},t.title),N("div",{style:{display:"flex",flexDirection:h?"column":"row",alignItems:h?"stretch":"flex-end",justifyContent:"center",gap:`${f}px`,height:h?void 0:`${r}px`,width:h?"100%":void 0,minHeight:h?void 0:`${r}px`,padding:"4px 0"}},...i.map((y,x)=>{const _=u>0?y.value/u*100:0,p=y.color||o;return h?N("div",{key:x,style:{display:"flex",alignItems:"center",gap:"8px",width:"100%"}},N("span",{style:{fontSize:"0.75rem",color:e.cfg.colors.textSecondary,minWidth:"60px",textAlign:"right",flexShrink:0}},y.label),N("div",{style:{flex:1,height:"20px",backgroundColor:e.cfg.colors.surfaceHover,borderRadius:"4px",overflow:"hidden",position:"relative"}},N("div",{style:{width:`${_}%`,height:"100%",backgroundColor:p,borderRadius:"4px",transition:"width 0.5s ease"}})),l&&N("span",{style:{fontSize:"0.7rem",color:e.cfg.colors.textMuted,minWidth:"32px",fontVariantNumeric:"tabular-nums"}},typeof y.value=="number"?y.value.toLocaleString():String(y.value))):N("div",{key:x,style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-end",flex:1,height:"100%",maxWidth:"60px"}},l&&N("span",{style:{fontSize:"0.65rem",color:e.cfg.colors.textMuted,marginBottom:"2px",fontVariantNumeric:"tabular-nums"}},typeof y.value=="number"?y.value.toLocaleString():String(y.value)),N("div",{style:{width:"100%",height:`${_}%`,backgroundColor:p,borderRadius:"4px 4px 0 0",transition:"height 0.5s ease",minHeight:_>0?"4px":"0px"}}),N("span",{style:{fontSize:"0.65rem",color:e.cfg.colors.textSecondary,marginTop:"4px",textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%"}},y.label))})))}function Il(e,t,n,i=!1,r=!1){const o=Array.isArray(t.chartData)?t.chartData:[];if(o.length===0)return null;const l=o.flatMap(A=>r?[A.low,A.high]:[A.value]).map(Number).filter(Number.isFinite);if(l.length===0)return null;const h=Math.min(...l),f=Math.max(...l)-h||1,c=Number(t.height)||220,m=640,y=A=>o.length===1?m/2:A/(o.length-1)*m,x=A=>c-(A-h)/f*c,_=o.map((A,P)=>`${y(P)},${x(Number(A.value))}`).join(" "),p=t.lineColor||e.cfg.colors.accent,E=t.fillColor||`${p}33`,T={width:"100%",padding:"0.75rem",backgroundColor:e.cfg.colors.surface,borderRadius:e.cfg.layout.borderRadiusLg,border:`1px solid ${e.cfg.colors.borderSubtle}`,...t.className?e.parseClassName(t.className):{}},k=r?o.map((A,P)=>{const I=Number(A.open),$=Number(A.close),j=Number(A.high),U=Number(A.low),nt=$>=I;return N("div",{key:P,style:{flex:1,height:"100%",position:"relative"}},N("div",{style:{position:"absolute",left:"50%",top:`${x(j)}px`,height:`${Math.max(1,x(U)-x(j))}px`,borderLeft:`1px solid ${nt?"#22c55e":"#ef4444"}`}}),N("div",{style:{position:"absolute",left:"25%",right:"25%",top:`${x(Math.max(I,$))}px`,height:`${Math.max(3,Math.abs(x($)-x(I)))}px`,background:nt?"#22c55e":"#ef4444",borderRadius:"2px"}}))}):v.createElement("svg",{viewBox:`0 0 ${m} ${c}`,preserveAspectRatio:"none",style:{width:"100%",height:c}},t.showGrid!==!1&&[25,50,75].map(A=>v.createElement("line",{key:A,x1:0,x2:m,y1:c*A/100,y2:c*A/100,stroke:e.cfg.colors.borderSubtle,strokeDasharray:"3 4"})),i&&v.createElement("polygon",{points:`0,${c} ${_} ${m},${c}`,fill:E}),v.createElement("polyline",{points:_,fill:"none",stroke:p,strokeWidth:3,strokeLinecap:"round",strokeLinejoin:"round"}));return N("div",{key:n,style:e.getCommonProps(n,T,t)},t.title&&N("div",{style:{color:e.cfg.colors.textSecondary,fontWeight:600,marginBottom:"0.75rem"}},t.title),N("div",{style:{display:"flex",alignItems:"stretch",gap:r?"4px":void 0,height:c}},k),N("div",{style:{display:"flex",justifyContent:"space-between",color:e.cfg.colors.textMuted,fontSize:"0.7rem",marginTop:"4px"}},...o.map((A,P)=>N("span",{key:P},A.label||""))))}function x1(e,t,n){const i=Array.isArray(t.chartData)?t.chartData[0]||{}:{},r=t.ticker||i.ticker||i.symbol||"EUR/USD",o=t.bid??i.bid??i.price,l=t.ask??i.ask,h=t.change??i.change,u=Number(h),f=Number.isFinite(u)&&u>=0,c=e.getCommonProps(n,{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"1rem",width:"100%",padding:"0.9rem 1rem",backgroundColor:e.cfg.colors.surface,border:`1px solid ${e.cfg.colors.borderSubtle}`,borderRadius:e.cfg.layout.borderRadiusLg,...t.className?e.parseClassName(t.className):{}},t);return N("div",{key:n,...c},N("div",{},N("div",{style:{color:e.cfg.colors.text,fontWeight:700}},r),t.label&&N("div",{style:{color:e.cfg.colors.textMuted,fontSize:"0.75rem"}},t.label)),N("div",{style:{display:"flex",gap:"1rem",alignItems:"baseline",fontVariantNumeric:"tabular-nums"}},o!=null&&N("span",{style:{color:e.cfg.colors.text,fontWeight:700}},String(o)),l!=null&&N("span",{style:{color:e.cfg.colors.textSecondary}},String(l)),h!=null&&N("span",{style:{color:f?"#22c55e":"#ef4444",fontSize:"0.8rem",fontWeight:600}},`${f?"+":""}${h}`)))}function _1({api:e,c:t,componentKey:n}){var E,T,k,A;const i=v.useRef(null),r=v.useRef(null),o=v.useRef(null),[l,h]=v.useState(null),u=v.useRef(null),[f,c]=v.useState(()=>Array.isArray(t.chartData)?t.chartData:[]);v.useEffect(()=>{Array.isArray(t.chartData)&&c(t.chartData)},[t.chartData]);const m=e.interpolateText(((E=t.realtime)==null?void 0:E.channel)||""),y=e.interpolateText(((T=t.timeRange)==null?void 0:T.from)||""),x=e.interpolateText(((k=t.timeRange)==null?void 0:k.to)||""),_=Array.isArray(t.timeframes)?t.timeframes:[];v.useEffect(()=>{var j,U;const P=e.sdk;if(!(((j=t.realtime)==null?void 0:j.mode)==="ws"&&e.isAuthenticated&&m&&((U=P==null?void 0:P.client)==null?void 0:U.createWebSocket)))return;const $=P.client.createWebSocket(m);return $.onmessage=nt=>{var ot;try{const q=typeof nt.data=="string"?JSON.parse(nt.data):nt.data,it=(q==null?void 0:q.tick)||((ot=q==null?void 0:q.data)==null?void 0:ot.tick)||(q==null?void 0:q.data)||q,ct=Number((it==null?void 0:it.quote)??(it==null?void 0:it.price)??(it==null?void 0:it.close));if(!Number.isFinite(ct))return;const K=Number((it==null?void 0:it.epoch)??(it==null?void 0:it.timestamp)??Date.now()/1e3),Z=Math.floor(K/60)*60;c(tt=>{const st=tt[tt.length-1];if((st==null?void 0:st.time)===Z)return[...tt.slice(0,-1),{...st,high:Math.max(Number(st.high),ct),low:Math.min(Number(st.low),ct),close:ct}];const J=Number((st==null?void 0:st.close)??ct);return[...tt.slice(-99),{time:Z,open:J,high:ct,low:ct,close:ct}]})}catch{}},()=>{var nt;return(nt=$.close)==null?void 0:nt.call($)}},[e.isAuthenticated,(A=t.realtime)==null?void 0:A.mode,m]);const p=v.useMemo(()=>f.map((P,I)=>{const $=P.time||P.timestamp;return{time:typeof $=="string"&&$.includes("T")?Math.floor(new Date($).getTime()/1e3):$||`2024-01-${String(I+1).padStart(2,"0")}`,...t.chartType==="candlestick"?{open:Number(P.open),high:Number(P.high),low:Number(P.low),close:Number(P.close)}:{value:Number(P.value??P.close)}}}),[t.chartType,f]);return u.current=p[p.length-1],v.useEffect(()=>{const P=i.current;if(!P)return;const I=Tw(P,{autoSize:!0,height:Number(t.height)||280,layout:{background:{color:"transparent"},textColor:e.cfg.colors.textSecondary},grid:{vertLines:{color:e.cfg.colors.borderSubtle},horzLines:{color:e.cfg.colors.borderSubtle}},rightPriceScale:{borderColor:e.cfg.colors.borderSubtle},timeScale:{borderColor:e.cfg.colors.borderSubtle,timeVisible:!0}}),$=t.chartType||"candlestick",j=$==="line"?I.addSeries(Iw,{color:t.lineColor||e.cfg.colors.accent}):$==="area"?I.addSeries(Vw,{lineColor:t.lineColor||e.cfg.colors.accent,topColor:t.fillColor||`${e.cfg.colors.accent}66`,bottomColor:"transparent"}):I.addSeries(Uw,{upColor:"#22c55e",downColor:"#ef4444",borderVisible:!1,wickUpColor:"#22c55e",wickDownColor:"#ef4444"});return o.current=I,r.current=j,()=>{r.current=null,o.current=null,I.remove()}},[e.cfg.colors.accent,e.cfg.colors.borderSubtle,e.cfg.colors.textSecondary,t.chartType,t.height,t.lineColor,t.fillColor]),v.useEffect(()=>{var P,I;!r.current||p.length===0||(r.current.setData(p),y&&x?(P=o.current)==null||P.timeScale().setVisibleRange({from:y,to:x}):(I=o.current)!=null&&I.timeScale().getVisibleLogicalRange()||o.current.timeScale().fitContent())},[p,y,x]),v.useEffect(()=>{if(!l||!o.current||!u.current)return;const P={"1H":3600,"4H":14400,"1D":86400,"1W":604800}[l],I=Number(u.current.time);P&&Number.isFinite(I)&&o.current.timeScale().setVisibleRange({from:I-P,to:I})},[l]),N("div",{key:n,style:{width:"100%",padding:"0.75rem",backgroundColor:e.cfg.colors.surface,borderRadius:e.cfg.layout.borderRadiusLg,border:`1px solid ${e.cfg.colors.borderSubtle}`,...t.className?e.parseClassName(t.className):{}}},_.length>0&&N("div",{style:{display:"flex",gap:"0.35rem",marginBottom:"0.5rem"}},..._.map(P=>N("button",{key:P,type:"button",onClick:()=>h(P),style:{padding:"0.3rem 0.6rem",border:`1px solid ${e.cfg.colors.borderSubtle}`,borderRadius:4,color:e.cfg.colors.text,background:l===P?e.cfg.colors.surfaceHover:"transparent",cursor:"pointer"}},P))),N("div",{ref:i,style:{width:"100%",height:Number(t.height)||280}}))}function w1(e,t,n){return v.createElement(_1,{api:e,c:t,componentKey:n})}function S1(e,t,n){const i=t.json||t.data||t.diagram||{},r=e.getCommonProps(n,{display:"flex",flexDirection:"column",minHeight:"300px"},t);return N("div",{key:n,className:t.className,...r},v.createElement("pre",{style:{fontSize:"12px",whiteSpace:"pre-wrap",margin:0}},typeof i=="string"?i:JSON.stringify(i,null,2)))}function C1({api:e,c:t,componentKey:n}){const i=t.data||t.json||t.diagram||{},{_config:r,...o}=i||{},l=Object.keys(o).length?o:i,{nodes:h,edges:u}=v.useMemo(()=>Th.createFlowDiagram(l),[l]),[f,c]=v.useState("LR"),m=e.cfg.fullscreen===!0,y=t.height||(m?"100%":320),x=e.getCommonProps(n,{width:"100%",height:y,...m?{minHeight:0}:{}},t);return N("div",{key:n,className:t.className,...x},v.createElement(Th.FlowDiagram,{nodes:h,edges:u,config:{direction:f,layout:(r==null?void 0:r.layout)||"dagre",colorMode:(r==null?void 0:r.colorMode)||(e.cfg.colorMode==="dark"?"dark":"light"),backgroundPattern:(r==null?void 0:r.backgroundPattern)||"dot"},callbacks:{onDirectionChange:_=>c(_)},showBottomBar:(r==null?void 0:r.showBottomBar)||!1,style:{width:"100%",height:"100%"}}))}function M1(e,t,n){return v.createElement(C1,{api:e,c:t,componentKey:n})}function k1(e,t,n){var i;if(t.className){const r=((i=e.parseClassNameResponsive)==null?void 0:i.call(e,t.className,n))??e.parseClassName(t.className);r.display==null&&(r.display="flex"),r.flexDirection==null&&(r.flexDirection=/(^|\s)flex(\s|$)/.test(t.className||"")||t.layout==="row"?"row":"column");const o=e.getCommonProps(n,r,t);return v.createElement("div",{key:n,className:t.className,...o},(Array.isArray(t.children)?t.children:[]).map((l,h)=>e.renderComponent(l,h,n)))}return null}const T1=v.memo(({api:e,field:t,fieldName:n,value:i,onChange:r})=>{v.useEffect(()=>{i!==void 0&&i!==""&&r&&r(i)},[]);const o=v.useRef(null),[l,h]=v.useState(!1),u=v.useRef(null),f=v.useRef(null),[c,m]=v.useState(!1),[y,x]=v.useState(""),[_,p]=v.useState(!1),E=t.html!==!1,T=k=>E?k:k.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/\n/g,"<br>");return v.useEffect(()=>{o.current&&!o.current.innerHTML&&(o.current.innerHTML=T(i))},[]),v.useEffect(()=>{o.current&&document.activeElement!==o.current&&o.current.innerHTML!==i&&(o.current.innerHTML=T(i))},[i]),v.createElement("div",{style:{width:"100%",marginBottom:"1rem"}},t.label?N("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem"}},t.label):null,v.createElement("div",{style:{border:`1px solid ${l?e.cfg.colors.primary:e.cfg.colors.border}`,borderRadius:e.cfg.components.inputRadius,overflow:"hidden",transition:"border-color 0.2s",position:"relative"}},v.createElement("div",{style:{display:"flex",gap:"4px",padding:"6px 8px",borderBottom:`1px solid ${e.cfg.colors.border}`,backgroundColor:e.cfg.colors.surface}},...[{cmd:"bold",label:"B"},{cmd:"italic",label:"I"},{cmd:"underline",label:"U"}].map(k=>N("button",{key:k.cmd,type:"button",onMouseDown:A=>{var P;A.preventDefault(),document.execCommand(k.cmd,!1),(P=o.current)==null||P.focus()},style:{padding:"2px 8px",borderRadius:"4px",border:"1px solid transparent",cursor:"pointer",backgroundColor:"transparent",color:e.cfg.colors.text,fontWeight:600,fontSize:"13px"},onMouseEnter:A=>A.target.style.borderColor=e.cfg.colors.border,onMouseLeave:A=>A.target.style.borderColor="transparent"},k.label)),N("span",{key:"spacer",style:{flex:1}}),N("button",{key:"list-btn",type:"button",onMouseDown:k=>{var A;k.preventDefault(),document.execCommand("insertUnorderedList",!1),(A=o.current)==null||A.focus()},style:{padding:"2px 8px",borderRadius:"4px",border:"1px solid transparent",cursor:"pointer",backgroundColor:"transparent",color:e.cfg.colors.text,fontSize:"13px"},onMouseEnter:k=>k.target.style.borderColor=e.cfg.colors.border,onMouseLeave:k=>k.target.style.borderColor="transparent"},"☰"),N("span",{key:"divider",style:{width:"1px",height:"16px",backgroundColor:e.cfg.colors.border,margin:"0 4px",alignSelf:"center"}}),N("button",{key:"img-btn",type:"button",onMouseDown:k=>{var A;k.preventDefault(),(A=u.current)==null||A.click()},style:{padding:"2px 6px",borderRadius:"4px",border:"1px solid transparent",cursor:"pointer",backgroundColor:"transparent",color:e.cfg.colors.text,fontSize:"13px",display:"inline-flex",alignItems:"center",justifyContent:"center"},onMouseEnter:k=>k.target.style.borderColor=e.cfg.colors.border,onMouseLeave:k=>k.target.style.borderColor="transparent"},e.renderIcon("image",14)),N("button",{key:"att-btn",type:"button",onMouseDown:k=>{var A;k.preventDefault(),(A=f.current)==null||A.click()},style:{padding:"2px 6px",borderRadius:"4px",border:"1px solid transparent",cursor:"pointer",backgroundColor:"transparent",color:e.cfg.colors.text,fontSize:"13px",display:"inline-flex",alignItems:"center",justifyContent:"center"},onMouseEnter:k=>k.target.style.borderColor=e.cfg.colors.border,onMouseLeave:k=>k.target.style.borderColor="transparent"},e.renderIcon("paperclip",14)),N("button",{key:"ai-btn",type:"button",onMouseDown:k=>{k.preventDefault(),m(!c)},style:{padding:"2px 6px",borderRadius:"4px",border:"1px solid transparent",cursor:"pointer",backgroundColor:c?e.cfg.colors.border:"transparent",color:e.cfg.colors.text,fontSize:"13px",display:"inline-flex",alignItems:"center",justifyContent:"center"},onMouseEnter:k=>k.target.style.borderColor=e.cfg.colors.border,onMouseLeave:k=>k.target.style.borderColor="transparent"},e.renderIcon("sparkles",14))),N("div",{ref:o,contentEditable:!0,suppressContentEditableWarning:!0,onInput:k=>r(k.currentTarget.innerHTML),onFocus:()=>h(!0),onBlur:()=>h(!1),style:{minHeight:(t.rows||10)*20+"px",padding:"0.75rem 1rem",backgroundColor:e.cfg.colors.surface,color:e.cfg.colors.text,outline:"none",fontSize:"0.875rem",lineHeight:"1.6"}}),t.expandAction?v.createElement("button",{type:"button",key:"expand",style:{position:"absolute",bottom:"6px",left:"6px",background:"rgba(0,0,0,0.55)",border:`1px solid ${e.cfg.colors.border}`,borderRadius:"4px",cursor:"pointer",color:e.cfg.colors.textMuted,padding:"3px 5px",display:"flex",alignItems:"center",justifyContent:"center",opacity:.5,transition:"opacity 0.2s",zIndex:1},onMouseEnter:k=>{k.currentTarget.style.opacity="0.85"},onMouseLeave:k=>{k.currentTarget.style.opacity="0.5"},onClick:k=>{k.preventDefault(),k.stopPropagation(),e.handleButtonClick(t.expandAction,{})}},e.renderIcon("maximize-2",13)):null,N("input",{key:"img-input",ref:u,type:"file",accept:"image/*",style:{display:"none"},onChange:async k=>{var P,I,$,j,U,nt;const A=(P=k.target.files)==null?void 0:P[0];if(A){try{const ot=(I=e.showToast)==null?void 0:I.call(e,"Uploading image (0%)…","success",0),q=e.uploadFile?await e.uploadFile(A,t.upload,it=>{var ct;return(ct=ot==null?void 0:ot.update)==null?void 0:ct.call(ot,`Uploading image (${it}%)`)}):"";if(($=ot==null?void 0:ot.dismiss)==null||$.call(ot),!q)throw Error();(j=o.current)==null||j.focus(),document.execCommand("insertImage",!1,q),r(((U=o.current)==null?void 0:U.innerHTML)||"")}catch{(nt=e.showToast)==null||nt.call(e,"Failed to upload image","error")}k.target.value=""}}}),N("input",{key:"att-input",ref:f,type:"file",multiple:!0,style:{display:"none"},onChange:async k=>{var j,U,nt,ot,q;const A=Array.from(k.target.files||[]);k.target.value="";const P=[];let I=0;const $=(j=e.showToast)==null?void 0:j.call(e,`Uploading 0/${A.length}…`,"success",0);for(const it of A){try{const ct=e.uploadFile?await e.uploadFile(it,t.upload,K=>{var Z;return(Z=$==null?void 0:$.update)==null?void 0:Z.call($,`Uploading ${it.name} (${K}%)`)}):"";if(!ct)throw Error();P.push(`<a href="${ct}">${it.name}</a>`)}catch{(U=e.showToast)==null||U.call(e,`Failed to upload ${it.name}`,"error")}I++,(nt=$==null?void 0:$.update)==null||nt.call($,`Uploading ${I}/${A.length}…`)}if((ot=$==null?void 0:$.dismiss)==null||ot.call($),P.length>0&&o.current){o.current.focus();const it=window.getSelection();if(it){it.removeAllRanges();const ct=document.createRange();ct.selectNodeContents(o.current),ct.collapse(!1),it.addRange(ct)}document.execCommand("insertHTML",!1,`<br><br>${P.join(", ")}`),r(((q=o.current)==null?void 0:q.innerHTML)||"")}}}),c?N("div",{key:"ai-popup",style:{position:"absolute",bottom:"100%",left:"8px",right:"8px",backgroundColor:e.cfg.colors.surfaceHover,border:`1px solid ${e.cfg.colors.borderSubtle}`,borderRadius:"8px",padding:"12px",zIndex:10,boxShadow:"0 -4px 24px rgba(0,0,0,0.4)"}},N("textarea",{value:y,onChange:k=>x(k.target.value),placeholder:"Ask AI to draft a reply...",rows:3,style:{width:"100%",padding:"8px 12px",borderRadius:"4px",border:`1px solid ${e.cfg.colors.borderSubtle}`,backgroundColor:e.cfg.colors.surface,color:e.cfg.colors.text,fontSize:"13px",outline:"none",fontFamily:"inherit",resize:"none",boxSizing:"border-box"}}),N("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end",marginTop:"8px"}},N("button",{type:"button",onClick:()=>{m(!1),x("")},style:{padding:"6px 14px",borderRadius:"6px",border:`1px solid ${e.cfg.colors.borderSubtle}`,cursor:"pointer",backgroundColor:"transparent",color:e.cfg.colors.textMuted,fontSize:"12px",fontFamily:"inherit"}},"Cancel"),N("button",{type:"button",disabled:_||!y.trim(),onClick:async()=>{var k,A,P,I;if(!(!y.trim()||_)){p(!0);try{const $=((k=o.current)==null?void 0:k.innerHTML)||"",j=await fetch("/api/tenant/email/ai/complete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:y,context:$})});if(!j.ok)throw Error();const U=await j.json(),nt=U.response||U.text||U.content||"";(A=o.current)==null||A.focus(),document.execCommand("insertText",!1,nt),r(((P=o.current)==null?void 0:P.innerHTML)||""),m(!1),x("")}catch{(I=e.showToast)==null||I.call(e,"AI request failed","error")}p(!1)}},style:{padding:"6px 14px",borderRadius:"6px",border:"none",cursor:_||!y.trim()?"not-allowed":"pointer",backgroundColor:_||!y.trim()?e.cfg.colors.surfaceHover:e.cfg.colors.background,color:_||!y.trim()?e.cfg.colors.textSecondary:e.cfg.colors.text,fontSize:"12px",fontWeight:600,fontFamily:"inherit"}},_?"Thinking...":"Generate"))):null))}),P1=v.memo(({api:e,c:t,componentKey:n})=>{const[i,r]=v.useState(!1),o=v.useRef(null),[l,h]=v.useState([]),u=t.name?`bf_persist_${t.name}`:null;v.useEffect(()=>{t.dataSource&&(async()=>{var m;try{const y=e.interpolateText(t.dataSource),x=(m=e.selectDynamicOptions)==null?void 0:m[y];if(x&&x.length>0){h(x);return}rs[y]||(rs[y]=(async()=>{var p;try{const E=await fetch(y,{headers:{Authorization:`Bearer ${localStorage.getItem("token")||""}`}});if(!E.ok)return[];const T=await E.json(),k=t.dataField||"configs",A=t.optionLabel||"label",P=t.optionValue||"value",I=T[k]||T.data||T,$=Array.isArray(I)?I.map(j=>({label:j[A]||j.name||j.label,value:j[P]||j.id||j.name||j.label})):[];return(p=e.setSelectDynamicOptions)==null||p.call(e,j=>({...j,[y]:$})),$}catch{return delete rs[y],[]}})());const _=await rs[y];_.length>0&&h(_)}catch{}})()},[t.dataSource]),v.useEffect(()=>{if(u&&t.name&&!e.sceneData[t.name]){const y=localStorage.getItem(u);y&&e.setSceneData(x=>({...x,[t.name]:y}))}},[u,t.name,e.sceneData[t.name]]),v.useEffect(()=>{if(!i)return;const m=x=>{o.current&&!o.current.contains(x.target)&&r(!1)},y=setTimeout(()=>{document.addEventListener("mousedown",m)},0);return()=>{clearTimeout(y),document.removeEventListener("mousedown",m)}},[i]);const f=t.variant==="selector",c=Array.isArray(t.items)?t.items:l;if(f){const m=t.name&&(e.sceneData[t.name||""]||u&&localStorage.getItem(u))||"",y=m||t.placeholder||"Select...";return N("div",{ref:o,style:{position:"relative",display:"inline-flex"}},v.createElement("button",{type:"button",style:{display:"inline-flex",alignItems:"center",gap:"6px",background:"none",border:"none",cursor:"pointer",fontFamily:"inherit",fontSize:t.fontSize||"1rem",fontWeight:t.fontWeight||600,color:t.color||e.cfg.colors.text,padding:"2px 0",outline:"none",lineHeight:"1.5"},onClick:x=>{x.preventDefault(),r(!i)}},N("span",{key:"text"},y),N("span",{key:"caret",style:{display:"flex",alignItems:"center",opacity:.6,marginLeft:"2px"}},e.renderIcon("chevron-down",14))),i?v.createElement("div",{style:{position:"absolute",top:"100%",left:"0",marginTop:"4px",backgroundColor:e.cfg.colors.surfaceHover,border:`1px solid ${e.cfg.colors.borderSubtle}`,borderRadius:"8px",boxShadow:"0 8px 24px rgba(0,0,0,0.4)",zIndex:9999,overflow:"hidden",minWidth:"200px"}},...c.map((x,_)=>v.createElement("button",{key:_,type:"button",style:{display:"flex",alignItems:"center",gap:"8px",width:"100%",padding:"10px 16px",backgroundColor:"transparent",color:e.cfg.colors.text,border:"none",cursor:"pointer",fontSize:"14px",textAlign:"left",fontFamily:"inherit",transition:"background-color 0.15s ease",outline:"none",whiteSpace:"nowrap"},onMouseEnter:p=>{p.currentTarget.style.backgroundColor=e.cfg.colors.borderSubtle},onMouseLeave:p=>{p.currentTarget.style.backgroundColor="transparent"},onClick:p=>{p.preventDefault(),p.stopPropagation(),r(!1),t.name&&x.value!==m&&e.setSceneData(E=>({...E,[t.name]:x.value}))}},x.label||""))):null)}return v.createElement("div",{ref:o,style:{position:"relative",display:"flex",width:"100%"}},(()=>{var x;const m=!!((x=e.buttonLoading)!=null&&x[n]),y=[];return m?y.push(N("span",{key:"spinner",className:"bf-btn-spinner",style:{width:"14px",height:"14px",border:"2px solid currentColor",borderTopColor:"transparent",borderRadius:"50%",flexShrink:0}})):t.icon&&y.push(N("span",{key:"icon",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginRight:"6px"}},e.renderIcon(t.icon,t.iconSize||16))),y.push(N("span",{key:"text",style:{lineHeight:"1"}},t.text||"Button")),v.createElement("button",{type:"button",style:{flex:1,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"0.75rem 1.5rem",backgroundColor:e.cfg.colorMode==="light"?e.cfg.colors.primary:"transparent",color:e.cfg.colorMode==="light"?"#ffffff":e.cfg.colors.textSecondary,border:`1px solid ${e.cfg.colors.border}`,cursor:"pointer",fontSize:"0.875rem",fontWeight:600,fontFamily:"inherit",lineHeight:"1.25rem",transition:"all 0.15s ease",outline:"none"},onMouseEnter:_=>{_.currentTarget.style.backgroundColor=e.cfg.colors.border,_.currentTarget.style.color=e.cfg.colorMode==="light"?"#111827":e.cfg.colors.text},onMouseLeave:_=>{_.currentTarget.style.backgroundColor=e.cfg.colorMode==="light"?e.cfg.colors.primary:"transparent",_.currentTarget.style.color=e.cfg.colorMode==="light"?"#ffffff":e.cfg.colors.textSecondary},onClick:_=>{if(_.preventDefault(),c.length>0&&c[0].onClick){const p=()=>e.handleButtonClick(c[0].onClick,{onSuccess:c[0].onSuccess,onError:c[0].onError},{feedback:c[0].feedback,optimistic:c[0].optimistic,payload:c[0].payload});(e.withLoading?e.withLoading(n,p):p()).catch(()=>{})}}},...y)})(),c.length>0?v.createElement("button",{type:"button",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"0.75rem 0.5rem",backgroundColor:"transparent",color:e.cfg.colors.textSecondary,border:`1px solid ${e.cfg.colors.border}`,borderLeft:`1px solid ${e.cfg.colors.border}`,cursor:"pointer",fontFamily:"inherit",transition:"all 0.15s ease",outline:"none"},onMouseEnter:m=>{m.currentTarget.style.backgroundColor=e.cfg.colors.border,m.currentTarget.style.color=e.cfg.colors.text},onMouseLeave:m=>{m.currentTarget.style.backgroundColor="transparent",m.currentTarget.style.color=e.cfg.colors.textSecondary},onClick:m=>{m.preventDefault(),m.stopPropagation(),r(!i)}},e.renderIcon("chevron-down",16)):null,i?v.createElement("div",{style:{position:"absolute",bottom:"100%",left:"0",right:"0",marginBottom:"4px",backgroundColor:e.cfg.colors.surfaceHover,border:`1px solid ${e.cfg.colors.borderSubtle}`,borderRadius:"8px",boxShadow:"0 -8px 24px rgba(0,0,0,0.4)",zIndex:9999,overflow:"hidden"}},...c.map((m,y)=>{var E;const x=`${n}-item-${y}`,_=!!((E=e.buttonLoading)!=null&&E[x]),p=[];return _?p.push(N("span",{key:"spinner",className:"bf-btn-spinner",style:{width:"12px",height:"12px",border:"2px solid currentColor",borderTopColor:"transparent",borderRadius:"50%",flexShrink:0}})):m.icon&&p.push(N("span",{key:"icon",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginRight:"8px"}},e.renderIcon(m.icon,14))),p.push(m.label||""),v.createElement("button",{key:y,type:"button",style:{display:"flex",alignItems:"center",gap:"8px",width:"100%",padding:"10px 16px",backgroundColor:"transparent",color:e.cfg.colors.text,border:"none",cursor:"pointer",fontSize:"14px",textAlign:"left",fontFamily:"inherit",transition:"background-color 0.15s ease",outline:"none"},onMouseEnter:T=>{T.currentTarget.style.backgroundColor=e.cfg.colors.borderSubtle},onMouseLeave:T=>{T.currentTarget.style.backgroundColor="transparent"},onClick:T=>{if(T.preventDefault(),T.stopPropagation(),!m.onClick)return;const k=m.loading==="self"?x:n;m.loading==="self"?r(!0):r(!1);const A=()=>e.handleButtonClick(m.onClick,{onSuccess:m.onSuccess,onError:m.onError},{feedback:m.feedback,optimistic:m.optimistic,payload:m.payload});(e.withLoading?e.withLoading(k,A):A()).finally(()=>{m.loading==="self"&&r(!1)}).catch(()=>{})}},...p)})):null)});function E1(e,t,n){return v.createElement(P1,{api:e,c:t,componentKey:n})}function L1(e,t,n){var u,f;const i=t.widgetId;if(!i)return null;const o=(e.widgets||[]).find(c=>c.id===i);if(!o||!Array.isArray(o.components))return Ea(`[renderer] widget "${i}" not found`),null;if(e.widgetStack&&e.widgetStack.includes(i))return Ea(`[renderer] circular widget reference "${i}"`),null;(u=e.widgetStack)==null||u.push(i);const l=t.props||{},h=pc(o.components,l).map((c,m)=>e.renderComponent(c,m,`${n}-${i}`));return(f=e.widgetStack)==null||f.pop(),v.createElement(v.Fragment,null,...h)}function pc(e,t){if(!t||Object.keys(t).length===0)return e;if(Array.isArray(e))return e.map(n=>pc(n,t));if(e&&typeof e=="object"){const n={};for(const[i,r]of Object.entries(e))typeof r=="string"&&r.includes("{{")?n[i]=r.replace(/\{\{\s*props\.([\w.]+)\s*\}\}/g,(o,l)=>{let h=t;for(const u of l.split("."))h=h==null?void 0:h[u];return h==null?"":String(h)}):n[i]=pc(r,t);return n}return e}const Cp=v.memo(({api:e,c:t,componentKey:n})=>{const[i,r]=v.useState(!1),[o,l]=v.useState(""),h=v.useRef(null),u=v.useMemo(()=>(Array.isArray(t.options)?t.options:[]).map(p=>typeof p=="string"?{label:p,value:p}:{label:p.label||p.value,value:p.value||p.label}),[t.options]),f=e.sceneData[t.name||""]??"",c=u.find(_=>_.value===f),m=v.useMemo(()=>{if(!o)return u;const _=o.toLowerCase();return u.filter(p=>p.label.toLowerCase().includes(_))},[u,o]),y=t.custom&&o&&!u.find(_=>_.value===o||_.label===o);v.useEffect(()=>{if(!i){l("");return}const _=p=>{h.current&&!h.current.contains(p.target)&&r(!1)};return setTimeout(()=>document.addEventListener("mousedown",_),0),()=>document.removeEventListener("mousedown",_)},[i]);const x=_=>{e.setSceneData(p=>({...p,[t.name||""]:_})),r(!1)};return N("div",{key:n,ref:h,style:{position:"relative",width:"100%"}},t.label&&N("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem"}},t.label),N("button",{style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 8px",borderRadius:"6px",border:"1px solid",borderColor:e.cfg.colors.border,background:"transparent",color:e.cfg.colors.text,cursor:"pointer",fontSize:"14px",textAlign:"left",gap:"8px"},onClick:()=>r(!i)},N("span",null,c?c.label:t.placeholder||"Select..."),N("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2"},N("path",{d:"m6 9 6 6 6-6"}))),i&&N("div",{style:{position:"absolute",top:"100%",left:0,right:0,zIndex:50,marginTop:"4px",borderRadius:"6px",border:"1px solid",borderColor:e.cfg.colors.border,background:e.cfg.colors.surface,overflow:"hidden",maxHeight:"260px",display:"flex",flexDirection:"column"}},t.searchable!==!1&&N("input",{style:{width:"100%",padding:"8px",border:"none",borderBottom:"1px solid",borderColor:e.cfg.colors.borderSubtle,background:"transparent",color:e.cfg.colors.text,outline:"none",fontSize:"13px"},placeholder:"Search...",value:o,onChange:_=>{l(_.target.value),_.stopPropagation()},onClick:_=>_.stopPropagation()}),N("div",{style:{overflow:"auto",flex:1}},m.map(_=>N("button",{key:_.value,style:{width:"100%",display:"block",textAlign:"left",padding:"8px",border:"none",background:_.value===f?"rgba(59,130,246,0.2)":"transparent",color:_.value===f?e.cfg.colors.primary:e.cfg.colors.text,cursor:"pointer",fontSize:"13px"},onMouseEnter:p=>{p.currentTarget.style.background=e.cfg.colors.surfaceHover},onMouseLeave:p=>{p.currentTarget.style.background=_.value===f?"rgba(59,130,246,0.2)":"transparent"},onClick:()=>x(_.value)},_.label)),y&&N("button",{style:{width:"100%",display:"block",textAlign:"left",padding:"8px",border:"none",borderTop:"1px solid",borderColor:e.cfg.colors.borderSubtle,background:"transparent",color:e.cfg.colors.primary,cursor:"pointer",fontSize:"13px",fontStyle:"italic"},onClick:()=>x(o)},`+ Add "${o}"`))))});function A1(e,t,n){return v.createElement(Cp,{api:e,c:t,componentKey:n})}const rs={},R1=v.memo(({api:e,field:t,fieldName:n,fieldKey:i,fieldStyle:r,fieldWrapperStyle:o})=>{const[l,h]=v.useState([]);v.useEffect(()=>{t.dataSource&&(async()=>{var c;try{const m=e.interpolateText(t.dataSource),y=(c=e.selectDynamicOptions)==null?void 0:c[m];if(y&&y.length>0){h(y);return}rs[m]||(rs[m]=(async()=>{var _;try{const p=await fetch(m,{headers:{Authorization:`Bearer ${localStorage.getItem("token")||""}`}});if(!p.ok)return[];const E=await p.json(),T=t.dataField||"configs",k=t.optionLabel||"label",A=t.optionValue||"value",P=E[T]||E.data||E,I=Array.isArray(P)?P.map($=>({label:$[k]||$.name||$.label,value:$[A]||$.id||$.name||$.label})):[];return(_=e.setSelectDynamicOptions)==null||_.call(e,$=>({...$,[m]:I})),I}catch{return delete rs[m],[]}})());const x=await rs[m];x.length>0&&h(x)}catch{}})()},[t.dataSource]);const u=l.length>0?l:Array.isArray(t.options)?t.options:[],f=t.placeholder||t.label||"Select...";return v.createElement("div",{key:i,style:o||{width:"100%"}},t.label?N("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem"}},t.label):null,N("select",{name:n,value:e.sceneData[n]??"",required:t.required,className:t.className,style:{...r,fontSize:"0.875rem"},size:"md",onChange:c=>e.setSceneData(m=>({...m,[n]:c.target.value}))},N("option",{key:"__placeholder",value:"",disabled:!0,hidden:!0},f),u.map((c,m)=>N("option",{key:m,value:typeof c=="string"?c:c.value},typeof c=="string"?c:c.label))))});function N1(e,t,n){var u;const i=t.className||"",r=((u=e.parseClassNameResponsive)==null?void 0:u.call(e,i,n))??e.parseClassName(i),o=e.getCommonProps(n,r,t),l=Array.isArray(t.fields)?t.fields:[],h=t.submitButton;return t.collection&&e.fetchEntitySchema?v.createElement(I1,{api:e,c:t,componentKey:n,formClassName:i,parsedStyle:r,formProps:o,fields:l,submitBtn:h}):Mp(e,t,n,i,r,o,l,h)}function I1({api:e,c:t,componentKey:n,formClassName:i,parsedStyle:r,formProps:o,fields:l,submitBtn:h}){const[u,f]=v.useState(l),[c,m]=v.useState(!0);return v.useEffect(()=>{if(!e.fetchEntitySchema){m(!1);return}e.fetchEntitySchema(t.collection).then(y=>{if(!Array.isArray(y==null?void 0:y.fields)){m(!1);return}const x=new Map(y.fields.map(p=>[p.name,p])),_=l.map(p=>{var T;const E=x.get(p.name||((T=p.label)==null?void 0:T.toLowerCase()));return E?{...p,required:p.required??E.required,validation:p.validation??(E.validation?{...E.validation}:void 0),placeholder:p.placeholder??E.placeholder}:p});f(_),m(!1)}).catch(()=>m(!1))},[t.collection]),c?N("div",{key:n,style:{padding:"1rem",textAlign:"center",color:e.cfg.colors.textMuted,fontSize:"0.8rem"}},"Loading fields..."):Mp(e,t,n,i,r,o,u,h)}const z1=v.memo(function({name:t,value:n,onChange:i,placeholder:r,required:o,inputType:l,label:h,fieldStyle:u,onKeyDown:f}){v.useEffect(()=>{n!==void 0&&n!==""&&i&&i(n)},[]);const c=v.useRef(i);c.current=i;const m=v.useRef(u);m.current=u;const y=v.useCallback(_=>{c.current(_.target.value)},[]),x=v.createElement("input",{name:t,placeholder:r,required:o,type:l||"text",value:n??"",onChange:y,onKeyDown:f?_=>{_.key==="Enter"&&f()}:void 0,style:m.current});return h?v.createElement("div",{style:{width:"100%",marginBottom:"1rem"}},v.createElement("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:u.color,marginBottom:"0.75rem"}},h),x):x}),D1=v.memo(function({api:t,field:n,fieldName:i,label:r,fieldStyle:o}){const l=v.useRef(null),[h,u]=v.useState(!1),f=t.sceneData[i]||"",c=t.sceneData[i+"_name"]||"",m=async y=>{var _,p,E,T;const x=(_=y.target.files)==null?void 0:_[0];if(y.target.value="",!!x){u(!0);try{const k=(p=t.showToast)==null?void 0:p.call(t,"Uploading test case (0%)…","success",0),A=t.uploadFile?await t.uploadFile(x,n.upload,P=>{var I;return(I=k==null?void 0:k.update)==null?void 0:I.call(k,`Uploading test case (${P}%)`)}):"";if((E=k==null?void 0:k.dismiss)==null||E.call(k),!A)throw new Error;t.setSceneData(P=>({...P,[i]:A,[i+"_name"]:x.name}))}catch{(T=t.showToast)==null||T.call(t,"Upload failed","error")}finally{u(!1)}}};return v.createElement("div",{style:{width:"100%"}},r&&N("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:t.cfg.colors.textSecondary,marginBottom:"0.75rem"}},r),f?v.createElement("div",{style:{...o,display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"}},N("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},"📎 "+(c||"Test case uploaded")),N("button",{type:"button",style:{background:"none",border:"none",cursor:"pointer",color:t.cfg.colors.danger,fontSize:"13px"},onClick:()=>t.setSceneData(y=>{const x={...y};return delete x[i],delete x[i+"_name"],x})},"Remove")):v.createElement("button",{type:"button",onClick:()=>{var y;return(y=l.current)==null?void 0:y.click()},style:{...o,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",cursor:"pointer",color:t.cfg.colors.textMuted,fontSize:"14px"}},h?"Uploading…":"⬆ Upload a test case"),N("input",{key:"file-input",ref:l,type:"file",accept:n.accept||".pdf,.docx,.txt,.md,.csv,.json",style:{display:"none"},onChange:m}))}),$1=v.memo(function({name:t,value:n,onChange:i,placeholder:r,required:o,options:l,label:h,fieldStyle:u}){v.useEffect(()=>{n!==void 0&&n!==""&&i&&i(n)},[]);const f=v.useRef(i);f.current=i;const c=v.useRef(u);c.current=u;const m=v.useCallback(x=>{f.current(x.target.value)},[]),y=v.createElement("select",{name:t,required:o,value:n??"",onChange:m,style:{...c.current,cursor:"pointer",appearance:"none"}},r?v.createElement("option",{key:"__placeholder",value:""},r):null,...l.map((x,_)=>v.createElement("option",{key:_,value:typeof x=="string"?x:x.value},typeof x=="string"?x:x.label)));return h?v.createElement("div",{style:{width:"100%",marginBottom:"1rem"}},v.createElement("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,marginBottom:"0.75rem"}},h),y):y}),B1=v.memo(function({name:t,value:n,onChange:i,placeholder:r,required:o,rows:l,label:h,fieldStyle:u}){v.useEffect(()=>{n!==void 0&&n!==""&&i&&i(n)},[]);const f=v.useRef(i);f.current=i;const c=v.useRef(u);c.current=u;const m=v.useCallback(x=>{f.current(x.target.value)},[]),y=v.createElement("textarea",{name:t,placeholder:r,required:o,rows:l||4,value:n??"",onChange:m,style:{...c.current,resize:"vertical",fontFamily:"inherit"}});return h?v.createElement("div",{style:{width:"100%",marginBottom:"1rem"}},v.createElement("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,marginBottom:"0.75rem"}},h),y):y});function Mp(e,t,n,i,r,o,l,h){var f,c;const u=[];if(l.forEach((m,y)=>{var k;const x=`${n}-field-${y}`,_=m.name||((k=m.label)==null?void 0:k.toLowerCase())||"",p={width:"100%",padding:"8px 8px",borderRadius:e.cfg.components.inputRadius||void 0,backgroundColor:m.borderless?m.backgroundColor||"transparent":e.cfg.colors.surface,color:m.textColor||e.cfg.colors.text,colorScheme:e.cfg.colorMode==="light"?"light":"dark",border:m.borderless?"none":`1px solid ${e.cfg.colors.border}`,outline:"none",transition:e.cfg.effects.transition},E={width:"100%",marginBottom:"1rem"},T=A=>A.value?e.interpolateText(String(A.value)):"";if(m.type==="richtext")u.push(v.createElement(T1,{key:x,api:e,field:m,fieldName:_,value:e.sceneData[_]??T(m),onChange:A=>e.setSceneData(P=>({...P,[_]:A}))}));else if(m.type==="textarea"){const A=m.rows||4;u.push(v.createElement(B1,{key:x,name:_,value:e.sceneData[_]??T(m),onChange:P=>e.setSceneData(I=>({...I,[_]:P})),placeholder:m.placeholder||m.label,required:m.required,rows:A,label:m.label,fieldStyle:p}))}else if(m.type==="select")if(m.dataSource)u.push(v.createElement(R1,{key:x,api:e,field:m,fieldName:_,fieldKey:x,fieldStyle:p,fieldWrapperStyle:E}));else{const A=Array.isArray(m.options)?m.options:[];u.push(v.createElement($1,{key:x,name:_,value:e.sceneData[_]??T(m),onChange:P=>e.setSceneData(I=>({...I,[_]:P})),placeholder:m.placeholder||m.label||"Select...",required:m.required,options:A,label:m.label,fieldStyle:p}))}else if(m.type==="advanced-select")u.push(v.createElement("div",{key:`${x}-wrap`,style:E},v.createElement(Cp,{key:x,api:e,c:{...m,name:_,options:m.options},componentKey:x})));else if(m.type==="file")u.push(v.createElement("div",{key:`${x}-wrap`,style:E},v.createElement(D1,{key:x,api:e,field:m,fieldName:_,label:m.label,fieldStyle:p})));else if(m.tags)u.push(v.createElement(O1,{key:x,api:e,field:m,value:e.sceneData[_]??T(m),onChange:A=>e.setSceneData(P=>({...P,[_]:A}))}));else{const A=m.type==="email"?"email":m.type==="password"?"password":m.type==="number"?"number":m.type==="date"?"date":"text";u.push(v.createElement(z1,{key:x,name:_,value:e.sceneData[_]??T(m),onChange:P=>e.setSceneData(I=>({...I,[_]:P})),placeholder:m.placeholder||m.label,required:m.required,inputType:A,label:m.label,fieldStyle:p,onKeyDown:m.onKeyDown?()=>e.handleButtonClick(m.onKeyDown):void 0}))}}),h){const m={padding:"0.75rem 1.5rem",borderRadius:e.cfg.components.inputRadius,cursor:"pointer",fontWeight:600,width:"100%",marginTop:"1rem"},y=h.className?((f=e.parseClassNameResponsive)==null?void 0:f.call(e,h.className,`${n}-submit`))??e.parseClassName(h.className):{},x=!!h.className&&/(^|\s)bg-[^\s]+/.test(h.className),_=!!h.className&&/(^|\s)text-[^\s]+/.test(h.className),p={...m,...y,...!x&&{backgroundColor:e.cfg.colors.primary},...!_&&{color:"#fff",border:"none"}},E=`${n}-submit`,T=!!((c=e.buttonLoading)!=null&&c[E]),k=()=>{var U,nt,ot,q,it;const $=[],j=e.sceneData||{};for(const ct of l){const K=ct.name||((U=ct.label)==null?void 0:U.toLowerCase()),Z=j[K],tt=ct.label||K;if(ct.required&&(Z==null||String(Z).trim()==="")){$.push(`${tt} is required`);continue}Z==null||String(Z).trim()===""||((nt=ct.validation)!=null&&nt.pattern&&!new RegExp(ct.validation.pattern).test(String(Z))&&$.push(`${tt} is invalid`),((ot=ct.validation)==null?void 0:ot.min)!==void 0&&Number(Z)<Number(ct.validation.min)&&$.push(`${tt} must be at least ${ct.validation.min}`),((q=ct.validation)==null?void 0:q.max)!==void 0&&Number(Z)>Number(ct.validation.max)&&$.push(`${tt} must be at most ${ct.validation.max}`),((it=ct.validation)==null?void 0:it.minLength)!==void 0&&String(Z).length<Number(ct.validation.minLength)&&$.push(`${tt} must be at least ${ct.validation.minLength} characters`))}return $},A=()=>{var nt,ot;const $=k();if($.length){(nt=e.showToast)==null||nt.call(e,$,"error");return}const j=()=>h.onClick?e.handleButtonClick(h.onClick,{onSuccess:h.onSuccess,onError:h.onError},{optimistic:h.optimistic,feedback:h.feedback}):Promise.resolve(),U=e.withLoading?e.withLoading(E,j):j();(ot=U==null?void 0:U.catch)==null||ot.call(U,()=>{})},P=h.onClick?()=>A():void 0,I=[];T?I.push(N("span",{key:"spinner",className:"bf-btn-spinner",style:{display:"inline-flex",width:"14px",height:"14px",marginRight:"6px",border:"2px solid currentColor",borderTopColor:"transparent",borderRadius:"50%",flexShrink:0}})):h.icon&&I.push(N("span",{key:"icon",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginRight:"6px"}},e.renderIcon(h.icon,h.iconSize||16))),I.push(N("span",{key:"text"},h.text||"Submit")),u.push(N("button",{key:E,type:h.type||"submit",className:h.className,...e.getCommonProps(E,p,h),disabled:T||void 0,onClick:P},...I))}return N("form",{key:n,className:i,...o,onSubmit:m=>m.preventDefault()},...u)}const O1=v.memo(({api:e,field:t,value:n,onChange:i})=>{v.useEffect(()=>{n!==void 0&&n!==""&&i&&i(n)},[]);const r=v.useRef(null),o=(n||"").split(",").filter(Boolean).map(x=>x.trim()),[l,h]=v.useState(""),[u,f]=v.useState(!1),c=x=>{const _=x.target.value;if(_.includes(",")||_.includes(";")){const p=_.split(/[,;]+/).map(E=>E.trim()).filter(Boolean);if(p.length>0){const E=[...new Set([...o,...p])].join(", ");i(E)}h("")}else h(_)},m=x=>{if(x.key==="Enter"||x.key===","||x.key===";"){x.preventDefault();const _=l.trim();_&&(i([...new Set([...o,_])].join(", ")),h(""))}else x.key==="Backspace"&&!l&&o.length>0&&i(o.slice(0,-1).join(", "))},y=()=>{const x=l.trim();x&&(i([...new Set([...o,x])].join(", ")),h(""))};return N("div",{key:"tags",style:{width:"100%",marginBottom:"1rem"}},t.label?N("label",{style:{display:"block",fontSize:"0.875rem",fontWeight:500,color:e.cfg.colors.textSecondary,marginBottom:"0.75rem"}},t.label):null,N("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px",padding:"0.5rem 0.75rem",borderRadius:e.cfg.components.inputRadius||"8px",backgroundColor:e.cfg.colors.surface,border:`1px solid ${u?e.cfg.colors.primary:e.cfg.colors.border}`,cursor:"text",outline:"none",transition:"border-color 0.2s"},onClick:()=>{var x;return(x=r.current)==null?void 0:x.focus()}},...o.map((x,_)=>N("span",{key:_,style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"4px",backgroundColor:e.cfg.colors.background,border:`1px solid ${e.cfg.colors.borderSubtle}`,color:e.cfg.colors.text,fontSize:"13px",lineHeight:"1.4"}},N("span",null,x),N("button",{type:"button",onMouseDown:p=>{p.preventDefault(),p.stopPropagation(),i(o.filter((E,T)=>T!==_).join(", "))},style:{background:"none",border:"none",cursor:"pointer",color:e.cfg.colors.textMuted,padding:"0",fontSize:"14px",lineHeight:"1",display:"flex",alignItems:"center",fontFamily:"inherit"}},"×"))),N("input",{ref:r,type:"text",value:l,onChange:c,onKeyDown:m,onFocus:()=>f(!0),onBlur:()=>{f(!1),y()},placeholder:t.placeholder||(o.length>0?"":"Add email..."),style:{flex:1,minWidth:"100px",border:"none",outline:"none",backgroundColor:"transparent",color:e.cfg.colors.text,fontSize:"14px",fontFamily:"inherit",padding:"2px 0"}})))});function F1(e,t,n){const i=e.interpolateText(t.text||t.content||"");if(!i)return null;const r=p=>{const E=[],T=/(\*\*(.+?)\*\*)|(\*(.+?)\*)|(`(.+?)`)|(\[(.+?)\]\((.+?)\))|(~~(.+?)~~)/g;let k=0,A;for(;(A=T.exec(p))!==null;)A.index>k&&E.push(p.slice(k,A.index)),A[2]?E.push(N("strong",{key:E.length},A[2])):A[4]?E.push(N("em",{key:E.length},A[4])):A[6]?E.push(N("code",{key:E.length},A[6])):A[8]?E.push(N("a",{key:E.length,href:A[9],target:"_blank",rel:"noopener noreferrer"},A[8])):A[11]&&E.push(N("del",{key:E.length},A[11])),k=A.index+A[0].length;return k<p.length&&E.push(p.slice(k)),E},o=i.split(`
16
+ `),l=[];let h=null,u=!1,f=[];const c=p=>{h&&(l.push(v.createElement(h.type,{key:p,style:{paddingLeft:"1.5rem",margin:"0.5rem 0"}},h.items.map((E,T)=>N("li",{key:`${p}-${T}`},E)))),h=null)},m=p=>{if(f.length===0)return;const E=f.join(`
17
+ `);l.push(N("div",{key:p,style:{position:"relative",background:"#1e1e2e",borderRadius:"8px",margin:"0.5rem 0"}},N("button",{style:{position:"absolute",top:"8px",right:"8px",background:"transparent",border:"none",color:"#666",cursor:"pointer",padding:"4px",borderRadius:"4px",lineHeight:"1",zIndex:1,display:"inline-flex",alignItems:"center",fontSize:"14px"},onClick:T=>{T.preventDefault(),T.stopPropagation(),(A=>{navigator.clipboard.writeText(A).catch(()=>{const P=document.createElement("textarea");P.value=A,P.style.position="fixed",P.style.opacity="0",document.body.appendChild(P),P.select(),document.execCommand("copy"),document.body.removeChild(P)})})(E)}},N("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},N("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),N("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"}))),N("pre",{style:{padding:"16px 12px",margin:0,overflow:"auto",fontSize:"13px",lineHeight:"1.5",color:"#e2e8f0"}},N("code",null,E)))),f=[]};for(let p=0;p<o.length;p++){const E=o[p],T=E.trim();if(T==="```"){u?(m(`code-${p}`),u=!1):(c(`list-${p}`),u=!0,f=[]);continue}if(u){f.push(E);continue}if(!T){c(`list-${p}`);continue}const k=T.match(/^(#{1,3})\s+(.+)/);if(k){c(`list-${p}`);const I=`h${k[1].length}`;l.push(v.createElement(I,{key:p,style:{margin:"0.75rem 0 0.25rem"}},...r(k[2])));continue}if(T.startsWith("- ")||T.startsWith("* ")){const P=T.slice(2);h?h.type!=="ul"&&(c(`list-${p}`),h={type:"ul",items:[]}):h={type:"ul",items:[]},h.items.push(v.createElement(v.Fragment,{},...r(P)));continue}const A=T.match(/^\d+\.\s+(.+)/);if(A){h?h.type!=="ol"&&(c(`list-${p}`),h={type:"ol",items:[]}):h={type:"ol",items:[]},h.items.push(v.createElement(v.Fragment,{},...r(A[1])));continue}c(`list-${p}`),l.push(N("p",{key:p,style:{margin:"0.25rem 0"}},...r(T)))}u&&m("code-end"),c("list-end");const y={};t.fontSize!==void 0&&(y.fontSize=`${t.fontSize}px`),t.fontWeight!==void 0&&(y.fontWeight=t.fontWeight),t.color!==void 0&&(y.color=t.color),t.textAlign!==void 0&&(y.textAlign=t.textAlign);const x=t.className?{...y,...e.parseClassName(t.className)}:y,_=e.getCommonProps(n,x,t);return N("div",{key:n,..._},...l)}function W1(e,t,n){const i=e.cfg.colors,r={position:"relative",marginTop:"auto",bottom:0,left:0,right:0,zIndex:40,display:"flex",justifyContent:"space-around",alignItems:"stretch",backgroundColor:i.surfaceHover,borderTop:`1px solid ${i.border}`,padding:"6px 0",boxShadow:"0 -2px 8px rgba(0,0,0,0.08)"},l=(Array.isArray(t.items)?t.items:[]).map((u,f)=>{const c=u.active||!1,m=()=>{const y=()=>e.handleButtonClick(u.onClick||"");(e.withLoading?e.withLoading(`${n}-bn-${f}`,y):y()).catch(()=>{})};return N("button",{key:`${n}-bn-${f}`,onClick:m,style:{background:"none",border:"none",cursor:"pointer",flex:1,display:"flex",flexDirection:"column",alignItems:"center",gap:2,padding:"6px 0",color:c?i.primary:i.textMuted,fontSize:11,fontFamily:"inherit"},"aria-label":u.label||u.icon||"nav item"},u.icon?e.renderIcon(u.icon,20):null,u.label?N("span",{},u.label):null)}),h=e.getCommonProps(n,r,t);return N("div",{key:n,...h},...l)}function V1(e,t,n){const i=Array.isArray(t.panes)?t.panes:[],r=t.className?{display:"flex",flexDirection:"row",alignItems:"stretch",...e.parseClassName(t.className)}:{display:"flex",flexDirection:"row",alignItems:"stretch",width:"100%",flex:1,minHeight:0},o=i.map((h,u)=>{const c={width:h.width!==void 0?h.width:u===i.length-1?"1fr":"50%",minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},m=`${n}-split-${u}`;return N("div",{key:m,style:c},h.component?e.renderComponent(h.component,u,`${n}-split`):null)}),l=e.getCommonProps(n,r,t);return N("div",{key:n,...l},...o)}function j1(e,t,n){const i=e.cfg.colorMode!=="light",r=()=>{var h;return(h=e.setColorMode)==null?void 0:h.call(e,i?"light":"dark")},o=t.className?e.parseClassName(t.className):{background:"none",border:`1px solid ${e.cfg.colors.border}`,borderRadius:8,cursor:"pointer",display:"flex",alignItems:"center",gap:6,padding:"6px 10px",color:e.cfg.colors.text,fontSize:14,fontFamily:"inherit"},l=e.getCommonProps(n,o,t);return N("button",{key:n,...l,onClick:r,"aria-label":i?"Switch to light mode":"Switch to dark mode"},N("span",{},i?"☀️":"🌙"),t.text?N("span",{},t.text):null)}function H1(e){var o;const{api:t,config:n}=e,i=t.interpolateText(n.channel||""),r=t.interpolateText(n.entityId||"");return v.useEffect(()=>{var E;const l=t.sdk;if(!t.isAuthenticated||!((E=l==null?void 0:l.client)!=null&&E.createWebSocket)||!i)return;let h=null,u=null,f=[],c=!1,m=null;const y=()=>{const T=t.interpolateText(n.resolution||"")||"",k=String(T).match(/(\d+)\s*x\s*(\d+)/);return k?{width:Number(k[1]),height:Number(k[2])}:{width:Number(t.interpolateText(n.width))||1280,height:Number(t.interpolateText(n.height))||720}},x=Number(t.interpolateText(n.fps))||10,_=async()=>{var k;if(c)return;c=!0,u&&u.state!=="inactive"&&await new Promise(A=>{u.onstop=()=>A(),u.stop()}),(k=h==null?void 0:h.close)==null||k.call(h);const T=new Blob(f,{type:"video/webm"});if(f=[],T.size!==0)try{const A=t.interpolateText(n.entityId||"")||"cast",P=t.interpolateText(n.fileName||"")||`${n.entityType||"video"}-${A}.webm`,I=new File([T],P,{type:"video/webm"}),$=await l.files.upload(I,{bucket:n.bucket||"backflow-storage",entityType:n.entityType||"video",entityId:A});t.setSceneData(j=>({...j,sessionId:A,[n.assetField||"asset_id"]:$==null?void 0:$.id,_recorded:$})),n.onRecorded&&t.handleButtonClick(String(n.onRecorded),{})}catch(A){Ea("[recorder] upload failed:",A)}},p=()=>{if(u)return;const{width:T,height:k}=y(),A=document.createElement("canvas");A.width=T,A.height=k;const P=A.getContext("2d");if(P){m=I=>{const $=new Image;$.onload=()=>P.drawImage($,0,0,T,k),$.src=I};try{const I=A.captureStream(x);u=new MediaRecorder(I,{mimeType:"video/webm",videoBitsPerSecond:5e6}),u.ondataavailable=$=>{$.data.size&&f.push($.data)},u.start(500)}catch(I){Ea("[recorder] start failed:",I),u=null}}};return h=l.client.createWebSocket(i),h.onmessage=T=>{let k=T==null?void 0:T.data;if(typeof k=="string")try{k=JSON.parse(k)}catch{return}(k==null?void 0:k.type)==="screencast_frame"&&k.frame?(p(),m==null||m(k.frame)):((k==null?void 0:k.status)==="completed"||(k==null?void 0:k.status)==="failed"||(k==null?void 0:k.type)==="workflow_completed"||(k==null?void 0:k.type)==="workflow_failed")&&_()},h.onclose=()=>_(),h.onerror=()=>_(),()=>{var T,k;c=!0,(T=u==null?void 0:u.stop)==null||T.call(u),(k=h==null?void 0:h.close)==null||k.call(h)}},[t.isAuthenticated,i,r,(o=e.config)==null?void 0:o.channel]),null}function Z1(e){const{api:t,config:n,componentKey:i}=e,r=t.interpolateText(n.channel||""),o=v.useRef(null),l=v.useRef(null),[h,u]=v.useState(!1);v.useEffect(()=>{const c=()=>u(document.fullscreenElement===o.current);return document.addEventListener("fullscreenchange",c),()=>document.removeEventListener("fullscreenchange",c)},[]);const f=async c=>{var y,x;c.preventDefault(),c.stopPropagation();const m=o.current;if(m){if(document.fullscreenElement){await((y=document.exitFullscreen)==null?void 0:y.call(document));return}await((x=m.requestFullscreen)==null?void 0:x.call(m))}};return v.useEffect(()=>{var p;const c=t.sdk;if(!t.isAuthenticated||!((p=c==null?void 0:c.client)!=null&&p.createWebSocket)||!r)return;let m=null,y=!1;const x=E=>{const T=l.current;if(!T)return;const k=new Image;k.onload=()=>{if(y)return;const A=T.getContext("2d");A&&(T.width=k.width,T.height=k.height,A.drawImage(k,0,0,T.width,T.height))},k.src=E},_=()=>{y||(m=c.client.createWebSocket(r),m.onmessage=E=>{let T=E==null?void 0:E.data;if(typeof T=="string")try{T=JSON.parse(T)}catch{return}(T==null?void 0:T.type)==="screencast_frame"&&T.frame&&x(T.frame)},m.onclose=()=>{y||setTimeout(_,3e3)},m.onerror=()=>{var E;(E=m==null?void 0:m.close)==null||E.call(m)})};return _(),()=>{var E;y=!0,(E=m==null?void 0:m.close)==null||E.call(m)}},[t.isAuthenticated,r,i]),v.createElement("div",{key:i,ref:o,className:"relative w-full h-full bg-black group",style:{width:"100%",height:"100%"}},v.createElement("canvas",{ref:l,className:t.parseClassName(n.className||"w-full h-full object-contain bg-black [aspect-ratio:16/9]"),style:{width:"100%",height:"100%",objectFit:"contain"}}),n.fullscreen===!1?null:v.createElement("button",{type:"button",onClick:f,title:h?"Exit fullscreen":"Open fullscreen","aria-label":h?"Exit fullscreen":"Open fullscreen",className:"absolute top-2 right-2 z-20 inline-flex h-8 w-8 items-center justify-center rounded-full bg-black/55 text-white transition-opacity hover:bg-black/75"},t.renderIcon(h?"minimize-2":"maximize-2",16)))}function kp(e,t){const n=v.useRef(t);v.useEffect(function(){t!==n.current&&e.attributionControl!=null&&(n.current!=null&&e.attributionControl.removeAttribution(n.current),t!=null&&e.attributionControl.addAttribution(t)),n.current=t},[e,t])}function Tp(e,t,n){t.center!==n.center&&e.setLatLng(t.center),t.radius!=null&&t.radius!==n.radius&&e.setRadius(t.radius)}const U1=1;function q1(e){return Object.freeze({__version:U1,map:e})}function Ha(e,t){return Object.freeze({...e,...t})}const Pp=v.createContext(null),Ep=Pp.Provider;function Za(){const e=v.useContext(Pp);if(e==null)throw new Error("No context provided: useLeafletContext() can only be used in a descendant of <MapContainer>");return e}function G1(e){function t(n,i){const{instance:r,context:o}=e(n).current;return v.useImperativeHandle(i,()=>r),n.children==null?null:v.createElement(Ep,{value:o},n.children)}return v.forwardRef(t)}function Y1(e){function t(n,i){const[r,o]=v.useState(!1),{instance:l}=e(n,o).current;v.useImperativeHandle(i,()=>l),v.useEffect(function(){r&&l.update()},[l,r,n.children]);const h=l._contentNode;return h?_c.createPortal(n.children,h):null}return v.forwardRef(t)}function X1(e){function t(n,i){const{instance:r}=e(n).current;return v.useImperativeHandle(i,()=>r),null}return v.forwardRef(t)}function xh(e,t){const n=v.useRef();v.useEffect(function(){return t!=null&&e.instance.on(t),n.current=t,function(){n.current!=null&&e.instance.off(n.current),n.current=null}},[e,t])}function Ua(e,t){const n=e.pane??t.pane;return n?{...e,pane:n}:e}function J1(e,t){return function(i,r){const o=Za(),l=e(Ua(i,o),o);return kp(o.map,i.attribution),xh(l.current,i.eventHandlers),t(l.current,o,i,r),l}}var Q1=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},gc={exports:{}};/* @preserve
18
+ * Leaflet 1.9.4, a JS library for interactive maps. https://leafletjs.com
19
+ * (c) 2010-2023 Vladimir Agafonkin, (c) 2010-2011 CloudMade
20
+ */(function(e,t){(function(n,i){i(t)})(Q1,function(n){var i="1.9.4";function r(s){var a,d,g,b;for(d=1,g=arguments.length;d<g;d++){b=arguments[d];for(a in b)s[a]=b[a]}return s}var o=Object.create||function(){function s(){}return function(a){return s.prototype=a,new s}}();function l(s,a){var d=Array.prototype.slice;if(s.bind)return s.bind.apply(s,d.call(arguments,1));var g=d.call(arguments,2);return function(){return s.apply(a,g.length?g.concat(d.call(arguments)):arguments)}}var h=0;function u(s){return"_leaflet_id"in s||(s._leaflet_id=++h),s._leaflet_id}function f(s,a,d){var g,b,C,D;return D=function(){g=!1,b&&(C.apply(d,b),b=!1)},C=function(){g?b=arguments:(s.apply(d,arguments),setTimeout(D,a),g=!0)},C}function c(s,a,d){var g=a[1],b=a[0],C=g-b;return s===g&&d?s:((s-b)%C+C)%C+b}function m(){return!1}function y(s,a){if(a===!1)return s;var d=Math.pow(10,a===void 0?6:a);return Math.round(s*d)/d}function x(s){return s.trim?s.trim():s.replace(/^\s+|\s+$/g,"")}function _(s){return x(s).split(/\s+/)}function p(s,a){Object.prototype.hasOwnProperty.call(s,"options")||(s.options=s.options?o(s.options):{});for(var d in a)s.options[d]=a[d];return s.options}function E(s,a,d){var g=[];for(var b in s)g.push(encodeURIComponent(d?b.toUpperCase():b)+"="+encodeURIComponent(s[b]));return(!a||a.indexOf("?")===-1?"?":"&")+g.join("&")}var T=/\{ *([\w_ -]+) *\}/g;function k(s,a){return s.replace(T,function(d,g){var b=a[g];if(b===void 0)throw new Error("No value provided for variable "+d);return typeof b=="function"&&(b=b(a)),b})}var A=Array.isArray||function(s){return Object.prototype.toString.call(s)==="[object Array]"};function P(s,a){for(var d=0;d<s.length;d++)if(s[d]===a)return d;return-1}var I="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";function $(s){return window["webkit"+s]||window["moz"+s]||window["ms"+s]}var j=0;function U(s){var a=+new Date,d=Math.max(0,16-(a-j));return j=a+d,window.setTimeout(s,d)}var nt=window.requestAnimationFrame||$("RequestAnimationFrame")||U,ot=window.cancelAnimationFrame||$("CancelAnimationFrame")||$("CancelRequestAnimationFrame")||function(s){window.clearTimeout(s)};function q(s,a,d){if(d&&nt===U)s.call(a);else return nt.call(window,l(s,a))}function it(s){s&&ot.call(window,s)}var ct={__proto__:null,extend:r,create:o,bind:l,get lastId(){return h},stamp:u,throttle:f,wrapNum:c,falseFn:m,formatNum:y,trim:x,splitWords:_,setOptions:p,getParamString:E,template:k,isArray:A,indexOf:P,emptyImageUrl:I,requestFn:nt,cancelFn:ot,requestAnimFrame:q,cancelAnimFrame:it};function K(){}K.extend=function(s){var a=function(){p(this),this.initialize&&this.initialize.apply(this,arguments),this.callInitHooks()},d=a.__super__=this.prototype,g=o(d);g.constructor=a,a.prototype=g;for(var b in this)Object.prototype.hasOwnProperty.call(this,b)&&b!=="prototype"&&b!=="__super__"&&(a[b]=this[b]);return s.statics&&r(a,s.statics),s.includes&&(Z(s.includes),r.apply(null,[g].concat(s.includes))),r(g,s),delete g.statics,delete g.includes,g.options&&(g.options=d.options?o(d.options):{},r(g.options,s.options)),g._initHooks=[],g.callInitHooks=function(){if(!this._initHooksCalled){d.callInitHooks&&d.callInitHooks.call(this),this._initHooksCalled=!0;for(var C=0,D=g._initHooks.length;C<D;C++)g._initHooks[C].call(this)}},a},K.include=function(s){var a=this.prototype.options;return r(this.prototype,s),s.options&&(this.prototype.options=a,this.mergeOptions(s.options)),this},K.mergeOptions=function(s){return r(this.prototype.options,s),this},K.addInitHook=function(s){var a=Array.prototype.slice.call(arguments,1),d=typeof s=="function"?s:function(){this[s].apply(this,a)};return this.prototype._initHooks=this.prototype._initHooks||[],this.prototype._initHooks.push(d),this};function Z(s){if(!(typeof L>"u"||!L||!L.Mixin)){s=A(s)?s:[s];for(var a=0;a<s.length;a++)s[a]===L.Mixin.Events&&console.warn("Deprecated include of L.Mixin.Events: this property will be removed in future releases, please inherit from L.Evented instead.",new Error().stack)}}var tt={on:function(s,a,d){if(typeof s=="object")for(var g in s)this._on(g,s[g],a);else{s=_(s);for(var b=0,C=s.length;b<C;b++)this._on(s[b],a,d)}return this},off:function(s,a,d){if(!arguments.length)delete this._events;else if(typeof s=="object")for(var g in s)this._off(g,s[g],a);else{s=_(s);for(var b=arguments.length===1,C=0,D=s.length;C<D;C++)b?this._off(s[C]):this._off(s[C],a,d)}return this},_on:function(s,a,d,g){if(typeof a!="function"){console.warn("wrong listener type: "+typeof a);return}if(this._listens(s,a,d)===!1){d===this&&(d=void 0);var b={fn:a,ctx:d};g&&(b.once=!0),this._events=this._events||{},this._events[s]=this._events[s]||[],this._events[s].push(b)}},_off:function(s,a,d){var g,b,C;if(this._events&&(g=this._events[s],!!g)){if(arguments.length===1){if(this._firingCount)for(b=0,C=g.length;b<C;b++)g[b].fn=m;delete this._events[s];return}if(typeof a!="function"){console.warn("wrong listener type: "+typeof a);return}var D=this._listens(s,a,d);if(D!==!1){var V=g[D];this._firingCount&&(V.fn=m,this._events[s]=g=g.slice()),g.splice(D,1)}}},fire:function(s,a,d){if(!this.listens(s,d))return this;var g=r({},a,{type:s,target:this,sourceTarget:a&&a.sourceTarget||this});if(this._events){var b=this._events[s];if(b){this._firingCount=this._firingCount+1||1;for(var C=0,D=b.length;C<D;C++){var V=b[C],H=V.fn;V.once&&this.off(s,H,V.ctx),H.call(V.ctx||this,g)}this._firingCount--}}return d&&this._propagateEvent(g),this},listens:function(s,a,d,g){typeof s!="string"&&console.warn('"string" type argument expected');var b=a;typeof a!="function"&&(g=!!a,b=void 0,d=void 0);var C=this._events&&this._events[s];if(C&&C.length&&this._listens(s,b,d)!==!1)return!0;if(g){for(var D in this._eventParents)if(this._eventParents[D].listens(s,a,d,g))return!0}return!1},_listens:function(s,a,d){if(!this._events)return!1;var g=this._events[s]||[];if(!a)return!!g.length;d===this&&(d=void 0);for(var b=0,C=g.length;b<C;b++)if(g[b].fn===a&&g[b].ctx===d)return b;return!1},once:function(s,a,d){if(typeof s=="object")for(var g in s)this._on(g,s[g],a,!0);else{s=_(s);for(var b=0,C=s.length;b<C;b++)this._on(s[b],a,d,!0)}return this},addEventParent:function(s){return this._eventParents=this._eventParents||{},this._eventParents[u(s)]=s,this},removeEventParent:function(s){return this._eventParents&&delete this._eventParents[u(s)],this},_propagateEvent:function(s){for(var a in this._eventParents)this._eventParents[a].fire(s.type,r({layer:s.target,propagatedFrom:s.target},s),!0)}};tt.addEventListener=tt.on,tt.removeEventListener=tt.clearAllEventListeners=tt.off,tt.addOneTimeEventListener=tt.once,tt.fireEvent=tt.fire,tt.hasEventListeners=tt.listens;var st=K.extend(tt);function J(s,a,d){this.x=d?Math.round(s):s,this.y=d?Math.round(a):a}var bt=Math.trunc||function(s){return s>0?Math.floor(s):Math.ceil(s)};J.prototype={clone:function(){return new J(this.x,this.y)},add:function(s){return this.clone()._add(et(s))},_add:function(s){return this.x+=s.x,this.y+=s.y,this},subtract:function(s){return this.clone()._subtract(et(s))},_subtract:function(s){return this.x-=s.x,this.y-=s.y,this},divideBy:function(s){return this.clone()._divideBy(s)},_divideBy:function(s){return this.x/=s,this.y/=s,this},multiplyBy:function(s){return this.clone()._multiplyBy(s)},_multiplyBy:function(s){return this.x*=s,this.y*=s,this},scaleBy:function(s){return new J(this.x*s.x,this.y*s.y)},unscaleBy:function(s){return new J(this.x/s.x,this.y/s.y)},round:function(){return this.clone()._round()},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},floor:function(){return this.clone()._floor()},_floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.clone()._ceil()},_ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},trunc:function(){return this.clone()._trunc()},_trunc:function(){return this.x=bt(this.x),this.y=bt(this.y),this},distanceTo:function(s){s=et(s);var a=s.x-this.x,d=s.y-this.y;return Math.sqrt(a*a+d*d)},equals:function(s){return s=et(s),s.x===this.x&&s.y===this.y},contains:function(s){return s=et(s),Math.abs(s.x)<=Math.abs(this.x)&&Math.abs(s.y)<=Math.abs(this.y)},toString:function(){return"Point("+y(this.x)+", "+y(this.y)+")"}};function et(s,a,d){return s instanceof J?s:A(s)?new J(s[0],s[1]):s==null?s:typeof s=="object"&&"x"in s&&"y"in s?new J(s.x,s.y):new J(s,a,d)}function ht(s,a){if(s)for(var d=a?[s,a]:s,g=0,b=d.length;g<b;g++)this.extend(d[g])}ht.prototype={extend:function(s){var a,d;if(!s)return this;if(s instanceof J||typeof s[0]=="number"||"x"in s)a=d=et(s);else if(s=kt(s),a=s.min,d=s.max,!a||!d)return this;return!this.min&&!this.max?(this.min=a.clone(),this.max=d.clone()):(this.min.x=Math.min(a.x,this.min.x),this.max.x=Math.max(d.x,this.max.x),this.min.y=Math.min(a.y,this.min.y),this.max.y=Math.max(d.y,this.max.y)),this},getCenter:function(s){return et((this.min.x+this.max.x)/2,(this.min.y+this.max.y)/2,s)},getBottomLeft:function(){return et(this.min.x,this.max.y)},getTopRight:function(){return et(this.max.x,this.min.y)},getTopLeft:function(){return this.min},getBottomRight:function(){return this.max},getSize:function(){return this.max.subtract(this.min)},contains:function(s){var a,d;return typeof s[0]=="number"||s instanceof J?s=et(s):s=kt(s),s instanceof ht?(a=s.min,d=s.max):a=d=s,a.x>=this.min.x&&d.x<=this.max.x&&a.y>=this.min.y&&d.y<=this.max.y},intersects:function(s){s=kt(s);var a=this.min,d=this.max,g=s.min,b=s.max,C=b.x>=a.x&&g.x<=d.x,D=b.y>=a.y&&g.y<=d.y;return C&&D},overlaps:function(s){s=kt(s);var a=this.min,d=this.max,g=s.min,b=s.max,C=b.x>a.x&&g.x<d.x,D=b.y>a.y&&g.y<d.y;return C&&D},isValid:function(){return!!(this.min&&this.max)},pad:function(s){var a=this.min,d=this.max,g=Math.abs(a.x-d.x)*s,b=Math.abs(a.y-d.y)*s;return kt(et(a.x-g,a.y-b),et(d.x+g,d.y+b))},equals:function(s){return s?(s=kt(s),this.min.equals(s.getTopLeft())&&this.max.equals(s.getBottomRight())):!1}};function kt(s,a){return!s||s instanceof ht?s:new ht(s,a)}function St(s,a){if(s)for(var d=a?[s,a]:s,g=0,b=d.length;g<b;g++)this.extend(d[g])}St.prototype={extend:function(s){var a=this._southWest,d=this._northEast,g,b;if(s instanceof Rt)g=s,b=s;else if(s instanceof St){if(g=s._southWest,b=s._northEast,!g||!b)return this}else return s?this.extend(Et(s)||Tt(s)):this;return!a&&!d?(this._southWest=new Rt(g.lat,g.lng),this._northEast=new Rt(b.lat,b.lng)):(a.lat=Math.min(g.lat,a.lat),a.lng=Math.min(g.lng,a.lng),d.lat=Math.max(b.lat,d.lat),d.lng=Math.max(b.lng,d.lng)),this},pad:function(s){var a=this._southWest,d=this._northEast,g=Math.abs(a.lat-d.lat)*s,b=Math.abs(a.lng-d.lng)*s;return new St(new Rt(a.lat-g,a.lng-b),new Rt(d.lat+g,d.lng+b))},getCenter:function(){return new Rt((this._southWest.lat+this._northEast.lat)/2,(this._southWest.lng+this._northEast.lng)/2)},getSouthWest:function(){return this._southWest},getNorthEast:function(){return this._northEast},getNorthWest:function(){return new Rt(this.getNorth(),this.getWest())},getSouthEast:function(){return new Rt(this.getSouth(),this.getEast())},getWest:function(){return this._southWest.lng},getSouth:function(){return this._southWest.lat},getEast:function(){return this._northEast.lng},getNorth:function(){return this._northEast.lat},contains:function(s){typeof s[0]=="number"||s instanceof Rt||"lat"in s?s=Et(s):s=Tt(s);var a=this._southWest,d=this._northEast,g,b;return s instanceof St?(g=s.getSouthWest(),b=s.getNorthEast()):g=b=s,g.lat>=a.lat&&b.lat<=d.lat&&g.lng>=a.lng&&b.lng<=d.lng},intersects:function(s){s=Tt(s);var a=this._southWest,d=this._northEast,g=s.getSouthWest(),b=s.getNorthEast(),C=b.lat>=a.lat&&g.lat<=d.lat,D=b.lng>=a.lng&&g.lng<=d.lng;return C&&D},overlaps:function(s){s=Tt(s);var a=this._southWest,d=this._northEast,g=s.getSouthWest(),b=s.getNorthEast(),C=b.lat>a.lat&&g.lat<d.lat,D=b.lng>a.lng&&g.lng<d.lng;return C&&D},toBBoxString:function(){return[this.getWest(),this.getSouth(),this.getEast(),this.getNorth()].join(",")},equals:function(s,a){return s?(s=Tt(s),this._southWest.equals(s.getSouthWest(),a)&&this._northEast.equals(s.getNorthEast(),a)):!1},isValid:function(){return!!(this._southWest&&this._northEast)}};function Tt(s,a){return s instanceof St?s:new St(s,a)}function Rt(s,a,d){if(isNaN(s)||isNaN(a))throw new Error("Invalid LatLng object: ("+s+", "+a+")");this.lat=+s,this.lng=+a,d!==void 0&&(this.alt=+d)}Rt.prototype={equals:function(s,a){if(!s)return!1;s=Et(s);var d=Math.max(Math.abs(this.lat-s.lat),Math.abs(this.lng-s.lng));return d<=(a===void 0?1e-9:a)},toString:function(s){return"LatLng("+y(this.lat,s)+", "+y(this.lng,s)+")"},distanceTo:function(s){return oe.distance(this,Et(s))},wrap:function(){return oe.wrapLatLng(this)},toBounds:function(s){var a=180*s/40075017,d=a/Math.cos(Math.PI/180*this.lat);return Tt([this.lat-a,this.lng-d],[this.lat+a,this.lng+d])},clone:function(){return new Rt(this.lat,this.lng,this.alt)}};function Et(s,a,d){return s instanceof Rt?s:A(s)&&typeof s[0]!="object"?s.length===3?new Rt(s[0],s[1],s[2]):s.length===2?new Rt(s[0],s[1]):null:s==null?s:typeof s=="object"&&"lat"in s?new Rt(s.lat,"lng"in s?s.lng:s.lon,s.alt):a===void 0?null:new Rt(s,a,d)}var re={latLngToPoint:function(s,a){var d=this.projection.project(s),g=this.scale(a);return this.transformation._transform(d,g)},pointToLatLng:function(s,a){var d=this.scale(a),g=this.transformation.untransform(s,d);return this.projection.unproject(g)},project:function(s){return this.projection.project(s)},unproject:function(s){return this.projection.unproject(s)},scale:function(s){return 256*Math.pow(2,s)},zoom:function(s){return Math.log(s/256)/Math.LN2},getProjectedBounds:function(s){if(this.infinite)return null;var a=this.projection.bounds,d=this.scale(s),g=this.transformation.transform(a.min,d),b=this.transformation.transform(a.max,d);return new ht(g,b)},infinite:!1,wrapLatLng:function(s){var a=this.wrapLng?c(s.lng,this.wrapLng,!0):s.lng,d=this.wrapLat?c(s.lat,this.wrapLat,!0):s.lat,g=s.alt;return new Rt(d,a,g)},wrapLatLngBounds:function(s){var a=s.getCenter(),d=this.wrapLatLng(a),g=a.lat-d.lat,b=a.lng-d.lng;if(g===0&&b===0)return s;var C=s.getSouthWest(),D=s.getNorthEast(),V=new Rt(C.lat-g,C.lng-b),H=new Rt(D.lat-g,D.lng-b);return new St(V,H)}},oe=r({},re,{wrapLng:[-180,180],R:6371e3,distance:function(s,a){var d=Math.PI/180,g=s.lat*d,b=a.lat*d,C=Math.sin((a.lat-s.lat)*d/2),D=Math.sin((a.lng-s.lng)*d/2),V=C*C+Math.cos(g)*Math.cos(b)*D*D,H=2*Math.atan2(Math.sqrt(V),Math.sqrt(1-V));return this.R*H}}),Ot=6378137,Re={R:Ot,MAX_LATITUDE:85.0511287798,project:function(s){var a=Math.PI/180,d=this.MAX_LATITUDE,g=Math.max(Math.min(d,s.lat),-d),b=Math.sin(g*a);return new J(this.R*s.lng*a,this.R*Math.log((1+b)/(1-b))/2)},unproject:function(s){var a=180/Math.PI;return new Rt((2*Math.atan(Math.exp(s.y/this.R))-Math.PI/2)*a,s.x*a/this.R)},bounds:function(){var s=Ot*Math.PI;return new ht([-s,-s],[s,s])}()};function Qe(s,a,d,g){if(A(s)){this._a=s[0],this._b=s[1],this._c=s[2],this._d=s[3];return}this._a=s,this._b=a,this._c=d,this._d=g}Qe.prototype={transform:function(s,a){return this._transform(s.clone(),a)},_transform:function(s,a){return a=a||1,s.x=a*(this._a*s.x+this._b),s.y=a*(this._c*s.y+this._d),s},untransform:function(s,a){return a=a||1,new J((s.x/a-this._b)/this._a,(s.y/a-this._d)/this._c)}};function ye(s,a,d,g){return new Qe(s,a,d,g)}var hi=r({},oe,{code:"EPSG:3857",projection:Re,transformation:function(){var s=.5/(Math.PI*Re.R);return ye(s,.5,-s,.5)}()}),ui=r({},hi,{code:"EPSG:900913"});function Ee(s){return document.createElementNS("http://www.w3.org/2000/svg",s)}function Ft(s,a){var d="",g,b,C,D,V,H;for(g=0,C=s.length;g<C;g++){for(V=s[g],b=0,D=V.length;b<D;b++)H=V[b],d+=(b?"L":"M")+H.x+" "+H.y;d+=a?gt.svg?"z":"x":""}return d||"M0 0"}var qt=document.documentElement.style,fe="ActiveXObject"in window,Kt=fe&&!document.addEventListener,Lt="msLaunchUri"in navigator&&!("documentMode"in document),jt=qe("webkit"),$t=qe("android"),Se=qe("android 2")||qe("android 3"),_n=parseInt(/WebKit\/([0-9]+)|$/.exec(navigator.userAgent)[1],10),di=$t&&qe("Google")&&_n<537&&!("AudioNode"in window),Ne=!!window.opera,Ce=!Lt&&qe("chrome"),fi=qe("gecko")&&!jt&&!Ne&&!fe,$e=!Ce&&qe("safari"),vt=qe("phantom"),Ze="OTransition"in qt,ve=navigator.platform.indexOf("Win")===0,Ni=fe&&"transition"in qt,Jn="WebKitCSSMatrix"in window&&"m11"in new window.WebKitCSSMatrix&&!Se,mi="MozPerspective"in qt,ee=!window.L_DISABLE_3D&&(Ni||Jn||mi)&&!Ze&&!vt,Wt=typeof orientation<"u"||qe("mobile"),pi=Wt&&jt,gi=Wt&&Jn,Tn=!window.PointerEvent&&window.MSPointerEvent,yi=!!(window.PointerEvent||Tn),Ii="ontouchstart"in window||!!window.TouchEvent,zi=!window.L_NO_TOUCH&&(Ii||yi),Bn=Wt&&Ne,Di=Wt&&fi,$i=(window.devicePixelRatio||window.screen.deviceXDPI/window.screen.logicalXDPI)>1,Bi=function(){var s=!1;try{var a=Object.defineProperty({},"passive",{get:function(){s=!0}});window.addEventListener("testPassiveEventSupport",m,a),window.removeEventListener("testPassiveEventSupport",m,a)}catch{}return s}(),fs=function(){return!!document.createElement("canvas").getContext}(),vi=!!(document.createElementNS&&Ee("svg").createSVGRect),Ue=!!vi&&function(){var s=document.createElement("div");return s.innerHTML="<svg/>",(s.firstChild&&s.firstChild.namespaceURI)==="http://www.w3.org/2000/svg"}(),bi=!vi&&function(){try{var s=document.createElement("div");s.innerHTML='<v:shape adj="1"/>';var a=s.firstChild;return a.style.behavior="url(#default#VML)",a&&typeof a.adj=="object"}catch{return!1}}(),wn=navigator.platform.indexOf("Mac")===0,Qn=navigator.platform.indexOf("Linux")===0;function qe(s){return navigator.userAgent.toLowerCase().indexOf(s)>=0}var gt={ie:fe,ielt9:Kt,edge:Lt,webkit:jt,android:$t,android23:Se,androidStock:di,opera:Ne,chrome:Ce,gecko:fi,safari:$e,phantom:vt,opera12:Ze,win:ve,ie3d:Ni,webkit3d:Jn,gecko3d:mi,any3d:ee,mobile:Wt,mobileWebkit:pi,mobileWebkit3d:gi,msPointer:Tn,pointer:yi,touch:zi,touchNative:Ii,mobileOpera:Bn,mobileGecko:Di,retina:$i,passiveEvents:Bi,canvas:fs,svg:vi,vml:bi,inlineSvg:Ue,mac:wn,linux:Qn},Oi=gt.msPointer?"MSPointerDown":"pointerdown",ce=gt.msPointer?"MSPointerMove":"pointermove",Pe=gt.msPointer?"MSPointerUp":"pointerup",Fi=gt.msPointer?"MSPointerCancel":"pointercancel",Kn={touchstart:Oi,touchmove:ce,touchend:Pe,touchcancel:Fi},Wi={touchstart:pe,touchmove:dn,touchend:dn,touchcancel:dn},un={},Ke=!1;function xi(s,a,d){return a==="touchstart"&&me(),Wi[a]?(d=Wi[a].bind(this,d),s.addEventListener(Kn[a],d,!1),d):(console.warn("wrong event specified:",a),m)}function Vs(s,a,d){if(!Kn[a]){console.warn("wrong event specified:",a);return}s.removeEventListener(Kn[a],d,!1)}function Vi(s){un[s.pointerId]=s}function Sn(s){un[s.pointerId]&&(un[s.pointerId]=s)}function On(s){delete un[s.pointerId]}function me(){Ke||(document.addEventListener(Oi,Vi,!0),document.addEventListener(ce,Sn,!0),document.addEventListener(Pe,On,!0),document.addEventListener(Fi,On,!0),Ke=!0)}function dn(s,a){if(a.pointerType!==(a.MSPOINTER_TYPE_MOUSE||"mouse")){a.touches=[];for(var d in un)a.touches.push(un[d]);a.changedTouches=[a],s(a)}}function pe(s,a){a.MSPOINTER_TYPE_TOUCH&&a.pointerType===a.MSPOINTER_TYPE_TOUCH&&Oe(a),dn(s,a)}function Pn(s){var a={},d,g;for(g in s)d=s[g],a[g]=d&&d.bind?d.bind(s):d;return s=a,a.type="dblclick",a.detail=2,a.isTrusted=!1,a._simulated=!0,a}var Fn=200;function ji(s,a){s.addEventListener("dblclick",a);var d=0,g;function b(C){if(C.detail!==1){g=C.detail;return}if(!(C.pointerType==="mouse"||C.sourceCapabilities&&!C.sourceCapabilities.firesTouchEvents)){var D=Yi(C);if(!(D.some(function(H){return H instanceof HTMLLabelElement&&H.attributes.for})&&!D.some(function(H){return H instanceof HTMLInputElement||H instanceof HTMLSelectElement}))){var V=Date.now();V-d<=Fn?(g++,g===2&&a(Pn(C))):g=1,d=V}}}return s.addEventListener("click",b),{dblclick:a,simDblclick:b}}function Hi(s,a){s.removeEventListener("dblclick",a.dblclick),s.removeEventListener("click",a.simDblclick)}var Wn=ms(["transform","webkitTransform","OTransform","MozTransform","msTransform"]),fn=ms(["webkitTransition","transition","OTransition","MozTransition","msTransition"]),Vn=fn==="webkitTransition"||fn==="OTransition"?fn+"End":"transitionend";function rn(s){return typeof s=="string"?document.getElementById(s):s}function be(s,a){var d=s.style[a]||s.currentStyle&&s.currentStyle[a];if((!d||d==="auto")&&document.defaultView){var g=document.defaultView.getComputedStyle(s,null);d=g?g[a]:null}return d==="auto"?null:d}function Ct(s,a,d){var g=document.createElement(s);return g.className=a||"",d&&d.appendChild(g),g}function Qt(s){var a=s.parentNode;a&&a.removeChild(s)}function ae(s){for(;s.firstChild;)s.removeChild(s.firstChild)}function jn(s){var a=s.parentNode;a&&a.lastChild!==s&&a.appendChild(s)}function dt(s){var a=s.parentNode;a&&a.firstChild!==s&&a.insertBefore(s,a.firstChild)}function ie(s,a){if(s.classList!==void 0)return s.classList.contains(a);var d=_i(s);return d.length>0&&new RegExp("(^|\\s)"+a+"(\\s|$)").test(d)}function xt(s,a){if(s.classList!==void 0)for(var d=_(a),g=0,b=d.length;g<b;g++)s.classList.add(d[g]);else if(!ie(s,a)){var C=_i(s);Zi(s,(C?C+" ":"")+a)}}function Bt(s,a){s.classList!==void 0?s.classList.remove(a):Zi(s,x((" "+_i(s)+" ").replace(" "+a+" "," ")))}function Zi(s,a){s.className.baseVal===void 0?s.className=a:s.className.baseVal=a}function _i(s){return s.correspondingElement&&(s=s.correspondingElement),s.className.baseVal===void 0?s.className:s.className.baseVal}function mn(s,a){"opacity"in s.style?s.style.opacity=a:"filter"in s.style&&Jt(s,a)}function Jt(s,a){var d=!1,g="DXImageTransform.Microsoft.Alpha";try{d=s.filters.item(g)}catch{if(a===1)return}a=Math.round(a*100),d?(d.Enabled=a!==100,d.Opacity=a):s.style.filter+=" progid:"+g+"(opacity="+a+")"}function ms(s){for(var a=document.documentElement.style,d=0;d<s.length;d++)if(s[d]in a)return s[d];return!1}function wi(s,a,d){var g=a||new J(0,0);s.style[Wn]=(gt.ie3d?"translate("+g.x+"px,"+g.y+"px)":"translate3d("+g.x+"px,"+g.y+"px,0)")+(d?" scale("+d+")":"")}function xe(s,a){s._leaflet_pos=a,gt.any3d?wi(s,a):(s.style.left=a.x+"px",s.style.top=a.y+"px")}function Si(s){return s._leaflet_pos||new J(0,0)}var tn,se,js;if("onselectstart"in document)tn=function(){zt(window,"selectstart",Oe)},se=function(){le(window,"selectstart",Oe)};else{var Ui=ms(["userSelect","WebkitUserSelect","OUserSelect","MozUserSelect","msUserSelect"]);tn=function(){if(Ui){var s=document.documentElement.style;js=s[Ui],s[Ui]="none"}},se=function(){Ui&&(document.documentElement.style[Ui]=js,js=void 0)}}function Hn(){zt(window,"dragstart",Oe)}function ps(){le(window,"dragstart",Oe)}var Hs,ti;function En(s){for(;s.tabIndex===-1;)s=s.parentNode;s.style&&(qi(),Hs=s,ti=s.style.outlineStyle,s.style.outlineStyle="none",zt(window,"keydown",qi))}function qi(){Hs&&(Hs.style.outlineStyle=ti,Hs=void 0,ti=void 0,le(window,"keydown",qi))}function Gi(s){do s=s.parentNode;while((!s.offsetWidth||!s.offsetHeight)&&s!==document.body);return s}function Ve(s){var a=s.getBoundingClientRect();return{x:a.width/s.offsetWidth||1,y:a.height/s.offsetHeight||1,boundingClientRect:a}}var Ln={__proto__:null,TRANSFORM:Wn,TRANSITION:fn,TRANSITION_END:Vn,get:rn,getStyle:be,create:Ct,remove:Qt,empty:ae,toFront:jn,toBack:dt,hasClass:ie,addClass:xt,removeClass:Bt,setClass:Zi,getClass:_i,setOpacity:mn,testProp:ms,setTransform:wi,setPosition:xe,getPosition:Si,get disableTextSelection(){return tn},get enableTextSelection(){return se},disableImageDrag:Hn,enableImageDrag:ps,preventOutline:En,restoreOutline:qi,getSizedParentNode:Gi,getScale:Ve};function zt(s,a,d,g){if(a&&typeof a=="object")for(var b in a)Rr(s,b,a[b],d);else{a=_(a);for(var C=0,D=a.length;C<D;C++)Rr(s,a[C],d,g)}return this}var Ie="_leaflet_events";function le(s,a,d,g){if(arguments.length===1)gs(s),delete s[Ie];else if(a&&typeof a=="object")for(var b in a)Nr(s,b,a[b],d);else if(a=_(a),arguments.length===2)gs(s,function(V){return P(a,V)!==-1});else for(var C=0,D=a.length;C<D;C++)Nr(s,a[C],d,g);return this}function gs(s,a){for(var d in s[Ie]){var g=d.split(/\d/)[0];(!a||a(g))&&Nr(s,g,null,null,d)}}var Ar={mouseenter:"mouseover",mouseleave:"mouseout",wheel:!("onwheel"in window)&&"mousewheel"};function Rr(s,a,d,g){var b=a+u(d)+(g?"_"+u(g):"");if(s[Ie]&&s[Ie][b])return this;var C=function(V){return d.call(g||s,V||window.event)},D=C;!gt.touchNative&&gt.pointer&&a.indexOf("touch")===0?C=xi(s,a,C):gt.touch&&a==="dblclick"?C=ji(s,C):"addEventListener"in s?a==="touchstart"||a==="touchmove"||a==="wheel"||a==="mousewheel"?s.addEventListener(Ar[a]||a,C,gt.passiveEvents?{passive:!1}:!1):a==="mouseenter"||a==="mouseleave"?(C=function(V){V=V||window.event,he(s,V)&&D(V)},s.addEventListener(Ar[a],C,!1)):s.addEventListener(a,D,!1):s.attachEvent("on"+a,C),s[Ie]=s[Ie]||{},s[Ie][b]=C}function Nr(s,a,d,g,b){b=b||a+u(d)+(g?"_"+u(g):"");var C=s[Ie]&&s[Ie][b];if(!C)return this;!gt.touchNative&&gt.pointer&&a.indexOf("touch")===0?Vs(s,a,C):gt.touch&&a==="dblclick"?Hi(s,C):"removeEventListener"in s?s.removeEventListener(Ar[a]||a,C,!1):s.detachEvent("on"+a,C),s[Ie][b]=null}function Ci(s){return s.stopPropagation?s.stopPropagation():s.originalEvent?s.originalEvent._stopped=!0:s.cancelBubble=!0,this}function Be(s){return Rr(s,"wheel",Ci),this}function ys(s){return zt(s,"mousedown touchstart dblclick contextmenu",Ci),s._leaflet_disable_click=!0,this}function Oe(s){return s.preventDefault?s.preventDefault():s.returnValue=!1,this}function pn(s){return Oe(s),Ci(s),this}function Yi(s){if(s.composedPath)return s.composedPath();for(var a=[],d=s.target;d;)a.push(d),d=d.parentNode;return a}function An(s,a){if(!a)return new J(s.clientX,s.clientY);var d=Ve(a),g=d.boundingClientRect;return new J((s.clientX-g.left)/d.x-a.clientLeft,(s.clientY-g.top)/d.y-a.clientTop)}var Ir=gt.linux&&gt.chrome?window.devicePixelRatio:gt.mac?window.devicePixelRatio*3:window.devicePixelRatio>0?2*window.devicePixelRatio:1;function Zs(s){return gt.edge?s.wheelDeltaY/2:s.deltaY&&s.deltaMode===0?-s.deltaY/Ir:s.deltaY&&s.deltaMode===1?-s.deltaY*20:s.deltaY&&s.deltaMode===2?-s.deltaY*60:s.deltaX||s.deltaZ?0:s.wheelDelta?(s.wheelDeltaY||s.wheelDelta)/2:s.detail&&Math.abs(s.detail)<32765?-s.detail*20:s.detail?s.detail/-32765*60:0}function he(s,a){var d=a.relatedTarget;if(!d)return!0;try{for(;d&&d!==s;)d=d.parentNode}catch{return!1}return d!==s}var Xi={__proto__:null,on:zt,off:le,stopPropagation:Ci,disableScrollPropagation:Be,disableClickPropagation:ys,preventDefault:Oe,stop:pn,getPropagationPath:Yi,getMousePosition:An,getWheelDelta:Zs,isExternalTarget:he,addListener:zt,removeListener:le},To=st.extend({run:function(s,a,d,g){this.stop(),this._el=s,this._inProgress=!0,this._duration=d||.25,this._easeOutPower=1/Math.max(g||.5,.2),this._startPos=Si(s),this._offset=a.subtract(this._startPos),this._startTime=+new Date,this.fire("start"),this._animate()},stop:function(){this._inProgress&&(this._step(!0),this._complete())},_animate:function(){this._animId=q(this._animate,this),this._step()},_step:function(s){var a=+new Date-this._startTime,d=this._duration*1e3;a<d?this._runFrame(this._easeOut(a/d),s):(this._runFrame(1),this._complete())},_runFrame:function(s,a){var d=this._startPos.add(this._offset.multiplyBy(s));a&&d._round(),xe(this._el,d),this.fire("step")},_complete:function(){it(this._animId),this._inProgress=!1,this.fire("end")},_easeOut:function(s){return 1-Math.pow(1-s,this._easeOutPower)}}),Zt=st.extend({options:{crs:hi,center:void 0,zoom:void 0,minZoom:void 0,maxZoom:void 0,layers:[],maxBounds:void 0,renderer:void 0,zoomAnimation:!0,zoomAnimationThreshold:4,fadeAnimation:!0,markerZoomAnimation:!0,transform3DLimit:8388608,zoomSnap:1,zoomDelta:1,trackResize:!0},initialize:function(s,a){a=p(this,a),this._handlers=[],this._layers={},this._zoomBoundLayers={},this._sizeChanged=!0,this._initContainer(s),this._initLayout(),this._onResize=l(this._onResize,this),this._initEvents(),a.maxBounds&&this.setMaxBounds(a.maxBounds),a.zoom!==void 0&&(this._zoom=this._limitZoom(a.zoom)),a.center&&a.zoom!==void 0&&this.setView(Et(a.center),a.zoom,{reset:!0}),this.callInitHooks(),this._zoomAnimated=fn&&gt.any3d&&!gt.mobileOpera&&this.options.zoomAnimation,this._zoomAnimated&&(this._createAnimProxy(),zt(this._proxy,Vn,this._catchTransitionEnd,this)),this._addLayers(this.options.layers)},setView:function(s,a,d){if(a=a===void 0?this._zoom:this._limitZoom(a),s=this._limitCenter(Et(s),a,this.options.maxBounds),d=d||{},this._stop(),this._loaded&&!d.reset&&d!==!0){d.animate!==void 0&&(d.zoom=r({animate:d.animate},d.zoom),d.pan=r({animate:d.animate,duration:d.duration},d.pan));var g=this._zoom!==a?this._tryAnimatedZoom&&this._tryAnimatedZoom(s,a,d.zoom):this._tryAnimatedPan(s,d.pan);if(g)return clearTimeout(this._sizeTimer),this}return this._resetView(s,a,d.pan&&d.pan.noMoveStart),this},setZoom:function(s,a){return this._loaded?this.setView(this.getCenter(),s,{zoom:a}):(this._zoom=s,this)},zoomIn:function(s,a){return s=s||(gt.any3d?this.options.zoomDelta:1),this.setZoom(this._zoom+s,a)},zoomOut:function(s,a){return s=s||(gt.any3d?this.options.zoomDelta:1),this.setZoom(this._zoom-s,a)},setZoomAround:function(s,a,d){var g=this.getZoomScale(a),b=this.getSize().divideBy(2),C=s instanceof J?s:this.latLngToContainerPoint(s),D=C.subtract(b).multiplyBy(1-1/g),V=this.containerPointToLatLng(b.add(D));return this.setView(V,a,{zoom:d})},_getBoundsCenterZoom:function(s,a){a=a||{},s=s.getBounds?s.getBounds():Tt(s);var d=et(a.paddingTopLeft||a.padding||[0,0]),g=et(a.paddingBottomRight||a.padding||[0,0]),b=this.getBoundsZoom(s,!1,d.add(g));if(b=typeof a.maxZoom=="number"?Math.min(a.maxZoom,b):b,b===1/0)return{center:s.getCenter(),zoom:b};var C=g.subtract(d).divideBy(2),D=this.project(s.getSouthWest(),b),V=this.project(s.getNorthEast(),b),H=this.unproject(D.add(V).divideBy(2).add(C),b);return{center:H,zoom:b}},fitBounds:function(s,a){if(s=Tt(s),!s.isValid())throw new Error("Bounds are not valid.");var d=this._getBoundsCenterZoom(s,a);return this.setView(d.center,d.zoom,a)},fitWorld:function(s){return this.fitBounds([[-90,-180],[90,180]],s)},panTo:function(s,a){return this.setView(s,this._zoom,{pan:a})},panBy:function(s,a){if(s=et(s).round(),a=a||{},!s.x&&!s.y)return this.fire("moveend");if(a.animate!==!0&&!this.getSize().contains(s))return this._resetView(this.unproject(this.project(this.getCenter()).add(s)),this.getZoom()),this;if(this._panAnim||(this._panAnim=new To,this._panAnim.on({step:this._onPanTransitionStep,end:this._onPanTransitionEnd},this)),a.noMoveStart||this.fire("movestart"),a.animate!==!1){xt(this._mapPane,"leaflet-pan-anim");var d=this._getMapPanePos().subtract(s).round();this._panAnim.run(this._mapPane,d,a.duration||.25,a.easeLinearity)}else this._rawPanBy(s),this.fire("move").fire("moveend");return this},flyTo:function(s,a,d){if(d=d||{},d.animate===!1||!gt.any3d)return this.setView(s,a,d);this._stop();var g=this.project(this.getCenter()),b=this.project(s),C=this.getSize(),D=this._zoom;s=Et(s),a=a===void 0?D:a;var V=Math.max(C.x,C.y),H=V*this.getZoomScale(D,a),rt=b.distanceTo(g)||1,pt=1.42,Nt=pt*pt;function Ut(ze){var Fo=ze?-1:1,Zp=ze?H:V,Up=H*H-V*V+Fo*Nt*Nt*rt*rt,qp=2*Zp*Nt*rt,nl=Up/qp,kh=Math.sqrt(nl*nl+1)-nl,Gp=kh<1e-9?-18:Math.log(kh);return Gp}function cn(ze){return(Math.exp(ze)-Math.exp(-ze))/2}function He(ze){return(Math.exp(ze)+Math.exp(-ze))/2}function zn(ze){return cn(ze)/He(ze)}var vn=Ut(0);function rr(ze){return V*(He(vn)/He(vn+pt*ze))}function Wp(ze){return V*(He(vn)*zn(vn+pt*ze)-cn(vn))/Nt}function Vp(ze){return 1-Math.pow(1-ze,1.5)}var jp=Date.now(),Ch=(Ut(1)-vn)/pt,Hp=d.duration?1e3*d.duration:1e3*Ch*.8;function Mh(){var ze=(Date.now()-jp)/Hp,Fo=Vp(ze)*Ch;ze<=1?(this._flyToFrame=q(Mh,this),this._move(this.unproject(g.add(b.subtract(g).multiplyBy(Wp(Fo)/rt)),D),this.getScaleZoom(V/rr(Fo),D),{flyTo:!0})):this._move(s,a)._moveEnd(!0)}return this._moveStart(!0,d.noMoveStart),Mh.call(this),this},flyToBounds:function(s,a){var d=this._getBoundsCenterZoom(s,a);return this.flyTo(d.center,d.zoom,a)},setMaxBounds:function(s){return s=Tt(s),this.listens("moveend",this._panInsideMaxBounds)&&this.off("moveend",this._panInsideMaxBounds),s.isValid()?(this.options.maxBounds=s,this._loaded&&this._panInsideMaxBounds(),this.on("moveend",this._panInsideMaxBounds)):(this.options.maxBounds=null,this)},setMinZoom:function(s){var a=this.options.minZoom;return this.options.minZoom=s,this._loaded&&a!==s&&(this.fire("zoomlevelschange"),this.getZoom()<this.options.minZoom)?this.setZoom(s):this},setMaxZoom:function(s){var a=this.options.maxZoom;return this.options.maxZoom=s,this._loaded&&a!==s&&(this.fire("zoomlevelschange"),this.getZoom()>this.options.maxZoom)?this.setZoom(s):this},panInsideBounds:function(s,a){this._enforcingBounds=!0;var d=this.getCenter(),g=this._limitCenter(d,this._zoom,Tt(s));return d.equals(g)||this.panTo(g,a),this._enforcingBounds=!1,this},panInside:function(s,a){a=a||{};var d=et(a.paddingTopLeft||a.padding||[0,0]),g=et(a.paddingBottomRight||a.padding||[0,0]),b=this.project(this.getCenter()),C=this.project(s),D=this.getPixelBounds(),V=kt([D.min.add(d),D.max.subtract(g)]),H=V.getSize();if(!V.contains(C)){this._enforcingBounds=!0;var rt=C.subtract(V.getCenter()),pt=V.extend(C).getSize().subtract(H);b.x+=rt.x<0?-pt.x:pt.x,b.y+=rt.y<0?-pt.y:pt.y,this.panTo(this.unproject(b),a),this._enforcingBounds=!1}return this},invalidateSize:function(s){if(!this._loaded)return this;s=r({animate:!1,pan:!0},s===!0?{animate:!0}:s);var a=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var d=this.getSize(),g=a.divideBy(2).round(),b=d.divideBy(2).round(),C=g.subtract(b);return!C.x&&!C.y?this:(s.animate&&s.pan?this.panBy(C):(s.pan&&this._rawPanBy(C),this.fire("move"),s.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(l(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:a,newSize:d}))},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire("viewreset"),this._stop()},locate:function(s){if(s=this._locateOptions=r({timeout:1e4,watch:!1},s),!("geolocation"in navigator))return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var a=l(this._handleGeolocationResponse,this),d=l(this._handleGeolocationError,this);return s.watch?this._locationWatchId=navigator.geolocation.watchPosition(a,d,s):navigator.geolocation.getCurrentPosition(a,d,s),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(s){if(this._container._leaflet_id){var a=s.code,d=s.message||(a===1?"permission denied":a===2?"position unavailable":"timeout");this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:a,message:"Geolocation error: "+d+"."})}},_handleGeolocationResponse:function(s){if(this._container._leaflet_id){var a=s.coords.latitude,d=s.coords.longitude,g=new Rt(a,d),b=g.toBounds(s.coords.accuracy*2),C=this._locateOptions;if(C.setView){var D=this.getBoundsZoom(b);this.setView(g,C.maxZoom?Math.min(D,C.maxZoom):D)}var V={latlng:g,bounds:b,timestamp:s.timestamp};for(var H in s.coords)typeof s.coords[H]=="number"&&(V[H]=s.coords[H]);this.fire("locationfound",V)}},addHandler:function(s,a){if(!a)return this;var d=this[s]=new a(this);return this._handlers.push(d),this.options[s]&&d.enable(),this},remove:function(){if(this._initEvents(!0),this.options.maxBounds&&this.off("moveend",this._panInsideMaxBounds),this._containerId!==this._container._leaflet_id)throw new Error("Map container is being reused by another instance");try{delete this._container._leaflet_id,delete this._containerId}catch{this._container._leaflet_id=void 0,this._containerId=void 0}this._locationWatchId!==void 0&&this.stopLocate(),this._stop(),Qt(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&(it(this._resizeRequest),this._resizeRequest=null),this._clearHandlers(),this._loaded&&this.fire("unload");var s;for(s in this._layers)this._layers[s].remove();for(s in this._panes)Qt(this._panes[s]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(s,a){var d="leaflet-pane"+(s?" leaflet-"+s.replace("Pane","")+"-pane":""),g=Ct("div",d,a||this._mapPane);return s&&(this._panes[s]=g),g},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter.clone():this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var s=this.getPixelBounds(),a=this.unproject(s.getBottomLeft()),d=this.unproject(s.getTopRight());return new St(a,d)},getMinZoom:function(){return this.options.minZoom===void 0?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return this.options.maxZoom===void 0?this._layersMaxZoom===void 0?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(s,a,d){s=Tt(s),d=et(d||[0,0]);var g=this.getZoom()||0,b=this.getMinZoom(),C=this.getMaxZoom(),D=s.getNorthWest(),V=s.getSouthEast(),H=this.getSize().subtract(d),rt=kt(this.project(V,g),this.project(D,g)).getSize(),pt=gt.any3d?this.options.zoomSnap:1,Nt=H.x/rt.x,Ut=H.y/rt.y,cn=a?Math.max(Nt,Ut):Math.min(Nt,Ut);return g=this.getScaleZoom(cn,g),pt&&(g=Math.round(g/(pt/100))*(pt/100),g=a?Math.ceil(g/pt)*pt:Math.floor(g/pt)*pt),Math.max(b,Math.min(C,g))},getSize:function(){return(!this._size||this._sizeChanged)&&(this._size=new J(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(s,a){var d=this._getTopLeftPoint(s,a);return new ht(d,d.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(s){return this.options.crs.getProjectedBounds(s===void 0?this.getZoom():s)},getPane:function(s){return typeof s=="string"?this._panes[s]:s},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(s,a){var d=this.options.crs;return a=a===void 0?this._zoom:a,d.scale(s)/d.scale(a)},getScaleZoom:function(s,a){var d=this.options.crs;a=a===void 0?this._zoom:a;var g=d.zoom(s*d.scale(a));return isNaN(g)?1/0:g},project:function(s,a){return a=a===void 0?this._zoom:a,this.options.crs.latLngToPoint(Et(s),a)},unproject:function(s,a){return a=a===void 0?this._zoom:a,this.options.crs.pointToLatLng(et(s),a)},layerPointToLatLng:function(s){var a=et(s).add(this.getPixelOrigin());return this.unproject(a)},latLngToLayerPoint:function(s){var a=this.project(Et(s))._round();return a._subtract(this.getPixelOrigin())},wrapLatLng:function(s){return this.options.crs.wrapLatLng(Et(s))},wrapLatLngBounds:function(s){return this.options.crs.wrapLatLngBounds(Tt(s))},distance:function(s,a){return this.options.crs.distance(Et(s),Et(a))},containerPointToLayerPoint:function(s){return et(s).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(s){return et(s).add(this._getMapPanePos())},containerPointToLatLng:function(s){var a=this.containerPointToLayerPoint(et(s));return this.layerPointToLatLng(a)},latLngToContainerPoint:function(s){return this.layerPointToContainerPoint(this.latLngToLayerPoint(Et(s)))},mouseEventToContainerPoint:function(s){return An(s,this._container)},mouseEventToLayerPoint:function(s){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(s))},mouseEventToLatLng:function(s){return this.layerPointToLatLng(this.mouseEventToLayerPoint(s))},_initContainer:function(s){var a=this._container=rn(s);if(a){if(a._leaflet_id)throw new Error("Map container is already initialized.")}else throw new Error("Map container not found.");zt(a,"scroll",this._onScroll,this),this._containerId=u(a)},_initLayout:function(){var s=this._container;this._fadeAnimated=this.options.fadeAnimation&&gt.any3d,xt(s,"leaflet-container"+(gt.touch?" leaflet-touch":"")+(gt.retina?" leaflet-retina":"")+(gt.ielt9?" leaflet-oldie":"")+(gt.safari?" leaflet-safari":"")+(this._fadeAnimated?" leaflet-fade-anim":""));var a=be(s,"position");a!=="absolute"&&a!=="relative"&&a!=="fixed"&&a!=="sticky"&&(s.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var s=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),xe(this._mapPane,new J(0,0)),this.createPane("tilePane"),this.createPane("overlayPane"),this.createPane("shadowPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),this.options.markerZoomAnimation||(xt(s.markerPane,"leaflet-zoom-hide"),xt(s.shadowPane,"leaflet-zoom-hide"))},_resetView:function(s,a,d){xe(this._mapPane,new J(0,0));var g=!this._loaded;this._loaded=!0,a=this._limitZoom(a),this.fire("viewprereset");var b=this._zoom!==a;this._moveStart(b,d)._move(s,a)._moveEnd(b),this.fire("viewreset"),g&&this.fire("load")},_moveStart:function(s,a){return s&&this.fire("zoomstart"),a||this.fire("movestart"),this},_move:function(s,a,d,g){a===void 0&&(a=this._zoom);var b=this._zoom!==a;return this._zoom=a,this._lastCenter=s,this._pixelOrigin=this._getNewPixelOrigin(s),g?d&&d.pinch&&this.fire("zoom",d):((b||d&&d.pinch)&&this.fire("zoom",d),this.fire("move",d)),this},_moveEnd:function(s){return s&&this.fire("zoomend"),this.fire("moveend")},_stop:function(){return it(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(s){xe(this._mapPane,this._getMapPanePos().subtract(s))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw new Error("Set map center and zoom first.")},_initEvents:function(s){this._targets={},this._targets[u(this._container)]=this;var a=s?le:zt;a(this._container,"click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup",this._handleDOMEvent,this),this.options.trackResize&&a(window,"resize",this._onResize,this),gt.any3d&&this.options.transform3DLimit&&(s?this.off:this.on).call(this,"moveend",this._onMoveEnd)},_onResize:function(){it(this._resizeRequest),this._resizeRequest=q(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var s=this._getMapPanePos();Math.max(Math.abs(s.x),Math.abs(s.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(s,a){for(var d=[],g,b=a==="mouseout"||a==="mouseover",C=s.target||s.srcElement,D=!1;C;){if(g=this._targets[u(C)],g&&(a==="click"||a==="preclick")&&this._draggableMoved(g)){D=!0;break}if(g&&g.listens(a,!0)&&(b&&!he(C,s)||(d.push(g),b))||C===this._container)break;C=C.parentNode}return!d.length&&!D&&!b&&this.listens(a,!0)&&(d=[this]),d},_isClickDisabled:function(s){for(;s&&s!==this._container;){if(s._leaflet_disable_click)return!0;s=s.parentNode}},_handleDOMEvent:function(s){var a=s.target||s.srcElement;if(!(!this._loaded||a._leaflet_disable_events||s.type==="click"&&this._isClickDisabled(a))){var d=s.type;d==="mousedown"&&En(a),this._fireDOMEvent(s,d)}},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(s,a,d){if(s.type==="click"){var g=r({},s);g.type="preclick",this._fireDOMEvent(g,g.type,d)}var b=this._findEventTargets(s,a);if(d){for(var C=[],D=0;D<d.length;D++)d[D].listens(a,!0)&&C.push(d[D]);b=C.concat(b)}if(b.length){a==="contextmenu"&&Oe(s);var V=b[0],H={originalEvent:s};if(s.type!=="keypress"&&s.type!=="keydown"&&s.type!=="keyup"){var rt=V.getLatLng&&(!V._radius||V._radius<=10);H.containerPoint=rt?this.latLngToContainerPoint(V.getLatLng()):this.mouseEventToContainerPoint(s),H.layerPoint=this.containerPointToLayerPoint(H.containerPoint),H.latlng=rt?V.getLatLng():this.layerPointToLatLng(H.layerPoint)}for(D=0;D<b.length;D++)if(b[D].fire(a,H,!0),H.originalEvent._stopped||b[D].options.bubblingMouseEvents===!1&&P(this._mouseEvents,a)!==-1)return}},_draggableMoved:function(s){return s=s.dragging&&s.dragging.enabled()?s:this,s.dragging&&s.dragging.moved()||this.boxZoom&&this.boxZoom.moved()},_clearHandlers:function(){for(var s=0,a=this._handlers.length;s<a;s++)this._handlers[s].disable()},whenReady:function(s,a){return this._loaded?s.call(a||this,{target:this}):this.on("load",s,a),this},_getMapPanePos:function(){return Si(this._mapPane)||new J(0,0)},_moved:function(){var s=this._getMapPanePos();return s&&!s.equals([0,0])},_getTopLeftPoint:function(s,a){var d=s&&a!==void 0?this._getNewPixelOrigin(s,a):this.getPixelOrigin();return d.subtract(this._getMapPanePos())},_getNewPixelOrigin:function(s,a){var d=this.getSize()._divideBy(2);return this.project(s,a)._subtract(d)._add(this._getMapPanePos())._round()},_latLngToNewLayerPoint:function(s,a,d){var g=this._getNewPixelOrigin(d,a);return this.project(s,a)._subtract(g)},_latLngBoundsToNewLayerBounds:function(s,a,d){var g=this._getNewPixelOrigin(d,a);return kt([this.project(s.getSouthWest(),a)._subtract(g),this.project(s.getNorthWest(),a)._subtract(g),this.project(s.getSouthEast(),a)._subtract(g),this.project(s.getNorthEast(),a)._subtract(g)])},_getCenterLayerPoint:function(){return this.containerPointToLayerPoint(this.getSize()._divideBy(2))},_getCenterOffset:function(s){return this.latLngToLayerPoint(s).subtract(this._getCenterLayerPoint())},_limitCenter:function(s,a,d){if(!d)return s;var g=this.project(s,a),b=this.getSize().divideBy(2),C=new ht(g.subtract(b),g.add(b)),D=this._getBoundsOffset(C,d,a);return Math.abs(D.x)<=1&&Math.abs(D.y)<=1?s:this.unproject(g.add(D),a)},_limitOffset:function(s,a){if(!a)return s;var d=this.getPixelBounds(),g=new ht(d.min.add(s),d.max.add(s));return s.add(this._getBoundsOffset(g,a))},_getBoundsOffset:function(s,a,d){var g=kt(this.project(a.getNorthEast(),d),this.project(a.getSouthWest(),d)),b=g.min.subtract(s.min),C=g.max.subtract(s.max),D=this._rebound(b.x,-C.x),V=this._rebound(b.y,-C.y);return new J(D,V)},_rebound:function(s,a){return s+a>0?Math.round(s-a)/2:Math.max(0,Math.ceil(s))-Math.max(0,Math.floor(a))},_limitZoom:function(s){var a=this.getMinZoom(),d=this.getMaxZoom(),g=gt.any3d?this.options.zoomSnap:1;return g&&(s=Math.round(s/g)*g),Math.max(a,Math.min(d,s))},_onPanTransitionStep:function(){this.fire("move")},_onPanTransitionEnd:function(){Bt(this._mapPane,"leaflet-pan-anim"),this.fire("moveend")},_tryAnimatedPan:function(s,a){var d=this._getCenterOffset(s)._trunc();return(a&&a.animate)!==!0&&!this.getSize().contains(d)?!1:(this.panBy(d,a),!0)},_createAnimProxy:function(){var s=this._proxy=Ct("div","leaflet-proxy leaflet-zoom-animated");this._panes.mapPane.appendChild(s),this.on("zoomanim",function(a){var d=Wn,g=this._proxy.style[d];wi(this._proxy,this.project(a.center,a.zoom),this.getZoomScale(a.zoom,1)),g===this._proxy.style[d]&&this._animatingZoom&&this._onZoomTransitionEnd()},this),this.on("load moveend",this._animMoveEnd,this),this._on("unload",this._destroyAnimProxy,this)},_destroyAnimProxy:function(){Qt(this._proxy),this.off("load moveend",this._animMoveEnd,this),delete this._proxy},_animMoveEnd:function(){var s=this.getCenter(),a=this.getZoom();wi(this._proxy,this.project(s,a),this.getZoomScale(a,1))},_catchTransitionEnd:function(s){this._animatingZoom&&s.propertyName.indexOf("transform")>=0&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName("leaflet-zoom-animated").length},_tryAnimatedZoom:function(s,a,d){if(this._animatingZoom)return!0;if(d=d||{},!this._zoomAnimated||d.animate===!1||this._nothingToAnimate()||Math.abs(a-this._zoom)>this.options.zoomAnimationThreshold)return!1;var g=this.getZoomScale(a),b=this._getCenterOffset(s)._divideBy(1-1/g);return d.animate!==!0&&!this.getSize().contains(b)?!1:(q(function(){this._moveStart(!0,d.noMoveStart||!1)._animateZoom(s,a,!0)},this),!0)},_animateZoom:function(s,a,d,g){this._mapPane&&(d&&(this._animatingZoom=!0,this._animateToCenter=s,this._animateToZoom=a,xt(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:s,zoom:a,noUpdate:g}),this._tempFireZoomEvent||(this._tempFireZoomEvent=this._zoom!==this._animateToZoom),this._move(this._animateToCenter,this._animateToZoom,void 0,!0),setTimeout(l(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&Bt(this._mapPane,"leaflet-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._tempFireZoomEvent&&this.fire("zoom"),delete this._tempFireZoomEvent,this.fire("move"),this._moveEnd(!0))}});function Po(s,a){return new Zt(s,a)}var Fe=K.extend({options:{position:"topright"},initialize:function(s){p(this,s)},getPosition:function(){return this.options.position},setPosition:function(s){var a=this._map;return a&&a.removeControl(this),this.options.position=s,a&&a.addControl(this),this},getContainer:function(){return this._container},addTo:function(s){this.remove(),this._map=s;var a=this._container=this.onAdd(s),d=this.getPosition(),g=s._controlCorners[d];return xt(a,"leaflet-control"),d.indexOf("bottom")!==-1?g.insertBefore(a,g.firstChild):g.appendChild(a),this._map.on("unload",this.remove,this),this},remove:function(){return this._map?(Qt(this._container),this.onRemove&&this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null,this):this},_refocusOnMap:function(s){this._map&&s&&s.screenX>0&&s.screenY>0&&this._map.getContainer().focus()}}),_e=function(s){return new Fe(s)};Zt.include({addControl:function(s){return s.addTo(this),this},removeControl:function(s){return s.remove(),this},_initControlPos:function(){var s=this._controlCorners={},a="leaflet-",d=this._controlContainer=Ct("div",a+"control-container",this._container);function g(b,C){var D=a+b+" "+a+C;s[b+C]=Ct("div",D,d)}g("top","left"),g("top","right"),g("bottom","left"),g("bottom","right")},_clearControlPos:function(){for(var s in this._controlCorners)Qt(this._controlCorners[s]);Qt(this._controlContainer),delete this._controlCorners,delete this._controlContainer}});var Zn=Fe.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction:function(s,a,d,g){return d<g?-1:g<d?1:0}},initialize:function(s,a,d){p(this,d),this._layerControlInputs=[],this._layers=[],this._lastZIndex=0,this._handlingClick=!1,this._preventClick=!1;for(var g in s)this._addLayer(s[g],g);for(g in a)this._addLayer(a[g],g,!0)},onAdd:function(s){this._initLayout(),this._update(),this._map=s,s.on("zoomend",this._checkDisabledLayers,this);for(var a=0;a<this._layers.length;a++)this._layers[a].layer.on("add remove",this._onLayerChange,this);return this._container},addTo:function(s){return Fe.prototype.addTo.call(this,s),this._expandIfNotCollapsed()},onRemove:function(){this._map.off("zoomend",this._checkDisabledLayers,this);for(var s=0;s<this._layers.length;s++)this._layers[s].layer.off("add remove",this._onLayerChange,this)},addBaseLayer:function(s,a){return this._addLayer(s,a),this._map?this._update():this},addOverlay:function(s,a){return this._addLayer(s,a,!0),this._map?this._update():this},removeLayer:function(s){s.off("add remove",this._onLayerChange,this);var a=this._getLayer(u(s));return a&&this._layers.splice(this._layers.indexOf(a),1),this._map?this._update():this},expand:function(){xt(this._container,"leaflet-control-layers-expanded"),this._section.style.height=null;var s=this._map.getSize().y-(this._container.offsetTop+50);return s<this._section.clientHeight?(xt(this._section,"leaflet-control-layers-scrollbar"),this._section.style.height=s+"px"):Bt(this._section,"leaflet-control-layers-scrollbar"),this._checkDisabledLayers(),this},collapse:function(){return Bt(this._container,"leaflet-control-layers-expanded"),this},_initLayout:function(){var s="leaflet-control-layers",a=this._container=Ct("div",s),d=this.options.collapsed;a.setAttribute("aria-haspopup",!0),ys(a),Be(a);var g=this._section=Ct("section",s+"-list");d&&(this._map.on("click",this.collapse,this),zt(a,{mouseenter:this._expandSafely,mouseleave:this.collapse},this));var b=this._layersLink=Ct("a",s+"-toggle",a);b.href="#",b.title="Layers",b.setAttribute("role","button"),zt(b,{keydown:function(C){C.keyCode===13&&this._expandSafely()},click:function(C){Oe(C),this._expandSafely()}},this),d||this.expand(),this._baseLayersList=Ct("div",s+"-base",g),this._separator=Ct("div",s+"-separator",g),this._overlaysList=Ct("div",s+"-overlays",g),a.appendChild(g)},_getLayer:function(s){for(var a=0;a<this._layers.length;a++)if(this._layers[a]&&u(this._layers[a].layer)===s)return this._layers[a]},_addLayer:function(s,a,d){this._map&&s.on("add remove",this._onLayerChange,this),this._layers.push({layer:s,name:a,overlay:d}),this.options.sortLayers&&this._layers.sort(l(function(g,b){return this.options.sortFunction(g.layer,b.layer,g.name,b.name)},this)),this.options.autoZIndex&&s.setZIndex&&(this._lastZIndex++,s.setZIndex(this._lastZIndex)),this._expandIfNotCollapsed()},_update:function(){if(!this._container)return this;ae(this._baseLayersList),ae(this._overlaysList),this._layerControlInputs=[];var s,a,d,g,b=0;for(d=0;d<this._layers.length;d++)g=this._layers[d],this._addItem(g),a=a||g.overlay,s=s||!g.overlay,b+=g.overlay?0:1;return this.options.hideSingleBase&&(s=s&&b>1,this._baseLayersList.style.display=s?"":"none"),this._separator.style.display=a&&s?"":"none",this},_onLayerChange:function(s){this._handlingClick||this._update();var a=this._getLayer(u(s.target)),d=a.overlay?s.type==="add"?"overlayadd":"overlayremove":s.type==="add"?"baselayerchange":null;d&&this._map.fire(d,a)},_createRadioElement:function(s,a){var d='<input type="radio" class="leaflet-control-layers-selector" name="'+s+'"'+(a?' checked="checked"':"")+"/>",g=document.createElement("div");return g.innerHTML=d,g.firstChild},_addItem:function(s){var a=document.createElement("label"),d=this._map.hasLayer(s.layer),g;s.overlay?(g=document.createElement("input"),g.type="checkbox",g.className="leaflet-control-layers-selector",g.defaultChecked=d):g=this._createRadioElement("leaflet-base-layers_"+u(this),d),this._layerControlInputs.push(g),g.layerId=u(s.layer),zt(g,"click",this._onInputClick,this);var b=document.createElement("span");b.innerHTML=" "+s.name;var C=document.createElement("span");a.appendChild(C),C.appendChild(g),C.appendChild(b);var D=s.overlay?this._overlaysList:this._baseLayersList;return D.appendChild(a),this._checkDisabledLayers(),a},_onInputClick:function(){if(!this._preventClick){var s=this._layerControlInputs,a,d,g=[],b=[];this._handlingClick=!0;for(var C=s.length-1;C>=0;C--)a=s[C],d=this._getLayer(a.layerId).layer,a.checked?g.push(d):a.checked||b.push(d);for(C=0;C<b.length;C++)this._map.hasLayer(b[C])&&this._map.removeLayer(b[C]);for(C=0;C<g.length;C++)this._map.hasLayer(g[C])||this._map.addLayer(g[C]);this._handlingClick=!1,this._refocusOnMap()}},_checkDisabledLayers:function(){for(var s=this._layerControlInputs,a,d,g=this._map.getZoom(),b=s.length-1;b>=0;b--)a=s[b],d=this._getLayer(a.layerId).layer,a.disabled=d.options.minZoom!==void 0&&g<d.options.minZoom||d.options.maxZoom!==void 0&&g>d.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expandSafely:function(){var s=this._section;this._preventClick=!0,zt(s,"click",Oe),this.expand();var a=this;setTimeout(function(){le(s,"click",Oe),a._preventClick=!1})}}),zr=function(s,a,d){return new Zn(s,a,d)},Us=Fe.extend({options:{position:"topleft",zoomInText:'<span aria-hidden="true">+</span>',zoomInTitle:"Zoom in",zoomOutText:'<span aria-hidden="true">&#x2212;</span>',zoomOutTitle:"Zoom out"},onAdd:function(s){var a="leaflet-control-zoom",d=Ct("div",a+" leaflet-bar"),g=this.options;return this._zoomInButton=this._createButton(g.zoomInText,g.zoomInTitle,a+"-in",d,this._zoomIn),this._zoomOutButton=this._createButton(g.zoomOutText,g.zoomOutTitle,a+"-out",d,this._zoomOut),this._updateDisabled(),s.on("zoomend zoomlevelschange",this._updateDisabled,this),d},onRemove:function(s){s.off("zoomend zoomlevelschange",this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(s){!this._disabled&&this._map._zoom<this._map.getMaxZoom()&&this._map.zoomIn(this._map.options.zoomDelta*(s.shiftKey?3:1))},_zoomOut:function(s){!this._disabled&&this._map._zoom>this._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(s.shiftKey?3:1))},_createButton:function(s,a,d,g,b){var C=Ct("a",d,g);return C.innerHTML=s,C.href="#",C.title=a,C.setAttribute("role","button"),C.setAttribute("aria-label",a),ys(C),zt(C,"click",pn),zt(C,"click",b,this),zt(C,"click",this._refocusOnMap,this),C},_updateDisabled:function(){var s=this._map,a="leaflet-disabled";Bt(this._zoomInButton,a),Bt(this._zoomOutButton,a),this._zoomInButton.setAttribute("aria-disabled","false"),this._zoomOutButton.setAttribute("aria-disabled","false"),(this._disabled||s._zoom===s.getMinZoom())&&(xt(this._zoomOutButton,a),this._zoomOutButton.setAttribute("aria-disabled","true")),(this._disabled||s._zoom===s.getMaxZoom())&&(xt(this._zoomInButton,a),this._zoomInButton.setAttribute("aria-disabled","true"))}});Zt.mergeOptions({zoomControl:!0}),Zt.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new Us,this.addControl(this.zoomControl))});var Eo=function(s){return new Us(s)},Lo=Fe.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(s){var a="leaflet-control-scale",d=Ct("div",a),g=this.options;return this._addScales(g,a+"-line",d),s.on(g.updateWhenIdle?"moveend":"move",this._update,this),s.whenReady(this._update,this),d},onRemove:function(s){s.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(s,a,d){s.metric&&(this._mScale=Ct("div",a,d)),s.imperial&&(this._iScale=Ct("div",a,d))},_update:function(){var s=this._map,a=s.getSize().y/2,d=s.distance(s.containerPointToLatLng([0,a]),s.containerPointToLatLng([this.options.maxWidth,a]));this._updateScales(d)},_updateScales:function(s){this.options.metric&&s&&this._updateMetric(s),this.options.imperial&&s&&this._updateImperial(s)},_updateMetric:function(s){var a=this._getRoundNum(s),d=a<1e3?a+" m":a/1e3+" km";this._updateScale(this._mScale,d,a/s)},_updateImperial:function(s){var a=s*3.2808399,d,g,b;a>5280?(d=a/5280,g=this._getRoundNum(d),this._updateScale(this._iScale,g+" mi",g/d)):(b=this._getRoundNum(a),this._updateScale(this._iScale,b+" ft",b/a))},_updateScale:function(s,a,d){s.style.width=Math.round(this.options.maxWidth*d)+"px",s.innerHTML=a},_getRoundNum:function(s){var a=Math.pow(10,(Math.floor(s)+"").length-1),d=s/a;return d=d>=10?10:d>=5?5:d>=3?3:d>=2?2:1,a*d}}),Ao=function(s){return new Lo(s)},Dr='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="12" height="8" viewBox="0 0 12 8" class="leaflet-attribution-flag"><path fill="#4C7BE1" d="M0 0h12v4H0z"/><path fill="#FFD500" d="M0 4h12v3H0z"/><path fill="#E0BC00" d="M0 7h12v1H0z"/></svg>',Ji=Fe.extend({options:{position:"bottomright",prefix:'<a href="https://leafletjs.com" title="A JavaScript library for interactive maps">'+(gt.inlineSvg?Dr+" ":"")+"Leaflet</a>"},initialize:function(s){p(this,s),this._attributions={}},onAdd:function(s){s.attributionControl=this,this._container=Ct("div","leaflet-control-attribution"),ys(this._container);for(var a in s._layers)s._layers[a].getAttribution&&this.addAttribution(s._layers[a].getAttribution());return this._update(),s.on("layeradd",this._addAttribution,this),this._container},onRemove:function(s){s.off("layeradd",this._addAttribution,this)},_addAttribution:function(s){s.layer.getAttribution&&(this.addAttribution(s.layer.getAttribution()),s.layer.once("remove",function(){this.removeAttribution(s.layer.getAttribution())},this))},setPrefix:function(s){return this.options.prefix=s,this._update(),this},addAttribution:function(s){return s?(this._attributions[s]||(this._attributions[s]=0),this._attributions[s]++,this._update(),this):this},removeAttribution:function(s){return s?(this._attributions[s]&&(this._attributions[s]--,this._update()),this):this},_update:function(){if(this._map){var s=[];for(var a in this._attributions)this._attributions[a]&&s.push(a);var d=[];this.options.prefix&&d.push(this.options.prefix),s.length&&d.push(s.join(", ")),this._container.innerHTML=d.join(' <span aria-hidden="true">|</span> ')}}});Zt.mergeOptions({attributionControl:!0}),Zt.addInitHook(function(){this.options.attributionControl&&new Ji().addTo(this)});var Ro=function(s){return new Ji(s)};Fe.Layers=Zn,Fe.Zoom=Us,Fe.Scale=Lo,Fe.Attribution=Ji,_e.layers=zr,_e.zoom=Eo,_e.scale=Ao,_e.attribution=Ro;var Rn=K.extend({initialize:function(s){this._map=s},enable:function(){return this._enabled?this:(this._enabled=!0,this.addHooks(),this)},disable:function(){return this._enabled?(this._enabled=!1,this.removeHooks(),this):this},enabled:function(){return!!this._enabled}});Rn.addTo=function(s,a){return s.addHandler(a,this),this};var Ga={Events:tt},No=gt.touch?"touchstart mousedown":"mousedown",ei=st.extend({options:{clickTolerance:3},initialize:function(s,a,d,g){p(this,g),this._element=s,this._dragStartTarget=a||s,this._preventOutline=d},enable:function(){this._enabled||(zt(this._dragStartTarget,No,this._onDown,this),this._enabled=!0)},disable:function(){this._enabled&&(ei._dragging===this&&this.finishDrag(!0),le(this._dragStartTarget,No,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(s){if(this._enabled&&(this._moved=!1,!ie(this._element,"leaflet-zoom-anim"))){if(s.touches&&s.touches.length!==1){ei._dragging===this&&this.finishDrag();return}if(!(ei._dragging||s.shiftKey||s.which!==1&&s.button!==1&&!s.touches)&&(ei._dragging=this,this._preventOutline&&En(this._element),Hn(),tn(),!this._moving)){this.fire("down");var a=s.touches?s.touches[0]:s,d=Gi(this._element);this._startPoint=new J(a.clientX,a.clientY),this._startPos=Si(this._element),this._parentScale=Ve(d);var g=s.type==="mousedown";zt(document,g?"mousemove":"touchmove",this._onMove,this),zt(document,g?"mouseup":"touchend touchcancel",this._onUp,this)}}},_onMove:function(s){if(this._enabled){if(s.touches&&s.touches.length>1){this._moved=!0;return}var a=s.touches&&s.touches.length===1?s.touches[0]:s,d=new J(a.clientX,a.clientY)._subtract(this._startPoint);!d.x&&!d.y||Math.abs(d.x)+Math.abs(d.y)<this.options.clickTolerance||(d.x/=this._parentScale.x,d.y/=this._parentScale.y,Oe(s),this._moved||(this.fire("dragstart"),this._moved=!0,xt(document.body,"leaflet-dragging"),this._lastTarget=s.target||s.srcElement,window.SVGElementInstance&&this._lastTarget instanceof window.SVGElementInstance&&(this._lastTarget=this._lastTarget.correspondingUseElement),xt(this._lastTarget,"leaflet-drag-target")),this._newPos=this._startPos.add(d),this._moving=!0,this._lastEvent=s,this._updatePosition())}},_updatePosition:function(){var s={originalEvent:this._lastEvent};this.fire("predrag",s),xe(this._element,this._newPos),this.fire("drag",s)},_onUp:function(){this._enabled&&this.finishDrag()},finishDrag:function(s){Bt(document.body,"leaflet-dragging"),this._lastTarget&&(Bt(this._lastTarget,"leaflet-drag-target"),this._lastTarget=null),le(document,"mousemove touchmove",this._onMove,this),le(document,"mouseup touchend touchcancel",this._onUp,this),ps(),se();var a=this._moved&&this._moving;this._moving=!1,ei._dragging=!1,a&&this.fire("dragend",{noInertia:s,distance:this._newPos.distanceTo(this._startPos)})}});function $r(s,a,d){var g,b=[1,4,2,8],C,D,V,H,rt,pt,Nt,Ut;for(C=0,pt=s.length;C<pt;C++)s[C]._code=qn(s[C],a);for(V=0;V<4;V++){for(Nt=b[V],g=[],C=0,pt=s.length,D=pt-1;C<pt;D=C++)H=s[C],rt=s[D],H._code&Nt?rt._code&Nt||(Ut=Un(rt,H,Nt,a,d),Ut._code=qn(Ut,a),g.push(Ut)):(rt._code&Nt&&(Ut=Un(rt,H,Nt,a,d),Ut._code=qn(Ut,a),g.push(Ut)),g.push(H));s=g}return s}function Io(s,a){var d,g,b,C,D,V,H,rt,pt;if(!s||s.length===0)throw new Error("latlngs not passed");an(s)||(console.warn("latlngs are not flat! Only the first ring will be used"),s=s[0]);var Nt=Et([0,0]),Ut=Tt(s),cn=Ut.getNorthWest().distanceTo(Ut.getSouthWest())*Ut.getNorthEast().distanceTo(Ut.getNorthWest());cn<1700&&(Nt=on(s));var He=s.length,zn=[];for(d=0;d<He;d++){var vn=Et(s[d]);zn.push(a.project(Et([vn.lat-Nt.lat,vn.lng-Nt.lng])))}for(V=H=rt=0,d=0,g=He-1;d<He;g=d++)b=zn[d],C=zn[g],D=b.y*C.x-C.y*b.x,H+=(b.x+C.x)*D,rt+=(b.y+C.y)*D,V+=D*3;V===0?pt=zn[0]:pt=[H/V,rt/V];var rr=a.unproject(et(pt));return Et([rr.lat+Nt.lat,rr.lng+Nt.lng])}function on(s){for(var a=0,d=0,g=0,b=0;b<s.length;b++){var C=Et(s[b]);a+=C.lat,d+=C.lng,g++}return Et([a/g,d/g])}var gn={__proto__:null,clipPolygon:$r,polygonCenter:Io,centroid:on};function zo(s,a){if(!a||!s.length)return s.slice();var d=a*a;return s=Do(s,d),s=Or(s,d),s}function vs(s,a,d){return Math.sqrt(Nn(s,a,d,!0))}function Br(s,a,d){return Nn(s,a,d)}function Or(s,a){var d=s.length,g=typeof Uint8Array<"u"?Uint8Array:Array,b=new g(d);b[0]=b[d-1]=1,qs(s,b,a,0,d-1);var C,D=[];for(C=0;C<d;C++)b[C]&&D.push(s[C]);return D}function qs(s,a,d,g,b){var C=0,D,V,H;for(V=g+1;V<=b-1;V++)H=Nn(s[V],s[g],s[b],!0),H>C&&(D=V,C=H);C>d&&(a[D]=1,qs(s,a,d,g,D),qs(s,a,d,D,b))}function Do(s,a){for(var d=[s[0]],g=1,b=0,C=s.length;g<C;g++)$o(s[g],s[b])>a&&(d.push(s[g]),b=g);return b<C-1&&d.push(s[C-1]),d}var Gs;function Ys(s,a,d,g,b){var C=g?Gs:qn(s,d),D=qn(a,d),V,H,rt;for(Gs=D;;){if(!(C|D))return[s,a];if(C&D)return!1;V=C||D,H=Un(s,a,V,d,b),rt=qn(H,d),V===C?(s=H,C=rt):(a=H,D=rt)}}function Un(s,a,d,g,b){var C=a.x-s.x,D=a.y-s.y,V=g.min,H=g.max,rt,pt;return d&8?(rt=s.x+C*(H.y-s.y)/D,pt=H.y):d&4?(rt=s.x+C*(V.y-s.y)/D,pt=V.y):d&2?(rt=H.x,pt=s.y+D*(H.x-s.x)/C):d&1&&(rt=V.x,pt=s.y+D*(V.x-s.x)/C),new J(rt,pt,b)}function qn(s,a){var d=0;return s.x<a.min.x?d|=1:s.x>a.max.x&&(d|=2),s.y<a.min.y?d|=4:s.y>a.max.y&&(d|=8),d}function $o(s,a){var d=a.x-s.x,g=a.y-s.y;return d*d+g*g}function Nn(s,a,d,g){var b=a.x,C=a.y,D=d.x-b,V=d.y-C,H=D*D+V*V,rt;return H>0&&(rt=((s.x-b)*D+(s.y-C)*V)/H,rt>1?(b=d.x,C=d.y):rt>0&&(b+=D*rt,C+=V*rt)),D=s.x-b,V=s.y-C,g?D*D+V*V:new J(b,C)}function an(s){return!A(s[0])||typeof s[0][0]!="object"&&typeof s[0][0]<"u"}function bs(s){return console.warn("Deprecated use of _flat, please use L.LineUtil.isFlat instead."),an(s)}function Gt(s,a){var d,g,b,C,D,V,H,rt;if(!s||s.length===0)throw new Error("latlngs not passed");an(s)||(console.warn("latlngs are not flat! Only the first ring will be used"),s=s[0]);var pt=Et([0,0]),Nt=Tt(s),Ut=Nt.getNorthWest().distanceTo(Nt.getSouthWest())*Nt.getNorthEast().distanceTo(Nt.getNorthWest());Ut<1700&&(pt=on(s));var cn=s.length,He=[];for(d=0;d<cn;d++){var zn=Et(s[d]);He.push(a.project(Et([zn.lat-pt.lat,zn.lng-pt.lng])))}for(d=0,g=0;d<cn-1;d++)g+=He[d].distanceTo(He[d+1])/2;if(g===0)rt=He[0];else for(d=0,C=0;d<cn-1;d++)if(D=He[d],V=He[d+1],b=D.distanceTo(V),C+=b,C>g){H=(C-g)/b,rt=[V.x-H*(V.x-D.x),V.y-H*(V.y-D.y)];break}var vn=a.unproject(et(rt));return Et([vn.lat+pt.lat,vn.lng+pt.lng])}var xs={__proto__:null,simplify:zo,pointToSegmentDistance:vs,closestPointOnSegment:Br,clipSegment:Ys,_getEdgeIntersection:Un,_getBitCode:qn,_sqClosestPointOnSegment:Nn,isFlat:an,_flat:bs,polylineCenter:Gt},Xs={project:function(s){return new J(s.lng,s.lat)},unproject:function(s){return new Rt(s.y,s.x)},bounds:new ht([-180,-90],[180,90])},Qi={R:6378137,R_MINOR:6356752314245179e-9,bounds:new ht([-2003750834279e-5,-1549657073972e-5],[2003750834279e-5,1876465623138e-5]),project:function(s){var a=Math.PI/180,d=this.R,g=s.lat*a,b=this.R_MINOR/d,C=Math.sqrt(1-b*b),D=C*Math.sin(g),V=Math.tan(Math.PI/4-g/2)/Math.pow((1-D)/(1+D),C/2);return g=-d*Math.log(Math.max(V,1e-10)),new J(s.lng*a*d,g)},unproject:function(s){for(var a=180/Math.PI,d=this.R,g=this.R_MINOR/d,b=Math.sqrt(1-g*g),C=Math.exp(-s.y/d),D=Math.PI/2-2*Math.atan(C),V=0,H=.1,rt;V<15&&Math.abs(H)>1e-7;V++)rt=b*Math.sin(D),rt=Math.pow((1-rt)/(1+rt),b/2),H=Math.PI/2-2*Math.atan(C*rt)-D,D+=H;return new Rt(D*a,s.x*a/d)}},Js={__proto__:null,LonLat:Xs,Mercator:Qi,SphericalMercator:Re},Ya=r({},oe,{code:"EPSG:3395",projection:Qi,transformation:function(){var s=.5/(Math.PI*Qi.R);return ye(s,.5,-s,.5)}()}),Fr=r({},oe,{code:"EPSG:4326",projection:Xs,transformation:ye(1/180,1,-1/180,.5)}),Xa=r({},re,{projection:Xs,transformation:ye(1,0,-1,0),scale:function(s){return Math.pow(2,s)},zoom:function(s){return Math.log(s)/Math.LN2},distance:function(s,a){var d=a.lng-s.lng,g=a.lat-s.lat;return Math.sqrt(d*d+g*g)},infinite:!0});re.Earth=oe,re.EPSG3395=Ya,re.EPSG3857=hi,re.EPSG900913=ui,re.EPSG4326=Fr,re.Simple=Xa;var yn=st.extend({options:{pane:"overlayPane",attribution:null,bubblingMouseEvents:!0},addTo:function(s){return s.addLayer(this),this},remove:function(){return this.removeFrom(this._map||this._mapToAdd)},removeFrom:function(s){return s&&s.removeLayer(this),this},getPane:function(s){return this._map.getPane(s?this.options[s]||s:this.options.pane)},addInteractiveTarget:function(s){return this._map._targets[u(s)]=this,this},removeInteractiveTarget:function(s){return delete this._map._targets[u(s)],this},getAttribution:function(){return this.options.attribution},_layerAdd:function(s){var a=s.target;if(a.hasLayer(this)){if(this._map=a,this._zoomAnimated=a._zoomAnimated,this.getEvents){var d=this.getEvents();a.on(d,this),this.once("remove",function(){a.off(d,this)},this)}this.onAdd(a),this.fire("add"),a.fire("layeradd",{layer:this})}}});Zt.include({addLayer:function(s){if(!s._layerAdd)throw new Error("The provided object is not a Layer.");var a=u(s);return this._layers[a]?this:(this._layers[a]=s,s._mapToAdd=this,s.beforeAdd&&s.beforeAdd(this),this.whenReady(s._layerAdd,s),this)},removeLayer:function(s){var a=u(s);return this._layers[a]?(this._loaded&&s.onRemove(this),delete this._layers[a],this._loaded&&(this.fire("layerremove",{layer:s}),s.fire("remove")),s._map=s._mapToAdd=null,this):this},hasLayer:function(s){return u(s)in this._layers},eachLayer:function(s,a){for(var d in this._layers)s.call(a,this._layers[d]);return this},_addLayers:function(s){s=s?A(s)?s:[s]:[];for(var a=0,d=s.length;a<d;a++)this.addLayer(s[a])},_addZoomLimit:function(s){(!isNaN(s.options.maxZoom)||!isNaN(s.options.minZoom))&&(this._zoomBoundLayers[u(s)]=s,this._updateZoomLevels())},_removeZoomLimit:function(s){var a=u(s);this._zoomBoundLayers[a]&&(delete this._zoomBoundLayers[a],this._updateZoomLevels())},_updateZoomLevels:function(){var s=1/0,a=-1/0,d=this._getZoomSpan();for(var g in this._zoomBoundLayers){var b=this._zoomBoundLayers[g].options;s=b.minZoom===void 0?s:Math.min(s,b.minZoom),a=b.maxZoom===void 0?a:Math.max(a,b.maxZoom)}this._layersMaxZoom=a===-1/0?void 0:a,this._layersMinZoom=s===1/0?void 0:s,d!==this._getZoomSpan()&&this.fire("zoomlevelschange"),this.options.maxZoom===void 0&&this._layersMaxZoom&&this.getZoom()>this._layersMaxZoom&&this.setZoom(this._layersMaxZoom),this.options.minZoom===void 0&&this._layersMinZoom&&this.getZoom()<this._layersMinZoom&&this.setZoom(this._layersMinZoom)}});var _s=yn.extend({initialize:function(s,a){p(this,a),this._layers={};var d,g;if(s)for(d=0,g=s.length;d<g;d++)this.addLayer(s[d])},addLayer:function(s){var a=this.getLayerId(s);return this._layers[a]=s,this._map&&this._map.addLayer(s),this},removeLayer:function(s){var a=s in this._layers?s:this.getLayerId(s);return this._map&&this._layers[a]&&this._map.removeLayer(this._layers[a]),delete this._layers[a],this},hasLayer:function(s){var a=typeof s=="number"?s:this.getLayerId(s);return a in this._layers},clearLayers:function(){return this.eachLayer(this.removeLayer,this)},invoke:function(s){var a=Array.prototype.slice.call(arguments,1),d,g;for(d in this._layers)g=this._layers[d],g[s]&&g[s].apply(g,a);return this},onAdd:function(s){this.eachLayer(s.addLayer,s)},onRemove:function(s){this.eachLayer(s.removeLayer,s)},eachLayer:function(s,a){for(var d in this._layers)s.call(a,this._layers[d]);return this},getLayer:function(s){return this._layers[s]},getLayers:function(){var s=[];return this.eachLayer(s.push,s),s},setZIndex:function(s){return this.invoke("setZIndex",s)},getLayerId:function(s){return u(s)}}),Ja=function(s,a){return new _s(s,a)},ni=_s.extend({addLayer:function(s){return this.hasLayer(s)?this:(s.addEventParent(this),_s.prototype.addLayer.call(this,s),this.fire("layeradd",{layer:s}))},removeLayer:function(s){return this.hasLayer(s)?(s in this._layers&&(s=this._layers[s]),s.removeEventParent(this),_s.prototype.removeLayer.call(this,s),this.fire("layerremove",{layer:s})):this},setStyle:function(s){return this.invoke("setStyle",s)},bringToFront:function(){return this.invoke("bringToFront")},bringToBack:function(){return this.invoke("bringToBack")},getBounds:function(){var s=new St;for(var a in this._layers){var d=this._layers[a];s.extend(d.getBounds?d.getBounds():d.getLatLng())}return s}}),Qa=function(s,a){return new ni(s,a)},ln=K.extend({options:{popupAnchor:[0,0],tooltipAnchor:[0,0],crossOrigin:!1},initialize:function(s){p(this,s)},createIcon:function(s){return this._createIcon("icon",s)},createShadow:function(s){return this._createIcon("shadow",s)},_createIcon:function(s,a){var d=this._getIconUrl(s);if(!d){if(s==="icon")throw new Error("iconUrl not set in Icon options (see the docs).");return null}var g=this._createImg(d,a&&a.tagName==="IMG"?a:null);return this._setIconStyles(g,s),(this.options.crossOrigin||this.options.crossOrigin==="")&&(g.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),g},_setIconStyles:function(s,a){var d=this.options,g=d[a+"Size"];typeof g=="number"&&(g=[g,g]);var b=et(g),C=et(a==="shadow"&&d.shadowAnchor||d.iconAnchor||b&&b.divideBy(2,!0));s.className="leaflet-marker-"+a+" "+(d.className||""),C&&(s.style.marginLeft=-C.x+"px",s.style.marginTop=-C.y+"px"),b&&(s.style.width=b.x+"px",s.style.height=b.y+"px")},_createImg:function(s,a){return a=a||document.createElement("img"),a.src=s,a},_getIconUrl:function(s){return gt.retina&&this.options[s+"RetinaUrl"]||this.options[s+"Url"]}});function Bo(s){return new ln(s)}var Ki=ln.extend({options:{iconUrl:"marker-icon.png",iconRetinaUrl:"marker-icon-2x.png",shadowUrl:"marker-shadow.png",iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],tooltipAnchor:[16,-28],shadowSize:[41,41]},_getIconUrl:function(s){return typeof Ki.imagePath!="string"&&(Ki.imagePath=this._detectIconPath()),(this.options.imagePath||Ki.imagePath)+ln.prototype._getIconUrl.call(this,s)},_stripUrl:function(s){var a=function(d,g,b){var C=g.exec(d);return C&&C[b]};return s=a(s,/^url\((['"])?(.+)\1\)$/,2),s&&a(s,/^(.*)marker-icon\.png$/,1)},_detectIconPath:function(){var s=Ct("div","leaflet-default-icon-path",document.body),a=be(s,"background-image")||be(s,"backgroundImage");if(document.body.removeChild(s),a=this._stripUrl(a),a)return a;var d=document.querySelector('link[href$="leaflet.css"]');return d?d.href.substring(0,d.href.length-11-1):""}}),Qs=Rn.extend({initialize:function(s){this._marker=s},addHooks:function(){var s=this._marker._icon;this._draggable||(this._draggable=new ei(s,s,!0)),this._draggable.on({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).enable(),xt(s,"leaflet-marker-draggable")},removeHooks:function(){this._draggable.off({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).disable(),this._marker._icon&&Bt(this._marker._icon,"leaflet-marker-draggable")},moved:function(){return this._draggable&&this._draggable._moved},_adjustPan:function(s){var a=this._marker,d=a._map,g=this._marker.options.autoPanSpeed,b=this._marker.options.autoPanPadding,C=Si(a._icon),D=d.getPixelBounds(),V=d.getPixelOrigin(),H=kt(D.min._subtract(V).add(b),D.max._subtract(V).subtract(b));if(!H.contains(C)){var rt=et((Math.max(H.max.x,C.x)-H.max.x)/(D.max.x-H.max.x)-(Math.min(H.min.x,C.x)-H.min.x)/(D.min.x-H.min.x),(Math.max(H.max.y,C.y)-H.max.y)/(D.max.y-H.max.y)-(Math.min(H.min.y,C.y)-H.min.y)/(D.min.y-H.min.y)).multiplyBy(g);d.panBy(rt,{animate:!1}),this._draggable._newPos._add(rt),this._draggable._startPos._add(rt),xe(a._icon,this._draggable._newPos),this._onDrag(s),this._panRequest=q(this._adjustPan.bind(this,s))}},_onDragStart:function(){this._oldLatLng=this._marker.getLatLng(),this._marker.closePopup&&this._marker.closePopup(),this._marker.fire("movestart").fire("dragstart")},_onPreDrag:function(s){this._marker.options.autoPan&&(it(this._panRequest),this._panRequest=q(this._adjustPan.bind(this,s)))},_onDrag:function(s){var a=this._marker,d=a._shadow,g=Si(a._icon),b=a._map.layerPointToLatLng(g);d&&xe(d,g),a._latlng=b,s.latlng=b,s.oldLatLng=this._oldLatLng,a.fire("move",s).fire("drag",s)},_onDragEnd:function(s){it(this._panRequest),delete this._oldLatLng,this._marker.fire("moveend").fire("dragend",s)}}),Ks=yn.extend({options:{icon:new Ki,interactive:!0,keyboard:!0,title:"",alt:"Marker",zIndexOffset:0,opacity:1,riseOnHover:!1,riseOffset:250,pane:"markerPane",shadowPane:"shadowPane",bubblingMouseEvents:!1,autoPanOnFocus:!0,draggable:!1,autoPan:!1,autoPanPadding:[50,50],autoPanSpeed:10},initialize:function(s,a){p(this,a),this._latlng=Et(s)},onAdd:function(s){this._zoomAnimated=this._zoomAnimated&&s.options.markerZoomAnimation,this._zoomAnimated&&s.on("zoomanim",this._animateZoom,this),this._initIcon(),this.update()},onRemove:function(s){this.dragging&&this.dragging.enabled()&&(this.options.draggable=!0,this.dragging.removeHooks()),delete this.dragging,this._zoomAnimated&&s.off("zoomanim",this._animateZoom,this),this._removeIcon(),this._removeShadow()},getEvents:function(){return{zoom:this.update,viewreset:this.update}},getLatLng:function(){return this._latlng},setLatLng:function(s){var a=this._latlng;return this._latlng=Et(s),this.update(),this.fire("move",{oldLatLng:a,latlng:this._latlng})},setZIndexOffset:function(s){return this.options.zIndexOffset=s,this.update()},getIcon:function(){return this.options.icon},setIcon:function(s){return this.options.icon=s,this._map&&(this._initIcon(),this.update()),this._popup&&this.bindPopup(this._popup,this._popup.options),this},getElement:function(){return this._icon},update:function(){if(this._icon&&this._map){var s=this._map.latLngToLayerPoint(this._latlng).round();this._setPos(s)}return this},_initIcon:function(){var s=this.options,a="leaflet-zoom-"+(this._zoomAnimated?"animated":"hide"),d=s.icon.createIcon(this._icon),g=!1;d!==this._icon&&(this._icon&&this._removeIcon(),g=!0,s.title&&(d.title=s.title),d.tagName==="IMG"&&(d.alt=s.alt||"")),xt(d,a),s.keyboard&&(d.tabIndex="0",d.setAttribute("role","button")),this._icon=d,s.riseOnHover&&this.on({mouseover:this._bringToFront,mouseout:this._resetZIndex}),this.options.autoPanOnFocus&&zt(d,"focus",this._panOnFocus,this);var b=s.icon.createShadow(this._shadow),C=!1;b!==this._shadow&&(this._removeShadow(),C=!0),b&&(xt(b,a),b.alt=""),this._shadow=b,s.opacity<1&&this._updateOpacity(),g&&this.getPane().appendChild(this._icon),this._initInteraction(),b&&C&&this.getPane(s.shadowPane).appendChild(this._shadow)},_removeIcon:function(){this.options.riseOnHover&&this.off({mouseover:this._bringToFront,mouseout:this._resetZIndex}),this.options.autoPanOnFocus&&le(this._icon,"focus",this._panOnFocus,this),Qt(this._icon),this.removeInteractiveTarget(this._icon),this._icon=null},_removeShadow:function(){this._shadow&&Qt(this._shadow),this._shadow=null},_setPos:function(s){this._icon&&xe(this._icon,s),this._shadow&&xe(this._shadow,s),this._zIndex=s.y+this.options.zIndexOffset,this._resetZIndex()},_updateZIndex:function(s){this._icon&&(this._icon.style.zIndex=this._zIndex+s)},_animateZoom:function(s){var a=this._map._latLngToNewLayerPoint(this._latlng,s.zoom,s.center).round();this._setPos(a)},_initInteraction:function(){if(this.options.interactive&&(xt(this._icon,"leaflet-interactive"),this.addInteractiveTarget(this._icon),Qs)){var s=this.options.draggable;this.dragging&&(s=this.dragging.enabled(),this.dragging.disable()),this.dragging=new Qs(this),s&&this.dragging.enable()}},setOpacity:function(s){return this.options.opacity=s,this._map&&this._updateOpacity(),this},_updateOpacity:function(){var s=this.options.opacity;this._icon&&mn(this._icon,s),this._shadow&&mn(this._shadow,s)},_bringToFront:function(){this._updateZIndex(this.options.riseOffset)},_resetZIndex:function(){this._updateZIndex(0)},_panOnFocus:function(){var s=this._map;if(s){var a=this.options.icon.options,d=a.iconSize?et(a.iconSize):et(0,0),g=a.iconAnchor?et(a.iconAnchor):et(0,0);s.panInside(this._latlng,{paddingTopLeft:g,paddingBottomRight:d.subtract(g)})}},_getPopupAnchor:function(){return this.options.icon.options.popupAnchor},_getTooltipAnchor:function(){return this.options.icon.options.tooltipAnchor}});function Ka(s,a){return new Ks(s,a)}var ii=yn.extend({options:{stroke:!0,color:"#3388ff",weight:3,opacity:1,lineCap:"round",lineJoin:"round",dashArray:null,dashOffset:null,fill:!1,fillColor:null,fillOpacity:.2,fillRule:"evenodd",interactive:!0,bubblingMouseEvents:!0},beforeAdd:function(s){this._renderer=s.getRenderer(this)},onAdd:function(){this._renderer._initPath(this),this._reset(),this._renderer._addPath(this)},onRemove:function(){this._renderer._removePath(this)},redraw:function(){return this._map&&this._renderer._updatePath(this),this},setStyle:function(s){return p(this,s),this._renderer&&(this._renderer._updateStyle(this),this.options.stroke&&s&&Object.prototype.hasOwnProperty.call(s,"weight")&&this._updateBounds()),this},bringToFront:function(){return this._renderer&&this._renderer._bringToFront(this),this},bringToBack:function(){return this._renderer&&this._renderer._bringToBack(this),this},getElement:function(){return this._path},_reset:function(){this._project(),this._update()},_clickTolerance:function(){return(this.options.stroke?this.options.weight/2:0)+(this._renderer.options.tolerance||0)}}),tr=ii.extend({options:{fill:!0,radius:10},initialize:function(s,a){p(this,a),this._latlng=Et(s),this._radius=this.options.radius},setLatLng:function(s){var a=this._latlng;return this._latlng=Et(s),this.redraw(),this.fire("move",{oldLatLng:a,latlng:this._latlng})},getLatLng:function(){return this._latlng},setRadius:function(s){return this.options.radius=this._radius=s,this.redraw()},getRadius:function(){return this._radius},setStyle:function(s){var a=s&&s.radius||this._radius;return ii.prototype.setStyle.call(this,s),this.setRadius(a),this},_project:function(){this._point=this._map.latLngToLayerPoint(this._latlng),this._updateBounds()},_updateBounds:function(){var s=this._radius,a=this._radiusY||s,d=this._clickTolerance(),g=[s+d,a+d];this._pxBounds=new ht(this._point.subtract(g),this._point.add(g))},_update:function(){this._map&&this._updatePath()},_updatePath:function(){this._renderer._updateCircle(this)},_empty:function(){return this._radius&&!this._renderer._bounds.intersects(this._pxBounds)},_containsPoint:function(s){return s.distanceTo(this._point)<=this._radius+this._clickTolerance()}});function Sh(s,a){return new tr(s,a)}var Wr=tr.extend({initialize:function(s,a,d){if(typeof a=="number"&&(a=r({},d,{radius:a})),p(this,a),this._latlng=Et(s),isNaN(this.options.radius))throw new Error("Circle radius cannot be NaN");this._mRadius=this.options.radius},setRadius:function(s){return this._mRadius=s,this.redraw()},getRadius:function(){return this._mRadius},getBounds:function(){var s=[this._radius,this._radiusY||this._radius];return new St(this._map.layerPointToLatLng(this._point.subtract(s)),this._map.layerPointToLatLng(this._point.add(s)))},setStyle:ii.prototype.setStyle,_project:function(){var s=this._latlng.lng,a=this._latlng.lat,d=this._map,g=d.options.crs;if(g.distance===oe.distance){var b=Math.PI/180,C=this._mRadius/oe.R/b,D=d.project([a+C,s]),V=d.project([a-C,s]),H=D.add(V).divideBy(2),rt=d.unproject(H).lat,pt=Math.acos((Math.cos(C*b)-Math.sin(a*b)*Math.sin(rt*b))/(Math.cos(a*b)*Math.cos(rt*b)))/b;(isNaN(pt)||pt===0)&&(pt=C/Math.cos(Math.PI/180*a)),this._point=H.subtract(d.getPixelOrigin()),this._radius=isNaN(pt)?0:H.x-d.project([rt,s-pt]).x,this._radiusY=H.y-D.y}else{var Nt=g.unproject(g.project(this._latlng).subtract([this._mRadius,0]));this._point=d.latLngToLayerPoint(this._latlng),this._radius=this._point.x-d.latLngToLayerPoint(Nt).x}this._updateBounds()}});function tl(s,a,d){return new Wr(s,a,d)}var Gn=ii.extend({options:{smoothFactor:1,noClip:!1},initialize:function(s,a){p(this,a),this._setLatLngs(s)},getLatLngs:function(){return this._latlngs},setLatLngs:function(s){return this._setLatLngs(s),this.redraw()},isEmpty:function(){return!this._latlngs.length},closestLayerPoint:function(s){for(var a=1/0,d=null,g=Nn,b,C,D=0,V=this._parts.length;D<V;D++)for(var H=this._parts[D],rt=1,pt=H.length;rt<pt;rt++){b=H[rt-1],C=H[rt];var Nt=g(s,b,C,!0);Nt<a&&(a=Nt,d=g(s,b,C))}return d&&(d.distance=Math.sqrt(a)),d},getCenter:function(){if(!this._map)throw new Error("Must add layer to map before using getCenter()");return Gt(this._defaultShape(),this._map.options.crs)},getBounds:function(){return this._bounds},addLatLng:function(s,a){return a=a||this._defaultShape(),s=Et(s),a.push(s),this._bounds.extend(s),this.redraw()},_setLatLngs:function(s){this._bounds=new St,this._latlngs=this._convertLatLngs(s)},_defaultShape:function(){return an(this._latlngs)?this._latlngs:this._latlngs[0]},_convertLatLngs:function(s){for(var a=[],d=an(s),g=0,b=s.length;g<b;g++)d?(a[g]=Et(s[g]),this._bounds.extend(a[g])):a[g]=this._convertLatLngs(s[g]);return a},_project:function(){var s=new ht;this._rings=[],this._projectLatlngs(this._latlngs,this._rings,s),this._bounds.isValid()&&s.isValid()&&(this._rawPxBounds=s,this._updateBounds())},_updateBounds:function(){var s=this._clickTolerance(),a=new J(s,s);this._rawPxBounds&&(this._pxBounds=new ht([this._rawPxBounds.min.subtract(a),this._rawPxBounds.max.add(a)]))},_projectLatlngs:function(s,a,d){var g=s[0]instanceof Rt,b=s.length,C,D;if(g){for(D=[],C=0;C<b;C++)D[C]=this._map.latLngToLayerPoint(s[C]),d.extend(D[C]);a.push(D)}else for(C=0;C<b;C++)this._projectLatlngs(s[C],a,d)},_clipPoints:function(){var s=this._renderer._bounds;if(this._parts=[],!(!this._pxBounds||!this._pxBounds.intersects(s))){if(this.options.noClip){this._parts=this._rings;return}var a=this._parts,d,g,b,C,D,V,H;for(d=0,b=0,C=this._rings.length;d<C;d++)for(H=this._rings[d],g=0,D=H.length;g<D-1;g++)V=Ys(H[g],H[g+1],s,g,!0),V&&(a[b]=a[b]||[],a[b].push(V[0]),(V[1]!==H[g+1]||g===D-2)&&(a[b].push(V[1]),b++))}},_simplifyPoints:function(){for(var s=this._parts,a=this.options.smoothFactor,d=0,g=s.length;d<g;d++)s[d]=zo(s[d],a)},_update:function(){this._map&&(this._clipPoints(),this._simplifyPoints(),this._updatePath())},_updatePath:function(){this._renderer._updatePoly(this)},_containsPoint:function(s,a){var d,g,b,C,D,V,H=this._clickTolerance();if(!this._pxBounds||!this._pxBounds.contains(s))return!1;for(d=0,C=this._parts.length;d<C;d++)for(V=this._parts[d],g=0,D=V.length,b=D-1;g<D;b=g++)if(!(!a&&g===0)&&vs(s,V[b],V[g])<=H)return!0;return!1}});function el(s,a){return new Gn(s,a)}Gn._flat=bs;var Mi=Gn.extend({options:{fill:!0},isEmpty:function(){return!this._latlngs.length||!this._latlngs[0].length},getCenter:function(){if(!this._map)throw new Error("Must add layer to map before using getCenter()");return Io(this._defaultShape(),this._map.options.crs)},_convertLatLngs:function(s){var a=Gn.prototype._convertLatLngs.call(this,s),d=a.length;return d>=2&&a[0]instanceof Rt&&a[0].equals(a[d-1])&&a.pop(),a},_setLatLngs:function(s){Gn.prototype._setLatLngs.call(this,s),an(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return an(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var s=this._renderer._bounds,a=this.options.weight,d=new J(a,a);if(s=new ht(s.min.subtract(d),s.max.add(d)),this._parts=[],!(!this._pxBounds||!this._pxBounds.intersects(s))){if(this.options.noClip){this._parts=this._rings;return}for(var g=0,b=this._rings.length,C;g<b;g++)C=$r(this._rings[g],s,!0),C.length&&this._parts.push(C)}},_updatePath:function(){this._renderer._updatePoly(this,!0)},_containsPoint:function(s){var a=!1,d,g,b,C,D,V,H,rt;if(!this._pxBounds||!this._pxBounds.contains(s))return!1;for(C=0,H=this._parts.length;C<H;C++)for(d=this._parts[C],D=0,rt=d.length,V=rt-1;D<rt;V=D++)g=d[D],b=d[V],g.y>s.y!=b.y>s.y&&s.x<(b.x-g.x)*(s.y-g.y)/(b.y-g.y)+g.x&&(a=!a);return a||Gn.prototype._containsPoint.call(this,s,!0)}});function Oo(s,a){return new Mi(s,a)}var In=ni.extend({initialize:function(s,a){p(this,a),this._layers={},s&&this.addData(s)},addData:function(s){var a=A(s)?s:s.features,d,g,b;if(a){for(d=0,g=a.length;d<g;d++)b=a[d],(b.geometries||b.geometry||b.features||b.coordinates)&&this.addData(b);return this}var C=this.options;if(C.filter&&!C.filter(s))return this;var D=ws(s,C);return D?(D.feature=Ms(s),D.defaultOptions=D.options,this.resetStyle(D),C.onEachFeature&&C.onEachFeature(s,D),this.addLayer(D)):this},resetStyle:function(s){return s===void 0?this.eachLayer(this.resetStyle,this):(s.options=r({},s.defaultOptions),this._setLayerStyle(s,this.options.style),this)},setStyle:function(s){return this.eachLayer(function(a){this._setLayerStyle(a,s)},this)},_setLayerStyle:function(s,a){s.setStyle&&(typeof a=="function"&&(a=a(s.feature)),s.setStyle(a))}});function ws(s,a){var d=s.type==="Feature"?s.geometry:s,g=d?d.coordinates:null,b=[],C=a&&a.pointToLayer,D=a&&a.coordsToLatLng||er,V,H,rt,pt;if(!g&&!d)return null;switch(d.type){case"Point":return V=D(g),Vr(C,s,V,a);case"MultiPoint":for(rt=0,pt=g.length;rt<pt;rt++)V=D(g[rt]),b.push(Vr(C,s,V,a));return new ni(b);case"LineString":case"MultiLineString":return H=Ss(g,d.type==="LineString"?0:1,D),new Gn(H,a);case"Polygon":case"MultiPolygon":return H=Ss(g,d.type==="Polygon"?1:2,D),new Mi(H,a);case"GeometryCollection":for(rt=0,pt=d.geometries.length;rt<pt;rt++){var Nt=ws({geometry:d.geometries[rt],type:"Feature",properties:s.properties},a);Nt&&b.push(Nt)}return new ni(b);case"FeatureCollection":for(rt=0,pt=d.features.length;rt<pt;rt++){var Ut=ws(d.features[rt],a);Ut&&b.push(Ut)}return new ni(b);default:throw new Error("Invalid GeoJSON object.")}}function Vr(s,a,d,g){return s?s(a,d):new Ks(d,g&&g.markersInheritOptions&&g)}function er(s){return new Rt(s[1],s[0],s[2])}function Ss(s,a,d){for(var g=[],b=0,C=s.length,D;b<C;b++)D=a?Ss(s[b],a-1,d):(d||er)(s[b]),g.push(D);return g}function nr(s,a){return s=Et(s),s.alt!==void 0?[y(s.lng,a),y(s.lat,a),y(s.alt,a)]:[y(s.lng,a),y(s.lat,a)]}function Cs(s,a,d,g){for(var b=[],C=0,D=s.length;C<D;C++)b.push(a?Cs(s[C],an(s[C])?0:a-1,d,g):nr(s[C],g));return!a&&d&&b.length>0&&b.push(b[0].slice()),b}function ki(s,a){return s.feature?r({},s.feature,{geometry:a}):Ms(a)}function Ms(s){return s.type==="Feature"||s.type==="FeatureCollection"?s:{type:"Feature",properties:{},geometry:s}}var ir={toGeoJSON:function(s){return ki(this,{type:"Point",coordinates:nr(this.getLatLng(),s)})}};Ks.include(ir),Wr.include(ir),tr.include(ir),Gn.include({toGeoJSON:function(s){var a=!an(this._latlngs),d=Cs(this._latlngs,a?1:0,!1,s);return ki(this,{type:(a?"Multi":"")+"LineString",coordinates:d})}}),Mi.include({toGeoJSON:function(s){var a=!an(this._latlngs),d=a&&!an(this._latlngs[0]),g=Cs(this._latlngs,d?2:a?1:0,!0,s);return a||(g=[g]),ki(this,{type:(d?"Multi":"")+"Polygon",coordinates:g})}}),_s.include({toMultiPoint:function(s){var a=[];return this.eachLayer(function(d){a.push(d.toGeoJSON(s).geometry.coordinates)}),ki(this,{type:"MultiPoint",coordinates:a})},toGeoJSON:function(s){var a=this.feature&&this.feature.geometry&&this.feature.geometry.type;if(a==="MultiPoint")return this.toMultiPoint(s);var d=a==="GeometryCollection",g=[];return this.eachLayer(function(b){if(b.toGeoJSON){var C=b.toGeoJSON(s);if(d)g.push(C.geometry);else{var D=Ms(C);D.type==="FeatureCollection"?g.push.apply(g,D.features):g.push(D)}}}),d?ki(this,{geometries:g,type:"GeometryCollection"}):{type:"FeatureCollection",features:g}}});function jr(s,a){return new In(s,a)}var w=jr,M=yn.extend({options:{opacity:1,alt:"",interactive:!1,crossOrigin:!1,errorOverlayUrl:"",zIndex:1,className:""},initialize:function(s,a,d){this._url=s,this._bounds=Tt(a),p(this,d)},onAdd:function(){this._image||(this._initImage(),this.options.opacity<1&&this._updateOpacity()),this.options.interactive&&(xt(this._image,"leaflet-interactive"),this.addInteractiveTarget(this._image)),this.getPane().appendChild(this._image),this._reset()},onRemove:function(){Qt(this._image),this.options.interactive&&this.removeInteractiveTarget(this._image)},setOpacity:function(s){return this.options.opacity=s,this._image&&this._updateOpacity(),this},setStyle:function(s){return s.opacity&&this.setOpacity(s.opacity),this},bringToFront:function(){return this._map&&jn(this._image),this},bringToBack:function(){return this._map&&dt(this._image),this},setUrl:function(s){return this._url=s,this._image&&(this._image.src=s),this},setBounds:function(s){return this._bounds=Tt(s),this._map&&this._reset(),this},getEvents:function(){var s={zoom:this._reset,viewreset:this._reset};return this._zoomAnimated&&(s.zoomanim=this._animateZoom),s},setZIndex:function(s){return this.options.zIndex=s,this._updateZIndex(),this},getBounds:function(){return this._bounds},getElement:function(){return this._image},_initImage:function(){var s=this._url.tagName==="IMG",a=this._image=s?this._url:Ct("img");if(xt(a,"leaflet-image-layer"),this._zoomAnimated&&xt(a,"leaflet-zoom-animated"),this.options.className&&xt(a,this.options.className),a.onselectstart=m,a.onmousemove=m,a.onload=l(this.fire,this,"load"),a.onerror=l(this._overlayOnError,this,"error"),(this.options.crossOrigin||this.options.crossOrigin==="")&&(a.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),this.options.zIndex&&this._updateZIndex(),s){this._url=a.src;return}a.src=this._url,a.alt=this.options.alt},_animateZoom:function(s){var a=this._map.getZoomScale(s.zoom),d=this._map._latLngBoundsToNewLayerBounds(this._bounds,s.zoom,s.center).min;wi(this._image,d,a)},_reset:function(){var s=this._image,a=new ht(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),d=a.getSize();xe(s,a.min),s.style.width=d.x+"px",s.style.height=d.y+"px"},_updateOpacity:function(){mn(this._image,this.options.opacity)},_updateZIndex:function(){this._image&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._image.style.zIndex=this.options.zIndex)},_overlayOnError:function(){this.fire("error");var s=this.options.errorOverlayUrl;s&&this._url!==s&&(this._url=s,this._image.src=s)},getCenter:function(){return this._bounds.getCenter()}}),S=function(s,a,d){return new M(s,a,d)},B=M.extend({options:{autoplay:!0,loop:!0,keepAspectRatio:!0,muted:!1,playsInline:!0},_initImage:function(){var s=this._url.tagName==="VIDEO",a=this._image=s?this._url:Ct("video");if(xt(a,"leaflet-image-layer"),this._zoomAnimated&&xt(a,"leaflet-zoom-animated"),this.options.className&&xt(a,this.options.className),a.onselectstart=m,a.onmousemove=m,a.onloadeddata=l(this.fire,this,"load"),s){for(var d=a.getElementsByTagName("source"),g=[],b=0;b<d.length;b++)g.push(d[b].src);this._url=d.length>0?g:[a.src];return}A(this._url)||(this._url=[this._url]),!this.options.keepAspectRatio&&Object.prototype.hasOwnProperty.call(a.style,"objectFit")&&(a.style.objectFit="fill"),a.autoplay=!!this.options.autoplay,a.loop=!!this.options.loop,a.muted=!!this.options.muted,a.playsInline=!!this.options.playsInline;for(var C=0;C<this._url.length;C++){var D=Ct("source");D.src=this._url[C],a.appendChild(D)}}});function R(s,a,d){return new B(s,a,d)}var z=M.extend({_initImage:function(){var s=this._image=this._url;xt(s,"leaflet-image-layer"),this._zoomAnimated&&xt(s,"leaflet-zoom-animated"),this.options.className&&xt(s,this.options.className),s.onselectstart=m,s.onmousemove=m}});function O(s,a,d){return new z(s,a,d)}var F=yn.extend({options:{interactive:!1,offset:[0,0],className:"",pane:void 0,content:""},initialize:function(s,a){s&&(s instanceof Rt||A(s))?(this._latlng=Et(s),p(this,a)):(p(this,s),this._source=a),this.options.content&&(this._content=this.options.content)},openOn:function(s){return s=arguments.length?s:this._source._map,s.hasLayer(this)||s.addLayer(this),this},close:function(){return this._map&&this._map.removeLayer(this),this},toggle:function(s){return this._map?this.close():(arguments.length?this._source=s:s=this._source,this._prepareOpen(),this.openOn(s._map)),this},onAdd:function(s){this._zoomAnimated=s._zoomAnimated,this._container||this._initLayout(),s._fadeAnimated&&mn(this._container,0),clearTimeout(this._removeTimeout),this.getPane().appendChild(this._container),this.update(),s._fadeAnimated&&mn(this._container,1),this.bringToFront(),this.options.interactive&&(xt(this._container,"leaflet-interactive"),this.addInteractiveTarget(this._container))},onRemove:function(s){s._fadeAnimated?(mn(this._container,0),this._removeTimeout=setTimeout(l(Qt,void 0,this._container),200)):Qt(this._container),this.options.interactive&&(Bt(this._container,"leaflet-interactive"),this.removeInteractiveTarget(this._container))},getLatLng:function(){return this._latlng},setLatLng:function(s){return this._latlng=Et(s),this._map&&(this._updatePosition(),this._adjustPan()),this},getContent:function(){return this._content},setContent:function(s){return this._content=s,this.update(),this},getElement:function(){return this._container},update:function(){this._map&&(this._container.style.visibility="hidden",this._updateContent(),this._updateLayout(),this._updatePosition(),this._container.style.visibility="",this._adjustPan())},getEvents:function(){var s={zoom:this._updatePosition,viewreset:this._updatePosition};return this._zoomAnimated&&(s.zoomanim=this._animateZoom),s},isOpen:function(){return!!this._map&&this._map.hasLayer(this)},bringToFront:function(){return this._map&&jn(this._container),this},bringToBack:function(){return this._map&&dt(this._container),this},_prepareOpen:function(s){var a=this._source;if(!a._map)return!1;if(a instanceof ni){a=null;var d=this._source._layers;for(var g in d)if(d[g]._map){a=d[g];break}if(!a)return!1;this._source=a}if(!s)if(a.getCenter)s=a.getCenter();else if(a.getLatLng)s=a.getLatLng();else if(a.getBounds)s=a.getBounds().getCenter();else throw new Error("Unable to get source layer LatLng.");return this.setLatLng(s),this._map&&this.update(),!0},_updateContent:function(){if(this._content){var s=this._contentNode,a=typeof this._content=="function"?this._content(this._source||this):this._content;if(typeof a=="string")s.innerHTML=a;else{for(;s.hasChildNodes();)s.removeChild(s.firstChild);s.appendChild(a)}this.fire("contentupdate")}},_updatePosition:function(){if(this._map){var s=this._map.latLngToLayerPoint(this._latlng),a=et(this.options.offset),d=this._getAnchor();this._zoomAnimated?xe(this._container,s.add(d)):a=a.add(s).add(d);var g=this._containerBottom=-a.y,b=this._containerLeft=-Math.round(this._containerWidth/2)+a.x;this._container.style.bottom=g+"px",this._container.style.left=b+"px"}},_getAnchor:function(){return[0,0]}});Zt.include({_initOverlay:function(s,a,d,g){var b=a;return b instanceof s||(b=new s(g).setContent(a)),d&&b.setLatLng(d),b}}),yn.include({_initOverlay:function(s,a,d,g){var b=d;return b instanceof s?(p(b,g),b._source=this):(b=a&&!g?a:new s(g,this),b.setContent(d)),b}});var W=F.extend({options:{pane:"popupPane",offset:[0,7],maxWidth:300,minWidth:50,maxHeight:null,autoPan:!0,autoPanPaddingTopLeft:null,autoPanPaddingBottomRight:null,autoPanPadding:[5,5],keepInView:!1,closeButton:!0,autoClose:!0,closeOnEscapeKey:!0,className:""},openOn:function(s){return s=arguments.length?s:this._source._map,!s.hasLayer(this)&&s._popup&&s._popup.options.autoClose&&s.removeLayer(s._popup),s._popup=this,F.prototype.openOn.call(this,s)},onAdd:function(s){F.prototype.onAdd.call(this,s),s.fire("popupopen",{popup:this}),this._source&&(this._source.fire("popupopen",{popup:this},!0),this._source instanceof ii||this._source.on("preclick",Ci))},onRemove:function(s){F.prototype.onRemove.call(this,s),s.fire("popupclose",{popup:this}),this._source&&(this._source.fire("popupclose",{popup:this},!0),this._source instanceof ii||this._source.off("preclick",Ci))},getEvents:function(){var s=F.prototype.getEvents.call(this);return(this.options.closeOnClick!==void 0?this.options.closeOnClick:this._map.options.closePopupOnClick)&&(s.preclick=this.close),this.options.keepInView&&(s.moveend=this._adjustPan),s},_initLayout:function(){var s="leaflet-popup",a=this._container=Ct("div",s+" "+(this.options.className||"")+" leaflet-zoom-animated"),d=this._wrapper=Ct("div",s+"-content-wrapper",a);if(this._contentNode=Ct("div",s+"-content",d),ys(a),Be(this._contentNode),zt(a,"contextmenu",Ci),this._tipContainer=Ct("div",s+"-tip-container",a),this._tip=Ct("div",s+"-tip",this._tipContainer),this.options.closeButton){var g=this._closeButton=Ct("a",s+"-close-button",a);g.setAttribute("role","button"),g.setAttribute("aria-label","Close popup"),g.href="#close",g.innerHTML='<span aria-hidden="true">&#215;</span>',zt(g,"click",function(b){Oe(b),this.close()},this)}},_updateLayout:function(){var s=this._contentNode,a=s.style;a.width="",a.whiteSpace="nowrap";var d=s.offsetWidth;d=Math.min(d,this.options.maxWidth),d=Math.max(d,this.options.minWidth),a.width=d+1+"px",a.whiteSpace="",a.height="";var g=s.offsetHeight,b=this.options.maxHeight,C="leaflet-popup-scrolled";b&&g>b?(a.height=b+"px",xt(s,C)):Bt(s,C),this._containerWidth=this._container.offsetWidth},_animateZoom:function(s){var a=this._map._latLngToNewLayerPoint(this._latlng,s.zoom,s.center),d=this._getAnchor();xe(this._container,a.add(d))},_adjustPan:function(){if(this.options.autoPan){if(this._map._panAnim&&this._map._panAnim.stop(),this._autopanning){this._autopanning=!1;return}var s=this._map,a=parseInt(be(this._container,"marginBottom"),10)||0,d=this._container.offsetHeight+a,g=this._containerWidth,b=new J(this._containerLeft,-d-this._containerBottom);b._add(Si(this._container));var C=s.layerPointToContainerPoint(b),D=et(this.options.autoPanPadding),V=et(this.options.autoPanPaddingTopLeft||D),H=et(this.options.autoPanPaddingBottomRight||D),rt=s.getSize(),pt=0,Nt=0;C.x+g+H.x>rt.x&&(pt=C.x+g-rt.x+H.x),C.x-pt-V.x<0&&(pt=C.x-V.x),C.y+d+H.y>rt.y&&(Nt=C.y+d-rt.y+H.y),C.y-Nt-V.y<0&&(Nt=C.y-V.y),(pt||Nt)&&(this.options.keepInView&&(this._autopanning=!0),s.fire("autopanstart").panBy([pt,Nt]))}},_getAnchor:function(){return et(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}}),X=function(s,a){return new W(s,a)};Zt.mergeOptions({closePopupOnClick:!0}),Zt.include({openPopup:function(s,a,d){return this._initOverlay(W,s,a,d).openOn(this),this},closePopup:function(s){return s=arguments.length?s:this._popup,s&&s.close(),this}}),yn.include({bindPopup:function(s,a){return this._popup=this._initOverlay(W,this._popup,s,a),this._popupHandlersAdded||(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null),this},openPopup:function(s){return this._popup&&(this instanceof ni||(this._popup._source=this),this._popup._prepareOpen(s||this._latlng)&&this._popup.openOn(this._map)),this},closePopup:function(){return this._popup&&this._popup.close(),this},togglePopup:function(){return this._popup&&this._popup.toggle(this),this},isPopupOpen:function(){return this._popup?this._popup.isOpen():!1},setPopupContent:function(s){return this._popup&&this._popup.setContent(s),this},getPopup:function(){return this._popup},_openPopup:function(s){if(!(!this._popup||!this._map)){pn(s);var a=s.layer||s.target;if(this._popup._source===a&&!(a instanceof ii)){this._map.hasLayer(this._popup)?this.closePopup():this.openPopup(s.latlng);return}this._popup._source=a,this.openPopup(s.latlng)}},_movePopup:function(s){this._popup.setLatLng(s.latlng)},_onKeyPress:function(s){s.originalEvent.keyCode===13&&this._openPopup(s)}});var lt=F.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,opacity:.9},onAdd:function(s){F.prototype.onAdd.call(this,s),this.setOpacity(this.options.opacity),s.fire("tooltipopen",{tooltip:this}),this._source&&(this.addEventParent(this._source),this._source.fire("tooltipopen",{tooltip:this},!0))},onRemove:function(s){F.prototype.onRemove.call(this,s),s.fire("tooltipclose",{tooltip:this}),this._source&&(this.removeEventParent(this._source),this._source.fire("tooltipclose",{tooltip:this},!0))},getEvents:function(){var s=F.prototype.getEvents.call(this);return this.options.permanent||(s.preclick=this.close),s},_initLayout:function(){var s="leaflet-tooltip",a=s+" "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=Ct("div",a),this._container.setAttribute("role","tooltip"),this._container.setAttribute("id","leaflet-tooltip-"+u(this))},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(s){var a,d,g=this._map,b=this._container,C=g.latLngToContainerPoint(g.getCenter()),D=g.layerPointToContainerPoint(s),V=this.options.direction,H=b.offsetWidth,rt=b.offsetHeight,pt=et(this.options.offset),Nt=this._getAnchor();V==="top"?(a=H/2,d=rt):V==="bottom"?(a=H/2,d=0):V==="center"?(a=H/2,d=rt/2):V==="right"?(a=0,d=rt/2):V==="left"?(a=H,d=rt/2):D.x<C.x?(V="right",a=0,d=rt/2):(V="left",a=H+(pt.x+Nt.x)*2,d=rt/2),s=s.subtract(et(a,d,!0)).add(pt).add(Nt),Bt(b,"leaflet-tooltip-right"),Bt(b,"leaflet-tooltip-left"),Bt(b,"leaflet-tooltip-top"),Bt(b,"leaflet-tooltip-bottom"),xt(b,"leaflet-tooltip-"+V),xe(b,s)},_updatePosition:function(){var s=this._map.latLngToLayerPoint(this._latlng);this._setPosition(s)},setOpacity:function(s){this.options.opacity=s,this._container&&mn(this._container,s)},_animateZoom:function(s){var a=this._map._latLngToNewLayerPoint(this._latlng,s.zoom,s.center);this._setPosition(a)},_getAnchor:function(){return et(this._source&&this._source._getTooltipAnchor&&!this.options.sticky?this._source._getTooltipAnchor():[0,0])}}),at=function(s,a){return new lt(s,a)};Zt.include({openTooltip:function(s,a,d){return this._initOverlay(lt,s,a,d).openOn(this),this},closeTooltip:function(s){return s.close(),this}}),yn.include({bindTooltip:function(s,a){return this._tooltip&&this.isTooltipOpen()&&this.unbindTooltip(),this._tooltip=this._initOverlay(lt,this._tooltip,s,a),this._initTooltipInteractions(),this._tooltip.options.permanent&&this._map&&this._map.hasLayer(this)&&this.openTooltip(),this},unbindTooltip:function(){return this._tooltip&&(this._initTooltipInteractions(!0),this.closeTooltip(),this._tooltip=null),this},_initTooltipInteractions:function(s){if(!(!s&&this._tooltipHandlersAdded)){var a=s?"off":"on",d={remove:this.closeTooltip,move:this._moveTooltip};this._tooltip.options.permanent?d.add=this._openTooltip:(d.mouseover=this._openTooltip,d.mouseout=this.closeTooltip,d.click=this._openTooltip,this._map?this._addFocusListeners():d.add=this._addFocusListeners),this._tooltip.options.sticky&&(d.mousemove=this._moveTooltip),this[a](d),this._tooltipHandlersAdded=!s}},openTooltip:function(s){return this._tooltip&&(this instanceof ni||(this._tooltip._source=this),this._tooltip._prepareOpen(s)&&(this._tooltip.openOn(this._map),this.getElement?this._setAriaDescribedByOnLayer(this):this.eachLayer&&this.eachLayer(this._setAriaDescribedByOnLayer,this))),this},closeTooltip:function(){if(this._tooltip)return this._tooltip.close()},toggleTooltip:function(){return this._tooltip&&this._tooltip.toggle(this),this},isTooltipOpen:function(){return this._tooltip.isOpen()},setTooltipContent:function(s){return this._tooltip&&this._tooltip.setContent(s),this},getTooltip:function(){return this._tooltip},_addFocusListeners:function(){this.getElement?this._addFocusListenersOnLayer(this):this.eachLayer&&this.eachLayer(this._addFocusListenersOnLayer,this)},_addFocusListenersOnLayer:function(s){var a=typeof s.getElement=="function"&&s.getElement();a&&(zt(a,"focus",function(){this._tooltip._source=s,this.openTooltip()},this),zt(a,"blur",this.closeTooltip,this))},_setAriaDescribedByOnLayer:function(s){var a=typeof s.getElement=="function"&&s.getElement();a&&a.setAttribute("aria-describedby",this._tooltip._container.id)},_openTooltip:function(s){if(!(!this._tooltip||!this._map)){if(this._map.dragging&&this._map.dragging.moving()&&!this._openOnceFlag){this._openOnceFlag=!0;var a=this;this._map.once("moveend",function(){a._openOnceFlag=!1,a._openTooltip(s)});return}this._tooltip._source=s.layer||s.target,this.openTooltip(this._tooltip.options.sticky?s.latlng:void 0)}},_moveTooltip:function(s){var a=s.latlng,d,g;this._tooltip.options.sticky&&s.originalEvent&&(d=this._map.mouseEventToContainerPoint(s.originalEvent),g=this._map.containerPointToLayerPoint(d),a=this._map.layerPointToLatLng(g)),this._tooltip.setLatLng(a)}});var Q=ln.extend({options:{iconSize:[12,12],html:!1,bgPos:null,className:"leaflet-div-icon"},createIcon:function(s){var a=s&&s.tagName==="DIV"?s:document.createElement("div"),d=this.options;if(d.html instanceof Element?(ae(a),a.appendChild(d.html)):a.innerHTML=d.html!==!1?d.html:"",d.bgPos){var g=et(d.bgPos);a.style.backgroundPosition=-g.x+"px "+-g.y+"px"}return this._setIconStyles(a,"icon"),a},createShadow:function(){return null}});function mt(s){return new Q(s)}ln.Default=Ki;var G=yn.extend({options:{tileSize:256,opacity:1,updateWhenIdle:gt.mobile,updateWhenZooming:!0,updateInterval:200,zIndex:1,bounds:null,minZoom:0,maxZoom:void 0,maxNativeZoom:void 0,minNativeZoom:void 0,noWrap:!1,pane:"tilePane",className:"",keepBuffer:2},initialize:function(s){p(this,s)},onAdd:function(){this._initContainer(),this._levels={},this._tiles={},this._resetView()},beforeAdd:function(s){s._addZoomLimit(this)},onRemove:function(s){this._removeAllTiles(),Qt(this._container),s._removeZoomLimit(this),this._container=null,this._tileZoom=void 0},bringToFront:function(){return this._map&&(jn(this._container),this._setAutoZIndex(Math.max)),this},bringToBack:function(){return this._map&&(dt(this._container),this._setAutoZIndex(Math.min)),this},getContainer:function(){return this._container},setOpacity:function(s){return this.options.opacity=s,this._updateOpacity(),this},setZIndex:function(s){return this.options.zIndex=s,this._updateZIndex(),this},isLoading:function(){return this._loading},redraw:function(){if(this._map){this._removeAllTiles();var s=this._clampZoom(this._map.getZoom());s!==this._tileZoom&&(this._tileZoom=s,this._updateLevels()),this._update()}return this},getEvents:function(){var s={viewprereset:this._invalidateAll,viewreset:this._resetView,zoom:this._resetView,moveend:this._onMoveEnd};return this.options.updateWhenIdle||(this._onMove||(this._onMove=f(this._onMoveEnd,this.options.updateInterval,this)),s.move=this._onMove),this._zoomAnimated&&(s.zoomanim=this._animateZoom),s},createTile:function(){return document.createElement("div")},getTileSize:function(){var s=this.options.tileSize;return s instanceof J?s:new J(s,s)},_updateZIndex:function(){this._container&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._container.style.zIndex=this.options.zIndex)},_setAutoZIndex:function(s){for(var a=this.getPane().children,d=-s(-1/0,1/0),g=0,b=a.length,C;g<b;g++)C=a[g].style.zIndex,a[g]!==this._container&&C&&(d=s(d,+C));isFinite(d)&&(this.options.zIndex=d+s(-1,1),this._updateZIndex())},_updateOpacity:function(){if(this._map&&!gt.ielt9){mn(this._container,this.options.opacity);var s=+new Date,a=!1,d=!1;for(var g in this._tiles){var b=this._tiles[g];if(!(!b.current||!b.loaded)){var C=Math.min(1,(s-b.loaded)/200);mn(b.el,C),C<1?a=!0:(b.active?d=!0:this._onOpaqueTile(b),b.active=!0)}}d&&!this._noPrune&&this._pruneTiles(),a&&(it(this._fadeFrame),this._fadeFrame=q(this._updateOpacity,this))}},_onOpaqueTile:m,_initContainer:function(){this._container||(this._container=Ct("div","leaflet-layer "+(this.options.className||"")),this._updateZIndex(),this.options.opacity<1&&this._updateOpacity(),this.getPane().appendChild(this._container))},_updateLevels:function(){var s=this._tileZoom,a=this.options.maxZoom;if(s!==void 0){for(var d in this._levels)d=Number(d),this._levels[d].el.children.length||d===s?(this._levels[d].el.style.zIndex=a-Math.abs(s-d),this._onUpdateLevel(d)):(Qt(this._levels[d].el),this._removeTilesAtZoom(d),this._onRemoveLevel(d),delete this._levels[d]);var g=this._levels[s],b=this._map;return g||(g=this._levels[s]={},g.el=Ct("div","leaflet-tile-container leaflet-zoom-animated",this._container),g.el.style.zIndex=a,g.origin=b.project(b.unproject(b.getPixelOrigin()),s).round(),g.zoom=s,this._setZoomTransform(g,b.getCenter(),b.getZoom()),m(g.el.offsetWidth),this._onCreateLevel(g)),this._level=g,g}},_onUpdateLevel:m,_onRemoveLevel:m,_onCreateLevel:m,_pruneTiles:function(){if(this._map){var s,a,d=this._map.getZoom();if(d>this.options.maxZoom||d<this.options.minZoom){this._removeAllTiles();return}for(s in this._tiles)a=this._tiles[s],a.retain=a.current;for(s in this._tiles)if(a=this._tiles[s],a.current&&!a.active){var g=a.coords;this._retainParent(g.x,g.y,g.z,g.z-5)||this._retainChildren(g.x,g.y,g.z,g.z+2)}for(s in this._tiles)this._tiles[s].retain||this._removeTile(s)}},_removeTilesAtZoom:function(s){for(var a in this._tiles)this._tiles[a].coords.z===s&&this._removeTile(a)},_removeAllTiles:function(){for(var s in this._tiles)this._removeTile(s)},_invalidateAll:function(){for(var s in this._levels)Qt(this._levels[s].el),this._onRemoveLevel(Number(s)),delete this._levels[s];this._removeAllTiles(),this._tileZoom=void 0},_retainParent:function(s,a,d,g){var b=Math.floor(s/2),C=Math.floor(a/2),D=d-1,V=new J(+b,+C);V.z=+D;var H=this._tileCoordsToKey(V),rt=this._tiles[H];return rt&&rt.active?(rt.retain=!0,!0):(rt&&rt.loaded&&(rt.retain=!0),D>g?this._retainParent(b,C,D,g):!1)},_retainChildren:function(s,a,d,g){for(var b=2*s;b<2*s+2;b++)for(var C=2*a;C<2*a+2;C++){var D=new J(b,C);D.z=d+1;var V=this._tileCoordsToKey(D),H=this._tiles[V];if(H&&H.active){H.retain=!0;continue}else H&&H.loaded&&(H.retain=!0);d+1<g&&this._retainChildren(b,C,d+1,g)}},_resetView:function(s){var a=s&&(s.pinch||s.flyTo);this._setView(this._map.getCenter(),this._map.getZoom(),a,a)},_animateZoom:function(s){this._setView(s.center,s.zoom,!0,s.noUpdate)},_clampZoom:function(s){var a=this.options;return a.minNativeZoom!==void 0&&s<a.minNativeZoom?a.minNativeZoom:a.maxNativeZoom!==void 0&&a.maxNativeZoom<s?a.maxNativeZoom:s},_setView:function(s,a,d,g){var b=Math.round(a);this.options.maxZoom!==void 0&&b>this.options.maxZoom||this.options.minZoom!==void 0&&b<this.options.minZoom?b=void 0:b=this._clampZoom(b);var C=this.options.updateWhenZooming&&b!==this._tileZoom;(!g||C)&&(this._tileZoom=b,this._abortLoading&&this._abortLoading(),this._updateLevels(),this._resetGrid(),b!==void 0&&this._update(s),d||this._pruneTiles(),this._noPrune=!!d),this._setZoomTransforms(s,a)},_setZoomTransforms:function(s,a){for(var d in this._levels)this._setZoomTransform(this._levels[d],s,a)},_setZoomTransform:function(s,a,d){var g=this._map.getZoomScale(d,s.zoom),b=s.origin.multiplyBy(g).subtract(this._map._getNewPixelOrigin(a,d)).round();gt.any3d?wi(s.el,b,g):xe(s.el,b)},_resetGrid:function(){var s=this._map,a=s.options.crs,d=this._tileSize=this.getTileSize(),g=this._tileZoom,b=this._map.getPixelWorldBounds(this._tileZoom);b&&(this._globalTileRange=this._pxBoundsToTileRange(b)),this._wrapX=a.wrapLng&&!this.options.noWrap&&[Math.floor(s.project([0,a.wrapLng[0]],g).x/d.x),Math.ceil(s.project([0,a.wrapLng[1]],g).x/d.y)],this._wrapY=a.wrapLat&&!this.options.noWrap&&[Math.floor(s.project([a.wrapLat[0],0],g).y/d.x),Math.ceil(s.project([a.wrapLat[1],0],g).y/d.y)]},_onMoveEnd:function(){!this._map||this._map._animatingZoom||this._update()},_getTiledPixelBounds:function(s){var a=this._map,d=a._animatingZoom?Math.max(a._animateToZoom,a.getZoom()):a.getZoom(),g=a.getZoomScale(d,this._tileZoom),b=a.project(s,this._tileZoom).floor(),C=a.getSize().divideBy(g*2);return new ht(b.subtract(C),b.add(C))},_update:function(s){var a=this._map;if(a){var d=this._clampZoom(a.getZoom());if(s===void 0&&(s=a.getCenter()),this._tileZoom!==void 0){var g=this._getTiledPixelBounds(s),b=this._pxBoundsToTileRange(g),C=b.getCenter(),D=[],V=this.options.keepBuffer,H=new ht(b.getBottomLeft().subtract([V,-V]),b.getTopRight().add([V,-V]));if(!(isFinite(b.min.x)&&isFinite(b.min.y)&&isFinite(b.max.x)&&isFinite(b.max.y)))throw new Error("Attempted to load an infinite number of tiles");for(var rt in this._tiles){var pt=this._tiles[rt].coords;(pt.z!==this._tileZoom||!H.contains(new J(pt.x,pt.y)))&&(this._tiles[rt].current=!1)}if(Math.abs(d-this._tileZoom)>1){this._setView(s,d);return}for(var Nt=b.min.y;Nt<=b.max.y;Nt++)for(var Ut=b.min.x;Ut<=b.max.x;Ut++){var cn=new J(Ut,Nt);if(cn.z=this._tileZoom,!!this._isValidTile(cn)){var He=this._tiles[this._tileCoordsToKey(cn)];He?He.current=!0:D.push(cn)}}if(D.sort(function(vn,rr){return vn.distanceTo(C)-rr.distanceTo(C)}),D.length!==0){this._loading||(this._loading=!0,this.fire("loading"));var zn=document.createDocumentFragment();for(Ut=0;Ut<D.length;Ut++)this._addTile(D[Ut],zn);this._level.el.appendChild(zn)}}}},_isValidTile:function(s){var a=this._map.options.crs;if(!a.infinite){var d=this._globalTileRange;if(!a.wrapLng&&(s.x<d.min.x||s.x>d.max.x)||!a.wrapLat&&(s.y<d.min.y||s.y>d.max.y))return!1}if(!this.options.bounds)return!0;var g=this._tileCoordsToBounds(s);return Tt(this.options.bounds).overlaps(g)},_keyToBounds:function(s){return this._tileCoordsToBounds(this._keyToTileCoords(s))},_tileCoordsToNwSe:function(s){var a=this._map,d=this.getTileSize(),g=s.scaleBy(d),b=g.add(d),C=a.unproject(g,s.z),D=a.unproject(b,s.z);return[C,D]},_tileCoordsToBounds:function(s){var a=this._tileCoordsToNwSe(s),d=new St(a[0],a[1]);return this.options.noWrap||(d=this._map.wrapLatLngBounds(d)),d},_tileCoordsToKey:function(s){return s.x+":"+s.y+":"+s.z},_keyToTileCoords:function(s){var a=s.split(":"),d=new J(+a[0],+a[1]);return d.z=+a[2],d},_removeTile:function(s){var a=this._tiles[s];a&&(Qt(a.el),delete this._tiles[s],this.fire("tileunload",{tile:a.el,coords:this._keyToTileCoords(s)}))},_initTile:function(s){xt(s,"leaflet-tile");var a=this.getTileSize();s.style.width=a.x+"px",s.style.height=a.y+"px",s.onselectstart=m,s.onmousemove=m,gt.ielt9&&this.options.opacity<1&&mn(s,this.options.opacity)},_addTile:function(s,a){var d=this._getTilePos(s),g=this._tileCoordsToKey(s),b=this.createTile(this._wrapCoords(s),l(this._tileReady,this,s));this._initTile(b),this.createTile.length<2&&q(l(this._tileReady,this,s,null,b)),xe(b,d),this._tiles[g]={el:b,coords:s,current:!0},a.appendChild(b),this.fire("tileloadstart",{tile:b,coords:s})},_tileReady:function(s,a,d){a&&this.fire("tileerror",{error:a,tile:d,coords:s});var g=this._tileCoordsToKey(s);d=this._tiles[g],d&&(d.loaded=+new Date,this._map._fadeAnimated?(mn(d.el,0),it(this._fadeFrame),this._fadeFrame=q(this._updateOpacity,this)):(d.active=!0,this._pruneTiles()),a||(xt(d.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:d.el,coords:s})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),gt.ielt9||!this._map._fadeAnimated?q(this._pruneTiles,this):setTimeout(l(this._pruneTiles,this),250)))},_getTilePos:function(s){return s.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(s){var a=new J(this._wrapX?c(s.x,this._wrapX):s.x,this._wrapY?c(s.y,this._wrapY):s.y);return a.z=s.z,a},_pxBoundsToTileRange:function(s){var a=this.getTileSize();return new ht(s.min.unscaleBy(a).floor(),s.max.unscaleBy(a).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var s in this._tiles)if(!this._tiles[s].loaded)return!1;return!0}});function ft(s){return new G(s)}var Pt=G.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:!1},initialize:function(s,a){this._url=s,a=p(this,a),a.detectRetina&&gt.retina&&a.maxZoom>0?(a.tileSize=Math.floor(a.tileSize/2),a.zoomReverse?(a.zoomOffset--,a.minZoom=Math.min(a.maxZoom,a.minZoom+1)):(a.zoomOffset++,a.maxZoom=Math.max(a.minZoom,a.maxZoom-1)),a.minZoom=Math.max(0,a.minZoom)):a.zoomReverse?a.minZoom=Math.min(a.maxZoom,a.minZoom):a.maxZoom=Math.max(a.minZoom,a.maxZoom),typeof a.subdomains=="string"&&(a.subdomains=a.subdomains.split("")),this.on("tileunload",this._onTileRemove)},setUrl:function(s,a){return this._url===s&&a===void 0&&(a=!0),this._url=s,a||this.redraw(),this},createTile:function(s,a){var d=document.createElement("img");return zt(d,"load",l(this._tileOnLoad,this,a,d)),zt(d,"error",l(this._tileOnError,this,a,d)),(this.options.crossOrigin||this.options.crossOrigin==="")&&(d.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),typeof this.options.referrerPolicy=="string"&&(d.referrerPolicy=this.options.referrerPolicy),d.alt="",d.src=this.getTileUrl(s),d},getTileUrl:function(s){var a={r:gt.retina?"@2x":"",s:this._getSubdomain(s),x:s.x,y:s.y,z:this._getZoomForUrl()};if(this._map&&!this._map.options.crs.infinite){var d=this._globalTileRange.max.y-s.y;this.options.tms&&(a.y=d),a["-y"]=d}return k(this._url,r(a,this.options))},_tileOnLoad:function(s,a){gt.ielt9?setTimeout(l(s,this,null,a),0):s(null,a)},_tileOnError:function(s,a,d){var g=this.options.errorTileUrl;g&&a.getAttribute("src")!==g&&(a.src=g),s(d,a)},_onTileRemove:function(s){s.tile.onload=null},_getZoomForUrl:function(){var s=this._tileZoom,a=this.options.maxZoom,d=this.options.zoomReverse,g=this.options.zoomOffset;return d&&(s=a-s),s+g},_getSubdomain:function(s){var a=Math.abs(s.x+s.y)%this.options.subdomains.length;return this.options.subdomains[a]},_abortLoading:function(){var s,a;for(s in this._tiles)if(this._tiles[s].coords.z!==this._tileZoom&&(a=this._tiles[s].el,a.onload=m,a.onerror=m,!a.complete)){a.src=I;var d=this._tiles[s].coords;Qt(a),delete this._tiles[s],this.fire("tileabort",{tile:a,coords:d})}},_removeTile:function(s){var a=this._tiles[s];if(a)return a.el.setAttribute("src",I),G.prototype._removeTile.call(this,s)},_tileReady:function(s,a,d){if(!(!this._map||d&&d.getAttribute("src")===I))return G.prototype._tileReady.call(this,s,a,d)}});function Y(s,a){return new Pt(s,a)}var wt=Pt.extend({defaultWmsParams:{service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"},options:{crs:null,uppercase:!1},initialize:function(s,a){this._url=s;var d=r({},this.defaultWmsParams);for(var g in a)g in this.options||(d[g]=a[g]);a=p(this,a);var b=a.detectRetina&&gt.retina?2:1,C=this.getTileSize();d.width=C.x*b,d.height=C.y*b,this.wmsParams=d},onAdd:function(s){this._crs=this.options.crs||s.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var a=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[a]=this._crs.code,Pt.prototype.onAdd.call(this,s)},getTileUrl:function(s){var a=this._tileCoordsToNwSe(s),d=this._crs,g=kt(d.project(a[0]),d.project(a[1])),b=g.min,C=g.max,D=(this._wmsVersion>=1.3&&this._crs===Fr?[b.y,b.x,C.y,C.x]:[b.x,b.y,C.x,C.y]).join(","),V=Pt.prototype.getTileUrl.call(this,s);return V+E(this.wmsParams,V,this.options.uppercase)+(this.options.uppercase?"&BBOX=":"&bbox=")+D},setParams:function(s,a){return r(this.wmsParams,s),a||this.redraw(),this}});function _t(s,a){return new wt(s,a)}Pt.WMS=wt,Y.wms=_t;var Vt=yn.extend({options:{padding:.1},initialize:function(s){p(this,s),u(this),this._layers=this._layers||{}},onAdd:function(){this._container||(this._initContainer(),xt(this._container,"leaflet-zoom-animated")),this.getPane().appendChild(this._container),this._update(),this.on("update",this._updatePaths,this)},onRemove:function(){this.off("update",this._updatePaths,this),this._destroyContainer()},getEvents:function(){var s={viewreset:this._reset,zoom:this._onZoom,moveend:this._update,zoomend:this._onZoomEnd};return this._zoomAnimated&&(s.zoomanim=this._onAnimZoom),s},_onAnimZoom:function(s){this._updateTransform(s.center,s.zoom)},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_updateTransform:function(s,a){var d=this._map.getZoomScale(a,this._zoom),g=this._map.getSize().multiplyBy(.5+this.options.padding),b=this._map.project(this._center,a),C=g.multiplyBy(-d).add(b).subtract(this._map._getNewPixelOrigin(s,a));gt.any3d?wi(this._container,C,d):xe(this._container,C)},_reset:function(){this._update(),this._updateTransform(this._center,this._zoom);for(var s in this._layers)this._layers[s]._reset()},_onZoomEnd:function(){for(var s in this._layers)this._layers[s]._project()},_updatePaths:function(){for(var s in this._layers)this._layers[s]._update()},_update:function(){var s=this.options.padding,a=this._map.getSize(),d=this._map.containerPointToLayerPoint(a.multiplyBy(-s)).round();this._bounds=new ht(d,d.add(a.multiplyBy(1+s*2)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}}),ne=Vt.extend({options:{tolerance:0},getEvents:function(){var s=Vt.prototype.getEvents.call(this);return s.viewprereset=this._onViewPreReset,s},_onViewPreReset:function(){this._postponeUpdatePaths=!0},onAdd:function(){Vt.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var s=this._container=document.createElement("canvas");zt(s,"mousemove",this._onMouseMove,this),zt(s,"click dblclick mousedown mouseup contextmenu",this._onClick,this),zt(s,"mouseout",this._handleMouseOut,this),s._leaflet_disable_events=!0,this._ctx=s.getContext("2d")},_destroyContainer:function(){it(this._redrawRequest),delete this._ctx,Qt(this._container),le(this._container),delete this._container},_updatePaths:function(){if(!this._postponeUpdatePaths){var s;this._redrawBounds=null;for(var a in this._layers)s=this._layers[a],s._update();this._redraw()}},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){Vt.prototype._update.call(this);var s=this._bounds,a=this._container,d=s.getSize(),g=gt.retina?2:1;xe(a,s.min),a.width=g*d.x,a.height=g*d.y,a.style.width=d.x+"px",a.style.height=d.y+"px",gt.retina&&this._ctx.scale(2,2),this._ctx.translate(-s.min.x,-s.min.y),this.fire("update")}},_reset:function(){Vt.prototype._reset.call(this),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())},_initPath:function(s){this._updateDashArray(s),this._layers[u(s)]=s;var a=s._order={layer:s,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=a),this._drawLast=a,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(s){this._requestRedraw(s)},_removePath:function(s){var a=s._order,d=a.next,g=a.prev;d?d.prev=g:this._drawLast=g,g?g.next=d:this._drawFirst=d,delete s._order,delete this._layers[u(s)],this._requestRedraw(s)},_updatePath:function(s){this._extendRedrawBounds(s),s._project(),s._update(),this._requestRedraw(s)},_updateStyle:function(s){this._updateDashArray(s),this._requestRedraw(s)},_updateDashArray:function(s){if(typeof s.options.dashArray=="string"){var a=s.options.dashArray.split(/[, ]+/),d=[],g,b;for(b=0;b<a.length;b++){if(g=Number(a[b]),isNaN(g))return;d.push(g)}s.options._dashArray=d}else s.options._dashArray=s.options.dashArray},_requestRedraw:function(s){this._map&&(this._extendRedrawBounds(s),this._redrawRequest=this._redrawRequest||q(this._redraw,this))},_extendRedrawBounds:function(s){if(s._pxBounds){var a=(s.options.weight||0)+1;this._redrawBounds=this._redrawBounds||new ht,this._redrawBounds.extend(s._pxBounds.min.subtract([a,a])),this._redrawBounds.extend(s._pxBounds.max.add([a,a]))}},_redraw:function(){this._redrawRequest=null,this._redrawBounds&&(this._redrawBounds.min._floor(),this._redrawBounds.max._ceil()),this._clear(),this._draw(),this._redrawBounds=null},_clear:function(){var s=this._redrawBounds;if(s){var a=s.getSize();this._ctx.clearRect(s.min.x,s.min.y,a.x,a.y)}else this._ctx.save(),this._ctx.setTransform(1,0,0,1,0,0),this._ctx.clearRect(0,0,this._container.width,this._container.height),this._ctx.restore()},_draw:function(){var s,a=this._redrawBounds;if(this._ctx.save(),a){var d=a.getSize();this._ctx.beginPath(),this._ctx.rect(a.min.x,a.min.y,d.x,d.y),this._ctx.clip()}this._drawing=!0;for(var g=this._drawFirst;g;g=g.next)s=g.layer,(!a||s._pxBounds&&s._pxBounds.intersects(a))&&s._updatePath();this._drawing=!1,this._ctx.restore()},_updatePoly:function(s,a){if(this._drawing){var d,g,b,C,D=s._parts,V=D.length,H=this._ctx;if(V){for(H.beginPath(),d=0;d<V;d++){for(g=0,b=D[d].length;g<b;g++)C=D[d][g],H[g?"lineTo":"moveTo"](C.x,C.y);a&&H.closePath()}this._fillStroke(H,s)}}},_updateCircle:function(s){if(!(!this._drawing||s._empty())){var a=s._point,d=this._ctx,g=Math.max(Math.round(s._radius),1),b=(Math.max(Math.round(s._radiusY),1)||g)/g;b!==1&&(d.save(),d.scale(1,b)),d.beginPath(),d.arc(a.x,a.y/b,g,0,Math.PI*2,!1),b!==1&&d.restore(),this._fillStroke(d,s)}},_fillStroke:function(s,a){var d=a.options;d.fill&&(s.globalAlpha=d.fillOpacity,s.fillStyle=d.fillColor||d.color,s.fill(d.fillRule||"evenodd")),d.stroke&&d.weight!==0&&(s.setLineDash&&s.setLineDash(a.options&&a.options._dashArray||[]),s.globalAlpha=d.opacity,s.lineWidth=d.weight,s.strokeStyle=d.color,s.lineCap=d.lineCap,s.lineJoin=d.lineJoin,s.stroke())},_onClick:function(s){for(var a=this._map.mouseEventToLayerPoint(s),d,g,b=this._drawFirst;b;b=b.next)d=b.layer,d.options.interactive&&d._containsPoint(a)&&(!(s.type==="click"||s.type==="preclick")||!this._map._draggableMoved(d))&&(g=d);this._fireEvent(g?[g]:!1,s)},_onMouseMove:function(s){if(!(!this._map||this._map.dragging.moving()||this._map._animatingZoom)){var a=this._map.mouseEventToLayerPoint(s);this._handleMouseHover(s,a)}},_handleMouseOut:function(s){var a=this._hoveredLayer;a&&(Bt(this._container,"leaflet-interactive"),this._fireEvent([a],s,"mouseout"),this._hoveredLayer=null,this._mouseHoverThrottled=!1)},_handleMouseHover:function(s,a){if(!this._mouseHoverThrottled){for(var d,g,b=this._drawFirst;b;b=b.next)d=b.layer,d.options.interactive&&d._containsPoint(a)&&(g=d);g!==this._hoveredLayer&&(this._handleMouseOut(s),g&&(xt(this._container,"leaflet-interactive"),this._fireEvent([g],s,"mouseover"),this._hoveredLayer=g)),this._fireEvent(this._hoveredLayer?[this._hoveredLayer]:!1,s),this._mouseHoverThrottled=!0,setTimeout(l(function(){this._mouseHoverThrottled=!1},this),32)}},_fireEvent:function(s,a,d){this._map._fireDOMEvent(a,d||a.type,s)},_bringToFront:function(s){var a=s._order;if(a){var d=a.next,g=a.prev;if(d)d.prev=g;else return;g?g.next=d:d&&(this._drawFirst=d),a.prev=this._drawLast,this._drawLast.next=a,a.next=null,this._drawLast=a,this._requestRedraw(s)}},_bringToBack:function(s){var a=s._order;if(a){var d=a.next,g=a.prev;if(g)g.next=d;else return;d?d.prev=g:g&&(this._drawLast=g),a.prev=null,a.next=this._drawFirst,this._drawFirst.prev=a,this._drawFirst=a,this._requestRedraw(s)}}});function je(s){return gt.canvas?new ne(s):null}var Me=function(){try{return document.namespaces.add("lvml","urn:schemas-microsoft-com:vml"),function(s){return document.createElement("<lvml:"+s+' class="lvml">')}}catch{}return function(s){return document.createElement("<"+s+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}(),ks={_initContainer:function(){this._container=Ct("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(Vt.prototype._update.call(this),this.fire("update"))},_initPath:function(s){var a=s._container=Me("shape");xt(a,"leaflet-vml-shape "+(this.options.className||"")),a.coordsize="1 1",s._path=Me("path"),a.appendChild(s._path),this._updateStyle(s),this._layers[u(s)]=s},_addPath:function(s){var a=s._container;this._container.appendChild(a),s.options.interactive&&s.addInteractiveTarget(a)},_removePath:function(s){var a=s._container;Qt(a),s.removeInteractiveTarget(a),delete this._layers[u(s)]},_updateStyle:function(s){var a=s._stroke,d=s._fill,g=s.options,b=s._container;b.stroked=!!g.stroke,b.filled=!!g.fill,g.stroke?(a||(a=s._stroke=Me("stroke")),b.appendChild(a),a.weight=g.weight+"px",a.color=g.color,a.opacity=g.opacity,g.dashArray?a.dashStyle=A(g.dashArray)?g.dashArray.join(" "):g.dashArray.replace(/( *, *)/g," "):a.dashStyle="",a.endcap=g.lineCap.replace("butt","flat"),a.joinstyle=g.lineJoin):a&&(b.removeChild(a),s._stroke=null),g.fill?(d||(d=s._fill=Me("fill")),b.appendChild(d),d.color=g.fillColor||g.color,d.opacity=g.fillOpacity):d&&(b.removeChild(d),s._fill=null)},_updateCircle:function(s){var a=s._point.round(),d=Math.round(s._radius),g=Math.round(s._radiusY||d);this._setPath(s,s._empty()?"M0 0":"AL "+a.x+","+a.y+" "+d+","+g+" 0,"+65535*360)},_setPath:function(s,a){s._path.v=a},_bringToFront:function(s){jn(s._container)},_bringToBack:function(s){dt(s._container)}},Ti=gt.vml?Me:Ee,ue=Vt.extend({_initContainer:function(){this._container=Ti("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=Ti("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){Qt(this._container),le(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){Vt.prototype._update.call(this);var s=this._bounds,a=s.getSize(),d=this._container;(!this._svgSize||!this._svgSize.equals(a))&&(this._svgSize=a,d.setAttribute("width",a.x),d.setAttribute("height",a.y)),xe(d,s.min),d.setAttribute("viewBox",[s.min.x,s.min.y,a.x,a.y].join(" ")),this.fire("update")}},_initPath:function(s){var a=s._path=Ti("path");s.options.className&&xt(a,s.options.className),s.options.interactive&&xt(a,"leaflet-interactive"),this._updateStyle(s),this._layers[u(s)]=s},_addPath:function(s){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(s._path),s.addInteractiveTarget(s._path)},_removePath:function(s){Qt(s._path),s.removeInteractiveTarget(s._path),delete this._layers[u(s)]},_updatePath:function(s){s._project(),s._update()},_updateStyle:function(s){var a=s._path,d=s.options;a&&(d.stroke?(a.setAttribute("stroke",d.color),a.setAttribute("stroke-opacity",d.opacity),a.setAttribute("stroke-width",d.weight),a.setAttribute("stroke-linecap",d.lineCap),a.setAttribute("stroke-linejoin",d.lineJoin),d.dashArray?a.setAttribute("stroke-dasharray",d.dashArray):a.removeAttribute("stroke-dasharray"),d.dashOffset?a.setAttribute("stroke-dashoffset",d.dashOffset):a.removeAttribute("stroke-dashoffset")):a.setAttribute("stroke","none"),d.fill?(a.setAttribute("fill",d.fillColor||d.color),a.setAttribute("fill-opacity",d.fillOpacity),a.setAttribute("fill-rule",d.fillRule||"evenodd")):a.setAttribute("fill","none"))},_updatePoly:function(s,a){this._setPath(s,Ft(s._parts,a))},_updateCircle:function(s){var a=s._point,d=Math.max(Math.round(s._radius),1),g=Math.max(Math.round(s._radiusY),1)||d,b="a"+d+","+g+" 0 1,0 ",C=s._empty()?"M0 0":"M"+(a.x-d)+","+a.y+b+d*2+",0 "+b+-d*2+",0 ";this._setPath(s,C)},_setPath:function(s,a){s._path.setAttribute("d",a)},_bringToFront:function(s){jn(s._path)},_bringToBack:function(s){dt(s._path)}});gt.vml&&ue.include(ks);function te(s){return gt.svg||gt.vml?new ue(s):null}Zt.include({getRenderer:function(s){var a=s.options.renderer||this._getPaneRenderer(s.options.pane)||this.options.renderer||this._renderer;return a||(a=this._renderer=this._createRenderer()),this.hasLayer(a)||this.addLayer(a),a},_getPaneRenderer:function(s){if(s==="overlayPane"||s===void 0)return!1;var a=this._paneRenderers[s];return a===void 0&&(a=this._createRenderer({pane:s}),this._paneRenderers[s]=a),a},_createRenderer:function(s){return this.options.preferCanvas&&je(s)||te(s)}});var we=Mi.extend({initialize:function(s,a){Mi.prototype.initialize.call(this,this._boundsToLatLngs(s),a)},setBounds:function(s){return this.setLatLngs(this._boundsToLatLngs(s))},_boundsToLatLngs:function(s){return s=Tt(s),[s.getSouthWest(),s.getNorthWest(),s.getNorthEast(),s.getSouthEast()]}});function yt(s,a){return new we(s,a)}ue.create=Ti,ue.pointsToPath=Ft,In.geometryToLayer=ws,In.coordsToLatLng=er,In.coordsToLatLngs=Ss,In.latLngToCoords=nr,In.latLngsToCoords=Cs,In.getFeature=ki,In.asFeature=Ms,Zt.mergeOptions({boxZoom:!0});var Dt=Rn.extend({initialize:function(s){this._map=s,this._container=s._container,this._pane=s._panes.overlayPane,this._resetStateTimeout=0,s.on("unload",this._destroy,this)},addHooks:function(){zt(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){le(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){Qt(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){this._resetStateTimeout!==0&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(s){if(!s.shiftKey||s.which!==1&&s.button!==1)return!1;this._clearDeferredResetState(),this._resetState(),tn(),Hn(),this._startPoint=this._map.mouseEventToContainerPoint(s),zt(document,{contextmenu:pn,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(s){this._moved||(this._moved=!0,this._box=Ct("div","leaflet-zoom-box",this._container),xt(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(s);var a=new ht(this._point,this._startPoint),d=a.getSize();xe(this._box,a.min),this._box.style.width=d.x+"px",this._box.style.height=d.y+"px"},_finish:function(){this._moved&&(Qt(this._box),Bt(this._container,"leaflet-crosshair")),se(),ps(),le(document,{contextmenu:pn,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(s){if(!(s.which!==1&&s.button!==1)&&(this._finish(),!!this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(l(this._resetState,this),0);var a=new St(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(a).fire("boxzoomend",{boxZoomBounds:a})}},_onKeyDown:function(s){s.keyCode===27&&(this._finish(),this._clearDeferredResetState(),this._resetState())}});Zt.addInitHook("addHandler","boxZoom",Dt),Zt.mergeOptions({doubleClickZoom:!0});var Xt=Rn.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(s){var a=this._map,d=a.getZoom(),g=a.options.zoomDelta,b=s.originalEvent.shiftKey?d-g:d+g;a.options.doubleClickZoom==="center"?a.setZoom(b):a.setZoomAround(s.containerPoint,b)}});Zt.addInitHook("addHandler","doubleClickZoom",Xt),Zt.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var Cn=Rn.extend({addHooks:function(){if(!this._draggable){var s=this._map;this._draggable=new ei(s._mapPane,s._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),s.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),s.on("zoomend",this._onZoomEnd,this),s.whenReady(this._onZoomEnd,this))}xt(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){Bt(this._map._container,"leaflet-grab"),Bt(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var s=this._map;if(s._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var a=Tt(this._map.options.maxBounds);this._offsetLimit=kt(this._map.latLngToContainerPoint(a.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(a.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;s.fire("movestart").fire("dragstart"),s.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(s){if(this._map.options.inertia){var a=this._lastTime=+new Date,d=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(d),this._times.push(a),this._prunePositions(a)}this._map.fire("move",s).fire("drag",s)},_prunePositions:function(s){for(;this._positions.length>1&&s-this._times[0]>50;)this._positions.shift(),this._times.shift()},_onZoomEnd:function(){var s=this._map.getSize().divideBy(2),a=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=a.subtract(s).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(s,a){return s-(s-a)*this._viscosity},_onPreDragLimit:function(){if(!(!this._viscosity||!this._offsetLimit)){var s=this._draggable._newPos.subtract(this._draggable._startPos),a=this._offsetLimit;s.x<a.min.x&&(s.x=this._viscousLimit(s.x,a.min.x)),s.y<a.min.y&&(s.y=this._viscousLimit(s.y,a.min.y)),s.x>a.max.x&&(s.x=this._viscousLimit(s.x,a.max.x)),s.y>a.max.y&&(s.y=this._viscousLimit(s.y,a.max.y)),this._draggable._newPos=this._draggable._startPos.add(s)}},_onPreDragWrap:function(){var s=this._worldWidth,a=Math.round(s/2),d=this._initialWorldOffset,g=this._draggable._newPos.x,b=(g-a+d)%s+a-d,C=(g+a+d)%s-a-d,D=Math.abs(b+d)<Math.abs(C+d)?b:C;this._draggable._absPos=this._draggable._newPos.clone(),this._draggable._newPos.x=D},_onDragEnd:function(s){var a=this._map,d=a.options,g=!d.inertia||s.noInertia||this._times.length<2;if(a.fire("dragend",s),g)a.fire("moveend");else{this._prunePositions(+new Date);var b=this._lastPos.subtract(this._positions[0]),C=(this._lastTime-this._times[0])/1e3,D=d.easeLinearity,V=b.multiplyBy(D/C),H=V.distanceTo([0,0]),rt=Math.min(d.inertiaMaxSpeed,H),pt=V.multiplyBy(rt/H),Nt=rt/(d.inertiaDeceleration*D),Ut=pt.multiplyBy(-Nt/2).round();!Ut.x&&!Ut.y?a.fire("moveend"):(Ut=a._limitOffset(Ut,a.options.maxBounds),q(function(){a.panBy(Ut,{duration:Nt,easeLinearity:D,noMoveStart:!0,animate:!0})}))}}});Zt.addInitHook("addHandler","dragging",Cn),Zt.mergeOptions({keyboard:!0,keyboardPanDelta:80});var si=Rn.extend({keyCodes:{left:[37],right:[39],down:[40],up:[38],zoomIn:[187,107,61,171],zoomOut:[189,109,54,173]},initialize:function(s){this._map=s,this._setPanDelta(s.options.keyboardPanDelta),this._setZoomDelta(s.options.zoomDelta)},addHooks:function(){var s=this._map._container;s.tabIndex<=0&&(s.tabIndex="0"),zt(s,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.on({focus:this._addHooks,blur:this._removeHooks},this)},removeHooks:function(){this._removeHooks(),le(this._map._container,{focus:this._onFocus,blur:this._onBlur,mousedown:this._onMouseDown},this),this._map.off({focus:this._addHooks,blur:this._removeHooks},this)},_onMouseDown:function(){if(!this._focused){var s=document.body,a=document.documentElement,d=s.scrollTop||a.scrollTop,g=s.scrollLeft||a.scrollLeft;this._map._container.focus(),window.scrollTo(g,d)}},_onFocus:function(){this._focused=!0,this._map.fire("focus")},_onBlur:function(){this._focused=!1,this._map.fire("blur")},_setPanDelta:function(s){var a=this._panKeys={},d=this.keyCodes,g,b;for(g=0,b=d.left.length;g<b;g++)a[d.left[g]]=[-1*s,0];for(g=0,b=d.right.length;g<b;g++)a[d.right[g]]=[s,0];for(g=0,b=d.down.length;g<b;g++)a[d.down[g]]=[0,s];for(g=0,b=d.up.length;g<b;g++)a[d.up[g]]=[0,-1*s]},_setZoomDelta:function(s){var a=this._zoomKeys={},d=this.keyCodes,g,b;for(g=0,b=d.zoomIn.length;g<b;g++)a[d.zoomIn[g]]=s;for(g=0,b=d.zoomOut.length;g<b;g++)a[d.zoomOut[g]]=-s},_addHooks:function(){zt(document,"keydown",this._onKeyDown,this)},_removeHooks:function(){le(document,"keydown",this._onKeyDown,this)},_onKeyDown:function(s){if(!(s.altKey||s.ctrlKey||s.metaKey)){var a=s.keyCode,d=this._map,g;if(a in this._panKeys){if(!d._panAnim||!d._panAnim._inProgress)if(g=this._panKeys[a],s.shiftKey&&(g=et(g).multiplyBy(3)),d.options.maxBounds&&(g=d._limitOffset(et(g),d.options.maxBounds)),d.options.worldCopyJump){var b=d.wrapLatLng(d.unproject(d.project(d.getCenter()).add(g)));d.panTo(b)}else d.panBy(g)}else if(a in this._zoomKeys)d.setZoom(d.getZoom()+(s.shiftKey?3:1)*this._zoomKeys[a]);else if(a===27&&d._popup&&d._popup.options.closeOnEscapeKey)d.closePopup();else return;pn(s)}}});Zt.addInitHook("addHandler","keyboard",si),Zt.mergeOptions({scrollWheelZoom:!0,wheelDebounceTime:40,wheelPxPerZoomLevel:60});var ri=Rn.extend({addHooks:function(){zt(this._map._container,"wheel",this._onWheelScroll,this),this._delta=0},removeHooks:function(){le(this._map._container,"wheel",this._onWheelScroll,this)},_onWheelScroll:function(s){var a=Zs(s),d=this._map.options.wheelDebounceTime;this._delta+=a,this._lastMousePos=this._map.mouseEventToContainerPoint(s),this._startTime||(this._startTime=+new Date);var g=Math.max(d-(+new Date-this._startTime),0);clearTimeout(this._timer),this._timer=setTimeout(l(this._performZoom,this),g),pn(s)},_performZoom:function(){var s=this._map,a=s.getZoom(),d=this._map.options.zoomSnap||0;s._stop();var g=this._delta/(this._map.options.wheelPxPerZoomLevel*4),b=4*Math.log(2/(1+Math.exp(-Math.abs(g))))/Math.LN2,C=d?Math.ceil(b/d)*d:b,D=s._limitZoom(a+(this._delta>0?C:-C))-a;this._delta=0,this._startTime=null,D&&(s.options.scrollWheelZoom==="center"?s.setZoom(a+D):s.setZoomAround(this._lastMousePos,a+D))}});Zt.addInitHook("addHandler","scrollWheelZoom",ri);var Ge=600;Zt.mergeOptions({tapHold:gt.touchNative&&gt.safari&&gt.mobile,tapTolerance:15});var Hr=Rn.extend({addHooks:function(){zt(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){le(this._map._container,"touchstart",this._onDown,this)},_onDown:function(s){if(clearTimeout(this._holdTimeout),s.touches.length===1){var a=s.touches[0];this._startPos=this._newPos=new J(a.clientX,a.clientY),this._holdTimeout=setTimeout(l(function(){this._cancel(),this._isTapValid()&&(zt(document,"touchend",Oe),zt(document,"touchend touchcancel",this._cancelClickPrevent),this._simulateEvent("contextmenu",a))},this),Ge),zt(document,"touchend touchcancel contextmenu",this._cancel,this),zt(document,"touchmove",this._onMove,this)}},_cancelClickPrevent:function s(){le(document,"touchend",Oe),le(document,"touchend touchcancel",s)},_cancel:function(){clearTimeout(this._holdTimeout),le(document,"touchend touchcancel contextmenu",this._cancel,this),le(document,"touchmove",this._onMove,this)},_onMove:function(s){var a=s.touches[0];this._newPos=new J(a.clientX,a.clientY)},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_simulateEvent:function(s,a){var d=new MouseEvent(s,{bubbles:!0,cancelable:!0,view:window,screenX:a.screenX,screenY:a.screenY,clientX:a.clientX,clientY:a.clientY});d._simulated=!0,a.target.dispatchEvent(d)}});Zt.addInitHook("addHandler","tapHold",Hr),Zt.mergeOptions({touchZoom:gt.touch,bounceAtZoomLimits:!0});var Yn=Rn.extend({addHooks:function(){xt(this._map._container,"leaflet-touch-zoom"),zt(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){Bt(this._map._container,"leaflet-touch-zoom"),le(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(s){var a=this._map;if(!(!s.touches||s.touches.length!==2||a._animatingZoom||this._zooming)){var d=a.mouseEventToContainerPoint(s.touches[0]),g=a.mouseEventToContainerPoint(s.touches[1]);this._centerPoint=a.getSize()._divideBy(2),this._startLatLng=a.containerPointToLatLng(this._centerPoint),a.options.touchZoom!=="center"&&(this._pinchStartLatLng=a.containerPointToLatLng(d.add(g)._divideBy(2))),this._startDist=d.distanceTo(g),this._startZoom=a.getZoom(),this._moved=!1,this._zooming=!0,a._stop(),zt(document,"touchmove",this._onTouchMove,this),zt(document,"touchend touchcancel",this._onTouchEnd,this),Oe(s)}},_onTouchMove:function(s){if(!(!s.touches||s.touches.length!==2||!this._zooming)){var a=this._map,d=a.mouseEventToContainerPoint(s.touches[0]),g=a.mouseEventToContainerPoint(s.touches[1]),b=d.distanceTo(g)/this._startDist;if(this._zoom=a.getScaleZoom(b,this._startZoom),!a.options.bounceAtZoomLimits&&(this._zoom<a.getMinZoom()&&b<1||this._zoom>a.getMaxZoom()&&b>1)&&(this._zoom=a._limitZoom(this._zoom)),a.options.touchZoom==="center"){if(this._center=this._startLatLng,b===1)return}else{var C=d._add(g)._divideBy(2)._subtract(this._centerPoint);if(b===1&&C.x===0&&C.y===0)return;this._center=a.unproject(a.project(this._pinchStartLatLng,this._zoom).subtract(C),this._zoom)}this._moved||(a._moveStart(!0,!1),this._moved=!0),it(this._animRequest);var D=l(a._move,a,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=q(D,this,!0),Oe(s)}},_onTouchEnd:function(){if(!this._moved||!this._zooming){this._zooming=!1;return}this._zooming=!1,it(this._animRequest),le(document,"touchmove",this._onTouchMove,this),le(document,"touchend touchcancel",this._onTouchEnd,this),this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom))}});Zt.addInitHook("addHandler","touchZoom",Yn),Zt.BoxZoom=Dt,Zt.DoubleClickZoom=Xt,Zt.Drag=Cn,Zt.Keyboard=si,Zt.ScrollWheelZoom=ri,Zt.TapHold=Hr,Zt.TouchZoom=Yn,n.Bounds=ht,n.Browser=gt,n.CRS=re,n.Canvas=ne,n.Circle=Wr,n.CircleMarker=tr,n.Class=K,n.Control=Fe,n.DivIcon=Q,n.DivOverlay=F,n.DomEvent=Xi,n.DomUtil=Ln,n.Draggable=ei,n.Evented=st,n.FeatureGroup=ni,n.GeoJSON=In,n.GridLayer=G,n.Handler=Rn,n.Icon=ln,n.ImageOverlay=M,n.LatLng=Rt,n.LatLngBounds=St,n.Layer=yn,n.LayerGroup=_s,n.LineUtil=xs,n.Map=Zt,n.Marker=Ks,n.Mixin=Ga,n.Path=ii,n.Point=J,n.PolyUtil=gn,n.Polygon=Mi,n.Polyline=Gn,n.Popup=W,n.PosAnimation=To,n.Projection=Js,n.Rectangle=we,n.Renderer=Vt,n.SVG=ue,n.SVGOverlay=z,n.TileLayer=Pt,n.Tooltip=lt,n.Transformation=Qe,n.Util=ct,n.VideoOverlay=B,n.bind=l,n.bounds=kt,n.canvas=je,n.circle=tl,n.circleMarker=Sh,n.control=_e,n.divIcon=mt,n.extend=r,n.featureGroup=Qa,n.geoJSON=jr,n.geoJson=w,n.gridLayer=ft,n.icon=Bo,n.imageOverlay=S,n.latLng=Et,n.latLngBounds=Tt,n.layerGroup=Ja,n.map=Po,n.marker=Ka,n.point=et,n.polygon=Oo,n.polyline=el,n.popup=X,n.rectangle=yt,n.setOptions=p,n.stamp=u,n.svg=te,n.svgOverlay=O,n.tileLayer=Y,n.tooltip=at,n.transformation=ye,n.version=i,n.videoOverlay=R;var sr=window.L;n.noConflict=function(){return window.L=sr,this},window.L=n})})(gc,gc.exports);var Ws=gc.exports;function Lr(e,t,n){return Object.freeze({instance:e,context:t,container:n})}function _h(e,t){return t==null?function(i,r){const o=v.useRef();return o.current||(o.current=e(i,r)),o}:function(i,r){const o=v.useRef();o.current||(o.current=e(i,r));const l=v.useRef(i),{instance:h}=o.current;return v.useEffect(function(){l.current!==i&&(t(h,i,l.current),l.current=i)},[h,i,r]),o}}function Lp(e,t){v.useEffect(function(){return(t.layerContainer??t.map).addLayer(e.instance),function(){var o;(o=t.layerContainer)==null||o.removeLayer(e.instance),t.map.removeLayer(e.instance)}},[t,e])}function K1(e){return function(n){const i=Za(),r=e(Ua(n,i),i);return kp(i.map,n.attribution),xh(r.current,n.eventHandlers),Lp(r.current,i),r}}function tS(e,t){const n=v.useRef();v.useEffect(function(){if(t.pathOptions!==n.current){const r=t.pathOptions??{};e.instance.setStyle(r),n.current=r}},[e,t])}function eS(e){return function(n){const i=Za(),r=e(Ua(n,i),i);return xh(r.current,n.eventHandlers),Lp(r.current,i),tS(r.current,n),r}}function nS(e,t){const n=_h(e),i=J1(n,t);return Y1(i)}function qa(e,t){const n=_h(e,t),i=eS(n);return G1(i)}function iS(e,t){const n=_h(e,t),i=K1(n);return X1(i)}function sS(e,t,n){const{opacity:i,zIndex:r}=t;i!=null&&i!==n.opacity&&e.setOpacity(i),r!=null&&r!==n.zIndex&&e.setZIndex(r)}function Ap(){return Za().map}function rS(e){const t=Ap();return v.useEffect(function(){return t.on(e),function(){t.off(e)}},[t,e]),t}const oS=qa(function({center:t,children:n,...i},r){const o=new Ws.Circle(t,i);return Lr(o,Ha(r,{overlayContainer:o}))},Tp),aS=qa(function({center:t,children:n,...i},r){const o=new Ws.CircleMarker(t,i);return Lr(o,Ha(r,{overlayContainer:o}))},Tp);function yc(){return yc=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},yc.apply(this,arguments)}function lS({bounds:e,boundsOptions:t,center:n,children:i,className:r,id:o,placeholder:l,style:h,whenReady:u,zoom:f,...c},m){const[y]=v.useState({className:r,id:o,style:h}),[x,_]=v.useState(null);v.useImperativeHandle(m,()=>(x==null?void 0:x.map)??null,[x]);const p=v.useCallback(T=>{if(T!==null&&x===null){const k=new Ws.Map(T,c);n!=null&&f!=null?k.setView(n,f):e!=null&&k.fitBounds(e,t),u!=null&&k.whenReady(u),_(q1(k))}},[]);v.useEffect(()=>()=>{x==null||x.map.remove()},[x]);const E=x?v.createElement(Ep,{value:x},i):l??null;return v.createElement("div",yc({},y,{ref:p}),E)}const cS=v.forwardRef(lS),hS=qa(function({positions:t,...n},i){const r=new Ws.Polygon(t,n);return Lr(r,Ha(i,{overlayContainer:r}))},function(t,n,i){n.positions!==i.positions&&t.setLatLngs(n.positions)}),uS=qa(function({positions:t,...n},i){const r=new Ws.Polyline(t,n);return Lr(r,Ha(i,{overlayContainer:r}))},function(t,n,i){n.positions!==i.positions&&t.setLatLngs(n.positions)}),dS=iS(function({url:t,...n},i){const r=new Ws.TileLayer(t,Ua(n,i));return Lr(r,i)},function(t,n,i){sS(t,n,i);const{url:r}=n;r!=null&&r!==i.url&&t.setUrl(r)}),fS=nS(function(t,n){const i=new Ws.Tooltip(t,n.overlayContainer);return Lr(i,n)},function(t,n,{position:i},r){v.useEffect(function(){const l=n.overlayContainer;if(l==null)return;const{instance:h}=t,u=c=>{c.tooltip===h&&(i!=null&&h.setLatLng(i),h.update(),r(!0))},f=c=>{c.tooltip===h&&r(!1)};return l.on({tooltipopen:u,tooltipclose:f}),l.bindTooltip(h),function(){l.off({tooltipopen:u,tooltipclose:f}),l._map!=null&&l.unbindTooltip()}},[t,n,r,i])});function gr(e){if(Array.isArray(e))return e;if(typeof e!="string")return[];try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function Pi(e,t){let n=t;if(typeof n=="string"){const h=e.interpolateText(n);try{n=JSON.parse(h)}catch{n=h.split(",")}}const i=Array.isArray(n)?n[0]:(n==null?void 0:n.latitude)??(n==null?void 0:n.lat),r=Array.isArray(n)?n[1]:(n==null?void 0:n.longitude)??(n==null?void 0:n.lng),o=Number(e.interpolateText(String(i??""))),l=Number(e.interpolateText(String(r??"")));return Number.isFinite(o)&&Number.isFinite(l)?[o,l]:null}function zl(e,t,n){return e[t||""]??n.map(i=>e[i]).find(Boolean)??""}function vc(e,t,n,i,r){if(e.interactionDisabled)return;const o={...i,latitude:n[0],longitude:n[1],[t.latitudeKey||"latitude"]:n[0],[t.longitudeKey||"longitude"]:n[1]};e.rowContextRef&&(e.rowContextRef.current=o),e.setSceneData(l=>({...l,...o})),r&&e.handleButtonClick(e.interpolateText(r)).catch(()=>{})}function mS({center:e,points:t,fitBounds:n}){const i=Ap(),r=t.map(o=>o.join(",")).join("|");return v.useEffect(()=>{if(n&&t.length>1){i.fitBounds(t,{padding:[24,24],maxZoom:16});return}i.setView(e,i.getZoom())},[e[0],e[1],n,i,r]),null}function pS({enabled:e,onSelect:t}){return rS({click:n=>{e&&t([n.latlng.lat,n.latlng.lng])}}),null}function gS(e,t,n){const i=Pi(n,t.center);if(i&&t.radius){const o=(e[0]-i[0])*111320,l=(e[1]-i[1])*111320*Math.cos(i[0]*Math.PI/180);return Math.hypot(o,l)<=Number(t.radius)}const r=gr(typeof t.points=="string"?n.interpolateText(t.points):t.points).map(o=>Pi(n,o)).filter(o=>o!==null);return r.length<3?!1:r.reduce((o,l,h)=>{const u=r[(h+r.length-1)%r.length];return l[0]>e[0]!=u[0]>e[0]&&e[1]<(u[1]-l[1])*(e[0]-l[0])/(u[0]-l[0])+l[1]?!o:o},!1)}function yS({api:e,config:t,location:n,fences:i}){const r=v.useRef(new Set),o=JSON.stringify(i),l=(n==null?void 0:n.join(","))||"";return v.useEffect(()=>{if(!n)return;const h=new Set(i.filter(f=>gS(n,f,e)).map((f,c)=>f.id||String(c))),u=t.geofenceKey||"activeGeofences";e.setSceneData(f=>({...f,[u]:[...h]})),i.forEach((f,c)=>{const m=f.id||String(c),y=h.has(m)&&!r.current.has(m),x=!h.has(m)&&r.current.has(m),_=y?f.onEnter||t.onGeofenceEnter:x?f.onExit||t.onGeofenceExit:void 0;_&&vc(e,t,n,{...f,geofenceId:m},_)}),r.current=h},[e,t,o,i,n,l]),null}function vS({api:e,config:t,componentKey:n}){var p,E;const i=e.interpolateText(t.dataSource||""),{fetchListData:r}=e;v.useEffect(()=>{i&&r(i,n,0,t.pageSize||50).catch(()=>{})},[n,t.pageSize,i,r]);const l=(i?((p=e.listData)==null?void 0:p[n])||[]:gr(typeof t.markers=="string"?e.interpolateText(t.markers):t.markers)).map(T=>({source:T,location:Pi(e,T)})).filter(T=>T.location!==null),h=gr(typeof t.route=="string"?e.interpolateText(t.route):t.route).map(T=>Pi(e,T)).filter(T=>T!==null),u=Pi(e,t.location),f=Pi(e,t.center||t)||u||((E=l[0])==null?void 0:E.location)||h[0];t.marker&&f&&l.length===0&&l.push({source:{},location:f});const c=gr(typeof t.geofences=="string"?e.interpolateText(t.geofences):t.geofences),m={width:"100%",height:t.height||t.h||"360px",minHeight:"180px",border:`1px solid ${e.cfg.colors.borderSubtle}`,borderRadius:"8px",overflow:"hidden",...t.className?e.parseClassName(t.className):{}},y=e.getCommonProps(n,m,t);if(!f)return N("div",{key:n,...y},t.emptyText||"Map location unavailable");const x=t.interactive!==!1&&!e.interactionDisabled,_=[...l.map(T=>T.location),...h];return De.jsx("div",{className:t.className,...y,children:De.jsxs(cS,{center:f,zoom:Math.min(19,Math.max(1,Number(t.zoom)||14)),dragging:x,scrollWheelZoom:x,zoomControl:x,attributionControl:!1,style:{width:"100%",height:"100%"},children:[De.jsx(dS,{url:t.tileUrl||"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",attribution:t.tileAttribution||"&copy; OpenStreetMap contributors"}),De.jsx(mS,{center:f,points:_,fitBounds:t.fitBounds??_.length>1}),De.jsx(pS,{enabled:x,onSelect:T=>vc(e,t,T,{},t.onMapClick||t.onClick)}),De.jsx(yS,{api:e,config:t,location:u,fences:c}),h.length>1&&De.jsx(uS,{positions:h,pathOptions:{color:t.routeColor||e.cfg.colors.primary,weight:5}}),c.map((T,k)=>{const A=T.color||e.cfg.colors.primary,P=Pi(e,T.center),I=gr(typeof T.points=="string"?e.interpolateText(T.points):T.points).map(j=>Pi(e,j)).filter(j=>j!==null),$={color:A,fillColor:A,fillOpacity:.14,weight:2};return P&&T.radius?De.jsx(oS,{center:P,radius:Number(T.radius),pathOptions:$},T.id||k):I.length>2?De.jsx(hS,{positions:I,pathOptions:$},T.id||k):null}),l.map(({source:T,location:k})=>De.jsx(aS,{center:k,radius:Number(T.radius||t.markerRadius)||9,pathOptions:{color:T.color||t.markerColor||e.cfg.colors.primary,fillColor:T.color||t.markerColor||e.cfg.colors.primary,fillOpacity:.9,weight:2},eventHandlers:{click:()=>vc(e,t,k,T,T.onClick||t.onMarkerClick)},children:T.label||T.name?De.jsx(fS,{children:e.interpolateText(T.label||T.name)}):null},T.id||k.join("-")))]})},n)}function bS({api:e,config:t,componentKey:n}){var E,T;const i=t.queryKey||"placeQuery",r=String(e.sceneData[i]||""),[o,l]=v.useState(r),h=e.interpolateText(t.dataSource||""),u=Number(t.minChars)||3,f=Number(t.debounceMs)||300,{fetchListData:c}=e;v.useEffect(()=>{r!==o&&l(r)},[o,r]),v.useEffect(()=>{if(!h||o.trim().length<u)return;const k=window.setTimeout(()=>{c(h,n,0,t.pageSize||8).catch(()=>{})},f);return()=>window.clearTimeout(k)},[n,t.pageSize,h,f,c,u,o]);const m=h?((E=e.listData)==null?void 0:E[n])||[]:gr(typeof t.places=="string"?e.interpolateText(t.places):t.places),y={display:"flex",flexDirection:"column",gap:"8px",width:"100%",...t.className?e.parseClassName(t.className):{}},x=e.getCommonProps(n,y,t),_=k=>{const A=zl(k,t.addressField,["address","formattedAddress","formatted_address","vicinity"]),P=Pi(e,k),I={...k,[t.valueKey||"address"]:A,...P?{latitude:P[0],longitude:P[1]}:{},...P&&t.latitudeKey?{[t.latitudeKey]:P[0]}:{},...P&&t.longitudeKey?{[t.longitudeKey]:P[1]}:{}};e.rowContextRef&&(e.rowContextRef.current=I),e.setSceneData(j=>({...j,...I}));const $=k.onClick||t.onPlaceClick||t.onClick;$&&e.handleButtonClick(e.interpolateText($)).catch(()=>{})},p=!((T=e.loading)!=null&&T[n])&&m.length===0&&(!h||o.trim().length>=u);return N("div",{key:n,className:t.className,...x},h&&t.searchable!==!1?N("input",{type:"search",value:o,placeholder:e.interpolateText(t.placeholder||"Search address"),autoComplete:"off",onChange:k=>{const A=k.target.value;l(A),e.setSceneData(P=>({...P,[i]:A}))},style:{width:"100%",padding:"10px 12px",border:`1px solid ${e.cfg.colors.borderSubtle}`,borderRadius:"8px",backgroundColor:e.cfg.colors.surface,color:e.cfg.colors.text}}):null,...m.map((k,A)=>{const P=e.interpolateText(zl(k,t.labelField,["name","title","label"])),I=e.interpolateText(zl(k,t.addressField,["address","formattedAddress","formatted_address","vicinity"]));return N("button",{key:k.id||`${n}-${A}`,type:"button",onClick:()=>!e.interactionDisabled&&_(k),disabled:e.interactionDisabled||void 0,"aria-label":`Select ${P||I||"place"}`,style:{display:"flex",alignItems:"center",gap:"10px",padding:"12px",border:`1px solid ${e.cfg.colors.borderSubtle}`,borderRadius:"8px",backgroundColor:e.cfg.colors.surface,color:e.cfg.colors.text,cursor:e.interactionDisabled?"default":"pointer",textAlign:"left",...t.itemClassName?e.parseClassName(t.itemClassName):{}}},e.renderIcon("map-pin",18),N("span",{style:{display:"flex",flex:1,flexDirection:"column",gap:"3px",minWidth:0}},N("strong",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},P||I),P&&I?N("span",{style:{color:e.cfg.colors.textSecondary,fontSize:"13px"}},I):null))}),p?N("span",{style:{color:e.cfg.colors.textMuted,fontSize:"13px"}},t.emptyText||"No addresses found"):null)}function Mr(e,t,n,i,r){if(!Array.isArray(t)||t.length===0)return null;if(i==="row")return t.map((f,c)=>e.renderComponent(f,c,n));const o=[];let l=[];const h=f=>f&&(f.type==="button"||r&&(f.type==="link"||f.type==="a")),u=f=>{l.length!==0&&(l.length===1?o.push(e.renderComponent(l[0],f,n)):o.push(N("div",{key:`${n}-btns-${f}`,style:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"center",gap:"0.75rem"}},...l.map((c,m)=>e.renderComponent(c,f+m,n)))),l=[])};return t.forEach((f,c)=>{h(f)?l.push(f):(u(c),o.push(e.renderComponent(f,c,n)))}),u(t.length),o}function Rp(e){return e.className?/\bhidden\b/.test(e.className)&&/\b(sm|md|lg|xl):(?:block|flex|inline|inline-block|inline-flex)\b/.test(e.className):!1}function Np(e){return e.children?e.children.filter(t=>Rp(t)):[]}function xS(e){return e.children?e.children.filter(t=>!Rp(t)):[]}function Ip(e){var t;return Array.isArray((t=e==null?void 0:e.mobileMenu)==null?void 0:t.items)?e.mobileMenu.items:[]}function _S(e){if(!(e.layout==="row"||e.className&&/\bflex-row\b/.test(e.className)))return!1;const n=Np(e),i=Ip(e);if(n.length===0&&i.length===0)return!1;const r=["text","link","button","accordion"];if(!(n.length===0||n.every(u=>r.includes(u.type))))return!1;const l=e.className||"";return/\b(sticky|fixed)\b/.test(l)||/\btop-0\b/.test(l)||/\bz-(10|20|30|40|50)\b/.test(l)||/\bjustify-between\b/.test(l)||e.justify==="space-between"}function Zd(e){const t=Ip(e);return t.length>0?t:Np(e)}function Ud(e){return xS(e)}function qd(e,t){return v.createElement("button",{key:"hamburger-icon",onClick:()=>t(!e),style:{background:"none",border:"none",cursor:"pointer",padding:"8px",display:"flex",alignItems:"center",justifyContent:"center",color:"inherit",fontSize:"24px",lineHeight:1},"aria-label":e?"Close menu":"Open menu"},e?"✕":"☰")}function zp(e){return e=String(e??""),e.replace(/\bhidden\b/g,"").replace(/\b(sm|md|lg|xl|2xl):(block|flex|inline|inline-block|inline-flex)\b/g,"").replace(/\s+/g," ").trim()}function Gd(e){const t=(e==null?void 0:e.className)||"";return/\bdrawer\b/.test(t)&&!/\bdrawer-(item|item-[a-z]+)\b/.test(t)}function lr(e){return/\bburger-first\b/.test((e==null?void 0:e.className)||"")}function Yd({navLinks:e,parentKey:t,renderComponentFn:n,open:i,onClose:r,colorMode:o,portalTarget:l,mobileMenu:h,parseMenuClassName:u}){const[f,c]=v.useState(i);if(v.useEffect(()=>{i&&c(!0)},[i]),!i&&!f)return null;const m=e.map(T=>({...T,className:T.className?zp(T.className):void 0})),y=o!=="light"?"rgba(17, 24, 39, 0.98)":"rgba(255, 255, 255, 0.98)",x=h!=null&&h.className&&u?u(h.className,`${t}-side-drawer-class`):{},_=h!=null&&h.headerClassName&&u?u(h.headerClassName,`${t}-side-header-class`):{},p=()=>{c(!1),r()},E=v.createElement(v.Fragment,null,v.createElement("div",{key:`${t}-side-backdrop`,onClick:p,style:{position:"absolute",inset:0,backgroundColor:"rgba(0, 0, 0, 0.45)",zIndex:90,opacity:i?1:0,transition:"opacity 0.25s ease",pointerEvents:i?"auto":"none"}}),v.createElement("div",{key:`${t}-side-drawer`,className:h==null?void 0:h.className,style:{position:"absolute",top:0,bottom:0,left:0,width:"min(300px, 85%)",backgroundColor:y,zIndex:100,overflowY:"auto",transform:i?"translateX(0)":"translateX(-100%)",transition:"transform 0.25s ease",boxShadow:"2px 0 12px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column",gap:"4px",padding:"16px 12px",...x}},v.createElement("div",{key:`${t}-side-header`,className:h==null?void 0:h.headerClassName,style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"4px 8px 12px",borderBottom:"1px solid rgba(128, 128, 128, 0.2)",marginBottom:"8px",fontSize:18,fontWeight:700,..._}},(h==null?void 0:h.title)||"Menu",v.createElement("button",{onClick:p,"aria-label":"Close menu",style:{background:"none",border:"none",cursor:"pointer",fontSize:22,color:"inherit",lineHeight:1}},"✕")),m.map((T,k)=>v.createElement(Dp,{key:`${t}-drawer-item-${k}`,link:T,idx:k,parentKey:t,renderComponentFn:n,onClose:p,itemClassName:h==null?void 0:h.itemClassName,itemStyle:h!=null&&h.itemClassName&&u?u(h.itemClassName,`${t}-drawer-item-class-${k}`):void 0}))));return l?_c.createPortal(E,l):E}function Dp({link:e,idx:t,parentKey:n,renderComponentFn:i,onClose:r,itemClassName:o,itemStyle:l}){const[h,u]=v.useState(!1),f=e.type==="link"||e.type==="button";return v.createElement("div",{key:`${n}-drawer-item-${t}`,className:o,style:{display:"flex",flexDirection:"row",alignItems:"center",gap:10,width:"100%",padding:"10px 12px",borderRadius:8,cursor:f?"pointer":"default",backgroundColor:h?"rgba(128, 128, 128, 0.12)":"transparent",transition:"background-color 0.15s ease",...l},onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),onClick:()=>{f&&r()}},i(e,t+1,`${n}-drawer`))}function Xd(e,t,n,i,r,o,l,h){if(!i)return null;const u=e.map(y=>({...y,className:y.className?zp(y.className):void 0})),f=r!=="light"?"rgba(17, 24, 39, 0.98)":"rgba(255, 255, 255, 0.98)",c=r!=="light"?"rgba(75, 85, 99, 0.5)":"rgba(209, 213, 219, 0.5)",m=l!=null&&l.className&&h?h(l.className,`${t}-mobile-drawer-class`):{};return v.createElement("div",{key:`${t}-mobile-drawer`,className:l==null?void 0:l.className,style:{position:"absolute",top:"100%",left:0,right:0,backgroundColor:f,borderTop:`1px solid ${c}`,padding:"12px",display:"flex",flexDirection:"column",gap:"4px",zIndex:50,boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",...m}},u.map((y,x)=>v.createElement(Dp,{key:`${t}-drawer-item-${x}`,link:y,idx:x,parentKey:t,renderComponentFn:n,onClose:()=>o==null?void 0:o(!1),itemClassName:l==null?void 0:l.itemClassName,itemStyle:l!=null&&l.itemClassName&&h?h(l.itemClassName,`${t}-drawer-item-class-${x}`):void 0})))}function wS(e,t,n){var l;if(t.className){const h=((l=e.parseClassNameResponsive)==null?void 0:l.call(e,t.className,n))??e.parseClassName(t.className);if(h.display==null&&(h.display="flex"),h.flexDirection==null){const f=t.className||"",c=f.match(/\b((sm|md|lg|xl|2xl):)?flex-(row|row-reverse|col|col-reverse)\b/);if(c)h.flexDirection=c[3].startsWith("row")?"row":"column";else if(/(^|\s)((sm|md|lg|xl|2xl):)?flex(\s|$)/.test(f)){const m=/\bmin-h-(screen|\[[^\]]+\])/.test(f)&&/\bitems-center\b/.test(f),y=Array.isArray(t.children)&&t.children.length>0&&t.children.every(x=>x&&["h1","h2","h3","h4","p","text"].includes(x.type));h.flexDirection=m||y?"column":"row"}else h.flexDirection=t.layout==="row"?"row":"column"}if(e.renderMode!=="css-driven"){const f=Mo(t.className);if(f.px.size>0){const m=It(f.px,e.containerWidth,"0px");h.paddingLeft=m,h.paddingRight=m}if(f.py.size>0){const m=It(f.py,e.containerWidth,"0px");h.paddingTop=m,h.paddingBottom=m}if(f.p.size>0){const m=It(f.p,e.containerWidth,"0px");h.padding=m}const c=Er(t.className);c.size>0&&(h.display=It(c,e.containerWidth,"flex"))}const u=e.getCommonProps(n,h,t);return v.createElement("div",{key:n,className:t.className,...u},Mr(e,Array.isArray(t.children)?t.children:[],n,h.flexDirection))}const i=e.cfg.colorMode==="light",r={display:"flex",flexDirection:t.layout==="row"?"row":"column",gap:t.gap!==void 0?`${t.gap}px`:"1rem",padding:"1.5rem",borderRadius:"1rem",backdropFilter:"blur(8px)",border:i?"1px solid rgba(0, 0, 0, 0.1)":"1px solid rgba(55, 65, 81, 0.5)"},o=e.getCommonProps(n,r,t);return v.createElement("div",{key:n,...o},Mr(e,t.children,n,r.flexDirection))}function SS(e,t,n){var h;const i=e.isMobileView&&_S(t);if(t.className){const u=((h=e.parseClassNameResponsive)==null?void 0:h.call(e,t.className,n))??e.parseClassName(t.className);if(u.display==null&&(u.display="flex"),u.flexDirection==null){const m=t.className||"",y=m.match(/\b((sm|md|lg|xl|2xl):)?flex-(row|row-reverse|col|col-reverse)\b/);if(y)u.flexDirection=y[3].startsWith("row")?"row":"column";else if(/(^|\s)((sm|md|lg|xl|2xl):)?flex(\s|$)/.test(m)){const x=/\bmin-h-(screen|\[[^\]]+\])/.test(m)&&/\bitems-center\b/.test(m),_=Array.isArray(t.children)&&t.children.length>0&&t.children.every(p=>p&&["h1","h2","h3","h4","p","text"].includes(p.type));u.flexDirection=x||_?"column":"row"}else u.flexDirection=t.layout==="row"?"row":"column"}if(e.renderMode!=="css-driven"){const m=Mo(t.className);if(m.px.size>0){const x=It(m.px,e.containerWidth,"0px");u.paddingLeft=x,u.paddingRight=x}if(m.py.size>0){const x=It(m.py,e.containerWidth,"0px");u.paddingTop=x,u.paddingBottom=x}if(m.p.size>0){const x=It(m.p,e.containerWidth,"0px");u.padding=x}const y=Er(t.className);y.size>0&&(u.display=It(y,e.containerWidth,"flex"))}if(i&&t.children&&t.children.length>0){const m=Ud(t),y=Zd(t);u.position="relative",u.display="flex",u.alignItems="center",u.justifyContent=lr(t)?"flex-start":"space-between",lr(t)&&(u.gap=10);const x=e.getCommonProps(n,u,t),_=qd(e.mobileMenuOpen,e.setMobileMenuOpen),p=(T,k)=>{var A;return((A=e.parseClassNameResponsive)==null?void 0:A.call(e,T,k))??e.parseClassName(T)},E=m.map((T,k)=>e.renderComponent(T,k,n));return v.createElement("div",{key:n,className:t.className,...t.scrollTarget?{id:t.scrollTarget}:{},...x},...lr(t)?[_,...E]:[...E,_],Gd(t)?v.createElement(Yd,{navLinks:y,parentKey:n,renderComponentFn:e.renderComponent,open:e.mobileMenuOpen,onClose:()=>e.setMobileMenuOpen(!1),colorMode:e.cfg.colorMode,portalTarget:e.portalTarget,mobileMenu:t.mobileMenu,parseMenuClassName:p}):Xd(y,n,e.renderComponent,e.mobileMenuOpen,e.cfg.colorMode,e.setMobileMenuOpen,t.mobileMenu,p))}const f=e.getCommonProps(n,u,t),c=t.onClick?{onClick:m=>{m.stopPropagation(),e.handleButtonClick(t.onClick,{})},style:{cursor:"pointer"}}:{};return v.createElement("div",{key:n,className:t.className,...t.scrollTarget?{id:t.scrollTarget}:{},...f,...c},Mr(e,Array.isArray(t.children)?t.children:[],n,u.flexDirection))}const r={display:"flex",flexDirection:t.layout==="row"?"row":"column",gap:t.gap!==void 0?`${t.gap}px`:"16px"};if(t.align){const u={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"};r.alignItems=u[t.align]}if(t.justify){const u={start:"flex-start",center:"center",end:"flex-end","space-between":"space-between"};r.justifyContent=u[t.justify]}if(t.padding!==void 0&&(r.padding=`${t.padding}px`),i&&t.children&&t.children.length>0){const u=Ud(t),f=Zd(t);r.position="relative",r.display="flex",r.alignItems="center",r.justifyContent=lr(t)?"flex-start":"space-between",lr(t)&&(r.gap=10);const c=e.getCommonProps(n,r,t),m=qd(e.mobileMenuOpen,e.setMobileMenuOpen),y=(_,p)=>{var E;return((E=e.parseClassNameResponsive)==null?void 0:E.call(e,_,p))??e.parseClassName(_)},x=u.map((_,p)=>e.renderComponent(_,p,n));return v.createElement("div",{key:n,...c},...lr(t)?[m,...x]:[...x,m],Gd(t)?v.createElement(Yd,{navLinks:f,parentKey:n,renderComponentFn:e.renderComponent,open:e.mobileMenuOpen,onClose:()=>e.setMobileMenuOpen(!1),colorMode:e.cfg.colorMode,portalTarget:e.portalTarget,mobileMenu:t.mobileMenu,parseMenuClassName:y}):Xd(f,n,e.renderComponent,e.mobileMenuOpen,e.cfg.colorMode,e.setMobileMenuOpen,t.mobileMenu,y))}const o=e.getCommonProps(n,r,t),l=t.onClick?{onClick:u=>{u.stopPropagation(),e.handleButtonClick(t.onClick,{})},style:{cursor:"pointer"}}:{};return v.createElement("div",{key:n,...o,...l},Mr(e,t.children,n,r.flexDirection))}function CS(e,t,n){var o,l;if(t.className){const h=((o=e.parseClassNameResponsive)==null?void 0:o.call(e,t.className,n))??e.parseClassName(t.className);let u;if(e.renderMode!=="css-driven"){const c=ox(t.className),m=c.size>0?ax(c,e.containerWidth):void 0;u={display:"grid",...h,...m!==void 0&&{gridTemplateColumns:`repeat(${m}, minmax(0, 1fr))`}}}else u={display:"grid",...h};const f=e.getCommonProps(n,u,t);return v.createElement("div",{key:n,className:t.className,...f},(Array.isArray(t.children)?t.children:[]).map((c,m)=>e.renderComponent(c,m,n)))}const i={display:"grid",width:"100%",gridTemplateColumns:`repeat(${t.cols||2}, minmax(0, 1fr))`,gap:t.gap!==void 0?`${t.gap}px`:"16px"},r=e.getCommonProps(n,i,t);return v.createElement("div",{key:n,...r},(l=t.children)==null?void 0:l.map((h,u)=>e.renderComponent(h,u,n)))}function MS(e,t,n){var h,u;if(t.className){const c={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",minHeight:e.containerWidth>0&&e.containerWidth<vo.md?"300px":"500px",gap:"24px"};(t.bg||t.backgroundColor)&&(c.background=t.bg||t.backgroundColor),t.bgImage&&(c.backgroundImage=`url(${t.bgImage})`,c.backgroundSize="cover",c.backgroundPosition="center");const m={...c,...((h=e.parseClassNameResponsive)==null?void 0:h.call(e,t.className,n))??e.parseClassName(t.className)};if(Array.isArray(t.children)&&t.children.some(_=>_.type==="grid")||(m.textAlign="center"),e.renderMode!=="css-driven"){const _=Mo(t.className);if(_.px.size>0){const p=It(_.px,e.containerWidth,"0px");m.paddingLeft=p,m.paddingRight=p}if(_.py.size>0){const p=It(_.py,e.containerWidth,"0px");m.paddingTop=p,m.paddingBottom=p}if(_.p.size>0){const p=It(_.p,e.containerWidth,"0px");m.padding=p}}const x=e.getCommonProps(n,m,t);return v.createElement("div",{key:n,className:t.className,...x},Mr(e,Array.isArray(t.children)?t.children:[],n,m.flexDirection))}const i=e.containerWidth<vo.md,r={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",minHeight:i?"300px":"500px",padding:i?"1.5rem":"3rem",background:t.bg||t.backgroundColor,gap:"24px"};t.bgImage&&(r.backgroundImage=`url(${t.bgImage})`,r.backgroundSize="cover",r.backgroundPosition="center"),Array.isArray(t.children)&&t.children.some(f=>f.type==="grid")||(r.textAlign="center");const l=e.getCommonProps(n,r,t);return v.createElement("div",{key:n,...l},(u=t.children)==null?void 0:u.map((f,c)=>e.renderComponent(f,c,n)))}function kS(e,t,n){var l;const i={display:"flex",flexDirection:"row",alignItems:"center",width:"100%",flexShrink:0,position:"sticky",top:0,zIndex:50,gap:"1.25rem",padding:"0.75rem 1.5rem",backgroundColor:e.cfg.colors.surface,borderBottom:`1px solid ${e.cfg.colors.border}`};if(t.className&&(Object.assign(i,((l=e.parseClassNameResponsive)==null?void 0:l.call(e,t.className,n))??e.parseClassName(t.className)),e.renderMode!=="css-driven")){const h=Mo(t.className);h.px.size>0&&(i.paddingLeft=It(h.px,e.containerWidth,"0px"),i.paddingRight=It(h.px,e.containerWidth,"0px")),h.py.size>0&&(i.paddingTop=It(h.py,e.containerWidth,"0px"),i.paddingBottom=It(h.py,e.containerWidth,"0px"));const u=Er(t.className);u.size>0&&(i.display=It(u,e.containerWidth,"flex"))}const r=e.getCommonProps(n,i,t),o=t.className?{key:n,className:t.className,...r}:{key:n,...r};return v.createElement("header",o,(Array.isArray(t.children)?t.children:[]).filter(h=>Array.isArray(h.visibleOn)?h.visibleOn.includes(e.currentSceneId):Array.isArray(h.hiddenOn)?!h.hiddenOn.includes(e.currentSceneId):!0).map((h,u)=>e.renderComponent(h,u,n)))}function TS(e,t,n){var u;const i={display:"flex",flexDirection:t.layout==="row"?"row":"column",width:"100%",flexShrink:0,marginTop:"auto",gap:"1rem",padding:"2.5rem 1.5rem",backgroundColor:e.cfg.colors.surfaceHover,borderTop:`1px solid ${e.cfg.colors.border}`};if(t.className&&(Object.assign(i,((u=e.parseClassNameResponsive)==null?void 0:u.call(e,t.className,n))??e.parseClassName(t.className)),e.renderMode!=="css-driven")){const f=Mo(t.className);f.px.size>0&&(i.paddingLeft=It(f.px,e.containerWidth,"0px"),i.paddingRight=It(f.px,e.containerWidth,"0px")),f.py.size>0&&(i.paddingTop=It(f.py,e.containerWidth,"0px"),i.paddingBottom=It(f.py,e.containerWidth,"0px"))}const r=e.getCommonProps(n,i,t),o=t.className?{key:n,className:t.className,...r}:{key:n,...r};let l=Array.isArray(t.children)?t.children:[];const h=l[0];return h&&h.type==="text"&&/^(\u00a9|\(c\)|copyright)/i.test(String(h.text).trim())&&(l=[...l.slice(1),h]),v.createElement("footer",o,Mr(e,l,n,i.flexDirection,!0))}const Jd=new Map;function PS(e){let t=Jd.get(e);return t||(t=Sa.create(e),Jd.set(e,t)),t}function Mt(e,t){if(!(e!=null&&e.motion)||!v.isValidElement(t))return t;const n=t,i=n.props,r=PS(n.type);return v.createElement(r,{key:n.key,...i,initial:e.initial,animate:e.animate,exit:e.exit,transition:e.transition,variants:e.variants,whileHover:e.whileHover,whileTap:e.whileTap,whileFocus:e.whileFocus,whileInView:e.whileInView,layout:e.animateLayout},i==null?void 0:i.children)}function fa(e,t,n,i=""){var l;const r=t,o=`${i}-${n}`;if(Array.isArray(r.hiddenOn)&&r.hiddenOn.includes(e.currentSceneId)||Array.isArray(r.visibleOn)&&!r.visibleOn.includes(e.currentSceneId)||r.condition&&e.evaluateCondition&&!e.evaluateCondition(r.condition))return null;if(!Array.isArray(r.children)&&Array.isArray(r.components)&&(r.children=r.components),r.type==="custom"){const h=r.tagName||"div",u=((l=e.parseClassNameResponsive)==null?void 0:l.call(e,r.className||"",o))??(r.className?e.parseClassName(r.className):{});r.rawStyle&&Object.assign(u,r.rawStyle);const f=e.getCommonProps(o,u,r),c=Array.isArray(r.children)?r.children.map((y,x)=>e.renderComponent(y,x,o)):[],m=r.motion?{motion:r.motion,initial:r.initial,animate:r.animate,exit:r.exit,transition:r.transition,variants:r.variants,whileHover:r.whileHover,whileTap:r.whileTap,whileFocus:r.whileFocus,whileInView:r.whileInView,animateLayout:r.animateLayout}:{};return N(h,{key:o,className:r.className,...f,...m},...c)}if(/^h[1-6]$/.test(r.type)||r.type==="p"||r.type==="span"||r.type==="label"||r.type==="blockquote"||r.type==="strong"||r.type==="em"||r.type==="li"||r.type==="figcaption"||r.type==="th"||r.type==="td"||r.type==="heading"||r.type==="paragraph"||r.type==="address"||r.type==="time"||r.type==="legend"||r.type==="caption"?r.type="text":r.type==="div"||r.type==="article"||r.type==="aside"||r.type==="main"||r.type==="figure"?r.type=r.children?"section":"text":r.type==="a"?r.type="link":r.type==="img"?r.type="image":r.type==="ul"||r.type==="ol"?r.type="list":r.type==="table"||r.type==="thead"||r.type==="tbody"||r.type==="tfoot"||r.type==="tr"?r.type="table":r.type==="br"?r.type="spacer":r.type==="hr"?r.type="divider":r.type==="details"||r.type==="summary"?r.type=r.children?"section":"text":r.type==="nav"?r.type="section":(r.type==="form"&&!r.fields||r.type==="listItem")&&(r.type=r.children?"section":"text"),r.type==="select"&&Array.isArray(r.options)&&typeof r.options[0]=="string"&&(r.options=r.options.map(h=>({label:h,value:h}))),r.type==="dropdown-button"&&!r.items&&r.options&&(r.items=Array.isArray(r.options)&&typeof r.options[0]=="string"?r.options.map(h=>({label:h,value:h})):r.options),(r.type==="input"||r.type==="textarea")&&!r.placeholder&&r.label&&(r.placeholder=r.label),e.imageReplacements&&e.imageReplacements.size>0){const h=e.imageReplacements.get(o);if(h&&h.url){const u={width:"100%",height:"auto",maxHeight:"300px",objectFit:"cover",borderRadius:"0.75rem"},f=e.getCommonProps(o,u,r),c=r.motion?{motion:r.motion,initial:r.initial,animate:r.animate,whileHover:r.whileHover,whileTap:r.whileTap,transition:r.transition,animateLayout:r.animateLayout}:{};return N("img",{key:`${o}-${h.url}`,src:h.url,alt:h.name||"Replacement image",...f,...c})}}switch(r.type){case"text":return Mt(r,Gw(e,r,o));case"html":return Mt(r,Xw(e,r,o));case"link":return Mt(r,Jw(e,r,o));case"button":return Mt(r,Qw(e,r,o));case"image":return Mt(r,Kw(e,r,o));case"input":return Mt(r,t1(e,r,o));case"hidden":return Mt(r,e1(e,r,o));case"select":return Mt(r,n1(e,r,o));case"checkbox":return Mt(r,i1(e,r,o));case"card":return Mt(r,wS(e,r,o));case"section":case"container":case"cta_section":return Mt(r,SS(e,r,o));case"header":return Mt(r,kS(e,r,o));case"grid":case"features_grid":return Mt(r,CS(e,r,o));case"hero":return Mt(r,MS(e,r,o));case"footer":return Mt(r,TS(e,r,o));case"spacer":return Mt(r,f1(e,r,o));case"divider":return Mt(r,m1(e,r,o));case"list":return Mt(r,hx(e,r,o));case"table":return Mt(r,dx(e,r,o));case"badge":return Mt(r,s1(e,r,o));case"tag":return Mt(r,r1(e,r,o));case"avatar":return Mt(r,o1(e,r,o));case"progress":return Mt(r,a1(e,r,o));case"recorder":return v.createElement(H1,{api:e,config:r,key:o});case"live-cast":return v.createElement(Z1,{api:e,config:r,componentKey:o,key:o});case"tabs":return Mt(r,lx(e,r,o));case"accordion":return Mt(r,cx(e,r,o));case"bottom_nav":return Mt(r,W1(e,r,o));case"split":return Mt(r,V1(e,r,o));case"theme_toggle":return Mt(r,j1(e,r,o));case"slider":case"carousel":return Mt(r,h1(e,r,o));case"marquee":return Mt(r,u1(e,r,o));case"camera":case"capture":return Mt(r,d1(e,r,o));case"phaser_game":return Mt(r,e.renderPhaserGame?e.renderPhaserGame(r,o):null);case"search":return Mt(r,l1(e,r,o));case"breadcrumb":return Mt(r,c1(e,r,o));case"form":return Mt(r,N1(e,r,o));case"textarea":return Mt(r,g1(e,r,o));case"icon":return Mt(r,y1(e,r,o));case"markdown":return Mt(r,F1(e,r,o));case"dropdown-button":return Mt(r,E1(e,r,o));case"widget":return Mt(r,L1(e,r,o));case"advanced-select":return Mt(r,A1(e,r,o));case"metric_display":return Mt(r,v1(e,r,o));case"bar_chart":return Mt(r,b1(e,r,o));case"line_chart":return Mt(r,Il(e,r,o,!1));case"area_chart":return Mt(r,Il(e,r,o,!0));case"candlestick":return Mt(r,Il(e,r,o,!1,!0));case"fx_ticker":return Mt(r,x1(e,r,o));case"trading_view":return Mt(r,w1(e,r,o));case"loader":return Mt(r,p1(e,r,o));case"map":return v.createElement(vS,{api:e,config:r,componentKey:o,key:o});case"places":return v.createElement(bS,{api:e,config:r,componentKey:o,key:o});case"flow_diagram":return Mt(r,S1(e,r,o));case"flow":return Mt(r,M1(e,r,o));default:return Mt(r,k1(e,r,o))}}function $p(e){const t=new Map,n=new Map;for(const i of e)if(i.type==="render_scene"&&i.route){const r=i.route.startsWith("/")?i.route:`/${i.route}`;t.set(i.id,r),n.set(r,i.id)}for(const i of e)if(i.type==="render_scene"&&!t.has(i.id)){const r=`/${i.id}`;t.set(i.id,r),n.set(r,i.id)}return{sceneToRoute:t,routeToScene:n}}function bc(e){if(typeof window>"u")return null;const t=window.location.hash;if(!t||t==="#")return null;const n=t.slice(1);return e.get(n)||null}function Qd(e){return typeof window>"u"?null:e.get(window.location.pathname)||null}function ma(e,t,n=!1){if(typeof window>"u")return;const i=t.get(e);if(!i)return;const r=`#${i}`;window.location.hash!==r&&(n?window.history.replaceState({sceneId:e},"",r):window.history.pushState({sceneId:e},"",r))}function Dl(e,t,n=!1){if(typeof window>"u")return;const i=t.get(e);if(!i||window.location.pathname===i)return;const r=`${i}${window.location.search}`;n?window.history.replaceState({sceneId:e},"",r):window.history.pushState({sceneId:e},"",r)}const ES=()=>{try{if(typeof window<"u")return window.localStorage.getItem("backflow_dev_diagnostics")==="1"}catch{}return!1};async function pa(e,t,n={},i){var r;try{const o=t.indexOf(".");if(o===-1)throw new Error(`Invalid SDK call syntax: ${t}`);const l=t.slice(0,o),h=t.slice(o+1),u=h.indexOf("(");if(u===-1)throw new Error(`Invalid SDK call syntax (missing parentheses): ${t}`);const f=h.slice(0,u),c=h.slice(u+1,-1),m=LS(c,n);let y=e[l];if(!y)throw new Error(`Unknown SDK resource: ${String(l)}`);const x=f.split(".");for(let E=0;E<x.length-1;E++){const T=x[E];if(T&&(y=y[T],!y))throw new Error(`Unknown path ${x.slice(0,E+1).join(".")} on resource ${String(l)}`)}const _=x[x.length-1],p=y[_];if(typeof p!="function")throw new Error(`Unknown method ${_} on ${String(l)}.${x.slice(0,-1).join(".")}`);return await p.apply(y,m)}catch(o){throw ES()&&console.error("[SDK Executor] Error:",o),(r=i==null?void 0:i.onError)==null||r.call(i,o),o}}function LS(e,t){if(!e.trim())return[];const i=e.replace(/\{\{([\w.]+)\}\}/g,(r,o)=>{if(o==="now")return JSON.stringify(new Date().toISOString());const l=RS(t,o);return l===void 0?"null":typeof l=="string"?`"${l}"`:JSON.stringify(l)}).replace(/([{,]\s*)([A-Za-z_$][\w$]*)\s*:/g,'$1"$2":').replace(/'((?:[^'\\]|\\.)*)'/g,(r,o)=>`"${o.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}"`);try{return JSON.parse(`[${i}]`)}catch{return AS(i).map(r=>{const o=r.trim();if(o.startsWith("'")&&o.endsWith("'")||o.startsWith('"')&&o.endsWith('"'))return o.slice(1,-1);if(!isNaN(Number(o)))return Number(o);if(o==="true")return!0;if(o==="false")return!1;if(o==="null")return null;try{return JSON.parse(o)}catch{return o}})}}function AS(e){const t=[];let n="",i=0,r=null;for(let o=0;o<e.length;o++){const l=e[o],h=e[o-1];if((l==='"'||l==="'")&&h!=="\\"&&(r===l?r=null:r||(r=l)),!r&&((l==="{"||l==="["||l==="(")&&i++,(l==="}"||l==="]"||l===")")&&i--,l===","&&i===0)){t.push(n),n="";continue}n+=l}return n.trim()&&t.push(n),t}function RS(e,t){const n=t.split(".");let i=e;for(const r of n){if(i==null)return;i=i[r]}return i}function co(e){return e.startsWith("sdk:")}function eo(e){return co(e)?e.slice(4):e}function NS(e,t,...n){const i=n.map(r=>typeof r=="string"?`'${r}'`:JSON.stringify(r)).join(", ");return`sdk:${e}.${t}(${i})`}function IS(e,t){const n=new Map,i=(r,o)=>{o.size>0&&n.set(r,o)};return i("--bf-fd",e.flexDirection),i("--bf-gap",e.gap),i("--bf-w",e.width),i("--bf-items",e.alignItems),i("--bf-justify",e.justifyContent),i("--bf-display",e.display),i("--bf-cols",e.gridCols),i("--bf-text",e.textSize),i("--bf-radius",e.borderRadius),e.padding.p.size>0&&i("--bf-p",e.padding.p),e.padding.px.size>0&&i("--bf-px",e.padding.px),e.padding.py.size>0&&i("--bf-py",e.padding.py),e.margin.all.size>0&&i("--bf-m",e.margin.all),e.margin.t.size>0&&i("--bf-mt",e.margin.t),e.margin.r.size>0&&i("--bf-mr",e.margin.r),e.margin.b.size>0&&i("--bf-mb",e.margin.b),e.margin.l.size>0&&i("--bf-ml",e.margin.l),e.margin.x.size>0&&i("--bf-mx",e.margin.x),e.margin.y.size>0&&i("--bf-my",e.margin.y),n}function zS(e,t){const n=String(t).replace(/[^a-zA-Z0-9_-]/g,"_");return`${e}-${n}`}function Bp(e,t,n){const i=IS(n);if(i.size===0)return"";const r=`[data-bf-r="${e}-${t}"]`,o=[];for(const l of Hm){if(l==="base")continue;const h=jm[l],u=[];for(const[f,c]of i)c.has(l)&&(zS(f,t),u.push(` ${f.replace("--bf-","--bf-")}: ${c.get(l)};`));u.length>0&&o.push(`@media (min-width: ${h}px) {
21
+ ${r} {
22
+ ${u.join(`
20
23
  `)}
21
24
  }
22
- }`)}return r.join(`
23
- `)}const uS={slate:{50:"#f8fafc",100:"#f1f5f9",200:"#e2e8f0",300:"#cbd5e1",400:"#94a3b8",500:"#64748b",600:"#475569",700:"#334155",800:"#1e293b",900:"#0f172a",950:"#020617"},gray:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827",950:"#030712"},zinc:{50:"#fafafa",100:"#f4f4f5",200:"#e4e4e7",300:"#d4d4d8",400:"#a1a1aa",500:"#71717a",600:"#52525b",700:"#3f3f46",800:"#27272a",900:"#18181b",950:"#09090b"},neutral:{50:"#fafafa",100:"#f5f5f5",200:"#e5e5e5",300:"#d4d4d4",400:"#a3a3a3",500:"#737373",600:"#525252",700:"#404040",800:"#262626",900:"#171717",950:"#0a0a0a"},stone:{50:"#fafaf9",100:"#f5f5f4",200:"#e7e5e4",300:"#d6d3d1",400:"#a8a29e",500:"#78716c",600:"#57534e",700:"#44403c",800:"#292524",900:"#1c1917",950:"#0c0a09"},red:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d",950:"#450a0a"},orange:{50:"#fff7ed",100:"#ffedd5",200:"#fed7aa",300:"#fdba74",400:"#fb923c",500:"#f97316",600:"#ea580c",700:"#c2410c",800:"#9a3412",900:"#7c2d12",950:"#431407"},amber:{50:"#fffbeb",100:"#fef3c7",200:"#fde68a",300:"#fcd34d",400:"#fbbf24",500:"#f59e0b",600:"#d97706",700:"#b45309",800:"#92400e",900:"#78350f",950:"#451a03"},yellow:{50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12",950:"#422006"},lime:{50:"#f7fee7",100:"#ecfccb",200:"#d9f99d",300:"#bef264",400:"#a3e635",500:"#84cc16",600:"#65a30d",700:"#4d7c0f",800:"#3f6212",900:"#365314",950:"#1a2e05"},green:{50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d",950:"#052e16"},emerald:{50:"#ecfdf5",100:"#d1fae5",200:"#a7f3d0",300:"#6ee7b7",400:"#34d399",500:"#10b981",600:"#059669",700:"#047857",800:"#065f46",900:"#064e3b",950:"#022c22"},teal:{50:"#f0fdfa",100:"#ccfbf1",200:"#99f6e4",300:"#5eead4",400:"#2dd4bf",500:"#14b8a6",600:"#0d9488",700:"#0f766e",800:"#115e59",900:"#134e4a",950:"#042f2e"},cyan:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"},sky:{50:"#f0f9ff",100:"#e0f2fe",200:"#bae6fd",300:"#7dd3fc",400:"#38bdf8",500:"#0ea5e9",600:"#0284c7",700:"#0369a1",800:"#075985",900:"#0c4a6e",950:"#082f49"},blue:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a",950:"#172554"},indigo:{50:"#eef2ff",100:"#e0e7ff",200:"#c7d2fe",300:"#a5b4fc",400:"#818cf8",500:"#6366f1",600:"#4f46e5",700:"#4338ca",800:"#3730a3",900:"#312e81",950:"#1e1b4b"},violet:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"},purple:{50:"#faf5ff",100:"#f3e8ff",200:"#e9d5ff",300:"#d8b4fe",400:"#c084fc",500:"#a855f7",600:"#9333ea",700:"#7e22ce",800:"#6b21a8",900:"#581c87",950:"#3b0764"},fuchsia:{50:"#fdf4ff",100:"#fae8ff",200:"#f5d0fe",300:"#f0abfc",400:"#e879f9",500:"#d946ef",600:"#c026d3",700:"#a21caf",800:"#86198f",900:"#701a75",950:"#4a044e"},pink:{50:"#fdf2f8",100:"#fce7f3",200:"#fbcfe8",300:"#f9a8d4",400:"#f472b6",500:"#ec4899",600:"#db2777",700:"#be185d",800:"#9d174d",900:"#831843",950:"#500724"},rose:{50:"#fff1f2",100:"#ffe4e6",200:"#fecdd3",300:"#fda4af",400:"#fb7185",500:"#f43f5e",600:"#e11d48",700:"#be123c",800:"#9f1239",900:"#881337",950:"#4c0519"}},Aa={transparent:"transparent",current:"currentColor",inherit:"inherit",black:"#000000",white:"#ffffff",primary:"#3b82f6",secondary:"#64748b",accent:"#ec4899",success:"#22c55e",warning:"#eab308",error:"#ef4444",info:"#3b82f6"};for(const[e,t]of Object.entries(uS))for(const[n,s]of Object.entries(t))Aa[`${e}-${n}`]=s;const vt={0:"0px","0.5":"0.125rem",1:"0.25rem","1.5":"0.375rem",2:"0.5rem","2.5":"0.625rem",3:"0.75rem","3.5":"0.875rem",4:"1rem",5:"1.25rem",6:"1.5rem",7:"1.75rem",8:"2rem",9:"2.25rem",10:"2.5rem",11:"2.75rem",12:"3rem",14:"3.5rem",16:"4rem",20:"5rem",24:"6rem",28:"7rem",32:"8rem",36:"9rem",40:"10rem",44:"11rem",48:"12rem",52:"13rem",56:"14rem",60:"15rem",64:"16rem",72:"18rem",80:"20rem",96:"24rem"},dS={xs:{fontSize:"0.75rem",lineHeight:"1rem"},sm:{fontSize:"0.875rem",lineHeight:"1.25rem"},base:{fontSize:"1rem",lineHeight:"1.5rem"},lg:{fontSize:"1.125rem",lineHeight:"1.75rem"},xl:{fontSize:"1.25rem",lineHeight:"1.75rem"},"2xl":{fontSize:"1.5rem",lineHeight:"2rem"},"3xl":{fontSize:"1.875rem",lineHeight:"2.25rem"},"4xl":{fontSize:"2.25rem",lineHeight:"2.5rem"},"5xl":{fontSize:"3rem",lineHeight:"1"},"6xl":{fontSize:"3.75rem",lineHeight:"1"},"7xl":{fontSize:"4.5rem",lineHeight:"1"},"8xl":{fontSize:"6rem",lineHeight:"1"},"9xl":{fontSize:"8rem",lineHeight:"1"}};function Tl(e,t,n=!0){if(!e)return{};e=String(e);const{colorMode:s,...i}=t||{},r=s==="light",o=e.match(/(?:^|\s)dark:([^\s]+)/g)||[],l=e.replace(/(?:^|\s)dark:[^\s]+/g," ").replace(/\s+/g," ").trim();!r&&o.length?e=l?`${l} ${o.map(d=>d.trim().replace(/^dark:/,"")).join(" ")}`:o.map(d=>d.trim().replace(/^dark:/,"")).join(" "):e=l;const c=i?{...Aa,...Object.fromEntries(Object.entries(i).filter(([,d])=>d))}:Aa;r&&n&&(c.white="#000000",c.black="#ffffff",c["gray-300"]="#4b5563",c["gray-400"]="#374151",c["gray-500"]="#374151",c["gray-600"]="#1f2937",c["gray-700"]="#111827",c["gray-800"]="#0f172a",c["slate-300"]="#475569",c["slate-400"]="#334155",c["slate-500"]="#334155",c["slate-600"]="#1e293b");const h=e.split(/\s+/).filter(Boolean),a={};let u="",f="",p="",g="";for(let d of h){if(d.startsWith("hover:")||d.startsWith("focus:")||d.startsWith("active:")||d.startsWith("group-hover:")||d==="transition"||d==="transition-all"||d==="transition-colors"||d==="transition-opacity"||d==="transition-transform"||d.startsWith("duration-")||d.startsWith("ease-")||d==="cursor-pointer"||d==="grayscale"||((d.startsWith("sm:")||d.startsWith("md:")||d.startsWith("lg:")||d.startsWith("xl:")||d.startsWith("2xl:"))&&(d=d.replace(/^(sm:|md:|lg:|xl:|2xl:)/,"")),d.startsWith("placeholder-"))||d.startsWith("disabled:"))continue;const w=d.match(/^bg-\[([^\]]+)\]$/);if(w){const tt=w[1];tt.startsWith("url(")?a.backgroundImage=tt:a.backgroundColor=tt;continue}const C=d.match(/^text-\[(#[0-9a-fA-F]{3,8}|rgb[a]?\([^)]+\)|hsl[a]?\([^)]+\))\]$/);if(C){a.color=C[1];continue}const x=d.match(/^text-\[(\d+(?:\.\d+)?(?:px|rem|em|%))\]$/);if(x){a.fontSize=x[1];continue}const k=d.match(/^w-\[([^\]]+)\]$/);if(k){a.width=k[1];continue}const S=d.match(/^h-\[([^\]]+)\]$/);if(S){a.height=S[1];continue}const T=d.match(/^min-w-\[([^\]]+)\]$/);if(T){a.minWidth=T[1];continue}const P=d.match(/^max-w-\[([^\]]+)\]$/);if(P){a.maxWidth=P[1];continue}const I=d.match(/^min-h-\[([^\]]+)\]$/);if(I){a.minHeight=I[1];continue}const L=d.match(/^max-h-\[([^\]]+)\]$/);if(L){a.maxHeight=L[1];continue}const O=d.match(/^p-\[([^\]]+)\]$/);if(O){a.padding=O[1];continue}const H=d.match(/^px-\[([^\]]+)\]$/);if(H){a.paddingLeft=H[1],a.paddingRight=H[1];continue}const U=d.match(/^py-\[([^\]]+)\]$/);if(U){a.paddingTop=U[1],a.paddingBottom=U[1];continue}const q=d.match(/^pt-\[([^\]]+)\]$/);if(q){a.paddingTop=q[1];continue}const X=d.match(/^pr-\[([^\]]+)\]$/);if(X){a.paddingRight=X[1];continue}const j=d.match(/^pb-\[([^\]]+)\]$/);if(j){a.paddingBottom=j[1];continue}const D=d.match(/^pl-\[([^\]]+)\]$/);if(D){a.paddingLeft=D[1];continue}const V=d.match(/^m-\[([^\]]+)\]$/);if(V){a.margin=V[1];continue}const J=d.match(/^mx-\[([^\]]+)\]$/);if(J){a.marginLeft=J[1],a.marginRight=J[1];continue}const nt=d.match(/^my-\[([^\]]+)\]$/);if(nt){a.marginTop=nt[1],a.marginBottom=nt[1];continue}const it=d.match(/^mt-\[([^\]]+)\]$/);if(it){a.marginTop=it[1];continue}const Q=d.match(/^mr-\[([^\]]+)\]$/);if(Q){a.marginRight=Q[1];continue}const ut=d.match(/^mb-\[([^\]]+)\]$/);if(ut){a.marginBottom=ut[1];continue}const Ct=d.match(/^ml-\[([^\]]+)\]$/);if(Ct){a.marginLeft=Ct[1];continue}const ft=d.match(/^gap-\[([^\]]+)\]$/);if(ft){a.gap=ft[1];continue}const Dt=d.match(/^gap-x-\[([^\]]+)\]$/);if(Dt){a.columnGap=Dt[1];continue}const qt=d.match(/^gap-y-\[([^\]]+)\]$/);if(qt){a.rowGap=qt[1];continue}const ne=d.match(/^rounded-\[([^\]]+)\]$/);if(ne){a.borderRadius=ne[1];continue}const te=d.match(/^border-\[(#[0-9a-fA-F]{3,8}|rgb[a]?\([^)]+\))\]$/);if(te){a.borderColor=te[1];continue}const mt=d.match(/^border-\[(\d+(?:\.\d+)?(?:px)?)\]$/);if(mt){a.borderWidth=mt[1];continue}const he=d.match(/^top-\[([^\]]+)\]$/);if(he){a.top=he[1];continue}const Pe=d.match(/^right-\[([^\]]+)\]$/);if(Pe){a.right=Pe[1];continue}const ae=d.match(/^bottom-\[([^\]]+)\]$/);if(ae){a.bottom=ae[1];continue}const In=d.match(/^left-\[([^\]]+)\]$/);if(In){a.left=In[1];continue}const Ys=d.match(/^inset-\[([^\]]+)\]$/);if(Ys){a.inset=Ys[1];continue}const Oe=d.match(/^z-\[([^\]]+)\]$/);if(Oe){a.zIndex=parseInt(Oe[1])||Oe[1];continue}const xe=d.match(/^opacity-\[([^\]]+)\]$/);if(xe){a.opacity=parseFloat(xe[1]);continue}const bt=d.match(/^leading-\[([^\]]+)\]$/);if(bt){a.lineHeight=bt[1];continue}if(d==="flex"){a.display="flex";continue}if(d==="grid"){a.display="grid";continue}if(d==="block"){a.display="block";continue}if(d==="inline"){a.display="inline";continue}if(d==="inline-flex"){a.display="inline-flex";continue}if(d==="inline-block"){a.display="inline-block";continue}if(d==="hidden"){a.display="none";continue}if(d==="flex-col"){a.flexDirection="column";continue}if(d==="flex-row"){a.flexDirection="row";continue}if(d==="flex-wrap"){a.flexWrap="wrap";continue}if(d==="flex-nowrap"){a.flexWrap="nowrap";continue}if(d==="flex-col-reverse"){a.flexDirection="column-reverse";continue}if(d==="flex-row-reverse"){a.flexDirection="row-reverse";continue}if(d==="flex-1"){a.flex="1 1 0%";continue}if(d==="flex-auto"){a.flex="1 1 auto";continue}if(d==="flex-initial"){a.flex="0 1 auto";continue}if(d==="flex-none"){a.flex="none";continue}if(d==="grow"){a.flexGrow=1;continue}if(d==="grow-0"){a.flexGrow=0;continue}if(d==="shrink"){a.flexShrink=1;continue}if(d==="shrink-0"){a.flexShrink=0;continue}if(d==="items-start"){a.alignItems="flex-start";continue}if(d==="items-center"){a.alignItems="center";continue}if(d==="items-end"){a.alignItems="flex-end";continue}if(d==="items-stretch"){a.alignItems="stretch";continue}if(d==="items-baseline"){a.alignItems="baseline";continue}if(d==="justify-start"){a.justifyContent="flex-start";continue}if(d==="justify-center"){a.justifyContent="center";continue}if(d==="justify-end"){a.justifyContent="flex-end";continue}if(d==="justify-between"){a.justifyContent="space-between";continue}if(d==="justify-around"){a.justifyContent="space-around";continue}if(d==="justify-evenly"){a.justifyContent="space-evenly";continue}if(d==="justify-items-start"){a.justifyItems="start";continue}if(d==="justify-items-center"){a.justifyItems="center";continue}if(d==="justify-items-end"){a.justifyItems="end";continue}if(d==="justify-items-stretch"){a.justifyItems="stretch";continue}if(d==="self-auto"){a.alignSelf="auto";continue}if(d==="self-start"){a.alignSelf="flex-start";continue}if(d==="self-center"){a.alignSelf="center";continue}if(d==="self-end"){a.alignSelf="flex-end";continue}if(d==="self-stretch"){a.alignSelf="stretch";continue}if(d==="self-baseline"){a.alignSelf="baseline";continue}if(d==="justify-self-auto"){a.justifySelf="auto";continue}if(d==="justify-self-start"){a.justifySelf="start";continue}if(d==="justify-self-center"){a.justifySelf="center";continue}if(d==="justify-self-end"){a.justifySelf="end";continue}if(d==="justify-self-stretch"){a.justifySelf="stretch";continue}if(d==="place-content-center"){a.placeContent="center";continue}if(d==="place-content-start"){a.placeContent="start";continue}if(d==="place-content-end"){a.placeContent="end";continue}if(d==="place-content-between"){a.placeContent="space-between";continue}if(d==="place-content-around"){a.placeContent="space-around";continue}if(d==="place-content-evenly"){a.placeContent="space-evenly";continue}if(d==="place-content-stretch"){a.placeContent="stretch";continue}if(d==="place-items-start"){a.placeItems="start";continue}if(d==="place-items-center"){a.placeItems="center";continue}if(d==="place-items-end"){a.placeItems="end";continue}if(d==="place-items-stretch"){a.placeItems="stretch";continue}if(d==="text-left"){a.textAlign="left";continue}if(d==="text-center"){a.textAlign="center";continue}if(d==="text-right"){a.textAlign="right";continue}if(d==="text-justify"){a.textAlign="justify";continue}if(d==="text-start"){a.textAlign="start";continue}if(d==="text-end"){a.textAlign="end";continue}if(d==="whitespace-normal"){a.whiteSpace="normal";continue}if(d==="whitespace-nowrap"){a.whiteSpace="nowrap";continue}if(d==="whitespace-pre"){a.whiteSpace="pre";continue}if(d==="whitespace-pre-line"){a.whiteSpace="pre-line";continue}if(d==="whitespace-pre-wrap"){a.whiteSpace="pre-wrap";continue}if(d==="whitespace-break-spaces"){a.whiteSpace="break-spaces";continue}if(d==="break-normal"){a.wordBreak="normal",a.overflowWrap="normal";continue}if(d==="break-words"){a.overflowWrap="break-word";continue}if(d==="break-all"){a.wordBreak="break-all";continue}if(d==="break-keep"){a.wordBreak="keep-all";continue}if(d==="truncate"){a.overflow="hidden",a.textOverflow="ellipsis",a.whiteSpace="nowrap";continue}if(d==="text-ellipsis"){a.textOverflow="ellipsis";continue}if(d==="text-clip"){a.textOverflow="clip";continue}if(d==="underline"){a.textDecoration="underline";continue}if(d==="overline"){a.textDecoration="overline";continue}if(d==="line-through"){a.textDecoration="line-through";continue}if(d==="no-underline"){a.textDecoration="none";continue}if(d==="uppercase"){a.textTransform="uppercase";continue}if(d==="lowercase"){a.textTransform="lowercase";continue}if(d==="capitalize"){a.textTransform="capitalize";continue}if(d==="normal-case"){a.textTransform="none";continue}if(d==="italic"){a.fontStyle="italic";continue}if(d==="not-italic"){a.fontStyle="normal";continue}if(d==="font-thin"){a.fontWeight=100;continue}if(d==="font-extralight"){a.fontWeight=200;continue}if(d==="font-light"){a.fontWeight=300;continue}if(d==="font-normal"){a.fontWeight=400;continue}if(d==="font-medium"){a.fontWeight=500;continue}if(d==="font-semibold"){a.fontWeight=600;continue}if(d==="font-bold"){a.fontWeight=700;continue}if(d==="font-extrabold"){a.fontWeight=800;continue}if(d==="font-black"){a.fontWeight=900;continue}if(d==="w-full"){a.width="100%";continue}if(d==="w-screen"){a.width="100vw";continue}if(d==="w-auto"){a.width="auto";continue}if(d==="w-fit"){a.width="fit-content";continue}if(d==="w-min"){a.width="min-content";continue}if(d==="w-max"){a.width="max-content";continue}const Rt=d.match(/^w-(\d+(?:\.\d+)?)$/);if(Rt){a.width=vt[Rt[1]]||`${parseFloat(Rt[1])*.25}rem`;continue}const Lt=d.match(/^w-(\d+)\/(\d+)$/);if(Lt){const tt=parseInt(Lt[1])/parseInt(Lt[2])*100;a.width=`${tt}%`;continue}if(d==="h-full"){a.height="100%";continue}if(d==="h-screen"){a.height="100vh";continue}if(d==="h-auto"){a.height="auto";continue}if(d==="h-fit"){a.height="fit-content";continue}if(d==="h-min"){a.height="min-content";continue}if(d==="h-max"){a.height="max-content";continue}const kt=d.match(/^h-(\d+(?:\.\d+)?)$/);if(kt){a.height=vt[kt[1]]||`${parseFloat(kt[1])*.25}rem`;continue}const yt=d.match(/^h-(\d+)\/(\d+)$/);if(yt){const tt=parseInt(yt[1])/parseInt(yt[2])*100;a.height=`${tt}%`;continue}if(d==="min-h-screen"){a.minHeight="100vh";continue}if(d==="min-h-full"){a.minHeight="100%";continue}if(d==="min-h-0"){a.minHeight="0";continue}if(d==="min-h-fit"){a.minHeight="fit-content";continue}const wt=d.match(/^min-h-(\d+(?:\.\d+)?)$/);if(wt){a.minHeight=vt[wt[1]]||`${parseFloat(wt[1])*.25}rem`;continue}if(d==="min-w-0"){a.minWidth="0";continue}if(d==="min-w-full"){a.minWidth="100%";continue}if(d==="min-w-fit"){a.minWidth="fit-content";continue}const gt=d.match(/^min-w-(\d+(?:\.\d+)?)$/);if(gt){a.minWidth=vt[gt[1]]||`${parseFloat(gt[1])*.25}rem`;continue}if(d==="max-w-none"){a.maxWidth="none";continue}if(d==="max-w-xs"){a.maxWidth="20rem";continue}if(d==="max-w-sm"){a.maxWidth="24rem";continue}if(d==="max-w-md"){a.maxWidth="28rem";continue}if(d==="max-w-lg"){a.maxWidth="32rem";continue}if(d==="max-w-xl"){a.maxWidth="36rem";continue}if(d==="max-w-2xl"){a.maxWidth="42rem";continue}if(d==="max-w-3xl"){a.maxWidth="48rem";continue}if(d==="max-w-4xl"){a.maxWidth="56rem";continue}if(d==="max-w-5xl"){a.maxWidth="64rem";continue}if(d==="max-w-6xl"){a.maxWidth="72rem";continue}if(d==="max-w-7xl"){a.maxWidth="80rem";continue}if(d==="max-w-full"){a.maxWidth="100%";continue}if(d==="max-w-prose"){a.maxWidth="65ch";continue}if(d==="max-w-screen-sm"){a.maxWidth="640px";continue}if(d==="max-w-screen-md"){a.maxWidth="768px";continue}if(d==="max-w-screen-lg"){a.maxWidth="1024px";continue}if(d==="max-w-screen-xl"){a.maxWidth="1280px";continue}if(d==="max-w-screen-2xl"){a.maxWidth="1536px";continue}if(d==="max-h-none"){a.maxHeight="none";continue}if(d==="max-h-full"){a.maxHeight="100%";continue}if(d==="max-h-screen"){a.maxHeight="100vh";continue}if(d==="max-h-fit"){a.maxHeight="fit-content";continue}const Xt=d.match(/^max-h-(\d+(?:\.\d+)?)$/);if(Xt){a.maxHeight=vt[Xt[1]]||`${parseFloat(Xt[1])*.25}rem`;continue}if(d==="relative"){a.position="relative";continue}if(d==="absolute"){a.position="absolute";continue}if(d==="fixed"){a.position="fixed";continue}if(d==="sticky"){a.position="sticky";continue}if(d==="inset-0"){a.top="0",a.right="0",a.bottom="0",a.left="0";continue}if(d==="inset-auto"){a.top="auto",a.right="auto",a.bottom="auto",a.left="auto";continue}if(d==="inset-x-0"){a.left="0",a.right="0";continue}if(d==="inset-y-0"){a.top="0",a.bottom="0";continue}const Ue=d.match(/^inset-(\d+(?:\.\d+)?)$/);if(Ue){const tt=vt[Ue[1]]||`${parseFloat(Ue[1])*.25}rem`;a.top=tt,a.right=tt,a.bottom=tt,a.left=tt;continue}const ge=d.match(/^inset-x-(\d+(?:\.\d+)?)$/);if(ge){const tt=vt[ge[1]]||`${parseFloat(ge[1])*.25}rem`;a.left=tt,a.right=tt;continue}const ee=d.match(/^inset-y-(\d+(?:\.\d+)?)$/);if(ee){const tt=vt[ee[1]]||`${parseFloat(ee[1])*.25}rem`;a.top=tt,a.bottom=tt;continue}if(d==="top-0"){a.top="0";continue}if(d==="top-auto"){a.top="auto";continue}if(d==="top-full"){a.top="100%";continue}const os=d.match(/^top-(\d+(?:\.\d+)?)$/);if(os){a.top=vt[os[1]]||`${parseFloat(os[1])*.25}rem`;continue}const ue=d.match(/^-top-(\d+(?:\.\d+)?)$/);if(ue){const tt=vt[ue[1]]||`${parseFloat(ue[1])*.25}rem`;a.top=`-${tt}`;continue}if(d==="right-0"){a.right="0";continue}if(d==="right-auto"){a.right="auto";continue}if(d==="right-full"){a.right="100%";continue}const ot=d.match(/^right-(\d+(?:\.\d+)?)$/);if(ot){a.right=vt[ot[1]]||`${parseFloat(ot[1])*.25}rem`;continue}const Me=d.match(/^-right-(\d+(?:\.\d+)?)$/);if(Me){const tt=vt[Me[1]]||`${parseFloat(Me[1])*.25}rem`;a.right=`-${tt}`;continue}if(d==="bottom-0"){a.bottom="0";continue}if(d==="bottom-auto"){a.bottom="auto";continue}if(d==="bottom-full"){a.bottom="100%";continue}const Gt=d.match(/^bottom-(\d+(?:\.\d+)?)$/);if(Gt){a.bottom=vt[Gt[1]]||`${parseFloat(Gt[1])*.25}rem`;continue}const Xs=d.match(/^-bottom-(\d+(?:\.\d+)?)$/);if(Xs){const tt=vt[Xs[1]]||`${parseFloat(Xs[1])*.25}rem`;a.bottom=`-${tt}`;continue}if(d==="left-0"){a.left="0";continue}if(d==="left-auto"){a.left="auto";continue}if(d==="left-full"){a.left="100%";continue}const as=d.match(/^left-(\d+(?:\.\d+)?)$/);if(as){a.left=vt[as[1]]||`${parseFloat(as[1])*.25}rem`;continue}const Dn=d.match(/^-left-(\d+(?:\.\d+)?)$/);if(Dn){const tt=vt[Dn[1]]||`${parseFloat(Dn[1])*.25}rem`;a.left=`-${tt}`;continue}if(d==="overflow-hidden"){a.overflow="hidden";continue}if(d==="overflow-auto"){a.overflow="auto";continue}if(d==="overflow-scroll"){a.overflow="scroll";continue}if(d==="overflow-visible"){a.overflow="visible";continue}if(d==="overflow-x-auto"){a.overflowX="auto";continue}if(d==="overflow-y-auto"){a.overflowY="auto";continue}if(d==="overflow-x-hidden"){a.overflowX="hidden";continue}if(d==="overflow-y-hidden"){a.overflowY="hidden";continue}if(d==="overflow-x-scroll"){a.overflowX="scroll";continue}if(d==="overflow-y-scroll"){a.overflowY="scroll";continue}if(d==="object-cover"){a.objectFit="cover";continue}if(d==="object-contain"){a.objectFit="contain";continue}if(d==="object-fill"){a.objectFit="fill";continue}if(d==="object-center"){a.objectPosition="center";continue}if(d==="z-0"){a.zIndex=0;continue}if(d==="z-10"){a.zIndex=10;continue}if(d==="z-20"){a.zIndex=20;continue}if(d==="z-30"){a.zIndex=30;continue}if(d==="z-40"){a.zIndex=40;continue}if(d==="z-50"){a.zIndex=50;continue}const Pt=d.match(/^opacity-(\d+)$/);if(Pt){a.opacity=parseInt(Pt[1])/100;continue}const St=d.match(/^text-(xs|sm|base|lg|xl|[2-9]xl)$/);if(St){const tt=dS[St[1]];tt&&(a.fontSize=tt.fontSize,a.lineHeight=tt.lineHeight);continue}const Ln=d.match(/^text-([\w-]+)(?:\/([\d]+))?$/);if(Ln&&!d.startsWith("text-center")&&!d.startsWith("text-left")&&!d.startsWith("text-right")){const tt=Ln[1],Yt=Ln[2],le=r?c[tt]:{black:"#e5e7eb","gray-600":"#9ca3af","gray-700":"#d1d5db","gray-800":"#e5e7eb","gray-900":"#f3f4f6","slate-700":"#cbd5e1","slate-800":"#e2e8f0","slate-900":"#f1f5f9"}[tt]||c[tt];le&&(Yt?a.color=Yn(le,parseInt(Yt)/100):a.color=le);continue}if(d==="bg-clip-text"){a.WebkitBackgroundClip="text",a.backgroundClip="text",a.WebkitTextFillColor="transparent";continue}if(d==="bg-fixed"){a.backgroundAttachment="fixed";continue}if(d==="bg-scroll"){a.backgroundAttachment="scroll";continue}const zn=d.match(/^bg-([\w-]+)(?:\/([\d]+))?$/);if(zn&&!d.startsWith("bg-gradient")){const tt=zn[1],Yt=zn[2],le=r?c[tt]:{white:"#1f2937","gray-50":"#1f2937","gray-100":"#1f2937","gray-200":"#374151","gray-300":"#4b5563","slate-50":"#1f2937","slate-100":"#1f2937","slate-200":"#334155"}[tt]||c[tt];le&&(Yt?a.backgroundColor=Yn(le,parseInt(Yt)/100):a.backgroundColor=le);continue}if(d==="bg-gradient-to-t"){u="to top";continue}if(d==="bg-gradient-to-tr"){u="to top right";continue}if(d==="bg-gradient-to-r"){u="to right";continue}if(d==="bg-gradient-to-br"){u="to bottom right";continue}if(d==="bg-gradient-to-b"){u="to bottom";continue}if(d==="bg-gradient-to-bl"){u="to bottom left";continue}if(d==="bg-gradient-to-l"){u="to left";continue}if(d==="bg-gradient-to-tl"){u="to top left";continue}const Ze=d.match(/^from-([\w-]+)(?:\/([\d]+))?$/);if(Ze){const tt=Ze[1],Yt=Ze[2],It=c[tt];It&&(f=Yt?Yn(It,parseInt(Yt)/100):It);continue}const ls=d.match(/^via-([\w-]+)(?:\/([\d]+))?$/);if(ls){const tt=ls[1],Yt=ls[2],It=c[tt];It&&(p=Yt?Yn(It,parseInt(Yt)/100):It);continue}const Qs=d.match(/^to-([\w-]+)(?:\/([\d]+))?$/);if(Qs){const tt=Qs[1],Yt=Qs[2],It=c[tt];It&&(g=Yt?Yn(It,parseInt(Yt)/100):It);continue}const cs=d.match(/^p-(\d+(?:\.\d+)?)$/);if(cs){a.padding=vt[cs[1]]||`${parseFloat(cs[1])*.25}rem`;continue}const tn=d.match(/^px-(\d+(?:\.\d+)?)$/);if(tn){const tt=vt[tn[1]]||`${parseFloat(tn[1])*.25}rem`;a.paddingLeft=tt,a.paddingRight=tt;continue}const hs=d.match(/^py-(\d+(?:\.\d+)?)$/);if(hs){const tt=vt[hs[1]]||`${parseFloat(hs[1])*.25}rem`;a.paddingTop=tt,a.paddingBottom=tt;continue}const us=d.match(/^pt-(\d+(?:\.\d+)?)$/);if(us){a.paddingTop=vt[us[1]]||`${parseFloat(us[1])*.25}rem`;continue}const ds=d.match(/^pr-(\d+(?:\.\d+)?)$/);if(ds){a.paddingRight=vt[ds[1]]||`${parseFloat(ds[1])*.25}rem`;continue}const Js=d.match(/^pb-(\d+(?:\.\d+)?)$/);if(Js){a.paddingBottom=vt[Js[1]]||`${parseFloat(Js[1])*.25}rem`;continue}const Ks=d.match(/^pl-(\d+(?:\.\d+)?)$/);if(Ks){a.paddingLeft=vt[Ks[1]]||`${parseFloat(Ks[1])*.25}rem`;continue}const Ee=d.match(/^m-(\d+(?:\.\d+)?)$/);if(Ee){a.margin=vt[Ee[1]]||`${parseFloat(Ee[1])*.25}rem`;continue}const Fn=d.match(/^mx-(\d+(?:\.\d+)?|auto)$/);if(Fn){const tt=Fn[1]==="auto"?"auto":vt[Fn[1]]||`${parseFloat(Fn[1])*.25}rem`;a.marginLeft=tt,a.marginRight=tt;continue}const Be=d.match(/^my-(\d+(?:\.\d+)?|auto)$/);if(Be){const tt=Be[1]==="auto"?"auto":vt[Be[1]]||`${parseFloat(Be[1])*.25}rem`;a.marginTop=tt,a.marginBottom=tt;continue}const dn=d.match(/^mt-(\d+(?:\.\d+)?|auto)$/);if(dn){a.marginTop=dn[1]==="auto"?"auto":vt[dn[1]]||`${parseFloat(dn[1])*.25}rem`;continue}const Bn=d.match(/^mr-(\d+(?:\.\d+)?|auto)$/);if(Bn){a.marginRight=Bn[1]==="auto"?"auto":vt[Bn[1]]||`${parseFloat(Bn[1])*.25}rem`;continue}const Zs=d.match(/^mb-(\d+(?:\.\d+)?)$/);if(Zs){a.marginBottom=vt[Zs[1]]||`${parseFloat(Zs[1])*.25}rem`;continue}const fs=d.match(/^ml-(\d+(?:\.\d+)?|auto)$/);if(fs){a.marginLeft=fs[1]==="auto"?"auto":vt[fs[1]]||`${parseFloat(fs[1])*.25}rem`;continue}if(d==="mt-auto"){a.marginTop="auto";continue}const zt=d.match(/^gap-(\d+(?:\.\d+)?)$/);if(zt){a.gap=vt[zt[1]]||`${parseFloat(zt[1])*.25}rem`;continue}const se=d.match(/^gap-x-(\d+(?:\.\d+)?)$/);if(se){a.columnGap=vt[se[1]]||`${parseFloat(se[1])*.25}rem`;continue}const ti=d.match(/^gap-y-(\d+(?:\.\d+)?)$/);if(ti){a.rowGap=vt[ti[1]]||`${parseFloat(ti[1])*.25}rem`;continue}const ms=d.match(/^space-x-(\d+(?:\.\d+)?)$/);if(ms){a.columnGap=vt[ms[1]]||`${parseFloat(ms[1])*.25}rem`;continue}const ps=d.match(/^space-y-(\d+(?:\.\d+)?)$/);if(ps){a.rowGap=vt[ps[1]]||`${parseFloat(ps[1])*.25}rem`;continue}const Wn=d.match(/^space-x-\[([^\]]+)\]$/);if(Wn){a.columnGap=Wn[1];continue}const _e=d.match(/^space-y-\[([^\]]+)\]$/);if(_e){a.rowGap=_e[1];continue}const jn=d.match(/^grid-cols-(\d+)$/);if(jn){a.gridTemplateColumns=`repeat(${jn[1]}, minmax(0, 1fr))`;continue}if(d==="rounded"){a.borderRadius="0.25rem";continue}if(d==="rounded-none"){a.borderRadius="0";continue}if(d==="rounded-sm"){a.borderRadius="0.125rem";continue}if(d==="rounded-md"){a.borderRadius="0.375rem";continue}if(d==="rounded-lg"){a.borderRadius="0.5rem";continue}if(d==="rounded-xl"){a.borderRadius="0.75rem";continue}if(d==="rounded-2xl"){a.borderRadius="1rem";continue}if(d==="rounded-3xl"){a.borderRadius="1.5rem";continue}if(d==="rounded-full"){a.borderRadius="9999px";continue}if(d==="border"){a.borderWidth="1px",a.borderStyle="solid";continue}if(d==="border-0"){a.borderWidth="0";continue}if(d==="border-2"){a.borderWidth="2px",a.borderStyle="solid";continue}if(d==="border-t"){a.borderTopWidth="1px",a.borderStyle="solid";continue}if(d==="border-b"){a.borderBottomWidth="1px",a.borderStyle="solid";continue}if(d==="border-l"){a.borderLeftWidth="1px",a.borderStyle="solid";continue}if(d==="border-r"){a.borderRightWidth="1px",a.borderStyle="solid";continue}const Wi=d.match(/^border-t-(\d+)$/);if(Wi){a.borderTopWidth=`${Wi[1]}px`,a.borderStyle="solid";continue}const gs=d.match(/^border-b-(\d+)$/);if(gs){a.borderBottomWidth=`${gs[1]}px`,a.borderStyle="solid";continue}const We=d.match(/^border-l-(\d+)$/);if(We){a.borderLeftWidth=`${We[1]}px`,a.borderStyle="solid";continue}const fn=d.match(/^border-r-(\d+)$/);if(fn){a.borderRightWidth=`${fn[1]}px`,a.borderStyle="solid";continue}const Ot=d.match(/^border-(\d+)$/);if(Ot){a.borderWidth=`${Ot[1]}px`,a.borderStyle="solid";continue}const en=d.match(/^border-([\w-]+)(?:\/([\d]+))?$/);if(en&&!d.match(/^border-[trbl]$/)){const tt=en[1],Yt=en[2],le=r?c[tt]:{white:"#374151","gray-100":"#374151","gray-200":"#374151","gray-300":"#4b5563","slate-100":"#334155","slate-200":"#334155","slate-300":"#475569"}[tt]||c[tt];le&&(a.borderColor=Yt?Yn(le,parseInt(Yt)/100):le);continue}if(d==="shadow"){a.boxShadow="0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)";continue}if(d==="shadow-sm"){a.boxShadow="0 1px 2px 0 rgb(0 0 0 / 0.05)";continue}if(d==="shadow-md"){a.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)";continue}if(d==="shadow-lg"){a.boxShadow="0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)";continue}if(d==="shadow-xl"){a.boxShadow="0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)";continue}if(d==="shadow-2xl"){a.boxShadow="0 25px 50px -12px rgb(0 0 0 / 0.25)";continue}if(d==="shadow-none"){a.boxShadow="none";continue}if(d==="ring"){a.boxShadow="0 0 0 3px rgba(59, 130, 246, 0.5)";continue}if(d==="ring-0"){a.boxShadow="0 0 0 0px transparent";continue}if(d==="ring-1"){a.boxShadow="0 0 0 1px rgba(59, 130, 246, 0.5)";continue}if(d==="ring-2"){a.boxShadow="0 0 0 2px rgba(59, 130, 246, 0.5)";continue}const Ft=d.match(/^ring-([\w-]+)(?:\/([\d]+))?$/);if(Ft&&!d.match(/^ring-\d$/)){const tt=Ft[1],Yt=Ft[2],It=c[tt];if(It){const le=Yt?parseInt(Yt)/100:1;a.boxShadow&&a.boxShadow.includes("0 0 0")&&(a.boxShadow=a.boxShadow.replace(/rgba\([^)]+\)/,Yn(It,le)))}continue}if(d==="backdrop-blur"){a.backdropFilter="blur(8px)";continue}if(d==="backdrop-blur-none"){a.backdropFilter="blur(0)";continue}if(d==="backdrop-blur-sm"){a.backdropFilter="blur(4px)";continue}if(d==="backdrop-blur-md"){a.backdropFilter="blur(12px)";continue}if(d==="backdrop-blur-lg"){a.backdropFilter="blur(16px)";continue}if(d==="backdrop-blur-xl"){a.backdropFilter="blur(24px)";continue}if(d==="backdrop-blur-2xl"){a.backdropFilter="blur(40px)";continue}if(d==="backdrop-blur-3xl"){a.backdropFilter="blur(64px)";continue}if(d==="blur"){a.filter="blur(8px)";continue}if(d==="blur-none"){a.filter="blur(0)";continue}if(d==="blur-sm"){a.filter="blur(4px)";continue}if(d==="blur-md"){a.filter="blur(12px)";continue}if(d==="blur-lg"){a.filter="blur(16px)";continue}if(d==="blur-xl"){a.filter="blur(24px)";continue}if(d==="blur-2xl"){a.filter="blur(40px)";continue}if(d==="blur-3xl"){a.filter="blur(64px)";continue}const He=d.match(/^scale-(\d+)$/);if(He){const tt=parseInt(He[1])/100;a.transform=`scale(${tt})`;continue}const nn=d.match(/^scale-x-(\d+)$/);if(nn){const tt=parseInt(nn[1])/100;a.transform=`scaleX(${tt})`;continue}const ys=d.match(/^scale-y-(\d+)$/);if(ys){const tt=parseInt(ys[1])/100;a.transform=`scaleY(${tt})`;continue}const bs=d.match(/^rotate-(\d+)$/);if(bs){a.transform=`rotate(${bs[1]}deg)`;continue}const vs=d.match(/^-rotate-(\d+)$/);if(vs){a.transform=`rotate(-${vs[1]}deg)`;continue}const mn=d.match(/^translate-x-(\d+(?:\.\d+)?)$/);if(mn){const tt=vt[mn[1]]||`${parseFloat(mn[1])*.25}rem`;a.transform=`translateX(${tt})`;continue}const pn=d.match(/^-translate-x-(\d+(?:\.\d+)?)$/);if(pn){const tt=vt[pn[1]]||`${parseFloat(pn[1])*.25}rem`;a.transform=`translateX(-${tt})`;continue}const Ie=d.match(/^translate-y-(\d+(?:\.\d+)?)$/);if(Ie){const tt=vt[Ie[1]]||`${parseFloat(Ie[1])*.25}rem`;a.transform=`translateY(${tt})`;continue}const ie=d.match(/^-translate-y-(\d+(?:\.\d+)?)$/);if(ie){const tt=vt[ie[1]]||`${parseFloat(ie[1])*.25}rem`;a.transform=`translateY(-${tt})`;continue}if(d==="translate-x-full"){a.transform="translateX(100%)";continue}if(d==="-translate-x-full"){a.transform="translateX(-100%)";continue}if(d==="translate-y-full"){a.transform="translateY(100%)";continue}if(d==="-translate-y-full"){a.transform="translateY(-100%)";continue}if(d==="translate-x-1/2"){a.transform="translateX(50%)";continue}if(d==="-translate-x-1/2"){a.transform="translateX(-50%)";continue}if(d==="translate-y-1/2"){a.transform="translateY(50%)";continue}if(d==="-translate-y-1/2"){a.transform="translateY(-50%)";continue}if(d.startsWith("animate-")||d.startsWith("divide-")||d.startsWith("group-"))continue;if(d==="leading-none"){a.lineHeight="1";continue}if(d==="leading-tight"){a.lineHeight="1.25";continue}if(d==="leading-snug"){a.lineHeight="1.375";continue}if(d==="leading-normal"){a.lineHeight="1.5";continue}if(d==="leading-relaxed"){a.lineHeight="1.625";continue}if(d==="leading-loose"){a.lineHeight="2";continue}if(d==="tracking-tighter"){a.letterSpacing="-0.05em";continue}if(d==="tracking-tight"){a.letterSpacing="-0.025em";continue}if(d==="tracking-normal"){a.letterSpacing="0em";continue}if(d==="tracking-wide"){a.letterSpacing="0.025em";continue}if(d==="tracking-wider"){a.letterSpacing="0.05em";continue}if(d==="tracking-widest"){a.letterSpacing="0.1em";continue}const re=d.match(/^tracking-\[(.+)\]$/);if(re){a.letterSpacing=re[1];continue}const sn=d.match(/^w-\[(.+)\]$/);if(sn){a.width=sn[1];continue}const Wt=d.match(/^h-\[(.+)\]$/);if(Wt){a.height=Wt[1];continue}const ji=d.match(/^min-h-\[(.+)\]$/);if(ji){a.minHeight=ji[1];continue}const gn=d.match(/^max-w-\[(.+)\]$/);if(gn){a.maxWidth=gn[1];continue}}return u&&f&&(p?a.backgroundImage=`linear-gradient(${u}, ${f}, ${p}, ${g||f})`:g?a.backgroundImage=`linear-gradient(${u}, ${f}, ${g})`:a.backgroundImage=`linear-gradient(${u}, ${f}, transparent)`),a}function Yn(e,t){const n=parseInt(e.slice(1,3),16),s=parseInt(e.slice(3,5),16),i=parseInt(e.slice(5,7),16);return`rgba(${n}, ${s}, ${i}, ${t})`}const zu={margin:0,padding:0,boxSizing:"border-box",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale"};function fS(e){return`
25
+ }`)}return o.join(`
26
+ `)}const DS={slate:{50:"#f8fafc",100:"#f1f5f9",200:"#e2e8f0",300:"#cbd5e1",400:"#94a3b8",500:"#64748b",600:"#475569",700:"#334155",800:"#1e293b",900:"#0f172a",950:"#020617"},gray:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827",950:"#030712"},zinc:{50:"#fafafa",100:"#f4f4f5",200:"#e4e4e7",300:"#d4d4d8",400:"#a1a1aa",500:"#71717a",600:"#52525b",700:"#3f3f46",800:"#27272a",900:"#18181b",950:"#09090b"},neutral:{50:"#fafafa",100:"#f5f5f5",200:"#e5e5e5",300:"#d4d4d4",400:"#a3a3a3",500:"#737373",600:"#525252",700:"#404040",800:"#262626",900:"#171717",950:"#0a0a0a"},stone:{50:"#fafaf9",100:"#f5f5f4",200:"#e7e5e4",300:"#d6d3d1",400:"#a8a29e",500:"#78716c",600:"#57534e",700:"#44403c",800:"#292524",900:"#1c1917",950:"#0c0a09"},red:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d",950:"#450a0a"},orange:{50:"#fff7ed",100:"#ffedd5",200:"#fed7aa",300:"#fdba74",400:"#fb923c",500:"#f97316",600:"#ea580c",700:"#c2410c",800:"#9a3412",900:"#7c2d12",950:"#431407"},amber:{50:"#fffbeb",100:"#fef3c7",200:"#fde68a",300:"#fcd34d",400:"#fbbf24",500:"#f59e0b",600:"#d97706",700:"#b45309",800:"#92400e",900:"#78350f",950:"#451a03"},yellow:{50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12",950:"#422006"},lime:{50:"#f7fee7",100:"#ecfccb",200:"#d9f99d",300:"#bef264",400:"#a3e635",500:"#84cc16",600:"#65a30d",700:"#4d7c0f",800:"#3f6212",900:"#365314",950:"#1a2e05"},green:{50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d",950:"#052e16"},emerald:{50:"#ecfdf5",100:"#d1fae5",200:"#a7f3d0",300:"#6ee7b7",400:"#34d399",500:"#10b981",600:"#059669",700:"#047857",800:"#065f46",900:"#064e3b",950:"#022c22"},teal:{50:"#f0fdfa",100:"#ccfbf1",200:"#99f6e4",300:"#5eead4",400:"#2dd4bf",500:"#14b8a6",600:"#0d9488",700:"#0f766e",800:"#115e59",900:"#134e4a",950:"#042f2e"},cyan:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"},sky:{50:"#f0f9ff",100:"#e0f2fe",200:"#bae6fd",300:"#7dd3fc",400:"#38bdf8",500:"#0ea5e9",600:"#0284c7",700:"#0369a1",800:"#075985",900:"#0c4a6e",950:"#082f49"},blue:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a",950:"#172554"},indigo:{50:"#eef2ff",100:"#e0e7ff",200:"#c7d2fe",300:"#a5b4fc",400:"#818cf8",500:"#6366f1",600:"#4f46e5",700:"#4338ca",800:"#3730a3",900:"#312e81",950:"#1e1b4b"},violet:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"},purple:{50:"#faf5ff",100:"#f3e8ff",200:"#e9d5ff",300:"#d8b4fe",400:"#c084fc",500:"#a855f7",600:"#9333ea",700:"#7e22ce",800:"#6b21a8",900:"#581c87",950:"#3b0764"},fuchsia:{50:"#fdf4ff",100:"#fae8ff",200:"#f5d0fe",300:"#f0abfc",400:"#e879f9",500:"#d946ef",600:"#c026d3",700:"#a21caf",800:"#86198f",900:"#701a75",950:"#4a044e"},pink:{50:"#fdf2f8",100:"#fce7f3",200:"#fbcfe8",300:"#f9a8d4",400:"#f472b6",500:"#ec4899",600:"#db2777",700:"#be185d",800:"#9d174d",900:"#831843",950:"#500724"},rose:{50:"#fff1f2",100:"#ffe4e6",200:"#fecdd3",300:"#fda4af",400:"#fb7185",500:"#f43f5e",600:"#e11d48",700:"#be123c",800:"#9f1239",900:"#881337",950:"#4c0519"}},xc={transparent:"transparent",current:"currentColor",inherit:"inherit",black:"#000000",white:"#ffffff",primary:"#3b82f6",secondary:"#64748b",accent:"#ec4899",success:"#22c55e",warning:"#eab308",error:"#ef4444",info:"#3b82f6"};for(const[e,t]of Object.entries(DS))for(const[n,i]of Object.entries(t))xc[`${e}-${n}`]=i;const Ht={0:"0px","0.5":"0.125rem",1:"0.25rem","1.5":"0.375rem",2:"0.5rem","2.5":"0.625rem",3:"0.75rem","3.5":"0.875rem",4:"1rem",5:"1.25rem",6:"1.5rem",7:"1.75rem",8:"2rem",9:"2.25rem",10:"2.5rem",11:"2.75rem",12:"3rem",14:"3.5rem",16:"4rem",20:"5rem",24:"6rem",28:"7rem",32:"8rem",36:"9rem",40:"10rem",44:"11rem",48:"12rem",52:"13rem",56:"14rem",60:"15rem",64:"16rem",72:"18rem",80:"20rem",96:"24rem"},$S={xs:{fontSize:"0.75rem",lineHeight:"1rem"},sm:{fontSize:"0.875rem",lineHeight:"1.25rem"},base:{fontSize:"1rem",lineHeight:"1.5rem"},lg:{fontSize:"1.125rem",lineHeight:"1.75rem"},xl:{fontSize:"1.25rem",lineHeight:"1.75rem"},"2xl":{fontSize:"1.5rem",lineHeight:"2rem"},"3xl":{fontSize:"1.875rem",lineHeight:"2.25rem"},"4xl":{fontSize:"2.25rem",lineHeight:"2.5rem"},"5xl":{fontSize:"3rem",lineHeight:"1"},"6xl":{fontSize:"3.75rem",lineHeight:"1"},"7xl":{fontSize:"4.5rem",lineHeight:"1"},"8xl":{fontSize:"6rem",lineHeight:"1"},"9xl":{fontSize:"8rem",lineHeight:"1"}};function wh(e,t,n=!0){if(!e)return{};e=String(e);const{colorMode:i,...r}=t||{},o=i==="light",l=e.match(/(?:^|\s)dark:([^\s]+)/g)||[],h=e.replace(/(?:^|\s)dark:[^\s]+/g," ").replace(/\s+/g," ").trim();!o&&l.length?e=h?`${h} ${l.map(p=>p.trim().replace(/^dark:/,"")).join(" ")}`:l.map(p=>p.trim().replace(/^dark:/,"")).join(" "):e=h;const u=r?{...xc,...Object.fromEntries(Object.entries(r).filter(([,p])=>p))}:xc;o&&n&&(u.white="#000000",u.black="#ffffff",u["gray-300"]="#4b5563",u["gray-400"]="#374151",u["gray-500"]="#374151",u["gray-600"]="#1f2937",u["gray-700"]="#111827",u["gray-800"]="#0f172a",u["slate-300"]="#475569",u["slate-400"]="#334155",u["slate-500"]="#334155",u["slate-600"]="#1e293b");const f=e.split(/\s+/).filter(Boolean),c={};let m="",y="",x="",_="";for(let p of f){if(p.startsWith("hover:")||p.startsWith("focus:")||p.startsWith("active:")||p.startsWith("group-hover:")||p==="transition"||p==="transition-all"||p==="transition-colors"||p==="transition-opacity"||p==="transition-transform"||p.startsWith("duration-")||p.startsWith("ease-")||p==="cursor-pointer"||p==="grayscale"||((p.startsWith("sm:")||p.startsWith("md:")||p.startsWith("lg:")||p.startsWith("xl:")||p.startsWith("2xl:"))&&(p=p.replace(/^(sm:|md:|lg:|xl:|2xl:)/,"")),p.startsWith("placeholder-"))||p.startsWith("disabled:"))continue;const E=p.match(/^bg-\[([^\]]+)\]$/);if(E){const dt=E[1];dt.startsWith("url(")?c.backgroundImage=dt:c.backgroundColor=dt;continue}const T=p.match(/^text-\[(#[0-9a-fA-F]{3,8}|rgb[a]?\([^)]+\)|hsl[a]?\([^)]+\))\]$/);if(T){c.color=T[1];continue}const k=p.match(/^text-\[(\d+(?:\.\d+)?(?:px|rem|em|%))\]$/);if(k){c.fontSize=k[1];continue}const A=p.match(/^w-\[([^\]]+)\]$/);if(A){c.width=A[1];continue}const P=p.match(/^h-\[([^\]]+)\]$/);if(P){c.height=P[1];continue}const I=p.match(/^min-w-\[([^\]]+)\]$/);if(I){c.minWidth=I[1];continue}const $=p.match(/^max-w-\[([^\]]+)\]$/);if($){c.maxWidth=$[1];continue}const j=p.match(/^min-h-\[([^\]]+)\]$/);if(j){c.minHeight=j[1];continue}const U=p.match(/^max-h-\[([^\]]+)\]$/);if(U){c.maxHeight=U[1];continue}const nt=p.match(/^p-\[([^\]]+)\]$/);if(nt){c.padding=nt[1];continue}const ot=p.match(/^px-\[([^\]]+)\]$/);if(ot){c.paddingLeft=ot[1],c.paddingRight=ot[1];continue}const q=p.match(/^py-\[([^\]]+)\]$/);if(q){c.paddingTop=q[1],c.paddingBottom=q[1];continue}const it=p.match(/^pt-\[([^\]]+)\]$/);if(it){c.paddingTop=it[1];continue}const ct=p.match(/^pr-\[([^\]]+)\]$/);if(ct){c.paddingRight=ct[1];continue}const K=p.match(/^pb-\[([^\]]+)\]$/);if(K){c.paddingBottom=K[1];continue}const Z=p.match(/^pl-\[([^\]]+)\]$/);if(Z){c.paddingLeft=Z[1];continue}const tt=p.match(/^m-\[([^\]]+)\]$/);if(tt){c.margin=tt[1];continue}const st=p.match(/^mx-\[([^\]]+)\]$/);if(st){c.marginLeft=st[1],c.marginRight=st[1];continue}const J=p.match(/^my-\[([^\]]+)\]$/);if(J){c.marginTop=J[1],c.marginBottom=J[1];continue}const bt=p.match(/^mt-\[([^\]]+)\]$/);if(bt){c.marginTop=bt[1];continue}const et=p.match(/^mr-\[([^\]]+)\]$/);if(et){c.marginRight=et[1];continue}const ht=p.match(/^mb-\[([^\]]+)\]$/);if(ht){c.marginBottom=ht[1];continue}const kt=p.match(/^ml-\[([^\]]+)\]$/);if(kt){c.marginLeft=kt[1];continue}const St=p.match(/^gap-\[([^\]]+)\]$/);if(St){c.gap=St[1];continue}const Tt=p.match(/^gap-x-\[([^\]]+)\]$/);if(Tt){c.columnGap=Tt[1];continue}const Rt=p.match(/^gap-y-\[([^\]]+)\]$/);if(Rt){c.rowGap=Rt[1];continue}const Et=p.match(/^rounded-\[([^\]]+)\]$/);if(Et){c.borderRadius=Et[1];continue}const re=p.match(/^border-\[(#[0-9a-fA-F]{3,8}|rgb[a]?\([^)]+\))\]$/);if(re){c.borderColor=re[1];continue}const oe=p.match(/^border-\[(\d+(?:\.\d+)?(?:px)?)\]$/);if(oe){c.borderWidth=oe[1];continue}const Ot=p.match(/^top-\[([^\]]+)\]$/);if(Ot){c.top=Ot[1];continue}const Re=p.match(/^right-\[([^\]]+)\]$/);if(Re){c.right=Re[1];continue}const Qe=p.match(/^bottom-\[([^\]]+)\]$/);if(Qe){c.bottom=Qe[1];continue}const ye=p.match(/^left-\[([^\]]+)\]$/);if(ye){c.left=ye[1];continue}const hi=p.match(/^inset-\[([^\]]+)\]$/);if(hi){c.inset=hi[1];continue}const ui=p.match(/^z-\[([^\]]+)\]$/);if(ui){c.zIndex=parseInt(ui[1])||ui[1];continue}const Ee=p.match(/^opacity-\[([^\]]+)\]$/);if(Ee){c.opacity=parseFloat(Ee[1]);continue}const Ft=p.match(/^leading-\[([^\]]+)\]$/);if(Ft){c.lineHeight=Ft[1];continue}if(p==="flex"){c.display="flex";continue}if(p==="grid"){c.display="grid";continue}if(p==="block"){c.display="block";continue}if(p==="inline"){c.display="inline";continue}if(p==="inline-flex"){c.display="inline-flex";continue}if(p==="inline-block"){c.display="inline-block";continue}if(p==="hidden"){c.display="none";continue}if(p==="flex-col"){c.flexDirection="column";continue}if(p==="flex-row"){c.flexDirection="row";continue}if(p==="flex-wrap"){c.flexWrap="wrap";continue}if(p==="flex-nowrap"){c.flexWrap="nowrap";continue}if(p==="flex-col-reverse"){c.flexDirection="column-reverse";continue}if(p==="flex-row-reverse"){c.flexDirection="row-reverse";continue}if(p==="flex-1"){c.flex="1 1 0%";continue}if(p==="flex-auto"){c.flex="1 1 auto";continue}if(p==="flex-initial"){c.flex="0 1 auto";continue}if(p==="flex-none"){c.flex="none";continue}if(p==="grow"){c.flexGrow=1;continue}if(p==="grow-0"){c.flexGrow=0;continue}if(p==="shrink"){c.flexShrink=1;continue}if(p==="shrink-0"){c.flexShrink=0;continue}if(p==="items-start"){c.alignItems="flex-start";continue}if(p==="items-center"){c.alignItems="center";continue}if(p==="items-end"){c.alignItems="flex-end";continue}if(p==="items-stretch"){c.alignItems="stretch";continue}if(p==="items-baseline"){c.alignItems="baseline";continue}if(p==="justify-start"){c.justifyContent="flex-start";continue}if(p==="justify-center"){c.justifyContent="center";continue}if(p==="justify-end"){c.justifyContent="flex-end";continue}if(p==="justify-between"){c.justifyContent="space-between";continue}if(p==="justify-around"){c.justifyContent="space-around";continue}if(p==="justify-evenly"){c.justifyContent="space-evenly";continue}if(p==="justify-items-start"){c.justifyItems="start";continue}if(p==="justify-items-center"){c.justifyItems="center";continue}if(p==="justify-items-end"){c.justifyItems="end";continue}if(p==="justify-items-stretch"){c.justifyItems="stretch";continue}if(p==="self-auto"){c.alignSelf="auto";continue}if(p==="self-start"){c.alignSelf="flex-start";continue}if(p==="self-center"){c.alignSelf="center";continue}if(p==="self-end"){c.alignSelf="flex-end";continue}if(p==="self-stretch"){c.alignSelf="stretch";continue}if(p==="self-baseline"){c.alignSelf="baseline";continue}if(p==="justify-self-auto"){c.justifySelf="auto";continue}if(p==="justify-self-start"){c.justifySelf="start";continue}if(p==="justify-self-center"){c.justifySelf="center";continue}if(p==="justify-self-end"){c.justifySelf="end";continue}if(p==="justify-self-stretch"){c.justifySelf="stretch";continue}if(p==="place-content-center"){c.placeContent="center";continue}if(p==="place-content-start"){c.placeContent="start";continue}if(p==="place-content-end"){c.placeContent="end";continue}if(p==="place-content-between"){c.placeContent="space-between";continue}if(p==="place-content-around"){c.placeContent="space-around";continue}if(p==="place-content-evenly"){c.placeContent="space-evenly";continue}if(p==="place-content-stretch"){c.placeContent="stretch";continue}if(p==="place-items-start"){c.placeItems="start";continue}if(p==="place-items-center"){c.placeItems="center";continue}if(p==="place-items-end"){c.placeItems="end";continue}if(p==="place-items-stretch"){c.placeItems="stretch";continue}if(p==="text-left"){c.textAlign="left";continue}if(p==="text-center"){c.textAlign="center";continue}if(p==="text-right"){c.textAlign="right";continue}if(p==="text-justify"){c.textAlign="justify";continue}if(p==="text-start"){c.textAlign="start";continue}if(p==="text-end"){c.textAlign="end";continue}if(p==="whitespace-normal"){c.whiteSpace="normal";continue}if(p==="whitespace-nowrap"){c.whiteSpace="nowrap";continue}if(p==="whitespace-pre"){c.whiteSpace="pre";continue}if(p==="whitespace-pre-line"){c.whiteSpace="pre-line";continue}if(p==="whitespace-pre-wrap"){c.whiteSpace="pre-wrap";continue}if(p==="whitespace-break-spaces"){c.whiteSpace="break-spaces";continue}if(p==="break-normal"){c.wordBreak="normal",c.overflowWrap="normal";continue}if(p==="break-words"){c.overflowWrap="break-word";continue}if(p==="break-all"){c.wordBreak="break-all";continue}if(p==="break-keep"){c.wordBreak="keep-all";continue}if(p==="truncate"){c.overflow="hidden",c.textOverflow="ellipsis",c.whiteSpace="nowrap";continue}if(p==="text-ellipsis"){c.textOverflow="ellipsis";continue}if(p==="text-clip"){c.textOverflow="clip";continue}if(p==="underline"){c.textDecoration="underline";continue}if(p==="overline"){c.textDecoration="overline";continue}if(p==="line-through"){c.textDecoration="line-through";continue}if(p==="no-underline"){c.textDecoration="none";continue}if(p==="uppercase"){c.textTransform="uppercase";continue}if(p==="lowercase"){c.textTransform="lowercase";continue}if(p==="capitalize"){c.textTransform="capitalize";continue}if(p==="normal-case"){c.textTransform="none";continue}if(p==="italic"){c.fontStyle="italic";continue}if(p==="not-italic"){c.fontStyle="normal";continue}if(p==="font-thin"){c.fontWeight=100;continue}if(p==="font-extralight"){c.fontWeight=200;continue}if(p==="font-light"){c.fontWeight=300;continue}if(p==="font-normal"){c.fontWeight=400;continue}if(p==="font-medium"){c.fontWeight=500;continue}if(p==="font-semibold"){c.fontWeight=600;continue}if(p==="font-bold"){c.fontWeight=700;continue}if(p==="font-extrabold"){c.fontWeight=800;continue}if(p==="font-black"){c.fontWeight=900;continue}if(p==="w-full"){c.width="100%";continue}if(p==="w-screen"){c.width="100vw";continue}if(p==="w-auto"){c.width="auto";continue}if(p==="w-fit"){c.width="fit-content";continue}if(p==="w-min"){c.width="min-content";continue}if(p==="w-max"){c.width="max-content";continue}const qt=p.match(/^w-(\d+(?:\.\d+)?)$/);if(qt){c.width=Ht[qt[1]]||`${parseFloat(qt[1])*.25}rem`;continue}const fe=p.match(/^w-(\d+)\/(\d+)$/);if(fe){const dt=parseInt(fe[1])/parseInt(fe[2])*100;c.width=`${dt}%`;continue}if(p==="h-full"){c.height="100%";continue}if(p==="h-screen"){c.height="100vh";continue}if(p==="h-auto"){c.height="auto";continue}if(p==="h-fit"){c.height="fit-content";continue}if(p==="h-min"){c.height="min-content";continue}if(p==="h-max"){c.height="max-content";continue}const Kt=p.match(/^h-(\d+(?:\.\d+)?)$/);if(Kt){c.height=Ht[Kt[1]]||`${parseFloat(Kt[1])*.25}rem`;continue}const Lt=p.match(/^h-(\d+)\/(\d+)$/);if(Lt){const dt=parseInt(Lt[1])/parseInt(Lt[2])*100;c.height=`${dt}%`;continue}if(p==="min-h-screen"){c.minHeight="100vh";continue}if(p==="min-h-full"){c.minHeight="100%";continue}if(p==="min-h-0"){c.minHeight="0";continue}if(p==="min-h-fit"){c.minHeight="fit-content";continue}const jt=p.match(/^min-h-(\d+(?:\.\d+)?)$/);if(jt){c.minHeight=Ht[jt[1]]||`${parseFloat(jt[1])*.25}rem`;continue}if(p==="min-w-0"){c.minWidth="0";continue}if(p==="min-w-full"){c.minWidth="100%";continue}if(p==="min-w-fit"){c.minWidth="fit-content";continue}const $t=p.match(/^min-w-(\d+(?:\.\d+)?)$/);if($t){c.minWidth=Ht[$t[1]]||`${parseFloat($t[1])*.25}rem`;continue}if(p==="max-w-none"){c.maxWidth="none";continue}if(p==="max-w-xs"){c.maxWidth="20rem";continue}if(p==="max-w-sm"){c.maxWidth="24rem";continue}if(p==="max-w-md"){c.maxWidth="28rem";continue}if(p==="max-w-lg"){c.maxWidth="32rem";continue}if(p==="max-w-xl"){c.maxWidth="36rem";continue}if(p==="max-w-2xl"){c.maxWidth="42rem";continue}if(p==="max-w-3xl"){c.maxWidth="48rem";continue}if(p==="max-w-4xl"){c.maxWidth="56rem";continue}if(p==="max-w-5xl"){c.maxWidth="64rem";continue}if(p==="max-w-6xl"){c.maxWidth="72rem";continue}if(p==="max-w-7xl"){c.maxWidth="80rem";continue}if(p==="max-w-full"){c.maxWidth="100%";continue}if(p==="max-w-prose"){c.maxWidth="65ch";continue}if(p==="max-w-screen-sm"){c.maxWidth="640px";continue}if(p==="max-w-screen-md"){c.maxWidth="768px";continue}if(p==="max-w-screen-lg"){c.maxWidth="1024px";continue}if(p==="max-w-screen-xl"){c.maxWidth="1280px";continue}if(p==="max-w-screen-2xl"){c.maxWidth="1536px";continue}if(p==="max-h-none"){c.maxHeight="none";continue}if(p==="max-h-full"){c.maxHeight="100%";continue}if(p==="max-h-screen"){c.maxHeight="100vh";continue}if(p==="max-h-fit"){c.maxHeight="fit-content";continue}const Se=p.match(/^max-h-(\d+(?:\.\d+)?)$/);if(Se){c.maxHeight=Ht[Se[1]]||`${parseFloat(Se[1])*.25}rem`;continue}if(p==="relative"){c.position="relative";continue}if(p==="absolute"){c.position="absolute";continue}if(p==="fixed"){c.position="fixed";continue}if(p==="sticky"){c.position="sticky";continue}if(p==="inset-0"){c.top="0",c.right="0",c.bottom="0",c.left="0";continue}if(p==="inset-auto"){c.top="auto",c.right="auto",c.bottom="auto",c.left="auto";continue}if(p==="inset-x-0"){c.left="0",c.right="0";continue}if(p==="inset-y-0"){c.top="0",c.bottom="0";continue}const _n=p.match(/^inset-(\d+(?:\.\d+)?)$/);if(_n){const dt=Ht[_n[1]]||`${parseFloat(_n[1])*.25}rem`;c.top=dt,c.right=dt,c.bottom=dt,c.left=dt;continue}const di=p.match(/^inset-x-(\d+(?:\.\d+)?)$/);if(di){const dt=Ht[di[1]]||`${parseFloat(di[1])*.25}rem`;c.left=dt,c.right=dt;continue}const Ne=p.match(/^inset-y-(\d+(?:\.\d+)?)$/);if(Ne){const dt=Ht[Ne[1]]||`${parseFloat(Ne[1])*.25}rem`;c.top=dt,c.bottom=dt;continue}if(p==="top-0"){c.top="0";continue}if(p==="top-auto"){c.top="auto";continue}if(p==="top-full"){c.top="100%";continue}const Ce=p.match(/^top-(\d+(?:\.\d+)?)$/);if(Ce){c.top=Ht[Ce[1]]||`${parseFloat(Ce[1])*.25}rem`;continue}const fi=p.match(/^-top-(\d+(?:\.\d+)?)$/);if(fi){const dt=Ht[fi[1]]||`${parseFloat(fi[1])*.25}rem`;c.top=`-${dt}`;continue}if(p==="right-0"){c.right="0";continue}if(p==="right-auto"){c.right="auto";continue}if(p==="right-full"){c.right="100%";continue}const $e=p.match(/^right-(\d+(?:\.\d+)?)$/);if($e){c.right=Ht[$e[1]]||`${parseFloat($e[1])*.25}rem`;continue}const vt=p.match(/^-right-(\d+(?:\.\d+)?)$/);if(vt){const dt=Ht[vt[1]]||`${parseFloat(vt[1])*.25}rem`;c.right=`-${dt}`;continue}if(p==="bottom-0"){c.bottom="0";continue}if(p==="bottom-auto"){c.bottom="auto";continue}if(p==="bottom-full"){c.bottom="100%";continue}const Ze=p.match(/^bottom-(\d+(?:\.\d+)?)$/);if(Ze){c.bottom=Ht[Ze[1]]||`${parseFloat(Ze[1])*.25}rem`;continue}const ve=p.match(/^-bottom-(\d+(?:\.\d+)?)$/);if(ve){const dt=Ht[ve[1]]||`${parseFloat(ve[1])*.25}rem`;c.bottom=`-${dt}`;continue}if(p==="left-0"){c.left="0";continue}if(p==="left-auto"){c.left="auto";continue}if(p==="left-full"){c.left="100%";continue}const Ni=p.match(/^left-(\d+(?:\.\d+)?)$/);if(Ni){c.left=Ht[Ni[1]]||`${parseFloat(Ni[1])*.25}rem`;continue}const Jn=p.match(/^-left-(\d+(?:\.\d+)?)$/);if(Jn){const dt=Ht[Jn[1]]||`${parseFloat(Jn[1])*.25}rem`;c.left=`-${dt}`;continue}if(p==="overflow-hidden"){c.overflow="hidden";continue}if(p==="overflow-auto"){c.overflow="auto";continue}if(p==="overflow-scroll"){c.overflow="scroll";continue}if(p==="overflow-visible"){c.overflow="visible";continue}if(p==="overflow-x-auto"){c.overflowX="auto";continue}if(p==="overflow-y-auto"){c.overflowY="auto";continue}if(p==="overflow-x-hidden"){c.overflowX="hidden";continue}if(p==="overflow-y-hidden"){c.overflowY="hidden";continue}if(p==="overflow-x-scroll"){c.overflowX="scroll";continue}if(p==="overflow-y-scroll"){c.overflowY="scroll";continue}if(p==="object-cover"){c.objectFit="cover";continue}if(p==="object-contain"){c.objectFit="contain";continue}if(p==="object-fill"){c.objectFit="fill";continue}if(p==="object-center"){c.objectPosition="center";continue}if(p==="z-0"){c.zIndex=0;continue}if(p==="z-10"){c.zIndex=10;continue}if(p==="z-20"){c.zIndex=20;continue}if(p==="z-30"){c.zIndex=30;continue}if(p==="z-40"){c.zIndex=40;continue}if(p==="z-50"){c.zIndex=50;continue}const mi=p.match(/^opacity-(\d+)$/);if(mi){c.opacity=parseInt(mi[1])/100;continue}const ee=p.match(/^text-(xs|sm|base|lg|xl|[2-9]xl)$/);if(ee){const dt=$S[ee[1]];dt&&(c.fontSize=dt.fontSize,c.lineHeight=dt.lineHeight);continue}const Wt=p.match(/^text-([\w-]+)(?:\/([\d]+))?$/);if(Wt&&!p.startsWith("text-center")&&!p.startsWith("text-left")&&!p.startsWith("text-right")){const dt=Wt[1],ie=Wt[2],Bt=o?u[dt]:{black:"#e5e7eb","gray-600":"#9ca3af","gray-700":"#d1d5db","gray-800":"#e5e7eb","gray-900":"#f3f4f6","slate-700":"#cbd5e1","slate-800":"#e2e8f0","slate-900":"#f1f5f9"}[dt]||u[dt];Bt&&(ie?c.color=Es(Bt,parseInt(ie)/100):c.color=Bt);continue}if(p==="bg-clip-text"){c.WebkitBackgroundClip="text",c.backgroundClip="text",c.WebkitTextFillColor="transparent";continue}if(p==="bg-fixed"){c.backgroundAttachment="fixed";continue}if(p==="bg-scroll"){c.backgroundAttachment="scroll";continue}const pi=p.match(/^bg-([\w-]+)(?:\/([\d]+))?$/);if(pi&&!p.startsWith("bg-gradient")){const dt=pi[1],ie=pi[2],Bt=o?u[dt]:{white:"#1f2937","gray-50":"#1f2937","gray-100":"#1f2937","gray-200":"#374151","gray-300":"#4b5563","slate-50":"#1f2937","slate-100":"#1f2937","slate-200":"#334155"}[dt]||u[dt];Bt&&(ie?c.backgroundColor=Es(Bt,parseInt(ie)/100):c.backgroundColor=Bt);continue}if(p==="bg-gradient-to-t"){m="to top";continue}if(p==="bg-gradient-to-tr"){m="to top right";continue}if(p==="bg-gradient-to-r"){m="to right";continue}if(p==="bg-gradient-to-br"){m="to bottom right";continue}if(p==="bg-gradient-to-b"){m="to bottom";continue}if(p==="bg-gradient-to-bl"){m="to bottom left";continue}if(p==="bg-gradient-to-l"){m="to left";continue}if(p==="bg-gradient-to-tl"){m="to top left";continue}const gi=p.match(/^from-([\w-]+)(?:\/([\d]+))?$/);if(gi){const dt=gi[1],ie=gi[2],xt=u[dt];xt&&(y=ie?Es(xt,parseInt(ie)/100):xt);continue}const Tn=p.match(/^via-([\w-]+)(?:\/([\d]+))?$/);if(Tn){const dt=Tn[1],ie=Tn[2],xt=u[dt];xt&&(x=ie?Es(xt,parseInt(ie)/100):xt);continue}const yi=p.match(/^to-([\w-]+)(?:\/([\d]+))?$/);if(yi){const dt=yi[1],ie=yi[2],xt=u[dt];xt&&(_=ie?Es(xt,parseInt(ie)/100):xt);continue}const Ii=p.match(/^p-(\d+(?:\.\d+)?)$/);if(Ii){c.padding=Ht[Ii[1]]||`${parseFloat(Ii[1])*.25}rem`;continue}const zi=p.match(/^px-(\d+(?:\.\d+)?)$/);if(zi){const dt=Ht[zi[1]]||`${parseFloat(zi[1])*.25}rem`;c.paddingLeft=dt,c.paddingRight=dt;continue}const Bn=p.match(/^py-(\d+(?:\.\d+)?)$/);if(Bn){const dt=Ht[Bn[1]]||`${parseFloat(Bn[1])*.25}rem`;c.paddingTop=dt,c.paddingBottom=dt;continue}const Di=p.match(/^pt-(\d+(?:\.\d+)?)$/);if(Di){c.paddingTop=Ht[Di[1]]||`${parseFloat(Di[1])*.25}rem`;continue}const $i=p.match(/^pr-(\d+(?:\.\d+)?)$/);if($i){c.paddingRight=Ht[$i[1]]||`${parseFloat($i[1])*.25}rem`;continue}const Bi=p.match(/^pb-(\d+(?:\.\d+)?)$/);if(Bi){c.paddingBottom=Ht[Bi[1]]||`${parseFloat(Bi[1])*.25}rem`;continue}const fs=p.match(/^pl-(\d+(?:\.\d+)?)$/);if(fs){c.paddingLeft=Ht[fs[1]]||`${parseFloat(fs[1])*.25}rem`;continue}const vi=p.match(/^m-(\d+(?:\.\d+)?)$/);if(vi){c.margin=Ht[vi[1]]||`${parseFloat(vi[1])*.25}rem`;continue}const Ue=p.match(/^mx-(\d+(?:\.\d+)?|auto)$/);if(Ue){const dt=Ue[1]==="auto"?"auto":Ht[Ue[1]]||`${parseFloat(Ue[1])*.25}rem`;c.marginLeft=dt,c.marginRight=dt;continue}const bi=p.match(/^my-(\d+(?:\.\d+)?|auto)$/);if(bi){const dt=bi[1]==="auto"?"auto":Ht[bi[1]]||`${parseFloat(bi[1])*.25}rem`;c.marginTop=dt,c.marginBottom=dt;continue}const wn=p.match(/^mt-(\d+(?:\.\d+)?|auto)$/);if(wn){c.marginTop=wn[1]==="auto"?"auto":Ht[wn[1]]||`${parseFloat(wn[1])*.25}rem`;continue}const Qn=p.match(/^mr-(\d+(?:\.\d+)?|auto)$/);if(Qn){c.marginRight=Qn[1]==="auto"?"auto":Ht[Qn[1]]||`${parseFloat(Qn[1])*.25}rem`;continue}const qe=p.match(/^mb-(\d+(?:\.\d+)?)$/);if(qe){c.marginBottom=Ht[qe[1]]||`${parseFloat(qe[1])*.25}rem`;continue}const gt=p.match(/^ml-(\d+(?:\.\d+)?|auto)$/);if(gt){c.marginLeft=gt[1]==="auto"?"auto":Ht[gt[1]]||`${parseFloat(gt[1])*.25}rem`;continue}if(p==="mt-auto"){c.marginTop="auto";continue}const Oi=p.match(/^gap-(\d+(?:\.\d+)?)$/);if(Oi){c.gap=Ht[Oi[1]]||`${parseFloat(Oi[1])*.25}rem`;continue}const ce=p.match(/^gap-x-(\d+(?:\.\d+)?)$/);if(ce){c.columnGap=Ht[ce[1]]||`${parseFloat(ce[1])*.25}rem`;continue}const Pe=p.match(/^gap-y-(\d+(?:\.\d+)?)$/);if(Pe){c.rowGap=Ht[Pe[1]]||`${parseFloat(Pe[1])*.25}rem`;continue}const Fi=p.match(/^space-x-(\d+(?:\.\d+)?)$/);if(Fi){c.columnGap=Ht[Fi[1]]||`${parseFloat(Fi[1])*.25}rem`;continue}const Kn=p.match(/^space-y-(\d+(?:\.\d+)?)$/);if(Kn){c.rowGap=Ht[Kn[1]]||`${parseFloat(Kn[1])*.25}rem`;continue}const Wi=p.match(/^space-x-\[([^\]]+)\]$/);if(Wi){c.columnGap=Wi[1];continue}const un=p.match(/^space-y-\[([^\]]+)\]$/);if(un){c.rowGap=un[1];continue}const Ke=p.match(/^grid-cols-(\d+)$/);if(Ke){c.gridTemplateColumns=`repeat(${Ke[1]}, minmax(0, 1fr))`;continue}if(p==="rounded"){c.borderRadius="0.25rem";continue}if(p==="rounded-none"){c.borderRadius="0";continue}if(p==="rounded-sm"){c.borderRadius="0.125rem";continue}if(p==="rounded-md"){c.borderRadius="0.375rem";continue}if(p==="rounded-lg"){c.borderRadius="0.5rem";continue}if(p==="rounded-xl"){c.borderRadius="0.75rem";continue}if(p==="rounded-2xl"){c.borderRadius="1rem";continue}if(p==="rounded-3xl"){c.borderRadius="1.5rem";continue}if(p==="rounded-full"){c.borderRadius="9999px";continue}if(p==="border"){c.borderWidth="1px",c.borderStyle="solid";continue}if(p==="border-0"){c.borderWidth="0";continue}if(p==="border-2"){c.borderWidth="2px",c.borderStyle="solid";continue}if(p==="border-t"){c.borderTopWidth="1px",c.borderStyle="solid";continue}if(p==="border-b"){c.borderBottomWidth="1px",c.borderStyle="solid";continue}if(p==="border-l"){c.borderLeftWidth="1px",c.borderStyle="solid";continue}if(p==="border-r"){c.borderRightWidth="1px",c.borderStyle="solid";continue}const xi=p.match(/^border-t-(\d+)$/);if(xi){c.borderTopWidth=`${xi[1]}px`,c.borderStyle="solid";continue}const Vs=p.match(/^border-b-(\d+)$/);if(Vs){c.borderBottomWidth=`${Vs[1]}px`,c.borderStyle="solid";continue}const Vi=p.match(/^border-l-(\d+)$/);if(Vi){c.borderLeftWidth=`${Vi[1]}px`,c.borderStyle="solid";continue}const Sn=p.match(/^border-r-(\d+)$/);if(Sn){c.borderRightWidth=`${Sn[1]}px`,c.borderStyle="solid";continue}const On=p.match(/^border-(\d+)$/);if(On){c.borderWidth=`${On[1]}px`,c.borderStyle="solid";continue}const me=p.match(/^border-([\w-]+)(?:\/([\d]+))?$/);if(me&&!p.match(/^border-[trbl]$/)){const dt=me[1],ie=me[2],Bt=o?u[dt]:{white:"#374151","gray-100":"#374151","gray-200":"#374151","gray-300":"#4b5563","slate-100":"#334155","slate-200":"#334155","slate-300":"#475569"}[dt]||u[dt];Bt&&(c.borderColor=ie?Es(Bt,parseInt(ie)/100):Bt);continue}if(p==="shadow"){c.boxShadow="0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)";continue}if(p==="shadow-sm"){c.boxShadow="0 1px 2px 0 rgb(0 0 0 / 0.05)";continue}if(p==="shadow-md"){c.boxShadow="0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)";continue}if(p==="shadow-lg"){c.boxShadow="0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)";continue}if(p==="shadow-xl"){c.boxShadow="0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)";continue}if(p==="shadow-2xl"){c.boxShadow="0 25px 50px -12px rgb(0 0 0 / 0.25)";continue}if(p==="shadow-none"){c.boxShadow="none";continue}if(p==="ring"){c.boxShadow="0 0 0 3px rgba(59, 130, 246, 0.5)";continue}if(p==="ring-0"){c.boxShadow="0 0 0 0px transparent";continue}if(p==="ring-1"){c.boxShadow="0 0 0 1px rgba(59, 130, 246, 0.5)";continue}if(p==="ring-2"){c.boxShadow="0 0 0 2px rgba(59, 130, 246, 0.5)";continue}const dn=p.match(/^ring-([\w-]+)(?:\/([\d]+))?$/);if(dn&&!p.match(/^ring-\d$/)){const dt=dn[1],ie=dn[2],xt=u[dt];if(xt){const Bt=ie?parseInt(ie)/100:1;c.boxShadow&&c.boxShadow.includes("0 0 0")&&(c.boxShadow=c.boxShadow.replace(/rgba\([^)]+\)/,Es(xt,Bt)))}continue}if(p==="backdrop-blur"){c.backdropFilter="blur(8px)";continue}if(p==="backdrop-blur-none"){c.backdropFilter="blur(0)";continue}if(p==="backdrop-blur-sm"){c.backdropFilter="blur(4px)";continue}if(p==="backdrop-blur-md"){c.backdropFilter="blur(12px)";continue}if(p==="backdrop-blur-lg"){c.backdropFilter="blur(16px)";continue}if(p==="backdrop-blur-xl"){c.backdropFilter="blur(24px)";continue}if(p==="backdrop-blur-2xl"){c.backdropFilter="blur(40px)";continue}if(p==="backdrop-blur-3xl"){c.backdropFilter="blur(64px)";continue}if(p==="blur"){c.filter="blur(8px)";continue}if(p==="blur-none"){c.filter="blur(0)";continue}if(p==="blur-sm"){c.filter="blur(4px)";continue}if(p==="blur-md"){c.filter="blur(12px)";continue}if(p==="blur-lg"){c.filter="blur(16px)";continue}if(p==="blur-xl"){c.filter="blur(24px)";continue}if(p==="blur-2xl"){c.filter="blur(40px)";continue}if(p==="blur-3xl"){c.filter="blur(64px)";continue}const pe=p.match(/^scale-(\d+)$/);if(pe){const dt=parseInt(pe[1])/100;c.transform=`scale(${dt})`;continue}const Pn=p.match(/^scale-x-(\d+)$/);if(Pn){const dt=parseInt(Pn[1])/100;c.transform=`scaleX(${dt})`;continue}const Fn=p.match(/^scale-y-(\d+)$/);if(Fn){const dt=parseInt(Fn[1])/100;c.transform=`scaleY(${dt})`;continue}const ji=p.match(/^rotate-(\d+)$/);if(ji){c.transform=`rotate(${ji[1]}deg)`;continue}const Hi=p.match(/^-rotate-(\d+)$/);if(Hi){c.transform=`rotate(-${Hi[1]}deg)`;continue}const Wn=p.match(/^translate-x-(\d+(?:\.\d+)?)$/);if(Wn){const dt=Ht[Wn[1]]||`${parseFloat(Wn[1])*.25}rem`;c.transform=`translateX(${dt})`;continue}const fn=p.match(/^-translate-x-(\d+(?:\.\d+)?)$/);if(fn){const dt=Ht[fn[1]]||`${parseFloat(fn[1])*.25}rem`;c.transform=`translateX(-${dt})`;continue}const Vn=p.match(/^translate-y-(\d+(?:\.\d+)?)$/);if(Vn){const dt=Ht[Vn[1]]||`${parseFloat(Vn[1])*.25}rem`;c.transform=`translateY(${dt})`;continue}const rn=p.match(/^-translate-y-(\d+(?:\.\d+)?)$/);if(rn){const dt=Ht[rn[1]]||`${parseFloat(rn[1])*.25}rem`;c.transform=`translateY(-${dt})`;continue}if(p==="translate-x-full"){c.transform="translateX(100%)";continue}if(p==="-translate-x-full"){c.transform="translateX(-100%)";continue}if(p==="translate-y-full"){c.transform="translateY(100%)";continue}if(p==="-translate-y-full"){c.transform="translateY(-100%)";continue}if(p==="translate-x-1/2"){c.transform="translateX(50%)";continue}if(p==="-translate-x-1/2"){c.transform="translateX(-50%)";continue}if(p==="translate-y-1/2"){c.transform="translateY(50%)";continue}if(p==="-translate-y-1/2"){c.transform="translateY(-50%)";continue}if(p.startsWith("animate-")||p.startsWith("divide-")||p.startsWith("group-"))continue;if(p==="leading-none"){c.lineHeight="1";continue}if(p==="leading-tight"){c.lineHeight="1.25";continue}if(p==="leading-snug"){c.lineHeight="1.375";continue}if(p==="leading-normal"){c.lineHeight="1.5";continue}if(p==="leading-relaxed"){c.lineHeight="1.625";continue}if(p==="leading-loose"){c.lineHeight="2";continue}if(p==="tracking-tighter"){c.letterSpacing="-0.05em";continue}if(p==="tracking-tight"){c.letterSpacing="-0.025em";continue}if(p==="tracking-normal"){c.letterSpacing="0em";continue}if(p==="tracking-wide"){c.letterSpacing="0.025em";continue}if(p==="tracking-wider"){c.letterSpacing="0.05em";continue}if(p==="tracking-widest"){c.letterSpacing="0.1em";continue}const be=p.match(/^tracking-\[(.+)\]$/);if(be){c.letterSpacing=be[1];continue}const Ct=p.match(/^w-\[(.+)\]$/);if(Ct){c.width=Ct[1];continue}const Qt=p.match(/^h-\[(.+)\]$/);if(Qt){c.height=Qt[1];continue}const ae=p.match(/^min-h-\[(.+)\]$/);if(ae){c.minHeight=ae[1];continue}const jn=p.match(/^max-w-\[(.+)\]$/);if(jn){c.maxWidth=jn[1];continue}}return m&&y&&(x?c.backgroundImage=`linear-gradient(${m}, ${y}, ${x}, ${_||y})`:_?c.backgroundImage=`linear-gradient(${m}, ${y}, ${_})`:c.backgroundImage=`linear-gradient(${m}, ${y}, transparent)`),c}function Es(e,t){const n=parseInt(e.slice(1,3),16),i=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16);return`rgba(${n}, ${i}, ${r}, ${t})`}const Kd={margin:0,padding:0,boxSizing:"border-box",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif",WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale"};function BS(e){return`
24
27
  #${e} {
25
28
  isolation: isolate;
26
29
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
@@ -85,11 +88,11 @@ ${c.join(`
85
88
  font-weight: inherit;
86
89
  margin: 0;
87
90
  }
88
- `}function mS(e,t,n,s){return m.createElement("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",minHeight:"100%",backgroundColor:e.colors.background,gap:"16px"}},E("p",{style:{color:e.colors.text,fontSize:"1.125rem"}},"Scene not found"),m.createElement("div",{style:{display:"flex",gap:"12px",alignItems:"center"}},t>0&&m.createElement("button",{onClick:n,style:{padding:"0.5rem 1.5rem",borderRadius:"0.5rem",backgroundColor:e.colors.surfaceHover,color:e.colors.text,border:"none",cursor:"pointer",fontSize:"0.875rem",fontWeight:500,transition:e.effects.transition},onMouseOver:i=>i.target.style.backgroundColor=e.colors.border,onMouseOut:i=>i.target.style.backgroundColor=e.colors.surfaceHover},"← Go Back"),s&&m.createElement("button",{onClick:s,style:{display:"flex",alignItems:"center",gap:"6px",padding:"0.5rem 1.5rem",borderRadius:"0.5rem",backgroundColor:e.colors.primary,variant:"outline",color:e.colors.text,border:"none",cursor:"pointer",fontSize:"0.875rem",fontWeight:500,transition:"opacity 0.2s"},onMouseOver:i=>i.target.style.opacity="0.85",onMouseOut:i=>i.target.style.opacity="1"},m.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},E("polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2"})),"Generate Scene")))}function pS(e){return m.createElement("div",{key:"preview-modal",style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4,animation:"bf-fade-in 0.15s ease"}},m.createElement("div",{style:{backgroundColor:e.colors.background,borderRadius:"12px",padding:"24px",maxWidth:"360px",width:"90%",boxShadow:"0 20px 40px rgba(0, 0, 0, 0.4)",border:"1px solid rgba(255, 255, 255, 0.08)"}},E("h3",{style:{color:e.colors.text,fontSize:"16px",fontWeight:600,marginBottom:"12px"}},"Sample Modal"),E("p",{style:{color:e.colors.textSecondary,fontSize:"14px",marginBottom:"20px"}},"This is a preview of the modal component for styling."),m.createElement("div",{style:{display:"flex",gap:"12px",justifyContent:"flex-end"}},E("button",{style:{padding:"10px 20px",borderRadius:"8px",cursor:"pointer",fontSize:"14px",fontWeight:500,background:"rgba(255,255,255,0.08)",color:e.colors.text,border:`1px solid ${e.colors.borderSubtle}`}},"Cancel"),E("button",{style:{padding:"10px 20px",borderRadius:"8px",cursor:"pointer",fontSize:"14px",fontWeight:500,background:e.colors.primary,color:e.colors.text,border:"none"}},"Confirm"))))}function Fu(e,t,n,s,i,r,o){var I,L,O,H,U,q,X,j,D,V,J;if(!e)return null;const{definition:l,closing:c}=e,h=l.variant?(I=l.variants)==null?void 0:I[l.variant]:void 0,a={...l,...h,style:{...l.style,...h==null?void 0:h.style},components:(h==null?void 0:h.components)||l.components,actions:(h==null?void 0:h.actions)||l.actions},u=a.popover===!0,f=(L=a.style)==null?void 0:L.placement,p=f==="left"||f==="right"||f==="bottom"?f:"center",g=a.drawer===!0||p==="left"||p==="right",d=p==="bottom",w=c===!0,C=a.className||"",x=C?((O=n.parseClassNameResponsive)==null?void 0:O.call(n,C,`modal-${e.id}`))??n.parseClassName(C):{},k=u&&o&&o.top>window.innerHeight/2&&o.bottom+300>window.innerHeight,S=o?Math.min(Math.max(12,o.left),Math.max(12,window.innerWidth-372)):void 0,T=()=>{var nt;w||(nt=i||n.dismissModal)==null||nt()},P=m.createElement("div",{key:`modal-overlay-${e.id||"base"}`,style:{position:"fixed",top:0,left:0,right:0,bottom:0,animation:w?"bf-fade-out 0.2s ease forwards":"bf-fade-in 0.15s ease",backdropFilter:u?void 0:"blur(4px)",WebkitBackdropFilter:u?void 0:"blur(4px)",display:"flex",alignItems:u?"flex-start":d?"flex-end":"center",justifyContent:u?"flex-end":g?p==="left"?"flex-start":"flex-end":"center",paddingTop:void 0,paddingRight:void 0,backgroundColor:u?"transparent":((H=a.style)==null?void 0:H.overlayColor)||"rgba(0,0,0,0.45)",pointerEvents:"auto",zIndex:r||1e4},onClick:nt=>{nt.target===nt.currentTarget&&T()}},m.createElement("div",{className:C||void 0,style:{pointerEvents:u?"auto":void 0,...u?{position:"fixed",top:k||!o?k?void 0:"116px":`${o.bottom+8}px`,bottom:k?`${Math.max(12,window.innerHeight-o.top+8)}px`:void 0,left:S===void 0?void 0:`${S}px`,right:S===void 0?"24px":void 0}:{},backgroundColor:((U=a.style)==null?void 0:U.backgroundColor)||s||t.colors.background,borderRadius:g?"0px":((q=a.style)==null?void 0:q.borderRadius)||(d?"16px 16px 0 0":"12px"),padding:g?"0.5rem":d?"16px":"24px",height:g?"100%":"auto",maxHeight:d?"90vh":g?void 0:"85vh",maxWidth:g?"520px":d?n.isMobileView?"none":"640px":((X=a.style)==null?void 0:X.width)||{sm:"min(360px, 92vw)",md:"min(480px, 92vw)",lg:"min(720px, 92vw)",full:"90vw"}[a.size||"sm"]||"min(400px, 92vw)",width:(j=a.style)!=null&&j.width?"100%":g?"90vw":d?"100%":"90%",boxShadow:g?p==="left"?"4px 0 24px rgba(0, 0, 0, 0.4)":"-4px 0 24px rgba(0, 0, 0, 0.4)":d?"0 -8px 32px rgba(0, 0, 0, 0.45)":"0 20px 40px rgba(0, 0, 0, 0.4)",...u?{minWidth:"min(360px, 92vw)",marginRight:"0px",boxShadow:"0 12px 32px rgba(0, 0, 0, 0.45)"}:{},border:"none",borderLeft:g&&p==="right"?`1px solid ${((D=a.style)==null?void 0:D.borderColor)||"rgba(255, 255, 255, 0.08)"}`:"none",borderRight:g&&p==="left"?`1px solid ${((V=a.style)==null?void 0:V.borderColor)||"rgba(255, 255, 255, 0.08)"}`:"none",overflow:"auto",animation:g?w?p==="left"?"bf-slide-out-left 0.2s ease forwards":"bf-slide-out-right 0.2s ease forwards":p==="left"?"bf-slide-in-left 0.2s ease":"bf-slide-in-right 0.2s ease":d?w?"bf-slide-out-down 0.2s ease forwards":"bf-slide-in-up 0.25s ease":w?"bf-fade-out 0.2s ease forwards":void 0,...x}},d?m.createElement("div",{key:"bf-sheet-handle",style:{width:"40px",height:"4px",borderRadius:"2px",backgroundColor:"rgba(255, 255, 255, 0.2)",margin:"0 auto 12px",flexShrink:0}}):null,a.icon?m.createElement("div",{style:{textAlign:"center",marginBottom:"12px",display:"flex",justifyContent:"center"}},n.renderIcon(a.icon,32)):null,a.title?m.createElement("h3",{style:{color:t.colors.text,fontSize:a.icon?"18px":"16px",fontWeight:600,marginBottom:"12px",marginTop:"4px",paddingLeft:g?"1.5rem":"0px",paddingRight:g?"1.5rem":"0px",textAlign:a.icon?"center":"left"}},n.interpolateText(a.title)):null,...(a.components||[]).map((nt,it)=>Cr(n,nt,it,"modal")),(((J=a.actions)==null?void 0:J.length)||0)>0?m.createElement("div",{style:{display:"flex",gap:"12px",justifyContent:"flex-end",marginTop:"20px"}},...(a.actions||[]).map((nt,it)=>{const ut=(Dt=>{const qt=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(Dt);if(!qt)return!1;const[ne,te,mt]=[parseInt(qt[1],16),parseInt(qt[2],16),parseInt(qt[3],16)];return(ne*299+te*587+mt*114)/1e3>150})(t.colors.primary)?"#000000":"#ffffff",Ct={primary:{background:t.colors.primary,color:ut,border:"none"},secondary:{background:"rgba(255, 255, 255, 0.08)",color:t.colors.text,border:`1px solid ${t.colors.borderSubtle}`},ghost:{background:"transparent",color:t.colors.text,border:`1px solid ${t.colors.borderSubtle}`},danger:{background:t.colors.danger,color:"#ffffff",border:"none"}},ft=Ct[nt.variant||"primary"]||Ct.primary;return m.createElement("button",{key:it,onClick:()=>{if(e.legacyOnConfirm&&nt.label==="Confirm"){T(),setTimeout(()=>{var Dt;return(Dt=e.legacyOnConfirm)==null?void 0:Dt.call(e)},250);return}nt.onClick&&n.handleButtonClick(nt.onClick,{onSuccess:nt.onSuccess,onError:nt.onError}),nt.dismiss&&T()},style:{padding:"10px 20px",borderRadius:"8px",cursor:"pointer",fontSize:"14px",fontWeight:500,...ft}},nt.label)})):null));return u&&typeof document<"u"?Wu.createPortal(P,document.body):P}const bm=()=>{try{if(typeof window<"u")return window.localStorage.getItem("backflow_dev_diagnostics")==="1"}catch{}return!1},gr=(...e)=>{bm()&&console.log(...e)},Yo=(...e)=>{bm()&&console.warn(...e)};let vm=null;window.addEventListener("message",e=>{var t,n,s;(((t=e.data)==null?void 0:t.type)==="auth"||((n=e.data)==null?void 0:n.type)==="auth-token")&&((s=e.data)!=null&&s.token)&&(vm=e.data.token,localStorage.setItem("token",e.data.token),e.data.refreshToken&&localStorage.setItem("backflow_refresh_token",e.data.refreshToken),e.data.userId&&localStorage.setItem("backflow_refresh_user_id",e.data.userId))});function ci(e){try{const t=JSON.parse(atob(e.split(".")[1]));return typeof t.exp!="number"||t.exp*1e3<=Date.now()}catch{return!0}}function gS({workflow:e,sdk:t,iconResolver:n,authToken:s,nativeAction:i,onRouteExecute:r,onJobProgress:o,appName:l,appIcon:c,selectedComponentKey:h,selectedComponentClass:a,styleOverrides:u,interactionDisabled:f,theme:p,imageReplacements:g,currentSceneId:d,onSceneChange:w,onGenerateScene:C,enableRouting:x,previewElement:k,tenantId:S,appId:T,renderPhaserGame:P,renderMode:I,apiUrl:L,workflowBaseUrl:O,initialScene:H,previewMode:U,remoteSessionId:q,devDiagnostics:X}){var Yl,Xl,Ql,Jl,Kl,Zl,tc,ec,nc,sc,ic,rc,oc;const j=(()=>{const y=vm||localStorage.getItem("token");return!!y&&!ci(y)})(),[D,V]=m.useState(!j),[J,nt]=m.useState(null),it=m.useMemo(()=>Array.isArray(e==null?void 0:e.steps)?e.steps:[],[e]),Q=m.useMemo(()=>{const y=it;return e&&!Array.isArray(e.steps)&&(Yo("[WorkflowRenderer] NON-ARRAY steps:",typeof e.steps,JSON.stringify(e.steps).slice(0,500)),Yo("[WorkflowRenderer] Workflow keys:",Object.keys(e))),D!==!0?y:y.filter(v=>{var b,_;return!(v.requiresAuth===!0||((b=v.config)==null?void 0:b.requireAuth)===!0||((_=v.config)==null?void 0:_.requiresAuth)===!0)})},[e,D,it]),ut=m.useCallback(y=>{var b;const v=it.find(_=>_.id===y);return((b=v==null?void 0:v.config)==null?void 0:b.requireAuth)===!0||(v==null?void 0:v.requiresAuth)===!0},[it]),Ct=e&&!((Yl=e.config)!=null&&Yl.colorMode)?pp(e):void 0,ft=Ju(Ct?{...(e==null?void 0:e.config)||{},colorMode:Ct}:e==null?void 0:e.config,void 0,p),Dt=y=>Tl(y,{primary:Et.colors.primary,accent:Et.colors.accent,colorMode:Et.colorMode},Et.colorMode==="light"),qt=I||"legacy",ne=x?"hash":"memory",te=ne!=="memory",[mt,he]=m.useState(j),[Pe,ae]=m.useState(!1),[In,Ys]=m.useState(!1),{sceneToRoute:Oe,routeToScene:xe}=m.useMemo(()=>gm(Q),[Q]),bt=m.useMemo(()=>{var v,b;if(H&&Q.some(_=>_.id===H))return H;const y=Q.filter(_=>_.type==="render_scene");return((v=y.find(_=>_.route==="/"))==null?void 0:v.id)||((b=y[0])==null?void 0:b.id)||""},[Q,H]),Rt=m.useMemo(()=>{if(te&&ne==="hash"){const y=Ta(xe);if(y)return y}return bt},[bt,te,ne,xe]),[Lt,kt]=m.useState([]),[yt,wt]=m.useState(Rt),gt=m.useRef(null),Xt=zf(gt),Ue=m.useRef(!1);m.useRef(null);const ge=m.useRef(!1),ee=m.useRef(!1),os=m.useRef(0),ue=m.useRef(null);m.useEffect(()=>(ge.current=!1,Qu(),()=>{ge.current=!0}),[]),m.useEffect(()=>{s&&localStorage.setItem("token",s)},[s]);const ot=d??yt;m.useEffect(()=>{var $;const y=Q.find(N=>N.id===ot),v=!!(($=e==null?void 0:e.config)!=null&&$.remoteControl)&&!!(y!=null&&y.remoteScene);if(ju(v),!v||!q){Jo();return}const b=L||(t==null?void 0:t.endpoint),_=b&&/^https?:\/\//.test(b)?b:window.location.origin,M=new URL("/ws",_);M.protocol=M.protocol==="https:"?"wss:":"ws:";const A=M.toString(),R=`agent:${S||"default"}:${q}`;return Xu(A,R,s||localStorage.getItem("token")||void 0),()=>Jo()},[(Xl=e==null?void 0:e.config)==null?void 0:Xl.remoteControl,Q,ot,q,S,L,t,s]);const Me=m.useCallback(y=>{wt(y),w==null||w(y)},[w]);m.useEffect(()=>{var b;const y=Q.find(_=>_.id===ot),v=((b=y==null?void 0:y.config)==null?void 0:b.requireAuth)===!0||(y==null?void 0:y.requiresAuth)===!0;ot&&!v&&ae(!1)},[ot,Q]);const Gt=(e==null?void 0:e.modals)||{};m.useEffect(()=>{if(!mt)return;const y=Et.startupModal;!y||!Gt[y]||localStorage.getItem(`backflow_startup_modal_${y}`)||se({id:y,definition:Gt[y]})},[mt]);const Xs=m.useRef(typeof window>"u"?null:new URLSearchParams(window.location.search).get("customer_session_token"));m.useEffect(()=>{if(!mt||!Xs.current||!Gt["payment-success"])return;window.history.replaceState({},"",window.location.pathname);const v=setTimeout(()=>{Gt["payment-success"]&&se({id:"payment-success",definition:Gt["payment-success"]})},400);return()=>clearTimeout(v)},[mt,Gt["payment-success"]]),m.useEffect(()=>{D===!0&&(!ot||Q.some(y=>y.id===ot)||bt&&Me(bt))},[D,Q,ot,bt]),m.useEffect(()=>{if(!(!te||ne!=="hash")){if(Ue.current){Ue.current=!1;return}kr(ot,Oe,!1)}},[ot,te,ne,Oe]),m.useEffect(()=>{!te||ne!=="hash"||kr(ot,Oe,!0)},[]);const as=m.useRef(!0);m.useEffect(()=>{const y=setTimeout(()=>{as.current=!1},1500);return()=>clearTimeout(y)},[]),m.useEffect(()=>{if(!te||ne!=="hash")return;const y=v=>{var _;if(as.current)return;const b=((_=v.state)==null?void 0:_.sceneId)||Ta(xe);b&&b!==ot&&(Ue.current=!0,Me(b),kt(M=>M.length>0&&M[M.length-1]===b?M.slice(0,-1):M))};return window.addEventListener("popstate",y),()=>window.removeEventListener("popstate",y)},[te,ne,xe,ot,Me]),m.useEffect(()=>{var v;const y=((v=Q.find(b=>b.type==="render_scene"))==null?void 0:v.id)||"";y&&y!==ot&&(wt(y),kt([]),w==null||w(y),te&&ne==="hash"&&kr(y,Oe,!0))},[e]),m.useEffect(()=>{d&&d!==yt&&wt(d)},[d]);const Dn=m.useCallback(()=>{if(te){window.history.back();return}if(Lt.length>0){const y=Lt[Lt.length-1];kt(v=>v.slice(0,-1)),Me(y)}},[Lt,te]),[Pt,St]=m.useState({}),Ln=m.useRef(Pt);m.useEffect(()=>{Ln.current=Pt},[Pt]);const[zn,Ze]=m.useState({}),ls=m.useRef(new Set),[Qs,cs]=m.useState({}),[tn,hs]=m.useState({}),[us,ds]=m.useState({}),[Js,Ks]=m.useState({}),[Ee,Fn]=m.useState({}),Be=m.useRef(new Map),dn=m.useRef(new Map),Bn=m.useRef(new Set),[Zs,fs]=m.useState(!1),[zt,se]=m.useState(null),[ti,ms]=m.useState(null),ps=m.useRef(null);m.useEffect(()=>{var v;if(!((v=zt==null?void 0:zt.definition)!=null&&v.popover))return;const y=()=>{const b=ps.current;b&&ms(b.getBoundingClientRect())};return window.addEventListener("scroll",y,!0),window.addEventListener("resize",y),y(),()=>{window.removeEventListener("scroll",y,!0),window.removeEventListener("resize",y)}},[zt==null?void 0:zt.id,(Ql=zt==null?void 0:zt.definition)==null?void 0:Ql.popover]);const Wn=m.useCallback(()=>{se(y=>y?{...y,closing:!0}:null),setTimeout(()=>se(null),250)},[]),[_e,jn]=m.useState(null),Wi=m.useCallback(()=>{jn(y=>y?{...y,closing:!0}:null),setTimeout(()=>jn(null),250)},[]),gs=Xt>0&&Xt<_i.md;m.useEffect(()=>{e&&typeof e=="object"&&(e.auth={signedIn:mt})},[e,mt]),m.useEffect(()=>{const y=e;if(!(y!=null&&y.config))return;if(c){y.config.logo=c,St(b=>b&&{...b});return}if(!O)return;let v=!1;return(async()=>{for(const b of["svg","png","jpg","jpeg"]){const _=`${O}logo.${b}`;try{if((await fetch(_,{method:"HEAD"})).ok&&!v){y.config.logo=_,St(A=>A&&{...A});return}}catch{}}})(),()=>{v=!0}},[e,O,c]);const[We,fn]=m.useState("login"),[Ot,en]=m.useState(""),[Ft,He]=m.useState(""),[nn,ys]=m.useState(""),[bs,vs]=m.useState({}),[mn,pn]=m.useState(""),[Ie,ie]=m.useState(null),[re,sn]=m.useState(!1),[Wt,ji]=m.useState({}),gn=y=>y?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(y)?null:"Invalid email address":null,tt=y=>y?y.length>=6?null:"Password must be at least 6 characters":null,Yt=(y,v)=>v?v===y?null:"Passwords do not match":null,It=(y,v)=>ji(b=>({...b,[y]:v||""})),le=y=>{var v,b;return y?typeof y=="string"?y:Array.isArray(y)?((v=y[0])==null?void 0:v.message)||"Validation failed":typeof y.error=="string"?y.error:(b=y.error)!=null&&b.message?y.error.message:y.message||"An error occurred":"An error occurred"},Vi=(Pt==null?void 0:Pt._colorMode)||ft.colorMode,xm=Vi==="dark"?ki:Mi,Et=Vi!==ft.colorMode?{...ft,colorMode:Vi,colors:{...xm,...ft.colors&&Vi==="dark"?ft.colors:{}}}:ft;m.useEffect(()=>{typeof document>"u"||document.documentElement.setAttribute("data-theme",Et.colorMode==="dark"?"dark":"light")},[Et.colorMode]);const Al=m.useCallback(y=>{try{localStorage.setItem("bf_theme",y)}catch{}St(v=>({...v,_colorMode:y}))},[]);m.useEffect(()=>{if(typeof localStorage>"u")return;const y=localStorage.getItem("bf_theme");(y==="dark"||y==="light")&&St(v=>({...v,_colorMode:y}))},[]),m.useEffect(()=>{const y=localStorage.getItem("token"),v=!!y&&!ci(y);v?(ee.current=!1,V(!1)):V(!0),he(v);const b=()=>{const A=localStorage.getItem("token"),R=!!A&&!ci(A);R?(ee.current=!1,V(!1)):V(!0),he(R)};window.addEventListener("storage",b);const _=A=>{var R,$,N;if((((R=A.data)==null?void 0:R.type)==="auth"||(($=A.data)==null?void 0:$.type)==="auth-token")&&((N=A.data)!=null&&N.token)){if(localStorage.setItem("token",A.data.token),A.data.refreshToken&&localStorage.setItem("backflow_refresh_token",A.data.refreshToken),A.data.userId&&localStorage.setItem("backflow_refresh_user_id",A.data.userId),ci(A.data.token)){ee.current=!0,he(!1);return}if(!mt&&(Pe||ee.current||!!ue.current)){window.location.reload();return}he(!0),ae(!1),V(!1),ee.current=!1}};window.addEventListener("message",_);const M=()=>{var A;if(!ee.current){const R=Q.find(N=>N.id===ot);if(!(((A=R==null?void 0:R.config)==null?void 0:A.requireAuth)===!0||(R==null?void 0:R.requiresAuth)===!0))return;ee.current=!0,he(!1),ae(!0)}};return window.addEventListener("auth:required",M),()=>{window.removeEventListener("storage",b),window.removeEventListener("message",_),window.removeEventListener("auth:required",M)}},[]);const wm=async()=>{var b;const y=localStorage.getItem("backflow_refresh_token"),v=localStorage.getItem("backflow_refresh_user_id");if(!y||!v)return!1;try{const M=await(await fetch(`${window.location.origin}/api/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:y,userId:v})})).json();if(M.success&&((b=M.data)!=null&&b.token))return M.data.refreshToken&&localStorage.setItem("backflow_refresh_token",M.data.refreshToken),localStorage.setItem("token",M.data.token),!0}catch{}return localStorage.removeItem("backflow_refresh_token"),localStorage.removeItem("backflow_refresh_user_id"),!1},to=async y=>{var v;if(y.status===401&&!Pe){if(await wm())return!1;gr("[bf] 401 intercepted, showAuth:",Pe,"authInterceptedRef:",ee.current);const _=localStorage.getItem("token"),M=!!_&&!ci(_);if(!ee.current&&!M){ee.current=!0,he(!1);const A=Q.find($=>$.id===ot);(((v=A==null?void 0:A.config)==null?void 0:v.requireAuth)===!0||(A==null?void 0:A.requiresAuth)===!0)&&(ae(!0),ot&&(ue.current=ot))}else M&&gr("[bf] 401 with valid stored token — ignoring");return!0}return!1},Sm=ot&&Q.some(y=>y.id===ot)?ot:(Jl=Q[0])==null?void 0:Jl.id,qe=Q.find(y=>y.id===Sm),jt=(qe==null?void 0:qe.type)==="render_scene"?qe.config:null;m.useEffect(()=>{if(!jt)return;const y=S||"default",v={TENANT_ID:y,tenantId:y,role:"user"};St(b=>{const _={};for(const M of Object.keys(b))M.startsWith("_")&&(_[M]=b[M]);return{...v,...jt.sceneData||{},..._}})},[ot,jt]),m.useEffect(()=>{const y=Et.persistedKeys;if(!y||y.length===0)return;const v={};for(const b of y){const _=localStorage.getItem(`bf_persist_${b}`);_&&(v[b]=_)}Object.keys(v).length>0&&St(b=>({...b,...v}))},[ot]),m.useEffect(()=>{const y=Et.persistedKeys;if(!(!y||y.length===0))for(const v of y){const b=Pt[v];b&&localStorage.setItem(`bf_persist_${v}`,String(b))}});const Rl=y=>{const v=y.match(/^(GET|POST|PATCH|DELETE|PUT)\s+(.+)/);return{method:v?v[1]:"POST",path:v?v[2]:y}},Pl=y=>{const v={...y};return delete v.TENANT_ID,delete v.tenantId,delete v.role,v},Vn=m.useCallback(async y=>{var _,M,A;if(!y.action)return;const v=String(y.action),b=Ln.current;try{if(v.startsWith("execute_workflow:")){if(!mt)return;const{method:R,path:$}=Rl(v.replace("execute_workflow:","")),N=$.replace(/:(\w+)/g,(et,B)=>{const Z=b[B];return Z===void 0?et:String(Z)}).replace(/\{\{(\w+)\}\}/g,(et,B)=>{const Z=b[B];return Z===void 0?et:String(Z)}),F=Ge(),Y=R!=="GET"&&R!=="DELETE";R!=="GET"&&$l(R,N,b,!0);const G=await fetch(new URL(N,F).toString(),{method:R,headers:{"Content-Type":"application/json",Authorization:`Bearer ${s||localStorage.getItem("token")||""}`},...Y?{body:JSON.stringify(Pl(b))}:{}});if(ge.current||await to(G)||ge.current)return;if(!G.ok)throw rn(N),new Error(`Route failed: ${G.statusText}`);const W=await G.json();if(ge.current)return;if(W&&typeof W=="object"&&!Array.isArray(W)&&St(et=>({...et,feedback:W})),((_=y.onSuccess)==null?void 0:_.type)==="toast"&&y.onSuccess.value)Vt(y.onSuccess.value,"success");else if(((M=y.onSuccess)==null?void 0:M.type)==="navigate"&&y.onSuccess.value){const et=y.onSuccess.value;if(ut(et)&&!mt){ue.current=et,ae(!0);return}kt(Z=>[...Z,ot]),Me(et)}W!=null&&W.data&&St(et=>({...et,...W.data})),W!=null&&W.user&&typeof W.user=="object"&&St(et=>({...et,user:W.user})),ce.current[N.replace(/^\//,"")]={response:W},St(et=>({...et}))}else if(v.startsWith("navigate:")){const R=v.replace("navigate:","");if(ut(R)&&!mt){ue.current=R,ae(!0);return}kt(N=>[...N,ot]),Me(R)}else if(v.startsWith("go_to_step:")){const R=v.replace("go_to_step:","").split("?")[0].trim();if(ut(R)&&!mt){ue.current=R,ae(!0);return}kt(N=>[...N,ot]),Me(R)}else if(v.startsWith("show_toast:")){const R=v.replace("show_toast:","");R&&Vt(R,"success")}else if(v.startsWith("show_modal:")){const R=v.replace("show_modal:","");if(Gt[R]){const $=Gt[R],N=$.clearFormKeys;St(F=>{const Y={...F};let G=Array.isArray(N)&&N.length>0;if(G)for(const W of N)delete Y[W];for(const W of Object.keys(Y))W.startsWith("__acc_")&&(delete Y[W],G=!0);return G?Y:F}),$.preload&&await ni(String($.preload)),se({id:R,definition:$})}else{const $=R.split("|");se({id:"__legacy",definition:{title:$[0]||"Notice",components:$[1]?[{type:"text",text:$[1],color:Et.colorMode==="light"?"rgba(0,0,0,0.65)":"rgba(255,255,255,0.7)",fontSize:14}]:[],actions:[{label:"OK",variant:"primary",dismiss:!0}]}})}}else if(v.startsWith("toast:")){const R=v.replace("toast:","");Vt(R,"success")}}catch(R){if(R instanceof ws&&io(R,y==null?void 0:y.onError))return;(A=y.onError)!=null&&A.message&&Vt(y.onError.message,"error")}},[ot,Q,mt]),eo=m.useRef(null);m.useEffect(()=>{const y=jt==null?void 0:jt.events,v=Array.isArray(y==null?void 0:y.onLoad)?y.onLoad:y!=null&&y.onLoad?[y.onLoad]:[];v.length!==0&&(eo.current!==null||ot)&&v.forEach(b=>Vn(b))},[ot,jt==null?void 0:jt.events,Vn]),m.useEffect(()=>{var v,b;const y=eo.current;if(eo.current=ot,y&&y!==ot){const _=Q.find(A=>A.id===y),M=(_==null?void 0:_.type)==="render_scene"?_.config:null;(b=(v=M==null?void 0:M.events)==null?void 0:v.onLeave)!=null&&b.action&&Vn(M.events.onLeave)}},[ot,Q,Vn]),m.useEffect(()=>{const y=jt==null?void 0:jt.events;if(!(y!=null&&y.onVisibilityChange))return;const v=()=>{var b,_,M,A;document.hidden?(_=(b=y.onVisibilityChange)==null?void 0:b.onHidden)!=null&&_.action&&Vn(y.onVisibilityChange.onHidden):(A=(M=y.onVisibilityChange)==null?void 0:M.onVisible)!=null&&A.action&&Vn(y.onVisibilityChange.onVisible)};return document.addEventListener("visibilitychange",v),()=>document.removeEventListener("visibilitychange",v)},[ot,jt==null?void 0:jt.events,Vn]);const Cm=m.useCallback(async(y,v)=>{ds(b=>({...b,[y]:!0}));try{await v()}finally{ds(b=>({...b,[y]:!1}))}},[]),xs=m.useRef({}),yn=m.useRef(null),no=m.useRef([]),ei=m.useRef({}),Te=m.useCallback(async(y,v,b=0,_=10,M,A,R,$=!1)=>{var F;if(!y||ee.current||!mt)return;xs.current[v]=y;const N=y.match(/^\{\{\s*\[([\w/.-]+)\](?:\.([\w.]+))?\s*\}\}$/);if(N){const Y=bn(`${N[1]}${N[2]?"."+N[2]:""}`);if(Array.isArray(Y))return Ze(G=>({...G,[v]:Y})),ce.current[v]=Y,ce.current[y]=Y,Fn(G=>({...G,[v]:{page:b,limit:_,total:Y.length,hasMore:(b+1)*_<Y.length}})),Y}ls.current.has(v)||hs(Y=>({...Y,[v]:!0}));try{let Y=[],G=0,W;const et=Ln.current;if(Ci(y)&&t){const B=Tm(y,{limit:_,page:b}),Z=M?Em(B,M,A):B,dt=pi(Z),z=await Mr(t,dt,et);W=z,Y=(z==null?void 0:z.emails)||(z==null?void 0:z.items)||(z==null?void 0:z.data)||(z==null?void 0:z.history)||(Array.isArray(z)?z:[]),G=((F=z==null?void 0:z.pagination)==null?void 0:F.total)??(z==null?void 0:z.count)??Y.length}else if(!Ci(y)){const B=t==null?void 0:t.endpoint,Z=L||(B&&/^https?:\/\//.test(B)?B:window.location.origin);let dt=y;!L&&B&&!/^https?:\/\//.test(B)&&typeof B=="string"&&(dt=`${B.replace(/\/+$/,"")}${y.startsWith("/")?y:`/${y}`}`),gr("[fetchListData] apiUrl=%s baseUrl=%s dataSource=%s origin=%s",L,Z,y,window.location.origin);const z=new URL(dt,Z);z.searchParams.set("limit",String(_)),z.searchParams.set("offset",String(b*_)),M&&(z.searchParams.set("sort",M),z.searchParams.set("dir",A||"asc"));const at=await fetch(z.toString(),{headers:{Authorization:`Bearer ${s||localStorage.getItem("token")||""}`}});if(await to(at)||ge.current)return;let rt=null;try{rt=await at.json()}catch{}if(!at.ok){const At=typeof(rt==null?void 0:rt.message)=="string"&&rt.message||typeof(rt==null?void 0:rt.error)=="string"&&rt.error||`Request failed: ${at.statusText}`;throw new ws([At],rt||void 0)}if(W=rt,ge.current)return;Y=Array.isArray(rt)?rt:Array.isArray(rt.data)?rt.data:Array.isArray(rt.items)?rt.items:[],G=rt.count??rt.total??Y.length}if(Ze(B=>{if($&&Array.isArray(B[v])){const Z=new Set(B[v].map(z=>z==null?void 0:z.id)),dt=[...B[v],...Y.filter(z=>!Z.has(z==null?void 0:z.id))];return{...B,[v]:dt}}return{...B,[v]:Y}}),ls.current.add(v),ce.current[v]=Y,y&&(ce.current[y]=Y),R&&(ce.current[R]={items:Y,response:W},y)){const B=ei.current[R];B&&B!==y&&Yo(`[renderer] duplicate list key "${R}" used for both ${B} and ${y}`),ei.current[R]=y}{const B=String(y||"").replace(/^\//,"").split("?")[0];B&&(ce.current[B]={response:W})}return Fn(B=>({...B,[v]:{page:b,limit:_,total:G,hasMore:(b+1)*_<G}})),Y}catch(Y){if(Y instanceof ws&&io(Y))return;Ze(G=>{const W=G[v];return Array.isArray(W)&&W.length>0?G:{...G,[v]:[]}})}finally{hs(Y=>({...Y,[v]:!1}))}},[t,mt]),Ge=()=>{const y=L||(t==null?void 0:t.endpoint);return y&&/^https?:\/\//.test(y)?y:y!=null&&y.startsWith("/")?`${window.location.origin}${y}`:window.location.origin};m.useEffect(()=>{var M;if(!mt)return;const y=s||localStorage.getItem("token");if(!y){V(!0);return}const v=((e==null?void 0:e.steps)||[]).find(A=>A.id===ot);if(!(((M=v==null?void 0:v.config)==null?void 0:M.requireAuth)===!0||(v==null?void 0:v.requiresAuth)===!0||Pe))return;let _=!1;return(async()=>{var A;try{const R=await fetch(`${Ge()}/admin/users/me`,{headers:{Authorization:`Bearer ${y}`}});if(_)return;if(R.ok){const $=await R.json().catch(()=>null);V(!1),nt(typeof((A=$==null?void 0:$.user)==null?void 0:A.emailVerified)=="boolean"?$.user.emailVerified:null)}else ot&&(ue.current=ot),V(!0),he(!1),nt(null)}catch{_||(ot&&(ue.current=ot),V(!0))}})(),()=>{_=!0}},[mt,ot,e==null?void 0:e.steps]);const _l=m.useCallback((y,v,b)=>{!y||v.length===0||Ze(_=>{const M={..._};for(const[A,R]of Object.entries(xs.current)){if(R!==y||!_[A])continue;const $=_[A];b==="remove"&&(M[A]=$.filter(N=>!v.includes(N.id)))}return M})},[]),rn=m.useCallback((y,v)=>{var M,A;const b=new Map;for(const[R,$]of Object.entries(ei.current))b.set($,R);const _=new Map;for(const[R,$]of Object.entries(xs.current))_.set(R,{ds:$,dataKey:b.get($)});for(const[R,$]of Object.entries(ei.current))Object.values(xs.current).includes($)||_.set(R,{ds:$,dataKey:R});if(_.size!==0)for(const[R,{ds:$,dataKey:N}]of _){if(v==="view"){Te($,R,0,((M=Ee[R])==null?void 0:M.limit)||10,void 0,void 0,N);continue}$&&y.startsWith($)&&Te($,R,0,((A=Ee[R])==null?void 0:A.limit)||10,void 0,void 0,N)}},[Te,Ee]),$l=m.useCallback((y,v,b,_)=>{const M=String(y||"").toUpperCase();if(M==="GET"||_===!1)return;const A=_==="remove"||_==="merge"||_==="add"||_==="refresh"?_:M==="DELETE"?"remove":M==="PUT"||M==="PATCH"?"merge":M==="POST"?"add":null;if(!A||A==="refresh")return;const R=()=>{const N=String(v).match(/\/([^/]+)\/?$/);return N?decodeURIComponent(N[1]):void 0},$=[];for(const[N,F]of Object.entries(xs.current))F&&v.startsWith(F)&&$.push({key:N,ds:F});$.length!==0&&Ze(N=>{const F={...N};for(const{key:Y,ds:G}of $){const W=N[Y]||[];if(A==="remove"){const et=(b==null?void 0:b.id)||R();F[Y]=W.filter(B=>B.id!==et)}else if(A==="merge"){const et=(b==null?void 0:b.id)||R();F[Y]=W.map(B=>B.id===et?{...B,...b}:B)}else{const et={...b||{},id:(b==null?void 0:b.id)||`temp_${Date.now()}`};A==="add"&&et.status===void 0&&(et.status="queued"),F[Y]=[et,...W]}}return F})},[]),Oi=m.useCallback((y,v,b,_)=>{var N;const M=Ge();let A=!1;const R=F=>{A||(A=!0,F())},$=t==null?void 0:t.queues;if(y==="sse"&&($!=null&&$.subscribe))try{const F=_.sseUrl||`${M}/queues/bulk-operations/jobs/${v}/subscribe?token=${encodeURIComponent(b)}`,Y=((t==null?void 0:t.endpoint)||M).replace(/\/$/,""),G=F.startsWith(Y)?F.slice(Y.length):F;$.subscribe(G,{onComplete:W=>R(()=>_.onComplete(W)),onFailed:W=>R(()=>_.onFailed({message:W||"Subscription failed",kind:"transport"})),onError:()=>R(()=>_.onFailed({message:"Stream error",kind:"transport"})),onConnected:()=>{},onProgress:W=>{var et;return(et=_.onProgress)==null?void 0:et.call(_,W)}}),setTimeout(()=>R(()=>_.onFailed({message:"Timed out",kind:"transport"})),3e4);return}catch{}if(y==="ws"&&((N=t==null?void 0:t.client)!=null&&N.createWebSocket))try{const F=t.client.createWebSocket(`job:${v}`);F.onmessage=Y=>{try{const G=JSON.parse(Y.data);(G==null?void 0:G.type)==="completed"?R(()=>_.onComplete(G.result)):(G==null?void 0:G.type)==="failed"&&R(()=>_.onFailed({message:G.error||"Job failed",kind:"job"}))}catch{}},F.onerror=()=>R(()=>_.onFailed({message:"Connection error",kind:"transport"})),setTimeout(()=>R(()=>_.onFailed({message:"Timed out",kind:"transport"})),3e4);return}catch{}if(y==="poll"&&($!=null&&$.getJob)){const F=window.setInterval(async()=>{var Y;try{const G=await $.getJob("bulk-operations",v),W=(G==null?void 0:G.status)||((Y=G==null?void 0:G.job)==null?void 0:Y.status),et=(G==null?void 0:G.result)||(G==null?void 0:G.data);W==="failed"||et!=null&&et.final?(window.clearInterval(F),R(()=>W==="failed"?_.onFailed({message:(et==null?void 0:et.error)||"Job failed",kind:"job"}):_.onComplete(et))):W==="completed"&&(window.clearInterval(F),R(()=>_.onComplete(et)))}catch{}},600);setTimeout(()=>{window.clearInterval(F),R(()=>_.onFailed({message:"Timed out",kind:"transport"}))},3e4);return}R(()=>_.onFailed({message:"Feedback transport unavailable",kind:"transport"}))},[]),km=m.useCallback(async(y,v,b)=>{var Y,G;const _=t==null?void 0:t.files,M=encodeURIComponent(s||localStorage.getItem("token")||"");if(_!=null&&_.upload){const W=await _.upload(y,v||{},b),et=(W==null?void 0:W.url)||(W==null?void 0:W.path)||"";return et?(W==null?void 0:W.visibility)==="public"?et:`${Ge()}${et}?token=${M}`:""}const A=new FormData;A.append("file",y),v!=null&&v.entityType&&A.append("entityType",v.entityType),v!=null&&v.entityId&&A.append("entityId",v.entityId),v!=null&&v.visibility&&A.append("visibility",v.visibility);const R=await fetch(`${Ge()}/files/upload`,{method:"POST",headers:{Authorization:`Bearer ${s||localStorage.getItem("token")||""}`},body:A});if(!R.ok)throw new Error("Upload failed");const $=await R.json(),N=((Y=$==null?void 0:$.asset)==null?void 0:Y.url)||($==null?void 0:$.url)||($==null?void 0:$.path)||($==null?void 0:$.id)||"";return N?((G=$==null?void 0:$.asset)==null?void 0:G.visibility)==="public"?N:`${Ge()}${N}?token=${M}`:""},[]),Mm=m.useCallback(async(y,v,b,_)=>{var R;if(!(y!=null&&y.endpoint)||_.length===0)return;const M=y.endpoint,A=y.optimistic??!0;try{const $=await fetch(Ge()+M,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s||localStorage.getItem("token")||""}`},body:JSON.stringify({ids:_})});let N={};try{N=await $.json()}catch{}if(!$.ok){Vt(((R=N==null?void 0:N.error)==null?void 0:R.message)||"Request failed","error");return}A!==!1&&(A==="remove"||A==="refresh"?A:N.softUpdate||(y.action==="delete"?"remove":"refresh"))==="remove"&&_l(v,_,"remove"),St(Y=>({...Y,_selIds:[],_selectMode:!1}));const F=(Y,G,W)=>{var et;if(Y)Vt(W||"Bulk operation failed","error");else{const B=G||{},Z=B.total??_.length,dt=B.successful??Z;Vt(dt>=Z?`${dt} ${y.action}d`:`${dt} of ${Z} ${y.action}d`,"success")}Te(v,b,0,((et=Ee[b])==null?void 0:et.limit)||10)};N.jobId&&N.token&&y.feedback?Oi(y.feedback,N.jobId,N.token,{onComplete:Y=>F(!1,Y),onFailed:Y=>{var G;if(Y.kind==="transport"){Te(v,b,0,((G=Ee[b])==null?void 0:G.limit)||10);return}F(!0,null,Y.message)}}):F(!1,N)}catch{Vt("Request failed","error")}},[_l,Oi,Te,Ee]),Em=(y,v,b)=>{const _=pi(y),M=_.indexOf("(");if(M===-1)return y;const A=_.slice(M+1,-1).trim(),R=`sort: "${v}", dir: ${b==="desc"?'"desc"':'"asc"'}`;if(!A)return y.replace(/\(\)$/,`({${R}})`);const $=A.lastIndexOf(",");if($===-1)return y.replace(/\(([^)]*)\)$/,`(${A}, {${R}})`);const N=A.slice($+1).trim();return N.startsWith("{")?y.replace(/\(([^)]*)\)$/,`(${A.slice(0,$)}, {${N.slice(1,-1)}, ${R}})`):y.replace(/\(([^)]*)\)$/,`(${A}, {${R}})`)},Tm=(y,v)=>{const b=pi(y),_=b.indexOf("(");if(_===-1)return y;const M=b.slice(_+1,-1).trim(),A=`limit: ${v.limit}, page: ${v.page}`;if(!M)return y.replace(/\(\)$/,`({${A}})`);const R=M.lastIndexOf(",");if(R===-1)return y.replace(/\(([^)]*)\)$/,`(${M}, {${A}})`);const $=M.slice(R+1).trim();return $.startsWith("{")?y.replace(/\(([^)]*)\)$/,`(${M.slice(0,R)}, {${$.slice(1,-1)}, ${A}})`):y.replace(/\(([^)]*)\)$/,`(${M}, {${A}})`)};m.useEffect(()=>()=>{ge.current=!0},[]),Et.colors.background;const we=m.useMemo(()=>`bf-preview-${Math.random().toString(36).slice(2,9)}`,[]),Am=y=>y.replace(/:(\w+)/g,(v,b)=>{const _=Pt[b];return _===void 0?v:String(_)}),Rm=y=>{try{const v=JSON.parse(y);if(Array.isArray(v)&&v.length>0)return v.map(b=>{var _;return b.message||`${((_=b.path)==null?void 0:_.join("."))||"field"} is invalid`})}catch{}return null};class ws extends Error{constructor(b,_){super(b.join(", "));go(this,"errors");go(this,"body");this.errors=b,this.body=_}}const ni=async(y,v)=>{var et,B,Z,dt;if(ee.current||!mt)return;const{method:b,path:_}=Rl(y),M=Am(_),A=b!=="GET"&&b!=="DELETE",R=Ge();b!=="GET"&&$l(b,M,Pt,(v==null?void 0:v.optimistic)??!0);let $;if(v!=null&&v.payload&&typeof v.payload=="object"){$={};for(const[z,at]of Object.entries(v.payload))$[z]=typeof at=="string"&&at.includes("{{")?ao(at):at}else $=Pt;$=Pl($);const N=await fetch(new URL(M,R).toString(),{method:b,headers:{"Content-Type":"application/json",Authorization:`Bearer ${s||localStorage.getItem("token")||""}`},...A?{body:JSON.stringify($)}:{}});if(await to(N)||ge.current)return;let F;try{F=await N.json()}catch{if(ge.current)return;if(!N.ok)throw new ws([`Request failed: ${N.statusText}`]);return}if(!N.ok||F.success===!1){rn(M,v==null?void 0:v.refetchScope);let z=["Something went wrong"];throw(et=F.error)!=null&&et.message?z=Rm(F.error.message)||[F.error.message]:F.message&&(z=[F.message]),new ws(z,F)}F.token&&localStorage.setItem("token",F.token),F&&typeof F=="object"&&!Array.isArray(F)&&St(z=>({...z,feedback:F})),F.data&&(v==null?void 0:v.mergeResponse)!==!1&&St(z=>({...z,...F.data})),F.user&&typeof F.user=="object"?St(z=>({...z,user:F.user})):St(z=>({...z})),ce.current[M.replace(/^\//,"")]={response:F};for(const[z,at]of Object.entries(ei.current))if(at===M||at.endsWith(M)){const rt=ce.current[z];ce.current[z]={items:Array.isArray(rt)?rt:Array.isArray(rt==null?void 0:rt.items)?rt.items:[],response:F}}const Y=(Z=(B=F.subscribe)==null?void 0:B.websocket)==null?void 0:Z.workflowChannel;Y&&(v==null?void 0:v.mergeResponse)!==!1&&St(z=>{var at,rt,At,$t;return{...z,liveCastChannel:Y,execution_id:F.draftId||z.execution_id,id:F.sessionId||z.id,status:"running",test_session:{...z.test_session||{},id:F.sessionId||((at=z.test_session)==null?void 0:at.id),execution_id:F.draftId||((rt=z.test_session)==null?void 0:rt.execution_id),status:"running",liveCastChannel:Y,prompt:($==null?void 0:$.prompt)||((At=z.test_session)==null?void 0:At.prompt),url:($==null?void 0:$.url)||(($t=z.test_session)==null?void 0:$t.url)}}}),rn(M,(v==null?void 0:v.refetchScope)||(b!=="GET"?"view":void 0));const G=v==null?void 0:v.feedback,W=typeof G=="string"?G:G==null?void 0:G.transport;if(W&&F.jobId&&(F.token||(dt=F.subscribe)!=null&&dt.sse||typeof G=="object")){let z;if(typeof G=="object"&&G.subscribeUrl){const at=String(G.subscribeUrl).trim(),rt=at.startsWith("{{")&&at.endsWith("}}")?at.slice(2,-2).trim():at,At=rt.match(/^\[(.+?)\](?:\.(.*))?$/),$t=At?bn(`${At[1]}${At[2]?"."+At[2]:""}`):rt.split(".").reduce((Se,de)=>Se==null?void 0:Se[de],F);$t&&(z=/^https?:\/\//.test($t)?$t:R+$t)}if(z){Oi(W,F.jobId,F.token,{sseUrl:z,onProgress:at=>{o==null||o(at);const rt=Date.now();rt-os.current>=2e3&&(os.current=rt,rn(M,v==null?void 0:v.refetchScope))},onComplete:at=>{const rt=(at==null?void 0:at.result)??at;if(rt&&typeof rt=="object"){const At=M.replace(/^\//,"");ce.current[At]={response:rt},St($t=>({...$t}))}rn(M,v==null?void 0:v.refetchScope)},onFailed:at=>{rn(M,v==null?void 0:v.refetchScope),at.kind!=="transport"&&Vt(at.message||"Job failed","error")}});return}Oi(W,F.jobId,F.token,{onComplete:at=>{const rt=at||{},At=rt.total,$t=rt.successful;At!==void 0&&Vt($t>=At?`${$t} completed`:`${$t} of ${At} completed`,"success"),rn(M,v==null?void 0:v.refetchScope)},onFailed:at=>{if(at.kind==="transport"){rn(M,v==null?void 0:v.refetchScope);return}Vt(at.message||"Job failed","error"),rn(M,v==null?void 0:v.refetchScope)}})}},on=y=>{var _,M;se(null);const v=y==="/"&&(((_=Q.find(A=>A.route==="/"))==null?void 0:_.id)||((M=Q.find(A=>A.type==="render_scene"))==null?void 0:M.id))||y;if(ut(v)&&!mt){ue.current=v,ae(!0);return}kt(A=>[...A,ot]),Me(v)},so=(y,v="error")=>{if(St(b=>({...b,gateTitle:y.uiTitle||"Usage Notice",gateMessage:y.message})),y.uiVariant!=="modal"){const b=y.uiTitle?`${y.uiTitle}
89
- ${y.message}`:y.message;Vt(b,v);return}if(y.modalId&&Gt[y.modalId]){se({id:y.modalId,definition:Gt[y.modalId]});return}se({id:"__legacy",definition:{title:y.uiTitle||"Usage Notice",components:[{type:"text",text:y.message,color:Et.colorMode==="light"?"rgba(0,0,0,0.65)":"rgba(255,255,255,0.7)",fontSize:14}],actions:[{label:"OK",variant:"primary",dismiss:!0}]}})},io=(y,v)=>{const b=y.body;if(!b)return!1;const _=typeof(b==null?void 0:b.message)=="string"&&b.message||y.errors[0]||"Request blocked by limits",M=()=>so({message:_,uiVariant:b.uiVariant,uiTitle:typeof(b==null?void 0:b.uiTitle)=="string"?b.uiTitle:void 0,modalId:typeof(b==null?void 0:b.modalId)=="string"?b.modalId:void 0});return b.gateAction==="login"?(fn("login"),!0):b.gateAction==="upgrade"?b.uiVariant==="modal"||typeof(b==null?void 0:b.modalId)=="string"?(M(),!0):v!=null&&v.upgradeScene?(on(v.upgradeScene),!0):(M(),!0):b.gateAction==="block"||b.gateAction==="warn"||b.warning?(M(),!0):!1};m.useEffect(()=>{if(!mt||D)return;const y=ue.current;!y||!Q.some(v=>v.id===y)||(ue.current=null,on(y))},[mt,D,Q]);const Vt=(y,v="success",b)=>{const _=Array.isArray(y)?y.join(`
90
- `):y,M=v==="success",A=M?"#10B981":"#EF4444",R=Et.toast||{},$=b??R.duration??3e3,N=R.position||"bottom-right",F={"bottom-right":{right:"24px",bottom:"24px"},"bottom-left":{left:"24px",bottom:"24px"},"bottom-center":{left:"50%",bottom:"24px",transform:"translateX(-50%)"},"top-right":{right:"24px",top:"24px"},"top-left":{left:"24px",top:"24px"},"top-center":{left:"50%",top:"24px",transform:"translateX(-50%)"}},Y=F[N]||F["bottom-right"],G=document.createElement("div"),W=document.createElement("span");W.textContent=M?"✓":"✕",Object.assign(W.style,{display:"flex",alignItems:"center",justifyContent:"center",width:"22px",height:"22px",minWidth:"22px",borderRadius:"50%",backgroundColor:`${A}26`,color:A,fontSize:"12px",fontWeight:"700"});const et=document.createElement("span");et.textContent=_,Object.assign(et.style,{color:"rgba(255, 255, 255, 0.92)",fontSize:"13.5px",lineHeight:"1.45",whiteSpace:"pre-line"}),Object.assign(G.style,{position:"fixed",...Y,zIndex:"2147483647",display:"flex",alignItems:"flex-start",gap:"10px",padding:"12px 16px",borderRadius:"12px",backgroundColor:"rgba(23, 25, 35, 0.97)",border:"1px solid rgba(148, 163, 184, 0.25)",boxShadow:"0 8px 28px rgba(0, 0, 0, 0.4)",maxWidth:"380px",opacity:"0",pointerEvents:"auto"}),G.appendChild(W),G.appendChild(et),document.body.appendChild(G),G.animate([{opacity:0,transform:"translateX(24px)"},{opacity:1,transform:"translateX(0)"}],{duration:250,easing:"cubic-bezier(0.16, 1, 0.3, 1)",fill:"both"}).finished.catch(()=>{});const Z=()=>{G.animate([{opacity:1,transform:"translateX(0)"},{opacity:0,transform:"translateX(16px)"}],{duration:200,easing:"ease",fill:"both"}).finished.then(()=>G.remove()).catch(()=>G.remove())};return $>0&&setTimeout(Z,$),{update:dt=>{et.textContent=Array.isArray(dt)?dt.join(`
91
- `):dt},dismiss:Z}},Ss=(y,v=!0)=>{if(v&&(y!=null&&y.onSuccess)){const b=Array.isArray(y.onSuccess)?y.onSuccess:[y.onSuccess];for(const _ of b){const{type:M,value:A,title:R,key:$}=_;switch(M){case"toast":Vt(A||"Success!","success");break;case"navigate":A&&on(A);break;case"redirect":A&&(window.location.href=A);break;case"modal":A&&Gt[A]?se({id:A,definition:Gt[A]}):se({id:"__legacy",definition:{title:R||"Success",components:A?[{type:"text",text:A,color:Et.colorMode==="light"?"rgba(0,0,0,0.65)":"rgba(255,255,255,0.7)",fontSize:14}]:[],actions:[{label:"OK",variant:"primary",dismiss:!0}]}});break;case"route":A&&ni(A);break;case"set_data":$&&A!==void 0&&St(N=>({...N,[$]:A}));break}}}else!v&&(y!=null&&y.onError)&&Vt(y.onError.message||"An error occurred","error")},Pm=()=>{var Se,de,ii,Xi,Qt,_t,Jt;const y=async()=>{var Tt,Ye,Un,Hn,Ce,ac;if(!Ot||!Ft||We==="register"&&!nn)return;const st=gn(Ot),pt=tt(Ft);if(st||pt){ie(st||pt);return}if(We==="register"&&nn!==Ft){It("confirm","Passwords do not match"),ie("Passwords do not match");return}sn(!0),ie(null);try{const xn=We==="login"?"/auth/login":"/auth/register",Qi=`${Ge().replace(/\/+$/,"")}${xn}`,Qm=We==="login"?{email:Ot,password:Ft,tenantId:S}:{email:Ot,password:Ft,displayName:Ot.split("@")[0],tenantId:S},lc={"Content-Type":"application/json"};T&&(lc["x-app-id"]=T);const po=await fetch(Qi,{method:"POST",headers:lc,body:JSON.stringify(Qm)});if(!po.ok){const Jm=await po.json().catch(()=>({error:"Authentication failed"}));throw new Error(le(Jm))}const Le=await po.json();if(Array.isArray(Le)||Le.success===!1)throw new Error(le(Le));const cc=((Tt=Le.data)==null?void 0:Tt.token)||Le.token||Le.accessToken||Le.idToken;cc&&localStorage.setItem("token",cc);const hc=((Ye=Le.data)==null?void 0:Ye.refreshToken)||Le.refreshToken;hc&&localStorage.setItem("backflow_refresh_token",hc);const uc=((Hn=(Un=Le.data)==null?void 0:Un.user)==null?void 0:Hn.id)||((Ce=Le.user)==null?void 0:Ce.id)||((ac=Le.data)==null?void 0:ac.userId);if(uc&&localStorage.setItem("backflow_refresh_user_id",uc),!mt&&(Pe||ee.current||!!ue.current)){window.location.reload();return}ee.current=!1,he(!0),ae(!1),V(!1),en(""),He(""),ys(""),vs({}),ie(null)}catch(xn){const Qi=typeof xn=="string"?xn:(xn==null?void 0:xn.message)||JSON.stringify(xn)||"Authentication failed";ie(Qi),Vt(Qi,"error")}finally{sn(!1)}},v=async()=>{if(!Ot)return;const st=gn(Ot);if(st){ie(st);return}sn(!0),ie(null);try{const pt=await fetch("/api/auth/forgot-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:Ot})});if(!pt.ok){const Tt=await pt.json().catch(()=>({error:"Failed to send reset email"}));throw new Error(le(Tt))}fn("reset"),pn(""),He(""),ie(null)}catch(pt){const Tt=typeof pt=="string"?pt:(pt==null?void 0:pt.message)||"Failed to send reset email";ie(Tt),Vt(Tt,"error")}finally{sn(!1)}},b=async()=>{if(!mn||!Ft)return;const st=tt(Ft);if(st){ie(st);return}sn(!0),ie(null);try{const pt=await fetch("/api/auth/reset-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:mn,password:Ft})});if(!pt.ok){const Tt=await pt.json().catch(()=>({error:"Failed to reset password"}));throw new Error(le(Tt))}fn("login"),en(""),He(""),pn(""),ie(null)}catch(pt){const Tt=typeof pt=="string"?pt:(pt==null?void 0:pt.message)||"Failed to reset password";ie(Tt),Vt(Tt,"error")}finally{sn(!1)}},_=st=>{fn(st),ie(null),st!=="reset"&&(pn(""),He("")),ys(""),vs({})},M=Et.colorMode==="dark",A=M?"#f3f4f6":"#111827",R=M?"#9ca3af":"#6b7280",$=M?"#374151":"#f3f4f6",N=M?"#4b5563":"#d1d5db",F=M?"#ffffff":"#000000",Y=M?"#000000":"#ffffff",G=M?"#1f2937":"#ffffff",W="#ef4444",et=(st="12px")=>({width:"100%",padding:"12px 16px",border:`1px solid ${N}`,borderRadius:"8px",fontSize:"14px",backgroundColor:$,color:A,outline:"none",marginBottom:st,boxSizing:"border-box"}),B=(st,pt,Tt,Ye,Un,Hn)=>m.createElement("div",{key:st,style:{position:"relative",marginBottom:"12px"}},E("input",{key:"input",type:bs[st]?"text":"password",placeholder:pt,value:Tt,onChange:Ce=>Ye(Ce.target.value),onKeyDown:Ce=>{Ce.key==="Enter"&&Un()},style:{...et("0px"),paddingRight:"40px",borderColor:Hn?W:N}}),m.createElement("button",{key:"toggle",type:"button","aria-label":bs[st]?"Hide password":"Show password",onClick:()=>vs(Ce=>({...Ce,[st]:!Ce[st]})),style:{position:"absolute",right:"8px",top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",color:R,display:"flex",alignItems:"center",padding:"4px"}},je.renderIcon(bs[st]?"eye-off":"eye",16)));l||e!=null&&e.title;const Z=(Se=e==null?void 0:e.config)!=null&&Se.logo&&((de=e==null?void 0:e.config)==null?void 0:de.logo)!==""?e.config.logo:"",dt=c||((ii=e==null?void 0:e.navigation)==null?void 0:ii.logo)||"mail",z=[];z.push(m.createElement("div",{key:"brand",role:"button","aria-label":"Go back home",onClick:()=>{on("/"),ae(!1),ee.current=!1,ue.current=null},style:{display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"20px",cursor:"pointer"}},Z?m.createElement("img",{src:Z,alt:"",style:{width:"56px",height:"56px",objectFit:"contain"}}):je.renderIcon(dt,56))),We==="login"?(z.push(m.createElement("h2",{key:"title",style:{fontSize:"24px",fontWeight:700,color:A,marginBottom:"8px",textAlign:"center"}},"Sign In")),z.push(m.createElement("p",{key:"sub",style:{fontSize:"14px",color:R,marginBottom:"24px",textAlign:"center"}},"Enter your credentials to continue")),z.push(E("input",{key:"email",type:"email",placeholder:"Email Address",value:Ot,onChange:st=>{en(st.target.value),It("email",gn(st.target.value))},style:{...et(),borderColor:Wt.email&&Ot?W:N}})),Wt.email&&Ot&&z.push(m.createElement("p",{key:"email-err",style:{color:W,fontSize:"12px",marginTop:"-8px",marginBottom:"8px"}},Wt.email)),z.push(B("pass","Password",Ft,st=>{He(st),It("pass",tt(st))},y,!!(Wt.pass&&Ft))),Wt.pass&&Ft&&z.push(m.createElement("p",{key:"pass-err",style:{color:W,fontSize:"12px",marginTop:"-12px",marginBottom:"12px"}},Wt.pass)),Ie&&z.push(m.createElement("p",{key:"err",style:{color:W,fontSize:"13px",marginBottom:"12px",textAlign:"center"}},Ie)),z.push(m.createElement("button",{key:"submt",onClick:y,disabled:re||!Ot||!Ft,style:{width:"100%",padding:"12px",borderRadius:"8px",fontSize:"15px",fontWeight:600,backgroundColor:re?M?"#4b5563":"#9ca3af":F,color:Y,border:"none",cursor:re?"not-allowed":"pointer",marginBottom:"8px"}},re?"Please wait...":"Sign In")),z.push(m.createElement("p",{key:"forgot",style:{fontSize:"13px",color:R,textAlign:"center",cursor:"pointer",marginBottom:"16px"},onClick:()=>_("forgot")},"Forgot password?")),z.push(m.createElement("p",{key:"sw",style:{fontSize:"13px",color:R,textAlign:"center",cursor:"pointer"},onClick:()=>_("register")},"Don’t have an account? Register"))):We==="register"?(z.push(m.createElement("h2",{key:"title",style:{fontSize:"24px",fontWeight:700,color:A,marginBottom:"8px",textAlign:"center"}},"Create Account")),z.push(m.createElement("p",{key:"sub",style:{fontSize:"14px",color:R,marginBottom:"24px",textAlign:"center"}},"Create an account to get started")),z.push(E("input",{key:"email",type:"email",placeholder:"Email",value:Ot,onChange:st=>{en(st.target.value),It("email",gn(st.target.value))},style:{...et(),borderColor:Wt.email&&Ot?W:N}})),Wt.email&&Ot&&z.push(m.createElement("p",{key:"email-err",style:{color:W,fontSize:"12px",marginTop:"-8px",marginBottom:"8px"}},Wt.email)),z.push(B("pass","Password",Ft,st=>{He(st),It("pass",tt(st))},y,!!(Wt.pass&&Ft))),Wt.pass&&Ft&&z.push(m.createElement("p",{key:"pass-err",style:{color:W,fontSize:"12px",marginTop:"-12px",marginBottom:"12px"}},Wt.pass)),z.push(B("confirm","Confirm password",nn,st=>{ys(st),It("confirm",Yt(Ft,st))},y,!!(Wt.confirm&&nn))),Wt.confirm&&nn&&z.push(m.createElement("p",{key:"confirm-err",style:{color:W,fontSize:"12px",marginTop:"-12px",marginBottom:"12px"}},Wt.confirm)),Ie&&z.push(m.createElement("p",{key:"err",style:{color:W,fontSize:"13px",marginBottom:"12px",textAlign:"center"}},Ie)),z.push(m.createElement("button",{key:"submt",onClick:y,disabled:re||!Ot||!Ft||!nn,style:{width:"100%",padding:"12px",borderRadius:"8px",fontSize:"15px",fontWeight:600,backgroundColor:re?M?"#4b5563":"#9ca3af":F,color:Y,border:"none",cursor:re?"not-allowed":"pointer",marginBottom:"16px"}},re?"Please wait...":"Create Account")),z.push(m.createElement("p",{key:"sw",style:{fontSize:"13px",color:R,textAlign:"center",cursor:"pointer"},onClick:()=>_("login")},"Already have an account? Sign In"))):We==="forgot"?(z.push(m.createElement("h2",{key:"title",style:{fontSize:"24px",fontWeight:700,color:A,marginBottom:"8px",textAlign:"center"}},"Reset Password")),z.push(m.createElement("p",{key:"sub",style:{fontSize:"14px",color:R,marginBottom:"24px",textAlign:"center"}},"Enter your email to receive a reset link")),z.push(E("input",{key:"email",type:"email",placeholder:"Email",value:Ot,onChange:st=>{en(st.target.value),It("email",gn(st.target.value))},onKeyDown:st=>{st.key==="Enter"&&v()},style:{...et("16px"),borderColor:Wt.email&&Ot?W:N}})),Wt.email&&Ot&&z.push(m.createElement("p",{key:"email-err",style:{color:W,fontSize:"12px",marginTop:"-8px",marginBottom:"8px"}},Wt.email)),Ie&&z.push(m.createElement("p",{key:"err",style:{color:W,fontSize:"13px",marginBottom:"12px",textAlign:"center"}},Ie)),z.push(m.createElement("button",{key:"submt",onClick:v,disabled:re||!Ot,style:{width:"100%",padding:"12px",borderRadius:"8px",fontSize:"15px",fontWeight:600,backgroundColor:re?M?"#4b5563":"#9ca3af":F,color:Y,border:"none",cursor:re?"not-allowed":"pointer",marginBottom:"16px"}},re?"Please wait...":"Send Reset Link")),z.push(m.createElement("p",{key:"sw",style:{fontSize:"13px",color:R,textAlign:"center",cursor:"pointer"},onClick:()=>_("login")},"Back to Sign In"))):We==="reset"&&(z.push(m.createElement("h2",{key:"title",style:{fontSize:"24px",fontWeight:700,color:A,marginBottom:"8px",textAlign:"center"}},"Set New Password")),z.push(m.createElement("p",{key:"sub",style:{fontSize:"14px",color:R,marginBottom:"24px",textAlign:"center"}},"Enter the reset code and your new password")),z.push(E("input",{key:"code",type:"text",placeholder:"Reset code",value:mn,onChange:st=>pn(st.target.value),style:et()})),z.push(B("pass","New password",Ft,st=>{He(st),It("pass",tt(st))},b,!!(Wt.pass&&Ft))),Wt.pass&&Ft&&z.push(m.createElement("p",{key:"pass-err",style:{color:W,fontSize:"12px",marginTop:"-12px",marginBottom:"12px"}},Wt.pass)),Ie&&z.push(m.createElement("p",{key:"err",style:{color:W,fontSize:"13px",marginBottom:"12px",textAlign:"center"}},Ie)),z.push(m.createElement("button",{key:"submt",onClick:b,disabled:re||!mn||!Ft,style:{width:"100%",padding:"12px",borderRadius:"8px",fontSize:"15px",fontWeight:600,backgroundColor:re?M?"#4b5563":"#9ca3af":F,color:Y,border:"none",cursor:re?"not-allowed":"pointer",marginBottom:"16px"}},re?"Please wait...":"Reset Password")),z.push(m.createElement("p",{key:"sw",style:{fontSize:"13px",color:R,textAlign:"center",cursor:"pointer"},onClick:()=>_("login")},"Back to Sign In")));const at=((Xi=e==null?void 0:e.config)==null?void 0:Xi.auth)||{},rt=at.style==="page"?"page":"modal",At=at.containerStyle||{},$t=m.createElement("div",{key:"auth-box",style:{width:"100%",maxWidth:rt==="page"?"400px":"360px",padding:"24px",backgroundColor:"#000000",borderRadius:"12px",...At}},...z);if(rt==="page"){const st=((Qt=Et.colors)==null?void 0:Qt.primary)||"#4f46e5",pt=at.coverImage?`url(${at.coverImage}) center/cover no-repeat`:st,Tt=(_t=e==null?void 0:e.config)!=null&&_t.logo&&((Jt=e==null?void 0:e.config)==null?void 0:Jt.logo)!==""?e.config.logo:"",Ye=Tt?m.createElement("img",{src:Tt,alt:"",style:{position:"absolute",bottom:"-6%",left:"50%",width:"90%",maxWidth:"660px",height:"auto",objectFit:"contain",transform:"translateX(-50%) rotate(-8deg)",opacity:.92,filter:"brightness(0) invert(1)"}}):m.createElement("div",{style:{color:"#ffffff",opacity:.95}},je.renderIcon(dt,96));return m.createElement("div",{key:"auth-page",style:{position:"fixed",top:0,left:0,right:0,bottom:0,display:"flex",backgroundColor:G,zIndex:1e4,animation:"bf-fade-in 0.2s ease"}},m.createElement("div",{style:{flex:gs?"1 1 100%":"0 0 40%",display:"flex",alignItems:"center",justifyContent:"center",padding:"24px",backgroundColor:"#000000"}},$t),m.createElement("div",{style:{flex:"0 0 60%",background:pt,display:gs?"none":"flex",alignItems:"center",justifyContent:"center",position:"relative",overflow:"hidden"}},Ye))}return m.createElement("div",{key:"auth-form",style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4,animation:"bf-fade-in 0.15s ease"}},$t)},ro=async(y,v,b)=>{var _,M;try{let A=String(ao(y)??"");const R=A.match(/^\{\{\s*(.+?)\s*\?\s*(.*?)\s+:\s+(.*?)\s*\}\}$/);R&&(A=zl(R[1])?R[2]:R[3]);const $=A.split(";").map(B=>B.trim()).filter(Boolean);if($.length>1){for(const B of $)await ro(B,void 0,b);return}if(A==="go_back"){Dn();return}if(A==="toggle_theme"){Al((Pt._colorMode||Et.colorMode)==="dark"?"light":"dark");return}if(A==="close_modal"){Wn();return}const N=A.match(/^(toast|show_toast):(.*)$/);if(N){const B=N[2].trim();B&&Vt(B,"success");return}const F=A.match(/^scroll_to:([\w-]+)$/);if(F){(_=document.getElementById(F[1]))==null||_.scrollIntoView({behavior:"smooth",block:"start"});return}const Y=A.match(/^set_data:([\w.]+)=(.*)$/);if(Y){St(B=>({...B,[Y[1]]:Y[2]}));return}const G=A.match(/^native:([a-z][\w.-]*)$/i);if(G){if(!i){Vt("Native app required","error");return}const B=G[1],Z=await i(B,Pt);if(Z&&typeof Z=="object"&&!Array.isArray(Z)){const dt=B.replace(/[^\w]/g,"_");St(z=>({...z,native:{...z.native||{},[dt]:Z}}))}return}const W=A.match(/^copy_to_clipboard:(.*)$/);if(W){const B=W[1];try{await navigator.clipboard.writeText(B)}catch{const Z=document.createElement("textarea");Z.value=B,Z.style.position="fixed",Z.style.opacity="0",document.body.appendChild(Z),Z.select(),document.execCommand("copy"),Z.remove()}Vt("API key copied","success");return}const et=A.match(/^auth:(login|register|forgot|reset|logout)$/);if(et){if(et[1]==="logout"){if(!mt)return;localStorage.removeItem("token"),localStorage.removeItem("backflow_refresh_token"),localStorage.removeItem("backflow_refresh_user_id"),ee.current=!1,ue.current=null,he(!1),ae(!1),nt(null),V(!1),on("/");return}if(mt)return;ie(null),fn(et[1]),ae(!0);return}if(A==="accept_startup_modal"){const B=Et.startupModal;B&&localStorage.setItem(`backflow_startup_modal_${B}`,"1"),Wn();const Z=Q.find(dt=>dt.route==="/");Z&&(kt(dt=>[...dt,ot]),Me(Z.id));return}if(A==="decline_startup_modal"){Wn();const B=Q.find(Z=>Z.route==="/");B&&(kt(Z=>[...Z,ot]),Me(B.id));return}if(A==="toggle_select"){St(B=>({...B,_selectMode:!B._selectMode,...B._selectMode?{_selIds:[]}:{}}));return}if(A.startsWith("go_to_step:"))on(A.replace("go_to_step:","")),Ss(v,!0);else if(A.startsWith("navigate:"))on(A.replace("navigate:","")),Ss(v,!0);else if(Ci(A)&&t){const B=pi(A),Z=await Mr(t,B,Pt);Z!=null&&Z.data?St(dt=>({...dt,...Z.data})):Z&&typeof Z=="object"&&!Array.isArray(Z)&&St(dt=>({...dt,...Z})),Z!=null&&Z.url&&String(Z.url).startsWith("http")&&window.open(String(Z.url),"_blank","noopener,noreferrer"),Ss(v,!0)}else if(A.startsWith("show_modal:")){const B=A.replace("show_modal:","");if(Gt[B]){const Z=Gt[B];if(ms(Z.popover&&(b!=null&&b.anchorElement)?b.anchorElement.getBoundingClientRect():null),ps.current=Z.popover&&(b==null?void 0:b.anchorElement)||null,yn.current&&typeof yn.current=="object"){const at=Object.keys(yn.current);St(rt=>{const At={...rt};for(const $t of no.current)at.includes($t)||delete At[$t];return{...At,...yn.current}}),no.current=at}const dt=Z.clearFormKeys;Array.isArray(dt)&&dt.length>0&&St(at=>{const rt={...at};for(const At of dt)delete rt[At];return rt});const z=Z.defaults;z&&typeof z=="object"&&St(at=>{const rt={...at};for(const[At,$t]of Object.entries(z))rt[At]===void 0&&(rt[At]=$t);return rt}),Z.preload&&await ni(String(Z.preload)),(zt==null?void 0:zt.id)===B||(_e==null?void 0:_e.id)===B||(zt?jn({id:B,definition:Z}):se({id:B,definition:Z}))}else{const Z=B.split("|");se({id:"__legacy",definition:{title:Z[0]||"Notice",components:Z[1]?[{type:"text",text:Z[1],color:"rgba(255,255,255,0.7)",fontSize:14}]:[],actions:[{label:"OK",variant:"primary",dismiss:!0}]}})}Ss(v,!0)}else A.startsWith("execute_workflow:")?(await ni(A.replace("execute_workflow:",""),b),Ss(v,!0)):A.startsWith("fetch:")&&(await ni(A.replace("fetch:",""),b),r==null||r(A.replace("fetch:","")),Ss(v,!0))}catch(A){if(gr("[handleButtonClick] caught error:",A,"callbacks:",v),A instanceof ws){if(io(A,v==null?void 0:v.onError))return;Vt(A.errors.length>1?A.errors:A.errors[0],"error")}else(M=v==null?void 0:v.onError)!=null&&M.message?Vt(v.onError.message,"error"):Vt(A instanceof Error?A.message:"An error occurred","error")}},Nl=y=>{const v=y&&typeof y=="object"&&"_seconds"in y?new Date(y._seconds*1e3):new Date(y);if(isNaN(v.getTime()))return String(y??"");const b=Math.floor((Date.now()-v.getTime())/6e4);if(b<1)return"just now";if(b<60)return`${b}m ago`;const _=Math.floor(b/60);if(_<24)return`${_}h ago`;const M=Math.floor(_/24);return M<7?`${M}d ago`:v.toLocaleDateString()},On=(y,v)=>{if(v==="timeago")return Nl(y);const b=y&&typeof y=="object"&&"_seconds"in y?new Date(y._seconds*1e3):new Date(y);if(!isNaN(b.getTime())){if(v==="date")return b.toLocaleDateString();if(v==="time")return b.toLocaleTimeString();if(v==="datetime")return b.toLocaleString()}return String(y??"")},ce=m.useRef({}),bn=y=>{const v=y.split(".").filter(Boolean);if(v.length===0)return;let b=ce.current[v[0]]??Pt[v[0]];for(let _=1;_<v.length;_++){if(b==null)return;const M=v[_];if(Array.isArray(b))if(M==="first")b=b[0];else if(M==="last")b=b[b.length-1];else if(M==="length")b=b.length;else if(/^\d+$/.test(M))b=b[Number(M)];else if(M==="index")b=b[0];else return;else if(b&&typeof b=="object"&&Array.isArray(b.items))M==="response"?b=b.response:M==="first"?b=b.items[0]:M==="last"?b=b.items[b.items.length-1]:M==="length"?b=b.items.length:/^\d+$/.test(M)?b=b.items[Number(M)]:M==="index"?b=b.items[0]:b=b[M];else if(typeof b=="object")b=b[M];else return}return b},oo=m.useRef({}),[Il,Dl]=m.useState({}),_m=m.useCallback(y=>(oo.current[y]||(oo.current[y]=import(y).catch(()=>fetch(y).then(v=>v.text()).then(v=>{const b={};return new Function("module","exports",v)(b,b),b.exports||b}))),oo.current[y]),[]),Ll=(y,v,b,_)=>{if(!y)return"";if(y.startsWith("sdk:")){const R=b||"",$=Il[R];if(R&&$!==void 0)return $;const N=y.slice(4);return t&&Mr(t,N,{...Pt,$data:ce.current}).then(F=>{ge.current||(_&&(ce.current[_]=F),Dl(Y=>({...Y,[R]:String(F??"")})))}).catch(()=>{}),""}const M=y.match(/^([A-Za-z_]\w*)\s*\(\s*(.*?)\s*\)$/s);if(M){const R=M[1],$=Ll(M[2]);if(v){const N=Il[b||""];return b&&N!==void 0?N:(_m(v).then(F=>{var G,W;const Y=F&&(F[R]||((G=F.default)==null?void 0:G[R])||((W=F.exports)==null?void 0:W[R]))||(typeof F=="function"?F:void 0);typeof Y=="function"&&b&&Promise.resolve(Y($,{data:ce.current})).then(et=>{ge.current||(_&&(ce.current[_]=et),Dl(B=>({...B,[b]:String(et??"")})))})}).catch(()=>{}),"")}return R==="timeago"?Nl($):R==="date"?On($,"date"):R==="time"?On($,"time"):R==="datetime"?On($,"datetime"):R==="upper"?String($).toUpperCase():R==="lower"?String($).toLowerCase():String($??"")}if(y.startsWith("{{")&&y.endsWith("}}")){const $=y.slice(2,-2).trim().split("|").map(G=>G.trim()),N=$[0],F=$[1],Y=N.startsWith("{")&&N.endsWith("}")?bn(N.slice(1,-1)):N.startsWith("$")?bn(N.slice(1)):Pt[N];return F?On(Y,F):String(Y??"")}if(y.startsWith("{")&&y.endsWith("}"))return String(bn(y.slice(1,-1))??"");const A=y.trim();return/^[A-Za-z_][\w.-]*$/.test(A)?String(bn(A)??""):String(y??"")},ao=y=>y?y.replace(/\{\{\s*\[([\w/.-]+)\](?:\.([\w.]+(?:\|\w+)?))?\s*(?:\|\|\s*(.+?))?\}\}/g,(v,b,_,M)=>{let A,R=_;if(_!=null&&_.includes("|")){const N=_.split("|");R=N[0],A=N[1]}const $=bn(R?`${b}.${R}`:b);if($!=null){const N=A?On($,A):$;return Array.isArray(N)||typeof N=="object"?JSON.stringify(N):String(N)}return M!==void 0?M.replace(/^["']|["']$/g,""):""}).replace(/\{\{(\w+(?:\.\w+)*)\s*(?:\|(date|time|datetime|timeago)\s*)?(?:\|\|\s*(.+?))?\}\}/g,(v,b,_,M)=>{const A=b.split(".");let R=Pt;for(const $ of A)R=R==null?void 0:R[$];if(R!==void 0)return _?On(R,_):String(R);if(yn.current){let $=yn.current;for(const N of A)$=$==null?void 0:$[N];if($!==void 0)return _?On($,_):String($)}if(A[0]==="config"){let $=e==null?void 0:e.config;for(const N of A.slice(1))$=$==null?void 0:$[N];if($!==void 0)return String($)}return M!==void 0?M.replace(/^["']|["']$/g,""):""}):"",Ui=(y,v)=>{if(!y)return!0;const b=A=>{var $;if(A==="auth"){const N=($=e==null?void 0:e.auth)==null?void 0:$.signedIn;return N===void 0?mt:N}if(A.startsWith("[")&&A.includes("]")){const N=A.indexOf("]"),F=ce.current[A.slice(1,N)],Y=A.slice(N+1).replace(/^\./,"");let G;const W=Y.split(".").filter(Boolean);W[0]==="response"||W[0]==="items"?G=F:G=(F==null?void 0:F.items)??F;for(const et of W){if(G==null)return;Array.isArray(G)&&et==="length"?G=G.length:G=G==null?void 0:G[et]}return G}let R=v;for(const N of A.split("."))R=R==null?void 0:R[N];return R},_=y.trim();if(_.includes("||"))return _.split("||").some(A=>Ui(A,v));if(_.includes("&&"))return _.split("&&").every(A=>Ui(A,v));if(_.startsWith("!"))return!b(_.slice(1).trim());const M=_.match(/^(\[[^\]]+\](?:\.\w+)*|\w+(?:\.\w+)*)\s*(==|!=|>|<|>=|<=)\s*(.+)$/);if(M){const A=b(M[1]),R=M[3].trim().replace(/^["']|["']$/g,"");switch(M[2]){case"==":return String(A)===R;case"!=":return String(A)!==R;case">":return Number(A)>Number(R);case"<":return Number(A)<Number(R);case">=":return Number(A)>=Number(R);case"<=":return Number(A)<=Number(R)}}return!!b(_)},zl=y=>Ui(y,Pt),$m=(y,v,b)=>{if(!u||h!==v&&!(a&&b&&a===b))return y;const M={...y};return u.size!==void 0&&(M.transform=`scale(${u.size/100})`,M.transformOrigin="center center"),u.spacing!==void 0&&(M.margin=`${u.spacing}px`),u.alignment&&(M.textAlign=u.alignment,u.alignment==="left"?(M.marginLeft="0",M.marginRight="auto"):u.alignment==="right"&&(M.marginLeft="auto",M.marginRight="0")),u.color&&(M.color=u.color),u.gridCols!==void 0&&(M.gridTemplateColumns=`repeat(${u.gridCols}, minmax(0, 1fr))`),u.gridGap!==void 0&&(M.gap=`${u.gridGap}px`),u.buttonBackground&&(M.background=u.buttonBackground),u.buttonTextColor&&(M.color=u.buttonTextColor),u.buttonBorderRadius!==void 0&&(M.borderRadius=`${u.buttonBorderRadius}px`),u.linkColor&&(M.color=u.linkColor),u.linkTextDecoration&&(M.textDecoration=u.linkTextDecoration),u.flexDirection&&(M.flexDirection=u.flexDirection),u.flexGap!==void 0&&(M.gap=`${u.flexGap}px`),M},Nm=(y,v)=>{const b={...y};return v.scale!==void 0&&v.scale!==100&&(b.transform=`scale(${v.scale/100})`,b.transformOrigin="center center"),v.spacing!==void 0&&v.spacing!==0&&(b.margin=`${v.spacing}px`),v.alignment&&v.alignment!=="center"&&(b.textAlign=v.alignment,v.alignment==="left"?(b.marginLeft="0",b.marginRight="auto"):v.alignment==="right"&&(b.marginLeft="auto",b.marginRight="0")),v.color&&(b.color=v.color),v.background&&(b.backgroundColor=v.background),v.borderColor&&(b.borderColor=v.borderColor),b},Im=(y,v,b)=>{const _=b==null?void 0:b.componentClass,A=h===y||a&&_&&a===_,R=b?Nm(v,b):v,$=$m(R,y,_);b!=null&&b.fieldSpan&&b.fieldSpan>1&&($.gridColumn=`span ${b.fieldSpan} / span ${b.fieldSpan}`),b!=null&&b.rawStyle&&Object.assign($,b.rawStyle);const N=qt==="css-driven"?{"data-bf-r":`${we}-${y}`}:{};if(A){const Y=$.boxShadow?`${$.boxShadow}, `:"";return{"data-component-key":y,...N,style:{...$,boxShadow:`${Y}0 0 0 3px ${Et.colors.primary}`}}}return Object.keys($).length>0?{"data-component-key":y,...N,style:$}:{"data-component-key":y,...N}},Dm=(y,v)=>{var R;if(!y)return{};const b=ba(y),_=y.split(/\s+/).filter($=>!/^(sm|md|lg|xl|2xl):/.test($)).join(" "),M=Dt(_||"flex");if(!ya(b))return M;if(qt==="css-driven"){const $={flexDirection:"fd",gap:"gap",width:"w",alignItems:"items",justifyContent:"justify",display:"display",fontSize:"text",borderRadius:"radius",padding:"p",paddingLeft:"px",paddingRight:"px",paddingTop:"py",paddingBottom:"py",margin:"m",marginTop:"mt",marginRight:"mr",marginBottom:"mb",marginLeft:"ml"},N=(F,Y)=>`var(--bf-${$[F]||F}-${v}, ${M[F]||Y})`;if(b.flexDirection.size>0&&(M.flexDirection=N("flexDirection","column")),b.gap.size>0&&(M.gap=N("gap","0px")),b.width.size>0&&(M.width=N("width","auto")),b.alignItems.size>0&&(M.alignItems=N("alignItems","stretch")),b.justifyContent.size>0&&(M.justifyContent=N("justifyContent","flex-start")),b.display.size>0&&(M.display=N("display","flex")),b.gridCols.size>0){const F=M.gridTemplateColumns||"1",Y=typeof F=="string"?(R=F.match(/^repeat\((\d+)/))==null?void 0:R[1]:F;M.gridTemplateColumns=`repeat(var(--bf-cols-${v}, ${Y||"1"}), minmax(0, 1fr))`}return b.textSize.size>0&&(M.fontSize=N("fontSize","1rem")),b.borderRadius.size>0&&(M.borderRadius=N("borderRadius","0px")),b.padding.p.size>0&&(M.padding=N("padding","0px")),b.padding.px.size>0&&(M.paddingLeft=N("paddingLeft","0px"),M.paddingRight=N("paddingRight","0px")),b.padding.py.size>0&&(M.paddingTop=N("paddingTop","0px"),M.paddingBottom=N("paddingBottom","0px")),b.margin.all.size>0&&(M.margin=N("margin","0px")),b.margin.t.size>0&&(M.marginTop=N("marginTop","0px")),b.margin.r.size>0&&(M.marginRight=N("marginRight","0px")),b.margin.b.size>0&&(M.marginBottom=N("marginBottom","0px")),b.margin.l.size>0&&(M.marginLeft=N("marginLeft","0px")),b.margin.x.size>0&&(M.marginLeft=N("marginLeft","0px"),M.marginRight=N("marginRight","0px")),b.margin.y.size>0&&(M.marginTop=N("marginTop","0px"),M.marginBottom=N("marginBottom","0px")),M}const A=Xt;if(b.flexDirection.size>0&&(M.flexDirection=ht(b.flexDirection,A,"column")),b.gap.size>0&&(M.gap=ht(b.gap,A,"0px")),b.width.size>0&&(M.width=ht(b.width,A,"auto")),b.alignItems.size>0&&(M.alignItems=ht(b.alignItems,A,"stretch")),b.justifyContent.size>0&&(M.justifyContent=ht(b.justifyContent,A,"flex-start")),b.display.size>0&&(M.display=ht(b.display,A,"flex")),b.gridCols.size>0){const $=ht(b.gridCols,A,1);M.gridTemplateColumns=`repeat(${$}, minmax(0, 1fr))`}return b.textSize.size>0&&(M.fontSize=ht(b.textSize,A,"1rem")),b.borderRadius.size>0&&(M.borderRadius=ht(b.borderRadius,A,"0px")),b.padding.p.size>0&&(M.padding=ht(b.padding.p,A,"0px")),b.padding.px.size>0&&(M.paddingLeft=ht(b.padding.px,A,"0px"),M.paddingRight=ht(b.padding.px,A,"0px")),b.padding.py.size>0&&(M.paddingTop=ht(b.padding.py,A,"0px"),M.paddingBottom=ht(b.padding.py,A,"0px")),b.margin.all.size>0&&(M.margin=ht(b.margin.all,A,"0px")),b.margin.t.size>0&&(M.marginTop=ht(b.margin.t,A,"0px")),b.margin.r.size>0&&(M.marginRight=ht(b.margin.r,A,"0px")),b.margin.b.size>0&&(M.marginBottom=ht(b.margin.b,A,"0px")),b.margin.l.size>0&&(M.marginLeft=ht(b.margin.l,A,"0px")),b.margin.x.size>0&&(M.marginLeft=ht(b.margin.x,A,"0px"),M.marginRight=ht(b.margin.x,A,"0px")),b.margin.y.size>0&&(M.marginTop=ht(b.margin.y,A,"0px"),M.marginBottom=ht(b.margin.y,A,"0px")),M},Fl=m.useRef(new Map),Lm=m.useCallback(async y=>{const v=Fl.current.get(y);if(v)return v;try{const b=s||localStorage.getItem("token")||"",_=await fetch(`/api/admin/schema?collection=${encodeURIComponent(y)}`,{headers:{Authorization:`Bearer ${b}`}});if(!_.ok)return null;const M=await _.json(),R=(Array.isArray(M)?M:Array.isArray(M==null?void 0:M.data)?M.data:[]).find($=>$.collection===y)||null;return Fl.current.set(y,R),R}catch{return null}},[s]),je={cfg:Et,sdk:t,renderMode:qt,scopeId:we,widgets:Array.isArray(e==null?void 0:e.widgets)?e.widgets:[],widgetStack:[],parseClassName:Dt,containerWidth:Xt,interactionDisabled:f,previewMode:U,isAuthenticated:mt,styleOverrides:u,selectedComponentKey:h,selectedComponentClass:a,sceneData:Pt,setSceneData:St,setColorMode:y=>Al(y),portalTarget:gt.current,imageErrors:Js,setImageErrors:Ks,handleButtonClick:ro,interpolateText:ao,evaluateExpression:Ll,evaluateCondition:zl,showToast:Vt,setActiveModal:se,dismissModal:Wn,setOverlayModal:jn,dismissOverlayModal:Wi,fetchListData:Te,fetchEntitySchema:Lm,goBack:Dn,currentSceneId:ot,isMobileView:gs,navigateToScene:on,mobileMenuOpen:Zs,setMobileMenuOpen:fs,renderComponent:(y,v,b)=>Cr(je,y,v,b),renderIcon:(y,v,b)=>(n==null?void 0:n(y,v,b))??Na(y,v,b),getCommonProps:Im,imageReplacements:g,listData:zn,rowContextRef:yn,uploadFile:km,runBulkSelectAction:Mm,selectDynamicOptions:Qs,setSelectDynamicOptions:cs,loading:tn,buttonLoading:us,withLoading:Cm,paginationState:Ee,renderPhaserGame:P,parseClassNameResponsive:Dm};let De=[];const zm=m.useMemo(()=>{const y={};for(const[v,b]of Object.entries(Pt))v.startsWith("_")||(y[v]=b);return JSON.stringify(y)},[Pt]),Hi=m.useRef({}),lo=m.useRef(""),co=m.useRef({}),Bl=m.useRef(Ee);Bl.current=Ee;const Wl=m.useRef(tn);Wl.current=tn;const ho=m.useRef({}),uo=m.useRef(new Set),Cs=m.useRef(null);m.useEffect(()=>{if(!jt||!mt){Be.current.forEach(v=>v()),Be.current.clear(),dn.current.clear();return}const y=v=>{var _;const b=v.getAttribute("data-bf-scroll-load");!b||uo.current.has(b)||(uo.current.add(b),(_=Cs.current)==null||_.observe(v))};Cs.current||(Cs.current=new IntersectionObserver(v=>{for(const b of v){if(!b.isIntersecting)continue;const _=b.target.getAttribute("data-bf-scroll-load");if(!_||ho.current[_])continue;const M=Bl.current[_],A=xs.current[_];if(!A||!(M!=null&&M.hasMore)||Wl.current[_])continue;ho.current[_]=!0;const R=co.current[_]||1;co.current[_]=R+1,Te(A,_,R,M.limit,void 0,void 0,void 0,!0).finally(()=>{var $;if(ho.current[_]=!1,b.target.isConnected){const N=b.target.getBoundingClientRect();N.bottom>-160&&N.top<(window.innerHeight||800)+160&&(($=Cs.current)==null||$.observe(b.target))}})}},{rootMargin:"160px 0px"})),document.querySelectorAll("[data-bf-scroll-load]").forEach(y)},[ot,jt,Te,zn,tn,Ee]),m.useEffect(()=>()=>{var y;(y=Cs.current)==null||y.disconnect(),Cs.current=null,uo.current=new Set},[ot]),m.useEffect(()=>{if(!jt)return;const y=M=>typeof M=="string"?M.replace(/\{\{\s*\[([\w/.-]+)\](?:\.([\w.]+))?\s*(?:\|\|\s*(.+?))?\}\}/g,(A,R,$,N)=>{const F=bn($?`${R}.${$}`:R);return F!=null?String(F):N!==void 0?N.replace(/^["']|["']$/g,""):""}).replace(/\{\{([\w.]+)\}\}/g,(A,R)=>{const $=R.split(".").reduce((N,F)=>N==null?void 0:N[F],Pt);return $!=null?String($):""}):"";lo.current!==ot&&(lo.current=ot);const v=(M,A="")=>{Array.isArray(M)&&M.forEach((R,$)=>{var G;const N=`${A}-${$}`;if((R.type==="list"||R.type==="table")&&R.dataSource){const W=y(R.dataSource),et=Hi.current[N]!==W;et&&(Hi.current[N]=W,co.current[N]=1,Te(W,N,0,R.pageSize||10,void 0,void 0,R.key));const B=R.realtime,Z=B?y(B.channel||""):"",dt=B?y(B.url||""):"",z=B?y(B.event||""):"",at=B?`${dt}|${Z}|${z}`:"",rt=dn.current.get(N)!==at;if(B&&(et||rt)){dn.current.set(N,at);const At=Be.current.get(N);At&&At();const $t=R.pageSize||10;let Se;const de=Qt=>{if(!B.bind)return;let _t=Qt;try{_t=typeof Qt=="string"?JSON.parse(Qt):Qt}catch{}B.bindField&&(!_t||_t[B.bindField]===void 0)||_t&&typeof _t=="object"&&St(Jt=>({...Jt,[B.bind]:_t}))},ii=Qt=>{if(!B.filter)return!0;let _t=Qt;if(typeof _t=="string")try{_t=JSON.parse(_t)}catch{return!1}return!_t||typeof _t!="object"?!1:Object.entries(B.filter).every(([Jt,st])=>_t[Jt]===st)},Xi=(Qt,_t)=>{if(!B.onEvent||!Array.isArray(_t))return;let Jt=Qt;if(typeof Jt=="string")try{Jt=JSON.parse(Jt)}catch{return}const st=Jt==null?void 0:Jt.id,pt=_t.find(Tt=>(Tt==null?void 0:Tt.id)===st);if(pt&&!(B.onEvent.when&&!Ui(B.onEvent.when,pt))){if(B.onEvent.once===!0){const Tt=[N,B.onEvent.action,B.onEvent.when||"",(pt==null?void 0:pt.id)||st||""].join(":");if(Bn.current.has(Tt))return;Bn.current.add(Tt)}yn.current=pt,no.current=Object.keys(pt),St(Tt=>({...Tt,...pt})),ro(B.onEvent.action,{}).catch(()=>{})}};switch(B.mode){case"poll":{const Qt=B.interval||5e3,_t=window.setInterval(()=>Te(W,N,0,$t),Qt);Se=()=>clearInterval(_t);break}case"sse":{if(!dt&&!Z){Se=()=>{};break}const Qt=s||localStorage.getItem("token")||"",_t=dt||`/events?channel=${Z}`,Jt=Qt&&!_t.includes("token=")?`${_t}${_t.includes("?")?"&":"?"}token=${encodeURIComponent(Qt)}`:_t,st=new EventSource(Jt),pt=Tt=>{ii(Tt.data)&&(de(Tt.data),Te(W,N,0,$t))};z?st.addEventListener(z,pt):st.onmessage=pt,st.onerror=()=>st.close(),Se=()=>st.close();break}case"ws":{if(!dt&&!Z){Se=()=>{};break}let Qt=null;const _t=()=>{var st;let Jt;if(Z&&((st=t==null?void 0:t.client)!=null&&st.createWebSocket))Jt=t.client.createWebSocket(Z);else{const pt=dt||`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws?channel=${Z}`;Jt=new WebSocket(pt)}Jt.onmessage=pt=>{ii(pt.data)&&(de(pt.data),Te(W,N,0,$t).then(Tt=>{const Ye=Array.isArray(Tt)?Tt:zn[N];B.onEvent&&Xi(pt.data,Ye);const Un=Pt==null?void 0:Pt.id;if(Un&&Array.isArray(Ye)&&lo.current===ot){const Hn=Ye.find(Ce=>(Ce==null?void 0:Ce.id)===Un);Hn&&St(Ce=>({...Ce,...Hn}))}}))},Jt.onclose=()=>setTimeout(_t,3e3),Qt=Jt};_t(),Se=()=>Qt==null?void 0:Qt.close();break}default:Se=()=>{}}Be.current.set(N,Se)}}if(R.type==="select"&&R.dataSource){const W=`${N}-sel`,et=y(R.dataSource);Hi.current[W]!==et&&(Hi.current[W]=et,(async()=>{try{const B=R.dataSource,Z=y(B),dt=await fetch(Z,{headers:{Authorization:`Bearer ${s||localStorage.getItem("token")||""}`}});if(!dt.ok)return;const z=await dt.json(),at=R.dataField||"configs",rt=R.optionLabel||"label",At=R.optionValue||"value",$t=z[at]||z.data||z,Se=Array.isArray($t)?$t.map(de=>({label:de[rt]||de.name||de.label,value:de[At]||de.id||de.name||de.label})):[];cs(de=>({...de,[N]:Se}))}catch{}})())}R.children&&v(R.children,N);const F=R.accordionItems||(R.type==="accordion"?R.items:null);Array.isArray(F)&&F.forEach((W,et)=>{Array.isArray(W==null?void 0:W.content)&&v(W.content,`${N}-acc-${et}-content`)}),Array.isArray(R.tabItems)&&R.tabItems.forEach((W,et)=>{const B=Array.isArray(W==null?void 0:W.content)?W.content:Array.isArray(W==null?void 0:W.children)?W.children:null;B&&v(B,`${N}-tabcontent-${et}`)});const Y=R;if(Y.type==="widget"&&Y.widgetId){const W=(G=e==null?void 0:e.widgets)==null?void 0:G.find(et=>et.id===Y.widgetId);W&&Array.isArray(W.components)&&v(W.components,`${N}-${Y.widgetId}`)}})};v(De);const b=zt||_e,_=b?Gt==null?void 0:Gt[b.id]:void 0;_&&Array.isArray(_==null?void 0:_.components)&&v(_.components,"modal")},[ot,Te,zm,zt==null?void 0:zt.id,_e==null?void 0:_e.id,mt]),m.useEffect(()=>()=>{Be.current.forEach(y=>y()),Be.current.clear()},[ot]);const fo=m.useMemo(()=>{if(!jt||qt!=="css-driven")return null;const y=new Map,v=(b,_)=>{b.forEach((M,A)=>{const R=`${_}-${A}`;if(M.className){const $=ba(M.className);if(ya($)){const N=ym(we,R,$);N&&y.set(R,N)}}M.children&&v(M.children,R)})};return v(De,""),y},[ot,De,qt,we]),jl=m.useRef(so);jl.current=so;const ks=Et.realtime,Vl=ks==null?void 0:ks.mode,qi=ks==null?void 0:ks.url;if(m.useEffect(()=>{if(!mt||Vl!=="sse"||!qi)return;const y=s||localStorage.getItem("token");if(!y)return;let v=null,b=!1;return(async()=>{try{const _=L||window.location.origin,M=await fetch(`${_}${qi}/token`,{headers:{Authorization:`Bearer ${y}`}});if(!M.ok)return;const{token:A}=await M.json();if(!A||b)return;v=new EventSource(`${_}${qi}/subscribe?token=${encodeURIComponent(A)}`),v.onmessage=R=>{try{const $=JSON.parse(R.data);$!=null&&$.message&&jl.current($,"success")}catch{}},v.onerror=()=>v==null?void 0:v.close()}catch{}})(),()=>{b=!0,v==null||v.close()}},[mt,L,s,Vl,qi]),!jt)return m.createElement(m.Fragment,null,mS(ft,Lt.length,Dn,C));const Mt=jt,si=Mt.backgroundColor,Ol=si&&Ko(si)!==(Et.colorMode==="dark"?"dark":"light")?Ko(si)==="dark"?ki.text:Mi.text:Et.colors.text,Gi=Mt.height!==void 0?typeof Mt.height=="number"?`${Mt.height}px`:Mt.height:void 0,Yi=Mt.minHeight!==void 0?typeof Mt.minHeight=="number"?`${Mt.minHeight}px`:Mt.minHeight:void 0,Fm=Mt.className?{...zu,display:"flex",flexDirection:"column",width:"100%",maxWidth:"100%",position:"relative",...Gi?{height:Gi}:{},...Yi?{minHeight:Yi}:{},backgroundColor:si||Et.colors.background,color:Ol,...Dt(Mt.className)}:{...zu,display:"flex",flexDirection:"column",position:"relative",width:"100%",maxWidth:"100%",...Gi?{height:Gi}:{},...Yi?{minHeight:Yi}:{},backgroundColor:si||Et.colors.background,color:Ol},Ul=Array.isArray(Mt.components)?Mt.components:[],Bm=fS(we),Hl=(jt==null?void 0:jt.requireAuth)===!0||(Mt==null?void 0:Mt.requiresAuth)===!0||(qe==null?void 0:qe.requiresAuth)===!0||((Kl=qe==null?void 0:qe.config)==null?void 0:Kl.requiresAuth)===!0,Wm=(Hl||Pe)&&!mt?Pm():null,jm=mt&&Hl&&J===!1&&!In?m.createElement("div",{key:"email-banner",style:{position:"fixed",top:0,left:0,right:0,zIndex:9500,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"10px 40px",backgroundColor:Et.colorMode==="dark"?"#78350f":"#fef3c7",color:Et.colorMode==="dark"?"#fef3c7":"#92400e",fontSize:"13px",fontWeight:500,boxShadow:"0 2px 8px rgba(0,0,0,0.15)"}},je.renderIcon("alert-triangle",14),m.createElement("span",null,"Verify your email — check your inbox for the confirmation link."),m.createElement("button",{"aria-label":"Dismiss",onClick:()=>Ys(!0),style:{position:"absolute",right:"8px",top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",color:"inherit",display:"flex",alignItems:"center",padding:"4px"}},je.renderIcon("x",16))):null,vn=e,ql=Array.isArray(vn==null?void 0:vn.widgets)?vn.widgets:[],Gl=new Set,mo=y=>{if(Array.isArray(y))for(const v of y)v&&v.type==="widget"&&v.widgetId&&Gl.add(v.widgetId),v&&Array.isArray(v.children)&&mo(v.children)};mo(Ul);for(const y of ql)mo(y.components);const Vm=ql.filter(y=>Gl.has(y.id)?!1:y.sceneIds==="*"?!0:Array.isArray(y.sceneIds)?y.sceneIds.includes("*")||y.sceneIds.includes(ot):!1);De=[...Ul],(tc=(Zl=vn.layout)==null?void 0:Zl.header)!=null&&tc.length?De.splice(0,0,...vn.layout.header):(nc=(ec=Mt==null?void 0:Mt.layout)==null?void 0:ec.header)!=null&&nc.length&&De.splice(0,0,...Mt.layout.header);for(const y of Vm||[]){const v=y.components||[];if(!v.length)continue;if(y.targetKey){const _=y.targetKey.split("-").filter(Boolean).map(Number);if(_.length>0){let M=De,A=_[0];for(let $=0;$<_.length-1;$++){const N=M[_[$]];if(!N||!Array.isArray(N.children))break;M=N.children,A=_[$+1]}const R=y.targetPosition||"before";if(R==="inside"){const $=M[A];$&&(Array.isArray($.children)||($.children=[]),$.children.unshift(...v))}else R==="after"?M.splice(A+1,0,...v):M.splice(A,0,...v);continue}}const b=y.index??De.length;De.splice(b,0,...v)}(ic=(sc=vn.layout)==null?void 0:sc.footer)!=null&&ic.length?De.push(...vn.layout.footer):(oc=(rc=Mt==null?void 0:Mt.layout)==null?void 0:rc.footer)!=null&&oc.length&&De.push(...Mt.layout.footer);const Om=fo&&fo.size>0?m.createElement("style",{key:"bf-responsive"},Array.from(fo.values()).join(`
92
- `)):null,Um=m.createElement("style",{key:"bf-transitions"},`#${we} * { transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease; }
91
+ `}function OS(e,t,n,i){return v.createElement("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",minHeight:"100%",backgroundColor:e.colors.background,gap:"16px"}},N("p",{style:{color:e.colors.text,fontSize:"1.125rem"}},"Scene not found"),v.createElement("div",{style:{display:"flex",gap:"12px",alignItems:"center"}},t>0&&v.createElement("button",{onClick:n,style:{padding:"0.5rem 1.5rem",borderRadius:"0.5rem",backgroundColor:e.colors.surfaceHover,color:e.colors.text,border:"none",cursor:"pointer",fontSize:"0.875rem",fontWeight:500,transition:e.effects.transition},onMouseOver:r=>r.target.style.backgroundColor=e.colors.border,onMouseOut:r=>r.target.style.backgroundColor=e.colors.surfaceHover},"← Go Back"),i&&v.createElement("button",{onClick:i,style:{display:"flex",alignItems:"center",gap:"6px",padding:"0.5rem 1.5rem",borderRadius:"0.5rem",backgroundColor:e.colors.primary,variant:"outline",color:e.colors.text,border:"none",cursor:"pointer",fontSize:"0.875rem",fontWeight:500,transition:"opacity 0.2s"},onMouseOver:r=>r.target.style.opacity="0.85",onMouseOut:r=>r.target.style.opacity="1"},v.createElement("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},N("polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2"})),"Generate Scene")))}function FS(e){return v.createElement("div",{key:"preview-modal",style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4,animation:"bf-fade-in 0.15s ease"}},v.createElement("div",{style:{backgroundColor:e.colors.background,borderRadius:"12px",padding:"24px",maxWidth:"360px",width:"90%",boxShadow:"0 20px 40px rgba(0, 0, 0, 0.4)",border:"1px solid rgba(255, 255, 255, 0.08)"}},N("h3",{style:{color:e.colors.text,fontSize:"16px",fontWeight:600,marginBottom:"12px"}},"Sample Modal"),N("p",{style:{color:e.colors.textSecondary,fontSize:"14px",marginBottom:"20px"}},"This is a preview of the modal component for styling."),v.createElement("div",{style:{display:"flex",gap:"12px",justifyContent:"flex-end"}},N("button",{style:{padding:"10px 20px",borderRadius:"8px",cursor:"pointer",fontSize:"14px",fontWeight:500,background:"rgba(255,255,255,0.08)",color:e.colors.text,border:`1px solid ${e.colors.borderSubtle}`}},"Cancel"),N("button",{style:{padding:"10px 20px",borderRadius:"8px",cursor:"pointer",fontSize:"14px",fontWeight:500,background:e.colors.primary,color:e.colors.text,border:"none"}},"Confirm"))))}function tf(e,t,n,i,r,o,l){var j,U,nt,ot,q,it,ct,K,Z,tt,st;if(!e)return null;const{definition:h,closing:u}=e,f=h.variant?(j=h.variants)==null?void 0:j[h.variant]:void 0,c={...h,...f,style:{...h.style,...f==null?void 0:f.style},components:(f==null?void 0:f.components)||h.components,actions:(f==null?void 0:f.actions)||h.actions},m=c.popover===!0,y=(U=c.style)==null?void 0:U.placement,x=y==="left"||y==="right"||y==="bottom"?y:"center",_=c.drawer===!0||x==="left"||x==="right",p=x==="bottom",E=u===!0,T=c.className||"",k=T?((nt=n.parseClassNameResponsive)==null?void 0:nt.call(n,T,`modal-${e.id}`))??n.parseClassName(T):{},A=m&&l&&l.top>window.innerHeight/2&&l.bottom+300>window.innerHeight,P=l?Math.min(Math.max(12,l.left),Math.max(12,window.innerWidth-372)):void 0,I=()=>{var J;E||(J=r||n.dismissModal)==null||J()},$=v.createElement("div",{key:`modal-overlay-${e.id||"base"}`,style:{position:"fixed",top:0,left:0,right:0,bottom:0,animation:E?"bf-fade-out 0.2s ease forwards":"bf-fade-in 0.15s ease",backdropFilter:m?void 0:"blur(4px)",WebkitBackdropFilter:m?void 0:"blur(4px)",display:"flex",alignItems:m?"flex-start":p?"flex-end":"center",justifyContent:m?"flex-end":_?x==="left"?"flex-start":"flex-end":"center",paddingTop:void 0,paddingRight:void 0,backgroundColor:m?"transparent":((ot=c.style)==null?void 0:ot.overlayColor)||"rgba(0,0,0,0.45)",pointerEvents:"auto",zIndex:o||1e4},onClick:J=>{J.target===J.currentTarget&&I()}},v.createElement("div",{className:T||void 0,style:{pointerEvents:m?"auto":void 0,...m?{position:"fixed",top:A||!l?A?void 0:"116px":`${l.bottom+8}px`,bottom:A?`${Math.max(12,window.innerHeight-l.top+8)}px`:void 0,left:P===void 0?void 0:`${P}px`,right:P===void 0?"24px":void 0}:{},backgroundColor:((q=c.style)==null?void 0:q.backgroundColor)||i||t.colors.background,borderRadius:_?"0px":((it=c.style)==null?void 0:it.borderRadius)||(p?"16px 16px 0 0":"12px"),padding:_?"0.5rem":p?"16px":"24px",height:_?"100%":"auto",maxHeight:p?"90vh":_?void 0:"85vh",maxWidth:_?"520px":p?n.isMobileView?"none":"640px":((ct=c.style)==null?void 0:ct.width)||{sm:"min(360px, 92vw)",md:"min(480px, 92vw)",lg:"min(720px, 92vw)",full:"90vw"}[c.size||"sm"]||"min(400px, 92vw)",width:(K=c.style)!=null&&K.width?"100%":_?"90vw":p?"100%":"90%",boxShadow:_?x==="left"?"4px 0 24px rgba(0, 0, 0, 0.4)":"-4px 0 24px rgba(0, 0, 0, 0.4)":p?"0 -8px 32px rgba(0, 0, 0, 0.45)":"0 20px 40px rgba(0, 0, 0, 0.4)",...m?{minWidth:"min(360px, 92vw)",marginRight:"0px",boxShadow:"0 12px 32px rgba(0, 0, 0, 0.45)"}:{},border:"none",borderLeft:_&&x==="right"?`1px solid ${((Z=c.style)==null?void 0:Z.borderColor)||"rgba(255, 255, 255, 0.08)"}`:"none",borderRight:_&&x==="left"?`1px solid ${((tt=c.style)==null?void 0:tt.borderColor)||"rgba(255, 255, 255, 0.08)"}`:"none",overflow:"auto",animation:_?E?x==="left"?"bf-slide-out-left 0.2s ease forwards":"bf-slide-out-right 0.2s ease forwards":x==="left"?"bf-slide-in-left 0.2s ease":"bf-slide-in-right 0.2s ease":p?E?"bf-slide-out-down 0.2s ease forwards":"bf-slide-in-up 0.25s ease":E?"bf-fade-out 0.2s ease forwards":void 0,...k}},p?v.createElement("div",{key:"bf-sheet-handle",style:{width:"40px",height:"4px",borderRadius:"2px",backgroundColor:"rgba(255, 255, 255, 0.2)",margin:"0 auto 12px",flexShrink:0}}):null,c.icon?v.createElement("div",{style:{textAlign:"center",marginBottom:"12px",display:"flex",justifyContent:"center"}},n.renderIcon(c.icon,32)):null,c.title?v.createElement("h3",{style:{color:t.colors.text,fontSize:c.icon?"18px":"16px",fontWeight:600,marginBottom:"12px",marginTop:"4px",paddingLeft:_?"1.5rem":"0px",paddingRight:_?"1.5rem":"0px",textAlign:c.icon?"center":"left"}},n.interpolateText(c.title)):null,...(c.components||[]).map((J,bt)=>fa(n,J,bt,"modal")),(((st=c.actions)==null?void 0:st.length)||0)>0?v.createElement("div",{style:{display:"flex",gap:"12px",justifyContent:"flex-end",marginTop:"20px"}},...(c.actions||[]).map((J,bt)=>{const ht=(Tt=>{const Rt=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(Tt);if(!Rt)return!1;const[Et,re,oe]=[parseInt(Rt[1],16),parseInt(Rt[2],16),parseInt(Rt[3],16)];return(Et*299+re*587+oe*114)/1e3>150})(t.colors.primary)?"#000000":"#ffffff",kt={primary:{background:t.colors.primary,color:ht,border:"none"},secondary:{background:"rgba(255, 255, 255, 0.08)",color:t.colors.text,border:`1px solid ${t.colors.borderSubtle}`},ghost:{background:"transparent",color:t.colors.text,border:`1px solid ${t.colors.borderSubtle}`},danger:{background:t.colors.danger,color:"#ffffff",border:"none"}},St=kt[J.variant||"primary"]||kt.primary;return v.createElement("button",{key:bt,onClick:()=>{if(e.legacyOnConfirm&&J.label==="Confirm"){I(),setTimeout(()=>{var Tt;return(Tt=e.legacyOnConfirm)==null?void 0:Tt.call(e)},250);return}J.onClick&&n.handleButtonClick(J.onClick,{onSuccess:J.onSuccess,onError:J.onError}),J.dismiss&&I()},style:{padding:"10px 20px",borderRadius:"8px",cursor:"pointer",fontSize:"14px",fontWeight:500,...St}},J.label)})):null));return m&&typeof document<"u"?_c.createPortal($,document.body):$}const Op=()=>{try{if(typeof window<"u")return window.localStorage.getItem("backflow_dev_diagnostics")==="1"}catch{}return!1},oa=(...e)=>{Op()&&console.log(...e)},$l=(...e)=>{Op()&&console.warn(...e)};let Fp=null;window.addEventListener("message",e=>{var t,n,i;(((t=e.data)==null?void 0:t.type)==="auth"||((n=e.data)==null?void 0:n.type)==="auth-token")&&((i=e.data)!=null&&i.token)&&(Fp=e.data.token,localStorage.setItem("token",e.data.token),e.data.refreshToken&&localStorage.setItem("backflow_refresh_token",e.data.refreshToken),e.data.userId&&localStorage.setItem("backflow_refresh_user_id",e.data.userId))});function Yr(e){try{const t=JSON.parse(atob(e.split(".")[1]));return typeof t.exp!="number"||t.exp*1e3<=Date.now()}catch{return!0}}function WS({workflow:e,sdk:t,iconResolver:n,authToken:i,nativeAction:r,onRouteExecute:o,onJobProgress:l,appName:h,appIcon:u,selectedComponentKey:f,selectedComponentClass:c,styleOverrides:m,interactionDisabled:y,theme:x,imageReplacements:_,currentSceneId:p,onSceneChange:E,onGenerateScene:T,enableRouting:k,routingMode:A,previewElement:P,tenantId:I,appId:$,renderPhaserGame:j,renderMode:U,apiUrl:nt,workflowBaseUrl:ot,initialScene:q,previewMode:it,remoteSessionId:ct,devDiagnostics:K}){var Mi,Oo,In,ws,Vr,er,Ss,nr,Cs,ki,Ms,ir,jr;const Z=(()=>{const w=Fp||localStorage.getItem("token");return!!w&&!Yr(w)})(),[tt,st]=v.useState(!Z),[J,bt]=v.useState(null),et=v.useMemo(()=>Array.isArray(e==null?void 0:e.steps)?e.steps:[],[e]),ht=v.useMemo(()=>{const w=et;return e&&!Array.isArray(e.steps)&&($l("[WorkflowRenderer] NON-ARRAY steps:",typeof e.steps,JSON.stringify(e.steps).slice(0,500)),$l("[WorkflowRenderer] Workflow keys:",Object.keys(e))),tt!==!0?w:w.filter(M=>{var S,B;return!(M.requiresAuth===!0||((S=M.config)==null?void 0:S.requireAuth)===!0||((B=M.config)==null?void 0:B.requiresAuth)===!0)})},[e,tt,et]),kt=v.useCallback(w=>{var S;const M=et.find(B=>B.id===w);return((S=M==null?void 0:M.config)==null?void 0:S.requireAuth)===!0||(M==null?void 0:M.requiresAuth)===!0},[et]),St=e&&!((Mi=e.config)!=null&&Mi.colorMode)?dg(e):void 0,Tt=ff(St?{...(e==null?void 0:e.config)||{},colorMode:St}:e==null?void 0:e.config,void 0,x),Rt=w=>wh(w,{primary:Jt.colors.primary,accent:Jt.colors.accent,colorMode:Jt.colorMode},Jt.colorMode==="light"),Et=U||"legacy",re=A||(k?"hash":"memory"),oe=re!=="memory",[Ot,Re]=v.useState(Z),[Qe,ye]=v.useState(!1),[hi,ui]=v.useState(!1),{sceneToRoute:Ee,routeToScene:Ft}=v.useMemo(()=>$p(ht),[ht]),qt=v.useMemo(()=>{var M,S;if(q&&ht.some(B=>B.id===q))return q;const w=ht.filter(B=>B.type==="render_scene");return((M=w.find(B=>B.route==="/"))==null?void 0:M.id)||((S=w[0])==null?void 0:S.id)||""},[ht,q]),fe=v.useMemo(()=>{if(oe){const w=re==="hash"?bc(Ft):Qd(Ft);if(w)return w}return qt},[qt,oe,re,Ft]),[Kt,Lt]=v.useState([]),[jt,$t]=v.useState(fe),Se=v.useRef(null),_n=Qm(Se),di=v.useRef(!1);v.useRef(null);const Ne=v.useRef(!1),Ce=v.useRef(!1),fi=v.useRef(0),$e=v.useRef(null);v.useEffect(()=>(Ne.current=!1,df(),()=>{Ne.current=!0}),[]),v.useEffect(()=>{i&&localStorage.setItem("token",i)},[i]);const vt=p??jt;v.useEffect(()=>{var F;const w=ht.find(W=>W.id===vt),M=!!((F=e==null?void 0:e.config)!=null&&F.remoteControl)&&!!(w!=null&&w.remoteScene);if(nf(M),!M||!ct){Fl();return}const S=nt||(t==null?void 0:t.endpoint),B=S&&/^https?:\/\//.test(S)?S:window.location.origin,R=new URL("/ws",B);R.protocol=R.protocol==="https:"?"wss:":"ws:";const z=R.toString(),O=`agent:${I||"default"}:${ct}`;return uf(z,O,i||localStorage.getItem("token")||void 0),()=>Fl()},[(Oo=e==null?void 0:e.config)==null?void 0:Oo.remoteControl,ht,vt,ct,I,nt,t,i]);const Ze=v.useCallback(w=>{$t(w),E==null||E(w)},[E]);v.useEffect(()=>{var S;const w=ht.find(B=>B.id===vt),M=((S=w==null?void 0:w.config)==null?void 0:S.requireAuth)===!0||(w==null?void 0:w.requiresAuth)===!0;vt&&!M&&ye(!1)},[vt,ht]);const ve=(e==null?void 0:e.modals)||{};v.useEffect(()=>{if(!Ot)return;const w=Jt.startupModal;!w||!ve[w]||localStorage.getItem(`backflow_startup_modal_${w}`)||Pe({id:w,definition:ve[w]})},[Ot]);const Ni=v.useRef(typeof window>"u"?null:new URLSearchParams(window.location.search).get("customer_session_token"));v.useEffect(()=>{if(!Ot||!Ni.current||!ve["payment-success"])return;window.history.replaceState({},"",window.location.pathname);const M=setTimeout(()=>{ve["payment-success"]&&Pe({id:"payment-success",definition:ve["payment-success"]})},400);return()=>clearTimeout(M)},[Ot,ve["payment-success"]]),v.useEffect(()=>{tt===!0&&(!vt||ht.some(w=>w.id===vt)||qt&&Ze(qt))},[tt,ht,vt,qt]),v.useEffect(()=>{if(oe){if(di.current){di.current=!1;return}re==="hash"?ma(vt,Ee,!1):Dl(vt,Ee,!1)}},[vt,oe,re,Ee]),v.useEffect(()=>{oe&&(re==="hash"?ma(vt,Ee,!0):Dl(vt,Ee,!0))},[]);const Jn=v.useRef(!0);v.useEffect(()=>{const w=setTimeout(()=>{Jn.current=!1},1500);return()=>clearTimeout(w)},[]),v.useEffect(()=>{if(!oe)return;const w=M=>{var B;if(Jn.current)return;const S=((B=M.state)==null?void 0:B.sceneId)||(re==="hash"?bc(Ft):Qd(Ft));S&&S!==vt&&(di.current=!0,Ze(S),Lt(R=>R.length>0&&R[R.length-1]===S?R.slice(0,-1):R))};return window.addEventListener("popstate",w),()=>window.removeEventListener("popstate",w)},[oe,re,Ft,vt,Ze]),v.useEffect(()=>{var M;const w=((M=ht.find(S=>S.type==="render_scene"))==null?void 0:M.id)||"";if(w&&w!==vt){if($t(w),Lt([]),E==null||E(w),!oe)return;re==="hash"?ma(w,Ee,!0):Dl(w,Ee,!0)}},[e]),v.useEffect(()=>{p&&p!==jt&&$t(p)},[p]);const mi=v.useCallback(()=>{if(oe){window.history.back();return}if(Kt.length>0){const w=Kt[Kt.length-1];Lt(M=>M.slice(0,-1)),Ze(w)}},[Kt,oe]),[ee,Wt]=v.useState({}),pi=v.useRef(ee);v.useEffect(()=>{pi.current=ee},[ee]);const[gi,Tn]=v.useState({}),yi=v.useRef(new Set),[Ii,zi]=v.useState({}),[Bn,Di]=v.useState({}),[$i,Bi]=v.useState({}),[fs,vi]=v.useState({}),[Ue,bi]=v.useState({}),wn=v.useRef(new Map),Qn=v.useRef(new Map),qe=v.useRef(new Set),[gt,Oi]=v.useState(!1),[ce,Pe]=v.useState(null),[Fi,Kn]=v.useState(null),Wi=v.useRef(null);v.useEffect(()=>{var M;if(!((M=ce==null?void 0:ce.definition)!=null&&M.popover))return;const w=()=>{const S=Wi.current;S&&Kn(S.getBoundingClientRect())};return window.addEventListener("scroll",w,!0),window.addEventListener("resize",w),w(),()=>{window.removeEventListener("scroll",w,!0),window.removeEventListener("resize",w)}},[ce==null?void 0:ce.id,(In=ce==null?void 0:ce.definition)==null?void 0:In.popover]);const un=v.useCallback(()=>{Pe(w=>w?{...w,closing:!0}:null),setTimeout(()=>Pe(null),250)},[]),[Ke,xi]=v.useState(null),Vs=v.useCallback(()=>{xi(w=>w?{...w,closing:!0}:null),setTimeout(()=>xi(null),250)},[]),Vi=_n>0&&_n<vo.md;v.useEffect(()=>{e&&typeof e=="object"&&(e.auth={signedIn:Ot})},[e,Ot]),v.useEffect(()=>{const w=e;if(!(w!=null&&w.config))return;if(u){w.config.logo=u,Wt(S=>S&&{...S});return}if(!ot)return;let M=!1;return(async()=>{for(const S of["svg","png","jpg","jpeg"]){const B=`${ot}logo.${S}`;try{if((await fetch(B,{method:"HEAD"})).ok&&!M){w.config.logo=B,Wt(z=>z&&{...z});return}}catch{}}})(),()=>{M=!0}},[e,ot,u]);const[Sn,On]=v.useState("login"),[me,dn]=v.useState(""),[pe,Pn]=v.useState(""),[Fn,ji]=v.useState(""),[Hi,Wn]=v.useState({}),[fn,Vn]=v.useState(""),[rn,be]=v.useState(null),[Ct,Qt]=v.useState(!1),[ae,jn]=v.useState({}),dt=w=>w?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(w)?null:"Invalid email address":null,ie=w=>w?w.length>=6?null:"Password must be at least 6 characters":null,xt=(w,M)=>M?M===w?null:"Passwords do not match":null,Bt=(w,M)=>jn(S=>({...S,[w]:M||""})),Zi=w=>{var M,S;return w?typeof w=="string"?w:Array.isArray(w)?((M=w[0])==null?void 0:M.message)||"Validation failed":typeof w.error=="string"?w.error:(S=w.error)!=null&&S.message?w.error.message:w.message||"An error occurred":"An error occurred"},_i=(ee==null?void 0:ee._colorMode)||Tt.colorMode,mn=_i==="dark"?ho:uo,Jt=_i!==Tt.colorMode?{...Tt,colorMode:_i,colors:{...mn,...Tt.colors&&_i==="dark"?Tt.colors:{}}}:Tt;v.useEffect(()=>{typeof document>"u"||document.documentElement.setAttribute("data-theme",Jt.colorMode==="dark"?"dark":"light")},[Jt.colorMode]);const ms=v.useCallback(w=>{try{localStorage.setItem("bf_theme",w)}catch{}Wt(M=>({...M,_colorMode:w}))},[]);v.useEffect(()=>{if(typeof localStorage>"u")return;const w=localStorage.getItem("bf_theme");(w==="dark"||w==="light")&&Wt(M=>({...M,_colorMode:w}))},[]),v.useEffect(()=>{const w=localStorage.getItem("token"),M=!!w&&!Yr(w);M?(Ce.current=!1,st(!1)):st(!0),Re(M);const S=()=>{const z=localStorage.getItem("token"),O=!!z&&!Yr(z);O?(Ce.current=!1,st(!1)):st(!0),Re(O)};window.addEventListener("storage",S);const B=z=>{var O,F,W;if((((O=z.data)==null?void 0:O.type)==="auth"||((F=z.data)==null?void 0:F.type)==="auth-token")&&((W=z.data)!=null&&W.token)){if(localStorage.setItem("token",z.data.token),z.data.refreshToken&&localStorage.setItem("backflow_refresh_token",z.data.refreshToken),z.data.userId&&localStorage.setItem("backflow_refresh_user_id",z.data.userId),Yr(z.data.token)){Ce.current=!0,Re(!1);return}if(!Ot&&(Qe||Ce.current||!!$e.current)){window.location.reload();return}Re(!0),ye(!1),st(!1),Ce.current=!1}};window.addEventListener("message",B);const R=()=>{var z;if(!Ce.current){const O=ht.find(W=>W.id===vt);if(!(((z=O==null?void 0:O.config)==null?void 0:z.requireAuth)===!0||(O==null?void 0:O.requiresAuth)===!0))return;Ce.current=!0,Re(!1),ye(!0)}};return window.addEventListener("auth:required",R),()=>{window.removeEventListener("storage",S),window.removeEventListener("message",B),window.removeEventListener("auth:required",R)}},[]);const wi=async()=>{var S;const w=localStorage.getItem("backflow_refresh_token"),M=localStorage.getItem("backflow_refresh_user_id");if(!w||!M)return!1;try{const R=await(await fetch(`${window.location.origin}/api/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:w,userId:M})})).json();if(R.success&&((S=R.data)!=null&&S.token))return R.data.refreshToken&&localStorage.setItem("backflow_refresh_token",R.data.refreshToken),localStorage.setItem("token",R.data.token),!0}catch{}return localStorage.removeItem("backflow_refresh_token"),localStorage.removeItem("backflow_refresh_user_id"),!1},xe=async w=>{var M;if(w.status===401&&!Qe){if(await wi())return!1;oa("[bf] 401 intercepted, showAuth:",Qe,"authInterceptedRef:",Ce.current);const B=localStorage.getItem("token"),R=!!B&&!Yr(B);if(!Ce.current&&!R){Ce.current=!0,Re(!1);const z=ht.find(F=>F.id===vt);(((M=z==null?void 0:z.config)==null?void 0:M.requireAuth)===!0||(z==null?void 0:z.requiresAuth)===!0)&&(ye(!0),vt&&($e.current=vt))}else R&&oa("[bf] 401 with valid stored token — ignoring");return!0}return!1},Si=vt&&ht.some(w=>w.id===vt)?vt:(ws=ht[0])==null?void 0:ws.id,tn=ht.find(w=>w.id===Si),se=(tn==null?void 0:tn.type)==="render_scene"?tn.config:null;v.useEffect(()=>{if(!se)return;const w=I||"default",M={TENANT_ID:w,tenantId:w,role:"user"};Wt(S=>{const B={};for(const R of Object.keys(S))R.startsWith("_")&&(B[R]=S[R]);return{...M,...se.sceneData||{},...B}})},[vt,se]),v.useEffect(()=>{const w=Jt.persistedKeys;if(!w||w.length===0)return;const M={};for(const S of w){const B=localStorage.getItem(`bf_persist_${S}`);B&&(M[S]=B)}Object.keys(M).length>0&&Wt(S=>({...S,...M}))},[vt]),v.useEffect(()=>{const w=Jt.persistedKeys;if(!(!w||w.length===0))for(const M of w){const S=ee[M];S&&localStorage.setItem(`bf_persist_${M}`,String(S))}});const js=w=>{const M=w.match(/^(GET|POST|PATCH|DELETE|PUT)\s+(.+)/);return{method:M?M[1]:"POST",path:M?M[2]:w}},Ui=w=>{const M={...w};return delete M.TENANT_ID,delete M.tenantId,delete M.role,M},Hn=v.useCallback(async w=>{var B,R,z;if(!w.action)return;const M=String(w.action),S=pi.current;try{if(M.startsWith("execute_workflow:")){if(!Ot)return;const{method:O,path:F}=js(M.replace("execute_workflow:","")),W=F.replace(/:(\w+)/g,(mt,G)=>{const ft=S[G];return ft===void 0?mt:String(ft)}).replace(/\{\{(\w+)\}\}/g,(mt,G)=>{const ft=S[G];return ft===void 0?mt:String(ft)}),X=Ln(),lt=O!=="GET"&&O!=="DELETE";O!=="GET"&&le(O,W,S,!0);const at=await fetch(new URL(W,X).toString(),{method:O,headers:{"Content-Type":"application/json",Authorization:`Bearer ${i||localStorage.getItem("token")||""}`},...lt?{body:JSON.stringify(Ui(S))}:{}});if(Ne.current||await xe(at)||Ne.current)return;if(!at.ok)throw Ie(W),new Error(`Route failed: ${at.statusText}`);const Q=await at.json();if(Ne.current)return;if(Q&&typeof Q=="object"&&!Array.isArray(Q)&&Wt(mt=>({...mt,feedback:Q})),((B=w.onSuccess)==null?void 0:B.type)==="toast"&&w.onSuccess.value)he(w.onSuccess.value,"success");else if(((R=w.onSuccess)==null?void 0:R.type)==="navigate"&&w.onSuccess.value){const mt=w.onSuccess.value;if(kt(mt)&&!Ot){$e.current=mt,ye(!0);return}Lt(ft=>[...ft,vt]),Ze(mt)}Q!=null&&Q.data&&Wt(mt=>({...mt,...Q.data})),Q!=null&&Q.user&&typeof Q.user=="object"&&Wt(mt=>({...mt,user:Q.user})),_e.current[W.replace(/^\//,"")]={response:Q},Wt(mt=>({...mt}))}else if(M.startsWith("navigate:")){const O=M.replace("navigate:","");if(kt(O)&&!Ot){$e.current=O,ye(!0);return}Lt(W=>[...W,vt]),Ze(O)}else if(M.startsWith("go_to_step:")){const O=M.replace("go_to_step:","").split("?")[0].trim();if(kt(O)&&!Ot){$e.current=O,ye(!0);return}Lt(W=>[...W,vt]),Ze(O)}else if(M.startsWith("show_toast:")){const O=M.replace("show_toast:","");O&&he(O,"success")}else if(M.startsWith("show_modal:")){const O=M.replace("show_modal:","");if(ve[O]){const F=ve[O],W=F.clearFormKeys;Wt(X=>{const lt={...X};let at=Array.isArray(W)&&W.length>0;if(at)for(const Q of W)delete lt[Q];for(const Q of Object.keys(lt))Q.startsWith("__acc_")&&(delete lt[Q],at=!0);return at?lt:X}),F.preload&&await Yi(String(F.preload)),Pe({id:O,definition:F})}else{const F=O.split("|");Pe({id:"__legacy",definition:{title:F[0]||"Notice",components:F[1]?[{type:"text",text:F[1],color:Jt.colorMode==="light"?"rgba(0,0,0,0.65)":"rgba(255,255,255,0.7)",fontSize:14}]:[],actions:[{label:"OK",variant:"primary",dismiss:!0}]}})}}else if(M.startsWith("toast:")){const O=M.replace("toast:","");he(O,"success")}}catch(O){if(O instanceof pn&&Zs(O,w==null?void 0:w.onError))return;(z=w.onError)!=null&&z.message&&he(w.onError.message,"error")}},[vt,ht,Ot]),ps=v.useRef(null);v.useEffect(()=>{const w=se==null?void 0:se.events,M=Array.isArray(w==null?void 0:w.onLoad)?w.onLoad:w!=null&&w.onLoad?[w.onLoad]:[];M.length!==0&&(ps.current!==null||vt)&&M.forEach(S=>Hn(S))},[vt,se==null?void 0:se.events,Hn]),v.useEffect(()=>{var M,S;const w=ps.current;if(ps.current=vt,w&&w!==vt){const B=ht.find(z=>z.id===w),R=(B==null?void 0:B.type)==="render_scene"?B.config:null;(S=(M=R==null?void 0:R.events)==null?void 0:M.onLeave)!=null&&S.action&&Hn(R.events.onLeave)}},[vt,ht,Hn]),v.useEffect(()=>{const w=se==null?void 0:se.events;if(!(w!=null&&w.onVisibilityChange))return;const M=()=>{var S,B,R,z;document.hidden?(B=(S=w.onVisibilityChange)==null?void 0:S.onHidden)!=null&&B.action&&Hn(w.onVisibilityChange.onHidden):(z=(R=w.onVisibilityChange)==null?void 0:R.onVisible)!=null&&z.action&&Hn(w.onVisibilityChange.onVisible)};return document.addEventListener("visibilitychange",M),()=>document.removeEventListener("visibilitychange",M)},[vt,se==null?void 0:se.events,Hn]);const Hs=v.useCallback(async(w,M)=>{Bi(S=>({...S,[w]:!0}));try{await M()}finally{Bi(S=>({...S,[w]:!1}))}},[]),ti=v.useRef({}),En=v.useRef(null),qi=v.useRef([]),Gi=v.useRef({}),Ve=v.useCallback(async(w,M,S=0,B=10,R,z,O,F=!1)=>{var X;if(!w||Ce.current||!Ot)return;ti.current[M]=w;const W=w.match(/^\{\{\s*\[([\w/.-]+)\](?:\.([\w.]+))?\s*\}\}$/);if(W){const lt=Zn(`${W[1]}${W[2]?"."+W[2]:""}`);if(Array.isArray(lt))return Tn(at=>({...at,[M]:lt})),_e.current[M]=lt,_e.current[w]=lt,bi(at=>({...at,[M]:{page:S,limit:B,total:lt.length,hasMore:(S+1)*B<lt.length}})),lt}yi.current.has(M)||Di(lt=>({...lt,[M]:!0}));try{let lt=[],at=0,Q;const mt=pi.current;if(co(w)&&t){const G=Ci(w,{limit:B,page:S}),ft=R?Nr(G,R,z):G,Pt=eo(ft),Y=await pa(t,Pt,mt);Q=Y,lt=(Y==null?void 0:Y.emails)||(Y==null?void 0:Y.items)||(Y==null?void 0:Y.data)||(Y==null?void 0:Y.history)||(Array.isArray(Y)?Y:[]),at=((X=Y==null?void 0:Y.pagination)==null?void 0:X.total)??(Y==null?void 0:Y.count)??lt.length}else if(!co(w)){const G=t==null?void 0:t.endpoint,ft=nt||(G&&/^https?:\/\//.test(G)?G:window.location.origin);let Pt=w;!nt&&G&&!/^https?:\/\//.test(G)&&typeof G=="string"&&(Pt=`${G.replace(/\/+$/,"")}${w.startsWith("/")?w:`/${w}`}`),oa("[fetchListData] apiUrl=%s baseUrl=%s dataSource=%s origin=%s",nt,ft,w,window.location.origin);const Y=new URL(Pt,ft);Y.searchParams.set("limit",String(B)),Y.searchParams.set("offset",String(S*B)),R&&(Y.searchParams.set("sort",R),Y.searchParams.set("dir",z||"asc"));const wt=await fetch(Y.toString(),{headers:{Authorization:`Bearer ${i||localStorage.getItem("token")||""}`}});if(await xe(wt)||Ne.current)return;let _t=null;try{_t=await wt.json()}catch{}if(!wt.ok){const Vt=typeof(_t==null?void 0:_t.message)=="string"&&_t.message||typeof(_t==null?void 0:_t.error)=="string"&&_t.error||`Request failed: ${wt.statusText}`;throw new pn([Vt],_t||void 0)}if(Q=_t,Ne.current)return;lt=Array.isArray(_t)?_t:Array.isArray(_t.data)?_t.data:Array.isArray(_t.items)?_t.items:[],at=_t.count??_t.total??lt.length}if(Tn(G=>{if(F&&Array.isArray(G[M])){const ft=new Set(G[M].map(Y=>Y==null?void 0:Y.id)),Pt=[...G[M],...lt.filter(Y=>!ft.has(Y==null?void 0:Y.id))];return{...G,[M]:Pt}}return{...G,[M]:lt}}),yi.current.add(M),_e.current[M]=lt,w&&(_e.current[w]=lt),O&&(_e.current[O]={items:lt,response:Q},w)){const G=Gi.current[O];G&&G!==w&&$l(`[renderer] duplicate list key "${O}" used for both ${G} and ${w}`),Gi.current[O]=w}{const G=String(w||"").replace(/^\//,"").split("?")[0];G&&(_e.current[G]={response:Q})}return bi(G=>({...G,[M]:{page:S,limit:B,total:at,hasMore:(S+1)*B<at}})),lt}catch(lt){if(lt instanceof pn&&Zs(lt))return;Tn(at=>{const Q=at[M];return Array.isArray(Q)&&Q.length>0?at:{...at,[M]:[]}})}finally{Di(lt=>({...lt,[M]:!1}))}},[t,Ot]),Ln=()=>{const w=nt||(t==null?void 0:t.endpoint);return w&&/^https?:\/\//.test(w)?w:w!=null&&w.startsWith("/")?`${window.location.origin}${w}`:window.location.origin};v.useEffect(()=>{var R;if(!Ot)return;const w=i||localStorage.getItem("token");if(!w){st(!0);return}const M=((e==null?void 0:e.steps)||[]).find(z=>z.id===vt);if(!(((R=M==null?void 0:M.config)==null?void 0:R.requireAuth)===!0||(M==null?void 0:M.requiresAuth)===!0||Qe))return;let B=!1;return(async()=>{var z;try{const O=await fetch(`${Ln()}/admin/users/me`,{headers:{Authorization:`Bearer ${w}`}});if(B)return;if(O.ok){const F=await O.json().catch(()=>null);st(!1),bt(typeof((z=F==null?void 0:F.user)==null?void 0:z.emailVerified)=="boolean"?F.user.emailVerified:null)}else vt&&($e.current=vt),st(!0),Re(!1),bt(null)}catch{B||(vt&&($e.current=vt),st(!0))}})(),()=>{B=!0}},[Ot,vt,e==null?void 0:e.steps]);const zt=v.useCallback((w,M,S)=>{!w||M.length===0||Tn(B=>{const R={...B};for(const[z,O]of Object.entries(ti.current)){if(O!==w||!B[z])continue;const F=B[z];S==="remove"&&(R[z]=F.filter(W=>!M.includes(W.id)))}return R})},[]),Ie=v.useCallback((w,M)=>{var R,z;const S=new Map;for(const[O,F]of Object.entries(Gi.current))S.set(F,O);const B=new Map;for(const[O,F]of Object.entries(ti.current))B.set(O,{ds:F,dataKey:S.get(F)});for(const[O,F]of Object.entries(Gi.current))Object.values(ti.current).includes(F)||B.set(O,{ds:F,dataKey:O});if(B.size!==0)for(const[O,{ds:F,dataKey:W}]of B){if(M==="view"){Ve(F,O,0,((R=Ue[O])==null?void 0:R.limit)||10,void 0,void 0,W);continue}F&&w.startsWith(F)&&Ve(F,O,0,((z=Ue[O])==null?void 0:z.limit)||10,void 0,void 0,W)}},[Ve,Ue]),le=v.useCallback((w,M,S,B)=>{const R=String(w||"").toUpperCase();if(R==="GET"||B===!1)return;const z=B==="remove"||B==="merge"||B==="add"||B==="refresh"?B:R==="DELETE"?"remove":R==="PUT"||R==="PATCH"?"merge":R==="POST"?"add":null;if(!z||z==="refresh")return;const O=()=>{const W=String(M).match(/\/([^/]+)\/?$/);return W?decodeURIComponent(W[1]):void 0},F=[];for(const[W,X]of Object.entries(ti.current))X&&M.startsWith(X)&&F.push({key:W,ds:X});F.length!==0&&Tn(W=>{const X={...W};for(const{key:lt,ds:at}of F){const Q=W[lt]||[];if(z==="remove"){const mt=(S==null?void 0:S.id)||O();X[lt]=Q.filter(G=>G.id!==mt)}else if(z==="merge"){const mt=(S==null?void 0:S.id)||O();X[lt]=Q.map(G=>G.id===mt?{...G,...S}:G)}else{const mt={...S||{},id:(S==null?void 0:S.id)||`temp_${Date.now()}`};z==="add"&&mt.status===void 0&&(mt.status="queued"),X[lt]=[mt,...Q]}}return X})},[]),gs=v.useCallback((w,M,S,B)=>{var W;const R=Ln();let z=!1;const O=X=>{z||(z=!0,X())},F=t==null?void 0:t.queues;if(w==="sse"&&(F!=null&&F.subscribe))try{const X=B.sseUrl||`${R}/queues/bulk-operations/jobs/${M}/subscribe?token=${encodeURIComponent(S)}`,lt=((t==null?void 0:t.endpoint)||R).replace(/\/$/,""),at=X.startsWith(lt)?X.slice(lt.length):X;F.subscribe(at,{onComplete:Q=>O(()=>B.onComplete(Q)),onFailed:Q=>O(()=>B.onFailed({message:Q||"Subscription failed",kind:"transport"})),onError:()=>O(()=>B.onFailed({message:"Stream error",kind:"transport"})),onConnected:()=>{},onProgress:Q=>{var mt;return(mt=B.onProgress)==null?void 0:mt.call(B,Q)}}),setTimeout(()=>O(()=>B.onFailed({message:"Timed out",kind:"transport"})),3e4);return}catch{}if(w==="ws"&&((W=t==null?void 0:t.client)!=null&&W.createWebSocket))try{const X=t.client.createWebSocket(`job:${M}`);X.onmessage=lt=>{try{const at=JSON.parse(lt.data);(at==null?void 0:at.type)==="completed"?O(()=>B.onComplete(at.result)):(at==null?void 0:at.type)==="failed"&&O(()=>B.onFailed({message:at.error||"Job failed",kind:"job"}))}catch{}},X.onerror=()=>O(()=>B.onFailed({message:"Connection error",kind:"transport"})),setTimeout(()=>O(()=>B.onFailed({message:"Timed out",kind:"transport"})),3e4);return}catch{}if(w==="poll"&&(F!=null&&F.getJob)){const X=window.setInterval(async()=>{var lt;try{const at=await F.getJob("bulk-operations",M),Q=(at==null?void 0:at.status)||((lt=at==null?void 0:at.job)==null?void 0:lt.status),mt=(at==null?void 0:at.result)||(at==null?void 0:at.data);Q==="failed"||mt!=null&&mt.final?(window.clearInterval(X),O(()=>Q==="failed"?B.onFailed({message:(mt==null?void 0:mt.error)||"Job failed",kind:"job"}):B.onComplete(mt))):Q==="completed"&&(window.clearInterval(X),O(()=>B.onComplete(mt)))}catch{}},600);setTimeout(()=>{window.clearInterval(X),O(()=>B.onFailed({message:"Timed out",kind:"transport"}))},3e4);return}O(()=>B.onFailed({message:"Feedback transport unavailable",kind:"transport"}))},[]),Ar=v.useCallback(async(w,M,S)=>{var lt,at;const B=t==null?void 0:t.files,R=encodeURIComponent(i||localStorage.getItem("token")||"");if(B!=null&&B.upload){const Q=await B.upload(w,M||{},S),mt=(Q==null?void 0:Q.url)||(Q==null?void 0:Q.path)||"";return mt?(Q==null?void 0:Q.visibility)==="public"?mt:`${Ln()}${mt}?token=${R}`:""}const z=new FormData;z.append("file",w),M!=null&&M.entityType&&z.append("entityType",M.entityType),M!=null&&M.entityId&&z.append("entityId",M.entityId),M!=null&&M.visibility&&z.append("visibility",M.visibility);const O=await fetch(`${Ln()}/files/upload`,{method:"POST",headers:{Authorization:`Bearer ${i||localStorage.getItem("token")||""}`},body:z});if(!O.ok)throw new Error("Upload failed");const F=await O.json(),W=((lt=F==null?void 0:F.asset)==null?void 0:lt.url)||(F==null?void 0:F.url)||(F==null?void 0:F.path)||(F==null?void 0:F.id)||"";return W?((at=F==null?void 0:F.asset)==null?void 0:at.visibility)==="public"?W:`${Ln()}${W}?token=${R}`:""},[]),Rr=v.useCallback(async(w,M,S,B)=>{var O;if(!(w!=null&&w.endpoint)||B.length===0)return;const R=w.endpoint,z=w.optimistic??!0;try{const F=await fetch(Ln()+R,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i||localStorage.getItem("token")||""}`},body:JSON.stringify({ids:B})});let W={};try{W=await F.json()}catch{}if(!F.ok){he(((O=W==null?void 0:W.error)==null?void 0:O.message)||"Request failed","error");return}z!==!1&&(z==="remove"||z==="refresh"?z:W.softUpdate||(w.action==="delete"?"remove":"refresh"))==="remove"&&zt(M,B,"remove"),Wt(lt=>({...lt,_selIds:[],_selectMode:!1}));const X=(lt,at,Q)=>{var mt;if(lt)he(Q||"Bulk operation failed","error");else{const G=at||{},ft=G.total??B.length,Pt=G.successful??ft;he(Pt>=ft?`${Pt} ${w.action}d`:`${Pt} of ${ft} ${w.action}d`,"success")}Ve(M,S,0,((mt=Ue[S])==null?void 0:mt.limit)||10)};W.jobId&&W.token&&w.feedback?gs(w.feedback,W.jobId,W.token,{onComplete:lt=>X(!1,lt),onFailed:lt=>{var at;if(lt.kind==="transport"){Ve(M,S,0,((at=Ue[S])==null?void 0:at.limit)||10);return}X(!0,null,lt.message)}}):X(!1,W)}catch{he("Request failed","error")}},[zt,gs,Ve,Ue]),Nr=(w,M,S)=>{const B=eo(w),R=B.indexOf("(");if(R===-1)return w;const z=B.slice(R+1,-1).trim(),O=`sort: "${M}", dir: ${S==="desc"?'"desc"':'"asc"'}`;if(!z)return w.replace(/\(\)$/,`({${O}})`);const F=z.lastIndexOf(",");if(F===-1)return w.replace(/\(([^)]*)\)$/,`(${z}, {${O}})`);const W=z.slice(F+1).trim();return W.startsWith("{")?w.replace(/\(([^)]*)\)$/,`(${z.slice(0,F)}, {${W.slice(1,-1)}, ${O}})`):w.replace(/\(([^)]*)\)$/,`(${z}, {${O}})`)},Ci=(w,M)=>{const S=eo(w),B=S.indexOf("(");if(B===-1)return w;const R=S.slice(B+1,-1).trim(),z=`limit: ${M.limit}, page: ${M.page}`;if(!R)return w.replace(/\(\)$/,`({${z}})`);const O=R.lastIndexOf(",");if(O===-1)return w.replace(/\(([^)]*)\)$/,`(${R}, {${z}})`);const F=R.slice(O+1).trim();return F.startsWith("{")?w.replace(/\(([^)]*)\)$/,`(${R.slice(0,O)}, {${F.slice(1,-1)}, ${z}})`):w.replace(/\(([^)]*)\)$/,`(${R}, {${z}})`)};v.useEffect(()=>()=>{Ne.current=!0},[]),Jt.colors.background;const Be=v.useMemo(()=>`bf-preview-${Math.random().toString(36).slice(2,9)}`,[]),ys=w=>w.replace(/:(\w+)/g,(M,S)=>{const B=ee[S];return B===void 0?M:String(B)}),Oe=w=>{try{const M=JSON.parse(w);if(Array.isArray(M)&&M.length>0)return M.map(S=>{var B;return S.message||`${((B=S.path)==null?void 0:B.join("."))||"field"} is invalid`})}catch{}return null};class pn extends Error{constructor(S,B){super(S.join(", "));il(this,"errors");il(this,"body");this.errors=S,this.body=B}}const Yi=async(w,M)=>{var mt,G,ft,Pt;if(Ce.current||!Ot)return;const{method:S,path:B}=js(w),R=ys(B),z=S!=="GET"&&S!=="DELETE",O=Ln();S!=="GET"&&le(S,R,ee,(M==null?void 0:M.optimistic)??!0);let F;if(M!=null&&M.payload&&typeof M.payload=="object"){F={};for(const[Y,wt]of Object.entries(M.payload))F[Y]=typeof wt=="string"&&wt.includes("{{")?Dr(wt):wt}else F=ee;F=Ui(F);const W=await fetch(new URL(R,O).toString(),{method:S,headers:{"Content-Type":"application/json",Authorization:`Bearer ${i||localStorage.getItem("token")||""}`},...z?{body:JSON.stringify(F)}:{}});if(await xe(W)||Ne.current)return;let X;try{X=await W.json()}catch{if(Ne.current)return;if(!W.ok)throw new pn([`Request failed: ${W.statusText}`]);return}if(!W.ok||X.success===!1){Ie(R,M==null?void 0:M.refetchScope);let Y=["Something went wrong"];throw(mt=X.error)!=null&&mt.message?Y=Oe(X.error.message)||[X.error.message]:X.message&&(Y=[X.message]),new pn(Y,X)}X.token&&localStorage.setItem("token",X.token),X&&typeof X=="object"&&!Array.isArray(X)&&Wt(Y=>({...Y,feedback:X})),X.data&&(M==null?void 0:M.mergeResponse)!==!1&&Wt(Y=>({...Y,...X.data})),X.user&&typeof X.user=="object"?Wt(Y=>({...Y,user:X.user})):Wt(Y=>({...Y})),_e.current[R.replace(/^\//,"")]={response:X};for(const[Y,wt]of Object.entries(Gi.current))if(wt===R||wt.endsWith(R)){const _t=_e.current[Y];_e.current[Y]={items:Array.isArray(_t)?_t:Array.isArray(_t==null?void 0:_t.items)?_t.items:[],response:X}}const lt=(ft=(G=X.subscribe)==null?void 0:G.websocket)==null?void 0:ft.workflowChannel;lt&&(M==null?void 0:M.mergeResponse)!==!1&&Wt(Y=>{var wt,_t,Vt,ne;return{...Y,liveCastChannel:lt,execution_id:X.draftId||Y.execution_id,id:X.sessionId||Y.id,status:"running",test_session:{...Y.test_session||{},id:X.sessionId||((wt=Y.test_session)==null?void 0:wt.id),execution_id:X.draftId||((_t=Y.test_session)==null?void 0:_t.execution_id),status:"running",liveCastChannel:lt,prompt:(F==null?void 0:F.prompt)||((Vt=Y.test_session)==null?void 0:Vt.prompt),url:(F==null?void 0:F.url)||((ne=Y.test_session)==null?void 0:ne.url)}}}),Ie(R,(M==null?void 0:M.refetchScope)||(S!=="GET"?"view":void 0));const at=M==null?void 0:M.feedback,Q=typeof at=="string"?at:at==null?void 0:at.transport;if(Q&&X.jobId&&(X.token||(Pt=X.subscribe)!=null&&Pt.sse||typeof at=="object")){let Y;if(typeof at=="object"&&at.subscribeUrl){const wt=String(at.subscribeUrl).trim(),_t=wt.startsWith("{{")&&wt.endsWith("}}")?wt.slice(2,-2).trim():wt,Vt=_t.match(/^\[(.+?)\](?:\.(.*))?$/),ne=Vt?Zn(`${Vt[1]}${Vt[2]?"."+Vt[2]:""}`):_t.split(".").reduce((je,Me)=>je==null?void 0:je[Me],X);ne&&(Y=/^https?:\/\//.test(ne)?ne:O+ne)}if(Y){gs(Q,X.jobId,X.token,{sseUrl:Y,onProgress:wt=>{l==null||l(wt);const _t=Date.now();_t-fi.current>=2e3&&(fi.current=_t,Ie(R,M==null?void 0:M.refetchScope))},onComplete:wt=>{const _t=(wt==null?void 0:wt.result)??wt;if(_t&&typeof _t=="object"){const Vt=R.replace(/^\//,"");_e.current[Vt]={response:_t},Wt(ne=>({...ne}))}Ie(R,M==null?void 0:M.refetchScope)},onFailed:wt=>{Ie(R,M==null?void 0:M.refetchScope),wt.kind!=="transport"&&he(wt.message||"Job failed","error")}});return}gs(Q,X.jobId,X.token,{onComplete:wt=>{const _t=wt||{},Vt=_t.total,ne=_t.successful;Vt!==void 0&&he(ne>=Vt?`${ne} completed`:`${ne} of ${Vt} completed`,"success"),Ie(R,M==null?void 0:M.refetchScope)},onFailed:wt=>{if(wt.kind==="transport"){Ie(R,M==null?void 0:M.refetchScope);return}he(wt.message||"Job failed","error"),Ie(R,M==null?void 0:M.refetchScope)}})}},An=w=>{var B,R;Pe(null);const M=w==="/"&&(((B=ht.find(z=>z.route==="/"))==null?void 0:B.id)||((R=ht.find(z=>z.type==="render_scene"))==null?void 0:R.id))||w;if(kt(M)&&!Ot){$e.current=M,ye(!0);return}Lt(z=>[...z,vt]),Ze(M)},Ir=(w,M="error")=>{if(Wt(S=>({...S,gateTitle:w.uiTitle||"Usage Notice",gateMessage:w.message})),w.uiVariant!=="modal"){const S=w.uiTitle?`${w.uiTitle}
92
+ ${w.message}`:w.message;he(S,M);return}if(w.modalId&&ve[w.modalId]){Pe({id:w.modalId,definition:ve[w.modalId]});return}Pe({id:"__legacy",definition:{title:w.uiTitle||"Usage Notice",components:[{type:"text",text:w.message,color:Jt.colorMode==="light"?"rgba(0,0,0,0.65)":"rgba(255,255,255,0.7)",fontSize:14}],actions:[{label:"OK",variant:"primary",dismiss:!0}]}})},Zs=(w,M)=>{const S=w.body;if(!S)return!1;const B=typeof(S==null?void 0:S.message)=="string"&&S.message||w.errors[0]||"Request blocked by limits",R=()=>Ir({message:B,uiVariant:S.uiVariant,uiTitle:typeof(S==null?void 0:S.uiTitle)=="string"?S.uiTitle:void 0,modalId:typeof(S==null?void 0:S.modalId)=="string"?S.modalId:void 0});return S.gateAction==="login"?(On("login"),!0):S.gateAction==="upgrade"?S.uiVariant==="modal"||typeof(S==null?void 0:S.modalId)=="string"?(R(),!0):M!=null&&M.upgradeScene?(An(M.upgradeScene),!0):(R(),!0):S.gateAction==="block"||S.gateAction==="warn"||S.warning?(R(),!0):!1};v.useEffect(()=>{if(!Ot||tt)return;const w=$e.current;!w||!ht.some(M=>M.id===w)||($e.current=null,An(w))},[Ot,tt,ht]);const he=(w,M="success",S)=>{const B=Array.isArray(w)?w.join(`
93
+ `):w,R=M==="success",z=R?"#10B981":"#EF4444",O=Jt.toast||{},F=S??O.duration??3e3,W=O.position||"bottom-right",X={"bottom-right":{right:"24px",bottom:"24px"},"bottom-left":{left:"24px",bottom:"24px"},"bottom-center":{left:"50%",bottom:"24px",transform:"translateX(-50%)"},"top-right":{right:"24px",top:"24px"},"top-left":{left:"24px",top:"24px"},"top-center":{left:"50%",top:"24px",transform:"translateX(-50%)"}},lt=X[W]||X["bottom-right"],at=document.createElement("div"),Q=document.createElement("span");Q.textContent=R?"✓":"✕",Object.assign(Q.style,{display:"flex",alignItems:"center",justifyContent:"center",width:"22px",height:"22px",minWidth:"22px",borderRadius:"50%",backgroundColor:`${z}26`,color:z,fontSize:"12px",fontWeight:"700"});const mt=document.createElement("span");mt.textContent=B,Object.assign(mt.style,{color:"rgba(255, 255, 255, 0.92)",fontSize:"13.5px",lineHeight:"1.45",whiteSpace:"pre-line"}),Object.assign(at.style,{position:"fixed",...lt,zIndex:"2147483647",display:"flex",alignItems:"flex-start",gap:"10px",padding:"12px 16px",borderRadius:"12px",backgroundColor:"rgba(23, 25, 35, 0.97)",border:"1px solid rgba(148, 163, 184, 0.25)",boxShadow:"0 8px 28px rgba(0, 0, 0, 0.4)",maxWidth:"380px",opacity:"0",pointerEvents:"auto"}),at.appendChild(Q),at.appendChild(mt),document.body.appendChild(at),at.animate([{opacity:0,transform:"translateX(24px)"},{opacity:1,transform:"translateX(0)"}],{duration:250,easing:"cubic-bezier(0.16, 1, 0.3, 1)",fill:"both"}).finished.catch(()=>{});const ft=()=>{at.animate([{opacity:1,transform:"translateX(0)"},{opacity:0,transform:"translateX(16px)"}],{duration:200,easing:"ease",fill:"both"}).finished.then(()=>at.remove()).catch(()=>at.remove())};return F>0&&setTimeout(ft,F),{update:Pt=>{mt.textContent=Array.isArray(Pt)?Pt.join(`
94
+ `):Pt},dismiss:ft}},Xi=(w,M=!0)=>{if(M&&(w!=null&&w.onSuccess)){const S=Array.isArray(w.onSuccess)?w.onSuccess:[w.onSuccess];for(const B of S){const{type:R,value:z,title:O,key:F}=B;switch(R){case"toast":he(z||"Success!","success");break;case"navigate":z&&An(z);break;case"redirect":z&&(window.location.href=z);break;case"modal":z&&ve[z]?Pe({id:z,definition:ve[z]}):Pe({id:"__legacy",definition:{title:O||"Success",components:z?[{type:"text",text:z,color:Jt.colorMode==="light"?"rgba(0,0,0,0.65)":"rgba(255,255,255,0.7)",fontSize:14}]:[],actions:[{label:"OK",variant:"primary",dismiss:!0}]}});break;case"route":z&&Yi(z);break;case"set_data":F&&z!==void 0&&Wt(W=>({...W,[F]:z}));break}}}else!M&&(w!=null&&w.onError)&&he(w.onError.message||"An error occurred","error")},To=()=>{var je,Me,ks,Ti,ue,te,we;const w=async()=>{var Xt,Cn,si,ri,Ge,Hr;if(!me||!pe||Sn==="register"&&!Fn)return;const yt=dt(me),Dt=ie(pe);if(yt||Dt){be(yt||Dt);return}if(Sn==="register"&&Fn!==pe){Bt("confirm","Passwords do not match"),be("Passwords do not match");return}Qt(!0),be(null);try{const Yn=Sn==="login"?"/auth/login":"/auth/register",sr=`${Ln().replace(/\/+$/,"")}${Yn}`,s=Sn==="login"?{email:me,password:pe,tenantId:I}:{email:me,password:pe,displayName:me.split("@")[0],tenantId:I},a={"Content-Type":"application/json"},d=["localhost","127.0.0.1","[::1]"].includes(window.location.hostname);$&&!d&&(a["x-app-id"]=$);const g=await fetch(sr,{method:"POST",headers:a,body:JSON.stringify(s)});if(!g.ok){const rt=await g.json().catch(()=>({error:"Authentication failed"}));throw new Error(Zi(rt))}const b=await g.json();if(Array.isArray(b)||b.success===!1)throw new Error(Zi(b));const C=((Xt=b.data)==null?void 0:Xt.token)||b.token||b.accessToken||b.idToken;C&&localStorage.setItem("token",C);const D=((Cn=b.data)==null?void 0:Cn.refreshToken)||b.refreshToken;D&&localStorage.setItem("backflow_refresh_token",D);const V=((ri=(si=b.data)==null?void 0:si.user)==null?void 0:ri.id)||((Ge=b.user)==null?void 0:Ge.id)||((Hr=b.data)==null?void 0:Hr.userId);if(V&&localStorage.setItem("backflow_refresh_user_id",V),!Ot&&(Qe||Ce.current||!!$e.current)){window.location.reload();return}Ce.current=!1,Re(!0),ye(!1),st(!1),dn(""),Pn(""),ji(""),Wn({}),be(null)}catch(Yn){const sr=typeof Yn=="string"?Yn:(Yn==null?void 0:Yn.message)||JSON.stringify(Yn)||"Authentication failed";be(sr),he(sr,"error")}finally{Qt(!1)}},M=async()=>{if(!me)return;const yt=dt(me);if(yt){be(yt);return}Qt(!0),be(null);try{const Dt=await fetch("/api/auth/forgot-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:me})});if(!Dt.ok){const Xt=await Dt.json().catch(()=>({error:"Failed to send reset email"}));throw new Error(Zi(Xt))}On("reset"),Vn(""),Pn(""),be(null)}catch(Dt){const Xt=typeof Dt=="string"?Dt:(Dt==null?void 0:Dt.message)||"Failed to send reset email";be(Xt),he(Xt,"error")}finally{Qt(!1)}},S=async()=>{if(!fn||!pe)return;const yt=ie(pe);if(yt){be(yt);return}Qt(!0),be(null);try{const Dt=await fetch("/api/auth/reset-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:fn,password:pe})});if(!Dt.ok){const Xt=await Dt.json().catch(()=>({error:"Failed to reset password"}));throw new Error(Zi(Xt))}On("login"),dn(""),Pn(""),Vn(""),be(null)}catch(Dt){const Xt=typeof Dt=="string"?Dt:(Dt==null?void 0:Dt.message)||"Failed to reset password";be(Xt),he(Xt,"error")}finally{Qt(!1)}},B=yt=>{On(yt),be(null),yt!=="reset"&&(Vn(""),Pn("")),ji(""),Wn({})},R=Jt.colorMode==="dark",z=R?"#f3f4f6":"#111827",O=R?"#9ca3af":"#6b7280",F=R?"#374151":"#f3f4f6",W=R?"#4b5563":"#d1d5db",X=R?"#ffffff":"#000000",lt=R?"#000000":"#ffffff",at=R?"#1f2937":"#ffffff",Q="#ef4444",mt=(yt="12px")=>({width:"100%",padding:"12px 16px",border:`1px solid ${W}`,borderRadius:"8px",fontSize:"14px",backgroundColor:F,color:z,outline:"none",marginBottom:yt,boxSizing:"border-box"}),G=(yt,Dt,Xt,Cn,si,ri)=>v.createElement("div",{key:yt,style:{position:"relative",marginBottom:"12px"}},N("input",{key:"input",type:Hi[yt]?"text":"password",placeholder:Dt,value:Xt,onChange:Ge=>Cn(Ge.target.value),onKeyDown:Ge=>{Ge.key==="Enter"&&si()},style:{...mt("0px"),paddingRight:"40px",borderColor:ri?Q:W}}),v.createElement("button",{key:"toggle",type:"button","aria-label":Hi[yt]?"Hide password":"Show password",onClick:()=>Wn(Ge=>({...Ge,[yt]:!Ge[yt]})),style:{position:"absolute",right:"8px",top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",color:O,display:"flex",alignItems:"center",padding:"4px"}},on.renderIcon(Hi[yt]?"eye-off":"eye",16)));h||e!=null&&e.title;const ft=(je=e==null?void 0:e.config)!=null&&je.logo&&((Me=e==null?void 0:e.config)==null?void 0:Me.logo)!==""?e.config.logo:"",Pt=u||((ks=e==null?void 0:e.navigation)==null?void 0:ks.logo)||"mail",Y=[];Y.push(v.createElement("div",{key:"brand",role:"button","aria-label":"Go back home",onClick:()=>{An("/"),ye(!1),Ce.current=!1,$e.current=null},style:{display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"20px",cursor:"pointer"}},ft?v.createElement("img",{src:ft,alt:"",style:{width:"56px",height:"56px",objectFit:"contain"}}):on.renderIcon(Pt,56))),Sn==="login"?(Y.push(v.createElement("h2",{key:"title",style:{fontSize:"24px",fontWeight:700,color:z,marginBottom:"8px",textAlign:"center"}},"Sign In")),Y.push(v.createElement("p",{key:"sub",style:{fontSize:"14px",color:O,marginBottom:"24px",textAlign:"center"}},"Enter your credentials to continue")),Y.push(N("input",{key:"email",type:"email",placeholder:"Email Address",value:me,onChange:yt=>{dn(yt.target.value),Bt("email",dt(yt.target.value))},style:{...mt(),borderColor:ae.email&&me?Q:W}})),ae.email&&me&&Y.push(v.createElement("p",{key:"email-err",style:{color:Q,fontSize:"12px",marginTop:"-8px",marginBottom:"8px"}},ae.email)),Y.push(G("pass","Password",pe,yt=>{Pn(yt),Bt("pass",ie(yt))},w,!!(ae.pass&&pe))),ae.pass&&pe&&Y.push(v.createElement("p",{key:"pass-err",style:{color:Q,fontSize:"12px",marginTop:"-12px",marginBottom:"12px"}},ae.pass)),rn&&Y.push(v.createElement("p",{key:"err",style:{color:Q,fontSize:"13px",marginBottom:"12px",textAlign:"center"}},rn)),Y.push(v.createElement("button",{key:"submt",onClick:w,disabled:Ct||!me||!pe,style:{width:"100%",padding:"12px",borderRadius:"8px",fontSize:"15px",fontWeight:600,backgroundColor:Ct?R?"#4b5563":"#9ca3af":X,color:lt,border:"none",cursor:Ct?"not-allowed":"pointer",marginBottom:"8px"}},Ct?"Please wait...":"Sign In")),Y.push(v.createElement("p",{key:"forgot",style:{fontSize:"13px",color:O,textAlign:"center",cursor:"pointer",marginBottom:"16px"},onClick:()=>B("forgot")},"Forgot password?")),Y.push(v.createElement("p",{key:"sw",style:{fontSize:"13px",color:O,textAlign:"center",cursor:"pointer"},onClick:()=>B("register")},"Don’t have an account? Register"))):Sn==="register"?(Y.push(v.createElement("h2",{key:"title",style:{fontSize:"24px",fontWeight:700,color:z,marginBottom:"8px",textAlign:"center"}},"Create Account")),Y.push(v.createElement("p",{key:"sub",style:{fontSize:"14px",color:O,marginBottom:"24px",textAlign:"center"}},"Create an account to get started")),Y.push(N("input",{key:"email",type:"email",placeholder:"Email",value:me,onChange:yt=>{dn(yt.target.value),Bt("email",dt(yt.target.value))},style:{...mt(),borderColor:ae.email&&me?Q:W}})),ae.email&&me&&Y.push(v.createElement("p",{key:"email-err",style:{color:Q,fontSize:"12px",marginTop:"-8px",marginBottom:"8px"}},ae.email)),Y.push(G("pass","Password",pe,yt=>{Pn(yt),Bt("pass",ie(yt))},w,!!(ae.pass&&pe))),ae.pass&&pe&&Y.push(v.createElement("p",{key:"pass-err",style:{color:Q,fontSize:"12px",marginTop:"-12px",marginBottom:"12px"}},ae.pass)),Y.push(G("confirm","Confirm password",Fn,yt=>{ji(yt),Bt("confirm",xt(pe,yt))},w,!!(ae.confirm&&Fn))),ae.confirm&&Fn&&Y.push(v.createElement("p",{key:"confirm-err",style:{color:Q,fontSize:"12px",marginTop:"-12px",marginBottom:"12px"}},ae.confirm)),rn&&Y.push(v.createElement("p",{key:"err",style:{color:Q,fontSize:"13px",marginBottom:"12px",textAlign:"center"}},rn)),Y.push(v.createElement("button",{key:"submt",onClick:w,disabled:Ct||!me||!pe||!Fn,style:{width:"100%",padding:"12px",borderRadius:"8px",fontSize:"15px",fontWeight:600,backgroundColor:Ct?R?"#4b5563":"#9ca3af":X,color:lt,border:"none",cursor:Ct?"not-allowed":"pointer",marginBottom:"16px"}},Ct?"Please wait...":"Create Account")),Y.push(v.createElement("p",{key:"sw",style:{fontSize:"13px",color:O,textAlign:"center",cursor:"pointer"},onClick:()=>B("login")},"Already have an account? Sign In"))):Sn==="forgot"?(Y.push(v.createElement("h2",{key:"title",style:{fontSize:"24px",fontWeight:700,color:z,marginBottom:"8px",textAlign:"center"}},"Reset Password")),Y.push(v.createElement("p",{key:"sub",style:{fontSize:"14px",color:O,marginBottom:"24px",textAlign:"center"}},"Enter your email to receive a reset link")),Y.push(N("input",{key:"email",type:"email",placeholder:"Email",value:me,onChange:yt=>{dn(yt.target.value),Bt("email",dt(yt.target.value))},onKeyDown:yt=>{yt.key==="Enter"&&M()},style:{...mt("16px"),borderColor:ae.email&&me?Q:W}})),ae.email&&me&&Y.push(v.createElement("p",{key:"email-err",style:{color:Q,fontSize:"12px",marginTop:"-8px",marginBottom:"8px"}},ae.email)),rn&&Y.push(v.createElement("p",{key:"err",style:{color:Q,fontSize:"13px",marginBottom:"12px",textAlign:"center"}},rn)),Y.push(v.createElement("button",{key:"submt",onClick:M,disabled:Ct||!me,style:{width:"100%",padding:"12px",borderRadius:"8px",fontSize:"15px",fontWeight:600,backgroundColor:Ct?R?"#4b5563":"#9ca3af":X,color:lt,border:"none",cursor:Ct?"not-allowed":"pointer",marginBottom:"16px"}},Ct?"Please wait...":"Send Reset Link")),Y.push(v.createElement("p",{key:"sw",style:{fontSize:"13px",color:O,textAlign:"center",cursor:"pointer"},onClick:()=>B("login")},"Back to Sign In"))):Sn==="reset"&&(Y.push(v.createElement("h2",{key:"title",style:{fontSize:"24px",fontWeight:700,color:z,marginBottom:"8px",textAlign:"center"}},"Set New Password")),Y.push(v.createElement("p",{key:"sub",style:{fontSize:"14px",color:O,marginBottom:"24px",textAlign:"center"}},"Enter the reset code and your new password")),Y.push(N("input",{key:"code",type:"text",placeholder:"Reset code",value:fn,onChange:yt=>Vn(yt.target.value),style:mt()})),Y.push(G("pass","New password",pe,yt=>{Pn(yt),Bt("pass",ie(yt))},S,!!(ae.pass&&pe))),ae.pass&&pe&&Y.push(v.createElement("p",{key:"pass-err",style:{color:Q,fontSize:"12px",marginTop:"-12px",marginBottom:"12px"}},ae.pass)),rn&&Y.push(v.createElement("p",{key:"err",style:{color:Q,fontSize:"13px",marginBottom:"12px",textAlign:"center"}},rn)),Y.push(v.createElement("button",{key:"submt",onClick:S,disabled:Ct||!fn||!pe,style:{width:"100%",padding:"12px",borderRadius:"8px",fontSize:"15px",fontWeight:600,backgroundColor:Ct?R?"#4b5563":"#9ca3af":X,color:lt,border:"none",cursor:Ct?"not-allowed":"pointer",marginBottom:"16px"}},Ct?"Please wait...":"Reset Password")),Y.push(v.createElement("p",{key:"sw",style:{fontSize:"13px",color:O,textAlign:"center",cursor:"pointer"},onClick:()=>B("login")},"Back to Sign In")));const wt=((Ti=e==null?void 0:e.config)==null?void 0:Ti.auth)||{},_t=wt.style==="page"?"page":"modal",Vt=wt.containerStyle||{},ne=v.createElement("div",{key:"auth-box",style:{width:"100%",maxWidth:_t==="page"?"400px":"360px",padding:"24px",backgroundColor:"#000000",borderRadius:"12px",...Vt}},...Y);if(_t==="page"){const yt=((ue=Jt.colors)==null?void 0:ue.primary)||"#4f46e5",Dt=wt.coverImage?`url(${wt.coverImage}) center/cover no-repeat`:yt,Xt=(te=e==null?void 0:e.config)!=null&&te.logo&&((we=e==null?void 0:e.config)==null?void 0:we.logo)!==""?e.config.logo:"",Cn=Xt?v.createElement("img",{src:Xt,alt:"",style:{position:"absolute",bottom:"-6%",left:"50%",width:"90%",maxWidth:"660px",height:"auto",objectFit:"contain",transform:"translateX(-50%) rotate(-8deg)",opacity:.92,filter:"brightness(0) invert(1)"}}):v.createElement("div",{style:{color:"#ffffff",opacity:.95}},on.renderIcon(Pt,96));return v.createElement("div",{key:"auth-page",style:{position:"fixed",top:0,left:0,right:0,bottom:0,display:"flex",backgroundColor:at,zIndex:1e4,animation:"bf-fade-in 0.2s ease"}},v.createElement("div",{style:{flex:Vi?"1 1 100%":"0 0 40%",display:"flex",alignItems:"center",justifyContent:"center",padding:"24px",backgroundColor:"#000000"}},ne),v.createElement("div",{style:{flex:"0 0 60%",background:Dt,display:Vi?"none":"flex",alignItems:"center",justifyContent:"center",position:"relative",overflow:"hidden"}},Cn))}return v.createElement("div",{key:"auth-form",style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4,animation:"bf-fade-in 0.15s ease"}},ne)},Zt=async(w,M,S)=>{var B,R;try{let z=String(Dr(w)??"");const O=z.match(/^\{\{\s*(.+?)\s*\?\s*(.*?)\s+:\s+(.*?)\s*\}\}$/);O&&(z=Ro(O[1])?O[2]:O[3]);const F=z.split(";").map(G=>G.trim()).filter(Boolean);if(F.length>1){for(const G of F)await Zt(G,void 0,S);return}if(z==="go_back"){mi();return}if(z==="toggle_theme"){ms((ee._colorMode||Jt.colorMode)==="dark"?"light":"dark");return}if(z==="close_modal"){un();return}const W=z.match(/^(toast|show_toast):(.*)$/);if(W){const G=W[2].trim();G&&he(G,"success");return}const X=z.match(/^scroll_to:([\w-]+)$/);if(X){(B=document.getElementById(X[1]))==null||B.scrollIntoView({behavior:"smooth",block:"start"});return}const lt=z.match(/^set_data:([\w.]+)=(.*)$/);if(lt){Wt(G=>({...G,[lt[1]]:lt[2]}));return}const at=z.match(/^native:([a-z][\w.-]*)$/i);if(at){if(!r){he("Native app required","error");return}const G=at[1],ft=await r(G,ee);if(ft&&typeof ft=="object"&&!Array.isArray(ft)){const Pt=G.replace(/[^\w]/g,"_");Wt(Y=>({...Y,native:{...Y.native||{},[Pt]:ft}}))}return}const Q=z.match(/^copy_to_clipboard:(.*)$/);if(Q){const G=Q[1];try{await navigator.clipboard.writeText(G)}catch{const ft=document.createElement("textarea");ft.value=G,ft.style.position="fixed",ft.style.opacity="0",document.body.appendChild(ft),ft.select(),document.execCommand("copy"),ft.remove()}he("API key copied","success");return}const mt=z.match(/^auth:(login|register|forgot|reset|logout)$/);if(mt){if(mt[1]==="logout"){if(!Ot)return;localStorage.removeItem("token"),localStorage.removeItem("backflow_refresh_token"),localStorage.removeItem("backflow_refresh_user_id"),Ce.current=!1,$e.current=null,Re(!1),ye(!1),bt(null),st(!1),An("/");return}if(Ot)return;be(null),On(mt[1]),ye(!0);return}if(z==="accept_startup_modal"){const G=Jt.startupModal;G&&localStorage.setItem(`backflow_startup_modal_${G}`,"1"),un();const ft=ht.find(Pt=>Pt.route==="/");ft&&(Lt(Pt=>[...Pt,vt]),Ze(ft.id));return}if(z==="decline_startup_modal"){un();const G=ht.find(ft=>ft.route==="/");G&&(Lt(ft=>[...ft,vt]),Ze(G.id));return}if(z==="toggle_select"){Wt(G=>({...G,_selectMode:!G._selectMode,...G._selectMode?{_selIds:[]}:{}}));return}if(z.startsWith("go_to_step:"))An(z.replace("go_to_step:","")),Xi(M,!0);else if(z.startsWith("navigate:"))An(z.replace("navigate:","")),Xi(M,!0);else if(co(z)&&t){const G=eo(z),ft=await pa(t,G,ee);ft!=null&&ft.data?Wt(Pt=>({...Pt,...ft.data})):ft&&typeof ft=="object"&&!Array.isArray(ft)&&Wt(Pt=>({...Pt,...ft})),ft!=null&&ft.url&&String(ft.url).startsWith("http")&&window.open(String(ft.url),"_blank","noopener,noreferrer"),Xi(M,!0)}else if(z.startsWith("show_modal:")){const G=z.replace("show_modal:","");if(ve[G]){const ft=ve[G];if(Kn(ft.popover&&(S!=null&&S.anchorElement)?S.anchorElement.getBoundingClientRect():null),Wi.current=ft.popover&&(S==null?void 0:S.anchorElement)||null,En.current&&typeof En.current=="object"){const wt=Object.keys(En.current);Wt(_t=>{const Vt={..._t};for(const ne of qi.current)wt.includes(ne)||delete Vt[ne];return{...Vt,...En.current}}),qi.current=wt}const Pt=ft.clearFormKeys;Array.isArray(Pt)&&Pt.length>0&&Wt(wt=>{const _t={...wt};for(const Vt of Pt)delete _t[Vt];return _t});const Y=ft.defaults;Y&&typeof Y=="object"&&Wt(wt=>{const _t={...wt};for(const[Vt,ne]of Object.entries(Y))_t[Vt]===void 0&&(_t[Vt]=ne);return _t}),ft.preload&&await Yi(String(ft.preload)),(ce==null?void 0:ce.id)===G||(Ke==null?void 0:Ke.id)===G||(ce?xi({id:G,definition:ft}):Pe({id:G,definition:ft}))}else{const ft=G.split("|");Pe({id:"__legacy",definition:{title:ft[0]||"Notice",components:ft[1]?[{type:"text",text:ft[1],color:"rgba(255,255,255,0.7)",fontSize:14}]:[],actions:[{label:"OK",variant:"primary",dismiss:!0}]}})}Xi(M,!0)}else z.startsWith("execute_workflow:")?(await Yi(z.replace("execute_workflow:",""),S),Xi(M,!0)):z.startsWith("fetch:")&&(await Yi(z.replace("fetch:",""),S),o==null||o(z.replace("fetch:","")),Xi(M,!0))}catch(z){if(oa("[handleButtonClick] caught error:",z,"callbacks:",M),z instanceof pn){if(Zs(z,M==null?void 0:M.onError))return;he(z.errors.length>1?z.errors:z.errors[0],"error")}else(R=M==null?void 0:M.onError)!=null&&R.message?he(M.onError.message,"error"):he(z instanceof Error?z.message:"An error occurred","error")}},Po=w=>{const M=w&&typeof w=="object"&&"_seconds"in w?new Date(w._seconds*1e3):new Date(w);if(isNaN(M.getTime()))return String(w??"");const S=Math.floor((Date.now()-M.getTime())/6e4);if(S<1)return"just now";if(S<60)return`${S}m ago`;const B=Math.floor(S/60);if(B<24)return`${B}h ago`;const R=Math.floor(B/24);return R<7?`${R}d ago`:M.toLocaleDateString()},Fe=(w,M)=>{if(M==="timeago")return Po(w);const S=w&&typeof w=="object"&&"_seconds"in w?new Date(w._seconds*1e3):new Date(w);if(!isNaN(S.getTime())){if(M==="date")return S.toLocaleDateString();if(M==="time")return S.toLocaleTimeString();if(M==="datetime")return S.toLocaleString()}return String(w??"")},_e=v.useRef({}),Zn=w=>{const M=w.split(".").filter(Boolean);if(M.length===0)return;let S=_e.current[M[0]]??ee[M[0]];for(let B=1;B<M.length;B++){if(S==null)return;const R=M[B];if(Array.isArray(S))if(R==="first")S=S[0];else if(R==="last")S=S[S.length-1];else if(R==="length")S=S.length;else if(/^\d+$/.test(R))S=S[Number(R)];else if(R==="index")S=S[0];else return;else if(S&&typeof S=="object"&&Array.isArray(S.items))R==="response"?S=S.response:R==="first"?S=S.items[0]:R==="last"?S=S.items[S.items.length-1]:R==="length"?S=S.items.length:/^\d+$/.test(R)?S=S.items[Number(R)]:R==="index"?S=S.items[0]:S=S[R];else if(typeof S=="object")S=S[R];else return}return S},zr=v.useRef({}),[Us,Eo]=v.useState({}),Lo=v.useCallback(w=>(zr.current[w]||(zr.current[w]=import(w).catch(()=>fetch(w).then(M=>M.text()).then(M=>{const S={};return new Function("module","exports",M)(S,S),S.exports||S}))),zr.current[w]),[]),Ao=(w,M,S,B)=>{if(!w)return"";if(w.startsWith("sdk:")){const O=S||"",F=Us[O];if(O&&F!==void 0)return F;const W=w.slice(4);return t&&pa(t,W,{...ee,$data:_e.current}).then(X=>{Ne.current||(B&&(_e.current[B]=X),Eo(lt=>({...lt,[O]:String(X??"")})))}).catch(()=>{}),""}const R=w.match(/^([A-Za-z_]\w*)\s*\(\s*(.*?)\s*\)$/s);if(R){const O=R[1],F=Ao(R[2]);if(M){const W=Us[S||""];return S&&W!==void 0?W:(Lo(M).then(X=>{var at,Q;const lt=X&&(X[O]||((at=X.default)==null?void 0:at[O])||((Q=X.exports)==null?void 0:Q[O]))||(typeof X=="function"?X:void 0);typeof lt=="function"&&S&&Promise.resolve(lt(F,{data:_e.current})).then(mt=>{Ne.current||(B&&(_e.current[B]=mt),Eo(G=>({...G,[S]:String(mt??"")})))})}).catch(()=>{}),"")}return O==="timeago"?Po(F):O==="date"?Fe(F,"date"):O==="time"?Fe(F,"time"):O==="datetime"?Fe(F,"datetime"):O==="upper"?String(F).toUpperCase():O==="lower"?String(F).toLowerCase():String(F??"")}if(w.startsWith("{{")&&w.endsWith("}}")){const F=w.slice(2,-2).trim().split("|").map(at=>at.trim()),W=F[0],X=F[1],lt=W.startsWith("{")&&W.endsWith("}")?Zn(W.slice(1,-1)):W.startsWith("$")?Zn(W.slice(1)):ee[W];return X?Fe(lt,X):String(lt??"")}if(w.startsWith("{")&&w.endsWith("}"))return String(Zn(w.slice(1,-1))??"");const z=w.trim();return/^[A-Za-z_][\w.-]*$/.test(z)?String(Zn(z)??""):String(w??"")},Dr=w=>w?w.replace(/\{\{\s*\[([\w/.-]+)\](?:\.([\w.]+(?:\|\w+)?))?\s*(?:\|\|\s*(.+?))?\}\}/g,(M,S,B,R)=>{let z,O=B;if(B!=null&&B.includes("|")){const W=B.split("|");O=W[0],z=W[1]}const F=Zn(O?`${S}.${O}`:S);if(F!=null){const W=z?Fe(F,z):F;return Array.isArray(W)||typeof W=="object"?JSON.stringify(W):String(W)}return R!==void 0?R.replace(/^["']|["']$/g,""):""}).replace(/\{\{(\w+(?:\.\w+)*)\s*(?:\|(date|time|datetime|timeago)\s*)?(?:\|\|\s*(.+?))?\}\}/g,(M,S,B,R)=>{const z=S.split(".");let O=ee;for(const F of z)O=O==null?void 0:O[F];if(O!==void 0)return B?Fe(O,B):String(O);if(En.current){let F=En.current;for(const W of z)F=F==null?void 0:F[W];if(F!==void 0)return B?Fe(F,B):String(F)}if(z[0]==="config"){let F=e==null?void 0:e.config;for(const W of z.slice(1))F=F==null?void 0:F[W];if(F!==void 0)return String(F)}return R!==void 0?R.replace(/^["']|["']$/g,""):""}):"",Ji=(w,M)=>{if(!w)return!0;const S=z=>{var F;if(z==="auth"){const W=(F=e==null?void 0:e.auth)==null?void 0:F.signedIn;return W===void 0?Ot:W}if(z.startsWith("[")&&z.includes("]")){const W=z.indexOf("]"),X=_e.current[z.slice(1,W)],lt=z.slice(W+1).replace(/^\./,"");let at;const Q=lt.split(".").filter(Boolean);Q[0]==="response"||Q[0]==="items"?at=X:at=(X==null?void 0:X.items)??X;for(const mt of Q){if(at==null)return;Array.isArray(at)&&mt==="length"?at=at.length:at=at==null?void 0:at[mt]}return at}let O=M;for(const W of z.split("."))O=O==null?void 0:O[W];return O},B=w.trim();if(B.includes("||"))return B.split("||").some(z=>Ji(z,M));if(B.includes("&&"))return B.split("&&").every(z=>Ji(z,M));if(B.startsWith("!"))return!S(B.slice(1).trim());const R=B.match(/^(\[[^\]]+\](?:\.\w+)*|\w+(?:\.\w+)*)\s*(==|!=|>|<|>=|<=)\s*(.+)$/);if(R){const z=S(R[1]),O=R[3].trim().replace(/^["']|["']$/g,"");switch(R[2]){case"==":return String(z)===O;case"!=":return String(z)!==O;case">":return Number(z)>Number(O);case"<":return Number(z)<Number(O);case">=":return Number(z)>=Number(O);case"<=":return Number(z)<=Number(O)}}return!!S(B)},Ro=w=>Ji(w,ee),Rn=(w,M,S)=>{if(!m||f!==M&&!(c&&S&&c===S))return w;const R={...w};return m.size!==void 0&&(R.transform=`scale(${m.size/100})`,R.transformOrigin="center center"),m.spacing!==void 0&&(R.margin=`${m.spacing}px`),m.alignment&&(R.textAlign=m.alignment,m.alignment==="left"?(R.marginLeft="0",R.marginRight="auto"):m.alignment==="right"&&(R.marginLeft="auto",R.marginRight="0")),m.color&&(R.color=m.color),m.gridCols!==void 0&&(R.gridTemplateColumns=`repeat(${m.gridCols}, minmax(0, 1fr))`),m.gridGap!==void 0&&(R.gap=`${m.gridGap}px`),m.buttonBackground&&(R.background=m.buttonBackground),m.buttonTextColor&&(R.color=m.buttonTextColor),m.buttonBorderRadius!==void 0&&(R.borderRadius=`${m.buttonBorderRadius}px`),m.linkColor&&(R.color=m.linkColor),m.linkTextDecoration&&(R.textDecoration=m.linkTextDecoration),m.flexDirection&&(R.flexDirection=m.flexDirection),m.flexGap!==void 0&&(R.gap=`${m.flexGap}px`),R},Ga=(w,M)=>{const S={...w};return M.scale!==void 0&&M.scale!==100&&(S.transform=`scale(${M.scale/100})`,S.transformOrigin="center center"),M.spacing!==void 0&&M.spacing!==0&&(S.margin=`${M.spacing}px`),M.alignment&&M.alignment!=="center"&&(S.textAlign=M.alignment,M.alignment==="left"?(S.marginLeft="0",S.marginRight="auto"):M.alignment==="right"&&(S.marginLeft="auto",S.marginRight="0")),M.color&&(S.color=M.color),M.background&&(S.backgroundColor=M.background),M.borderColor&&(S.borderColor=M.borderColor),S},No=(w,M,S)=>{const B=S==null?void 0:S.componentClass,z=f===w||c&&B&&c===B,O=S?Ga(M,S):M,F=Rn(O,w,B);S!=null&&S.fieldSpan&&S.fieldSpan>1&&(F.gridColumn=`span ${S.fieldSpan} / span ${S.fieldSpan}`),S!=null&&S.rawStyle&&Object.assign(F,S.rawStyle);const W=Et==="css-driven"?{"data-bf-r":`${Be}-${w}`}:{};if(z){const lt=F.boxShadow?`${F.boxShadow}, `:"";return{"data-component-key":w,...W,style:{...F,boxShadow:`${lt}0 0 0 3px ${Jt.colors.primary}`}}}return Object.keys(F).length>0?{"data-component-key":w,...W,style:F}:{"data-component-key":w,...W}},ei=(w,M)=>{var O;if(!w)return{};const S=ac(w),B=w.split(/\s+/).filter(F=>!/^(sm|md|lg|xl|2xl):/.test(F)).join(" "),R=Rt(B||"flex");if(!oc(S))return R;if(Et==="css-driven"){const F={flexDirection:"fd",gap:"gap",width:"w",alignItems:"items",justifyContent:"justify",display:"display",fontSize:"text",borderRadius:"radius",padding:"p",paddingLeft:"px",paddingRight:"px",paddingTop:"py",paddingBottom:"py",margin:"m",marginTop:"mt",marginRight:"mr",marginBottom:"mb",marginLeft:"ml"},W=(X,lt)=>`var(--bf-${F[X]||X}-${M}, ${R[X]||lt})`;if(S.flexDirection.size>0&&(R.flexDirection=W("flexDirection","column")),S.gap.size>0&&(R.gap=W("gap","0px")),S.width.size>0&&(R.width=W("width","auto")),S.alignItems.size>0&&(R.alignItems=W("alignItems","stretch")),S.justifyContent.size>0&&(R.justifyContent=W("justifyContent","flex-start")),S.display.size>0&&(R.display=W("display","flex")),S.gridCols.size>0){const X=R.gridTemplateColumns||"1",lt=typeof X=="string"?(O=X.match(/^repeat\((\d+)/))==null?void 0:O[1]:X;R.gridTemplateColumns=`repeat(var(--bf-cols-${M}, ${lt||"1"}), minmax(0, 1fr))`}return S.textSize.size>0&&(R.fontSize=W("fontSize","1rem")),S.borderRadius.size>0&&(R.borderRadius=W("borderRadius","0px")),S.padding.p.size>0&&(R.padding=W("padding","0px")),S.padding.px.size>0&&(R.paddingLeft=W("paddingLeft","0px"),R.paddingRight=W("paddingRight","0px")),S.padding.py.size>0&&(R.paddingTop=W("paddingTop","0px"),R.paddingBottom=W("paddingBottom","0px")),S.margin.all.size>0&&(R.margin=W("margin","0px")),S.margin.t.size>0&&(R.marginTop=W("marginTop","0px")),S.margin.r.size>0&&(R.marginRight=W("marginRight","0px")),S.margin.b.size>0&&(R.marginBottom=W("marginBottom","0px")),S.margin.l.size>0&&(R.marginLeft=W("marginLeft","0px")),S.margin.x.size>0&&(R.marginLeft=W("marginLeft","0px"),R.marginRight=W("marginRight","0px")),S.margin.y.size>0&&(R.marginTop=W("marginTop","0px"),R.marginBottom=W("marginBottom","0px")),R}const z=_n;if(S.flexDirection.size>0&&(R.flexDirection=It(S.flexDirection,z,"column")),S.gap.size>0&&(R.gap=It(S.gap,z,"0px")),S.width.size>0&&(R.width=It(S.width,z,"auto")),S.alignItems.size>0&&(R.alignItems=It(S.alignItems,z,"stretch")),S.justifyContent.size>0&&(R.justifyContent=It(S.justifyContent,z,"flex-start")),S.display.size>0&&(R.display=It(S.display,z,"flex")),S.gridCols.size>0){const F=It(S.gridCols,z,1);R.gridTemplateColumns=`repeat(${F}, minmax(0, 1fr))`}return S.textSize.size>0&&(R.fontSize=It(S.textSize,z,"1rem")),S.borderRadius.size>0&&(R.borderRadius=It(S.borderRadius,z,"0px")),S.padding.p.size>0&&(R.padding=It(S.padding.p,z,"0px")),S.padding.px.size>0&&(R.paddingLeft=It(S.padding.px,z,"0px"),R.paddingRight=It(S.padding.px,z,"0px")),S.padding.py.size>0&&(R.paddingTop=It(S.padding.py,z,"0px"),R.paddingBottom=It(S.padding.py,z,"0px")),S.margin.all.size>0&&(R.margin=It(S.margin.all,z,"0px")),S.margin.t.size>0&&(R.marginTop=It(S.margin.t,z,"0px")),S.margin.r.size>0&&(R.marginRight=It(S.margin.r,z,"0px")),S.margin.b.size>0&&(R.marginBottom=It(S.margin.b,z,"0px")),S.margin.l.size>0&&(R.marginLeft=It(S.margin.l,z,"0px")),S.margin.x.size>0&&(R.marginLeft=It(S.margin.x,z,"0px"),R.marginRight=It(S.margin.x,z,"0px")),S.margin.y.size>0&&(R.marginTop=It(S.margin.y,z,"0px"),R.marginBottom=It(S.margin.y,z,"0px")),R},$r=v.useRef(new Map),Io=v.useCallback(async w=>{const M=$r.current.get(w);if(M)return M;try{const S=i||localStorage.getItem("token")||"",B=await fetch(`/api/admin/schema?collection=${encodeURIComponent(w)}`,{headers:{Authorization:`Bearer ${S}`}});if(!B.ok)return null;const R=await B.json(),O=(Array.isArray(R)?R:Array.isArray(R==null?void 0:R.data)?R.data:[]).find(F=>F.collection===w)||null;return $r.current.set(w,O),O}catch{return null}},[i]),on={cfg:Jt,sdk:t,renderMode:Et,scopeId:Be,widgets:Array.isArray(e==null?void 0:e.widgets)?e.widgets:[],widgetStack:[],parseClassName:Rt,containerWidth:_n,interactionDisabled:y,previewMode:it,isAuthenticated:Ot,styleOverrides:m,selectedComponentKey:f,selectedComponentClass:c,sceneData:ee,setSceneData:Wt,setColorMode:w=>ms(w),portalTarget:Se.current,imageErrors:fs,setImageErrors:vi,handleButtonClick:Zt,interpolateText:Dr,evaluateExpression:Ao,evaluateCondition:Ro,showToast:he,setActiveModal:Pe,dismissModal:un,setOverlayModal:xi,dismissOverlayModal:Vs,fetchListData:Ve,fetchEntitySchema:Io,goBack:mi,currentSceneId:vt,isMobileView:Vi,navigateToScene:An,mobileMenuOpen:gt,setMobileMenuOpen:Oi,renderComponent:(w,M,S)=>fa(on,w,M,S),renderIcon:(w,M,S)=>(n==null?void 0:n(w,M,S))??kc(w,M,S),getCommonProps:No,imageReplacements:_,listData:gi,rowContextRef:En,uploadFile:Ar,runBulkSelectAction:Rr,selectDynamicOptions:Ii,setSelectDynamicOptions:zi,loading:Bn,buttonLoading:$i,withLoading:Hs,paginationState:Ue,renderPhaserGame:j,parseClassNameResponsive:ei};let gn=[];const zo=v.useMemo(()=>{const w={};for(const[M,S]of Object.entries(ee))M.startsWith("_")||(w[M]=S);return JSON.stringify(w)},[ee]),vs=v.useRef({}),Br=v.useRef(""),Or=v.useRef({}),qs=v.useRef(Ue);qs.current=Ue;const Do=v.useRef(Bn);Do.current=Bn;const Gs=v.useRef({}),Ys=v.useRef(new Set),Un=v.useRef(null);v.useEffect(()=>{if(!se||!Ot){wn.current.forEach(M=>M()),wn.current.clear(),Qn.current.clear();return}const w=M=>{var B;const S=M.getAttribute("data-bf-scroll-load");!S||Ys.current.has(S)||(Ys.current.add(S),(B=Un.current)==null||B.observe(M))};Un.current||(Un.current=new IntersectionObserver(M=>{for(const S of M){if(!S.isIntersecting)continue;const B=S.target.getAttribute("data-bf-scroll-load");if(!B||Gs.current[B])continue;const R=qs.current[B],z=ti.current[B];if(!z||!(R!=null&&R.hasMore)||Do.current[B])continue;Gs.current[B]=!0;const O=Or.current[B]||1;Or.current[B]=O+1,Ve(z,B,O,R.limit,void 0,void 0,void 0,!0).finally(()=>{var F;if(Gs.current[B]=!1,S.target.isConnected){const W=S.target.getBoundingClientRect();W.bottom>-160&&W.top<(window.innerHeight||800)+160&&((F=Un.current)==null||F.observe(S.target))}})}},{rootMargin:"160px 0px"})),document.querySelectorAll("[data-bf-scroll-load]").forEach(w)},[vt,se,Ve,gi,Bn,Ue]),v.useEffect(()=>()=>{var w;(w=Un.current)==null||w.disconnect(),Un.current=null,Ys.current=new Set},[vt]),v.useEffect(()=>{if(!se)return;const w=R=>typeof R=="string"?R.replace(/\{\{\s*\[([\w/.-]+)\](?:\.([\w.]+))?\s*(?:\|\|\s*(.+?))?\}\}/g,(z,O,F,W)=>{const X=Zn(F?`${O}.${F}`:O);return X!=null?String(X):W!==void 0?W.replace(/^["']|["']$/g,""):""}).replace(/\{\{([\w.]+)\}\}/g,(z,O)=>{const F=O.split(".").reduce((W,X)=>W==null?void 0:W[X],ee);return F!=null?String(F):""}):"";Br.current!==vt&&(Br.current=vt);const M=(R,z="")=>{Array.isArray(R)&&R.forEach((O,F)=>{var at;const W=`${z}-${F}`;if((O.type==="list"||O.type==="table")&&O.dataSource){const Q=w(O.dataSource),mt=vs.current[W]!==Q;mt&&(vs.current[W]=Q,Or.current[W]=1,Ve(Q,W,0,O.pageSize||10,void 0,void 0,O.key));const G=O.realtime,ft=G?w(G.channel||""):"",Pt=G?w(G.url||""):"",Y=G?w(G.event||""):"",wt=G?`${Pt}|${ft}|${Y}`:"",_t=Qn.current.get(W)!==wt;if(G&&(mt||_t)){Qn.current.set(W,wt);const Vt=wn.current.get(W);Vt&&Vt();const ne=O.pageSize||10;let je;const Me=ue=>{if(!G.bind)return;let te=ue;try{te=typeof ue=="string"?JSON.parse(ue):ue}catch{}G.bindField&&(!te||te[G.bindField]===void 0)||te&&typeof te=="object"&&Wt(we=>({...we,[G.bind]:te}))},ks=ue=>{if(!G.filter)return!0;let te=ue;if(typeof te=="string")try{te=JSON.parse(te)}catch{return!1}return!te||typeof te!="object"?!1:Object.entries(G.filter).every(([we,yt])=>te[we]===yt)},Ti=(ue,te)=>{if(!G.onEvent||!Array.isArray(te))return;let we=ue;if(typeof we=="string")try{we=JSON.parse(we)}catch{return}const yt=we==null?void 0:we.id,Dt=te.find(Xt=>(Xt==null?void 0:Xt.id)===yt);if(Dt&&!(G.onEvent.when&&!Ji(G.onEvent.when,Dt))){if(G.onEvent.once===!0){const Xt=[W,G.onEvent.action,G.onEvent.when||"",(Dt==null?void 0:Dt.id)||yt||""].join(":");if(qe.current.has(Xt))return;qe.current.add(Xt)}En.current=Dt,qi.current=Object.keys(Dt),Wt(Xt=>({...Xt,...Dt})),Zt(G.onEvent.action,{}).catch(()=>{})}};switch(G.mode){case"poll":{const ue=G.interval||5e3,te=window.setInterval(()=>Ve(Q,W,0,ne),ue);je=()=>clearInterval(te);break}case"sse":{if(!Pt&&!ft){je=()=>{};break}const ue=i||localStorage.getItem("token")||"",te=Pt||`/events?channel=${ft}`,we=ue&&!te.includes("token=")?`${te}${te.includes("?")?"&":"?"}token=${encodeURIComponent(ue)}`:te,yt=new EventSource(we),Dt=Xt=>{ks(Xt.data)&&(Me(Xt.data),Ve(Q,W,0,ne))};Y?yt.addEventListener(Y,Dt):yt.onmessage=Dt,yt.onerror=()=>yt.close(),je=()=>yt.close();break}case"ws":{if(!Pt&&!ft){je=()=>{};break}let ue=null;const te=()=>{var yt;let we;if(ft&&((yt=t==null?void 0:t.client)!=null&&yt.createWebSocket))we=t.client.createWebSocket(ft);else{const Dt=Pt||`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws?channel=${ft}`;we=new WebSocket(Dt)}we.onmessage=Dt=>{ks(Dt.data)&&(Me(Dt.data),Ve(Q,W,0,ne).then(Xt=>{const Cn=Array.isArray(Xt)?Xt:gi[W];G.onEvent&&Ti(Dt.data,Cn);const si=ee==null?void 0:ee.id;if(si&&Array.isArray(Cn)&&Br.current===vt){const ri=Cn.find(Ge=>(Ge==null?void 0:Ge.id)===si);ri&&Wt(Ge=>({...Ge,...ri}))}}))},we.onclose=()=>setTimeout(te,3e3),ue=we};te(),je=()=>ue==null?void 0:ue.close();break}default:je=()=>{}}wn.current.set(W,je)}}if(O.type==="select"&&O.dataSource){const Q=`${W}-sel`,mt=w(O.dataSource);vs.current[Q]!==mt&&(vs.current[Q]=mt,(async()=>{try{const G=O.dataSource,ft=w(G),Pt=await fetch(ft,{headers:{Authorization:`Bearer ${i||localStorage.getItem("token")||""}`}});if(!Pt.ok)return;const Y=await Pt.json(),wt=O.dataField||"configs",_t=O.optionLabel||"label",Vt=O.optionValue||"value",ne=Y[wt]||Y.data||Y,je=Array.isArray(ne)?ne.map(Me=>({label:Me[_t]||Me.name||Me.label,value:Me[Vt]||Me.id||Me.name||Me.label})):[];zi(Me=>({...Me,[W]:je}))}catch{}})())}O.children&&M(O.children,W);const X=O.accordionItems||(O.type==="accordion"?O.items:null);Array.isArray(X)&&X.forEach((Q,mt)=>{Array.isArray(Q==null?void 0:Q.content)&&M(Q.content,`${W}-acc-${mt}-content`)}),Array.isArray(O.tabItems)&&O.tabItems.forEach((Q,mt)=>{const G=Array.isArray(Q==null?void 0:Q.content)?Q.content:Array.isArray(Q==null?void 0:Q.children)?Q.children:null;G&&M(G,`${W}-tabcontent-${mt}`)});const lt=O;if(lt.type==="widget"&&lt.widgetId){const Q=(at=e==null?void 0:e.widgets)==null?void 0:at.find(mt=>mt.id===lt.widgetId);Q&&Array.isArray(Q.components)&&M(Q.components,`${W}-${lt.widgetId}`)}})};M(gn);const S=ce||Ke,B=S?ve==null?void 0:ve[S.id]:void 0;B&&Array.isArray(B==null?void 0:B.components)&&M(B.components,"modal")},[vt,Ve,zo,ce==null?void 0:ce.id,Ke==null?void 0:Ke.id,Ot]),v.useEffect(()=>()=>{wn.current.forEach(w=>w()),wn.current.clear()},[vt]);const qn=v.useMemo(()=>{if(!se||Et!=="css-driven")return null;const w=new Map,M=(S,B)=>{S.forEach((R,z)=>{const O=`${B}-${z}`;if(R.className){const F=ac(R.className);if(oc(F)){const W=Bp(Be,O,F);W&&w.set(O,W)}}R.children&&M(R.children,O)})};return M(gn,""),w},[vt,gn,Et,Be]),$o=v.useRef(Ir);$o.current=Ir;const Nn=Jt.realtime,an=Nn==null?void 0:Nn.mode,bs=Nn==null?void 0:Nn.url;if(v.useEffect(()=>{if(!Ot||an!=="sse"||!bs)return;const w=i||localStorage.getItem("token");if(!w)return;let M=null,S=!1;return(async()=>{try{const B=nt||window.location.origin,R=await fetch(`${B}${bs}/token`,{headers:{Authorization:`Bearer ${w}`}});if(!R.ok)return;const{token:z}=await R.json();if(!z||S)return;M=new EventSource(`${B}${bs}/subscribe?token=${encodeURIComponent(z)}`),M.onmessage=O=>{try{const F=JSON.parse(O.data);F!=null&&F.message&&$o.current(F,"success")}catch{}},M.onerror=()=>M==null?void 0:M.close()}catch{}})(),()=>{S=!0,M==null||M.close()}},[Ot,nt,i,an,bs]),!se)return v.createElement(v.Fragment,null,OS(Tt,Kt.length,mi,T));const Gt=se,xs=Gt.backgroundColor,Xs=xs&&Wl(xs)!==(Jt.colorMode==="dark"?"dark":"light")?Wl(xs)==="dark"?ho.text:uo.text:Jt.colors.text,Qi=Gt.height!==void 0?typeof Gt.height=="number"?`${Gt.height}px`:Gt.height:void 0,Js=Gt.minHeight!==void 0?typeof Gt.minHeight=="number"?`${Gt.minHeight}px`:Gt.minHeight:void 0,Ya=Gt.className?{...Kd,display:"flex",flexDirection:"column",width:"100%",maxWidth:"100%",position:"relative",...Qi?{height:Qi}:{},...Js?{minHeight:Js}:{},backgroundColor:xs||Jt.colors.background,color:Xs,...Rt(Gt.className)}:{...Kd,display:"flex",flexDirection:"column",position:"relative",width:"100%",maxWidth:"100%",...Qi?{height:Qi}:{},...Js?{minHeight:Js}:{},backgroundColor:xs||Jt.colors.background,color:Xs},Fr=Array.isArray(Gt.components)?Gt.components:[],Xa=BS(Be),yn=(se==null?void 0:se.requireAuth)===!0||(Gt==null?void 0:Gt.requiresAuth)===!0||(tn==null?void 0:tn.requiresAuth)===!0||((Vr=tn==null?void 0:tn.config)==null?void 0:Vr.requiresAuth)===!0,Ja=(yn||Qe)&&!Ot?To():null,Qa=Ot&&yn&&J===!1&&!hi?v.createElement("div",{key:"email-banner",style:{position:"fixed",top:0,left:0,right:0,zIndex:9500,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",padding:"10px 40px",backgroundColor:Jt.colorMode==="dark"?"#78350f":"#fef3c7",color:Jt.colorMode==="dark"?"#fef3c7":"#92400e",fontSize:"13px",fontWeight:500,boxShadow:"0 2px 8px rgba(0,0,0,0.15)"}},on.renderIcon("alert-triangle",14),v.createElement("span",null,"Verify your email — check your inbox for the confirmation link."),v.createElement("button",{"aria-label":"Dismiss",onClick:()=>ui(!0),style:{position:"absolute",right:"8px",top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",color:"inherit",display:"flex",alignItems:"center",padding:"4px"}},on.renderIcon("x",16))):null,ln=e,Bo=Array.isArray(ln==null?void 0:ln.widgets)?ln.widgets:[],Ki=new Set,Qs=w=>{if(Array.isArray(w))for(const M of w)M&&M.type==="widget"&&M.widgetId&&Ki.add(M.widgetId),M&&Array.isArray(M.children)&&Qs(M.children)};Qs(Fr);for(const w of Bo)Qs(w.components);const Ks=Bo.filter(w=>Ki.has(w.id)?!1:w.sceneIds==="*"?!0:Array.isArray(w.sceneIds)?w.sceneIds.includes("*")||w.sceneIds.includes(vt):!1);gn=[...Fr],(Ss=(er=ln.layout)==null?void 0:er.header)!=null&&Ss.length?gn.splice(0,0,...ln.layout.header):(Cs=(nr=Gt==null?void 0:Gt.layout)==null?void 0:nr.header)!=null&&Cs.length&&gn.splice(0,0,...Gt.layout.header);for(const w of Ks||[]){const M=w.components||[];if(!M.length)continue;if(w.targetKey){const B=w.targetKey.split("-").filter(Boolean).map(Number);if(B.length>0){let R=gn,z=B[0];for(let F=0;F<B.length-1;F++){const W=R[B[F]];if(!W||!Array.isArray(W.children))break;R=W.children,z=B[F+1]}const O=w.targetPosition||"before";if(O==="inside"){const F=R[z];F&&(Array.isArray(F.children)||(F.children=[]),F.children.unshift(...M))}else O==="after"?R.splice(z+1,0,...M):R.splice(z,0,...M);continue}}const S=w.index??gn.length;gn.splice(S,0,...M)}(Ms=(ki=ln.layout)==null?void 0:ki.footer)!=null&&Ms.length?gn.push(...ln.layout.footer):(jr=(ir=Gt==null?void 0:Gt.layout)==null?void 0:ir.footer)!=null&&jr.length&&gn.push(...Gt.layout.footer);const Ka=qn&&qn.size>0?v.createElement("style",{key:"bf-responsive"},Array.from(qn.values()).join(`
95
+ `)):null,ii=v.createElement("style",{key:"bf-transitions"},`#${Be} * { transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease; }
93
96
  @keyframes bf-fade-in { from { opacity: 0; } to { opacity: 1; } }
94
97
  @keyframes bf-fade-out { from { opacity: 1; } to { opacity: 0; } }
95
98
  @keyframes bf-slide-in-right { from { transform: translateX(100%); } to { transform: translateX(0); } }
@@ -102,19 +105,19 @@ ${y.message}`:y.message;Vt(b,v);return}if(y.modalId&&Gt[y.modalId]){se({id:y.mod
102
105
  @keyframes bf-loader-dot-bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }
103
106
  @keyframes bf-loader-pulse { 0% { transform: scale(1); opacity: 1; } 100% { transform: scale(1.5); opacity: 0; } }
104
107
  @keyframes bf-loader-progress { 0% { transform: translateX(-100%); } 100% { transform: translateX(400%); } }
105
- #${we} .bf-loader-skeleton { background: linear-gradient(90deg, rgba(128,128,128,0.08) 25%, rgba(128,128,128,0.15) 50%, rgba(128,128,128,0.08) 75%); background-size: 200% 100%; animation: bf-shimmer 1.5s infinite ease-in-out; }
106
- #${we} .bf-loader-shimmer { background: linear-gradient(90deg, rgba(255,255,255,0.02) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.02) 75%); background-size: 200% 100%; animation: bf-shimmer 1.5s infinite ease-in-out; }
107
- #${we} .bf-loader-dot { animation: bf-loader-dot-bounce 1.4s infinite ease-in-out both; }
108
- #${we} .bf-loader-pulse { animation: bf-loader-pulse 1.5s infinite ease-out; }
109
- #${we} .bf-loader-progress-bar { animation: bf-loader-progress 1.5s infinite ease-in-out; }
110
- #${we} .bf-loader-spinner { animation: bf-spin 0.7s linear infinite; }
111
- #${we} .bf-btn-spinner { animation: bf-spin 0.7s linear infinite; }
108
+ #${Be} .bf-loader-skeleton { background: linear-gradient(90deg, rgba(128,128,128,0.08) 25%, rgba(128,128,128,0.15) 50%, rgba(128,128,128,0.08) 75%); background-size: 200% 100%; animation: bf-shimmer 1.5s infinite ease-in-out; }
109
+ #${Be} .bf-loader-shimmer { background: linear-gradient(90deg, rgba(255,255,255,0.02) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.02) 75%); background-size: 200% 100%; animation: bf-shimmer 1.5s infinite ease-in-out; }
110
+ #${Be} .bf-loader-dot { animation: bf-loader-dot-bounce 1.4s infinite ease-in-out both; }
111
+ #${Be} .bf-loader-pulse { animation: bf-loader-pulse 1.5s infinite ease-out; }
112
+ #${Be} .bf-loader-progress-bar { animation: bf-loader-progress 1.5s infinite ease-in-out; }
113
+ #${Be} .bf-loader-spinner { animation: bf-spin 0.7s linear infinite; }
114
+ #${Be} .bf-btn-spinner { animation: bf-spin 0.7s linear infinite; }
112
115
  @keyframes bf-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
113
- @keyframes bf-marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }`),Hm=De.map((y,v)=>Cr(je,y,v)),qm=Object.values(tn).some(Boolean)||Object.values(us).some(Boolean)?Mt!=null&&Mt.loadingComponent?m.createElement("div",{key:"scene-loader",style:{position:"absolute",inset:0,zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.15)",backdropFilter:"blur(1px)"}},Cr(je,Mt.loadingComponent,0,`${we}-sceneloader`)):m.createElement("div",{key:"scene-loader",style:{position:"absolute",inset:0,zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.08)"}},m.createElement("div",{className:"bf-loader-spinner",style:{width:"32px",height:"32px",border:"3px solid rgba(128,128,128,0.15)",borderTopColor:"currentColor",borderRadius:"50%"}})):null,Gm=[jm,Wm,k==="modal"&&pS(ft),Fu(zt,Et,je,Mt==null?void 0:Mt.backgroundColor,void 0,void 0,ti),_e&&_e.id!==(zt==null?void 0:zt.id)?Fu(_e,Et,je,Mt==null?void 0:Mt.backgroundColor,je.dismissOverlayModal,10001):null,qm,Pp(e,{sceneId:ot,sceneData:Pt,registry:ce.current,isAuthenticated:mt,colorMode:Et.colorMode,enabled:X,navigateToScene:on,openModal:y=>{const v=Gt[y];v&&se({id:y,definition:v})},submitReport:async y=>{const v=await fetch(new URL("/tenant/diagnostics/ui",Ge()).toString(),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s||localStorage.getItem("token")||""}`},body:JSON.stringify(y)}),b=await v.json().catch(()=>null);return{submitted:v.ok,status:v.status,body:b,report:y}}})].filter(Boolean),Ym=Et.effects.scrollBehavior||"smooth",Xm=m.createElement("style",{key:"bf-scroll-behavior"},`
116
+ @keyframes bf-marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }`),tr=gn.map((w,M)=>fa(on,w,M)),Wr=Object.values(Bn).some(Boolean)||Object.values($i).some(Boolean)?Gt!=null&&Gt.loadingComponent?v.createElement("div",{key:"scene-loader",style:{position:"absolute",inset:0,zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.15)",backdropFilter:"blur(1px)"}},fa(on,Gt.loadingComponent,0,`${Be}-sceneloader`)):v.createElement("div",{key:"scene-loader",style:{position:"absolute",inset:0,zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.08)"}},v.createElement("div",{className:"bf-loader-spinner",style:{width:"32px",height:"32px",border:"3px solid rgba(128,128,128,0.15)",borderTopColor:"currentColor",borderRadius:"50%"}})):null,tl=[Qa,Ja,P==="modal"&&FS(Tt),tf(ce,Jt,on,Gt==null?void 0:Gt.backgroundColor,void 0,void 0,Fi),Ke&&Ke.id!==(ce==null?void 0:ce.id)?tf(Ke,Jt,on,Gt==null?void 0:Gt.backgroundColor,on.dismissOverlayModal,10001):null,Wr,Tg(e,{sceneId:vt,sceneData:ee,registry:_e.current,isAuthenticated:Ot,colorMode:Jt.colorMode,enabled:K,navigateToScene:An,openModal:w=>{const M=ve[w];M&&Pe({id:w,definition:M})},submitReport:async w=>{const M=await fetch(new URL("/tenant/diagnostics/ui",Ln()).toString(),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i||localStorage.getItem("token")||""}`},body:JSON.stringify(w)}),S=await M.json().catch(()=>null);return{submitted:M.ok,status:M.status,body:S,report:w}}})].filter(Boolean),Gn=Jt.effects.scrollBehavior||"smooth",el=v.createElement("style",{key:"bf-scroll-behavior"},`
114
117
  html {
115
- scroll-behavior: ${Ym};
118
+ scroll-behavior: ${Gn};
116
119
  }
117
- `);return m.createElement(m.Fragment,null,E("style",{key:"css-reset"},Bm),Xm,Om,Um,m.createElement("div",{id:we,style:Fm,ref:gt},...Hm,...Gm))}function yS(e){return m.createElement(gS,e)}function bS(e,t,n={}){var f,p;const s=JSON.stringify(e),r=(n.colorMode||"dark")==="dark",o=n.primaryColor||(r?"#8b5cf6":"#7c3aed"),l=r?"#111827":"#f9fafb",c=r?"#1f2937":"#ffffff",h=r?"#374151":"#e5e7eb",a=((p=(f=e.config)==null?void 0:f.effects)==null?void 0:p.scrollBehavior)||"smooth",u=n.sdkEndpoint?`
120
+ `);return v.createElement(v.Fragment,null,N("style",{key:"css-reset"},Xa),el,Ka,ii,v.createElement("div",{id:Be,style:Ya,ref:Se},...tr,...tl))}function VS(e){return v.createElement(WS,e)}function jS(e,t,n={}){var y,x;const i=JSON.stringify(e),o=(n.colorMode||"dark")==="dark",l=n.primaryColor||(o?"#8b5cf6":"#7c3aed"),h=o?"#111827":"#f9fafb",u=o?"#1f2937":"#ffffff",f=o?"#374151":"#e5e7eb",c=((x=(y=e.config)==null?void 0:y.effects)==null?void 0:x.scrollBehavior)||"smooth",m=n.sdkEndpoint?`
118
121
  <script src="https://unpkg.com/@backflow.sdk/client@latest/dist/backflow.umd.js"><\/script>
119
122
  <script>
120
123
  (function() {
@@ -129,16 +132,16 @@ ${y.message}`:y.message;Vt(b,v);return}if(y.modalId&&Gt[y.modalId]){se({id:y.mod
129
132
  <meta charset="UTF-8">
130
133
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
131
134
  <title>${t}</title>
132
- <meta name="theme-color" content="${o}" />
135
+ <meta name="theme-color" content="${l}" />
133
136
  <script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"><\/script>
134
137
  <script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"><\/script>
135
- <script src="https://cdn.tailwindcss.com"><\/script>${u}
138
+ <script src="https://cdn.tailwindcss.com"><\/script>${m}
136
139
  <style>
137
- html { scroll-behavior: ${a}; }
140
+ html { scroll-behavior: ${c}; }
138
141
  * { margin: 0; padding: 0; box-sizing: border-box; }
139
- body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: ${l}; }
142
+ body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: ${h}; }
140
143
  #root { width: 100%; height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
141
- .scene-container { width: 100%; max-width: 600px; aspect-ratio: 375 / 667; background: ${c}; border-radius: 20px; border: 2px solid ${h}; overflow-y: auto; scroll-behavior: ${a}; box-shadow: 0 10px 40px rgba(0,0,0,${r?"0.5":"0.15"}); }
144
+ .scene-container { width: 100%; max-width: 600px; aspect-ratio: 375 / 667; background: ${u}; border-radius: 20px; border: 2px solid ${f}; overflow-y: auto; scroll-behavior: ${c}; box-shadow: 0 10px 40px rgba(0,0,0,${o?"0.5":"0.15"}); }
142
145
  </style>
143
146
  </head>
144
147
  <body>
@@ -146,7 +149,7 @@ ${y.message}`:y.message;Vt(b,v);return}if(y.modalId&&Gt[y.modalId]){se({id:y.mod
146
149
  <script>
147
150
  const { useState, useEffect } = React;
148
151
  const { createRoot } = ReactDOM;
149
- const workflow = ${s};
152
+ const workflow = ${i};
150
153
 
151
154
  function WorkflowApp() {
152
155
  const [currentSceneId, setCurrentSceneId] = useState(
@@ -184,4 +187,4 @@ ${y.message}`:y.message;Vt(b,v);return}if(y.modalId&&Gt[y.modalId]){se({id:y.mod
184
187
  root.render(React.createElement(WorkflowApp));
185
188
  <\/script>
186
189
  </body>
187
- </html>`}exports.BREAKPOINTS_LIST=Rf;exports.BREAKPOINT_MIN_WIDTHS=Af;exports.DARK_COLORS=ki;exports.LIGHT_COLORS=Mi;exports.UnifiedWorkflowRenderer=yS;exports.buildRouteMaps=gm;exports.buildSDKCall=lS;exports.clearMonitorLog=$a;exports.connectRemoteControl=Xu;exports.disconnectRemoteControl=Jo;exports.executeSDKCall=Mr;exports.extractSDKCall=pi;exports.fillElement=Pa;exports.findElement=Tn;exports.findElements=Wr;exports.generateComponentCSS=ym;exports.generateStandaloneHTML=bS;exports.getFeatherIcon=wp;exports.getMonitorLog=_a;exports.getSceneFromHash=Ta;exports.hasAnyResponsive=ya;exports.initBackflowAgent=Qu;exports.isAgentEnabled=Vu;exports.isSDKCall=Ci;exports.parseAlignItemsResponsive=If;exports.parseAllResponsiveClasses=ba;exports.parseBorderRadiusResponsive=Lf;exports.parseClassName=Tl;exports.parseClassNameFull=Tl;exports.parseDisplayResponsive=ml;exports.parseFlexDirectionResponsive=Pf;exports.parseGapResponsive=_f;exports.parseGridColsResponsive=pl;exports.parseJustifyResponsive=Df;exports.parseMarginResponsive=Nf;exports.parsePaddingResponsive=yl;exports.parseTextSizeResponsive=gl;exports.parseWidthResponsive=$f;exports.renderIcon=Na;exports.resolveConfig=Ju;exports.setAgentEnabled=ju;exports.setHashForScene=kr;exports.startMonitoring=Yu;exports.triggerElement=Ou;exports.useContainerWidth=zf;
190
+ </html>`}exports.BREAKPOINTS_LIST=Hm;exports.BREAKPOINT_MIN_WIDTHS=jm;exports.DARK_COLORS=ho;exports.LIGHT_COLORS=uo;exports.UnifiedWorkflowRenderer=VS;exports.buildRouteMaps=$p;exports.buildSDKCall=NS;exports.clearMonitorLog=Mc;exports.connectRemoteControl=uf;exports.disconnectRemoteControl=Fl;exports.executeSDKCall=pa;exports.extractSDKCall=eo;exports.fillElement=Sc;exports.findElement=os;exports.findElements=La;exports.generateComponentCSS=Bp;exports.generateStandaloneHTML=jS;exports.getFeatherIcon=vg;exports.getMonitorLog=Cc;exports.getSceneFromHash=bc;exports.hasAnyResponsive=oc;exports.initBackflowAgent=df;exports.isAgentEnabled=sf;exports.isSDKCall=co;exports.parseAlignItemsResponsive=Ym;exports.parseAllResponsiveClasses=ac;exports.parseBorderRadiusResponsive=Jm;exports.parseClassName=wh;exports.parseClassNameFull=wh;exports.parseDisplayResponsive=ah;exports.parseFlexDirectionResponsive=Zm;exports.parseGapResponsive=Um;exports.parseGridColsResponsive=lh;exports.parseJustifyResponsive=Xm;exports.parseMarginResponsive=Gm;exports.parsePaddingResponsive=hh;exports.parseTextSizeResponsive=ch;exports.parseWidthResponsive=qm;exports.renderIcon=kc;exports.resolveConfig=ff;exports.setAgentEnabled=nf;exports.setHashForScene=ma;exports.startMonitoring=hf;exports.triggerElement=rf;exports.useContainerWidth=Qm;